public function build($runData) { $user = $runData->getUser(); $pl = $runData->getParameterList(); $pageId = $pl->getParameterValue("pageId"); $site = $runData->getTemp("site"); if (!$pageId || !is_numeric($pageId)) { throw new ProcessException(_("The page can not be found or does not exist."), "no_page"); } $page = DB_PagePeer::instance()->selectByPrimaryKey($pageId); if ($page == null || $page->getSiteId() != $site->getSiteId()) { throw new ProcessException(_("Error getting page information."), "no_page"); } $category = $page->getCategory(); WDPermissionManager::instance()->hasPagePermission('edit', $user, $category, $page); // get the tags now $c = new Criteria(); $c->add("page_id", $pageId); $c->addOrderAscending("tag"); $tags = DB_PageTagPeer::instance()->select($c); $t2 = array(); foreach ($tags as $t) { $t2[] = $t->getTag(); } $t3 = implode(' ', $t2); $runData->contextAdd("tags", $t3); }
public function indexPage($page) { // look for an existing fts_entry $ie = DB_FtsEntryPeer::instance()->selectByPageId($page->getPageId()); if (!$ie) { $ie = new DB_FtsEntry(); $ie->setPageId($page->getPageId()); $ie->setSiteId($page->getSiteId()); } // set properties (fields) $ie->setTitle(htmlspecialchars($page->getTitleOrUnixName())); $ie->setUnixName($page->getUnixName()); $text = $page->getCompiled()->getText(); $text = strip_tags($text); // kill modules $d = utf8_encode("þ"); $text = preg_replace("/" . $d . "module \"([a-zA-Z0-9\\/_]+?)\"([^" . $d . "]+?)?" . $d . "/", "\n", $text); $ie->setText($text); $title = db_escape_string(htmlspecialchars($page->getTitleOrUnixName())); $unixName = db_escape_string(htmlspecialchars($page->getUnixName())); //get tags $c = new Criteria(); $c->add("page_id", $page->getPageId()); $c->addOrderAscending("tag"); $tags = DB_PageTagPeer::instance()->select($c); $tagstring = ''; foreach ($tags as $tag) { $tagstring .= $tag->getTag() . ' '; } $db = Database::connection(); $v = pg_version($db->getLink()); if (!preg_match(';^8\\.3;', $v['server'])) { $db->query("SELECT set_curcfg('default')"); } $ie->setVector("(setweight( to_tsvector('{$title}'), 'A') || to_tsvector('" . db_escape_string($text) . "') || setweight( to_tsvector('{$tagstring}'), 'B'))", true); $ie->save(); }
public function build($runData) { $pl = $runData->getParameterList(); $this->_pl = $pl; $site = $runData->getTemp("site"); $categoryName = $this->_readParameter(array('category', 'categories'), false); $categoryName = strtolower($categoryName); $startPage = $this->_readParameter(array('startPage', 'targetPage')); if (!$startPage) { /* Get curent page. */ $startPage = $runData->getTemp('pageUnixName'); if (!$startPage) { $startPage = $pl->getParameterValue('page_unix_name'); // from preview } } $categories = array(); $categoryNames = array(); if ($categoryName != '*') { if (!$categoryName) { /* No category name specified, use the current category! */ $pageUnixName = $runData->getTemp('pageUnixName'); if (!$pageUnixName) { $pageUnixName = $pl->getParameterValue('page_unix_name'); // from preview } if (strpos($pageUnixName, ":") != false) { $tmp0 = explode(':', $pageUnixName); $categoryName = $tmp0[0]; } else { $categoryName = "_default"; } } foreach (preg_split('/[,;\\s]+?/', $categoryName) as $cn) { $category = DB_CategoryPeer::instance()->selectByName($cn, $site->getSiteId()); if ($category) { $categories[] = $category; $categoryNames[] = $category->getName(); } } if (count($categories) == 0) { throw new ProcessException('The requested categories do not (yet) exist.'); } } //if(count($categories) == 0){ // throw new ProcessException(_("The category can not be found.")); //} $attrUrlPrefix = $pl->getParameterValue('urlAttrPrefix'); // now select pages according to the specified criteria $c = new Criteria(); $c->add("site_id", $site->getSiteId()); if (count($categories) > 0) { $ccat = new Criteria(); foreach ($categories as $cat) { $ccat->addOr('category_id', $cat->getCategoryId()); } $c->addCriteriaAnd($ccat); } $c->add('unix_name', '(^|:)_', '!~'); /* Handle tags! */ $tagString = $this->_readParameter(array('tag', 'tags'), true); //var_dump($tagString); if ($tagString) { /* Split tags. */ $tags = preg_split(';[\\s,\\;]+;', $tagString); $tagsAny = array(); $tagsAll = array(); $tagsNone = array(); foreach ($tags as $t) { if (substr($t, 0, 1) == '+') { $tagsAll[] = substr($t, 1); } elseif (substr($t, 0, 1) == '-') { $tagsNone[] = substr($t, 1); } elseif ($t == '=') { /* It means: any tags of the current page. */ if ($runData->getTemp('page')) { $pageId = $runData->getTemp('page')->getPageId(); $co = new Criteria(); $co->add("page_id", $pageId); $co->addOrderAscending("tag"); $tagso = DB_PageTagPeer::instance()->select($co); foreach ($tagso as $to) { $tagsAny[] = $to->getTag(); } if (count($tagsAny) == 0) { /* * If someone uses the '=' tag, the line below guarantees that * only pages that DO have tags and share at least one similar tag with the * current page are listed. */ $tagsAny[] = ' '; } } } else { $tagsAny[] = $t; } } /* ANY */ if (count($tagsAny) > 0) { $t = array(); foreach ($tagsAny as $tag0) { $t[] = 'tag = \'' . db_escape_string($tag0) . '\''; } $tagQuery = "SELECT count(*) FROM page_tag " . "WHERE page_tag.page_id=page.page_id " . "AND (" . implode(' OR ', $t) . ")"; $c->add('(' . $tagQuery . ')', 1, '>='); } /* ALL */ if (count($tagsAll) > 0) { $t = array(); foreach ($tagsAll as $tag0) { $t[] = 'tag = \'' . db_escape_string($tag0) . '\''; } $tagQuery = "SELECT count(*) FROM page_tag " . "WHERE page_tag.page_id=page.page_id " . "AND (" . implode(' OR ', $t) . ")"; $c->add('(' . $tagQuery . ')', count($tagsAll)); } /* NONE */ if (count($tagsNone) > 0) { $t = array(); foreach ($tagsNone as $tag0) { $t[] = 'tag = \'' . db_escape_string($tag0) . '\''; } $tagQuery = "SELECT count(*) FROM page_tag " . "WHERE page_tag.page_id=page.page_id " . "AND (" . implode(' OR ', $t) . ")"; $c->add('(' . $tagQuery . ')', 0); } } $c->addGroupBy('datestring'); $db = Database::connection(); $corig = clone $c; $c->setExplicitFields("EXTRACT(YEAR FROM date_created)::varchar || '.' || EXTRACT(MONTH FROM date_created)::varchar as datestring, count(*) as c"); //$c->addOrderDescending("regexp_replace(datestring, '\.[0-9]+$', '')::integer"); //$c->addOrderDescending("regexp_replace(datestring, '^[0-9]+\.', '')::integer"); $q = DB_PagePeer::instance()->criteriaToQuery($c); $r = $db->query($q); $r = $r->fetchAll(); if ($r === false) { $r = array(); } $postCount = array(); if ($lang == 'pl') { $locale = 'pl_PL'; } setlocale(LC_TIME, $locale); foreach ($r as $mo) { $spl = explode('.', $mo['datestring']); $year = $spl[0]; $month = $spl[1]; $postCount[$year]['months'][$month]['count'] = $mo['c']; /* Month names. */ $lang = $site->getLanguage(); $locale = 'en_US'; $postCount[$year]['months'][$month]['name'] = strftime('%B', mktime(6, 6, 6, $month, 6, $year)); } //$c = clone($corig); $c->setExplicitFields("EXTRACT(YEAR FROM date_created)::varchar as datestring, count(*) as c"); $q = DB_PagePeer::instance()->criteriaToQuery($c); $r = $db->query($q); $r = $r->fetchAll(); if ($r === false) { $r = array(); } foreach ($r as $mo) { $postCount[$mo['datestring']]['count'] = $mo['c']; } /* Order the results. */ /* Order years. */ krsort($postCount, SORT_NUMERIC); foreach ($postCount as &$year) { krsort($year['months'], SORT_NUMERIC); } $uprefix = ''; if ($attrUrlPrefix) { $uprefix = $attrUrlPrefix . '_'; } /* Get current (selected) date (if any). */ $date = $this->_pl->getParameterValue($uprefix . "date", "GET"); $dateA = array(); if (preg_match(';^[0-9]{4}$;', $date)) { $dateA['year'] = $date; if (isset($postCount[$date])) { $postCount[$date]['selected'] = true; } } if (preg_match(';^[0-9]{4}\\.[0-9]{1,2}$;', $date)) { $dateS = explode('.', $date); $dateA['year'] = $dateS[0]; $dateA['month'] = $dateS[1]; if (isset($postCount[$dateA['year']]['months'][$dateA['month']])) { $postCount[$dateA['year']]['months'][$dateA['month']]['selected'] = true; } } $runData->contextAdd('postCount', $postCount); $startUrlBase = '/' . $startPage; if ($tagString) { $startUrlBase .= '/' . $uprefix . 'tag/' . urldecode($tagString); } $startUrlBase .= '/' . $uprefix . 'date/'; $runData->contextAdd('startUrlBase', $startUrlBase); //var_dump($postCount); $runData->contextAdd('attrUrlPrefix', $attrUrlPrefix); return; }
public function save($args) { $db = Database::connection(); $db->begin(); // simple argument checking if (!isset($args['page'])) { throw new Wikidot_Facade_Exception_WrongArguments("Page argument must be passed"); } $pm = new WDPermissionManager(); $now = new ODate(); // page (existant or not) name $arg_page = WDStringUtils::toUnixName($args['page']); // parse the rest (beside page name) unset($args['page']); $this->parseArgs($args, array("performer", "site")); try { // parse page name to figure out if it points to an existant page $page = $this->_parsePage($this->site, $arg_page); $new = false; // check permissions to edit the page $pm->hasPagePermission('edit', $this->performer, $page->getCategory(), $page); } catch (Wikidot_Facade_Exception_WrongArguments $e) { if ($this->source === null) { $this->source = ""; } if ($this->title === null) { $this->title = $arg_page; } $new = true; $category_name = preg_replace('/^([^:]*):.*$/', '\\1', $arg_page); if ($category_name == $arg_page) { $category_name = '_default'; } $category = $this->_getOrCreateCategory($this->site, $category_name); $page = new DB_Page(); $page->setSiteId($this->site->getSiteId()); $page->setCategoryId($category->getCategoryId()); $page->setUnixName($arg_page); $page->setDateCreated(new ODate()); $page->setOwnerUserId($this->performer->getUserId()); $page->save(); $compiled = new DB_PageCompiled(); $compiled->setPageId($page->getPageId()); $compiled->save(); } // get current revision and metadata if (!$new) { $cur_rev = $page->getCurrentRevision(); $cur_meta = $cur_rev->getMetadata(); } // construct new metadata if ($new) { $new_meta = new DB_PageMetadata(); $new_meta->setUnixName($arg_page); $new_meta->setOwnerUserId($this->performer->getUserId()); } else { $new_meta = clone $cur_meta; $new_meta->setNew(true); $new_meta->setMetadataId(null); } // construct new revision $new_rev = new DB_PageRevision(); $new_rev->setSiteId($this->site->getSiteId()); $new_rev->setPageId($page->getPageId()); $new_rev->setUserId($this->performer->getUserId()); $new_rev->setDateLastEdited($now); if ($new) { $new_rev->setRevisionNumber(0); } else { $new_rev->setRevisionNumber($cur_rev->getRevisionNumber() + 1); } $src_changed = false; $title_changed = false; $parent_changed = false; $tags_changed = false; // handle source change if ($new || $this->source !== null && $page->getSource() != $this->source) { $new_src = new DB_PageSource(); $new_src->setText($this->source); $new_src->save(); $new_rev->setSourceId($new_src->getSourceId()); $src_changed = true; } else { $new_rev->setSourceId($cur_rev->getSourceId()); $new_rev->setSinceFullSource($cur_rev->getSinceFullSource()); $new_rev->setDiffSource($cur_rev->getDiffSource()); } // handle tags change if ($this->tags) { $new_tags = $this->tags; $cur_tags = $page->getTagsAsArray(); sort($cur_tags); sort($new_tags); if ($cur_tags != $new_tags) { $tags_changed = true; $tags_deleted = array(); $tags_added = array(); foreach ($cur_tags as $tag) { if (!in_array($tag, $new_tags)) { $c = new Criteria(); $c->add('page_id', $page->getPageId()); $c->add('tag', $tag); if ($t = DB_PageTagPeer::instance()->selectOne($c)) { $t->delete(); $tags_deleted[] = $tag; } } } foreach ($new_tags as $tag) { if (!in_array($tag, $cur_tags)) { $t = new DB_PageTag(); $t->getPageId($page->getPageId()); $t->setSiteId($this->site->getSiteId()); $t->setTag($tag); $t->save(); $tags_added[] = $tag; } } } } // handle metadata: title change if ($new || $this->title !== null && $cur_meta->getTitle() != $this->title) { $new_meta->setTitle($this->title); $page->setTitle($this->title); $title_changed = true; } // handle metadata: parent page change if ($this->parent_page) { if (!$cur_meta->getParentPageId() || $cur_meta->getParentPageId() != $this->parent_page->getPageId()) { $new_meta->setParentPageId($this->parent_page->getPageId()); $parent_changed = true; } } if ($this->clear_parent_page && $page->getParentPageId()) { $new_meta->setParentPageId(null); $parent_changed = true; } $meta_changed = $title_changed || $parent_changed; // decide whether to use previous metadata or create a new object if ($meta_changed) { $new_meta->save(); $new_rev->setMetadataId($new_meta->getMetadataId()); } else { $new_rev->setMetadataId($cur_meta->getMetadataId()); } // set flag on revision if ($new) { $new_rev->setFlagNew(true); } else { if ($src_changed) { $new_rev->setFlagText(true); } if ($title_changed) { $new_rev->setFlagTitle(true); } if ($parent_changed) { $new_rev->setFlagMeta(true); } } if ($src_changed || $meta_changed || $tags_changed) { $new_rev->save(); $page->setSourceId($new_rev->getSourceId()); $page->setDateLastEdited($now); $page->setMetadataId($new_rev->getMetadataId()); $page->setRevisionNumber($new_rev->getRevisionNumber()); $page->setRevisionId($new_rev->getRevisionId()); $page->save(); $db->commit(); $GLOBALS['site'] = $this->site; $outdater = new Outdater(); if ($src_changed) { $outdater->pageEvent("source_changed", $page); } if ($title_changed) { $outdater->pageEvent("title_changed", $page); } if ($parent_changed) { $outdater->pageEvent("parent_changed", $page); } if ($tags_changed) { $outdater->pageEvent("tag_changed", $page); } } else { /* This place is reached when API client tries to set source or * title or parent page or tags that are already set (in the DB) * to the same value. * * Let's suppose doing nothing is the desired behavior in this case * * Other possible way to react can be raising an exception. * But it should be different from Wikidot_Facade_Exception_WrongArguments * because this one implies client error (and client does not need * to know the exact database state). */ } }
public function getTags() { $c = new Criteria(); $c->add('page_id', $this->getPageId()); $tags = DB_PageTagPeer::instance()->select($c); return $tags; }
public function saveTagsEvent($runData) { // do not create any new revision... :-( // or create??? $user = $runData->getUser(); $pl = $runData->getParameterList(); $tags = strtolower(trim($pl->getParameterValue("tags"))); $pageId = $pl->getParameterValue("pageId"); $site = $runData->getTemp("site"); $page = DB_PagePeer::instance()->selectByPrimaryKey($pageId); if ($page == null || $page->getSiteId() != $site->getSiteId()) { throw new ProcessException(_("Error getting page information."), "no_page"); } $category = $page->getCategory(); WDPermissionManager::instance()->hasPagePermission('edit', $user, $category, $page); if (strlen8($tags) > 256) { throw new ProcessException(_('"Tags" field too long.'), "form_error"); } $db = Database::connection(); $db->begin(); $c = new Criteria(); $c->add("page_id", $pageId); $dbTags = DB_PageTagPeer::instance()->select($c); $tags = preg_split("/[ ,]+/", $tags); $tagstmp = array(); foreach ($tags as $tag) { $tagstmp[] = substr($tag, 0, 64); } $tags = $tagstmp; $tags = array_unique($tags); foreach ($dbTags as $dbTag) { if (in_array($dbTag->getTag(), $tags)) { unset($tags[array_search($dbTag->getTag(), $tags)]); } else { DB_PageTagPeer::instance()->deleteByPrimaryKey($dbTag->getTagId()); } } // insert all the other foreach ($tags as $tag) { if (trim($tag) != '') { $dbTag = new DB_PageTag(); $dbTag->setSiteId($site->getSiteId()); $dbTag->setPageId($pageId); $dbTag->setTag($tag); $dbTag->save(); } } $od = new Outdater(); $od->pageEvent("tag_change", $page); $db->commit(); if (GlobalProperties::$UI_SLEEP) { sleep(1); } }
private function _handleTags($m) { $page = $this->_tmpPage; /* Select tags. */ // 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(); } if (count($t2) == 0) { return _('//no tags found for this page//'); } return implode(' ', $t2); }
public function duplicatePage($page, $nsite, $ncategory, $newUnixName = null) { if ($newUnixName == null) { $newUnixName = $page->getUnixName(); } // check if page exists - if so, forcibly delete!!! $p = DB_PagePeer::instance()->selectByName($nsite->getSiteId(), $newUnixName); if ($p) { DB_PagePeer::instance()->deleteByPrimaryKey($p->getPageId()); } $owner = $this->owner; $now = new ODate(); // create new page object based on the existing page $nsource = new DB_PageSource(); $nsource->setText($page->getSource()); $nsource->save(); $meta = $page->getMetadata(); $nmeta = new DB_PageMetadata(); $nmeta->setTitle($meta->getTitle()); $nmeta->setUnixName($newUnixName); if ($owner) { $nmeta->setOwnerUserId($owner->getUserId()); } else { $nmeta->setOwnerUserId($meta->getOwnerUserId()); } $nmeta->save(); $rev = $page->getCurrentRevision(); $nrev = new DB_PageRevision(); $nrev->setSiteId($nsite->getSiteId()); $nrev->setSourceId($nsource->getSourceId()); $nrev->setMetadataId($nmeta->getMetadataId()); $nrev->setFlagNew(true); $nrev->setFlagNewSite(true); $nrev->setDateLastEdited($now); $nrev->setUserId($owner->getUserId()); $nrev->obtainPK(); $npage = new DB_Page(); $npage->setSiteId($nsite->getSiteId()); $npage->setCategoryId($ncategory->getCategoryId()); $npage->setRevisionId($nrev->getRevisionId()); $npage->setSourceId($nsource->getSourceId()); $npage->setMetadataId($nmeta->getMetadataId()); $npage->setTitle($page->getTitle()); $npage->setUnixName($newUnixName); $npage->setDateLastEdited($now); $npage->setDateCreated($now); $npage->setLastEditUserId($owner->getUserId()); $npage->setOwnerUserId($owner->getUserId()); $npage->save(); $nrev->setPageId($npage->getPageId()); $nrev->save(); $ncomp = new DB_PageCompiled(); $ncomp->setPageId($npage->getPageId()); $ncomp->setDateCompiled($now); $ncomp->save(); /* Copy tags too. */ $c = new Criteria(); $c->add('page_id', $page->getPageId()); $tags = DB_PageTagPeer::instance()->select($c); foreach ($tags as $tag) { $tag->setNew(true); $tag->setTagId(null); $tag->setSiteId($nsite->getSiteId()); $tag->setPageId($npage->getPageId()); $tag->save(); } $this->pageMap[$page->getPageId()] = $npage->getPageId(); }
private function _handleTags($m) { $page = $this->_tmpPage; /* Select tags. */ // 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(); } if (count($t2) == 0) { return _('//no tags found for this page//'); } $tagTarget = $this->_readParameter('tagTarget', true); if ($tagTarget) { $t3 = array(); $p = 'tag'; if ($this->_parameterUrlPrefix) { $p = $this->_parameterUrlPrefix . '_tag'; } foreach ($t2 as $t) { $t3[] = '[/' . $tagTarget . '/' . $p . '/' . urlencode($t) . ' ' . $t . ']'; } return implode(' ', $t3); } return implode(' ', $t2); }
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; }