Пример #1
0
 /**
  * handle tree edit
  */
 private function handleTreeEditGet($retrieveFields = true)
 {
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $view->setType(ViewManager::TREE_EDIT);
     if (!$request->exists('tree_id')) {
         throw new Exception('Node ontbreekt.');
     }
     if (!$request->exists('tag')) {
         throw new Exception('Tag ontbreekt.');
     }
     $tree_id = intval($request->getValue('tree_id'));
     $tag = $request->getValue('tag');
     $key = array('tree_id' => $tree_id, 'tag' => $tag);
     $fields = array();
     if ($retrieveFields) {
         if ($this->exists($key)) {
             $fields = $this->getDetail($key);
             $fields['online'] = $fields['online'] ? strftime('%Y-%m-%d', $fields['online']) : '';
             $fields['offline'] = $fields['offline'] ? strftime('%Y-%m-%d', $fields['offline']) : '';
         } else {
             $fields = $this->getFields(SqlParser::MOD_INSERT);
         }
     } else {
         $fields = $this->getFields(SqlParser::MOD_UPDATE);
     }
     // get all tree nodes which have plugin modules
     $sitePlugin = $this->director->siteManager->systemSite->getSitePlugin();
     $tree = $this->plugin->getReferer()->getTree();
     $searchcriteria = array('classname' => 'News', 'plugin_type' => News::TYPE_DEFAULT);
     $treeplugin = $sitePlugin->getList($searchcriteria);
     $treelist = array();
     foreach ($treeplugin['data'] as $item) {
         if (!$tree->exists($item['tree_id'])) {
             continue;
         }
         $treelist[] = array('id' => $item['tree_id'], 'name' => $tree->toString($item['tree_id'], '/', 'name'));
     }
     // get all selected tree node connections
     $treeRef = new NewsTreeRef();
     $treeRefTmp = $treeRef->getList($key);
     $treeRefLink = array();
     foreach ($treeRefTmp['data'] as $item) {
         $treeRefLink[] = $item['ref_tree_id'];
     }
     $template->setVariable('ref_tree_id', Utils::getHtmlCheckbox($treelist, $treeRefLink, 'ref_tree_id', '<br />'));
     $datefields = array();
     $datefields[] = array('dateField' => 'online', 'triggerElement' => 'online');
     $datefields[] = array('dateField' => 'offline', 'triggerElement' => 'offline');
     Utils::getDatePicker($this->director->theme, $datefields);
     $this->setFields($fields);
     $template->setVariable($fields, NULL, false);
     $template->setVariable('tree_id', $tree_id, false);
     $template->setVariable('tag', $tag, false);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }