/** * create an array structure from drop downs used elsewhere */ public function sections_as_collection() { $model = new CmsCategory(); $collection = array(); foreach ($model->all() as $item) { $collection["{$item->id}"] = $item->title; } return $collection; }
/** * ajax filter function - takes the incoming string, matches against columns * and outputs view of the matching data */ public function filters() { $this->use_layout = false; $cat = new CmsCategory(); if (strlen($fil = $_POST['filter']) < 1) { $this->all_categories = $cat->order("name ASC")->all(); } else { $this->all_categories = $cat->filter("name LIKE '%{$fil}%'")->order("name ASC")->all(); } $this->cat_partial = $this->render_partial("cat_list"); }
public function __construct() { $this->server = "http://" . $_SERVER['HTTP_HOST']; if (Request::param('warned') || Session::get('warned')) { Session::set('warned', 1); $this->warned = true; } if (substr_count($_SERVER['HTTP_USER_AGENT'], "MSIE") > 0) { $this->ie = true; } $cat = new CmsCategory(); $this->all_categories = $cat->order('name ASC')->all(); }
public function actionIndex($id) { $this->processPageRequest('page'); if ($dataStr = Yii::app()->request->getParam('data')) { if (!empty($dataStr)) { if ($id == null) { $id = 1; } $data = strtotime($dataStr); $criteria = new CDbCriteria(); $criteria->condition = 'category_id =:id AND status=2 AND DATE_FORMAT(FROM_UNIXTIME(created), "%Y%m%d")=:data'; $criteria->params = array(':data' => date('Ymd', $data), ':id' => $id); $model = CmsSetting::model()->findByPk(1); $prow = new CActiveDataProvider('CmsPage', array('criteria' => $criteria, 'pagination' => array('pageSize' => $model->ct_page, 'pageVar' => 'page'))); } } else { $category = CmsCategory::model()->findByPk($id); $criteria = new CDbCriteria(); $criteria->condition = 'status = 2 AND category_id =:id AND ' . 'created < :time'; $criteria->params = array(':id' => $id, ':time' => time()); $criteria->order = 'created DESC'; $model = CmsSetting::model()->findByPk(1); $prow = new CActiveDataProvider('CmsPage', array('criteria' => $criteria, 'pagination' => array('pageSize' => $model->ct_page, 'pageVar' => 'page'))); } if (Yii::app()->request->isAjaxRequest) { $this->renderPartial('widget_ajax', array('category' => $category, 'data' => $prow)); Yii::app()->end(); } else { $this->render('index', array('category' => $category, 'data' => $prow, 'val' => $dataStr)); } }
public function category() { $this->use_view = "cms_list"; if (!($this->this_page = Request::param('page'))) { $this->this_page = 1; } if (!($url = Request::param('id'))) { $this->redirect_to('/'); } $cat = new CmsCategory(); $this->category = $cat->filter(array('url' => $url))->first(); if (!$this->category->id) { $this->redirect_to('/'); } $this->cms_content = $this->category->attached_to->order('published DESC')->page($this->this_page, $this->per_page); $this->section_stack[0] = "category"; }
/* @var $this Controller */ session_start(); $this->beginContent('//layouts/main'); ?> <div class="row" style="margin: 0; padding-right: 0"> <div class="col-md-3" id="LeftblockId"> <div class="category">Категории</div> <ul class="CatItem"> <?php foreach (CmsCategory::menu('top') as $one) { ?> <li> <?php echo CHtml::openTag('a', array('href' => Yii::app()->baseUrl . $one['url']['0'], 'id' => 'categ', 'class' => 'activeBtn')); ?> <div class="row-fluid divBlock"> <div class="col-md-4 LeftBkock"> <i class="fa fa-chevron-up fa-rotate-90"></i> </div> <div class="col-md-4 CenterBlock"> <?php echo $one['label']; ?> </div> <div class="col-md-4 RightBkock">
<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'cmscategory-form', 'enableAjaxValidation' => false)); ?> <p class="help-block">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); if (!$model->isNewRecord) { $category_check = CmsCategory::model()->findByPk($model->ID); $parent = $category_check->parent()->find(); } echo '<select id="CmsCategory_node" name="CmsCategory[node]">'; $descendants = CmsCategory::model()->findAll(array('condition' => 'Root=1', 'order' => 'Lft')); $level = 1; foreach ($descendants as $child) { $string = ' '; $string .= str_repeat(' ', 2 * ($child->Level - $level)); // if ($child->isLeaf() && !$child->next()->find()) { // $string .= ' '; // } else { // // $string .= ''; // } $string .= $child->Name; // echo $string; if (!$model->isNewRecord) { if ($parent->ID == $child->ID) { $selected = 'selected'; echo '<option value="' . $child->ID . '" selected="' . $selected . '">' . $string . '</option>';
<?php require '../../../inc/admin/config.php'; $session->auth_or_redirect('su', '/admin'); $action = $_GET['f']; $todayDate = date('Y-m-d H:i:s'); switch ($action) { case 'new': $cms_category = new CmsCategory(); $cms_category->create($_POST['cms_category']); $URL = './index.php'; break; case 'edit': parse_str(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY)); $cms_category = new CmsCategory(); $cms_category = $cms_category->find($id); $cms_category->update($_POST['cms_category']); $URL = './index.php'; break; case 'delete': parse_str(parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY)); $cms_category = new CmsCategory(); $cms_category = $cms_category->find($id); $cms_category->delete(); $URL = './index.php'; break; default: break; } header("Location: {$URL}"); include ROOT . '/inc/closedb.php';
<div class="row"> <?php echo $form->label($model, 'status'); ?> <?php echo $form->dropDownList($model, 'status', array('' => '', 1 => "На модерацию", 2 => "Опубликовать", 3 => "Снять с пуб")); ?> </div> <div class="row"> <?php echo $form->label($model, 'category_id'); ?> <?php echo $form->dropDownList($model, 'category_id', CmsCategory::all(), array('empty' => '')); ?> </div> <div class="row"> <?php echo $form->label($model, 'user_id'); ?> <?php echo $form->dropDownList($model, 'user_id', CmsUser::all(), array('empty' => '')); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton('Поиск', array('class' => 'btn btn-primary'));
<div class="form-group"> <label ><?php echo $form->labelEx($model, 'status'); ?> </label> <?php echo $form->dropDownList($model, 'status', array(0 => "Черновик", 1 => "На модерацию"), array('class' => 'form-control')); ?> </div> <div class="form-group"> <label ><?php echo $form->labelEx($model, 'category_id'); ?> </label> <?php echo $form->dropDownList($model, 'category_id', CmsCategory::all(), array('class' => 'form-control')); ?> </div> <div class="form-group"> <?php if (CmsPage::model()->isNewRecord) { ?> <?php echo CmsSetting::carimage('', 200, 150, 'img-thumbnail ImgDef', 1, $model->user_id); ?> <?php } if (!CmsPage::model()->isNewRecord) { ?> <?php
<?php echo $form->dropDownList($model, 'status', array(2 => "Опубликовать", 3 => "Снять с пуб")); ?> <?php echo $form->error($model, 'status'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'category_id'); ?> <?php echo $form->dropDownList($model, 'category_id', CmsCategory::all()); ?> <?php echo $form->error($model, 'category_id'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton('Сохранить'); ?> </div> <?php $this->endWidget(); ?>
?> <h1>Журнал страниц</h1> <?php echo CHtml::link('Расширеный поиск', '#', array('class' => 'search-button')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <?php echo CHtml::form(); echo "<br>"; echo CHtml::submitButton('Опубликовать', array('name' => 'opyblic', 'class' => 'btn btn-primary', 'style' => 'width : 200px')); echo "<br>"; echo "<br>"; echo CHtml::submitButton('Снять с публикации', array('name' => 'del', 'class' => 'btn btn-primary', 'style' => 'width : 200px')); ?> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'cms-page-grid', 'dataProvider' => $model->search(), 'selectableRows' => 2, 'filter' => $model, 'columns' => array('id' => array('name' => 'id', 'headerHtmlOptions' => array('width' => 30)), array('class' => 'CCheckBoxColumn', 'id' => 'page_id'), 'title', 'created' => array('name' => 'created', 'value' => 'date("j.m.Y.H:i",$data->created)', 'filter' => false), 'status' => array('name' => 'status', 'value' => '$data->getStatus($data->status)', 'filter' => array(1 => "На модерацию", 2 => "Опубликовать", 3 => "Снять с пуб")), 'category_id' => array('name' => 'category_id', 'value' => '$data->category->title', 'filter' => CmsCategory::all()), 'user_id' => array('name' => 'user_id', 'value' => '$data->user->username', 'filter' => CmsUser::all()), array('class' => 'CButtonColumn', 'viewButtonOptions' => array('style' => 'display:none'))))); ?> <?php echo CHtml::endForm();
/** * 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 $id the ID of the model to be loaded * @return CmsCategory the loaded model * @throws CHttpException */ public function loadModel($id) { $model = CmsCategory::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function extractElementInfo() { switch ($this->type) { case 'external': $this->link = $this->external; break; } if ($this->element) { switch ($this->type) { case 'cms_category': $title = $this->element->name; $this->link = $this->element->getLink(); if ($this->display_cms_cat_childs && !self::isAdmin()) { foreach (CmsCategory::getChildren($this->element->id, self::getIdLang()) as $children) { $obj = new CmsCategory($children['id_cms_category'], self::getIdLang()); $child = new self(array('type' => 'cms_category', 'id_cms_category' => $obj->id, 'element' => $obj, 'display_cms_cat_childs' => $this->display_cms_cat_childs)); $this->childrens[] = $child; } foreach ($this->getCMSPages($this->element->id) as $page) { $obj = new CMS($page['id_cms'], self::getIdLang()); $child = new self(array('type' => 'cms', 'id_cms' => $obj->id, 'element' => $obj, 'display_cms_cat_childs' => $this->display_cms_cat_childs)); $this->childrens[] = $child; } } break; case 'product_category': $title = $this->element->name; $link = $this->element->getLink(); if ($this->display_prod_cat_childs && !self::isAdmin()) { /** @var $this->element CategoryCore */ foreach (Category::getChildren($this->element->id, self::getIdLang()) as $children) { $obj = new Category($children['id_category'], self::getIdLang()); $child = new self(array('type' => 'product_category', 'id_category' => $obj->id, 'title' => $obj->name, 'link' => $obj->getLink(), 'display_prod_cat_childs' => $this->display_prod_cat_childs)); $this->childrens[] = $child; } } break; case 'product': $link = $this->element->getLink(); $title = $this->element->name; break; case 'internal': $link = self::getClassLink()->getPageLink($this->element->page); $title = $this->element->title; break; case 'cms': $link = self::getClassLink()->getCMSLink($this->element, null); $title = $this->element->meta_title; break; case 'manufacturer': $link = $this->element->getLink(); $title = $this->element->name; break; case 'supplier': $link = $this->element->getLink(); $title = $this->element->name; break; case 'attachment': $link = self::getClassLink()->getPageLink('attachment', NULL, "id_attachment=" . $this->id_attachment); $title = $this->element->name; break; } } // if(self::isSSL()) // $this->link = str_replace('http://','https://',$this->link); if (empty($this->link)) { $this->link = @$link; } if (empty($this->title)) { $this->title = @$title; } if (is_array($this->title)) { $this->title = $this->title[self::getIdLang()]; } if ($this->has_anchor) { $this->link .= '#' . $this->anchor; } }
//$id = array_rand(array_fill_keys(range('a','z'), null), 1); $id = NULL; Yii::app()->getClientScript()->registerScript('editorparam', 'window.KEDITOR_PARAM = "action=' . $action . '&id=' . $id . '"', CClientScript::POS_HEAD); $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'article-form', 'htmlOptions' => array('enctype' => 'multipart/form-data'), 'enableAjaxValidation' => false)); ?> <p class="note">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <?php echo '<select id="CmsArticle_category_id" name="CmsArticle[CategoryID]">'; $category = CmsCategory::model()->findByPk(5); $descendants = $category->descendants()->findAll(); $level = 1; echo '<option value="">请选择分类</option>'; foreach ($descendants as $child) { $string = ' '; $string .= str_repeat(' ', $child->Level - $level); if ($child->isLeaf() && !$child->next()->find()) { $string .= ''; } else { $string .= ''; } $string .= '' . $child->Name; // echo $string; if (!$model->isNewRecord) { if ($model->CategoryID == $child->ID) {
<?php echo '<select id="SettingsForm_menu_' . $key . '" name="SettingsForm[menu][' . $key . ']">'; $menu = CmsCategory::model()->roots()->findAll(); $level = 1; echo '<option value="0">请选择分类</option>'; foreach ($menu as $n => $m) { if ($val) { if ($val == $m->ID) { $selected = 'selected'; echo '<option value="' . $m->ID . '" selected="' . $selected . '">' . $m->Name . '</option>'; } else { echo '<option value="' . $m->ID . '">' . $m->Name . '</option>'; } } else { echo '<option value="' . $m->ID . '">' . $m->Name . '</option>'; } $children = $m->descendants()->findAll(); foreach ($children as $child) { $string = ' '; $string .= str_repeat(' ', 2 * ($child->Level - $level)); $string .= $child->Name; if ($val) { if ($val == $child->ID) { $selected = 'selected'; echo '<option value="' . $child->ID . '" selected="' . $selected . '">' . $string . '</option>'; } else { echo '<option value="' . $child->ID . '" >' . $string . '</option>'; } } else { echo '<option value="' . $child->ID . '" >' . $string . '</option>';
function child_categories($category_id) { $categories = new CmsCategory(); return $categories->order_by('name')->find(array("`parent` = '{$category_id}'"), array('index' => 'id')); }
/** * Ajax function - makes a new category on the file and returns the new list in the view **/ public function new_category() { $this->use_layout = false; $cat = new CmsCategory(); $cat->name = Request::get("cat"); $cat->save(); if (!($this->all_categories = $cat->clear()->all())) { $this->all_categories = array(); } $this->cat_list = $this->render_partial("cat_list"); }