/**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'update' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     // set attributes from get
     if (isset($_GET['SaleGroup'])) {
         $model->attributes = $_GET['SaleGroup'];
     }
     if (isset($_POST['SaleGroup'])) {
         $model->attributes = $_POST['SaleGroup'];
         $model->imagefile = CUploadedFile::getInstance($model, 'imagefile');
         if (isset($model->imagefile)) {
             $ext = pathinfo($model->imagefile);
             $model->image = $ext['extension'];
         }
         if ($model->save()) {
             if (isset($model->imagefile) && ($modelSettings = SiteModuleSettings::model()->find('site_module_id = 9'))) {
                 $filename = $model->id . '.' . $model->image;
                 $filepatch = '/../uploads/filestorage/sale/rubrics/';
                 $model->imagefile->saveAs(YiiBase::getPathOfAlias('webroot') . $filepatch . $filename);
                 //Обработка изображения
                 SiteModuleSettings::model()->chgImgModel($modelSettings, 'GD', 1, $model->id);
             }
             $url = isset($_POST['go_to_list']) ? $this->listUrl('index') : $this->itemUrl('update', $model->id);
             $this->redirect($url);
         }
     }
     $this->render('update', array('model' => $model));
 }
 public function init()
 {
     //Проверяю что модуль не отключен
     if (SiteModuleSettings::model()->find('site_module_id = 8 AND `status`=0')) {
         throw new CHttpException(404, 'The page can not be found.');
     }
 }
 public function init()
 {
     //Проверяю что модуль не отключен
     if (SiteModuleSettings::model()->find('site_module_id = 2 AND `status`=0')) {
         throw new CHttpException(404, 'The page can not be found.');
     }
     /*
     if (Yii::app()->user->isGuest){
         $this->redirect('/login');
     }
     */
 }
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  *
  * Typical usecase:
  * - Initialize the model fields with values from filter form.
  * - Execute this method to get CActiveDataProvider instance which will filter
  * models according to data in model fields.
  * - Pass data provider to CGridView, CListView or any similar widget.
  *
  * @return CActiveDataProvider the data provider that can return the models
  * based on the search/filter conditions.
  */
 public function search()
 {
     // @todo Please modify the following code to remove attributes that should not be searched.
     $criteria = new CDbCriteria();
     $criteria->compare('id', $this->id);
     $criteria->compare('doctor_rubrics_id', $this->doctor_rubrics_id);
     $criteria->compare('doctor_elements_id', $this->doctor_elements_id);
     $this->compareDate($criteria, 'created_at');
     $criteria_param = array('criteria' => $criteria);
     if ($settingsModel = SiteModuleSettings::model()->find('site_module_id = 10')) {
         $criteria_param['Pagination'] = array('PageSize' => (int) $settingsModel->elements_page_admin > 0 ? $settingsModel->elements_page_admin : 10);
     }
     return new CActiveDataProvider($this, $criteria_param);
 }
Esempio n. 5
0
 public function actionElement($param)
 {
     if (SiteModuleSettings::model()->find('site_module_id = 11 AND `status`=0')) {
         throw new CHttpException(404, 'The page can not be found.');
     }
     $paramArr = explode("/", $param);
     $paramArr = array_pop($paramArr);
     $paramArr = strtolower($paramArr);
     $root = PhotoRubrics::getRoot(new PhotoRubrics());
     $menu_top = array();
     //2
     $root = PhotoRubrics::model()->find('url LIKE "' . $paramArr . '"');
     $param_model = $root->descendants(1, 1)->findAll($root->id);
     //Титл и SEO
     $this->setSEO(Yii::app()->request->requestUri, 'Фотогалерея', $root->level > 1 ? $root : null);
     foreach ($param_model as $data) {
         $menu_top[$data->id]['name'] = $data->name;
         $menu_top[$data->id]['url'] = $data->url;
         $menu_top[$data->id]['image'] = $data->id . "." . $data->image;
     }
     $page = array();
     foreach ($root->ancestors()->findAll() as $data) {
         if ($data->level == 1) {
             continue;
         }
         $page[] = $data->name;
     }
     $page[] = $root->name;
     $model["title"] = $root->name;
     //implode(' / ', $page);
     $param = $root;
     $model['catalogs'] = array();
     $model['elements'] = array();
     $category = PhotoRubrics::model()->findByPk($param->id);
     $tmp_model = $category->descendants(1, 1)->findAll();
     if ($tmp_model = $category->descendants(1, 1)->findAll()) {
         //3 Категорий нет  - получаю картинки в раздела
         //$model['catalogs'] = $tmp_model;
     } else {
         //3 Категорий нет  - получаю картинки в раздела
         $model['elements'] = PhotoElements::model()->findAll('parent_id=' . $param->id . ' AND `status`=1');
     }
     //ФОТОГАЛЕРЕЯ
     //$this->title_page = 'ФОТОГАЛЕРЕЯ'.'<span>'.$page.'</span>';
     $this->render('index', array('model' => $model, 'param' => $param, 'menu_top' => $menu_top));
 }
