Example #1
0
 public function getForm()
 {
     Yii::import('zii.widgets.jui.CJuiDatePicker');
     Yii::import('ext.BootstrapTagInput');
     Yii::app()->controller->widget('ext.tinymce.TinymceWidget');
     return new TabForm(array('showErrorSummary' => true, 'attributes' => array('class' => 'form-horizontal', 'id' => __CLASS__), 'elements' => array('content' => array('type' => 'form', 'title' => $this->t('TAB_CONTENT'), 'elements' => array('title' => array('type' => 'text', 'id' => 'title'), 'seo_alias' => array('type' => 'text', 'id' => 'alias', 'visible' => Yii::app()->settings->get('core', 'translate_object_url') ? false : true), 'category_id' => array('type' => 'dropdownlist', 'items' => Html::listData(CategoriesModel::model()->findAll(), 'id', 'name')), 'short_text' => array('type' => 'textarea', 'class' => 'editor'), 'full_text' => array('type' => 'textarea', 'class' => 'editor'), 'tags' => array('type' => 'BootstrapTagInput', 'htmlOptions' => array()))), 'seo' => array('type' => 'form', 'title' => $this->t('TAB_META'), 'elements' => array('seo_title' => array('type' => 'text'), 'seo_keywords' => array('type' => 'textarea'), 'seo_description' => array('type' => 'textarea'))), 'additional' => array('type' => 'form', 'title' => $this->t('TAB_ADDITIONALLY'), 'elements' => array('switch' => array('type' => 'dropdownlist', 'items' => array(0 => Yii::t('app', 'OFF', 0), 1 => Yii::t('app', 'ON', 0))), 'date_create' => array('type' => 'CJuiDatePicker', 'options' => array('dateFormat' => 'yy-mm-dd ' . date('H:i:s')), 'htmlOptions' => array('value' => $this->isNewRecord ? date('Y-m-d H:i:s') : $this->date_create))))), 'buttons' => array('submit' => array('type' => 'submit', 'class' => 'btn btn-success', 'label' => $this->isNewRecord ? Yii::t('app', 'CREATE', 0) : Yii::t('app', 'SAVE')))), $this);
 }
Example #2
0
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new CategoriesModel();
     }
     return self::$instance;
 }
 public function actionUpdate($new = false)
 {
     $model = $new === true ? new CategoriesModel() : CategoriesModel::model()->findByPk($_GET['id']);
     $this->pageName = Yii::t('app', 'CATEGORIES');
     $this->breadcrumbs = array($this->pageName => Yii::app()->createUrl('admin/core/categories'), $new === true ? Yii::t('app', 'CREATE', 1) : Yii::t('app', 'UPDATE', 1));
     if (isset($_POST['CategoriesModel'])) {
         $model->attributes = $_POST['CategoriesModel'];
         if ($model->validate()) {
             $model->save();
             $this->redirect(array('index'));
         }
     }
     $this->render('update', array('model' => $model));
 }
Example #4
0
 public function setCategory($category)
 {
     if (isset($category)) {
         $criteria = new CDbCriteria();
         $criteria->params = array(':cid' => $category);
         if (is_numeric($category)) {
             $criteria->addCondition('id = :cid', 'OR');
         } else {
             $criteria->addCondition('seo_alias = :cid', 'OR');
         }
         $this->_model = CategoriesModel::model()->find($criteria);
         $this->setCategory_id($this->_model->id);
     }
     return $this->_model;
 }
Example #5
0
 public function getForm()
 {
     Yii::app()->controller->widget('ext.tinymce.TinymceWidget');
     return new CMSForm(array('id' => __CLASS__, 'showErrorSummary' => true, 'attributes' => array('class' => 'form-horizontal'), 'elements' => array('name' => array('type' => 'text', 'id' => 'title'), 'seo_alias' => array('type' => 'text', 'id' => 'alias', 'visible' => !Yii::app()->settings->get('core', 'translate_object_url')), 'parent_id' => array('type' => 'dropdownlist', 'items' => Html::listData(CategoriesModel::model()->parent()->findAll(), 'id', 'name'), 'empty' => '— Выбать —'), 'module' => array('type' => 'dropdownlist', 'items' => CMS::getModules()), 'text' => array('type' => 'textarea', 'class' => 'editor'), 'date_update' => array('type' => 'text', 'value' => date('Y-m-d H:i:s'))), 'buttons' => array('submit' => array('type' => 'submit', 'class' => 'btn btn-success', 'label' => Yii::t('app', 'SAVE')))), $this);
 }
Example #6
0
 protected function get_cat()
 {
     $list = CategoriesModel::getList();
     Output::success(array("list" => $list));
 }
Example #7
0
 protected function get_cat_count($r)
 {
     Input::ensureRequest($r, array("id"));
     $id = $r["id"];
     $cats = new CategoriesModel();
     $cat = $cats->getBy(CategoriesModel::SLUG, $id);
     $col = Collection::Model($this->model);
     $col->whereEq(PostsModel::CATEGORY_ID, $cat->get("id"));
     $this->filterList($col);
     if (Input::has("q") && strlen(Input::get("q")) > 0) {
         $col->filter(Input::get("q"));
     }
     $count = $col->getCount();
     Output::success(array('count' => intVal($count), 'limit' => $this->options["limit"], 'pages' => ceil(intVal($count) / $this->options["limit"])));
 }
Example #8
0
 /**
  * Показываем список категорий текущего модуля
  * @return type
  */
 public static function getSelectCategories()
 {
     return Html::listData(CategoriesModel::model()->module()->findAll(), 'id', 'name');
 }