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');
 }
Beispiel #2
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;
     }
 }
 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_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'));
 }