public function render($runData) { $this->build($runData); $smarty = Ozone::getSmarty(); // put context into context $context = $runData->getContext(); if ($context !== null) { foreach ($context as $key => $value) { $smarty->assign($key, $value); } } $templateFile = WIKIDOT_ROOT . '/templates/screens/feed/FeedTemplate.tpl'; $out = $smarty->fetch($templateFile); return $out; }
public function load($macroSet) { $smarty = Ozone::getSmarty(); $smarty->fetch($this->macroPath . $macroSet . '.tpl'); // should we load it for the plain smarty too? }
/** * This method renders the page. * */ public function render($runData) { ## render! if ($runData->getScreenTemplate() == null || $runData->getPage()->getLayout() == null) { return null; } $smarty = Ozone::getSmarty(); $templateFile = PathManager::screenTemplate($runData->getScreenTemplate()); ////////// $updateLayoutContentLater = false; $mainContent = null; if (!file_exists($templateFile)) { // some error please! $runData->setScreenTemplate("DefaultError"); $runData->addErrorMessage("Taka strona nie istnieje."); $templateFile = PathManager::screenTemplate($runData->getScreenTemplate()); } else { // process the cache!!! $cacheSettings = $this->getScreenCacheSettings(); if ($runData->getRequestMethod() == "GET" && $runData->getAction() == null && $cacheSettings != null && $cacheSettings->isScreenCacheable($runData)) { $content = ScreenCacheManager::instance()->cachedScreen($runData, $this->getScreenCacheSettings()); if ($content != null && $content != "") { $mainContent = $content; } else { $updateScreenContentLater = true; // run user's method "build" $this->build($runData); } // cache end!!! (for now...) } else { // run user's method "build" $this->build($runData); } } // repeat in case sceen template has changed... $templateFile = PathManager::screenTemplate($runData->getScreenTemplate()); // put context into context $context = $runData->getContext(); if ($context !== null) { foreach ($context as $key => $value) { $smarty->assign($key, $value); } } $page = $runData->getPage(); $smarty->assign("page", $page); // put errorMessages and messages into the smarty's context as well. $dataMessages = $runData->getMessages(); $dataErrorMessages = $runData->getErrorMessages(); if (count($dataMessages) > 0) { $smarty->assign('data_messages', $dataMessages); } if (count($dataErrorMessages) > 0) { $smarty->assign('data_errorMessages', $dataErrorMessages); } if ($mainContent == null) { $mainContent = $smarty->fetch($templateFile); } if ($updateScreenContentLater) { // update the cached content in the database ScreenCacheManager::instance()->updateCachedScreen($runData, $mainContent); } $layoutFile = PathManager::layoutTemplate($page->getLayout()); $smarty->assign("screen_placeholder", $mainContent); $page->setStyleSelector(1); $out = $smarty->fetch($layoutFile); return $out; }
public function render($runData) { // get site $site = $runData->getTemp("site"); $runData->contextAdd("site", $site); $this->handleNotifications($runData); $pl = $runData->getParameterList(); $wikiPage = $pl->getParameterValue("wiki_page"); $privateAccessGranted = true; // check if the site is private if ($site->getPrivate()) { $user = $runData->getUser(); if ($user && !$user->getSuperAdmin() && !$user->getSuperModerator()) { // check if member $c = new Criteria(); $c->add("site_id", $site->getSiteId()); $c->add("user_id", $user->getUserId()); $mem = DB_MemberPeer::instance()->selectOne($c); if (!$mem) { // check if a viewer $c = new Criteria(); $c->add("site_id", $site->getSiteId()); $c->add("user_id", $user->getUserId()); $vi = DB_SiteViewerPeer::instance()->selectOne($c); if (!$vi) { $user = null; } } } if ($user == null) { $wikiPage = $site->getSettings()->getPrivateLandingPage(); $privateAccessGranted = false; } } if ($wikiPage == "") { $wikiPage = $site->getDefaultPage(); } $wikiPage = WDStringUtils::toUnixName($wikiPage); $runData->setTemp("pageUnixName", $wikiPage); $memcache = Ozone::$memcache; if ($runData->getAction() == null && $runData->getRequestMethod() == "GET" && $privateAccessGranted) { // try to get content from the memorycache server $mcKey = 'page..' . $site->getUnixName() . '..' . $wikiPage; if (strpos($wikiPage, ":") != false) { $tmp0 = explode(':', $wikiPage); $categoryName = $tmp0[0]; } else { $categoryName = "_default"; } $aKey = 'category_lc..' . $site->getUnixName() . '..' . $categoryName; $changeTime = $memcache->get($aKey); $cachedPage = $memcache->get($mcKey); if ($cachedPage !== false && $changeTime && $changeTime <= $cachedPage['timestamp']) { $runData->setTemp("page", $cachedPage['page']); $GLOBALS['page'] = $cachedPage['page']; $out = $cachedPage['content']; if ($this->vars['notificationsDialog']) { $out = preg_replace(';<div id="account-notifications-dummy" style="display:none"></div>;', '<div id="notifications-dialog" style="display:none">' . $this->vars['notificationsDialog'] . '</div>', $out, 1); } return $out; } else { $storeLater = true; } } $runData->contextAdd("wikiPageName", $wikiPage); $settings = $site->getSettings(); // get wiki page from the database $page = DB_PagePeer::instance()->selectByName($site->getSiteId(), $wikiPage); if ($page == null) { $runData->contextAdd("pageNotExists", true); // get category based on suggested page name if (strpos($wikiPage, ":") != false) { $tmp0 = explode(':', $wikiPage); $categoryName = $tmp0[0]; } else { $categoryName = "_default"; } $category = DB_CategoryPeer::instance()->selectByName($categoryName, $site->getSiteId()); if ($category == null) { $category = DB_CategoryPeer::instance()->selectByName('_default', $site->getSiteId()); } $runData->setTemp("category", $category); } else { // page exists!!! wooo!!! $runData->setTemp("page", $page); $GLOBALS['page'] = $page; $compiled = $page->getCompiled(); $runData->contextAdd("wikiPage", $page); $runData->contextAdd("pageContent", $compiled->getText()); $category = $page->getCategory(); $runData->setTemp("category", $category); // show options? $showPageOptions = true; $runData->contextAdd("showPageoptions", $showPageOptions); // get the tags $c = new Criteria(); $c->add("page_id", $page->getPageId()); $c->addOrderAscending("tag"); $tags = DB_PageTagPeer::instance()->select($c); $t2 = array(); foreach ($tags as $t) { $t2[] = $t->getTag(); } $runData->contextAdd("tags", $t2); // has discussion? if ($page->getThreadId() !== null) { $thread = DB_ForumThreadPeer::instance()->selectByPrimaryKey($page->getThreadId()); if ($thread == null) { $page->setThreadId(null); $page->save(); } else { $page->setTemp("numberPosts", $thread->getNumberPosts()); } } // look for parent pages (and prepare breadcrumbs) if ($page->getParentPageId()) { $breadcrumbs = array(); $ppage = DB_PagePeer::instance()->selectByPrimaryKey($page->getParentPageId()); array_unshift($breadcrumbs, $ppage); $bcount = 0; while ($ppage->getParentPageId() && $bcount <= 4) { $ppage = DB_PagePeer::instance()->selectByPrimaryKey($ppage->getParentPageId()); array_unshift($breadcrumbs, $ppage); $bcount++; } $runData->contextAdd("breadcrumbs", $breadcrumbs); } } $runData->contextAdd("category", $category); // GET THEME for the category $theme = $category->getTheme(); $runData->contextAdd("theme", $theme); // GET LICENSE for the category $licenseText = $category->getLicenseText(); $runData->contextAdd("licenseText", $licenseText); // show nav elements? if ($privateAccessGranted || !$settings->getHideNavigationUnauthorized()) { if ($theme->getUseSideBar()) { $sideBar1 = $category->getSidePage(); if ($sideBar1 !== null) { $sideBar1Compiled = $sideBar1->getCompiled(); $ccc = $sideBar1Compiled->getText(); $ccc = preg_replace('/id="[^"]*"/', '', $ccc); $runData->contextAdd("sideBar1Content", $ccc); } } if ($theme->getUseTopBar()) { $topBar = $category->getTopPage(); if ($topBar !== null) { $topBarCompiled = $topBar->getCompiled(); $ccc = $topBarCompiled->getText(); $ccc = preg_replace('/id="[^"]*"/', '', $ccc); $runData->contextAdd("topBarContent", $ccc); } } } // OpenID stuff now !!! if ($settings->getOpenidEnabled() && $page) { // find a page $c = new Criteria(); $c->add("site_id", $site->getSiteId()); if ($_SERVER['REQUEST_URI'] == "/") { $c->add("page_id", null); } else { $c->add("page_id", $page->getPageId()); } $oentry = DB_OpenidEntryPeer::instance()->selectOne($c); if ($oentry) { $openId = array(); $openId['enabled'] = true; $openId['identity'] = $oentry->getUrl(); $openId['server'] = $oentry->getServerUrl(); $runData->contextAdd("openId", $openId); } } // check wether to include a special JS file for custom domains or a special JS file for private files //if (preg_match('/^([a-zA-Z0-9\-]+)\.' . GlobalProperties::$URL_DOMAIN_PREG . '$/',$_SERVER["HTTP_HOST"], $matches) !==1) { // $runData->contextAdd("useCustomDomainScript", true); //} $smarty = Ozone::getSmarty(); // put context into context $context = $runData->getContext(); if ($context !== null) { foreach ($context as $key => $value) { $smarty->assign($key, $value); } } $templateFile = PathManager::screenTemplate("wiki/WikiScreen"); $screenContent = $smarty->fetch($templateFile); $smarty->assign("screen_placeholder", $screenContent); $layoutFile = PathManager::layoutTemplate("WikiLayout"); $out = $smarty->fetch($layoutFile); if ($storeLater) { $now = time(); if (!$changeTime) { $memcache->set($aKey, $now, 0, 864000); } $memcache->set($mcKey, array("page" => $page, "content" => $out, "timestamp" => $now), 0, 864000); } if ($this->vars['notificationsDialog']) { $out = preg_replace(';<div id="account-notifications-dummy" style="display:none"></div>;', '<div id="notifications-dialog" style="display:none">' . $this->vars['notificationsDialog'] . '</div>', $out, 1); } return $out; }
public function render($runData) { try { // get site $site = $runData->getTemp("site"); $runData->contextAdd("site", $site); $pl = $runData->getParameterList(); $wikiPage = $pl->getParameterValue("wiki_page"); if ($site->getPrivate()) { $user = $runData->getUser(); if ($user && !$user->getSuperAdmin() && !$user->getSuperModerator()) { // check if member $c = new Criteria(); $c->add("site_id", $site->getSiteId()); $c->add("user_id", $user->getUserId()); $mem = DB_MemberPeer::instance()->selectOne($c); if (!$mem) { // check if a viewer $c = new Criteria(); $c->add("site_id", $site->getSiteId()); $c->add("user_id", $user->getUserId()); $vi = DB_SiteViewerPeer::instance()->selectOne($c); if (!$vi) { $user = null; } } } if ($user == null) { throw new ProcessException("This is a private wiki. Access is limited to selected users."); } } $wikiPage = WDStringUtils::toUnixName($wikiPage); $runData->setTemp("pageUnixName", $wikiPage); if ($wikiPage === "") { $wikiPage = $site->getDefaultPage(); } $runData->contextAdd("wikiPageName", $wikiPage); // get wiki page from the database $page = DB_PagePeer::instance()->selectByName($site->getSiteId(), $wikiPage); if ($page == null) { throw new ProcessException("No such page"); } else { // page exists!!! wooo!!! $runData->setTemp("page", $page); $GLOBALS['page'] = $page; $compiled = $page->getCompiled(); $runData->contextAdd("wikiPage", $page); $runData->contextAdd("screen_placeholder", $compiled->getText()); $category = $page->getCategory(); $runData->setTemp("category", $category); } $runData->contextAdd("category", $category); // GET THEME for the category $theme = $category->getTheme(); $runData->contextAdd("theme", $theme); // GET LICENSE for the category $licenseText = $category->getLicenseText(); $runData->contextAdd("licenseText", $licenseText); $smarty = Ozone::getSmarty(); // put context into context $context = $runData->getContext(); if ($context !== null) { foreach ($context as $key => $value) { $smarty->assign($key, $value); } } $layoutFile = PathManager::layoutTemplate("PrintLayout"); $out = $smarty->fetch($layoutFile); return $out; } catch (Exception $e) { $out = $e->getMessage(); return $out; } }
public function render($navigationTemplate) { $smarty = Ozone::getSmarty(); return $smarty->fetch($this->navPath . $navigationTemplate . '.tpl'); }