Exemple #1
0
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $dataProvider = new CActiveDataProvider('CmsPage');
     $this->render('index', array('dataProvider' => $dataProvider));
 }
 /**
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     $criteria->order = 'created DESC';
     $criteria->compare('status', 2);
     $criteria->limit = 4;
     $model = CmsPage::model()->findAll($criteria);
     $this->render('index', array('model' => $model));
 }
 public static function menu($position)
 {
     $model = self::model()->findAllByAttributes(array('position' => $position));
     $array = array();
     foreach ($model as $one) {
         $array[] = array('label' => $one->title, 'url' => array('/page/index/id/' . $one->id), 'icon' => 'fa fa-arrow-right fa-border fa-2x', 'data' => CmsPage::model()->countByAttributes(array('category_id' => $one->id, 'status' => 2)));
     }
     return $array;
 }
 public function loadModel($id)
 {
     $criteria = new CDbCriteria();
     $criteria = "id=:id";
     $criteria->params = array(':id' => $id);
     $model = CmsPage::model()->find($criteria);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function parseUrl($request)
 {
     $searchPaths = array($request->pathInfo);
     // Also search for paths that end with the wildcard "*" (e.g. with news details)
     if ($lastPathSeparatorPos = strrpos($request->pathInfo, '/')) {
         $searchPaths[] = substr($request->pathInfo, 0, $lastPathSeparatorPos + 1) . '*';
     }
     $page = CmsPage::model()->findByAttributes(array('path' => $searchPaths));
     if ($page !== null) {
         return 'cms/page/default/id/' . $page->id;
     }
     return parent::parseUrl($request);
 }
 public static function ar_kol($id_user)
 {
     $model = CmsPage::model()->findAllByAttributes(array('user_id' => array($id_user)));
     $ar = array();
     $rr = date_parse(date("j.m.Y.H:i", time()));
     for ($i = 0; $i < $rr['month']; $i++) {
         $ar[$i] = 0;
     }
     foreach ($model as $one) {
         $rr = date_parse(date("j.m.Y.H:i", $one->created));
         $ar[$rr['month'] - 1]++;
     }
     return $ar;
 }
 public function actionDefault($id)
 {
     $this->page = CmsPage::model()->findByPk($id);
     $this->layout = $this->page->layout;
     $this->contents = $this->page->getContents();
     if ($this->adminMode) {
         Yii::app()->clientScript->registerCoreScript('jquery');
         $assetsUrl = Yii::app()->assetManager->publish(Yii::getPathOfAlias('cms.assets.admin'), false, -1, true);
         Yii::app()->clientScript->registerCssFile($assetsUrl . '/lib/jquery-ui/css/smoothness/jquery-ui.css');
         Yii::app()->clientScript->registerScriptFile($assetsUrl . '/lib/jquery-ui/js/jquery-ui.min.js');
         Yii::app()->clientScript->registerCssFile($assetsUrl . '/css/admin.css');
         Yii::app()->clientScript->registerScriptFile($assetsUrl . '/js/admin.js');
     }
     $this->render('/blank');
 }
 public function actionView($id)
 {
     $model = CmsPage::model()->findByPk($id);
     $model1 = new CmsComment();
     $ar = $model1->getCommentsTree($id);
     if (isset($_POST['CmsComment'])) {
         $model1->page_id = $id;
         if (!Yii::app()->user->isGuest) {
             $model1->user_id = Yii::app()->user->id;
         }
         // esli polzovatel ne gost tokda soxranaem ego id
         $model1->attributes = $_POST['CmsComment'];
         if ($model1->save()) {
             if ($model1->parent_id != null && !Yii::app()->user->isGuest) {
                 CmsComment::sendOtvet($model1->parent_id);
             }
             $this->refresh();
         }
     }
     if (Yii::app()->user->isGuest) {
         $model1->scenario = 'ComSet';
     }
     $this->render('view', array('model1' => $model1, 'model' => $model, 'comments' => $ar));
 }
Exemple #9
0
 public function actionIndex($key)
 {
     $page = CmsPage::model()->findByAttributes(array('Key' => $key));
     $this->render('index', array('page' => $page));
 }
Exemple #10
0
     $criteria->compare('Key', $this->Key, true);
     $criteria->compare('Title', $this->Title, true);
     $criteria->compare('Content', $this->Content, true);
     return new CActiveDataProvider(get_class($this), array('criteria' => $criteria));
 }
 public function actionUpdate($id)
 {
     $model = CmsPage::model()->findByPk($id);
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'cms-page-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     if (isset($_POST['CmsPage'])) {
         if ($model->validate()) {
             $model->SaveImage();
             CmsPage::model()->updateByPk($id, array('path_img' => $model->path_img, 'content' => $model->content, 'title' => $model->title));
         }
         $this->redirect(array('index', 'id' => Yii::app()->user->id));
     }
     $this->render('update', array('model' => $model));
 }
Exemple #12
0
                        <td class="text-center wid"><?php 
    echo $ct;
    ?>
</td>
                    <?php 
}
?>
                </tr>
                <tr>
                    <?php 
$criteria = new CDbCriteria();
$criteria->condition = 'user_id=:id AND status=2';
$criteria->params = array(':id' => $id);
$criteria->order = 'created DESC';
$criteria->limit = '1';
$page = CmsPage::model()->find($criteria);
if ($page != 0) {
    ?>

                    <td class="text-left wid">
                        <span>Последняя статья</span>
                        <div>
                            <?php 
    echo date('j F Y H:i', $page->created);
    ?>
                        </div>
                    </td>
                    <td><i class="fa fa-comment-o " style="margin-left: 15px"></i></td>
                    <td class="text-center wid">
                        <?php 
    echo CHtml::link($page->title, array('page/view/', 'id' => $page->id));
Exemple #13
0
</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 
    echo CmsSetting::carimage($model->path_img, 200, 150, 'img-thumbnail ImgDef', 1, $model->user_id);
    ?>

            <?php 
}
?>

            <br>
            <br>

            <?php 
echo $form->fileField($model, 'image', array('id' => 'InputField'));
?>