public function actionElement($param)
 {
     //Если параметр текст - это каталог, если число - элемент
     $paramArr = explode("/", $param);
     $paramArr = array_pop($paramArr);
     if (is_numeric($paramArr)) {
         //Число - это элемент
         $model = Press::model()->findByPk((int) $paramArr);
         if (empty($model)) {
             throw new CHttpException(404, 'The page can not be found.');
         }
         //Смотрим, нужно ли вставить фотогалерею
         $model->description = $this->addPhotogalery($model->description);
         $param = null;
         $render = 'view';
     } else {
         //Список новостей категории
         $paramArr = str_replace("press-", "", $paramArr);
         $model = array();
         //получаем новости в группах
         $model['group'] = PressGroup::model()->findAll(array("condition" => "status!=0", "order" => "id ASC"));
         $model_tmp = PressGroup::model()->find(array("condition" => "status!=0 AND url LIKE '" . $paramArr . "'", "order" => "id ASC"));
         //получаем новости без групп
         $model['first_group'] = Press::model()->findAll(array("condition" => "status!=0 AND group_id=" . $model_tmp->id, "order" => "id ASC"));
         $param = $model_tmp->id;
         $render = 'index';
     }
     if (empty($model)) {
         throw new CHttpException(404, 'The page can not be found.');
     }
     $this->render($render, array('model' => $model, 'param' => $param));
 }
 /**
  * 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 Press the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Press::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Beispiel #3
0
</h1>
        </div>
    </main>
    <div class="news-block">
        <main role="main" class="all">
            <div class="container news-all">
                <figure>
                    <?php 
if (!empty($model->image)) {
    echo '<img src="/uploads/filestorage/press/elements/small-' . $model->id . '.' . $model->image . '">';
}
?>
                </figure>
                <article>
                    <p><?php 
echo Press::model()->getDate($model->maindate);
?>
</p>
                    <blockquote>
                        <?php 
echo $model->name;
?>
                    </blockquote>
                        <?php 
echo $model->description;
?>
                </article>
            </div>
        </main>
    </div>
 public function actionAjax()
 {
     if (isset($_POST)) {
         switch ((int) $_POST['type']) {
             case 1:
                 //Смена статуса
                 $model = $this->loadModel((int) $_POST['id']);
                 $model->status = $model->status == 1 ? 0 : 1;
                 $model->save();
                 //Меняем статус для новостей в группе
                 foreach (Press::model()->findAll('group_id = ' . $model->id) as $data) {
                     $data->status = $model->status;
                     $data->save();
                 }
                 break;
         }
         echo CJavaScript::jsonEncode('ok');
     }
     Yii::app()->end();
 }
Beispiel #5
0
<legend><?php 
echo Yii::t("Bootstrap", "LIST.Press");
?>
</legend>

<?php 
$assetsDir = Yii::app()->basePath;
$labels = Press::model()->attributeLabels();
$this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'pages-grid', 'template' => "{items}\n{pager}", 'enableHistory' => true, 'dataProvider' => $model->search(), 'filter' => null, 'bulkActions' => array('actionButtons' => $this->bulkRemoveButton(), 'checkBoxColumnConfig' => array('name' => 'id')), 'columns' => array(array('header' => $labels["id"], 'name' => "id"), array('header' => $labels["name"], 'name' => "name"), array('header' => $labels["brieftext"], 'name' => "brieftext"), 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}  {delete}', 'buttons' => array('update' => array('label' => yii::t('Bootstrap', 'PHRASE.UPDATE'), 'url' => 'CHtml::normalizeUrl(array("update", "id" => $data->id))', 'options' => array()), 'delete' => array('label' => yii::t('Bootstrap', 'PHRASE.DELETE'), 'options' => array())), 'htmlOptions' => array('style' => 'white-space: nowrap')))));
?>

<a href="/admin/<?php 
echo Yii::app()->controller->module->id;
?>
/<?php 
echo Yii::app()->controller->id;
?>
/create" class="btn">Добавить новость</a>

<script>
    //Меняем статус
    $(document).on('click', '.on-off-product', function(){
        $.ajax({
            type: 'POST',
Beispiel #6
0
?>
        <br>
        <?php 
echo CHtml::activeFileField($model, 'imagefile', array('style' => 'cursor: pointer;'));
?>
    </div>
</div>


<?php 
echo $form->DatePickerRow($model, 'maindate', array('options' => array('autoclose' => true, 'type' => 'Component', 'format' => 'yyyy-mm-dd'), 'htmlOptions' => array()));
?>


<?php 
echo $form->dropDownListRow($model, 'status', Press::model()->getStatuslist(), array('class' => 'span5'));
?>


	<div class="form-actions">

		<?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'htmlOptions' => array('style' => 'margin-right: 20px'), 'label' => $model->isNewRecord ? Yii::t('Bootstrap', 'PHRASE.BUTTON.CREATE') : Yii::t('Bootstrap', 'PHRASE.BUTTON.SAVE')));
?>

        <?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'link', 'label' => Yii::t('Bootstrap', 'PHRASE.BUTTON.RETURN'), 'url' => $this->listUrl('index')));
?>

	</div>
Beispiel #7
0
 /**
  * @param bool $primary - выводить только те новости, у которых стоит признак "Главные новости"
  * @param int $count   -   количество новостей
  * @param int $sort   -  сортировка 1-по убыванию, 2-по возрастанию
  */
 public function getLastPress($primary = true, $count = 3, $sort = 1)
 {
     $retrnData = null;
     $paramArray = array();
     if ($primary == true) {
         $paramArray[] = '`primary`="1"';
     }
     $param = implode(" AND ", $paramArray);
     $param .= ' ORDER BY maindate ' . ($sort == 1 ? 'DESC' : 'ASC');
     $i = 0;
     foreach (Press::model()->findAll($param) as $data) {
         $retrnData[] = $data;
         if ($i < (int) $count) {
             break;
         }
         ++$i;
     }
     return $retrnData;
 }