Esempio n. 6
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  *
  * Typical usecase:
  * - Initialize the model fields with values from filter form.
  * - Execute this method to get CActiveDataProvider instance which will filter
  * models according to data in model fields.
  * - Pass data provider to CGridView, CListView or any similar widget.
  *
  * @return CActiveDataProvider the data provider that can return the models
  * based on the search/filter conditions.
  */
 public function search()
 {
     // @todo Please modify the following code to remove attributes that should not be searched.
     $criteria = new CDbCriteria();
     $criteria->compare('id', $this->id);
     $criteria->compare('name', $this->name, true);
     $criteria->compare('title', $this->title, true);
     $criteria->compare('url', $this->url, true);
     $criteria->compare('brieftext', $this->brieftext, true);
     $criteria->compare('description', $this->description, true);
     $criteria->compare('status', $this->status);
     $criteria->compare('param_design', $this->param_design);
     $this->compareDate($criteria, 'created_at');
     $criteria_param = array('criteria' => $criteria);
     if ($settingsModel = SiteModuleSettings::model()->find('site_module_id = 14')) {
         $criteria_param['Pagination'] = array('PageSize' => (int) $settingsModel->elements_page_admin > 0 ? $settingsModel->elements_page_admin : 10);
     }
     return new CActiveDataProvider($this, $criteria_param);
 }
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  *
  * Typical usecase:
  * - Initialize the model fields with values from filter form.
  * - Execute this method to get CActiveDataProvider instance which will filter
  * models according to data in model fields.
  * - Pass data provider to CGridView, CListView or any similar widget.
  *
  * @return CActiveDataProvider the data provider that can return the models
  * based on the search/filter conditions.
  */
 public function search()
 {
     // @todo Please modify the following code to remove attributes that should not be searched.
     $criteria = new CDbCriteria();
     $criteria->compare('id', $this->id);
     $criteria->compare('parent_id', $this->parent_id);
     $criteria->compare('on_main', $this->on_main);
     $criteria->compare('status', $this->status);
     $criteria->compare('before_photo', $this->before_photo, true);
     $criteria->compare('after_photo', $this->after_photo, true);
     $criteria->compare('briftext', $this->briftext, true);
     $criteria->compare('before_text', $this->before_text, true);
     $criteria->compare('after_text', $this->after_text, true);
     $this->compareDate($criteria, 'created_at');
     $criteria_param = array('criteria' => $criteria);
     if ($settingsModel = SiteModuleSettings::model()->find('site_module_id = 12')) {
         $criteria_param['Pagination'] = array('PageSize' => (int) $settingsModel->elements_page_admin > 0 ? $settingsModel->elements_page_admin : 10);
     }
     return new CActiveDataProvider($this, $criteria_param);
 }
Esempio n. 8
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  *
  * Typical usecase:
  * - Initialize the model fields with values from filter form.
  * - Execute this method to get CActiveDataProvider instance which will filter
  * models according to data in model fields.
  * - Pass data provider to CGridView, CListView or any similar widget.
  *
  * @return CActiveDataProvider the data provider that can return the models
  * based on the search/filter conditions.
  */
 public function search()
 {
     // @todo Please modify the following code to remove attributes that should not be searched.
     $criteria = new CDbCriteria();
     $criteria->compare('id', $this->id);
     $criteria->compare('basket_order_id', $this->basket_order_id);
     $criteria->compare('module', $this->module, true);
     $criteria->compare('url', $this->url, true);
     $criteria->compare('item', $this->item);
     $criteria->compare('price', $this->price, true);
     $criteria->compare('trueprice', $this->trueprice, true);
     $criteria->compare('quantity', $this->quantity);
     $criteria->compare('comments', $this->comments, true);
     $this->compareDate($criteria, 'created_at');
     $criteria_param = array('criteria' => $criteria);
     if ($settingsModel = SiteModuleSettings::model()->find('site_module_id = 5')) {
         $criteria_param['Pagination'] = array('PageSize' => (int) $settingsModel->elements_page_admin > 0 ? $settingsModel->elements_page_admin : 10);
     }
     return new CActiveDataProvider($this, $criteria_param);
 }
Esempio n. 9
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  *
  * Typical usecase:
  * - Initialize the model fields with values from filter form.
  * - Execute this method to get CActiveDataProvider instance which will filter
  * models according to data in model fields.
  * - Pass data provider to CGridView, CListView or any similar widget.
  *
  * @return CActiveDataProvider the data provider that can return the models
  * based on the search/filter conditions.
  */
 public function search()
 {
     // @todo Please modify the following code to remove attributes that should not be searched.
     $criteria = new CDbCriteria();
     $criteria->compare('id', $this->id);
     $criteria->compare('name', $this->name, true);
     $criteria->compare('group_id', $this->group_id, true);
     $criteria->compare('brieftext', $this->brieftext, true);
     $criteria->compare('description', $this->description, true);
     $criteria->compare('status', $this->status);
     $criteria->compare('meta_title', $this->meta_title, true);
     $criteria->compare('image', $this->image, true);
     $criteria->compare('meta_keywords', $this->meta_keywords, true);
     $criteria->compare('meta_description', $this->meta_description, true);
     $criteria->compare('maindate', $this->maindate, true);
     $criteria->compare('keyword', $this->keyword);
     $criteria->compare('primary', $this->primary);
     $criteria_param = array('criteria' => $criteria);
     if ($settingsModel = SiteModuleSettings::model()->find('site_module_id = 6')) {
         $criteria_param['Pagination'] = array('PageSize' => (int) $settingsModel->elements_page_admin > 0 ? $settingsModel->elements_page_admin : 10);
     }
     return new CActiveDataProvider($this, $criteria_param);
 }
