Пример #1
0
 function execute($par)
 {
     global $wgUser, $wgOut, $wgLang, $wgContLang, $wgTitle, $wgMemc, $wgDBname;
     global $wgRequest, $wgSitename, $wgLanguageCode, $wgContLanguageCode;
     global $wgFeedClasses, $wgUseRCPatrol;
     global $wgScriptPath, $wgServer;
     global $wgSitename, $wgFeedClasses, $wgContLanguageCode;
     $fname = 'wfSpecialGeneratefeed';
     $pretty = isset($_GET['pretty']) && $_GET['pretty'] != null;
     global $messageMemc, $wgDBname, $wgFeedCacheTimeout;
     global $wgFeedClasses, $wgTitle, $wgSitename, $wgContLanguageCode;
     header('Content-type: application/x-javascript');
     if ($pretty) {
         echo 'document.writeln("<div style=\\"border: 1px solid #ccc; padding: 15px; width:275px; font-size: small; font-family: Arial;\\"><center><a href=\\"http://www.wikihow.com\\"><img src=\\"http://www.wikihow.com/skins/WikiHow/wikiHow.gif\\" border=0></a></center><br/>");';
         echo 'document.writeln("<b>How-to of the Day:</b><br />");';
     } else {
         echo 'document.writeln("<b>wikiHow: How-to of the Day:</b><br />");';
     }
     $feeds = FeaturedArticles::getFeaturedArticles(6);
     $now = time();
     foreach ($feeds as $f) {
         $url = $f[0];
         $d = $f[1];
         if ($d > $now) {
             continue;
         }
         $url = str_replace("http://www.wikihow.com/", "", $url);
         $title = Title::newFromURL(urldecode($url));
         echo 'document.writeln("<a href=\\"' . $title->getFullURL() . '\\">How to ' . $title->getText() . '</a><br/>");';
     }
     if ($pretty) {
         echo 'document.writeln("</div>");';
     }
     exit;
 }
Пример #2
0
 function doQuery()
 {
     $fas = FeaturedArticles::getTitles(45);
     foreach ($fas as $fa) {
         $this->articles[] = Linker::link($fa['title']);
     }
 }
Пример #3
0
 function doQuery()
 {
     $Fas = FeaturedArticles::getTitles(45);
     foreach ($Fas as $fa) {
         $this->articles[] = $this->skin->makeLinkObj($fa['title']);
     }
 }
