Example #1
0
 public function build($runData)
 {
     $page = $runData->getTemp("page");
     if ($page) {
         $rate = $page->getRate();
     } else {
         $pl = $runData->getParameterList();
         $pageId = $pl->getParameterValue("pageId");
         if ($pageId) {
             $page = DB_PagePeer::instance()->selectByPrimaryKey($pageId);
             $rate = $page->getRate();
         } else {
             $rate = 0;
         }
     }
     // get the category too
     if (!$page) {
         $site = $runData->getTemp("site");
         $category = DB_CategoryPeer::instance()->selectByName('_default', $site->getSiteId());
     } else {
         $category = $runData->getTemp("category");
         if (!$category) {
             $category = DB_CategoryPeer::instance()->selectByPrimaryKey($page->getCategoryId());
         }
     }
     $type = $category->getRatingType();
     $runData->contextAdd("type", $type);
     $runData->contextAdd("rate", $rate);
 }
Example #2
0
 public function buildPageUrl()
 {
     $page = DB_PagePeer::instance()->selectByPrimaryKey($this->getPageId());
     $site = DB_SitePeer::instance()->selectByPrimaryKey($page->getSiteId());
     $h = 'http://' . $site->getDomain() . '/' . $page->getUnixName();
     return $h;
 }
Example #3
0
 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 build($runData)
 {
     $site = $runData->getTemp("site");
     $runData->contextAdd("site", $site);
     // select templates
     $templatesCategory = DB_CategoryPeer::instance()->selectByName("template", $site->getSiteId());
     if ($templatesCategory == null) {
         $runData->contextAdd("noTemplates", true);
         return;
     }
     $c = new Criteria();
     $c->add("category_id", $templatesCategory->getCategoryId());
     $c->addOrderAscending("title");
     $templates = DB_PagePeer::instance()->select($c);
     $runData->contextAdd("templates", $templates);
     // get all categories for the site
     $c = new Criteria();
     $c->add("site_id", $site->getSiteId());
     $c->addOrderAscending("replace(name, '_', '00000000')");
     $categories = DB_CategoryPeer::instance()->select($c);
     $runData->contextAdd("categories", $categories);
     // also prepare categories to put into javascript...
     $cats2 = array();
     foreach ($categories as $category) {
         $cats2[] = $category->getFieldValuesArray();
     }
     $runData->ajaxResponseAdd("categories", $cats2);
 }
Example #5
0
 public function build($runData)
 {
     $pl = $runData->getParameterList();
     $site = $runData->getTemp("site");
     $root = $pl->getParameterValue("root");
     $showRoot = $pl->getParameterValue("showRoot");
     if (!$root) {
         $page = $runData->getTemp("page");
     } else {
         $page = DB_PagePeer::instance()->selectByName($site->getSiteId(), $root);
     }
     if (!$page) {
         $runData->setModuleTemplate("Empty");
         return;
     }
     $depth = $pl->getParameterValue("depth");
     if (!$depth || !is_numeric($depth) || $depth < 1) {
         $depth = 5;
     }
     $tree = array();
     $c = new Criteria();
     $c->add("parent_page_id", $page->getPageId());
     $c->addOrderAscending("COALESCE(title, unix_name)");
     $children = DB_PagePeer::instance()->select($c);
     $descendants = array();
     // select next level of children
     $ch1 = $children;
     $d = 0;
     while ($ch1 != null && count($ch1) > 0 && (!$depth || $d < $depth)) {
         $q = "SELECT * FROM page WHERE parent_page_id IN (";
         $tch = array();
         foreach ($ch1 as $ch) {
             // check if already in the $tch
             if (!array_key_exists($ch->getPageId(), $descendants)) {
                 $tch[] = $ch->getPageId();
                 $descendants[$ch->getParentPageId()][] = $ch;
             } else {
                 $ch->setTemp('circular', true);
                 $descendants[$ch->getParentPageId()][] = $ch;
             }
         }
         if (count($tch) > 0) {
             $q .= implode(',', $tch);
             $q .= ") ORDER BY COALESCE(title, unix_name)";
             $c = new Criteria();
             $c->setExplicitQuery($q);
             $ch2 = DB_PagePeer::instance()->select($c);
             $ch1 = $ch2;
         } else {
             $ch1 = null;
         }
         $d++;
     }
     $runData->contextAdd("root", $page);
     $runData->contextAdd("children", $descendants);
     if ($showRoot) {
         $runData->contextAdd("showRoot", true);
     }
 }