Esempio n. 10
0
                    <li style="<?php 
echo SiteModuleSettings::model()->find('site_module_id = 15 AND `status`=0') ? ' display:none; ' : '';
?>
" class="left-menu-title"><span><img src="/images/admin/icons/ic30.png" alt="" /></span> <a href="#" title="">Банеры </a></li>
                    <li class="no">
                        <ul>
                            <li><a href="/admin/baners/banersrubrics/index" title=""><img src="/images/admin/strela2.gif" alt="" /> Группы банеров  </a></li>
                            <li><a href="/admin/baners/banersrubrics/create" title=""><img src="/images/admin/strela2.gif" alt="" /> Добавить группу  </a></li>
                            <li><a href="/admin/baners/baners/index" title=""><img src="/images/admin/strela2.gif" alt="" /> Список банеров  </a></li>
                            <li><a href="/admin/baners/baners/create" title=""><img src="/images/admin/strela2.gif" alt="" /> Добавить баннер  </a></li>
                        </ul>
                    </li>

                    <li style="<?php 
echo SiteModuleSettings::model()->find('site_module_id = 15 AND `status`=0') ? ' display:none; ' : '';
?>
" class="left-menu-title"><span><img src="/images/admin/icons/ic23.gif" alt="" /></span> <a href="#" title="">Конструктор форм</a></li>
                    <li class="no">
                        <ul>
                            <li><a href="/admin/forms/creatingformrubrics" title=""><img src="/images/admin/strela2.gif" alt="" /> Список форм  </a></li>
                            <li><a href="/admin/forms/creatingformelements" title=""><img src="/images/admin/strela2.gif" alt="" /> Список полей форм  </a></li>
                        </ul>
                    </li>

                    <li class="left-menu-title"><span><img src="/images/admin/icons/ic22.png" alt="" /></span> <a href="#" title="">Яндекс метки  </a></li>
                    <li class="no">
                        <ul>
                            <li><a href="/admin/yandexmap/yandexmap" title=""><img src="/images/admin/strela2.gif" alt="" /> Добавить/удалить точку</a></li>
                        </ul>
                    </li>
Esempio n. 11
0
 /**
  * @param null $id - id элемента
  * @param null $type_parent - тип элемента: 1-категория, 2-товар
  */
 public function actionListchars($id = null, $type_parent = 1)
 {
     $this->breadcrumbs = array($type_parent == 1 ? 'Группы товаров' : 'Список товаров' => array('/catalog/catalog/listgroup'), 'Свойства ' => array('/catalog/catalog/listchars?id=' . (int) $id . '&type_parent=' . $type_parent));
     $model = new CatalogChars('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['CatalogChars'])) {
         $model->attributes = $_GET['CatalogChars'];
     }
     $object_name = '';
     if (!empty($id)) {
         switch ($type_parent) {
             case 1:
                 $object_name = CatalogRubrics::model()->findByPk($id)->name;
                 break;
             case 2:
                 $object_name = CatalogElements::model()->findByPk($id);
                 //Применяем к выбраному товару все характеристики которые есть у родительского каталога
                 $modelCharsAppend = CatalogChars::model()->findAll('parent_id = ' . $object_name->parent_id);
                 foreach ($modelCharsAppend as $tmp_model_chrs) {
                     CatalogChars::model()->applyCategoryChars($id, $type_parent, $tmp_model_chrs);
                 }
                 $object_name = $object_name->name;
                 break;
         }
     }
     $param[] = 'is_deleted = 0';
     if (!empty($id)) {
         $param[] = 'parent_id = ' . $id;
     }
     $param[] = 'type_parent = ' . $type_parent;
     $data['sort'] = array('defaultOrder' => 'id DESC');
     $data['Pagination'] = array('PageSize' => 100);
     if ($settingsModel = SiteModuleSettings::model()->find('site_module_id = 4')) {
         $data['Pagination'] = array('PageSize' => (int) $settingsModel->elements_page_admin > 0 ? $settingsModel->elements_page_admin : 100);
     }
     $provider = new CActiveDataProvider('CatalogChars', $data);
     $param = implode(" AND ", $param);
     $provider->criteria = $model->search($param);
     $this->render('listchars', array('model' => $model, 'provider' => $provider, 'object_name' => $object_name, 'type_parent' => $type_parent));
 }
Esempio n. 12
0
<legend><?php 
echo Yii::t("Bootstrap", "LIST.SiteModuleSettings");
?>
</legend>

