예제 #1
0
 protected function on_init()
 {
     $this->vars['content'] = '';
     if (strlen(_GET('node_id'))) {
         $node = new Node();
         if (!$node->find_by_id(_GET('node_id'))) {
             return;
         }
         if (!array_key_exists($node->type, $this->modules)) {
             return;
         }
         $this->vars['content'] = $this->modules[$node->type]->render_editor($node);
     } elseif (strlen(_GET('parent_id'))) {
         $parent_node = new Node();
         if (!$parent_node->find_by_id(_GET('parent_id'))) {
             return;
         }
         if (array_key_exists($parent_node->type, $this->modules)) {
             if (!$this->modules[$parent_node->type]->can_has_childs($parent_node)) {
                 return;
             }
             $type = $this->modules[$parent_node->type]->get_new_node_type($parent_node, $parent_node->type);
         } else {
             $type = '';
             foreach ($this->modules as $mtype => $module) {
                 if ($module->get_tree_subpath() != '' && Cms::path_start_with($parent_node->full_path, $module->get_tree_subpath(), true)) {
                     $type = $module->get_new_node_type($parent_node, $mtype);
                     break;
                 }
             }
         }
         if ($type == '') {
             return;
         }
         $node = new Node();
         $node->type = $type;
         $node->flags = Node::Visible | Node::UserChilds;
         $node->path = $parent_node->full_path . '/';
         $this->vars['content'] = $this->modules[$type]->render_editor($node);
     } elseif (strlen(_GET('module')) && strlen(_GET('item_id'))) {
         if (!array_key_exists(_GET('module'), $this->modules)) {
             return;
         }
         require_once CMS . 'modules/' . _GET('module') . '/admin.php';
         $class_name = $this->modules[_GET('module')];
         $module = new $class_name();
         $module->owner = $this;
         $this->vars['content'] = $module->render_nav_editor(_GET('item_id'));
     }
 }
 protected function get_new_name_for_node($node)
 {
     if (array_key_exists($node->type, $this->owner->modules)) {
         return $this->owner->modules[$node->type]->get_new_node_name($node);
     }
     $type = '';
     foreach ($this->owner->modules as $mtype => $module) {
         if (Cms::path_start_with($node->parent_node->full_path, $module->get_tree_subpath(), true)) {
             $type = $module->get_new_node_type($node->parent_node, $mtype);
             break;
         }
     }
     if (strlen($type) && array_key_exists($type, $this->owner->modules)) {
         return $this->owner->modules[$type]->get_new_node_name($node);
     }
     return Loc::get('cms/admin/new-element');
 }