Example #6
0
 public function build($runData)
 {
     $site = $runData->getTemp("site");
     $page = DB_PagePeer::instance()->selectByName($site->getSiteId(), "system:create-account");
     if ($page != null) {
         $runData->contextAdd("content", $page->getCompiled()->getText());
     }
 }
Example #7
0
 public function getPageUnixName()
 {
     if ($this->getPageId()) {
         return DB_PagePeer::instance()->selectByPrimaryKey($this->getPageId())->getUnixName();
     } else {
         return null;
     }
 }
Example #8
0
 public function saveEvent($runData)
 {
     $site = $runData->getTemp("site");
     $pl = $runData->getParameterList();
     $pageId = $pl->getParameterValue("pageId");
     if (!is_numeric($pageId)) {
         throw new ProcessException(_("Page does not exist."));
     }
     $page = DB_PagePeer::instance()->selectByPrimaryKey($pageId);
     if (!$page) {
         throw new ProcessException(_("Page does not exist."));
     }
     // check permissions
     $category = $page->getCategory();
     WDPermissionManager::instance()->hasPagePermission('edit', $runData->getUser(), $category, $page);
     $data = $pl->getParameterValue("data");
     $json = new JSONService();
     $listData = $json->decode($data);
     //it's time to do some checking
     $listData->label = trim($listData->label);
     if (!$listData->label) {
         throw new ProcessException(_('The SimpleTodo module must have an id (e.g. id="list1").'));
     }
     $dataArray['label'] = $listData->label;
     $listData->title = trim($listData->title);
     if (!$listData->title) {
         throw new ProcessException(_('Your title field is empty, please correct that.'));
     }
     $dataArray['title'] = $listData->title;
     for ($i = 0; $i < count($listData->data); $i++) {
         $listData->data[$i]->text = trim($listData->data[$i]->text);
         $listData->data[$i]->link = trim($listData->data[$i]->link);
         if (!is_bool($listData->data[$i]->checked)) {
             throw new ProcessException(_('Something is wrong witch checkbox (it is not a boolean value).'));
         }
         if (empty($listData->data[$i]->text)) {
             throw new ProcessException(_('One of your text fields is empty, please correct that.'));
         }
         $dataArray['data'][$i]['text'] = $listData->data[$i]->text;
         $dataArray['data'][$i]['link'] = $listData->data[$i]->link;
         $dataArray['data'][$i]['checked'] = $listData->data[$i]->checked;
     }
     $c = new Criteria();
     $c->add('label', $listData->label);
     $c->add('site_id', $site->getSiteId());
     $list = DB_SimpletodoListPeer::instance()->selectOne($c);
     if (!$list) {
         $list = new DB_SimpletodoList();
         $list->setSiteId($site->getSiteId());
         $list->setLabel($dataArray['label']);
     }
     $list->setTitle($dataArray['title']);
     $itemData = $json->encode($dataArray['data']);
     $list->setData($itemData);
     $list->save();
 }
Example #9
0
 /**
  * 
  * Generates a token entry for the matched text.  Token options are:
  * 
  * 'text' => The full matched text, not including the <code></code> tags.
  * 
  * @access public
  *
  * @param array &$matches The array of matches from parse().
  *
  * @return A delimited token number to be used as a placeholder in
  * the source text.
  *
  */
 function process(&$matches)
 {
     $page = $this->wiki->vars['page'];
     if (!$page) {
         $pageName = $this->wiki->vars['pageName'];
         $site = $GLOBALS['site'];
         $page = DB_PagePeer::instance()->selectByName($site->getSiteId(), $pageName);
     }
     if (!$page) {
         return;
     }
     $tag0 = $tags0[0];
     $tags = $page->getTagsAsArray();
     $tags0 = preg_split(';[, ]+;', trim($matches[1]));
     $allTags = array();
     $noTags = array();
     $anyTags = array();
     foreach ($tags0 as $t) {
         if (substr($t, 0, 1) == '+') {
             $allTags[] = substr($t, 1);
         } elseif (substr($t, 0, 1) == '-') {
             $noTags[] = substr($t, 1);
         } else {
             $anyTags[] = $t;
         }
     }
     if (count($allTags) > 0) {
         foreach ($allTags as $t) {
             /* If any of the required tags is not present, return ''. */
             if (!in_array($t, $tags)) {
                 return '';
             }
         }
     }
     if (count($noTags) > 0) {
         foreach ($noTags as $t) {
             /* If any of the forbidden tags is present, return ''. */
             if (in_array($t, $tags)) {
                 return '';
             }
         }
     }
     if (count($anyTags) > 0) {
         foreach ($anyTags as $t) {
             /* If any of the "any" tags is present, return the content. */
             if (in_array($t, $tags)) {
                 return $matches[2];
             }
         }
         /* If not, return ''. */
         return '';
     }
     /* If we are here, the content should be returned. */
     return $matches[2];
 }
Example #10
0
 public function build($runData)
 {
     $site = $runData->getTemp("site");
     $siteId = $site->getSiteId();
     $q = "SELECT *, count(*) AS number_links FROM page, page_link " . "WHERE page.site_id = '{$siteId}' AND page_link.to_page_id=page.page_id " . "GROUP BY (page.page_id) " . "ORDER BY COALESCE(page.title, page.unix_name)";
     $q = "SELECT * FROM page " . "WHERE page.site_id = '{$siteId}'" . "AND (SELECT count(*) FROM page_link WHERE page_link.to_page_id = page.page_id) = 0 " . "ORDER BY COALESCE(page.title, page.unix_name)";
     $c = new Criteria();
     $c->setExplicitQuery($q);
     $pages = DB_PagePeer::instance()->select($c);
     $runData->contextAdd("pages", $pages);
 }
Example #11
0
 public function save()
 {
     // set parmhash
     $this->setParmhash(crc32($this->getTitle() . " " . $this->getCategories()));
     $page = DB_PagePeer::instance()->selectByPrimaryKey($this->getPageId());
     $site = $GLOBALS['site'];
     $fkey = "frontforumfeedobject.." . $site->getUnixName() . '..' . $page->getUnixName() . '..' . $this->getLabel();
     $mc = OZONE::$memcache;
     $mc->delete($fkey);
     parent::save();
 }
Example #12
0
 public function build($runData)
 {
     $pl = $runData->getParameterList();
     $fromRevisionId = $pl->getParameterValue("from_revision_id");
     $toRevisionId = $pl->getParameterValue("to_revision_id");
     if ($fromRevisionId == $toRevisionId) {
         throw new ProcessException(_("What is the point in comparing the revision with itself? Please choose different revisions of the page."), "same_revision");
     }
     $fromRevision = DB_PageRevisionPeer::instance()->selectByPrimaryKey($fromRevisionId);
     $toRevision = DB_PageRevisionPeer::instance()->selectByPrimaryKey($toRevisionId);
     if ($fromRevision == null || $toRevision == null) {
         throw new ProcessException(_("Error selecting revisions to compare"), "no_revisions");
     }
     $fromMetadata = $fromRevision->getMetadata();
     $toMetadata = $toRevision->getMetadata();
     $changed = array();
     // compare titles and other things
     if ($fromMetadata->getTitle() !== $toMetadata->getTitle()) {
         $changed['title'] = true;
     }
     if ($fromMetadata->getUnixName() !== $toMetadata->getUnixName()) {
         $changed['unix_name'] = true;
     }
     if ($fromMetadata->getParentPageId() !== $toMetadata->getParentPageId()) {
         $changed['parent'] = true;
         if ($fromMetadata->getParentPageId()) {
             $fromParent = DB_PagePeer::instance()->selectByPrimaryKey($fromMetadata->getParentPageId())->getUnixName();
             $runData->contextAdd("fromParent", $fromParent);
         }
         if ($toMetadata->getParentPageId()) {
             $toParent = DB_PagePeer::instance()->selectByPrimaryKey($toMetadata->getParentPageId())->getUnixName();
             $runData->contextAdd("toParent", $toParent);
         }
     }
     //compare source now
     $fromPageSource = $fromRevision->getSourceText();
     $toPageSource = $toRevision->getSourceText();
     if ($fromPageSource !== $toPageSource) {
         $changed['source'] = true;
         // create page diff... wooo...
         $t1 = $fromPageSource;
         $t2 = $toPageSource;
         $inlineDiff = Wikidot_Util_Diff::generateInlineStringDiff($t1, $t2);
         $runData->contextAdd("inlineDiff", $inlineDiff);
     }
     $runData->contextAdd("fromPageSource", $fromPageSource);
     $runData->contextAdd("toPageSource", $toPageSource);
     $runData->contextAdd("fromRevision", $fromRevision);
     $runData->contextAdd("toRevision", $toRevision);
     $runData->contextAdd("fromMetadata", $fromMetadata);
     $runData->contextAdd("toMetadata", $toMetadata);
     $runData->contextAdd("changed", $changed);
 }
