コード例 #1
0
	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__);
	}
コード例 #2
0
ファイル: WikiaApiBlogs.php プロジェクト: Tjorriemorrie/app
 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);
 }
コード例 #3
0
 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);
 }
コード例 #4
0
ファイル: BlogArticle.php プロジェクト: schwarer2006/wikia
 /**
  * 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__);
 }
コード例 #5
0
ファイル: BlogArticle.php プロジェクト: Tjorriemorrie/app
 /**
  * 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();
 }
コード例 #6
0
 /**
  * @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('&nbsp;', ' ', 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);
     }
 }