<?php 
$assetsDir = Yii::app()->basePath;
$labels = SiteModuleSettings::model()->attributeLabels();
$this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'site-module-settings-grid', 'template' => "{items}\n{pager}", 'enableHistory' => true, 'dataProvider' => $model->search(), 'filter' => null, 'columns' => array(array('header' => 'Название модуля', 'name' => "Название модуля", 'value' => '$data->siteModuleName->name'), array('header' => $labels["site_module_id"], 'name' => "site_module_id", 'value' => '$data->siteModuleName->url_to_controller'), array('header' => $labels["version"], 'name' => "version"), array('header' => 'Статус', 'name' => "status", 'type' => 'raw', 'value' => function ($data) {
    return '
                    <a href="#" class="on-off-product" data-id="' . $data->id . '" data-status="' . $data->status . '">
                        <div style="margin-left:20px; width: 13px; height: 13px; border-radius: 3px; background:' . ($data->status == 1 ? 'green' : 'red') . '"></div>
                    </a>
                ';
}, 'filter' => ''), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update}', 'buttons' => array('update' => array('label' => yii::t('Bootstrap', 'PHRASE.UPDATE'), 'url' => 'CHtml::normalizeUrl(array("update", "id" => $data->id))', 'options' => array())), 'htmlOptions' => array('style' => 'white-space: nowrap')))));
?>