Example #13
0
 public function build($runData)
 {
     $pl = $runData->getParameterList();
     $pageId = $pl->getParameterValue("pageId");
     $page = DB_PagePeer::instance()->selectByPrimaryKey($pageId);
     $c = new Criteria();
     $c->add("page_id", $page->getPageId());
     $c->addJoin("user_id", "ozone_user.user_id");
     $c->addOrderAscending("ozone_user.nick_name");
     $rates = DB_PageRateVotePeer::instance()->select($c);
     $runData->contextAdd("rates", $rates);
 }
Example #14
0
 public function selectPagesByParent($categoryId, $parentId)
 {
     $c = new Criteria();
     $categoryId = (int) $categoryId;
     $parentId = (int) $parentId;
     if ($parentId) {
         $c->setExplicitQuery("SELECT * FROM page WHERE category_id = {$categoryId} AND parent_page_id = {$parentId}");
     } else {
         $c->setExplicitQuery("SELECT * FROM page WHERE category_id = {$categoryId} AND parent_page_id IS NULL");
     }
     return DB_PagePeer::instance()->select($c);
 }
Example #15
0
 public function build($runData)
 {
     $user = $runData->getUser();
     $runData->contextAdd("user", $user);
     $pl = $runData->getParameterList();
     // get watched pages for this user
     $c = new Criteria();
     $q = "SELECT page.* FROM watched_page, page " . "WHERE watched_page.user_id='" . $user->getUserId() . "' " . "AND watched_page.page_id=page.page_id";
     $c->setExplicitQuery($q);
     $pages = DB_PagePeer::instance()->select($c);
     $runData->contextAdd("pages", $pages);
     $runData->contextAdd("pagesCount", count($pages));
 }
Example #16
0
 public function getPage()
 {
     if ($this->page) {
         return $this->page;
     } else {
         if ($this->getPageId() === null) {
             return null;
         }
         $page = DB_PagePeer::instance()->selectByPrimaryKey($this->getPageId());
         $this->page = $page;
         return $page;
     }
 }
Example #17
0
 public function build($runData)
 {
     $site = $runData->getTemp("site");
     $pl = $runData->getParameterList();
     $pageId = $pl->getParameterValue("p");
     $page = DB_PagePeer::instance()->selectByPrimaryKey($pageId);
     $threadId = $page->getThreadId();
     $thread = DB_ForumThreadPeer::instance()->selectByPrimaryKey($threadId);
     if ($thread == null) {
         throw new ProcessException("No such thread.", "no_thread");
     }
     $this->threadId = $thread->getThreadId();
     $channel = array();
     $channel['title'] = _('Comments for page') . ' "' . $page->getTitleOrUnixName() . '"';
     $channel['link'] = "http://" . $site->getDomain() . "/" . $page->getUnixName() . "/comments/show";
     $items = array();
     $c = new Criteria();
     $c->add("thread_id", $threadId);
     $c->add("forum_post.site_id", $site->getSiteId());
     $c->addJoin("user_id", "ozone_user.user_id");
     $c->addOrderDescending("post_id");
     $c->setLimit(20);
     $posts = DB_ForumPostPeer::instance()->select($c);
     foreach ($posts as $post) {
         $item = array();
         if ($post->getTitle() != '') {
             $item['title'] = $post->getTitle();
         } else {
             $item['title'] = "(no title)";
         }
         $item['link'] = $channel['link'] . '#post-' . $post->getPostId();
         $item['guid'] = $item['link'];
         $item['date'] = date('r', $post->getDatePosted()->getTimestamp());
         // TODO: replace relative links with absolute links!
         $content = $post->getText();
         $content = preg_replace(';(<.*?)(src|href)="/([^"]+)"([^>]*>);si', '\\1\\2="http://' . $site->getDomain() . '/\\3"\\4', $content);
         $content = preg_replace(';<script\\s+[^>]+>.*?</script>;is', '', $content);
         $content = preg_replace(';(<[^>]*\\s+)on[a-z]+="[^"]+"([^>]*>);si', '\\1 \\2', $content);
         $item['content'] = $content;
         if ($post->getUserId() > 0) {
             $item['authorUserId'] = $post->getUserId();
             $user = $post->getUser();
             $item['author'] = $user->getNickName();
         } else {
             $item['author'] = $post->getUserString();
         }
         $items[] = $item;
     }
     $runData->contextAdd("channel", $channel);
     $runData->contextAdd("items", $items);
 }