Beispiel #8
0
 /**
  * @param $model - модель pressGroup
  * Возращает сформированый дизайн списка групп в соответствии с $model группы
  */
 public function returnDesignGroup($model)
 {
     //Серый
     $template_gray = '
         <section class="shadow mg-top-15">
             <div class="bg-gray pd-bottom-40 bottom-shadow">
                 <main class="all" role="main">
                     <div class="container">
                         <h1 class="caption-big">%name%</h1>
                         <a href="' . Yii::app()->request->requestUri . '/' . $model->url . '">
                         <figure class="main-pic" style="cursor: pointer;" >
                             %image%
                             <figcaption>
                                 %brieftext%
                             </figcaption>
                         </figure>
                         </a>
                     </div>
                 </main>
             </div>
         </section>
     ';
     //Белый
     $template_white = '
         <section class="metro pd-top-30 mg-bottom-30">
             <main class="all" role="main">
                 <div class="container">
                     <h2 class="main-caption">%name%</h2>
                     <a href="' . Yii::app()->request->requestUri . '/' . $model->url . '">
                     <figure class="main-pic" style="cursor: pointer;">
                         %image%
                         <figcaption>
                             %brieftext%
                         </figcaption>
                     </figure>
                     </a>
                 </div>
             </main>
         </section>
     ';
     $return = $template_white;
     if ($model->param_design == 2) {
         $return = $template_gray;
     }
     $return = str_replace("%name%", $model->name, $return);
     $return = str_replace("%image%", !empty($model->image) ? '<img src="/uploads/filestorage/press/rubrics/' . $model->id . '.' . $model->image . '">' : '', $return);
     $return = str_replace("%brieftext%", $model->brieftext, $return);
     $return = str_replace("%description%", $model->description, $return);
     $press_element = '';
     $i = 0;
     foreach (Press::model()->findAll('group_id = ' . $model->id . ' AND status!=0 ORDER BY id DESC') as $dataPress) {
         ++$i;
         if ($i % 2 != 0) {
             $press_element .= '<div class="press-line">';
         }
         $press_element .= PressGroup::model()->returnDesignElement($dataPress);
         if ($i % 2 == 0) {
             $press_element .= '</div>';
         }
     }
     $return = str_replace("%press_element%", $press_element, $return);
     return $return;
 }