Пример #1
0
 /**
  * retrieves a list from a database
  * @param array $searchcriteria supplied criteria
  * @param integer $pagesize size of result
  * @param integer $page offset
  * @param integer $order type of order
  * @return array
  */
 public function getList($searchcriteria = NULL, $pagesize = 0, $page = 1, $order = NULL)
 {
     $sqlParser = clone $this->sqlParser;
     $sqlParser->parseCriteria($searchcriteria);
     $this->parseCriteria($sqlParser, $searchcriteria);
     $sqlParser->setOrderby($this->getOrder($order));
     $query = $sqlParser->getSql(SqlParser::SEL_LIST);
     //if($sqlParser->getTable() == 'siteplugin') echo $query."<br />\n";
     //if($sqlParser->getTable() == 'users') Utils::debug($query);
     $db = $this->getDb();
     $this->pagerUrl->setParameter($this->getPagerKey(), '%d', false);
     //Pager replaces "%d" with the page number
     $this->pagerOptions['perPage'] = $pagesize;
     $this->pagerOptions['currentPage'] = $page;
     $this->pagerOptions['fileName'] = $this->pagerUrl->getUrl(false);
     $res = Pager_Wrapper_MDB2($db, $query, $this->pagerOptions, $pagesize == 0);
     if ($db->isError($res)) {
         throw new Exception($res->getDebugInfo());
     }
     // do postprocessing
     foreach ($res['data'] as &$item) {
         if (!$item) {
             continue;
         }
         $item['formatName'] = $this->formatName($item);
         $item = $this->handlePostGetList($item);
     }
     return $res;
 }
Пример #2
0
 /**
  * handle tree overview
  */
 private function handleTreeOverview()
 {
     $pagesize = 20;
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $view->setType(ViewManager::TREE_OVERVIEW);
     $page = $this->getPage();
     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);
     $template->setVariable($key);
     $this->pagerUrl->addParameters($key);
     $this->pagerUrl->setParameter($view->getUrlId(), $view->getType());
     // add breadcrumb item
     $url = new Url(true);
     $url->clearParameter('id');
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('tag', $tag);
     // create urls
     $url_new = clone $url;
     $url_new->setParameter($view->getUrlId(), ViewManager::TREE_NEW);
     $template->setVariable('href_new', $url_new->getUrl(true), false);
     $url_import = clone $url;
     $url_import->setParameter($view->getUrlId(), Gallery::VIEW_IMPORT);
     $template->setVariable('href_import', $url_import->getUrl(true), false);
     $url_resize = clone $url;
     $url_resize->setParameter($view->getUrlId(), Gallery::VIEW_RESIZE);
     $template->setVariable('href_resize', $url_resize->getUrl(true), false);
     $url_conf = clone $url;
     $url_conf->setParameter($view->getUrlId(), Gallery::VIEW_CONFIG);
     $template->setVariable('href_conf', $url_conf->getUrl(true), false);
     $url_edit = clone $url;
     $url_edit->setParameter($view->getUrlId(), ViewManager::TREE_EDIT);
     $url_del = clone $url;
     $url_del->setParameter($view->getUrlId(), ViewManager::TREE_DELETE);
     $url_com = clone $url;
     $url_com->setParameter($view->getUrlId(), Gallery::VIEW_COMMENT_OVERVIEW);
     $list = $this->getList($key, $pagesize, $page, null, clone $url);
     foreach ($list['data'] as &$item) {
         $url_edit->setParameter('id', $item['id']);
         $url_del->setParameter('id', $item['id']);
         $url_com->setParameter('gal_id', $item['id']);
         $item['href_edit'] = $url_edit->getUrl(true);
         $item['href_del'] = $url_del->getUrl(true);
         $item['href_com'] = $url_com->getUrl(true);
         if ($item['thumbnail']) {
             $img = new Image($item['thumbnail'], $this->plugin->getContentPath(true));
             $item['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
         }
     }
     $template->setVariable('list', $list, false);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
Пример #3
0
 /**
  * handle add
  */
 public function addComment($values)
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $values['active'] = 1;
     try {
         $id = $this->insert($values);
         $calendar = $this->plugin->getObject(Calendar::TYPE_DEFAULT);
         $calendarDetail = $calendar->getDetail(array('id' => $values['cal_id']));
         $url = new Url();
         $url->setPath($this->director->tree->getPath($calendarDetail['tree_id']));
         $url->setParameter('id', $calendarDetail['id']);
         $url->setParameter($view->getUrlId(), Calendar::VIEW_DETAIL);
         // notify insert
         $ip = $request->getValue('REMOTE_ADDR', Request::SERVER);
         $template = new TemplateEngine($this->getPath() . "templates/calendarcommentemail.tpl");
         $template->setVariable($values);
         $template->setVariable('calendarName', $calendarDetail['name']);
         $template->setVariable('href_detail', $url->getUrl());
         $template->setVariable('siteTitle', $this->director->tree->getTreeName());
         $template->setVariable('domain', $request->getDomain());
         $template->setVariable('protocol', $request->getProtocol());
         $template->setVariable('ip', $ip);
         $template->setVariable('host', gethostbyaddr($ip));
         $template->setVariable('client', $request->getValue('HTTP_USER_AGENT', Request::SERVER));
         $this->director->systemUser->notify($calendarDetail['tree_id'], 'Comment added at ' . $request->getDomain(), $template->fetch());
     } catch (Exception $e) {
         $template = new TemplateEngine();
         $template->setVariable('commentError', $e->getMessage(), false);
         $template->setVariable('cmtValues', $values, false);
     }
 }
Пример #4
0
 /**
  * handle breadcrumb
  */
 private function handleBreadcrumb($template)
 {
     $view = ViewManager::getInstance();
     $request = Request::getInstance();
     $tree_id = intval($request->getValue('tree_id'));
     $tag = $request->getValue('tag');
     $template->setVariable('tree_id', $tree_id);
     $template->setVariable('tag', $tag);
     $url = new Url(true);
     $url->clearParameter('id');
     $url->setParameter($view->getUrlId(), NewsLetter::VIEW_GROUP_OVERVIEW);
     $breadcrumb = array('name' => $view->getName(NewsLetter::VIEW_GROUP_OVERVIEW), 'path' => $url->getUrl(true));
     $this->director->theme->addBreadcrumb($breadcrumb);
     $this->director->theme->handleAdminLinks($template);
 }
Пример #5
0
 /**
  * handle navigation for sub classes / pages
  */
 public function handleAdminSubLinks($keyName, $title, $addBreadcrumb = false)
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $template = new TemplateEngine();
     if (!$request->exists('nl_id')) {
         return;
     }
     $nl_id = $request->getValue('nl_id');
     $newsLetterName = $this->getName(array('id' => $nl_id));
     $template->setVariable('pageTitle', $newsLetterName, false);
     $tree_id = $request->getValue('tree_id');
     $tag = $request->getValue('tag');
     $template->setVariable('tree_id', $tree_id, false);
     $template->setVariable('tag', $tag, false);
     $template->setVariable('nl_id', $nl_id, false);
     if (!$addBreadcrumb) {
         return;
     }
     $url = new Url(true);
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('tag', $tag);
     $url->setParameter('id', $nl_id);
     $url->setParameter($view->getUrlId(), ViewManager::TREE_EDIT);
     $breadcrumb = array('name' => $newsLetterName, 'path' => $url->getUrl(true));
     $this->addBreadcrumb($breadcrumb);
 }
Пример #6
0
 private function handleTreeSettings($template)
 {
     $view = ViewManager::getInstance();
     $request = Request::getInstance();
     if (!$request->exists('tree_id')) {
         throw new Exception('Node ontbreekt.');
     }
     if (!$request->exists('nl_id')) {
         throw new Exception('Newsletter is missing.');
     }
     if (!$request->exists('tag')) {
         throw new Exception('Tag ontbreekt.');
     }
     $tree_id = intval($request->getValue('tree_id'));
     $nl_id = intval($request->getValue('nl_id'));
     $tag = $request->getValue('tag');
     $template->setVariable('tree_id', $tree_id, false);
     $template->setVariable('tag', $tag, false);
     // create href back url
     $url = new Url(true);
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('nl_id', $nl_id);
     $url->setParameter('id', $nl_id);
     $url->setParameter('tag', $tag);
     $url->setParameter($view->getUrlId(), NewsLetter::VIEW_FILE_OVERVIEW);
     $template->setVariable('href_back', $url->getUrl(true), false);
     // add breadcrumb item
     $breadcrumb = array('name' => $view->getName(NewsLetter::VIEW_FILE_OVERVIEW), 'path' => $url->getUrl(true));
     $this->director->theme->addBreadcrumb($breadcrumb);
     $this->director->theme->handleAdminLinks($template);
 }
Пример #7
0
 /**
  * handle detail request
  */
 private function handleDetail()
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     // it makes no sense to have multiple tags for this plugin.
     // if someone did it, you get strange results and he probably can figure out why.. no multiple detail stuff in 1 page supported!
     // so take a shot and get the first tag to set the content
     $taglist = $this->plugin->getTagList(array('plugin_type' => News::TYPE_ARCHIVE));
     if (!$taglist) {
         return;
     }
     $taginfo = current($taglist);
     // process attachments
     $attachment = $this->getAttachment();
     $attachment->handleHttpGetRequest();
     // clear subtitle
     $view->setName('');
     if (!$request->exists('id')) {
         continue;
     }
     $id = intval($request->getValue('id'));
     $key = array('id' => $id, 'active' => true);
     $overview = $this->getNewsOverview();
     if (!$overview->exists($key)) {
         throw new HttpException('404');
     }
     $detail = $overview->getDetail($key);
     // check if tree node of news item is accessable
     $tree = $this->director->tree;
     if (!$tree->exists($detail['tree_id'])) {
         throw new HttpException('404');
     }
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $template->setPostfix($detail['tag']);
     // disable cache because we want to count visits
     $template->setCacheable(false);
     Cache::disableCache();
     // update view counter
     $overview->updateCount($key);
     // overwrite default naming
     $template->setVariable('pageTitle', $detail['name'], false);
     $template->setVariable('news', $detail, false);
     $url = new Url(true);
     $url->clearParameter('id');
     $url->setParameter($view->getUrlId(), ViewManager::OVERVIEW);
     $template->setVariable('href_back', $url->getUrl(true), false);
     $breadcrumb = array('name' => $detail['name'], 'path' => $url->getUrl(true));
     $this->director->theme->addBreadcrumb($breadcrumb);
     $this->template[$taginfo['tag']] = $template;
 }
Пример #8
0
 private function renderSiteGroup()
 {
     $template = new TemplateEngine($this->getPath() . "templates/sitegroup.tpl");
     $siteGroup = $this->getSiteGroup();
     $id = $siteGroup->getCurrentId();
     $url = new Url();
     $url->useCurrent(false);
     $grouplist = $siteGroup->getList();
     //if($grouplist['totalItems'] < 2) return;
     foreach ($grouplist['data'] as &$item) {
         $url->setParameter(SystemSiteGroup::CURRENT_ID_KEY, $item['id']);
         $item['href_detail'] = $url->getUrl(true);
         $item['selected'] = $item['id'] == $id;
     }
     $template->setVariable('sitegroup', $grouplist, false);
     // add link to sitegroup to add / modify / delete websites
     $admin = $this->director->adminManager;
     $admintree = $admin->tree;
     $sitegroupPath = $admintree->getPath($admintree->getIdFromClassname('SiteGroup'));
     $template->setVariable('href_sitegroup', $sitegroupPath, false);
     return $template;
 }
Пример #9
0
 /**
  * handle import
  */
 private function handleImportGet()
 {
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $grp_used = $request->getValue('grp_used');
     $this->handleEdit($template, $grp_used);
     $template->setVariable('id', '', false);
     $url_import_template = new Url(true);
     $url_import_template->setParameter($view->getUrlId(), self::VIEW_IMPORT_TEMPL);
     $template->setVariable('href_import_template', $url_import_template->getUrl(true), false);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
Пример #10
0
 /**
  * handle element overview
  */
 private function handleElementOverview($template)
 {
     $reference = $this->getObject(self::TYPE_ELEMENT);
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $view->setType(ViewManager::TREE_OVERVIEW);
     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);
     // add breadcrumb item
     $url = new Url(true);
     $url->clearParameter('id');
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('tag', $tag);
     // create urls
     $url_new = clone $url;
     $url_new->setParameter($view->getUrlId(), ViewManager::TREE_NEW);
     $template->setVariable('href_new', $url_new->getUrl(true));
     $url_edit = clone $url;
     $url_edit->setParameter($view->getUrlId(), ViewManager::TREE_EDIT);
     $url_del = clone $url;
     $url_del->setParameter($view->getUrlId(), ViewManager::TREE_DELETE);
     $list = $reference->getList($key);
     foreach ($list['data'] as &$item) {
         $url_edit->setParameter('id', $item['id']);
         $url_del->setParameter('id', $item['id']);
         $item['type_id'] = $reference->getTypeId($item['id']);
         $item['href_edit'] = $url_edit->getUrl(true);
         $item['href_del'] = $url_del->getUrl(true);
     }
     $template->setVariable('list', $list);
     return $template;
 }
Пример #11
0
 /**
  * handle delete
  */
 private function handleAdminDeleteGet()
 {
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     if (!$request->exists('id')) {
         throw new Exception('Gebruikersgroep ontbreekt.');
     }
     $id = intval($request->getValue('id'));
     $template->setVariable('id', $id, false);
     $template->setVariable('name', $this->getName(array('id' => $id)), false);
     $view = ViewManager::getInstance();
     $url = new Url(true);
     $url->setParameter($view->getUrlId(), ViewManager::ADMIN_OVERVIEW);
     $template->setVariable('href_back', $url->getUrl(true), false);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
Пример #12
0
 /**
  * handle tree overview
  */
 private function handleTreeOverview()
 {
     $pagesize = 20;
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $view->setType(ViewManager::TREE_OVERVIEW);
     $page = $this->getPage();
     if (!$request->exists('tree_id')) {
         throw new Exception('Node is missing.');
     }
     if (!$request->exists('tag')) {
         throw new Exception('Tag is missing.');
     }
     $tree_id = intval($request->getValue('tree_id'));
     $tag = $request->getValue('tag');
     $key = array('tree_id' => $tree_id, 'tag' => $tag);
     $this->pagerUrl->addParameters($key);
     $this->pagerUrl->setParameter($view->getUrlId(), $view->getType());
     // handle searchcriteria
     $search = new SearchManager();
     $search->setUrl($this->pagerUrl);
     $search->setExclude($this->pagerKey);
     $search->setParameter('search');
     $search->saveList();
     $searchcriteria = $search->getSearchParameterList();
     $searchcriteria = array_merge($searchcriteria, $key);
     $url = new Url(true);
     $url->clearParameter('id');
     $url->clearParameter('res_id');
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('tag', $tag);
     // create urls
     $url_new = clone $url;
     $url_new->setParameter($view->getUrlId(), ViewManager::TREE_NEW);
     $template->setVariable('href_new', $url_new->getUrl(true), false);
     $url_conf = clone $url;
     $url_conf->setParameter($view->getUrlId(), Reservation::VIEW_CONFIG);
     $template->setVariable('href_conf', $url_conf->getUrl(true), false);
     $url_period = clone $url;
     $url_period->setParameter($view->getUrlId(), Reservation::VIEW_BLOCK_PERIOD_OVERVIEW);
     $template->setVariable('href_period', $url_period->getUrl(true), false);
     $url_usergroup = clone $url;
     $url_usergroup->setParameter($view->getUrlId(), Reservation::VIEW_USER_GROUP_OVERVIEW);
     $template->setVariable('href_usergroup', $url_usergroup->getUrl(true), false);
     $url_del = clone $url;
     $url_del->setParameter($view->getUrlId(), ViewManager::TREE_DELETE);
     $list = $this->getList($searchcriteria, $pagesize, $page, self::ORDER_TIME_DESC | SqlParser::ORDER_DESC);
     foreach ($list['data'] as &$item) {
         $url_del->setParameter('id', $item['id']);
         $item['href_del'] = $url_del->getUrl(true);
     }
     $template->setVariable('list', $list, false);
     $template->setVariable('searchparam', $search->getMandatoryParameterList(), false);
     $template->setVariable('searchcriteria', $searchcriteria, false);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
Пример #13
0
 /**
  * handle tree overview
  */
 private function handleTreeOverview()
 {
     $pagesize = 10;
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $record = $this->plugin->getObject(Form::TYPE_RECORD);
     $recordItem = $this->plugin->getObject(Form::TYPE_RECORD_ITEM);
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $view->setType(ViewManager::TREE_OVERVIEW);
     $page = $this->getPage();
     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);
     $template->setVariable($key);
     $this->pagerUrl->addParameters($key);
     $this->pagerUrl->setParameter($view->getUrlId(), $view->getType());
     // store updated pager url to record object
     $record->setPagerUrl($this->pagerUrl);
     // handle searchcriteria
     $search = new SearchManager();
     $search->setUrl($this->pagerUrl);
     $search->setExclude($this->pagerKey);
     $search->setParameter('search');
     $search->saveList();
     $searchcriteria = $search->getSearchParameterList();
     $searchcriteria = array_merge($searchcriteria, $key);
     $url = new Url(true);
     $url->clearParameter('id');
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('tag', $tag);
     // create urls
     $url_conf = clone $url;
     $url_conf->setParameter($view->getUrlId(), Form::VIEW_CONFIG);
     $template->setVariable('href_conf', $url_conf->getUrl(true), false);
     $url_elem = clone $url;
     $url_elem->setParameter($view->getUrlId(), Form::VIEW_ELEMENT_OVERVIEW);
     $template->setVariable('href_elem', $url_elem->getUrl(true), false);
     $url_del_all = clone $url;
     $url_del_all->setParameter($view->getUrlId(), Form::VIEW_RECORD_DEL_ALL);
     $template->setVariable('href_del_all', $url_del_all->getUrl(true), false);
     $url_export = clone $url;
     $url_export->setParameter($view->getUrlId(), Form::VIEW_RECORD_EXPORT);
     $template->setVariable('href_export', $url_export->getUrl(true), false);
     $url_new = clone $url;
     $url_new->setParameter($view->getUrlId(), ViewManager::TREE_NEW);
     $template->setVariable('href_new', $url_new->getUrl(true), false);
     $url_edit = clone $url;
     $url_edit->setParameter($view->getUrlId(), ViewManager::TREE_EDIT);
     // get columns and create template column list because not every record may have all the columns.
     $recordTemplate = array();
     $columns = $recordItem->getColumns($tree_id, $tag);
     $columns[] = 'timestamp';
     $columns[] = 'host';
     foreach ($columns as $column) {
         $recordTemplate[$column] = '';
     }
     $template->setVariable('columns', $columns);
     $themeVars = $this->director->theme->getFileVars();
     $img_edit = $themeVars['img_edit'];
     $editString = '<a href="%s">' . sprintf('<img class="noborder" src="%s" width="%s" height="%s" alt="edit" title="edit" /></a>', $img_edit['src'], $img_edit['width'], $img_edit['height']);
     $delString = '<input type="checkbox" name="id[]" value="%d" class="noborder" />';
     // retrieve all records within this tree node
     // array[record id] => timestamp
     $searchcriteria = array_merge($searchcriteria, $key);
     $searchcriteria['optin'] = '';
     $recordlist = array();
     $records = $record->getList($searchcriteria, $pagesize, $page);
     foreach ($records['data'] as $item) {
         $recordlist[$item['id']] = $item;
     }
     $template->setVariable('records', $records);
     $recordItemListFinal = array();
     if ($recordlist) {
         // search for all form elements within the specified records
         $elemsearch = array('rcd_id' => array_keys($recordlist));
         $recordItemList = $recordItem->getItems($elemsearch);
         foreach ($recordItemList as $rcd_id => $recordElement) {
             // set values to all the columns
             $element = $recordTemplate;
             foreach ($recordElement as $recordColumn) {
                 // columnames are forced to lowercase, do the same for this result to merge case sensitive versions of columns
                 $element[strtolower($recordColumn['name'])] = $recordColumn['value'];
             }
             $element['timestamp'] = strftime('%c', $recordlist[$rcd_id]['createdate']);
             $element['host'] = $recordlist[$rcd_id]['host'];
             $url_edit->setParameter('rcd_id', $rcd_id);
             $urls = array();
             $urls[] = sprintf($delString, $rcd_id);
             $urls[] = sprintf($editString, $url_edit->getUrl(true));
             array_unshift($element, join('', $urls));
             $recordItemListFinal[] = $element;
         }
     }
     $template->setVariable('list', $recordItemListFinal);
     $template->setVariable('searchparam', $search->getMandatoryParameterList(), false);
     $template->setVariable('searchcriteria', $searchcriteria, false);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
Пример #14
0
 /**
  * handle overview request
  */
 private function handleOverview()
 {
     $taglist = $this->getTagList();
     if (!$taglist) {
         return;
     }
     $tree = $this->director->tree;
     foreach ($taglist as $item) {
         $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
         $template->setCacheable(true);
         $template->setPostfix($item['tag']);
         $key = array('tree_id' => $item['tree_id'], 'tag' => $item['tag']);
         // check if template is in cache
         if (!$template->isCached()) {
             $siteGroup = $this->getSiteGroup();
             $id = $siteGroup->getCurrentId();
             $detail = $this->exists($key) ? $this->getDetail($key) : $this->getFields(SqlParser::MOD_INSERT);
             $template->setVariable('detail', $detail);
             $url = new Url();
             $url->setPath('/');
             $grouplist = $siteGroup->getList(array('active' => true));
             if ($grouplist['totalItems'] < 2) {
                 continue;
             }
             foreach ($grouplist['data'] as &$list) {
                 $url->setParameter(SystemSiteGroup::CURRENT_ID_KEY, $list['id']);
                 $list['path'] = $url->getUrl(true);
                 $list['selected'] = $list['id'] == $id;
                 $list['img'] = $this->getImage($list['language']);
             }
             $template->setVariable('sitegroup', $grouplist, false);
             $template->setVariable('sitegroupId', $id);
         }
         $this->template[$item['tag']] = $template;
     }
 }
Пример #15
0
 private function handlePost()
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     try {
         $autentication = Authentication::getInstance();
         $usermail = $request->getValue('email');
         if (!$usermail) {
             throw new Exception("Email adres ontbreekt.");
         }
         if (!$request->exists('tag')) {
             throw new Exception('Tag ontbreekt.');
         }
         $tree = $this->director->tree;
         $tag = $request->getValue('tag');
         $tree_id = $tree->getCurrentId();
         $key = array('tree_id' => $tree_id, 'tag' => $tag);
         $detail = $this->getDetail($key);
         if (!$detail) {
             $this->log->info("Request login information for unknown user at " . $request->getValue('REMOTE_ADDR', Request::SERVER));
             throw new Exception("Error creating request");
         }
         // get userinfo
         $systemUser = new SystemUser();
         $users = $systemUser->getList(array('email' => $usermail));
         foreach ($users['data'] as $user) {
             $detail = array_merge($detail, $user);
             $loginKey = md5(time() . $user['username']);
             $requestValues = array('request_key' => $loginKey, 'usr_id' => $user['id']);
             // register request
             $loginRequest = new LoginRequest();
             $loginRequest->insert($requestValues);
             $url = new Url(true);
             $url->setParameter($view->getUrlId(), self::VIEW_ACTIVATE);
             $url->setParameter('key', $loginKey);
             // mail userinfo (only if user is present)
             if ($user) {
                 $this->sendMail($user['email'], $this->director->getConfig()->email_address, $detail['subject'], $detail, $request->getProtocol() . $request->getDomain() . $url->getUrl());
             }
         }
         $referer = $detail['ref_tree_id'] ? $tree->getPath($detail['ref_tree_id'], '/', Tree::TREE_ORIGINAL) : ($request->exists('referer') ? $request->getValue('referer') : '/');
         header("Location: {$referer}");
         exit;
     } catch (Exception $e) {
         $template = new TemplateEngine();
         $template->setVariable('formError', $e->getMessage(), false);
         $this->handleHttpGetRequest();
     }
 }
Пример #16
0
 private function handleSettings($template)
 {
     $view = ViewManager::getInstance();
     $request = Request::getInstance();
     if (!$request->exists('tree_id')) {
         throw new Exception('Node is missing.');
     }
     if (!$request->exists('tag')) {
         throw new Exception('Tag is missing.');
     }
     $tree_id = intval($request->getValue('tree_id'));
     $tag = $request->getValue('tag');
     $key = $this->getKey();
     $template->setVariable('tree_id', $tree_id);
     $template->setVariable('tag', $tag);
     $template->setVariable($key);
     // create href back url
     $url = new Url(true);
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('tag', $tag);
     $url->setParameter('nl_id', $key['nl_id']);
     $url->setParameter($view->getUrlId(), NewsLetter::VIEW_PLUGIN_OVERVIEW);
     $template->setVariable('href_back', $url->getUrl(true), false);
     // add breadcrumb item
     $objOverview = $this->plugin->getObject(NewsLetter::TYPE_DEFAULT);
     $key = array('id' => $key['nl_id']);
     $breadcrumb = array('name' => $objOverview->getName($key), 'path' => $url->getUrl(true));
     $this->director->theme->addBreadcrumb($breadcrumb);
     $this->director->theme->handleAdminLinks($template);
 }
Пример #17
0
 private function handlePluginList($tag, $parameters)
 {
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $searchcriteria = isset($parameters) && array_key_exists('searchcriteria', $parameters) ? $parameters['searchcriteria'] : array();
     $keys = isset($parameters) && array_key_exists('keys', $parameters) ? $parameters['keys'] : array();
     $searchcriteria['id'] = $keys;
     $settings = $this->plugin->getSettings();
     $template->setVariable('settings', $settings);
     $systemSite = new SystemSite();
     $tree = $systemSite->getTree();
     $list = $this->getList($searchcriteria, $pagesize, $page);
     foreach ($list['data'] as &$item) {
         //TODO get url from caller plugin (newsletter) to track visits
         $url = new Url();
         $url->setPath($request->getProtocol() . $request->getDomain() . $tree->getPath($item['tree_id']));
         $url->setParameter('id', $item['id']);
         $url->setParameter(ViewManager::URL_KEY_DEFAULT, Calendar::VIEW_DETAIL);
         $item['href_detail'] = $url->getUrl(true);
         if ($item['thumbnail']) {
             $img = new Image($item['thumbnail'], $this->plugin->getContentPath(true));
             $item['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
         }
     }
     $template->setVariable('calendar', $list);
     $this->template[$tag] = $template;
 }
Пример #18
0
 /**
  * handle overview request
  */
 private function handleOverview()
 {
     $view = ViewManager::getInstance();
     $taglist = $this->plugin->getTagList(array('plugin_type' => Gallery::TYPE_HEADLINES));
     if (!$taglist) {
         return;
     }
     $tree = $this->director->tree;
     $url = new Url(true);
     //$url->setParameter($view->getUrlId(), Gallery::VIEW_DETAIL);
     // link to gallery tree nodes
     $treeRef = new GalleryTreeRef();
     foreach ($taglist as $tag) {
         $key = array('tree_id' => $tag['tree_id'], 'tag' => $tag['tag']);
         $detail = $this->getDetail($key);
         $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
         $template->setPostfix($tag['tag']);
         $cacheable = $detail['display_order'] != Gallery::ORDER_RANDOM;
         $template->setCacheable($cacheable);
         if (!$cacheable) {
             Cache::disableCache();
         }
         $template->setVariable($detail);
         // include lightbox if needed
         if ($detail['display'] == self::DISP_LIGHTBOX) {
             $theme = $this->director->theme;
             $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/prototype.js"></script>');
             $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/scriptaculous.js"></script>');
             $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/lightbox.js"></script>');
             $theme->addHeader('<link rel="stylesheet" href="' . DIF_VIRTUAL_WEB_ROOT . 'css/lightbox.css" type="text/css" media="screen" />');
         }
         // check if template is in cache
         if (!$template->isCached()) {
             // get settings
             $settings = $this->getSettings();
             $treeRefList = $treeRef->getList($key);
             $treeItemList = array();
             foreach ($treeRefList['data'] as $treeRefItem) {
                 if (!$tree->exists($treeRefItem['ref_tree_id'])) {
                     continue;
                 }
                 $treeItemList[] = $treeRefItem['ref_tree_id'];
             }
             if (!$treeItemList) {
                 continue;
             }
             $searchcriteria = array('activated' => true, 'tree_id' => $treeItemList);
             $overview = $this->getGalleryOverview();
             $list = $overview->getList($searchcriteria, $detail['rows'], 1, $detail['display_order']);
             // skip if empty
             if ($list['totalItems'] < 1) {
                 continue;
             }
             foreach ($list['data'] as &$item) {
                 $url->setPath($tree->getPath($item['tree_id']));
                 // go to detail if requested
                 if ($detail['display'] == self::DISP_DETAIL) {
                     $url->setParameter('id', $item['id']);
                 }
                 $item['href_detail'] = $url->getUrl(true);
                 if ($item['image']) {
                     $img = new Image($item['image'], $this->plugin->getContentPath(true));
                     $item['image'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
                 }
                 if ($item['thumbnail']) {
                     $img = new Image($item['thumbnail'], $this->plugin->getContentPath(true));
                     $item['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
                 }
             }
             $template->setVariable('gallery', $list);
         }
         $this->template[$tag['tag']] = $template;
     }
 }
Пример #19
0
 /**
  * handle tree overview
  */
 private function handleTreeOverview()
 {
     $pagesize = 20;
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $view->setType(ViewManager::TREE_OVERVIEW);
     $page = $this->getPage();
     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);
     $this->pagerUrl->addParameters($key);
     $this->pagerUrl->setParameter($view->getUrlId(), $view->getType());
     $url = new Url(true);
     $url->clearParameter('id');
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('tag', $tag);
     // create urls
     $url_new = clone $url;
     $url_new->setParameter($view->getUrlId(), ViewManager::TREE_NEW);
     $template->setVariable('href_new', $url_new->getUrl(true), false);
     $url_import = clone $url;
     $url_import->setParameter($view->getUrlId(), Attachment::VIEW_FILE_IMPORT);
     $template->setVariable('href_import', $url_import->getUrl(true), false);
     $url_edit = clone $url;
     $url_edit->setParameter($view->getUrlId(), ViewManager::TREE_EDIT);
     $url_del = clone $url;
     $url_del->setParameter($view->getUrlId(), ViewManager::TREE_DELETE);
     // get settings
     $settings = $this->getSettings();
     $list = $this->getList($key, $pagesize, $page, $settings['display_order']);
     foreach ($list['data'] as &$item) {
         $url_edit->setParameter('id', $item['id']);
         $url_del->setParameter('id', $item['id']);
         $item['href_edit'] = $url_edit->getUrl(true);
         $item['href_del'] = $url_del->getUrl(true);
         if ($item['file']) {
             $item['file_url'] = $this->plugin->getFileUrl($item['id']);
         }
     }
     $template->setVariable('list', $list, false);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
Пример #20
0
 /**
  * handle sub navigation
  */
 private function handleSubNavigation()
 {
     $request = Request::getInstance();
     if (!$request->exists('poll_id')) {
         return;
     }
     $view = ViewManager::getInstance();
     $template = new TemplateEngine();
     $poll_id = $request->getValue('poll_id');
     $url = new Url(true);
     $url->setParameter('tree_id', $request->getValue('tree_id'));
     $url->setParameter('tag', $request->getValue('tag'));
     $url->setParameter('id', $poll_id);
     $url->setParameter($view->getUrlId(), ViewManager::TREE_EDIT);
     $breadcrumb = array('name' => $this->getName(array('id' => $poll_id)), 'path' => $url->getUrl(true));
     $this->director->theme->addBreadcrumb($breadcrumb);
 }
Пример #21
0
 /**
  * handle overview request
  */
 private function handleOverview()
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $page = $this->getPage();
     $this->pagerUrl->setParameter($view->getUrlId(), $view->getType());
     $view->setType(self::VIEW_OVERVIEW);
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $template->setVariable('pageTitle', $this->description);
     if (!$request->exists('ext_id')) {
         throw new Exception('Extension is missing.');
     }
     $ext_id = intval($request->getValue('ext_id'));
     // handle searchcriteria
     $search = new SearchManager();
     $search->setUrl($this->pagerUrl);
     $search->setExclude($this->pagerKey);
     $search->setParameter('search');
     $search->setParameter('ext_id', $ext_id);
     $search->saveList();
     $searchcriteria = $search->getSearchParameterList();
     $url = new Url(true);
     $url->clearParameter('ip');
     $url->setParameter('ext_id', $ext_id);
     $url_new = clone $url;
     $url_new->setParameter($view->getUrlId(), self::VIEW_NEW);
     $template->setVariable('href_new', $url_new->getUrl(true));
     $url_edit = clone $url;
     $url_edit->setParameter($view->getUrlId(), self::VIEW_EDIT);
     $url_del = clone $url;
     $url_del->setParameter($view->getUrlId(), self::VIEW_DELETE);
     $list = $this->getList($searchcriteria, $this->pagesize, $page);
     foreach ($list['data'] as &$item) {
         $url_edit->setParameter('ip', $item['ip']);
         $url_del->setParameter('ip', $item['ip']);
         $item['href_edit'] = $url_edit->getUrl(true);
         $item['href_del'] = $url_del->getUrl(true);
         if ($item['suspect']) {
             $item['state'] = 'suspect';
         } elseif (!$item['activated']) {
             $item['state'] = 'expired';
         } else {
             $item['state'] = 'intruder';
         }
     }
     $template->setVariable('list', $list);
     $template->setVariable('searchparam', $search->getMandatoryParameterList());
     $template->setVariable('searchcriteria', $searchcriteria);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
Пример #22
0
 /**
  * handle tree overview
  */
 private function handleTreeOverviewGet($retrieveFields = true)
 {
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     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);
     // add breadcrumb item
     $url = new Url(true);
     $url->clearParameter('id');
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('tag', $tag);
     // create urls
     $url_new = clone $url;
     $url_new->setParameter($view->getUrlId(), Form::VIEW_ELEMENT_NEW);
     $template->setVariable('href_new', $url_new->getUrl(true));
     $url_edit = clone $url;
     $url_edit->setParameter($view->getUrlId(), Form::VIEW_ELEMENT_EDIT);
     $url_mv_prev = clone $url;
     $url_mv_prev->setParameter($view->getUrlId(), Form::VIEW_MV_PREC);
     $url_mv_next = clone $url;
     $url_mv_next->setParameter($view->getUrlId(), Form::VIEW_MV_FOL);
     $url_del = clone $url;
     $url_del->setParameter($view->getUrlId(), Form::VIEW_ELEMENT_DELETE);
     $list = $this->getList($key, 0, 1, SqlParser::ORDER_ASC);
     $counter = 0;
     $maxcount = $list['totalItems'];
     foreach ($list['data'] as &$item) {
         $counter++;
         $url_edit->setParameter('id', $item['id']);
         $url_del->setParameter('id', $item['id']);
         $url_mv_prev->setParameter('id', $item['id']);
         $url_mv_next->setParameter('id', $item['id']);
         $item['type_id'] = $this->getTypeId($item['id']);
         $item['href_edit'] = $url_edit->getUrl(true);
         $item['href_del'] = $url_del->getUrl(true);
         if ($counter > 1) {
             $item['href_mv_prev'] = $url_mv_prev->getUrl(true);
         }
         if ($counter < $maxcount) {
             $item['href_mv_next'] = $url_mv_next->getUrl(true);
         }
     }
     $template->setVariable('list', $list);
     //$this->handleTreeSettings($template);
     $this->director->theme->handleAdminLinks($template);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
Пример #23
0
 /**
  * handle user
  */
 private function handleUserGet($retrieveFields = true)
 {
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     if (!$request->exists('id')) {
         throw new Exception('User group is missing.');
     }
     $id = intval($request->getValue('id'));
     $template->setVariable('id', $id, false);
     $key = array('id' => $id);
     $user = $this->director->adminManager->getPlugin('User');
     $usr_used = $request->getValue('usr_used');
     if ($retrieveFields) {
         $searchcriteria = array('grp_id' => $id);
         $tmp = $user->getList($searchcriteria);
         $usr_used = $tmp['data'];
     }
     $search_used = $usr_used ? array('id' => $usr_used) : NULL;
     $search_free = $usr_used ? array('no_id' => $usr_used) : NULL;
     $user_used = $usr_used ? $user->getList($search_used) : array('data' => '');
     $user_free = $user->getList($search_free);
     $template->setVariable('cbo_usr_used', Utils::getHtmlCombo($user_used['data'], NULL, NULL, 'id', 'formatName'));
     $template->setVariable('cbo_usr_free', Utils::getHtmlCombo($user_free['data'], NULL, NULL, 'id', 'formatName'));
     $view = ViewManager::getInstance();
     $url = new Url(true);
     $breadcrumb = array('name' => $view->getName(), 'path' => $url->getUrl(true));
     $this->director->theme->addBreadcrumb($breadcrumb);
     $url->setParameter($view->getUrlId(), ViewManager::ADMIN_OVERVIEW);
     $template->setVariable('href_back', $url->getUrl(true), false);
     $template->setVariable('title', $this->getName($key), false);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
Пример #24
0
 /**
  * handle tree overview
  */
 private function handleTreeOverview()
 {
     $pagesize = 20;
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $view->setType(ViewManager::TREE_OVERVIEW);
     $page = $this->getPage();
     if (!$request->exists('tree_id')) {
         throw new Exception('Node is missing.');
     }
     if (!$request->exists('tag')) {
         throw new Exception('Tag is missing.');
     }
     $tree_id = intval($request->getValue('tree_id'));
     $tag = $request->getValue('tag');
     $key = array('tree_id' => $tree_id, 'tag' => $tag);
     $this->pagerUrl->addParameters($key);
     $this->pagerUrl->setParameter($view->getUrlId(), $view->getType());
     // handle searchcriteria
     $search = new SearchManager();
     $search->setUrl($this->pagerUrl);
     $search->setExclude($this->pagerKey);
     $search->setParameter('search');
     $search->saveList();
     $searchcriteria = $search->getSearchParameterList();
     $searchcriteria = array_merge($searchcriteria, $key);
     // add breadcrumb item
     $url = new Url(true);
     $url->clearParameter('id');
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('tag', $tag);
     // create urls
     $url_new = clone $url;
     $url_new->setParameter($view->getUrlId(), ViewManager::TREE_NEW);
     $template->setVariable('href_new', $url_new->getUrl(true), false);
     $url_conf = clone $url;
     $url_conf->setParameter($view->getUrlId(), Links::VIEW_CONFIG);
     $template->setVariable('href_conf', $url_conf->getUrl(true), false);
     $url_import = clone $url;
     $url_import->setParameter($view->getUrlId(), Links::VIEW_IMPORT);
     $template->setVariable('href_import', $url_import->getUrl(true), false);
     $url_resize = clone $url;
     $url_resize->setParameter($view->getUrlId(), Links::VIEW_RESIZE);
     $template->setVariable('href_resize', $url_resize->getUrl(true), false);
     $url_edit = clone $url;
     $url_edit->setParameter($view->getUrlId(), ViewManager::TREE_EDIT);
     $url_mv_prev = clone $url;
     $url_mv_prev->setParameter($view->getUrlId(), Links::VIEW_MV_PREC);
     $url_mv_next = clone $url;
     $url_mv_next->setParameter($view->getUrlId(), Links::VIEW_MV_FOL);
     $url_del = clone $url;
     $url_del->setParameter($view->getUrlId(), ViewManager::TREE_DELETE);
     $counter = 0;
     $list = $this->getList($searchcriteria, $pagesize, $page);
     $maxcount = $list['totalItems'];
     foreach ($list['data'] as &$item) {
         $counter++;
         $url_edit->setParameter('id', $item['id']);
         $url_del->setParameter('id', $item['id']);
         $url_mv_prev->setParameter('id', $item['id']);
         $url_mv_next->setParameter('id', $item['id']);
         $item['href_edit'] = $url_edit->getUrl(true);
         $item['href_del'] = $url_del->getUrl(true);
         if ($counter > 1) {
             $item['href_mv_prev'] = $url_mv_prev->getUrl(true);
         }
         if ($counter < $maxcount) {
             $item['href_mv_next'] = $url_mv_next->getUrl(true);
         }
         if ($item['url']) {
             $item['link'] = $item['url'];
         } elseif ($item['ref_tree_id']) {
             $item['link'] = $this->director->tree->getPath($item['ref_tree_id']);
         } else {
             $item['link'] = "link detailed page";
         }
         if ($item['thumbnail']) {
             $img = new Image($item['thumbnail'], $this->getContentPath(true));
             $item['thumbnail'] = array('src' => $this->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
         }
     }
     $template->setVariable('list', $list, false);
     $template->setVariable('searchparam', $search->getMandatoryParameterList(), false);
     $template->setVariable('searchcriteria', $searchcriteria, false);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
Пример #25
0
 public function getFileUrl($id, $htmlentities = true)
 {
     $view = ViewManager::getInstance();
     $request = Request::getInstance();
     $url_file = new Url();
     $url_file->useCurrent(false);
     $url_file->setParameter($view->getUrlId(), self::VIEW_FILE);
     $url_file->setParameter('id', $id);
     $url_file->setParameter('tag', $request->getValue('tag'));
     $url_file->setParameter('tree_id', $request->getValue('tree_id'));
     return $url_file->getUrl($htmlentities);
 }
Пример #26
0
 /**
  * handle admin overview request
  */
 private function handleAdminOverview()
 {
     $view = ViewManager::getInstance();
     $log = Logger::getInstance();
     $logfile = $log->getLogFile();
     if ($view->isType(self::VIEW_FILE)) {
         $request = Request::getInstance();
         $extension = ".log";
         $filename = $request->getDomain() . $extension;
         header("Content-type: application/{$extension}");
         header("Content-Length: " . filesize($logfile));
         // stupid bastards of microsnob: ie does not like attachment option
         $browser = $request->getValue('HTTP_USER_AGENT', Request::SERVER);
         if (strstr($browser, 'MSIE')) {
             header("Content-Disposition: filename=\"{$filename}\"");
         } else {
             header("Content-Disposition: attachment; filename=\"{$filename}\"");
         }
         readfile($logfile);
         exit;
     } else {
         $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
         $template->setVariable('logfile', nl2br(file_get_contents($logfile)), false);
         $url = new Url(true);
         $url->setParameter($view->getUrlId(), self::VIEW_FILE);
         $template->setVariable('href_export', $url->getUrl(true), false);
         $this->template[$this->director->theme->getConfig()->main_tag] = $template;
     }
 }
Пример #27
0
 private function handleAdminUpdatePost()
 {
     $request = Request::getInstance();
     try {
         $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
         $debug = $this->updateExtensions();
         $view = ViewManager::getInstance();
         $view->setType(self::VIEW_SUCCESS);
         $url = new Url(true);
         $url->setParameter($view->getUrlId(), ViewManager::ADMIN_OVERVIEW);
         $template->setVariable('href_back', $url->getUrl(true), false);
         $template->setVariable('debug', is_array($debug) ? join('<br />', $debug) : '');
         $this->template[$this->director->theme->getConfig()->main_tag] = $template;
     } catch (Exception $e) {
         $template = new TemplateEngine();
         $template->setVariable('errorMessage', $e->getMessage(), false);
         $this->handleAdminUpdateGet();
     }
 }
Пример #28
0
 /**
  * handle overview
  */
 private function handleEdit($template, $usr_id)
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $tree_id = intval($request->getValue('tree_id'));
     $tag = $request->getValue('tag');
     $template->setVariable('tree_id', $tree_id, false);
     $template->setVariable('tag', $tag, false);
     $user = $this->director->systemUser;
     $usr_used = $request->getValue('usr_used');
     // get list of users that have access to the reservation module
     $groupList = $this->getGroupList($tree_id);
     $theme = $this->director->theme;
     $theme->addJavascript(file_get_contents($this->plugin->getHtdocsPath(true) . 'js/multibox.js'));
     // get list of group owners
     if ($view->isType(Reservation::VIEW_USER_GROUP_NEW)) {
         $userList = $user->getList(array('grp_id' => $groupList));
         $template->setVariable('cbo_user', Utils::getHtmlCombo($userList['data'], $usr_id, 'select a user...', 'id', 'formatName'));
         $theme->addFileVar('reservation_htdocs_path', $this->plugin->getHtdocsPath());
         // parse rpc file to set variables
         $rpcfile_src = $this->plugin->getHtdocsPath(true) . "js/rpc.js.in";
         $theme->addJavascript($theme->fetchFile($rpcfile_src));
         $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/prototype.js"></script>');
         $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/scriptaculous.js"></script>');
         $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/jsxmlrpc/lib/xmlrpc_lib.js"></script>');
         $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/jsxmlrpc/lib/xmlrpc_wrappers.js"></script>');
     }
     if ($view->isType(Reservation::VIEW_USER_GROUP_EDIT) || $request->getRequestType() == Request::POST) {
         $grp_id = intval($request->getValue('id'));
         $template->setVariable('tpl_userselect', $this->getUserSelection($tree_id, $usr_id, $grp_id, $usr_used));
     }
     // add overview link
     $view = ViewManager::getInstance();
     $url = new Url(true);
     $url->clearParameter('id');
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('tag', $tag);
     $url->setParameter($view->getUrlId(), Reservation::VIEW_USER_GROUP_OVERVIEW);
     $breadcrumb = array('name' => $view->getName(Reservation::VIEW_USER_GROUP_OVERVIEW), 'path' => $url->getUrl(true));
     $this->director->theme->addBreadcrumb($breadcrumb);
     // create up & back links and create breadcrumb
     $this->director->theme->handleAdminLinks($template);
 }
Пример #29
0
 /**
  * Returns protected var $oberserver.
  * @param string observer key
  * @return array
  */
 public function getTagList($param)
 {
     $id = $param['id'];
     $tree_id = $param['tree_id'];
     $url_edit = new Url();
     $url_del = new Url();
     $url_edit->fromString($param['href_edit_theme_tag']);
     $url_del->fromString($param['href_del_theme_tag']);
     try {
         $siteTag = new SystemSiteTag();
         $theme = $this->director->themeManager->getThemeFromId(array('id' => $id));
         $usedTags = $siteTag->getTagList(array('tree_id' => $tree_id));
         $taglist = $theme->getTagList();
         foreach ($taglist as &$item) {
             $item['userdefined'] = array_key_exists($item['id'], $usedTags) ? join(', ', $usedTags[$item['id']]) : '';
             $url_edit->setParameter('parent_tag', $item['id']);
             $url_del->setParameter('parent_tag', $item['id']);
             $item['href_edit'] = $url_edit->getUrl();
             $item['href_del'] = $item['userdefined'] ? $url_del->getUrl() : '';
         }
         return array_values($taglist);
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }
Пример #30
0
 /**
  * handle overview
  */
 private function handleEdit($template)
 {
     $request = Request::getInstance();
     $tree_id = intval($request->getValue('tree_id'));
     $tag = $request->getValue('tag');
     $template->setVariable('tree_id', $tree_id, false);
     $template->setVariable('tag', $tag, false);
     // add overview link
     $view = ViewManager::getInstance();
     $url = new Url(true);
     $url->clearParameter('id');
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('tag', $tag);
     $url->setParameter($view->getUrlId(), Reservation::VIEW_BLOCK_PERIOD_OVERVIEW);
     $breadcrumb = array('name' => $view->getName(Reservation::VIEW_BLOCK_PERIOD_OVERVIEW), 'path' => $url->getUrl(true));
     $this->director->theme->addBreadcrumb($breadcrumb);
     // create up & back links and create breadcrumb
     $this->director->theme->handleAdminLinks($template);
     $datefields = array();
     $datefields[] = array('dateField' => 'date_start', 'triggerElement' => 'date_start');
     $datefields[] = array('dateField' => 'date_stop', 'triggerElement' => 'date_stop');
     Utils::getDatePicker($this->director->theme, $datefields);
 }