Пример #4
0
function wfSpecialListFeed($par)
{
    global $wgUser, $wgOut;
    $fname = "wfSpecialListFeed";
    $sk = $wgUser->getSkin();
    $feeds = FeaturedArticles::getFeaturedArticles(11);
    $wgOut->addHTML("<ul>");
    foreach ($feeds as $item) {
        $feed = $item[0];
        $x = str_replace("http://wiki.ehow.com/", "", $feed);
        $x = str_replace("http://www.wikihow.com/", "", $feed);
        $t = Title::newFromDBKey($x);
        $summary = "";
        $a = null;
        if ($t->getArticleID() > 0) {
            $a = new Article(&$t);
            $summary = Article::getSection($a->getContent(false), 0);
            $summary = ereg_replace("<.*>", "", $summary);
            $summary = ereg_replace("\\[\\[.*\\]\\]", "", $summary);
            $summary = ereg_replace("\\{\\{.*\\}\\}", "", $summary);
            $summary = trim($summary);
            $tags = getTechnoratiTags($a->getContent(false));
        }
        $wgOut->addHTML("<div style='width:400px; border: 1px #ccc solid; margin-bottom:20px; padding: 10px; '>");
        $wgOut->addHTML("<img height=16 src='http://wiki.ehow.com/skins/common/images/check.jpg'><a href='{$feed}'>How to " . $t->getText() . "</a><br/><br/>");
        $wgOut->addHTML($summary);
        $wgOut->addHTML("<br/><a href='{$feed}'><i>Read more...</i></a><br/><br/><font size=-2>Posted " . $item[1] . " - (<a href='{$feed}'>Permalink</a>)");
        if ($tags != null) {
            $wgOut->addHTML(" (Technorati Tags: " . trim($tags) . ")");
        }
        $wgOut->addHTML("</font>");
        $wgOut->addHTML("</div>");
    }
    $wgOut->addHTML("</ul>");
    $wgOut->addHTML('<script type="text/javascript" src="http://embed.technorati.com/embed/unj3heqw9.js"></script>');
}
Пример #5
0
    function getFacebookHTML($showimages = false)
    {
        global $wgParser, $wgServer;
        $feeds = FeaturedArticles::getFeaturedArticles(1);
        $html = "<fb:title>The How-to Article of the Day</fb:title>\n\t\t\t\t<fb:subtitle><a href='http://www.wikihow.com'>from wikiHow</a></fb:subtitle>\n\t\t";
        $now = time();
        $dbr = wfGetDB(DB_SLAVE);
        foreach ($feeds as $f) {
            $url = $f[0];
            $d = $f[1];
            if ($d > $now) {
                continue;
            }
            $url = str_replace("http://www.wikihow.com/", "", $url);
            $url = str_replace("{$wgServer}/", "", $url);
            $title = Title::newFromURL(urldecode($url));
            // get last safe id
            $res = $dbr->select('revision', array('rev_user', 'rev_id', 'rev_user_text'), array('rev_page' => $title->getArticleId(), 'rev_user>0'), "wfGetFacebookHTML", array('ORDER BY' => 'rev_id desc'));
            $rev_id = 0;
            while ($row = $dbr->fetchObject($res)) {
                $num_edits = $dbr->selectField('revision', 'count(*)', array("rev_user={$row->rev_user}"));
                if ($num_edits > 300) {
                    $rev_id = $row->rev_id;
                    break;
                }
            }
            $dbr->freeResult($res);
            $revision = null;
            if ($rev_id > 0) {
                $revision = Revision::newFromID($rev_id);
            } else {
                $revision = Revision::newFromTitle($title);
            }
            $summary = Article::getSection($revision->getText(), 0);
            $summary = ereg_replace("\\{\\{.*\\}\\}", "", $summary);
            if (!$showimages) {
                $summary = preg_replace("/\\[\\[Image[^\\]]*\\]\\]/", "", $summary);
            }
            // strip images
            $output = $wgParser->parse($summary, $title, new ParserOptions());
            $summary = strip_tags($output->getText(), '<img>');
            $img = "";
            $style = 'style="float:right;margin-left:10px;margin-bottom:10px;"';
            if (strpos($summary, "<img") !== false && $showimages) {
                $re = '/<img[^>]*>/';
                preg_match_all($re, $summary, $matches);
                $summary = preg_replace($re, '', $summary);
                $img = $matches[0][0];
                preg_match_all('/width="[0-9]*"/', $img, $matches);
                $width = 200;
                if (sizeof($matches[0]) > 0) {
                    $s_width = str_replace('width=', '', $matches[0][0]);
                    $s_width = str_replace('"', '', $s_width);
                    $s_width = intval($s_width);
                    if ($s_width < $width) {
                        $width = $s_width;
                    }
                }
                $src = "";
                preg_match_all('/src="[^"]*"/', $img, $matches);
                if (sizeof($matches[0]) > 0) {
                    $src = str_replace("src=", "", $matches[0][0]);
                    $src = str_replace('"', "", $src);
                    if (strpos($src, "http://www.wikihow.com") === false) {
                        $src = "http://www.wikihow.com" . $src;
                    }
                }
                $img = "<img src=\"{$src}\" {$style} width=\"{$width}\">";
            } else {
                $img = "<img src=\"http://www.wikihow.com/skins/WikiHow/wikiHow.gif\" {$style} width=\"100\"/>";
            }
            $html .= "<p style=\"font-size:1.2em;margin:2px 0;\"><a href='{$title->getFullURL()}' style=\"font-weight:bold\">" . wfMsg('howto', $title->getText()) . '</a></p>';
            $html .= "<p>\n\t\t\t\t{$img} \n\t\t\t\t{$summary}\n\t\t\t\t</p>\n\t\t\t\t<p><a href='{$title->getFullURL()}'>Read more...</a></p>";
            $html .= '<table style="clear:both;margin:0 auto;"><tr><td>Do you want to do this? |&nbsp;
				</td><td >' . "<fb:share-button class='url' href='{$title->getFullURL()}'/> </td></tr></table>";
            break;
        }
        $html .= '<fb:if-is-own-profile>&nbsp;<fb:else><br/><div style="text-align:right;"><a href="http://apps.facebook.com/howtooftheday">Put this on my profile</a></div></fb:else></fb:if-is-own-profile>';
        return $html;
    }
 function processFeatured()
 {
     global $wgServer, $wgFeedClasses;
     echo "Processing Featured Articles Notification\n";
     $days = 1;
     date_default_timezone_set("UTC");
     $feeds = FeaturedArticles::getFeaturedArticles($days);
     $now = time();
     $tomorrow = strtotime('tomorrow');
     $today = strtotime('today');
     echo "Tomorrow: " . date('m/d/Y H:i:s', $tomorrow) . "[{$tomorrow}] Today: " . date('m/d/Y H:i:s', $today) . "[{$today}] NOW: " . date('m/d/Y H:i:s', $now) . " \n";
     foreach ($feeds as $f) {
         $url = $f[0];
         $d = $f[1];
         echo "Processing url: {$url} with epoch " . date('m/d/Y H:i:s', $d) . "[{$d}]\n";
         if ($d > $tomorrow || $d < $today) {
             continue;
         }
         $url = str_replace("http://www.wikihow.com/", "", $url);
         $url = str_replace($wgServer . "/", "", $url);
         $title = Title::newFromURL(urldecode($url));
         $title_text = $title->getText();
         if (isset($f[2]) && $f[2] != null && trim($f[2]) != '') {
             $title_text = $f[2];
         } else {
             $title_text = wfMsg('howto', $title_text);
         }
         if (isset($title)) {
             echo "Featured: {$title_text} [AID] " . $title->getArticleID() . " [URL] {$url}\n";
             AuthorEmailNotification::notifyFeatured($title);
         } else {
             echo "Warning Featured: could not retrieve article id for {$url}\n";
         }
     }
 }
Пример #7
0
 private function getFeaturedArticles($num)
 {
     global $IP;
     $NUM_DAYS = 15;
     // enough days to make sure we get $num articles
     $featured = FeaturedArticles::getFeaturedArticles($NUM_DAYS);
     $fas = '';
     $n = 1;
     foreach ($featured as $f) {
         $partUrl = preg_replace('@^http://(\\w|\\.)+\\.wikihow\\.com/@', '', $f[0]);
         $title = Title::newFromURL(urldecode($partUrl));
         $box_array = $this->makeRelatedBox($title, true);
         if (!empty($box_array)) {
             $fas[] = $box_array;
             if (++$n > $num) {
                 break;
             }
         }
     }
     return $fas;
 }
Пример #8
0
<?php

require_once 'commandLine.inc';
$dbr = wfGetDB(DB_SLAVE);
$dbw = wfGetDB(DB_MASTER);
// PROCESS FA articles
$fas = FeaturedArticles::getFeaturedArticles(1);
foreach ($fas as $fa) {
    $url = urldecode(preg_replace("@http://www.wikihow.com/@", "", $fa[0]));
    $t = Title::newFromURL($url);
    if (!$t) {
        echo "Can't make title";
        print_r($fa);
        continue;
    }
    echo "sending notification for FA for {$t->getFullText()}\n";
    AuthorEmailNotification::notifyFeatured($t);
}
// PROCESS VIEWERSHIP EMAILS
$ts = wfTimestamp(TS_MW, time() - 86400);
$sql = "SELECT page_namespace, page_title, page_counter, en_viewership, en_user\n\t\tFROM email_notifications \n\t\tLEFT JOIN page ON en_page=page_id\n\t\tWHERE en_viewership_email IS NULL\n\t\t\tOR en_viewership_email < '{$ts}'";
$res = $dbr->query($sql, __FILE__);
$milestones = array(10000, 5000, 1000, 500, 100);
while ($row = $dbr->fetchObject($res)) {
    $send = false;
    if (!$row->page_title) {
        continue;
    }
    if ($row->page_counter >= 10000 && $row->page_counter - $row->en_viewership >= 10000) {
        $milestone = floor($row->page_counter / 10000) * 10000;
        $send = true;
Пример #9
0
 public static function generateFeedItem()
 {
     $fname = "FeedGeneralActivities:generateFeedItem";
     $dbr = wfGetDB(DB_SLAVE);
     $msg = null;
     $x = rand(0, 4);
     switch ($x) {
         case 0:
             $count = $dbr->selectField('imageadder', 'count(*)', array('imageadder_hasimage' => 0));
             $count = number_format($count, 0, ".", ",");
             $msg = "There are {$count} articles with no image in the introduction, start adding images <a href='/Special:Introimageadder'>now.</a>";
             $t = Title::makeTitle(NS_SPECIAL, "Introimageadder");
             break;
         case 1:
             $count = $dbr->selectField('recentchanges', 'count(*)', array('rc_patrolled' => 0));
             $count = number_format($count, 0, ".", ",");
             $msg = "There are {$count} unpatrolled edits in recent changes, start patrolling <a href='/Special:RCPatrol'>now.</a>";
             $t = Title::makeTitle(NS_SPECIAL, "RCPatrol");
             break;
         case 2:
             $count = $dbr->selectField('editfinder', 'count(*)', array());
             $count = number_format($count, 0, ".", ",");
             $msg = "There are {$count} articles in the repair shop, start fixing them <a href='/Special:EditFinder'>now.</a>";
             $t = Title::makeTitle(NS_SPECIAL, "EditFinder");
             break;
         case 3:
             $count = $dbr->selectField('qc', 'count(*)', array('qc_patrolled' => 0));
             $count = number_format($count, 0, ".", ",");
             $msg = "There are {$count} edits in the QG queue, start patrolling them <a href='/Special:QG'>now.</a>";
             $t = Title::makeTitle(NS_SPECIAL, "QG");
             break;
         case 4:
             $feeds = FeaturedArticles::getFeaturedArticles(1);
             if (sizeof($feeds > 0)) {
                 $url = $feeds[0][0];
                 $url = preg_replace("@http://www.wikihow.com/@", "", $url);
                 $t = Title::newFromURL(urldecode($url));
                 if ($t) {
                     $img = SkinWikihowskin::getGalleryImage($t, 44, 33);
                     $msg = "<img src='{$img}'/><a href='{$t->getFullURL()}'>{$t->getText()}</a> is today's Featured Article";
                 }
             }
             break;
     }
     $html = "";
     if ($msg) {
         $html = "<div class='feeditem'>{$msg}<div class='actions'><a href='{$t->getFullURL()}'>Go there now</a></div></div>";
     }
     wfProfileOut($fname);
     return $html;
 }
Пример #10
0
 function execute($par)
 {
     global $wgOut, $wgTitle, $wgMemc, $wgServer;
     global $wgScriptPath, $wgServer, $wgRequest;
     require_once 'NVGadgetTMPL.php';
     header("Content-Type: text/html");
     $wgOut->setSquidMaxage(3600);
     $nvtmpl = new NetVibes();
     $nvtmpl->outHeader();
     // extract the number of days
     $days = 6;
     $numitems = 5;
     date_default_timezone_set("UTC");
     $days = FeaturedArticles::getNumberOfDays($days);
     $feeds = FeaturedArticles::getFeaturedArticles($days);
     if (count($feeds) > 2) {
         $spotlight = rand(0, 3);
     } else {
         $spotlight = rand(0, count($feeds));
     }
     if ($getSpotlight = $wgRequest->getVal('spotlight')) {
         $spotlight = $getSpotlight;
     }
     $now = time();
     $count = 0;
     $itemsshown = 0;
     $itemlist = "";
     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));
         $summary = "";
         $image = "";
         $mtext = "";
         $a = "";
         if ($title == null) {
             echo "title is null for {$url}";
             exit;
         }
         if ($title->getArticleID() > 0) {
             $a = $this->getLastPatrolledRevision($title);
             $summary = Article::getSection($a->getContent(true), 0);
             global $wgParser;
             $summary = ereg_replace("\\{\\{.*\\}\\}", "", $summary);
             $output = $wgParser->parse($summary, $title, new ParserOptions());
             $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);
             }
             $artbloblen = 480;
             if ($count == $spotlight) {
                 $summary = $output->getText();
                 // REMOVE MAGNIFY IMAGE
                 $summary = preg_replace('/<img src="\\/skins\\/common\\/images\\/magnify-clip\\.png" width="15" height="11" alt="" \\/>/', '', $summary);
                 // REBUILD IMAGE TAG. RESIZE IMAGE AND SET ABSOLUTE PATH.
                 if (preg_match('/<img alt=".*?" src="(.*?)" width="(\\d+)" height="(\\d+)"/', $summary, $match)) {
                     if ($match[3] != "") {
                         if ($match[3] > 100) {
                             $hrat = 100 / $match[3];
                         } else {
                             $hrat = 1;
                         }
                         $width = number_format($match[2] * $hrat, 0, '.', '');
                         $height = number_format($match[3] * $hrat, 0, '.', '');
                     }
                     $summary = preg_replace('/width="' . $match[2] . '"/', 'width="' . $width . '"', $summary);
                     $summary = preg_replace('/height="' . $match[3] . '"/', 'height="' . $height . '"', $summary);
                     $p = preg_replace('/\\//', '\\/', $match[1]);
                     $p = '/src="' . $p . '"/';
                     $rval = 'src="' . $wgServer . $match[1] . '"';
                     $summary = preg_replace($p, $rval, $summary);
                 }
                 // REMOVE ALL TAGS EXCEPT IMG AND SETUP IMAGE DIV
                 $summary = strip_tags($summary, '<img>');
                 if (preg_match('/<img(.*?)>/', $summary, $match)) {
                     $m = preg_replace('/\\//', '\\/', $match[1]);
                     $pat = '/<img' . $m . '>/';
                     $rval = '<div class="floatright"><span>' . '<a href="' . $wgServer . '/' . $url . '" target="_blank">' . '<img' . $match[1] . '></a></span></div>';
                     $summary = preg_replace($pat, $rval, $summary);
                 }
                 // TRUNCATE ARTICLE
                 if (strlen($summary) > $artbloblen) {
                     $summary = substr($summary, 0, $artbloblen);
                     $summary .= '... <a href="' . $wgServer . '/' . $url . '" target="_blank">[Read More]</a>' . "\n";
                 } else {
                     $summary .= ' <a href="' . $wgServer . '/' . $url . '" target="_blank">[Read More]</a>' . "\n";
                 }
                 $nvtmpl->outMain($title_text, $summary, $url);
             } else {
                 if ($itemsshown < $numitems) {
                     $itemlist .= $nvtmpl->outItem($title_text, $summary, $url, $count);
                     $itemsshown++;
                 }
             }
             $count++;
         }
     }
     $nvtmpl->outItemList($itemlist);
     $nvtmpl->outFooter();
 }