Example #18
0
 public function build($runData)
 {
     $site = $runData->getTemp("site");
     $pl = $runData->getParameterList();
     $categoryName = trim($pl->getParameterValue("category", "MODULE"));
     $template = trim($pl->getParameterValue("template", "MODULE"));
     $format = trim($pl->getParameterValue("format", "MODULE"));
     $runData->contextAdd("categoryName", WDStringUtils::toUnixName($categoryName));
     if ($template) {
         $ta = explode(',', $template);
         $tp = array();
         foreach ($ta as $t) {
             // 	for each of the suggested arrays
             $t = trim($t);
             if (!preg_match("/^template:/", $t)) {
                 throw new ProcessException(sprintf(_('"%s" is not in the "template:" category.'), $t), "not_template");
             }
             $page = DB_PagePeer::instance()->selectByName($site->getSiteId(), $t);
             if ($page == null) {
                 throw new ProcessException(sprintf(_('Template "%s" can not be found.'), $t), "no_template");
             }
             $tp[] = $page;
         }
         if (count($tp) > 1) {
             $runData->contextAdd("templates", $tp);
         }
         if (count($tp) == 1) {
             $runData->contextAdd("template", $tp[0]);
         }
     }
     // size of the field
     $fieldSize = $pl->getParameterValue("size", "MODULE");
     $style = $pl->getParameterValue("style", "MODULE");
     $buttonText = $pl->getParameterValue("button", "MODULE");
     if (!$fieldSize) {
         $fieldSize = 30;
     }
     $runData->contextAdd('size', $fieldSize);
     $runData->contextAdd('style', $style);
     $runData->contextAdd('button', $buttonText);
     // check if format is valid (vali regexp)
     $m = false;
     if ($format) {
         $m = @preg_match($format, 'abc');
         if ($m !== false) {
             $runData->contextAdd('format', $format);
         } else {
             $runData->contextAdd("formatError", $format);
         }
     }
 }
Example #19
0
 public function createNewPageEvent($runData)
 {
     // this just checks if page exists and if the user has permissions to create.
     // returns cleaned name.
     $pl = $runData->getParameterList();
     $pageName = trim($pl->getParameterValue("pageName"));
     $categoryName = trim($pl->getParameterValue("categoryName"));
     $format = trim($pl->getParameterValue("format"));
     $autoincrement = $pl->getParameterValue('autoincrement');
     $templateId = $pl->getParameterValue("template");
     $site = $runData->getTemp("site");
     if (strlen($pageName) === 0) {
         $runData->ajaxResponseAdd("status", "no_name");
         $runData->ajaxResponseAdd("message", "You should provide a page name.");
         return;
     }
     // check if use a title too
     //if(WDStringUtils::toUnixName($pageName) != $pageName){
     $pageTitle = $pageName;
     //}
     if ($format) {
         $m = false;
         $m = @preg_match($format, $pageName);
         if ($m !== false && $m === 0) {
             throw new ProcessException(_("The page name is not in the required format."));
         }
     }
     if ($autoincrement) {
         $unixName = $categoryName . ':autoincrementpage';
     } else {
         $unixName = WDStringUtils::toUnixName($categoryName . ':' . $pageName);
     }
     $page = DB_PagePeer::instance()->selectByName($site->getSiteId(), $unixName);
     if ($page != null) {
         $runData->ajaxResponseAdd("status", "page_exists");
         $runData->ajaxResponseAdd("message", "The page <em>" . $unixName . "</em> already exists." . ' <a href="/' . $unixName . '">Jump to it</a> if you wish.');
         return;
     }
     if ($templateId) {
         $templatePage = DB_PagePeer::instance()->selectByPrimaryKey($templateId);
         if (!$templatePage || !preg_match("/^template:/", $templatePage->getUnixName())) {
             throw new ProcessException("Error selecting the template");
         }
         $runData->ajaxResponseAdd("templateId", $templateId);
     }
     $runData->ajaxResponseAdd("unixName", $unixName);
     if ($pageTitle) {
         $runData->ajaxResponseAdd("pageTitle", $pageTitle);
     }
 }
 public function build($runData)
 {
     $categoryId = $runData->getParameterList()->getParameterValue("category_id");
     $site = $runData->getTemp("site");
     $c = new Criteria();
     $c->add("site_id", $site->getSiteId());
     $c->add("category_id", $categoryId);
     $c->addOrderAscending("COALESCE(title, unix_name)");
     $pages = DB_PagePeer::instance()->select($c);
     if (count($pages) > 0) {
         $runData->contextAdd("pages", $pages);
     }
     $runData->ajaxResponseAdd("categoryId", $categoryId);
 }
Example #21
0
 public function build($runData)
 {
     $page = $runData->getTemp("page");
     if (!$page) {
         return;
     }
     $pageId = $page->getPageId();
     // create a very custom query ;-)
     $c = new Criteria();
     $q = "SELECT page_id, title, unix_name FROM page_link, page " . "WHERE page_link.to_page_id='" . db_escape_string($pageId) . "' " . "AND page_link.from_page_id=page.page_id ORDER BY COALESCE(title, unix_name)";
     $c->setExplicitQuery($q);
     $pages = DB_PagePeer::instance()->select($c);
     $runData->contextAdd("pages", $pages);
 }
Example #22
0
 public function processPage($out, $runData)
 {
     $site = $runData->getTemp("site");
     $pageName = $runData->getTemp("pageUnixName");
     if ($pageName == null) {
         return $out;
     }
     $page = DB_PagePeer::instance()->selectByName($site->getSiteId(), $pageName);
     $pageId = $page->getPageId();
     $link = '/feed/page/comments-' . $pageId . '.xml';
     $title = "Comments for the page \"" . $page->getTitleOrUnixName() . "\"";
     $out = preg_replace("/<\\/head>/", '<link rel="alternate" type="application/rss+xml" title="' . htmlspecialchars($title) . '" href="' . $link . '"/></head>', $out, 1);
     return $out;
 }
Example #23
0
 public function build($runData)
 {
     $pl = $runData->getParameterList();
     $site = $runData->getTemp("site");
     $categoryName = $pl->getParameterValue("category", "MODULE", "AMODULE");
     $details = $pl->getParameterValue("details", "MODULE", "AMODULE");
     $preview = $pl->getParameterValue("preview", "MODULE", "AMODULE");
     $order = $pl->getParameterValue("order", "MODULE", "AMODULE");
     $limit = $pl->getParameterValue("limit", "MODULE", "AMODULE");
     if ($categoryName !== null) {
         $category = DB_CategoryPeer::instance()->selectByName($categoryName, $site->getSiteId());
         if ($category == null) {
             throw new ProcessException(_("The category can not be found."));
         }
     }
     // now select pages according to the specified criteria
     $c = new Criteria();
     $c->add("site_id", $site->getSiteId());
     if ($category) {
         $c->add("category_id", $category->getCategoryId());
     }
     switch ($order) {
         case 'dateCreatedDesc':
             $c->addOrderDescending('page_id');
             break;
         case 'dateCreatedAsc':
             $c->addOrderAscending('page_id');
             break;
         case 'dateEditedDesc':
             $c->addOrderDescending('date_last_edited');
             break;
         case 'dateEditedAsc':
             $c->addOrderAscending('date_last_edited');
             break;
         case 'titleDesc':
             $c->addOrderDescending("COALESCE(title, unix_name)");
             break;
         default:
             $c->addOrderAscending("COALESCE(title, unix_name)");
     }
     if ($limit && is_numeric($limit) && $limit > 0) {
         $c->setLimit($limit);
     }
     $pages = DB_PagePeer::instance()->select($c);
     // by default cathegorize by first letter...
     $runData->contextAdd("pages", $pages);
     $runData->contextAdd("details", $details);
     $runData->contextAdd("preview", $preview);
 }
Example #24
0
 public function build($runData)
 {
     $pl = $runData->getParameterList();
     $site = $runData->getTemp("site");
     $pageId = $pl->getParameterValue("page_id");
     $user = $runData->getUser();
     $page = DB_PagePeer::instance()->selectByPrimaryKey($pageId);
     if (!$pageId || $page == null || $page->getSiteId() != $runData->getTemp("site")->getSiteId()) {
         throw new ProcessException(_("Error getting page information."), "no_page");
     }
     if ($this->canSetBlock($user, $page) == false) {
         throw new WDPermissionException(_("Sorry, only Site Admnistrators and selected Moderators can block a page."));
     }
     $runData->contextAdd("page", $page);
 }
Example #25
0
 public function build($runData)
 {
     $pl = $runData->getParameterList();
     $pageId = $pl->getParameterValue("pageId");
     $page = DB_PagePeer::instance()->selectByPrimaryKey($pageId);
     // todo: check if allowed
     $runData->contextAdd("pageId", $page->getPageId());
     $uri = GlobalProperties::$MODULES_CSS_URL . '/pagerate/PageRateWidgetModule.css';
     $this->extraCss[] = $uri;
     $uri = GlobalProperties::$MODULES_JS_URL . '/pagerate/PageRateWidgetModule.js';
     $this->extraJs[] = $uri;
     //check if voters visible
     $category = $page->getCategory();
     $runData->contextAdd("visibility", $category->getRatingVisible());
 }
Example #26
0
 /**
  * Get pages from a site
  * 
  * Argument array keys:
  *  site: site to get pages from
  *  category: category to get pages from (optional)
  * 
  * @param struct $args
  * @return struct
  */
 public function pages($args)
 {
     $this->parseArgs($args, array("performer", "site"));
     WDPermissionManager::instance()->canAccessSite($this->performer, $this->site);
     $c = new Criteria();
     $c->add("site_id", $this->site->getSiteId());
     if ($this->category) {
         $c->add("category_id", $this->category->getCategoryId());
     }
     $ret = array();
     foreach (DB_PagePeer::instance()->selectByCriteria($c) as $page) {
         $ret[] = $this->repr($page, "meta");
     }
     return $ret;
 }
Example #27
0
 public function build($runData)
 {
     $site = $runData->getTemp("site");
     $pageId = $runData->getParameterList()->getParameterValue("page_id");
     $raw = $runData->getParameterList()->getParameterValue("raw");
     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 || $page->getSiteId() !== $site->getSiteId()) {
         throw new ProcessException(_("The page can not be found or does not exist."), "no_page");
     }
     $source = $page->getCurrentRevision()->getSourceText();
     $runData->contextAdd("source", $source);
     $runData->contextAdd("raw", $raw);
 }
Example #28
0
 public function build($runData)
 {
     $pageId = $runData->getParameterList()->getParameterValue("page_id");
     $page = DB_PagePeer::instance()->selectByPrimaryKey($pageId);
     if ($page == null || $page->getSiteId() != $runData->getTemp("site")->getSiteId()) {
         throw new ProcessException(_("Error getting page information."), "no_page");
     }
     $user = $runData->getUser();
     // check permissions now
     $category = $page->getCategory();
     // now check for permissions!!!
     WDPermissionManager::instance()->hasPagePermission('edit', $user, $category, $page);
     if ($page->getParentPageId() !== null) {
         $parentPage = DB_PagePeer::instance()->selectByPrimaryKey($page->getParentPageId());
         $runData->contextAdd("parentPageName", $parentPage->getUnixName());
     }
 }