<script>
    //Меняем статус
    $(document).on('click', '.on-off-product', function(){
        $.ajax({
            type: 'POST',
            url: '/admin/<?php 
echo Yii::app()->controller->module->id;
?>
/<?php 
echo Yii::app()->controller->id;
?>
/ajax',
 /**
  * Manages all models.
  */
 public function actionIndex()
 {
     $this->breadcrumbs = array('Новости' => array('/news/newsrubrics/index'));
     set_time_limit(0);
     $model = new NewsRubrics();
     $category = NewsRubrics::getRoot($model);
     $category = NewsRubrics::model()->findByPk($category->id);
     $descendants = $category->descendants(1)->findAll();
     $root = "";
     $param = array();
     $param[] = 'level > 1';
     $param = implode(" AND ", $param);
     $data = array('criteria' => array('condition' => $param));
     $data['sort'] = array('defaultOrder' => 'left_key ASC');
     if ($settingsModel = SiteModuleSettings::model()->find('site_module_id = 6')) {
         $data['Pagination'] = array('PageSize' => (int) $settingsModel->elements_page_admin > 0 ? $settingsModel->elements_page_admin : 100);
     }
     $provider = new CActiveDataProvider('NewsRubrics', $data);
     $provider->criteria = $model->search($param);
     $this->render('list', array('model' => $model, 'provider' => $provider, 'root' => $root, 'categories' => $descendants));
 }
Esempio n. 14
0
 /**
  * Manages all models.
  */
 public function actionIndex()
 {
     $this->breadcrumbs = array('Отзывы' => array('/review/review'), 'Список');
     $model = new ReviewElements('search');
     $model->attachBehavior('dateComparator', array('class' => 'DateComparator'));
     $model->unsetAttributes();
     // clear any default values
     // set attributes from get
     if (isset($_GET['ReviewElements'])) {
         $model->attributes = $_GET['ReviewElements'];
     }
     $param = array();
     $data['sort'] = array('defaultOrder' => 'id DESC');
     $data['Pagination'] = array('PageSize' => 100);
     if ($settingsModel = SiteModuleSettings::model()->find('site_module_id = 7')) {
         $data['Pagination'] = array('PageSize' => (int) $settingsModel->elements_page_admin > 0 ? $settingsModel->elements_page_admin : 100);
     }
     $provider = new CActiveDataProvider('ReviewElements', $data);
     $param = implode(" AND ", $param);
     $provider->criteria = $model->search($param);
     $this->render('list', array('model' => $model, 'provider' => $provider));
 }
Esempio n. 15
0
 public function actionIndex($model = null)
 {
     if (SiteModuleSettings::model()->find('site_module_id = 4 AND `status`=0')) {
         throw new CHttpException(404, 'The page can not be found.');
     }
     $data = array();
     $filters = '';
     $data['base_url'] = Pages::getBaseUrl(4);
     if (empty($model)) {
         $model = CatalogRubrics::getRoot();
     }
     //Титл и SEO
     $this->setSEOData($model);
     $criteria = new CDbCriteria();
     $criteria->condition = "parent_id = :parent_id AND status = 1";
     $criteria->params = array(":parent_id" => $model->id);
     $criteria->order = "order_id, id";
     $count = CatalogElements::model()->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 12;
     $pages->applyLimit($criteria);
     $data['elements'] = CatalogElements::model()->findAll($criteria);
     $data['pages'] = $pages;
     $data['catalogs'] = $this->getChaildCategory($model, 1);
     $data['model'] = $model;
     $this->render('index', $data);
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = SiteModuleSettings::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'update' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $root = NewsRubrics::getRoot(new NewsRubrics());
     $catalog = $root->descendants()->findAll($root->id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     // set attributes from get
     if (isset($_GET['NewsElements'])) {
         $model->attributes = $_GET['NewsElements'];
     }
     if (isset($_POST['NewsElements'])) {
         $model->attributes = $_POST['NewsElements'];
         $model->imagefile = CUploadedFile::getInstance($model, 'imagefile');
         if (isset($model->imagefile)) {
             $ext = pathinfo($model->imagefile);
             $model->image = $ext['extension'];
         }
         if ($model->save()) {
             if (isset($model->imagefile) && ($modelSettings = SiteModuleSettings::model()->find('site_module_id = 1'))) {
                 //site_module_id = - должен указывать на id модуля в tbl_site_module
                 $filename = $model->id . '.' . $model->image;
                 $filepatch = '/../uploads/filestorage/news/elements/';
                 $model->imagefile->saveAs(YiiBase::getPathOfAlias('webroot') . $filepatch . $filename);
                 //Обработка изображения
                 SiteModuleSettings::model()->chgImgModel($modelSettings, 'GD', 2, $model->id);
             }
             $url = isset($_POST['go_to_list']) ? $this->listUrl('index') : $this->itemUrl('update', $model->id);
             $this->redirect($url);
         }
     }
     $this->render('update', array('model' => $model, 'root' => $root, 'catalog' => $catalog));
 }
Esempio n. 18
0
    <a class="btn btn-primary" style="margin-top:14px; float:left; margin-left:15px" href="/admin/<?php 
echo Yii::app()->controller->module->id;
?>
/<?php 
echo Yii::app()->controller->id;
?>
/create?id=<?php 
echo isset($_GET['id']) ? (int) $_GET['id'] : 0;
?>
"> Добавить группу</a>
    <a class="btn btn-danger" style="float:left; margin-left:15px; margin-top:14px" href="javascript: deleteselected();">Удалить отмеченные</a>
</div>


<?php 
$moduleSettings = SiteModuleSettings::model()->find('site_module_id = 4');
?>
<script>
    function selectall(){
       $('.selectCategory').prop('checked', true);
    }
    function unselectall(){
        $('.selectCategory').prop('checked', false);
    }

    //Меняем статус
    $(document).on('click', '.on-off-category', function(){
        $.ajax({
            type: 'POST',
            url: '/admin/<?php 
echo Yii::app()->controller->module->id;
Esempio n. 19
0
 /**
  * Создает изображения для  загруженых дополнительных изображений (мультизагрузка) в каталоге товаров(элементы)
  * @param null $id_element_model
  * @param string $driver
  * @return bool
  */
 public function chgImgagesCatalogModel($id_element_model = null, $driver = 'GD')
 {
     $filepatch = '../uploads/filestorage/catalog/elements/';
     $model = SiteModuleSettings::model()->find('site_module_id = 4');
     set_time_limit(0);
     $param = array();
     $param['small'] = array('coords' => $model->e_cover_small, 'crop' => $model->e_cover_small_crop, 'color' => $model->e_small_color);
     $param['medium'] = array('coords' => $model->e_cover_medium, 'crop' => $model->e_cover_medium_crop, 'color' => $model->e_medium_color);
     $param['large'] = array('coords' => $model->e_cover_large, 'crop' => $model->e_cover_large_crop, 'color' => $model->e_large_color);
     $param['admin'] = array('coords' => '100x100', 'crop' => 'Resize', 'color' => 'ffffff');
     foreach (CatalogElementsImages::model()->findAll(!empty($id_element_model) ? 'elements_id = ' . $id_element_model : '') as $dataModel) {
         foreach ($param as $name => $data) {
             if (!file_exists($filepatch . $dataModel->image_name . '.' . $dataModel->image)) {
                 continue;
             }
             $image = new EasyImage($filepatch . $dataModel->image_name . '.' . $dataModel->image, $driver);
             //$image = new EasyImage($fileOrigin, 'Imagick');  - для Imagic
             //Накладываем возяной знак
             $watermark = YiiBase::getPathOfAlias('webroot') . '/../uploads/filestorage/catalog/watermark.png';
             if ($model->watermark_type == 1 && file_exists($watermark) && $name != 'admin') {
                 $opacity = 20;
                 $watermark_pos = $model->watermark_pos;
                 //Получаем размеры водяного знака
                 $mark = new EasyImage($watermark);
                 //Позиции водной марки
                 $sizeWm = getimagesize($watermark);
                 $size = getimagesize($filepatch . $dataModel->image_name . '.' . $dataModel->image);
                 switch ($watermark_pos) {
                     case 1:
                         //Замостить
                         for ($y_i = 0; $y_i < $size[1]; $y_i = $y_i + $sizeWm[1]) {
                             for ($x_i = 0; $x_i < $size[0]; $x_i = $x_i + $sizeWm[0]) {
                                 $image->watermark($mark, $x_i, $y_i, $opacity);
                             }
                         }
                         break;
                     case 2:
                         //Изображение в нижнем левом углу
                         $x_i = 0;
                         $y_i = $size[1] - $sizeWm[1];
                         $image->watermark($mark, $x_i, $y_i, $opacity);
                         break;
                     case 3:
                         //Изображение внизу по центру
                         $x_i = $size[0] / 2 - $sizeWm[0] / 2;
                         $y_i = $size[1] - $sizeWm[1];
                         $image->watermark($mark, $x_i, $y_i, $opacity);
                         break;
                     case 4:
                         //Изображение в центре
                         //$x_i =($x/2)-($sizeWm[0]/2);
                         $x_i = $size[0] / 2 - $sizeWm[0] / 2;
                         $y_i = $size[1] / 2 - $sizeWm[1] / 2;
                         $image->watermark($mark, $x_i, $y_i, $opacity);
                         break;
                     case 5:
                         //Изображение в левом верхнем углу
                         $image->watermark($mark, 0, 0, $opacity);
                         break;
                     case 6:
                         //Изображение в нижнем правом углу
                         $x_i = $size[0] - $sizeWm[0];
                         $y_i = $size[1] - $sizeWm[1];
                         $image->watermark($mark, $x_i, $y_i, $opacity);
                         break;
                     default:
                         $image->watermark($mark, 0, 0, $opacity);
                 }
             }
             $coords = explode("x", strtolower($data['coords']));
             $x = $coords[0];
             $y = $coords[1];
             switch ($data['crop']) {
                 case 'Resize':
                     $image->resize($x, $y, EasyImage::RESIZE_AUTO);
                     break;
                 case 'horResize':
                     $image->resize($x, $y, EasyImage::RESIZE_WIDTH);
                     break;
                 case 'verResize':
                     $image->resize($x, $y, EasyImage::RESIZE_HEIGHT);
                     break;
                 case 'insertResize':
                     $image->resize($x, $y, EasyImage::RESIZE_AUTO);
                     $image->background('#' . str_replace("#", "", $data['color']), 100);
                     break;
                 case 'exactResize':
                     $image->crop($x, $y);
                     break;
                 default:
                     $image->resize($x, $y, EasyImage::RESIZE_AUTO);
             }
             //$filepatch.$dataModel->image_name.'.'.$dataModel->image
             $image->save($filepatch . $name . '-' . $dataModel->image_name . '.' . $dataModel->image);
         }
     }
     return true;
 }
Esempio n. 20
0
 public static function returnUrl($url)
 {
     $urlArr = explode("/", Yii::app()->request->requestUri . '/' . $url . '/');
     $urlArr = array_diff($urlArr, array(''));
     $modelPages = Pages::model()->find('url LIKE "' . array_shift($urlArr) . '"');
     //Не текстовая страницы - смотрю модуль
     $complite_url = $modelPages->url . '/' . $url;
     if ($modelPages->type_module != 0) {
         //Число - ищем в таблице элементов
         if (is_numeric(end($urlArr))) {
             if ($tabel_name = SiteModuleSettings::model()->getModelById($modelPages->type_module, 2)) {
                 $parent_field_name = 'group_id';
                 if (!Yii::app()->db->createCommand("show columns from " . $tabel_name . " where `Field` = '" . $parent_field_name . "'")->queryRow()) {
                     $parent_field_name = 'parent_id';
                 }
                 $modelElemetn = Yii::app()->db->createCommand()->select('id, ' . $parent_field_name)->from($tabel_name)->where('id = ' . array_pop($urlArr))->queryRow();
                 $complite_url = $modelPages->url;
                 if ((int) $modelElemetn[$parent_field_name] > 0) {
                     $tabel_name = SiteModuleSettings::model()->getModelById($modelPages->type_module, 1);
                     $url_field_name = '';
                     if (Yii::app()->db->createCommand("show columns from " . $tabel_name . " where `Field` = 'url'")->queryRow()) {
                         $url_field_name = 'url';
                     }
                     $modelCatalog = Yii::app()->db->createCommand()->select('id, name' . (!empty($url_field_name) ? ', ' . $url_field_name : ''))->from($tabel_name)->where('id = ' . (int) $modelElemetn[$parent_field_name])->queryRow();
                     if (isset($modelCatalog['url'])) {
                         $complite_url .= '/' . $modelCatalog['url'];
                     }
                 }
                 $complite_url .= '/' . $url;
             }
         } else {
             //Ссылка - таблица групп
             $tabel_name = SiteModuleSettings::model()->getModelById($modelPages->type_module, 1);
             if (!empty($tabel_name) && Yii::app()->db->createCommand("show columns from " . $tabel_name . " where `Field` = 'level'")->queryRow()) {
                 $modelCatalog = Yii::app()->db->createCommand()->select('id, parent_id, level')->from($tabel_name)->where('url LIKE "' . end($urlArr) . '"')->queryRow();
                 $model = SiteModuleSettings::model()->getModelById($modelPages->type_module, 1, 0);
                 $category = $model::model()->findByPk((int) $modelCatalog['id']);
                 if ($category = $category->ancestors()->findAll()) {
                     foreach ($category as $data) {
                         if ($data->level <= 1) {
                             continue;
                         }
                         $complite_url .= '/' . $data->url;
                     }
                 } else {
                     $complite_url .= '/' . $url;
                 }
             }
         }
     }
     return $complite_url;
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'update' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     // set attributes from get
     if (isset($_GET['DoctorElements'])) {
         $model->attributes = $_GET['DoctorElements'];
     }
     if (isset($_POST['DoctorElements'])) {
         $model->attributes = $_POST['DoctorElements'];
         $model->imagefile = CUploadedFile::getInstance($model, 'imagefile');
         if (isset($model->imagefile)) {
             $ext = pathinfo($model->imagefile);
             $model->image = $ext['extension'];
         }
         if ($model->save()) {
             //Пишем специализацию
             DoctorSpecialization::model()->deleteAll('doctor_elements_id = ' . $model->id);
             foreach ($model->doctor_rubrics_id as $key => $val) {
                 $modelSpec = new DoctorSpecialization();
                 $modelSpec->doctor_rubrics_id = $val;
                 $modelSpec->doctor_elements_id = $model->id;
                 $modelSpec->save();
             }
             if (isset($model->imagefile) && ($modelSettings = SiteModuleSettings::model()->find('site_module_id = 10'))) {
                 $filename = $model->id . '.' . $model->image;
                 $filepatch = '/../uploads/filestorage/doctor/elements/';
                 $model->imagefile->saveAs(YiiBase::getPathOfAlias('webroot') . $filepatch . $filename);
                 //Обработка изображения
                 SiteModuleSettings::model()->chgImgModel($modelSettings, 'GD', 2, $model->id);
             }
             $url = isset($_POST['go_to_list']) ? $this->listUrl('index') : $this->itemUrl('update', $model->id);
             $this->redirect($url);
         }
     }
     $this->render('update', array('model' => $model));
 }
Esempio n. 22
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  *
  * Typical usecase:
  * - Initialize the model fields with values from filter form.
  * - Execute this method to get CActiveDataProvider instance which will filter
  * models according to data in model fields.
  * - Pass data provider to CGridView, CListView or any similar widget.
  *
  * @return CActiveDataProvider the data provider that can return the models
  * based on the search/filter conditions.
  */
 public function search($param = null)
 {
     // @todo Please modify the following code to remove attributes that should not be searched.
     $criteria = new CDbCriteria();
     if (!empty($param)) {
         $criteria->condition = $param;
     }
     $criteria->compare('id', $this->id);
     $criteria->compare('order_id', $this->order_id);
     $criteria->compare('doctor_rubrics_id', $this->doctor_rubrics_id);
     $criteria->compare('name', $this->name, true);
     $criteria->compare('anonse', $this->anonse, true);
     $criteria->compare('anonse_dop', $this->anonse_dop, true);
     $criteria->compare('description', $this->description, true);
     $criteria->compare('image', $this->image, true);
     $criteria->compare('chief_doctor', $this->chief_doctor);
     $criteria->compare('status', $this->status);
     $criteria->compare('meta_title', $this->meta_title, true);
     $criteria->compare('meta_keywords', $this->meta_keywords, true);
     $criteria->compare('meta_description', $this->meta_description, true);
     $this->compareDate($criteria, 'created_at');
     $criteria_param = array('criteria' => $criteria);
     if ($settingsModel = SiteModuleSettings::model()->find('site_module_id = 10')) {
         $criteria_param['Pagination'] = array('PageSize' => (int) $settingsModel->elements_page_admin > 0 ? $settingsModel->elements_page_admin : 10);
     }
     return new CActiveDataProvider($this, $criteria_param);
 }
 /**
  * Manages all models.
  */
 public function actionIndex($id = null)
 {
     $this->breadcrumbs = array('Фотогалерея' => array('/photo/photorubrics/index'));
     set_time_limit(0);
     //получаем URL
     $base_patch = SITE_NAME_FULL . '/photo_rubrics';
     if (!empty($id)) {
         $model = PhotoRubrics::model()->findByPk((int) $id);
         if ($model) {
             $i = (int) $id;
             $array = array();
             do {
                 $model = PhotoRubrics::model()->findByPk((int) $i);
                 if (isset($model->id)) {
                     $array[] = $model->id;
                 }
                 $i = (int) $model->parent_id;
             } while ($i != 0);
             $array = array_reverse($array);
             unset($array[0]);
             foreach ($array as $value) {
                 $base_patch .= '/' . PhotoRubrics::model()->findByPk((int) $value)->url;
             }
         }
     }
     if (!empty($id)) {
         $model = PhotoRubrics::model()->findByPk((int) $id);
         $root = PhotoRubrics::getRoot($model);
         $category = PhotoRubrics::model()->findByPk((int) $id);
         //Получаем нужный узел
         $descendants = $category->descendants(1)->findAll();
         $param[] = 'left_key > ' . $model->left_key . ' AND right_key < ' . $model->right_key;
     } else {
         $model = new PhotoRubrics();
         $category = PhotoRubrics::getRoot($model);
         $category = PhotoRubrics::model()->findByPk($category->id);
         $descendants = $category->descendants(1)->findAll();
         $root = "";
         $param[] = 'level > 1';
     }
     $model = new PhotoRubrics();
     $param = implode(" AND ", $param);
     $data = array('criteria' => array('condition' => $param));
     $data['sort'] = array('defaultOrder' => 'left_key ASC');
     if ($settingsModel = SiteModuleSettings::model()->find('site_module_id = 11')) {
         $data['Pagination'] = array('PageSize' => (int) $settingsModel->elements_page_admin > 0 ? $settingsModel->elements_page_admin : 100);
     }
     $provider = new CActiveDataProvider('PhotoRubrics', $data);
     $provider->criteria = $model->search($param);
     $this->render('list', array('model' => $model, 'provider' => $provider, 'root' => $root, 'categories' => $descendants, 'base_patch' => $base_patch));
 }
Esempio n. 24
0
 /**
  * Manages all models.
  */
 public function actionIndex()
 {
     $this->breadcrumbs = array('Список альбомов' => array('/photo/photorubrics/index'), 'Просмотр альбома');
     $model = new PhotoElements('search');
     $model->attachBehavior('dateComparator', array('class' => 'DateComparator'));
     $model->unsetAttributes();
     // clear any default values
     $parent_id = 0;
     // set attributes from get
     if (isset($_GET['PhotoElements'])) {
         $model->attributes = $_GET['PhotoElements'];
         $parent_id = $_GET['PhotoElements']['parent_id'];
     }
     $dmp = var_export($_POST, true);
     file_put_contents($_SERVER["DOCUMENT_ROOT"] . "/log.txt", $dmp);
     // если это мультизагрузка, значит должен быть файл...
     if (isset($_POST['ASPSESSID'])) {
         file_put_contents($_SERVER["DOCUMENT_ROOT"] . "/log.txt", "request");
         $model_el = new PhotoElements();
         $root = PhotoRubrics::getRoot(new PhotoRubrics());
         $catalog = $root->descendants()->findAll($root->id);
         // set attributes from get
         if (isset($_GET['PhotoElements'])) {
             $model_el->attributes = $_GET['PhotoElements'];
         }
         $model_el->attributes = $_POST['PhotoElements'];
         $model_el->imagefile = CUploadedFile::getInstance($model_el, 'Filedata');
         if (isset($model_el->imagefile)) {
             $ext = pathinfo($model_el->imagefile);
             $model_el->image = $ext['extension'];
         }
         if ($model_el->save()) {
             if (isset($model_el->imagefile) && ($modelSettings = SiteModuleSettings::model()->find('site_module_id = 11'))) {
                 $filename = $model_el->id . '.' . $model_el->image;
                 $filepatch = '/../uploads/filestorage/photo/elements/';
                 $model_el->imagefile->saveAs(YiiBase::getPathOfAlias('webroot') . $filepatch . $filename);
                 //Обработка изображения
                 SiteModuleSettings::model()->chgImgModel($modelSettings, 'GD', 2, $model_el->id);
             }
         }
     }
     $param = array();
     $data['sort'] = array('defaultOrder' => 'id DESC');
     $data['Pagination'] = array('PageSize' => 100);
     if ($settingsModel = SiteModuleSettings::model()->find('site_module_id = 11')) {
         $data['Pagination'] = array('PageSize' => (int) $settingsModel->elements_page_admin > 0 ? $settingsModel->elements_page_admin : 100);
     }
     $provider = new CActiveDataProvider('PhotoElements', $data);
     $param = implode(" AND ", $param);
     $provider->criteria = $model->search($param);
     $root = PhotoRubrics::getRoot(new PhotoRubrics());
     $catalog = $root->descendants()->findAll($root->id);
     $this->render('list', array('model' => $model, 'provider' => $provider, 'root' => $root, 'parent_id' => $parent_id, 'catalog' => $catalog));
 }
Esempio n. 25
0
 /**
  * Manages all models.
  */
 public function actionIndex()
 {
     $model = new BanersElements('search');
     $model->attachBehavior('dateComparator', array('class' => 'DateComparator'));
     $model->unsetAttributes();
     // clear any default values
     // set attributes from get
     if (isset($_GET['BanersElements'])) {
         $model->attributes = $_GET['BanersElements'];
     }
     $param = array();
     $data['sort'] = array('defaultOrder' => 'id DESC');
     $data['Pagination'] = array('PageSize' => 100);
     if ($settingsModel = SiteModuleSettings::model()->find('site_module_id = 15')) {
         $data['Pagination'] = array('PageSize' => (int) $settingsModel->elements_page_admin > 0 ? $settingsModel->elements_page_admin : 100);
     }
     $provider = new CActiveDataProvider('BanersElements', $data);
     $param = implode(" AND ", $param);
     $provider->criteria = $model->search($param);
     $root = BanersRubrics::getRoot(new BanersRubrics());
     $catalog = $root->descendants()->findAll($root->id);
     $this->render('list', array('model' => $model, 'provider' => $provider, 'root' => $root, 'catalog' => $catalog));
 }
Esempio n. 26
0
    echo '<img src="' . $url_img . '" style="max-width:150px;">';
}
?>
			<br>
			<?php 
echo CHtml::activeFileField($model, 'image_watermark', array('style' => 'cursor: pointer;'));
?>
		</div>
	</div>



<?php 
//echo $form->textFieldRow($model,'watermark',array('class'=>'span5','maxlength'=>255));;
echo $form->dropDownListRow($model, 'watermark_type', array(0 => 'Отсутствует', 1 => 'Изображение PNG'), array('class' => 'span5'));
echo $form->dropDownListRow($model, 'watermark_pos', SiteModuleSettings::model()->getWatermarkMethod(), array('class' => 'span5'));
?>

<?php 
//echo $form->textFieldRow($model,'watermark_transp',array('class'=>'span5','maxlength'=>10));;
//echo $form->textFieldRow($model,'watermark_color',array('class'=>'span5','maxlength'=>80));;
//echo $form->textFieldRow($model,'watermask_font',array('class'=>'span5','maxlength'=>10));;
//echo $form->textFieldRow($model,'watermask_fontsize',array('class'=>'span5','maxlength'=>20));;
?>

</div>

<div class="block_data" style="width: 100%; background-color: #3689d8; margin-bottom: 5px; cursor: pointer;">
	<span style="color: #fff; margin-left: 10px; font-weight: bold;">Пересборка иллюстраций</span>
</div>
<div class="control-group">