Пример #11
0
 function getFeaturedArticlesBox($daysLimit = 11, $linksLimit = 4)
 {
     global $wgServer, $wgTitle, $IP, $wgMemc, $wgProdHost;
     $cachekey = wfMemcKey('featuredbox', $daysLimit, $linksLimit);
     $result = $wgMemc->get($cachekey);
     if ($result) {
         return $result;
     }
     $feeds = FeaturedArticles::getFeaturedArticles($daysLimit);
     $html = "<h3><span onclick=\"location='" . wfMessage('featuredarticles_url')->text() . "';\" style=\"cursor:pointer;\">" . wfMessage('featuredarticles')->text() . "</span></h3>\n";
     $now = time();
     $popular = Title::makeTitle(NS_SPECIAL, "Popularpages");
     $randomizer = Title::makeTitle(NS_SPECIAL, "Randomizer");
     $count = 0;
     foreach ($feeds as $item) {
         $url = $item[0];
         $date = $item[1];
         if ($date > $now) {
             continue;
         }
         $url = str_replace("{$wgServer}/", "", $url);
         if ($wgServer != 'http://www.wikihow.com') {
             $url = str_replace("http://www.wikihow.com/", "", $url);
         }
         $url = str_replace("http://{$wgProdHost}/", "", $url);
         $title = Title::newFromURL(urldecode($url));
         if ($title) {
             //$html .= $this->featuredArticlesRow($title);
             $html .= self::getArticleThumb($title, 126, 120);
         }
         $count++;
         if ($count >= $linksLimit) {
             break;
         }
     }
     // main page stuff
     if ($daysLimit > 8) {
         $data = self::featuredArticlesAttrs($popular, wfMessage('populararticles')->text());
         $html .= $this->featuredArticlesRow($data);
         $data = self::featuredArticlesAttrs($randomizer, wfMessage('or_a_random_article')->text());
         $html .= $this->featuredArticlesRow($data);
     }
     $html .= "<div class='clearall'></div>";
     // expires every 5 minutes
     $wgMemc->set($cachekey, $html, 5 * 60);
     return $html;
 }
