function execute($par) { global $wgUser, $wgOut, $wgLang, $wgContLang, $wgTitle, $wgMemc, $wgDBname; global $wgServer, $wgRequest, $wgSitename, $wgLanguageCode, $wgContLanguageCode; global $wgFeedClasses, $wgUseRCPatrol; global $wgScriptPath, $wgServer; global $wgSitename, $wgFeedClasses, $wgContLanguageCode; $wgOut->setArticleBodyOnly(true); $type = $wgRequest->getVal("type"); $ndisplay = $wgRequest->getVal("ndisplay"); $DEBUG = 1; require_once 'IGGadgetTMPL.php'; global $messageMemc, $wgDBname, $wgFeedCacheTimeout; global $wgFeedClasses, $wgTitle, $wgSitename, $wgContLanguageCode; $wgOut->setSquidMaxage(3600); // extract the number of days $days = 6; if ($ndisplay != "" && is_numeric($ndisplay) && $ndisplay < 10) { $numitems = $ndisplay; } else { $numitems = 3; } date_default_timezone_set("UTC"); $days = FeaturedArticles::getNumberOfDays($days); $feeds = FeaturedArticles::getFeaturedArticles($days); if ($type == "home") { $now = time(); $count = 0; $mainTitle = ""; $relatedArticles = ""; $featuredArticles = ""; $ggtmpl = new GoogleGadgetHome2(); $ggtmpl->outHeader(); $itemnum = 1; $itemmax = 3; foreach ($feeds as $f) { $url = $f[0]; $d = $f[1]; if ($d > $now) { continue; } $url = str_replace("http://wiki.ehow.com/", "", $url); $url = str_replace("http://www.wikihow.com/", "", $url); $url = str_replace($wgServer . $wgScriptPath . "/", "", $url); $title = Title::newFromURL(urldecode($url)); $title_text = $title->getPrefixedText(); if (isset($f[2]) && $f[2] != null && trim($f[2]) != '') { $title_text = $f[2]; } else { $title_text = wfMsg('howto', $title_text); } $mainTitle = $title; $summary = ""; $a = ""; if ($title == null) { echo "title is null for {$url}"; exit; } if ($title->getArticleID() > 0) { $a = GoodRevision::newArticleFromLatest($title); $summary = $a->getContent(true); $summary = preg_replace('/\\{\\{fa\\}\\}/', '', $summary); global $wgParser; $output = $wgParser->parse($summary, $title, new ParserOptions()); $relatedArticles = $this->getRelatedWikihowsFromSource($title, 4); $summary = $this->addTargetBlank($output->getText()); $summary = preg_replace('/href="\\//', 'href="' . $wgServer . '/', $summary); $summary = preg_replace('/src="\\//', 'src="' . $wgServer . '/', $summary); $summary = preg_replace('/<span id="gatEditSection" class="editsection1">(.*?)<\\/span>/', '', $summary); $linkEmail = $wgServer . '/index.php?title=Special:EmailLink&target=' . $title->getPrefixedURL(); $backlinks = "\n<div id='articletools'><div class='SecL'></div><div class='SecR'></div><a name='articletools'></a><h2> <span>Article Tools</span></h2> </div>"; $backlinks .= "<ul style='list-style: none;margin-left:0;padding-left:4em;text-indent:-1em;'>"; $backlinks .= "<li style='list-style-type: none;'><img src='" . $wgServer . "/skins/WikiHow/images/logo_small.png' height=12 width=15> <a target='_blank' href='" . $wgServer . "/" . $title->getPrefixedURL() . "'>Read on wikiHow</a></li>"; $backlinks .= "<li style='list-style-type: none;'><img src='" . $wgServer . "/skins/WikiHow/sharetab/ShareTab_Email.gif' height=15 width=15> <a target='_blank' href='" . $linkEmail . "'>Email this Article</a></li>"; $backlinks .= "<li style='list-style-type: none;'><img src='" . $wgServer . "/skins/WikiHow/images/pencil_benji_park_01.png' height=15 width=15> <a target='_blank' href='" . $wgServer . $title->getEditURL() . "'>Edit</a></li>"; $backlinks .= "<li style='list-style-type: none;'><img src='" . $wgServer . "/skins/WikiHow/images/speech_ballon.png' height=15 width=15> <a target='_blank' href='" . $wgServer . "/Discussion:" . $title->getPrefixedURL() . "'>Discuss</a></li>"; $backlinks .= "<ul>\n"; $summary .= $backlinks; $ggtmpl->outMain($title_text, $summary, $url, $itemnum); $itemnum++; } else { echo '<!-- no article found for articleid:' . $title->getArticleID() . ' title:' . $title_text . ' -->'; } if ($itemnum > $itemmax) { break; } } $relatedArticles = preg_replace('/href="\\//', 'href="' . $wgServer . '/', $relatedArticles); $ggtmpl->outFooter(); } else { if ($type == "canvas") { $now = time(); $count = 0; $mainTitle = ""; $relatedArticles = ""; $featuredArticles = ""; $maxShow = 7; $ggtmpl = new GoogleGadgetCanvas(); $ggtmpl->outHeader(); foreach ($feeds as $f) { $url = $f[0]; $d = $f[1]; if ($d > $now) { continue; } $url = str_replace("http://wiki.ehow.com/", "", $url); $url = str_replace("http://www.wikihow.com/", "", $url); $url = str_replace($wgServer . $wgScriptPath . "/", "", $url); $title = Title::newFromURL(urldecode($url)); $title_text = $title->getPrefixedText(); if (isset($f[2]) && $f[2] != null && trim($f[2]) != '') { $title_text = $f[2]; } else { $title_text = wfMsg('howto', $title_text); } if ($count < $maxShow) { $mainTitle = $title; $summary = ""; $a = ""; if ($title == null) { echo "title is null for {$url}"; exit; } if ($title->getArticleID() > 0) { $a = GoodRevision::newArticleFromLatest($title); $summary = $a->getContent(true); $summary = preg_replace('/\\{\\{.*\\}\\}/', '', $summary); global $wgParser; $output = $wgParser->parse($summary, $title, new ParserOptions()); $relatedArticles = $this->getRelatedWikihowsFromSource($title, 4); $summary = $this->addTargetBlank($output->getText()); $summary = preg_replace('/href="\\//', 'href="' . $wgServer . '/', $summary); $summary = preg_replace('/src="\\//', 'src="' . $wgServer . '/', $summary); $summary = preg_replace('/<span id="gatEditSection" class="editsection1">(.*?)<\\/span>/', '', $summary); $linkEmail = $wgServer . '/index.php?title=Special:EmailLink&target=' . $title->getPrefixedURL(); $backlinks = "\n<div id='articletools'><div class='SecL'></div><div class='SecR'></div><a name='articletools'></a><h2> <span>Article Tools</span></h2> </div>"; $backlinks .= "<ul style='list-style: none;margin-left:0;padding-left:4em;text-indent:-1em;'>"; $backlinks .= "<li style='list-style-type: none;'><img src='" . $wgServer . "/skins/WikiHow/images/logo_small.png' height=12 width=15> <a target='_blank' href='" . $wgServer . "/" . $title->getPrefixedURL() . "'>Read on wikiHow</a></li>"; $backlinks .= "<li style='list-style-type: none;'><img src='" . $wgServer . "/skins/WikiHow/sharetab/ShareTab_Email.gif' height=15 width=15> <a target='_blank' href='" . $linkEmail . "'>Email this Article</a></li>"; $backlinks .= "<li style='list-style-type: none;'><img src='" . $wgServer . "/skins/WikiHow/images/pencil_benji_park_01.png' height=15 width=15> <a target='_blank' href='" . $wgServer . $title->getEditURL() . "'>Edit</a></li>"; $backlinks .= "<li style='list-style-type: none;'><img src='" . $wgServer . "/skins/WikiHow/images/speech_ballon.png' height=15 width=15> <a target='_blank' href='" . $wgServer . "/Discussion:" . $title->getPrefixedURL() . "'>Discuss</a></li>"; $backlinks .= "<ul>\n"; $summary .= $backlinks; $ggtmpl->outMain($title_text, $summary, $url); } else { echo '<!-- no article found for articleid:' . $title->getArticleID() . ' title:' . $title_text . ' -->'; } } $featuredArticles .= '<li><a href="' . $wgServer . '/' . $url . '" target="_blank">' . $title_text . '</a></li>' . "\n"; $count++; } $relatedArticles = preg_replace('/href="\\//', 'href="' . $wgServer . '/', $relatedArticles); $ggtmpl->outFeaturedArticles($featuredArticles); $ggtmpl->outRelatedArticles($relatedArticles); $ggtmpl->outFooter(); } else { $ggtmpl = new GoogleGadgetModule($wgServer); $ggtmpl->outModulePrefs(); exit; } } }
private function getFeaturedArticleIntro(&$title) { // use public methods from the RSS feed that do the same thing $article = GoodRevision::newArticleFromLatest($title); $summary = Generatefeed::getArticleSummary($article, $title); return $summary; }
public function execute($par) { global $wgUser, $wgOut, $wgLang, $wgContLang, $wgTitle, $wgMemc; global $IP, $wgDBname, $wgParser; global $wgRequest, $wgSitename, $wgLanguageCode, $wgContLanguageCode; global $wgFeedClasses, $wgUseRCPatrol; global $wgScriptPath, $wgServer; global $wgSitename, $wgFeedClasses, $wgContLanguageCode; global $messageMemc, $wgDBname, $wgFeedCacheTimeout; global $wgFeedClasses, $wgTitle, $wgSitename, $wgContLanguageCode, $wgLanguageCode; $fname = 'wfSpecialGeneratefeed'; $fullfeed = 0; $mrss = 0; if ($par == 'fullfeed') { $fullfeed = 1; } else { if ($par == 'mrss') { $mrss = 1; } } require_once "{$IP}/extensions/wikihow/FeaturedRSSFeed.php"; header('Content-Type: text/xml'); $wgOut->setSquidMaxage(60); $feedFormat = 'rss'; $timekey = "{$wgDBname}:rcfeed:{$feedFormat}:timestamp"; $key = "{$wgDBname}:rcfeed:{$feedFormat}:limit:{$limit}:minor:{$hideminor}"; $feedTitle = wfMsg('Rss-feedtitle'); $feedBlurb = wfMsg('Rss-feedblurb'); $feed = new FeaturedRSSFeed($feedTitle, $feedBlurb, "{$wgServer}{$wgScriptPath}/Main-Page"); if ($mrss) { $feed->outHeaderMRSS(); } else { // Replace to get back to raw feed (not full and without mrss) //$feed->outHeader(); $feed->outHeaderFullFeed(); } // extract the number of days below -- this is default $days = 6; date_default_timezone_set('UTC'); if ($wgRequest->getVal('micro', null) == 1) { $days = FeaturedArticles::getNumberOfDays($days, 'RSS-Microblog-Feed'); $feeds = FeaturedArticles::getFeaturedArticles($days, 'RSS-Microblog-Feed'); } else { $days = FeaturedArticles::getNumberOfDays($days); $feeds = FeaturedArticles::getFeaturedArticles($days); } $now = time(); $itemcount = 0; $itemcountmax = 6; foreach ($feeds as $f) { $url = trim($f[0]); $d = $f[1]; if ($d > $now) { continue; } if (!$url) { continue; } $url = str_replace('http://wiki.ehow.com/', '', $url); $url = str_replace('http://www.wikihow.com/', '', $url); $url = str_replace($wgServer . $wgScriptPath . '/', '', $url); $title = Title::newFromURL(urldecode($url)); $summary = ''; $content = ''; if ($title == null) { echo "title is null for {$url}"; exit; } //from the Featured Articles if ($title->getArticleID() > 0) { $article = GoodRevision::newArticleFromLatest($title); $summary = self::getArticleSummary($article, $title); $images = self::getImages($article, $title); //XXFULL FEED if (!$mrss) { $content = $article->getContent(true); $content = preg_replace('/\\{\\{[^}]*\\}\\}/', '', $content); $output = $wgParser->parse($content, $title, new ParserOptions()); $content = self::addTargetBlank($output->getText()); $content = preg_replace('/href="\\//', 'href="' . $wgServer . '/', $content); $content = preg_replace('/src="\\//', 'src="' . $wgServer . '/', $content); $content = preg_replace('/<span id="gatEditSection" class="editsection1">(.*?)<\\/span>/', '', $content); $content = preg_replace('/<h2> <a target="_blank" href="(.*?)>edit<\\/a>/', '<h2>', $content); $content = preg_replace('/<img src="(.*?)\\/skins\\/common\\/images\\/magnify-clip.png"(.*?)\\/>/', '', $content); $linkEmail = $wgServer . '/index.php?title=Special:EmailLink&target=' . $title->getPrefixedURL(); $backlinks = "\n<div id='articletools'><div class='SecL'></div><div class='SecR'></div><a name='articletools'></a><h2> <span>" . wfMsg('RSS-fullfeed-articletools') . "</span></h2> </div>"; $backlinks .= "<ul>\n"; $backlinks .= "<li type='square'><a target='_blank' href='" . $wgServer . "/" . $title->getPrefixedURL() . "'>" . wfMsg('RSS-fullfeed-articletools-read') . "</a></li>\n"; $backlinks .= "<li type='square'><a target='_blank' href='" . $linkEmail . "'>" . wfMsg('RSS-fullfeed-articletools-email') . "</a></li>\n"; $backlinks .= "<li type='square'><a target='_blank' href='" . $wgServer . $title->getEditURL() . "'>" . wfMsg('RSS-fullfeed-articletools-edit') . "</a></li>\n"; $backlinks .= "<li type='square'><a target='_blank' href='" . $wgServer . "/" . $title->getTalkPage() . "'>" . wfMsg('RSS-fullfeed-articletools-discuss') . "</a></li>\n"; $backlinks .= "<ul>\n"; $content .= $backlinks; } } else { continue; } $talkpage = $title->getTalkPage(); $title_text = $title->getPrefixedText(); if (isset($f[2]) && $f[2] != null && trim($f[2]) != '') { $title_text = $f[2]; } else { $title_text = wfMsg('howto', $title_text); } $item = new FeedItem($title_text, $summary, $title->getFullURL(), $d, null, $talkpage->getFullURL()); if ($mrss) { $feed->outItemMRSS($item, $images); } else { // Replace to get back to raw feed (not full and without mrss) $feed->outItemFullFeed($item, $content, $images); } $itemcount++; } $feed->outFooter(); }