68 lines
2.3 KiB
PHP
68 lines
2.3 KiB
PHP
<?php
|
|
/**
|
|
* 2012 - 2020 HiPresta
|
|
*
|
|
* MODULE Gallery
|
|
*
|
|
* @author HiPresta <support@hipresta.com>
|
|
* @copyright HiPresta 2020
|
|
* @license Addons PrestaShop license limitation
|
|
* @link https://hipresta.com
|
|
*
|
|
* NOTICE OF LICENSE
|
|
*
|
|
* Don't use this module on several shops. The license provided by PrestaShop Addons
|
|
* for all its modules is valid only once for a single shop.
|
|
*/
|
|
|
|
class GalleryImage extends ObjectModel
|
|
{
|
|
public $id_image;
|
|
public $id_gallery;
|
|
public $image;
|
|
public $image_caption;
|
|
public $position;
|
|
public $date_add;
|
|
public $date_upd;
|
|
|
|
public static $definition = array(
|
|
'table' => 'higallery_image',
|
|
'primary' => 'id_image',
|
|
'multilang' => true,
|
|
'fields' => array(
|
|
'id_gallery' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true),
|
|
'image' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 255, 'required' => true),
|
|
'image_caption' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'lang' => true),
|
|
'position' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
|
|
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
|
|
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
|
|
),
|
|
);
|
|
|
|
public static function getPositionMaxValue()
|
|
{
|
|
$position = DB::getInstance()->ExecuteS('
|
|
SELECT MAX(position) FROM '._DB_PREFIX_.'higallery_image');
|
|
if (empty($position)) {
|
|
return false;
|
|
}
|
|
return $position[0]['MAX(position)'] + 1;
|
|
}
|
|
|
|
public static function getGalleryAllImages($id_gallery, $order_by = 'ASC')
|
|
{
|
|
$query = new DbQuery();
|
|
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
|
|
$query
|
|
->select('gi.*')
|
|
->select('gil.*')
|
|
->from('higallery_image', 'gi')
|
|
->leftJoin('higallery_image_lang', 'gil', 'gi.id_image = gil.id_image')
|
|
->where('gi.id_gallery = '.(int)$id_gallery)
|
|
->where('gil.id_lang = '.(int)Context::getContext()->language->id)
|
|
->orderBy('gi.position '.$order_by)
|
|
->build()
|
|
);
|
|
}
|
|
}
|