Пример #12
0
 function getFeaturedArticlesBoxWide($daysLimit = 11, $linksLimit = 4, $isMainPage = true)
 {
     global $wgUser, $wgServer, $wgTitle, $IP, $wgProdHost;
     $sk = $wgUser->getSkin();
     $feeds = FeaturedArticles::getFeaturedArticles($daysLimit);
     $html = '';
     $html .= "<div class='featured_articles_inner' id='featuredArticles'>\n\t\t  <table class='featuredArticle_Table'><tr>";
     $hidden = "<div id='hiddenFA' style='display:none; zoom:1;'><div>\n\t<table class='featuredArticle_Table'><tr>";
     $now = time();
     $popular = Title::makeTitle(NS_SPECIAL, "Popularpages");
     $count = 0;
     foreach ($feeds as $item) {
         $url = $item[0];
         $date = $item[1];
         if ($date > $now) {
             continue;
         }
         $url = str_replace("{$wgServer}/", "", $url);
         if ($wgServer != 'http://www.wikihow.com') {
             $url = str_replace("http://www.wikihow.com/", "", $url);
         }
         $url = str_replace("http://{$wgProdHost}/", "", $url);
         $title = Title::newFromURL(urldecode($url));
         if ($title) {
             if ($count < $linksLimit) {
                 $html .= $this->featuredArticlesLineWide($title);
             } else {
                 $hidden .= $this->featuredArticlesLineWide($title);
             }
             $count++;
         }
         if ($count >= 2 * $linksLimit) {
             break;
         }
         if ($count % 5 == 0) {
             if ($count < $linksLimit) {
                 $html .= "</tr><tr>";
             } else {
                 $hidden .= "</tr><tr>";
             }
         }
     }
     $html .= "</tr></table>";
     $hidden .= "</tr></table></div></div>";
     $html .= '</div></div>';
     return $html;
 }
Пример #13
0
 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>&nbsp;&nbsp;<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>&nbsp;&nbsp;<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>&nbsp;&nbsp;<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>&nbsp;&nbsp;<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>&nbsp;&nbsp;<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>&nbsp;&nbsp;<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>&nbsp;&nbsp;<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>&nbsp;&nbsp;<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;
         }
     }
 }
Пример #14
0
 static function featuredArticles($num)
 {
     $titles = array();
     $fas = FeaturedArticles::getTitles($num);
     foreach ($fas as $fa) {
         $titles[] = $fa['title'];
     }
     return self::formatResults($titles);
 }
Пример #15
0
 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();
 }