/** * 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; }
<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'));
<?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();
<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
/** * Ajax function - removes an association between a category and a content record * makes a view with new data **/ public function remove_category() { $this->use_layout = false; $this->model = new $this->model_class(WaxUrl::get("id")); $category = new CmsCategory(Request::get("cat")); $this->model->categories->unlink($category); if (!($this->attached_categories = $this->model->categories)) { $this->attached_categories = array(); } $cat = new CmsCategory(); if (!($this->all_categories = $cat->all())) { $this->all_categories = array(); } $this->cat_partial = $this->render_partial("list_categories"); }