public function executeIndex() { $this->wf->ProfileIn(__METHOD__); $mcKey = $this->wf->MemcKey( "OasisPopularBlogPosts", $this->wg->Lang->getCode() ); $this->body = $this->wg->Memc->get($mcKey); if (empty ($this->body)) { $input = " <title>" .$this->wf->Msg('oasis-popular-blogs-title') ."</title> <type>box</type> <order>date</order>"; $time = date('Ymd', strtotime("-1 week")) . '000000'; // 7 days ago // $time = '20091212000000'; // use this value for testing if there are no recent posts $params = array ( "summary" => true, "paging" => false, "create_timestamp" => $time, "count" => 50, "displaycount" => 4, "order" => "comments" // "style" => "add additionalClass if necessary" ); $this->body = BlogTemplateClass::parseTag($input, $params, $wgParser); if (substr($this->body, 0, 9) == '<p><br />') { $this->body = '<p>'.substr($this->body, 9); } if (substr($this->body, 0, 45) !== '<section class="WikiaBlogListingBox module ">') { $this->body = '<section class="WikiaBlogListingBox module ">'.$this->body.'</section>'; } $this->wg->Memc->set ($mcKey, $this->body, 60*60); // cache for 1 hour } $this->wf->ProfileOut(__METHOD__); }
public function execute() { global $wgParser; $summarylength = $page_id = null; extract($this->extractRequestParams()); $params = array("type" => "array", "timestamp" => true, "summary" => true, "summarylength" => (int) $summarylength); $cats = BlogTemplateClass::parseTag("<pages>" . (int) $page_id . "</pages>", $params, $wgParser); if (empty($cats)) { $cats = array(); } foreach ($cats as $page_id => $cat) { if (!empty($cat['category'])) { $this->getResult()->setIndexedTagName($cats[$page_id]['category'], 'cat_url'); } } $this->getResult()->setIndexedTagName($cats, 'id'); $this->getResult()->addValue(null, 'blogpage', $cats); }
} ?> <li class="list"> <div class="wk_blogs_link"><a href="<?php echo $oTitle->getLocalUrl(); ?> "><?php echo BlogTemplateClass::getSubpageText($oTitle); ?> </a></div> <?php /* s: TIMESTAMP */ if (!empty($aOptions['timestamp'])) { $sUserLinks = ''; if ($wgTitle->getNamespace() != NS_BLOG_ARTICLE) { $aUserLinks = BlogTemplateClass::getUserNameRecord($aRow['username']); if (!empty($aUserLinks)) { $sUserLinks = $aUserLinks['userpage'] . ' (' . $aUserLinks['talkpage'] . '|' . $aUserLinks['contribs'] . ')'; } } ?> <div class="wk_date"><span class="left"><?php echo $wgLang->date($aRow['rev_timestamp'], true); ?> </span><span class="right"><?php echo $sUserLinks; ?> </span></div> <?php } /* e: TIMESTAMP */
public static function axBlogListingCheckMatches() { global $wgRequest, $wgParser; $oSpecialPage = new CreateBlogListingPage(); $oSpecialPage->setFormData('listingCategories', $wgRequest->getVal('categories')); $oSpecialPage->setFormData('listingAuthors', $wgRequest->getVal('authors')); $oSpecialPage->setFormData('listingType', 'count'); return (string) BlogTemplateClass::parseTag($oSpecialPage->buildTagContent(), array(), $wgParser); }
/** * categoryIndexer -- indexer for blog listing page used only one time by indexing script * * @static * @access public * * * @return bool */ public static function categoryIndexer(&$self, $article) { global $wgRequest; if ($wgRequest->getVal("makeindex", 0) != 1) { return true; } if ($article != null) { $self->parseTag(urldecode($article)); $cats = BlogTemplateClass::getCategoryNames(); if (count($cats) > 0) { self::blogListingBuildRelation($article, $cats, array()); } } return true; }
/** * generate xml feed from returned data */ private function showFeed($format) { global $wgOut, $wgRequest, $wgParser, $wgMemc, $wgFeedClasses, $wgTitle; global $wgSitename; $user = $this->mTitle->getBaseText(); $userMemc = $this->mTitle->getPrefixedDBkey(); $listing = false; $purge = $wgRequest->getVal('action') == 'purge'; $offset = 0; wfProfileIn(__METHOD__); if (!$purge) { $listing = $wgMemc->get(wfMemcKey("blog", "feed", $userMemc, $offset)); } if (!$listing) { $params = array("count" => 50, "summary" => true, "summarylength" => 750, "type" => "array", "title" => "Blogs", "offset" => $offset); $listing = BlogTemplateClass::parseTag("<author>{$user}</author>", $params, $wgParser); $wgMemc->set(wfMemcKey("blog", "feed", $userMemc, $offset), $listing, 3600); } $feed = new $wgFeedClasses[$format](wfMsg("blog-userblog", $user), wfMsg("blog-fromsitename", $wgSitename), $wgTitle->getFullUrl()); $feed->outHeader(); if (is_array($listing)) { foreach ($listing as $item) { $title = Title::newFromText($item["title"], NS_BLOG_ARTICLE); $item = new FeedItem($title->getSubpageText(), $item["description"], $item["url"], $item["timestamp"], $item["author"]); $feed->outItem($item); } } $feed->outFooter(); wfProfileOut(__METHOD__); }
/** * generate xml feed from returned data */ private function showFeed($format) { global $wgRequest, $wgParser, $wgMemc, $wgFeedClasses, $wgTitle; global $wgSitename; $user = $this->mTitle->getBaseText(); $listing = false; $purge = $wgRequest->getVal('action') == 'purge'; $offset = 0; $memKey = $this->blogFeedMemcacheKey($this->getBlogOwner(), $offset); if (!$purge) { $listing = $wgMemc->get($memKey); } if (!$listing) { $params = ["count" => 50, "summary" => true, "summarylength" => 750, "type" => "array", "title" => "Blogs", "offset" => $offset]; $listing = BlogTemplateClass::parseTag("<author>{$user}</author>", $params, $wgParser); $wgMemc->set($memKey, $listing, self::CACHE_TTL); } /** @var ChannelFeed $feed */ $feed = new $wgFeedClasses[$format](wfMessage("blog-userblog", $user)->escaped(), wfMessage("blog-fromsitename", $wgSitename)->escaped(), $wgTitle->getFullUrl()); $feed->outHeader(); if (is_array($listing)) { foreach ($listing as $item) { $title = Title::newFromText($item["title"], NS_BLOG_ARTICLE); $item = new FeedItem($title->getSubpageText(), $item["description"], $item["url"], $item["timestamp"], $item["author"]); $feed->outItem($item); } } $feed->outFooter(); }
<?= Wikia::specialPageLink('CreateBlogPage', 'blog-create-post-label', 'wikia-button', 'blank.gif', 'blog-create-post-label', 'sprite blog') ?> <h3> <?= $title ?> </h3> <?php } // end BlogListingBox header ?> <ul> <?php foreach ($posts as $post) { $title = Title::newFromText($post['title'], $post['namespace']); ?> <li class="WikiaBlogListingPost"> <?= F::app()->renderView('CommentsLikes', 'Index', array('comments' => $post['comments'], 'bubble' => true, 'title' => $title, 'accesskey' => false)); ?> <?= $post['avatar'] ?> <div class="author-details"> <h1><a href="<?= htmlspecialchars($title->getLocalUrl()) ?>"><?= htmlspecialchars(BlogTemplateClass::getSubpageText($title)) ?></a></h1> <span><?= wfMsg('blog-by', $post['date'], Xml::element('a', array('href' => htmlspecialchars($post['userpage'])), $post['username'], false)) ?></span> </div> <blockquote> <?php // handle proper rendering of "read more" $readMoreLink = Xml::openElement('span', array('class' => 'read-more')) . Wikia::link($title, wfMsg('blog-readfullpost') . ' >') . Xml::closeElement('span'); // if blog post rendered text ends with </p> if (!empty($post['readmore'])) { if (substr($post['text'], -4) == '</p>') { $post['text'] = substr($post['text'], 0, -4) . '<br>' . $readMoreLink . '</p>'; } else {
$title = Title::newFromText($post['title'], $post['namespace']); ?> <li class="WikiaBlogListingPost"> <?php echo F::app()->renderView('CommentsLikes', 'Index', array('comments' => $post['comments'], 'bubble' => true, 'title' => $title, 'accesskey' => false)); ?> <?php echo $post['avatar']; ?> <div class="author-details"> <h2><a href="<?php echo htmlspecialchars($title->getLocalUrl()); ?> "><?php echo htmlspecialchars(BlogTemplateClass::getSubpageText($title)); ?> </a></h2> <span><?php echo wfMsg('blog-by', $post['date'], Xml::element('a', array('href' => htmlspecialchars($post['userpage'])), $post['username'], false)); ?> </span> </div> <div class='post-summary'> <?php // handle proper rendering of "read more" $readMoreLink = Xml::openElement('span', array('class' => 'read-more')) . Wikia::link($title, wfMsg('blog-readfullpost') . ' >') . Xml::closeElement('span'); // if blog post rendered text ends with </p> if (substr($post['text'], -4) == '</p>') { $post['text'] = substr($post['text'], 0, -4) . '<br>' . $readMoreLink . '</p>';
/** * Retrieve short text from provided article * * This is a way to access a functionality of private __getRevisionText method * * @author Kamil Koterba * @since June 2013 * * @param integer $iPage Page id * @param Revision $oRev Revision of article to get text from * @return mixed|string */ public static function getShortText($iPage, Revision $oRev) { wfProfileIn(__METHOD__); // backup current value $aOptions_bck = self::$aOptions; // set options required to retrieve short text self::$aOptions = array('type' => 'plain', 'summary' => 'true'); // get short text $shortText = self::__getRevisionText($iPage, $oRev); // restore options self::$aOptions = $aOptions_bck; wfProfileOut(__METHOD__); return $shortText; }
/** * @author Jakub Kurcek * @param format string 'rss' or 'atom' * */ private function FeedRecentBlogPosts($format) { global $wgParser, $wgUser, $wgServer, $wgOut, $wgExtensionsPath, $wgRequest, $wgEnableBlogArticles; if (empty($wgEnableBlogArticles)) { $this->showMenu(); } else { // local settings $maxNumberOfBlogPosts = 10; $postCharacterLimit = 293; $userAvatarSize = 48; // If blog listing does not exit treats parameter as empty; $sListing = $wgRequest->getVal('listing'); $title = Title::newFromText($sListing, NS_BLOG_LISTING); if (!empty($sListing) && ($title == null || !$title->exists())) { unset($sListing); } $oBlogListing = new CreateBlogListingPage(); $oBlogListing->setFormData('listingAuthors', ''); $oBlogListing->setFormData('tagContent', ''); if (!empty($sListing)) { $oBlogListing->parseTag(urldecode($sListing)); $subTitleName = wfMsg('blog-posts-from-listing', $sListing); } else { $oBlogListing->setFormData('listingCategories', ''); $subTitleName = wfMsg('all-blog-posts'); } $input = $oBlogListing->buildTagContent(); $db = wfGetDB(DB_SLAVE, 'dpl'); $params = array("summary" => true, "timestamp" => true, "count" => $maxNumberOfBlogPosts); $result = BlogTemplateClass::parseTag($input, $params, $wgParser, null, true); $feedArray = array(); foreach ($result as $val) { $oTitle = Title::newFromID($val['page']); $aValue = explode('/', $oTitle->getText()); $feedArray[] = array('title' => $aValue[1], 'description' => substr(str_replace(' ', ' ', strip_tags($val['text'])), 0, $postCharacterLimit), 'url' => $oTitle->getFullURL(), 'date' => $val['date'], 'author' => $val['username'], 'otherTags' => array('image' => AvatarService::getAvatarUrl($val['username'], $userAvatarSize))); } $this->showFeed($format, wfMsg('feed-title-blogposts') . ' - ' . $subTitleName, $feedArray); } }
public static function axShowCurrentPage($articleId, $namespace, $offset, $skin) { global $wgParser; wfProfileIn(__METHOD__); $result = ""; $offset = intval($offset); if ($offset >= 0) { $oTitle = Title::newFromID($articleId); if (!empty($oTitle) && $oTitle instanceof Title) { self::$oTitle = $oTitle; $oRevision = Revision::newFromTitle($oTitle); $sText = $oRevision->getText(); $id = Parser::extractTagsAndParams(array(BLOGTPL_TAG), $oRevision->getText(), $matches, md5(BLOGTPL_TAG . $articleId . $namespace . $offset)); if (!empty($matches)) { list($sKey, $aValues) = each($matches); list(, $input, $params, ) = $matches[$sKey]; $input = trim($input); if (!empty($input) && !empty($params)) { $aTags = array(); $count = 0; /* try to find count */ if (preg_match_all(BLOGS_XML_REGEX, $input, $aTags)) { if (!empty($aTags) && !empty($aTags[1])) { if (in_array('count', array_values($aTags[1]))) { foreach ($aTags[1] as $id => $key) { if ($key == 'count') { $count = intval($aTags[2][$id]); break; } } } } } if (!empty($params) && array_key_exists('count', $params)) { $count = intval($params['count']); } if (empty($count)) { $count = intval(self::$aBlogParams['count']['default']); } $offset = $count * $offset; /* set new value of offset */ $params['offset'] = $offset; /* run parser */ $result = self::parseTag($input, $params, $wgParser); } } } else { wfDebugLog(__METHOD__, "Invalid parameters - {$articleId}, {$namespace}, {$offset} \n"); } } wfProfileOut(__METHOD__); if (is_array($result)) { return $result[0]; } return $result; }