Ejemplo n.º 1
0
 protected function renderContent()
 {
     if (isset($this->block) && $this->block != null) {
         //Set Params from Block Params
         $params = b64_unserialize($this->block['params']);
         $this->setParams($params);
         $post_id = (int) $_GET['id'];
         if ($post_id) {
             $post = Object::model()->findByPk($post_id);
             if ($post) {
                 Yii::app()->controller->pageTitle = CHtml::encode($post->object_name);
                 Yii::app()->controller->description = CHtml::encode($post->object_description);
                 Yii::app()->controller->keywords = CHtml::encode($post->object_keywords);
                 Yii::app()->controller->change_title = true;
                 $this->render(BlockRenderWidget::setRenderOutput($this), array('post' => $post));
             } else {
                 throw new CHttpException('404', t('site', 'Page not found'));
             }
         } else {
             throw new CHttpException('404', t('site', 'Page not found'));
         }
     } else {
         echo '';
     }
 }
Ejemplo n.º 2
0
 protected function renderContent()
 {
     if (isset($this->block) && $this->block != null) {
         //Set Params from Block Params
         $params = b64_unserialize($this->block['params']);
         $this->setParams($params);
         $this->render(BlockRenderWidget::setRenderOutput($this), array());
     } else {
         echo '';
     }
 }
Ejemplo n.º 3
0
 protected function renderContent()
 {
     if (isset($this->block) && $this->block != null) {
         $params = b64_unserialize($this->block['params']);
         $this->setParams($params);
         $menu_r0_items = Yii::app()->cache->get('menu_r0_' . $this->menu_id);
         if ($menu_r0_items === false) {
             $menu_r0_items = self::getMenuItems(0, $this->menu_id);
             Yii::app()->cache->set('menu_r0_' . $this->menu_id, $menu_r0_items, 7200);
         }
         $this->render(BlockRenderWidget::setRenderOutput($this), array('menus' => $menu_r0_items));
     } else {
         echo '';
     }
 }
Ejemplo n.º 4
0
 protected function renderContent()
 {
     $block_id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
     $model = GxcHelpers::loadDetailModel('Block', $block_id);
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'block-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     $current_type = $model->type;
     $block_ini = parse_ini_file(Yii::getPathOfAlias('common.blocks.' . $current_type) . DIRECTORY_SEPARATOR . 'info.ini');
     //Include the class
     Yii::import('common.blocks.' . $current_type . '.' . $block_ini['class']);
     $block_model = new $block_ini['class']();
     //We re-init the params of the attributes
     $block_model->setParams(b64_unserialize($model->params));
     // collect user input data
     if (isset($_POST['Block'])) {
         $model->attributes = $_POST['Block'];
         $model->type = $_POST['Block']['type'];
         $params = $block_model->params();
         $block_params = array();
         foreach ($params as $key => $param) {
             $block_params[$key] = $block_model->{$key} = isset($_POST['Block'][$key]) ? $_POST['Block'][$key] : null;
         }
         if ($model->validate()) {
             if (!$block_model->validate()) {
                 foreach ($block_model->errors as $key => $message) {
                     $model->addError($key, $message);
                 }
             } else {
                 $block_model->beforeBlockSave();
                 //Re-set params if needed
                 foreach ($params as $key => $param) {
                     $block_params[$key] = $block_model->{$key};
                 }
                 $model->params = b64_serialize($block_params);
                 if ($model->save()) {
                     $block_model->afterBlockSave();
                     user()->setFlash('success', t('cms', 'Update Block Successfully!'));
                 }
             }
         }
     }
     Yii::app()->controller->layout = isset($_GET['embed']) ? 'clean' : 'main';
     $this->render('cmswidgets.views.block.block_form_widget', array('model' => $model, 'type' => $current_type, 'block_model' => $block_model));
 }
Ejemplo n.º 5
0
 /**
  * load from database the items of the specified category
  * 
  * @param string $category
  * @return array the items of the category
  */
 public function load($category)
 {
     $items = $this->getCacheComponent()->get($category . '_' . $this->getCacheId());
     $this->loaded[$category] = true;
     $this->addToCacheRegistry($category);
     if (!$items) {
         $connection = $this->getDbComponent();
         $command = $connection->createCommand('SELECT `key`, `value` FROM ' . $this->getTableName() . ' WHERE category=:cat');
         $command->bindParam(':cat', $category);
         $result = $command->queryAll();
         if (empty($result)) {
             return;
         }
         $items = array();
         foreach ($result as $row) {
             $items[$row['key']] = b64_unserialize($row['value']);
         }
         $this->getCacheComponent()->set($category . '_' . $this->getCacheId(), $items, $this->getCacheTime());
     }
     if (isset($this->items[$category])) {
         $items = CMap::mergeArray($items, $this->items[$category]);
     }
     $this->set($category, $items, null, false);
     return $items;
 }