Example #29
0
 function process(&$matches)
 {
     $pageName = WDStringUtils::toUnixName(trim($matches[1]));
     // get page source (if exists)
     $runData = Ozone::getRunData();
     $site = $runData->getTemp("site");
     $page = DB_PagePeer::instance()->selectByName($site->getSiteId(), $pageName);
     if ($page == null) {
         //$output =  $this->wiki->addToken(
         //	$this->rule, array('fromIncludeRule' => true, 'type' => 'error', 'pageName' => $pageName)
         $output = "\n\n" . '[[div class="error-block"]]' . "\n" . sprintf(_('Page to be included %s can not be found!'), htmlspecialchars($pageName)) . "\n" . '[[/div]]' . "\n\n";
         $wiki = $this->wiki;
         if ($wiki->vars['inclusionsNotExist'] == null) {
             $wiki->vars['inclusionsNotExist'] = array();
         }
         $wiki->vars['inclusionsNotExist'][$pageName] = $pageName;
     } else {
         $output = $page->getSource();
         // prepare entry...
         $wiki = $this->wiki;
         if ($wiki->vars['inclusions'] == null) {
             $wiki->vars['inclusions'] = array();
         }
         $wiki->vars['inclusions'][$page->getPageId()] = $page->getPageId();
         // preprocess the output too!!!
         // missed a few rules so far... TODO!!!
         //process the output - make substitutions.
         $subs = $matches[2];
         if ($subs) {
             $subsArray = explode('|', $subs);
             foreach ($subsArray as $sub) {
                 if (strpos($sub, '=') !== false) {
                     $pos = strpos($sub, '=');
                     $var = trim(substr($sub, 0, $pos));
                     $value = trim(substr($sub, $pos + 1));
                     if ($value != '' && $var != '' && preg_match('/^[a-z0-9\\-\\_]+$/i', $var)) {
                         // substitute!!!
                         $output = str_replace('{$' . $var . '}', $value, $output);
                     }
                 }
             }
         }
     }
     // done, place the script output directly in the source
     return "\n\n" . $output . "\n\n";
 }
Example #30
0
 public function build($runData)
 {
     $pl = $runData->getParameterList();
     $source = $pl->getParameterValue("source");
     $mode = $pl->getParameterValue("mode");
     $site = $runData->getTemp("site");
     $pageId = $pl->getParameterValue("pageId");
     if ($pageId) {
         $runData->setTemp("pageId", $pageId);
         $page = DB_PagePeer::instance()->selectByPrimaryKey($pageId);
         if ($page == null || $page->getSiteId() != $site->getSiteId()) {
             throw new ProcessException(_("Error selecting the page."));
         }
         $runData->setTemp("page", $page);
     }
     $wt = new WikiTransformation();
     $wt->setPageUnixName($pl->getParameterValue("page_unix_name"));
     /*	if($mode == "append"){
     			// combine current source and submitted source
     			$pageId = $pl->getParameterValue("page_id");
     			$page = DB_PagePeer::instance()->selectByPrimaryKey($pageId);
     			$source = $page->getSource()."\n\n[[div id=\"append-preview-div\"]]\n".$source."\n[[/div]]\n";
     		}
     		*/
     /* Get the category and apply the "live template" to the source. */
     $pageUnixName = $pl->getParameterValue("page_unix_name");
     if (strpos($pageUnixName, ":") != false) {
         $tmp0 = explode(':', $pageUnixName);
         $categoryName = $tmp0[0];
     } else {
         $categoryName = "_default";
     }
     $category = DB_CategoryPeer::instance()->selectByName($categoryName, $site->getSiteId());
     /* Look for the template (if any). */
     if (!preg_match(';(:|^)_;', $pageUnixName)) {
         $templatePage = DB_PagePeer::instance()->selectByName($site->getSiteId(), ($categoryName == '_default' ? '' : $categoryName . ':') . '_template');
         if ($templatePage) {
             $source = $wt->assemblyTemplate($source, $templatePage->getSource());
         }
     }
     $result = $wt->processSource($source);
     $body = $result;
     $runData->contextAdd("body", $body);
     $runData->ajaxResponseAdd("title", $pl->getParameterValue("title"));
 }