The followings are the available columns in table 'ContentBlock':
Inheritance: extends CActiveRecord
コード例 #1
0
 public function run()
 {
     $cacheName = "ContentBlock{$this->code}" . Yii::app()->language;
     $output = Yii::app()->cache->get($cacheName);
     if ($output === false) {
         $block = ContentBlock::model()->published()->findByCode($this->code);
         if (null === $block) {
             if ($this->silent === false) {
                 throw new CException(Yii::t('ContentBlockModule.contentblock', 'Content block "{code}" was not found !', array('{code}' => $this->code)));
             }
             $output = '';
         } else {
             switch ($block->type) {
                 case ContentBlock::PHP_CODE:
                     $output = eval($block->content);
                     break;
                 case ContentBlock::SIMPLE_TEXT:
                     $output = CHtml::encode($block->content);
                     break;
                 case ContentBlock::HTML_TEXT:
                     $output = $block->content;
                     break;
             }
         }
         Yii::app()->cache->set($cacheName, $output);
     }
     $this->render($this->view, array('output' => $output));
 }
コード例 #2
0
 public function loadModel($id)
 {
     if (($model = ContentBlock::model()->findByPk($id)) === null) {
         throw new CHttpException(404, Yii::t('ContentBlockModule.contentblock', 'Page was not found!'));
     }
     return $model;
 }
コード例 #3
0
 public function loadModel($id)
 {
     if (($model = ContentBlock::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
コード例 #4
0
ファイル: ContentBlockWidget.php プロジェクト: RSol/yupe
 public function run()
 {
     $cacheName = "{$this->cacheName}{$this->code}";
     $output = Yii::app()->cache->get($cacheName);
     if ($output === false) {
         $block = ContentBlock::model()->find('code = :code', array(':code' => $this->code));
         if (is_null($block)) {
             if ((bool) $this->silent === false) {
                 throw new CException(Yii::t('contentblock', 'Контент блок "{code}" не найден !', array('{code}' => $this->code)));
             }
         } else {
             switch ($block->type) {
                 case ContentBlock::PHP_CODE:
                     $output = eval($block->content);
                     break;
                 case ContentBlock::SIMPLE_TEXT:
                     $output = CHtml::encode($block->content);
                     break;
                 case ContentBlock::HTML_TEXT:
                     $output = $block->content;
                     break;
             }
         }
         Yii::app()->cache->set($cacheName, $output);
     }
     $this->render('contentblock', array('output' => $output));
 }
コード例 #5
0
ファイル: ContentBlockWidget.php プロジェクト: yupe/yupe
 /**
  * @throws CException
  */
 public function run()
 {
     $cacheName = "ContentBlock{$this->code}";
     $output = Yii::app()->getCache()->get($cacheName);
     if (false === $output) {
         $block = ContentBlock::model()->findByAttributes(['code' => $this->code]);
         if (null === $block) {
             if (false === $this->silent) {
                 throw new CException(Yii::t('ContentBlockModule.contentblock', 'Content block "{code}" was not found !', ['{code}' => $this->code]));
             }
             $output = '';
         } else {
             $output = $block->status == ContentBlock::STATUS_ACTIVE ? $block->getContent() : '';
         }
         Yii::app()->getCache()->set($cacheName, $output);
     }
     $this->render($this->view, ['output' => $output]);
 }
コード例 #6
0
 public function run()
 {
     $cacheName = "ContentBlock{$this->category}" . Yii::app()->language;
     $blocks = Yii::app()->cache->get($cacheName);
     if ($blocks === false) {
         $category = Category::model()->findByAttributes(['slug' => $this->category]);
         $criteria = new CDbCriteria(['scopes' => ['active']]);
         $criteria->addCondition('category_id = :category_id');
         $criteria->params[':category_id'] = $category->id;
         if ($this->rand) {
             $criteria->order = 'RAND()';
         }
         if ($this->limit) {
             $criteria->limit = (int) $this->limit;
         }
         $blocks = ContentBlock::model()->findAll($criteria);
         if (empty($blocks) && $this->silent === false) {
             throw new CException(Yii::t('ContentBlockModule.contentblock', 'Group content block "{category_id}" was not found !', ['{category_id}' => $this->category]));
         }
         Yii::app()->cache->set($cacheName, $blocks, $this->cacheTime);
     }
     $this->render($this->view, ['blocks' => $blocks]);
 }
コード例 #7
0
 public function run()
 {
     $cacheName = "ContentBlock{$this->code}" . Yii::app()->language;
     $output = Yii::app()->cache->get($cacheName);
     if ($output === false) {
         $block = ContentBlock::model()->active()->findByAttributes(['code' => $this->code]);
         if (null === $block) {
             if ($this->silent === false) {
                 throw new CException(Yii::t('ContentBlockModule.contentblock', 'Content block "{code}" was not found !', ['{code}' => $this->code]));
             }
             $blockContent = '';
         } else {
             if ($block->status == ContentBlock::STATUS_ACTIVE) {
                 $blockContent = $block->getContent();
             } else {
                 $blockContent = '';
             }
         }
         $output = $this->render($this->view, ['output' => $blockContent, 'block' => $block], true);
         Yii::app()->cache->set($cacheName, $output);
     }
     echo $output;
 }
コード例 #8
0
 public static function adminSign()
 {
     $adminSign = '';
     if (Yii::app()->controller) {
         Yii::app()->controller->widget("application.modules.contentblock.widgets.ContentBlockWidget", array("code" => "admin-sign"), true);
     } else {
         Yii::import("application.modules.contentblock.models.*");
         $block = ContentBlock::model()->find('code = :code', array(':code' => "admin-sign"));
         if ($block !== null) {
             $adminSign = $block->content;
         }
     }
     return $adminSign;
 }
コード例 #9
0
 /**
  * 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 ContentBlock $model
  *
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = ContentBlock::model()->with('category')->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('ContentBlockModule.contentblock', 'Page was not found!'));
     }
     return $model;
 }
コード例 #10
0
 public function match_content_old()
 {
     /* problem with Phalanx service? - use previous version of Phalanx extension - tested */
     return ContentBlock::onEditFilter($this->getText(), '', $this->block);
 }
コード例 #11
0
ファイル: DefaultController.php プロジェクト: RSol/yupe
 /**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = ContentBlock::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }