예제 #1
0
 /**
  * renders tree into menu template
  * @return  object
  */
 public function renderTree()
 {
     if (!$this->getConfig()->template_menu) {
         return;
     }
     if (!$this->tree) {
         return;
     }
     $template = new TemplateEngine($this->templatePath . $this->getConfig()->template_menu);
     $template->setCacheable(true);
     $cache = Cache::getInstance();
     if (!$cache->isCached('submenu')) {
         $childs = array();
         $childlist = $this->tree->getChildList($this->tree->getCurrentId());
         foreach ($childlist as $item) {
             if (isset($item['visible']) && !$item['visible']) {
                 continue;
             }
             $item['path'] = $this->tree->getPath($item['id']);
             $childs[] = $item;
         }
         $template->setVariable('submenu', $childs, false);
         $cache->save(serialize($childs), 'submenu');
     } else {
         $template->setVariable('submenu', unserialize($cache->getCache('submenu')), false);
     }
     // check if template is in cache
     if ($template->isCached()) {
         return $template;
     }
     $menu = $this->tree->getRootList();
     // get selected main menu item
     $firstNode = $this->tree->getFirstAncestorNode($this->tree->getCurrentId());
     $firstId = $firstNode ? $firstNode['id'] : 0;
     foreach ($menu as &$item) {
         $item['path'] = isset($item['external']) && $item['external'] ? $item['url'] : $this->tree->getPath($item['id']);
         $item['selected'] = $item['id'] == $firstId;
     }
     $template->setVariable('menu', $menu, false);
     $auth = Authentication::getInstance();
     $template->setVariable('loginName', $auth->getUserName(), false);
     return $template;
 }
예제 #2
0
 public function getImageTemplate($cal_id, $tag)
 {
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $template->setPostfix($tag . $cal_id);
     $template->setCacheable(true);
     // check if template is in cache
     if (!$template->isCached()) {
         $searchcriteria = array('cal_id' => $cal_id, 'activated' => true);
         $imageSelect = array();
         $htdocsPathAbs = $this->plugin->getContentPath(true);
         $htdocsPath = $this->plugin->getContentPath(false);
         $list = $this->getList($searchcriteria);
         foreach ($list['data'] as &$item) {
             $imageSelect[] = $item['id'];
             if ($item['image']) {
                 $img = new Image($item['image'], $htdocsPathAbs);
                 $item['image'] = array('src' => $htdocsPath . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
             }
             if ($item['thumbnail']) {
                 $img = new Image($item['thumbnail'], $htdocsPathAbs);
                 $item['thumbnail'] = array('src' => $htdocsPath . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
             }
         }
         $template->setVariable('calendarimage', $list);
     }
     $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" />');
     return $template;
 }
예제 #3
0
 /**
  * handle detail request
  */
 private function handleDetail()
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     // process attachments
     $attachment = $this->getAttachment();
     $attachment->handleHttpGetRequest();
     // clear subtitle
     $view->setName('');
     // check security
     if (!$request->exists('id')) {
         throw new Exception('Poll item is missing.');
     }
     $id = intval($request->getValue('id'));
     $key = array('id' => $id, 'activated' => true);
     if (!$this->exists($key)) {
         throw new HttpException('404');
     }
     $detail = $this->getDetail($key);
     // check if tree node of poll item is accessable
     $tree = $this->director->tree;
     if (!$tree->exists($detail['tree_id'])) {
         throw new HttpException('404');
     }
     // process request
     $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
     $this->updateCount($key);
     // overwrite default naming
     $template->setVariable('pageTitle', $detail['name'], false);
     // add breadcrumb item
     $url = new Url(true);
     $url->clearParameter('id');
     $breadcrumb = array('name' => $detail['name'], 'path' => $url->getUrl(true));
     $this->director->theme->addBreadcrumb($breadcrumb);
     // check if template is in cache
     /*
     if(!$template->isCached())
     {
     	$template->setVariable('poll',  $detail, false);
     }
     */
     $template->setVariable('poll', $detail, false);
     $settings = $this->getPollSettings();
     $treeSettings = $settings->getSettings($detail['tag'], $detail['tree_id']);
     $template->setVariable('newssettings', $treeSettings, false);
     // get settings
     if ($treeSettings['item']) {
         // process items
         $item = $this->getItem();
         $item->handleHttpGetRequest();
     }
     $url = new Url(true);
     $url->clearParameter('id');
     $url->setParameter($view->getUrlId(), ViewManager::OVERVIEW);
     $template->setVariable('href_back', $url->getUrl(true), false);
     $this->template[$detail['tag']] = $template;
 }
예제 #4
0
파일: Menu.php 프로젝트: rverbrugge/dif
 /**
  * handle overview request
  */
 private function handleOverview()
 {
     $taglist = $this->getTagList();
     if (!$taglist) {
         return;
     }
     foreach ($taglist as $item) {
         $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
         $template->setCacheable(true);
         $template->setPostfix($item['tag']);
         $skip = false;
         $key = array('tree_id' => $item['tree_id'], 'tag' => $item['tag']);
         $detail = $this->exists($key) ? $this->getDetail($key) : $this->getFields(SqlParser::MOD_INSERT);
         switch ($detail['type']) {
             case self::TYPE_HORIZONTAL_LEVEL1:
             case self::TYPE_VERTICAL_LEVEL1:
             case self::TYPE_VERTICAL_LEVEL2:
                 $this->handleSingleMenu($detail, $template);
                 break;
             case self::TYPE_HORIZONTAL_PULLDOWN:
             case self::TYPE_VERTICAL_PULLDOWN:
                 $this->handlePulldownMenu($detail, $template);
                 break;
             default:
                 $skip = true;
         }
         // skip if no type defined
         if ($skip) {
             continue;
         }
         $this->template[$item['tag']] = $template;
     }
 }
예제 #5
0
 public function getAttachmentTemplate($nl_id, $tag)
 {
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $template->setPostfix($tag . $nl_id);
     $template->setCacheable(true);
     // check if template is in cache
     if (!$template->isCached()) {
         $searchcriteria = array('nl_id' => $nl_id, 'activated' => true);
         $list = $this->getList($searchcriteria);
         foreach ($list['data'] as &$item) {
             $item['href_detail'] = $item['file'] ? $this->plugin->getFileUrl($item['id']) : '';
         }
         $template->setVariable('attachment', $list);
     }
     return $template;
 }
예제 #6
0
 /**
  * handle overview request
  */
 private function handleOverview()
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $page = $this->getPage();
     $this->pagerUrl->setParameter($view->getUrlId(), $view->getType());
     // retrieve tags that are linked to this plugin
     $taglist = $this->plugin->getTagList();
     if (!$taglist) {
         return;
     }
     // get settings
     $settings = $this->getSettings();
     foreach ($taglist as $tag) {
         $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
         $template->setPostfix($tag['tag']);
         $template->setCacheable(true);
         $template->setVariable($settings, NULL, false);
         // check if template is in cache
         if (!$template->isCached()) {
             $pagesize = $settings['rows'];
             $searchcriteria = array('tree_id' => $tag['tree_id'], 'tag' => $tag['tag'], 'activated' => true);
             $list = $this->getList($searchcriteria, $pagesize, $page, $settings['display_order']);
             foreach ($list['data'] as &$item) {
                 $item['href_detail'] = $item['file'] ? $this->plugin->getFileUrl($item['id']) : '';
             }
             $template->setVariable('attachment', $list);
         }
         $this->template[$tag['tag']] = $template;
     }
 }
예제 #7
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']);
         // check if template is in cache
         if (!$template->isCached()) {
             $key = array('tree_id' => $item['tree_id'], 'tag' => $item['tag']);
             $detail = $this->getDetail($key);
             $currentId = $tree->getCurrentId();
             if (!$detail['type'] || $detail['type'] == self::TYPE_SKIP_TOP && $tree->getParentId($currentId) == $tree->getRootId() || $detail['type'] == self::TYPE_LAST && !$tree->isLeafNode($currentId)) {
                 continue;
             }
             $parentId = $tree->getParentId($currentId);
             $sibling = array();
             $siblinglist = $tree->getChildList($parentId);
             foreach ($siblinglist as $sibitem) {
                 if (isset($sibitem['visible']) && !$sibitem['visible']) {
                     continue;
                 }
                 $sibitem['path'] = isset($sibitem['external']) && $sibitem['external'] ? $sibitem['url'] : $tree->getPath($sibitem['id']);
                 $sibling[] = $sibitem;
             }
             // skip if no sibling present
             if (sizeof($sibling) <= 1) {
                 return;
             }
             if ($detail['show_name']) {
                 $template->setVariable('currentmenuname', $tree->getName($parentId));
             }
             $template->setVariable('currentmenu', $sibling);
             $template->setVariable('currentId', $currentId);
         }
         $this->template[$item['tag']] = $template;
     }
 }
예제 #8
0
파일: SubMenu.php 프로젝트: rverbrugge/dif
 /**
  * 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']);
         // check if template is in cache
         if (!$template->isCached()) {
             $key = array('tree_id' => $item['tree_id'], 'tag' => $item['tag']);
             $detail = $this->exists($key) ? $this->getDetail($key) : $this->getFields(SqlParser::MOD_INSERT);
             $currentId = $tree->getCurrentId();
             if (!$detail['type'] || $detail['type'] == self::TYPE_SKIP_TOP && $tree->getParentId($currentId) == $tree->getRootId()) {
                 continue;
             }
             $childs = array();
             $childlist = $tree->getChildList($currentId);
             foreach ($childlist as $subitem) {
                 if (isset($subitem['visible']) && !$subitem['visible']) {
                     continue;
                 }
                 $subitem['path'] = isset($subitem['external']) && $subitem['external'] ? $subitem['url'] : $tree->getPath($subitem['id']);
                 $childs[] = $subitem;
             }
             // skip if no submenu
             if (!$childs) {
                 return;
             }
             if ($detail['show_name']) {
                 $template->setVariable('submenuname', $tree->getName($currentId));
             }
             $template->setVariable('submenu', $childs);
         }
         $this->template[$item['tag']] = $template;
     }
 }
예제 #9
0
파일: PollItem.php 프로젝트: rverbrugge/dif
 /**
  * handle overview request
  */
 private function handleOverview()
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $tag = 'poll_item';
     if (!$request->exists('id')) {
         throw new Exception('Poll is missing.');
     }
     $poll_id = intval($request->getValue('id'));
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $template->setPostfix($tag);
     $template->setCacheable(true);
     // add item if requested
     if ($request->exists(self::VIEW_KEY)) {
         $this->handleItemAdd($template);
     }
     // check if template is in cache
     if (!$template->isCached()) {
         // retrieve items
         $searchcriteria = array('poll_id' => $poll_id, 'activated' => true);
         $list = $this->getList($searchcriteria);
         $template->setVariable('item', $list);
     }
     $this->template[$tag] = $template;
 }
예제 #10
0
 /**
  * handle detail request
  */
 private function handleDetail()
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     // clear subtitle
     $view->setName('');
     // check security
     if (!$request->exists('id')) {
         throw new Exception('Reservation item is missing.');
     }
     $id = intval($request->getValue('id'));
     $key = array('id' => $id, 'activated' => true);
     if (!$this->exists($key)) {
         throw new HttpException('404');
     }
     $detail = $this->getDetail($key);
     // check if tree node of reservation item is accessable
     $tree = $this->director->tree;
     if (!$tree->exists($detail['tree_id'])) {
         throw new HttpException('404');
     }
     // process request
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $template->setPostfix($detail['tag']);
     $template->setCacheable(true);
     // overwrite default naming
     $template->setVariable('pageTitle', $detail['name'], false);
     // add breadcrumb item
     $url = new Url(true);
     $url->clearParameter('id');
     $breadcrumb = array('name' => $detail['name'], 'path' => $url->getUrl(true));
     $this->director->theme->addBreadcrumb($breadcrumb);
     // check if template is in cache
     if (!$template->isCached()) {
         $template->setVariable('reservation', $detail);
     }
     $objSettings = $this->plugin->getObject(Reservation::TYPE_SETTINGS);
     $settings = $objSettings->getSettings($detail['tree_id'], $detail['tag']);
     $template->setVariable('reservationsettings', $settings, false);
     $url = new Url(true);
     $url->clearParameter('id');
     $url->setParameter($view->getUrlId(), ViewManager::OVERVIEW);
     $template->setVariable('href_back', $url->getUrl(true), false);
     $this->template[$detail['tag']] = $template;
 }
예제 #11
0
 /**
  * handle edit request
  */
 private function handleTreeEditGet($retrieveFields = true)
 {
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $view->setType(ViewManager::TREE_EDIT);
     $element = $this->plugin->getObject(Form::TYPE_ELEMENT);
     $record = $this->plugin->getObject(Form::TYPE_RECORD);
     $recordItem = $this->plugin->getObject(Form::TYPE_RECORD_ITEM);
     if (!$request->exists('rcd_id')) {
         throw new Exception('Record id is missing.');
     }
     $rcd_id = intval($request->getValue('rcd_id'));
     $key = array('id' => $rcd_id);
     if (!$record->exists($key)) {
         throw new Exception('Record does not exist.');
     }
     $recordDetail = $record->getDetail($key);
     $tree_id = $recordDetail['tree_id'];
     $tag = $recordDetail['tag'];
     // get record items
     if ($request->getRequestType() == Request::GET) {
         $recordItemList = $recordItem->getRecordElementList($rcd_id);
     } else {
         $recordItemList = array();
     }
     // get settings
     $settings = $this->plugin->getSettings($tree_id, $tag);
     $templateItem = new TemplateEngine($this->getPath() . "templates/formoverviewitem.tpl");
     $template->setPostfix($tag);
     $template->setCacheable(true);
     $templateItem->setVariable('settings', $settings);
     $searchcriteria = array('tree_id' => $tree_id, 'tag' => $tag, 'active' => true);
     $list = $element->getList($searchcriteria, 0, 1, SqlParser::ORDER_ASC);
     foreach ($list['data'] as &$item) {
         $obj = $element->getObject($item['type'], $item);
         $obj->setId($element->getTypeId($item['id']));
         if ($request->getRequestType() == Request::POST) {
             $obj->handlePostRequest();
         } elseif (array_key_exists($obj->getId(), $recordItemList)) {
             $obj->handleSetValue($recordItemList[$obj->getId()]['value']);
         }
         $item['html'] = $obj->getHtml();
         $item['class'] = get_class($obj);
     }
     $templateItem->setVariable('fields', $list);
     $template->setVariable('rcd_id', $rcd_id);
     $template->setVariable('tag', $tag);
     $template->setVariable('settings', $settings);
     $template->setVariable('tpl_element_item', $templateItem);
     $this->handleTreeSettings($template);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
예제 #12
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;
     }
 }
예제 #13
0
 /**
  * handle detail request
  */
 private function handleDetail()
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     // clear subtitle
     $view->setName('');
     if (!$request->exists('id')) {
         throw new Exception('Galerij ontbreekt.');
     }
     $id = intval($request->getValue('id'));
     $key = array('id' => $id, 'activated' => true);
     if (!$this->exists($key)) {
         throw new HttpException('404');
     }
     $detail = $this->getDetail($key);
     // check if tree node of gallery 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->setCacheable(true);
     // overwrite default naming
     $template->setVariable('pageTitle', $detail['name'], false);
     // add breadcrumb item
     $url = new Url(true);
     $url->clearParameter('id');
     $breadcrumb = array('name' => $detail['name'], 'path' => $url->getUrl(true));
     $this->director->theme->addBreadcrumb($breadcrumb);
     // check if template is in cache
     if (!$template->isCached()) {
         // add image
         if ($detail['image']) {
             $img = new Image($detail['image'], $this->plugin->getContentPath(true));
             $detail['image'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
         }
         $template->setVariable('gallery', $detail, false);
         // previous and next
         $url = new Url(true);
         $search = array('activated' => true, 'previous' => $detail['id']);
         $prev_id = $this->getId($search);
         if ($prev_id) {
             $url->setParameter('id', $prev_id);
             $template->setVariable('href_previous', $url->getUrl(true), false);
         }
         $search = array('activated' => true, 'next' => $detail['id']);
         $next_id = $this->getId($search);
         if ($next_id) {
             $url->setParameter('id', $next_id);
             $template->setVariable('href_next', $url->getUrl(true), false);
         }
         // comment
         $settings = $this->getSettings($detail['tree_id'], $detail['tag']);
         $template->setVariable('gallerysettings', $settings);
         // get settings
         if ($settings['comment']) {
             // process comments
             $comment = $this->plugin->getObject(Gallery::TYPE_COMMENT);
             $comment->setSettings($settings);
             $comment->handleHttpGetRequest();
         }
     }
     $url = new Url(true);
     $url->clearParameter('id');
     $url->setParameter($view->getUrlId(), ViewManager::OVERVIEW);
     $template->setVariable('href_back', $url->getUrl(true), false);
     $this->template[$detail['tag']] = $template;
 }
예제 #14
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' => Calendar::TYPE_ARCHIVE));
     if (!$taglist) {
         return;
     }
     $taginfo = current($taglist);
     // process attachments
     $attachment = $this->plugin->getObject(Calendar::TYPE_ATTACHMENT);
     $attachment->handleHttpGetRequest();
     // process images
     $image = $this->plugin->getObject(Calendar::TYPE_IMAGE);
     $image->handleHttpGetRequest();
     // clear subtitle
     $view->setName('');
     if (!$request->exists('id')) {
         throw new Exception('Calendar id is missing.');
     }
     $id = intval($request->getValue('id'));
     $key = array('id' => $id, 'active' => true, 'finished' => true);
     $overview = $this->plugin->getObject(Calendar::TYPE_DEFAULT);
     if (!$overview->exists($key)) {
         return;
     }
     $detail = $overview->getDetail($key);
     // check if tree node of cal item is accessable
     $tree = $this->director->tree;
     if (!$tree->exists($detail['tree_id'])) {
         throw new HttpException('404');
     }
     $objSettings = $this->plugin->getObject(Calendar::TYPE_SETTINGS);
     $settings = $objSettings->getSettings($detail['tree_id'], $detail['tag']);
     if ($detail['thumbnail']) {
         $img = new Image($detail['thumbnail'], $this->plugin->getContentPath(true));
         $detail['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
     }
     $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);
     $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);
     $template->setVariable('cal', $detail, false);
     $template->setVariable('settings', $settings);
     $template->setVariable('calsettings', $settings, false);
     // get settings
     if ($settings['comment']) {
         // process comments
         $comment = $this->plugin->getObject(Calendar::TYPE_COMMENT);
         $comment->setSettings($settings);
         $comment->handleHttpGetRequest();
     }
     $this->template[$taginfo['tag']] = $template;
 }
예제 #15
0
 /**
  * handle overview request
  */
 private function handleOverview()
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     // retrieve tags that are linked to this plugin
     $taglist = $this->plugin->getTagList(array('plugin_type' => Reservation::TYPE_LIST));
     if (!$taglist) {
         return;
     }
     foreach ($taglist as $tag) {
         $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
         $template->setPostfix($tag['tag']);
         $template->setCacheable(false);
         $template->setVariable($tag, null, false);
         $this->template[$tag['tag']] = $template;
     }
     $this->director->theme->addJavascript('Event.observe( window, "load", function() { getReservationList();} );');
 }
예제 #16
0
 /**
  * handle overview request
  */
 private function handleOverview($tree_id = NULL, $tag = NULL)
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $page = $this->getPage();
     $this->pagerUrl->setParameter($view->getUrlId(), $view->getType());
     $active_id = NULL;
     // retrieve tags that are linked to this plugin
     if (!isset($tree_id) && !isset($tag)) {
         $taglist = $this->plugin->getTagList();
         if (!$taglist) {
             return;
         }
     } else {
         $taglist = array(array('tree_id' => $tree_id, 'tag' => $tag));
         $active_id = intval($request->getValue('id'));
     }
     $url = new Url(true);
     $url->setParameter($view->getUrlId(), Links::VIEW_DETAIL);
     foreach ($taglist as $tag) {
         $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
         $template->setPostfix($tag['tag']);
         $template->setCacheable(true);
         $template->setVariable('active_id', $active_id);
         if (isset($active_id)) {
             $template->setVariable('currentView', ViewManager::OVERVIEW);
         }
         // check if template is in cache
         if (!$template->isCached()) {
             // get settings
             $settings = $this->plugin->getObject(Links::TYPE_SETTINGS)->getSettings($tag['tag'], $tag['tree_id']);
             $pagesize = $settings['rows'];
             $searchcriteria = array('tree_id' => $tag['tree_id'], 'tag' => $tag['tag'], 'activated' => true);
             $list = $this->getList($searchcriteria, $pagesize, $page);
             foreach ($list['data'] as &$item) {
                 if ($item['url']) {
                     $item['href_detail'] = $item['url'];
                 } elseif ($item['ref_tree_id']) {
                     $item['href_detail'] = $this->director->tree->getPath($item['ref_tree_id']);
                 } else {
                     $url->setParameter('id', $item['id']);
                     $item['href_detail'] = $url->getUrl(true);
                 }
                 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('links', $list);
             $template->setVariable('settings', $settings);
         }
         $this->template[$tag['tag']] = $template;
     }
 }
예제 #17
0
파일: Source.php 프로젝트: rverbrugge/dif
 /**
  * handle overview request
  */
 private function handleOverview()
 {
     $taglist = $this->getTagList();
     if (!$taglist) {
         return;
     }
     foreach ($taglist as $item) {
         $template = new TemplateEngine();
         $template->setPostfix($item['tag']);
         $template->setCacheable(true);
         // check if template is in cache
         if (!$template->isCached()) {
             $key = array('tree_id' => $item['tree_id'], 'tag' => $item['tag']);
             $detail = $this->getDetail($key);
             $template->setFile($detail['text']);
             $template->setIncludeFile(false);
         }
         $this->template[$item['tag']] = $template;
     }
 }
예제 #18
0
 /**
  * handle detail request
  */
 private function handleDetail()
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     // process attachments
     $attachment = $this->plugin->getObject(Calendar::TYPE_ATTACHMENT);
     $attachment->handleHttpGetRequest();
     // process images
     $image = $this->plugin->getObject(Calendar::TYPE_IMAGE);
     $image->handleHttpGetRequest();
     // clear subtitle
     $view->setName('');
     // check security
     if (!$request->exists('id')) {
         throw new Exception('Calendar id is missing.');
     }
     $id = intval($request->getValue('id'));
     $key = array('id' => $id, 'activated' => $settings['history'] ? strftime('%Y-%m-%d', $settings['history']) : '');
     if (!$this->exists($key)) {
         throw new HttpException('404');
     }
     $detail = $this->getDetail($key);
     $objSettings = $this->plugin->getObject(Calendar::TYPE_SETTINGS);
     $settings = $objSettings->getSettings($detail['tree_id'], $detail['tag']);
     // check if tree node of cal item is accessable
     $tree = $this->director->tree;
     if (!$tree->exists($detail['tree_id'])) {
         throw new HttpException('404');
     }
     if ($detail['thumbnail']) {
         $img = new Image($detail['thumbnail'], $this->plugin->getContentPath(true));
         $detail['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
     }
     // process request
     $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
     $this->updateCount($key);
     // overwrite default naming
     $template->setVariable('pageTitle', $detail['name'], false);
     // add breadcrumb item
     $url = new Url(true);
     $url->clearParameter('id');
     $breadcrumb = array('name' => $detail['name'], 'path' => $url->getUrl(true));
     $this->director->theme->addBreadcrumb($breadcrumb);
     $template->setVariable('cal', $detail, false);
     $template->setVariable('settings', $settings);
     $template->setVariable('calsettings', $settings, false);
     // get settings
     if ($settings['comment']) {
         // process comments
         $comment = $this->plugin->getObject(Calendar::TYPE_COMMENT);
         $comment->setSettings($settings);
         $comment->handleHttpGetRequest();
     }
     $url->setParameter($view->getUrlId(), ViewManager::OVERVIEW);
     $template->setVariable('href_back', $url->getUrl(true), false);
     $this->template[$detail['tag']] = $template;
 }
예제 #19
0
 /**
  * handle overview request
  */
 private function handleOverview()
 {
     $view = ViewManager::getInstance();
     $taglist = $this->plugin->getTagList();
     if (!$taglist) {
         return;
     }
     $tree = $this->director->tree;
     // link to attachment tree nodes
     $treeRef = new AttachmentTreeRef();
     foreach ($taglist as $item) {
         $key = array('tree_id' => $item['tree_id'], 'tag' => $item['tag']);
         $detail = $this->getDetail($key);
         $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
         $template->setPostfix($item['tag']);
         $template->setCacheable($detail['display_order'] != Attachment::ORDER_RAND);
         // 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);
             $display_order = $detail['display_order'] ? $detail['display_order'] : $settings['display_order'];
             $overview = $this->getAttachmentOverview();
             $list = $overview->getList($searchcriteria, $detail['rows'], 1, $display_order);
             // skip if empty
             if ($list['totalItems'] < 1) {
                 continue;
             }
             foreach ($list['data'] as &$att) {
                 $att['href_detail'] = $att['file'] ? $this->plugin->getFileUrl($att['id']) : '';
             }
             $template->setVariable('attachment', $list);
             $template->setVariable('name', $detail['name']);
             $template->setVariable('display', $settings['display_hdl']);
         }
         $this->template[$item['tag']] = $template;
     }
 }
예제 #20
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;
     }
 }
예제 #21
0
 public function getImageTemplate($news_id, $tag)
 {
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $template->setPostfix($tag . $news_id);
     $template->setCacheable(true);
     // check if template is in cache
     if (!$template->isCached()) {
         $searchcriteria = array('news_id' => $news_id, 'activated' => true);
         $imageSelect = array();
         $htdocsPathAbs = $this->plugin->getContentPath(true);
         $htdocsPath = $this->plugin->getContentPath(false);
         $list = $this->getList($searchcriteria);
         foreach ($list['data'] as &$item) {
             $imageSelect[] = $item['id'];
             if ($item['image']) {
                 $img = new Image($item['image'], $htdocsPathAbs);
                 $item['image'] = array('src' => $htdocsPath . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
             }
             if ($item['thumbnail']) {
                 $img = new Image($item['thumbnail'], $htdocsPathAbs);
                 $item['thumbnail'] = array('src' => $htdocsPath . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
             }
         }
         /*
         // retrieve all images for lightbox
         $all = $this->getList($searchcriteria);
         $pregallery =  array();
         $postgallery = array();
         $pre = true;
         foreach($all['data'] as $allImg)
         {
         	if(in_array($allImg['id'], $imageSelect))
         	{
         		// image is in selection, skip image and change array to post
         		$pre = false;
         		continue;
         	}
         	if($allImg['image'])
         	{
         		$img = new Image($allImg['image'], $htdocsPathAbs);
         		$allImg['image'] = array('src' => $htdocsPath.$img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
         	}
         	// add to right array
         	$pre ? $prenewsimage[] = $allImg : $postnewsimage[] = $allImg;
         }
         $template->setVariable('prenewsimage',  $prenewsimage);
         $template->setVariable('postnewsimage',  $postnewsimage);
         */
         $template->setVariable('newsimage', $list);
     }
     $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" />');
     return $template;
 }
예제 #22
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;
 }
예제 #23
0
 /**
  * handle overview request
  */
 private function handleOverview()
 {
     $view = ViewManager::getInstance();
     $taglist = $this->plugin->getTagList();
     if (!$taglist) {
         return;
     }
     $tree = $this->director->tree;
     // link to attachment tree nodes
     $treeRef = new AttachmentTreeRef();
     foreach ($taglist as $item) {
         $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
         $template->setPostfix($item['tag']);
         $template->setCacheable(true);
         // check if template is in cache
         if (!$template->isCached()) {
             // get settings
             $settings = $this->getSettings();
             $key = array('tree_id' => $item['tree_id'], 'tag' => $item['tag']);
             $detail = $this->getDetail($key);
             $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('tree_id' => $treeItemList, 'active' => true);
             if ($detail['online']) {
                 $searchcriteria['archiveonline'] = $detail['online'];
             }
             $searchcriteria['archiveoffline'] = $detail['offline'] ? $detail['offline'] : time();
             $overview = $this->getAttachmentOverview();
             $list = $overview->getList($searchcriteria, $settings['rows']);
             foreach ($list['data'] as &$item) {
                 $item['href_detail'] = $item['file'] ? $this->plugin->getFileUrl($item['id']) : '';
             }
             $template->setVariable('attachment', $list);
             $template->setVariable('display', $settings['display'], false);
         }
         $this->template[$detail['tag']] = $template;
     }
 }
예제 #24
0
 public function getOverview($cal_id)
 {
     $cal_id = intval($cal_id);
     $tag = 'calendarcomment';
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $template->setPostfix($tag);
     $template->setCacheable(true);
     $template->setVariable('cal_id', $cal_id);
     // check if template is in cache
     if (!$template->isCached()) {
         // retrieve comments
         $searchcriteria = array('cal_id' => $cal_id, 'activated' => true);
         $settings = $this->getSettings();
         $order = array_key_exists('comment_order_asc', $settings) && $settings['comment_order_asc'] ? SqlParser::ORDER_ASC : SqlParser::ORDER_DESC;
         $list = $this->getList($searchcriteria, 0, 1, $order);
         $template->setVariable('calendarsettings', $settings);
         $template->setVariable('comment', $list);
     }
     return $template;
 }
예제 #25
0
 /**
  * handle overview request
  */
 private function handleOverview()
 {
     $view = ViewManager::getInstance();
     $taglist = $this->plugin->getTagList(array('plugin_type' => News::TYPE_HEADLINES));
     if (!$taglist) {
         return;
     }
     $tree = $this->director->tree;
     $url = new Url(true);
     $url->setParameter($view->getUrlId(), News::VIEW_DETAIL);
     // link to news tree nodes
     $treeRef = new NewsTreeRef();
     foreach ($taglist as $tag) {
         $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
         $template->setPostfix($tag['tag']);
         $template->setCacheable(true);
         // check if template is in cache
         if (!$template->isCached()) {
             // get settings
             //$settings = $this->getSettings();
             $key = array('tree_id' => $tag['tree_id'], 'tag' => $tag['tag']);
             $detail = $this->getDetail($key);
             $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->getNewsOverview();
             $list = $overview->getList($searchcriteria, $detail['rows']);
             // skip if empty
             if ($list['totalItems'] < 1) {
                 continue;
             }
             foreach ($list['data'] as &$item) {
                 $url->setPath($tree->getPath($item['tree_id']));
                 $url->setParameter('id', $item['id']);
                 $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('news', $list);
             $template->setVariable('settings', $detail);
         }
         $this->template[$tag['tag']] = $template;
     }
 }