Example #1
0
 public static function getTagList()
 {
     $tagModel = SlNode::getModel()->CmsTag;
     $tagModel->CmsTagCategory;
     // needed for proper TranslateBehavior initialization
     return $tagModel->find('list', array('fields' => array('CmsTag.id', 'CmsTag.name', 'CmsTagCategory.name'), 'recursive' => 0));
 }
Example #2
0
 function parse($html = null, $blockName = 'document', $blockParams = null)
 {
     $blockParams = (array) $blockParams;
     $blockParams += array('id' => null);
     if ($blockParams['id']) {
         $oldVars = $this->vars;
         $this->vars = SlNode::get($blockParams['id'], array('auth' => true));
     }
     if ($blockName === 'NodeView') {
         $skin = empty(SL::getInstance()->view->params['named']['skin']) ? Inflector::camelize($this->_getVar('CmsNode.skin')) : Inflector::camelize(SL::getInstance()->view->params['named']['skin']);
         $skin = $skin && Pheme::init("NodeView{$skin}") ? "NodeView{$skin}" : "NodeViewDefault";
     } else {
         $skin = $blockName;
     }
     if ($skin != $blockName) {
         PhemeParser::$parseCallStack[] = Pheme::get($skin);
         $result = parent::parse($html, $skin);
         array_pop(PhemeParser::$parseCallStack);
     } else {
         $result = parent::parse($html, $skin);
     }
     if (isset($oldVars)) {
         $this->vars = $oldVars;
     }
     return $result;
 }
 public function view($id)
 {
     $this->set('tag', $tag = $this->CmsTag->read(null, $id));
     if (!$tag) {
         $this->cakeError();
     }
     if ($tag['CmsTag']['node_id']) {
         $this->set('node', $node = SlNode::get($tag['CmsTag']['node_id']));
     }
     if ($node) {
         $this->set('title', $node['CmsNode']['title']);
     } else {
         $this->set('title', $tag['CmsTag']['name']);
     }
     // get all nodes associated with the CmsTag
     $this->set('nodes', SlNode::find('all', array('conditions' => array('TagFilter.id' => $id), 'link' => array('CmsNodesTags' => array('TagFilter' => array('class' => 'CmsTag', 'conditions' => 'TagFilter.id = CmsNodesTags.tag_id', 'fields' => array('TagFilter.id')))))));
 }
 public function admin_add()
 {
     $newItem = empty($this->data);
     $this->admin_edit();
     if ($newItem && !empty($this->params['named']['cms_node_id'])) {
         $nodeId = $this->params['named']['cms_node_id'];
         $node = $this->CmsBlock->CmsNode->read(null, $nodeId);
         if ($node) {
             // set link title to node title
             $locales = SlConfigure::read('I18n.locales');
             foreach ($locales as $locale) {
                 $this->data['CmsBlock']['title_' . $locale] = $node["CmsNode"]['short_title_' . $locale] ? $node["CmsNode"]['short_title_' . $locale] : $node["CmsNode"]['title_' . $locale];
             }
             $this->data['CmsBlock']['cms_node_id'] = $nodeId;
             $this->data['CmsBlock']['url'] = SlNode::url($node, array('base' => false, 'slug' => false, 'lang' => false));
         }
     }
     $this->render('admin_edit');
 }
Example #5
0
 function parse($html = null, $blockName = 'document', $blockParams = null)
 {
     $blockParams = (array) $blockParams;
     $blockParams += array('id' => false, 'skin' => null);
     if ($blockName === 'NodeIndex') {
         $skin = empty(SL::getInstance()->view->params['named']['skin']) ? Inflector::camelize($blockParams['skin']) : Inflector::camelize(SL::getInstance()->view->params['named']['skin']);
         $skin = $skin && Pheme::init("NodeIndex{$skin}") ? "NodeIndex{$skin}" : "NodeIndexDefault";
     } else {
         $skin = $blockName;
     }
     $this->vars['ajaxId'] = SL::uniqid();
     if ($blockParams['id'] === false) {
         $nodes = $this->_getVar('nodes');
     } else {
         if ($blockParams['id'] === 0) {
             $blockParams['id'] = null;
         }
         $nodes = SlNode::find('all', array('conditions' => array('CmsNode.parent_id' => $blockParams['id'], 'CmsNode.visible' => true), 'order' => array('CmsNode.lft' => 'asc'), 'auth' => 'index'));
     }
     if ($nodes) {
         foreach ($nodes as &$node) {
             $node['href'] = h(SlNode::url($node));
         }
         $this->blocks["loop"]->params[0] =& $nodes;
         if ($skin != $blockName) {
             PhemeParser::$parseCallStack[] = Pheme::get($skin);
         }
         PhemeParser::$parseCallStack[] = Pheme::get('NodeView');
         $html = parent::parse($html, $skin);
         array_pop(PhemeParser::$parseCallStack);
         if ($skin != $blockName) {
             array_pop(PhemeParser::$parseCallStack);
         }
         return $html;
     }
 }
Example #6
0
 protected function _admin_edit($options = array())
 {
     $this->helpers[] = 'JsValidate.Validation';
     $this->{$this->modelClass};
     if ($this->data) {
         if (empty($options['node'])) {
             $result = $this->{$this->modelClass}->saveAll($this->data);
         } else {
             $result = SlNode::getModel()->saveAll($this->data);
         }
         if ($result) {
             if (isset($options['redirect'])) {
                 if (is_array($options['redirect']) && isset($options['redirect']['action']) && $options['redirect']['action'] == 'view') {
                     $options['redirect'][] = $this->{$this->modelClass}->id;
                 }
                 $this->redirect($options['redirect']);
             }
             $this->redirect(array('action' => 'index'));
         }
     } elseif ($this->id) {
         if (empty($options['node'])) {
             $this->data = $this->{$this->modelClass}->read(null, $this->id);
         } else {
             $this->data = SlNode::getModel()->read(null, $this->id);
         }
         if (empty($this->data)) {
             $this->cakeError();
         }
     }
     if (empty($this->data)) {
         $this->data = $this->_getPassedDefaults();
     }
 }
 public function admin_set_as_thumb($id)
 {
     $this->CmsImage->CmsNode->id = $nodeId = $this->CmsImage->field('cms_node_id');
     $this->CmsImage->CmsNode->saveField('cms_image_id', $id);
     $this->redirect(SlNode::url($nodeId, array('admin' => true, 'route' => false)));
 }
 public function admin_edit()
 {
     $this->_admin_edit(array('node' => true));
     $this->set('cmsTags', SlNode::getTagList());
     $this->set('parents', SlNode::getModel()->find('treelist', array('conditions' => array('CmsNode.id !=' => $this->id))));
 }
 public function admin_set_as_homepage($id)
 {
     SlConfigure::write('Cms.homeNodeId', $id, true);
     SlConfigure::write('Routing.home', array('admin' => null, '!merge' => false) + SlNode::url($id, array('route' => false, 'slug' => false)), true);
     $this->redirect(array('action' => 'index'));
 }