public function loadUploaderConfiguration() { $uploaderConfig = GalleryConfig::model()->find(array('condition' => "type='uploader'"))->config; $this->uploaderConfig = unserialize($uploaderConfig); $galleryConfig = GalleryConfig::model()->find(array('condition' => "type='gallery'"))->config; $this->galleryConfig = unserialize($galleryConfig); }
public function actionIndex() { $galleryConfig = GalleryConfig::model()->find(); $criteria = new CDbCriteria(); $criteria->limit = $galleryConfig->limit; $dataProvider = new CActiveDataProvider('Gallery', array('criteria' => $criteria, 'sort' => array('defaultOrder' => 'sort_order'), 'pagination' => array('pageSize' => $galleryConfig->limit))); $this->render('index', array('dataProvider' => $dataProvider)); }
public function actionIndex() { $model = GalleryConfig::model()->find(); if (isset($_POST['GalleryConfig'])) { $model->attributes = $_POST['GalleryConfig']; if ($model->save()) { Yii::app()->user->setFlash('success', "Изменения успешно сохранены!"); } } $this->render('index', array('model' => $model)); }
public function __construct() { $galleryConfig = unserialize(GalleryConfig::model()->find(array('condition' => "type='gallery'"))->config); $albumConfig = unserialize(GalleryConfig::model()->find(array('condition' => "type='album'"))->config); $collectionConfig = unserialize(GalleryConfig::model()->find(array('condition' => "type='collection'"))->config); $fancyBoxConfig = unserialize(GalleryConfig::model()->find(array('condition' => "type='fancybox'"))->config); $uploaderConfig = unserialize(GalleryConfig::model()->find(array('condition' => "type='uploader'"))->config); $configs = array_merge($galleryConfig, $albumConfig, $collectionConfig, $fancyBoxConfig, $uploaderConfig); foreach ($configs as $config => $value) { $this->{$config} = $value; } }
public function updateGalleryConfig() { $type = $_POST['scenario']; $model = new Cfg($type); $model->attributes = $_POST['Cfg']; if ($model->validate()) { $record = GalleryConfig::model()->find(array('condition' => "type='{$type}'")); $attributes = array("config" => serialize($_POST['Cfg'])); $record->saveAttributes($attributes); Yii::app()->user->setFlash('succes', Yii::t('app', 'Configuration succesfully saved!')); } else { Yii::app()->user->setFlash('error', Yii::t('app', 'There are errors. Configuration wasn\'t saved! Old configuration is reloaded!')); } }
public function updateGalleryConfig() { if (isset($_POST['Cfg']['predefinedTitle'])) { $_POST['Cfg']['predefinedTitle'] = operations::purifiedTtext($_POST['Cfg']['predefinedTitle']); } $type = $_POST['scenario']; $model = new Cfg($type); $model->attributes = $_POST['Cfg']; if ($model->validate()) { $record = GalleryConfig::model()->find(array('condition' => "type='{$type}'")); $attributes = array("config" => serialize($_POST['Cfg'])); $record->saveAttributes($attributes); Yii::app()->user->setFlash('succes', $this->tr('successUpdate')); } else { Yii::app()->user->setFlash('error', $this->tr('errorUpdate')); } }
public function run() { $galleryConfig = GalleryConfig::model()->find(); $displayMode = $galleryConfig->display_mode; switch ($displayMode) { case 0: $gallery = Gallery::getFirstGallery(); break; case 1: $gallery = Gallery::getRandomGallery(); break; case 2: $gallery = Gallery::getSelectedGallery($galleryConfig->selected_gallery_id); break; } $this->render('gallery', array('gallery' => $gallery)); return parent::run(); }
protected function beforeSave() { if (parent::beforeSave()) { // Читаем конфигурацию каталога $galleryConfig = GalleryConfig::model()->findByPk(1); // Загружаем фотографии $photos = new GalleryPhoto(); if ($photosUpload = CUploadedFile::getInstances($photos, 'image')) { foreach ($photosUpload as $file) { $photo = new GalleryPhoto(); $photoName = md5(time() . $file->name) . '.' . $file->getExtensionName(); $photo->file = $photoName; $file->saveAs($this->folder . '/' . $photoName); $this->uploaded_photos[] = $photo; Yii::app()->ih->load($this->folder . '/' . $photoName)->adaptiveThumb($galleryConfig->prev_x, $galleryConfig->prev_y)->save($this->folder . '/small/' . $photoName, false, 100)->reload()->adaptiveThumb(200, 135)->save($this->folder . '/medium/' . $photoName, false, 100); } } if ($this->isNewRecord) { $this->sort_order = $this->getMaxSortOrder() + 10; } if (!empty($this->uploaded_photos)) { foreach ($this->uploaded_photos as $photo) { $photo->gallery_id = $this->id; $photo->save(); } if ($this->photos and $coverPhoto = $this->getCover()) { $this->cover_photo_id = $coverPhoto->id; } } return true; } else { return false; } }
public function cfgModel($type) { $attributes = unserialize(GalleryConfig::model()->find(array('condition' => "type='{$type}'"))->config); $model = new Cfg($type); foreach ($model as $attr => $value) { if (array_key_exists($attr, $attributes)) { $model->{$attr} = $attributes[$attr]; } else { unset($model->{$attr}); } } return $model; }
public function setStandardShop() { //operation reserved only for admins if (!$this->levelAccess === 2) { return; } $arrStandardShop = array('gallery' => array('isShopStyle' => true, 'cssTheme' => 'shop', 'thumbStyle' => 'square', 'imgWidth' => 700, 'thumbWidth' => 50, 'thWidth' => 200, 'hCollectionShop' => true, 'itemWidthCollectionShop' => 140, 'itemInfoShop' => 'ProductID' . "\n" . 'Availability' . "\n" . 'Name' . "\n" . 'Model' . "\n" . 'Price' . "\n" . 'Coin' . "\n" . 'VTA' . "\n" . 'Quantity' . "\n" . 'Url'), 'album' => array('showAlbumTitleDescription' => false, 'itemsOnPaginate' => 0, 'thTitleShow' => false, 'useInfoBox' => false), 'uploader' => array('max' => 6)); foreach ($arrStandardShop as $type => $attrs) { $config = unserialize(GalleryConfig::model()->find(array('condition' => "type='{$type}'"))->config); foreach ($attrs as $attr => $val) { $config[$attr] = $val; } $record = GalleryConfig::model()->find(array('condition' => "type='{$type}'")); $attributes = array("config" => serialize($config)); $record->saveAttributes($attributes); } return; }
private function publishForVisitor() { $baseUrl = Yii::app()->assetManager->publish($this->path->assets); $hideTooltips = (bool) $this->conf->hideTooltips; $jqcfg = CJavaScript::encode(unserialize(GalleryConfig::model()->find(array('condition' => "type='fancybox'"))->config)); if (is_dir($this->path->assets)) { Yii::app()->clientScript->registerCssFile($baseUrl . '/themes/' . $this->conf->cssTheme . '/standard.css'); Yii::app()->clientScript->registerCssFile($baseUrl . '/fancybox/jquery.fancybox-1.3.4.min.css'); Yii::app()->clientScript->registerCssFile($baseUrl . '/themes/' . $this->conf->cssTheme . '/custom.css'); //will place jquery and jquery-ui to end of page not in the head if ($this->conf->coreScriptPosEnd) { Yii::app()->clientScript->coreScriptPosition = CClientScript::POS_END; } Yii::app()->clientScript->registerCoreScript('jquery'); Yii::app()->clientScript->registerScriptFile($baseUrl . '/jquery.bttooltip.min.js', CClientScript::POS_END); if (!$this->isShop) { Yii::app()->clientScript->registerScriptFile($baseUrl . '/setThumbs.min.js', CClientScript::POS_END); Yii::app()->clientScript->registerScript('setThumbs', "setThumbsWidht('" . $this->conf->thumbWidth . "', '" . $this->conf->thumbStyle . "', '" . $this->conf->ratioThumb . "')", CClientScript::POS_READY); } else { Yii::app()->clientScript->registerScriptFile($baseUrl . '/setThumbsShop.min.js', CClientScript::POS_END); Yii::app()->clientScript->registerScript('setThumbs', "setThumbsWidht('" . $this->conf->thumbWidth . "', '" . $this->conf->thumbStyle . "', '" . $this->conf->ratioThumb . "', '" . (bool) $this->collection . "')", CClientScript::POS_READY); } Yii::app()->clientScript->registerScript('setGallery', "\$('.gImg').fancybox({$jqcfg}); \$('.ttp').bttooltip({design:'fbtooltip', hide :'{$hideTooltips}'});"); if ($this->conf->mouseEnabled) { Yii::app()->clientScript->registerScriptFile($baseUrl . '/fancybox/jquery.mousewheel-3.0.4.pack.min.js', CClientScript::POS_END); } if ($this->conf->easingEnabled) { Yii::app()->clientScript->registerScriptFile($baseUrl . '/fancybox/jquery.easing-1.3.pack.min.js', CClientScript::POS_END); } Yii::app()->clientScript->registerScriptFile($baseUrl . '/fancybox/jquery.fancybox-1.3.4.min.js', CClientScript::POS_END); } else { throw new Exception($this->tr('errFolder')); } }