/** * addIntroImage * Called from EasyImageUploader and adds image to intro section and updates article **/ function addIntroImage($v) { global $wgOut, $wgRequest, $wgUser; $fname = "IntroImageAdder::addIntroImage"; wfProfileIn($fname); $title = $wgRequest->getVal('iiatitle'); $imgtag = "[[Image:" . $v['imageFilename'] . "|thumb|right|251px]]"; $json = ''; $t = Title::newFromText($title); $r = Revision::newFromTitle($t); $intro = Article::getSection($r->getText(), 0); if (!preg_match('/\\[\\[Image:(.*?)\\]\\]/', $intro)) { $a = new Article($t); //gotta insert the image AFTER any templates //split 'em $parts = preg_split("@(\\{\\{[^}]*\\}\\})@im", $intro, 0, PREG_SPLIT_DELIM_CAPTURE); //iterate through until we hit the first non-template $newintro = ""; $found = false; while (sizeof($parts) > 0) { $x = array_shift($parts); if (trim($x) != '') { if (!preg_match('@^\\{\\{@', $x)) { // we have found a non template $newintro .= $imgtag . $x; $found = true; break; } } // otherwise keep pasting the templates into the new intro $newintro .= $x; } // we may have stuff left over from the parts $newintro .= implode($parts); if (!$found) { // the intro had no template(s) $newintro .= $imgtag; } //$text = $a->replaceSection(0, $newintro); global $wgParser; $oldtext = $r->getText(); $text = $wgParser->replaceSection($oldtext, 0, $newintro); $a->doEdit($text, wfMsg('iia-editsummary'), EDIT_MINOR); wfRunHooks("IntroImageAdderUploadComplete", array($t, $imgtag, $wgUser)); } else { wfDebug("IntroImageAdder - image already exists for article {$title} \n"); } $json['status'] = "SUCCESS"; $json['title'] = urlencode($t->getText()); $json['img'] = urlencode($v['imageFilename']); wfProfileOut($fname); return json_encode($json); }
public static function getArticleSummary(&$article, &$title) { global $wgParser; $summary = Article::getSection($article->getContent(true), 0); // remove templates from intro $summary = preg_replace('@\\{\\{[^}]*\\}\\}@', '', $summary); $summary = preg_replace('@\\[\\[Image:[^\\]]*\\]\\]@', '', $summary); // parse summary from wiki text to html $output = $wgParser->parse($summary, $title, new ParserOptions()); // strip html tags from summary $summary = trim(strip_tags($output->getText())); return $summary; }
function wfSpecialCheckquality($par) { global $wgRequest, $wgSitename, $wgLanguageCode; global $wgDeferredUpdateList, $wgOut, $wgUser; $fname = "wfCheckquality"; $sk = $wgUser->getSkin(); $target = $wgRequest->getVal('target'); if ($target == '') { $wgOut->addHTML(wfMsg('checkquality_notitle')); return; } $t = Title::newFromText($target); $id = $t->getArticleID(); if ($id == 0) { $wgOut->addHTML(wfMsg("checkquality_titlenonexistant")); return; } $dbr = wfGetDB(DB_SLAVE); $related = $dbr->selectField("pagelinks", "count(*)", array('pl_from' => $id), "wfSpecialCheckquality"); $inbound = $dbr->selectField("pagelinks", "count(*)", array('pl_namespace' => $t->getNamespace(), 'pl_title' => $t->getDBKey()), "wfSpecialCheckquality"); // talk page $f = Title::newFromText("Featured", NS_TEMPLATE); $tp = $t->getTalkPage(); $featured = $dbr->selectField("templatelinks", "count(*)", array('tl_from' => $tp->getArticleID(), 'tl_namespace' => 10, 'tl_title' => 'Featured'), "wfSpecialCheckquality"); $fadate = ""; if ($featured > 0) { $rev = Revision::newFromTitle($tp); $text = $rev->getText(); $matches = array(); preg_match('/{{Featured.*}}/', $text, &$matches); $fadate = $matches[0]; $fadate = str_replace("{{Featured|", "", $fadate); $fadate = str_replace("}}", "", $fadate); } $rev = Revision::newFromTitle($t); $section = Article::getSection($rev->getText(), 0); $intro_photo = preg_match('/\\[\\[Image:/', $section); $section = Article::getSection($rev->getText(), 1); $num_steps = preg_match_all('/^#/im', $section, $matches); $num_step_photos = preg_match_all('/\\[\\[Image:/', $section, $matches); $linkshere = Title::newFromText("Whatlinkshere", NS_SPECIAL); $linksherelink = $sk->makeLinkObj($linkshere, $inbound, "target=" . $t->getPrefixedURL()); $articlelink = $sk->makeLinkObj($t, wfMsg('howto', $t->getFullText())); $numvotes = $dbr->selectField("rating", "count(*)", array('rat_page' => $t->getArticleID()), "wfSpecialCheckquality"); $rating = $dbr->selectField("rating", "avg(rat_rating)", array('rat_page' => $t->getArticleID(), 'rat_isdeleted' => 0), "wfSpecialCheckquality"); $rating = number_format($rating * 100, 0, "", ""); $a = new Article(&$t); $pageviews = number_format($a->getCount(), 0, "", ","); $wgOut->addHTML("\n\n<style type='text/css'>\n\n.roundcont {\n\twidth: 450px;\n\tbackground-color: #f90;\n}\n\n.roundcont p {\n\tmargin: 0 10px;\n}\n\n.roundtop { \n\tbackground: url(http://kalsey.com/tools/css/rounded/images/tr.gif) no-repeat top right; \n}\n\n.roundbottom {\n\tbackground: url(http://kalsey.com/tools/css/rounded/images/br.gif) no-repeat top right; \n}\n\nimg.corner {\n width: 15px;\n height: 15px;\n border: none;\n display: block !important;\n}\n</style>\n\t\t\n<div class='roundcont'>\n <div class='roundtop'>\n\t <img src='http://kalsey.com/tools/css/rounded/images/tl.gif' alt='' \n\t width='15' height='15' class='corner' \n\t style='display: none' />\n </div>\n\t<p> {$articlelink}<br/>\n\t<table border=0 cellpadding=5>\n\t\t\t<tr><td><b># related wikihows:</td><td> {$related} <br/></td></tr>\n\t\t\t<tr><td><b># inbound links</td><td> {$linksherelink} <br/></td></tr>\n\t\t\t<tr><td><b>featured? </td><td>1=yes,0=no (optional date): {$featured} ({$fadate}) <br/></td></tr>\n\t\t\t<tr><td><b>Has intro photo? </td><td>{$intro_photo} <br/></td></tr>\n\t\t\t<tr><td><b>Number of steps:</td><td> {$num_steps} <br/></td></tr>\n\t\t\t<tr><td><b>Number of step photos:</td><td> {$num_step_photos} <br/></td></tr>\n\t\t\t<tr><td><b>page views:</td><td> {$pageviews} <br/></td></tr>\n\t\t\t<tr><td><b>accuracy :</td><td> {$rating}% of people found this article accurate (based on {$numvotes} votes) <br/>\t\t\t</td></tr>\n \t</table> \n\t</p>\n <div class='roundbottom'>\n\t <img src='http://kalsey.com/tools/css/rounded/images/bl.gif' alt='' \n\t width='15' height='15' class='corner' \n\t style='display: none' />\n\n </div>\n</div>\n\t\t\thas tips? has warnings? should we include this? <br/> </p>\n\t\t\t"); }
function upload() { $details = null; $this->content = 'error'; $up = new UploadFromFile(); $up->initializeFromRequest($this->wg->request); $permErrors = $up->verifyPermissions($this->wg->user); if ($permErrors !== true) { $this->status = self::UPLOAD_PERMISSION_ERROR; $this->statusMessage = $this->uploadMessage($this->status, null); } else { if (empty($this->wg->EnableUploads)) { // BugId:6122 $this->statusMessage = wfMsg('uploaddisabled'); } else { $details = $up->verifyUpload(); $this->status = is_array($details) ? $details['status'] : UploadBase::UPLOAD_VERIFICATION_ERROR; $this->statusMessage = ''; if ($this->status > 0) { $this->statusMessage = $this->uploadMessage($this->status, $details); } else { $titleText = $this->request->getVal('title'); $sectionNumber = $this->request->getVal('section', 0); $this->status = $up->performUpload('', '', '', $this->wg->user); $mainArticle = new Article(Title::newFromText($titleText)); if ($sectionNumber == 0) { $mainArticle->updateArticle($this->getWikiText($up->getTitle()->getText(), self::LEFT) . $mainArticle->getRawText(), '', false, false); } else { $firstSectionText = $mainArticle->getSection($mainArticle->getRawText(), $sectionNumber); $matches = array(); if (preg_match('/={2,3}[^=]+={2,3}/', $firstSectionText, $matches)) { $firstSectionText = trim(str_replace($matches[0], '', $firstSectionText)); $newSectionText = $mainArticle->replaceSection($sectionNumber, $matches[0] . "\n" . $this->getWikiText($up->getTitle()->getText(), self::LEFT) . $firstSectionText); $mainArticle->updateArticle($newSectionText, '', false, false); } } $this->content = $this->renderImage($up->getTitle()->getText(), self::LEFT); } } } }
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>'); }
$wgUser = User::newFromName("BoldStepFixer"); $fixed = 0; while ($row = $dbr->fetchObject($res)) { $t = Title::makeTitle(NS_MAIN, $row->page_title); if (!$t) { continue; } $r = Revision::newFromTitle($t); if (!$r) { continue; } $fb = "[^a-zA-Z0-9_|\\[\\]]"; $text = $r->getText(); $changed = false; for ($i = 0; $i < 4; $i++) { $section = Article::getSection($text, $i); if (preg_match("@^==[ ]*Steps@", $section)) { $lines = split("\n", $section); foreach ($lines as $line) { if (preg_match("@\\[\\[Image:@", $line)) { continue; } if (!preg_match("@^#@", $line)) { continue; } if (!preg_match("@'''@", $line)) { continue; } $parts = preg_split("@('''|\\.|\\!)@", $line, 0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $newline = ""; $open = false;
$aid = $title->getArticleID(); if ($aid > 0) { $title_text = ""; $topics = array(); //GET ARTICLE $a = getLastPatrolledRevision(&$title); $intro = Article::getSection($a->getContent(true), 0); if (preg_match('/^#REDIRECT \\[\\[(.*?)\\]\\]/', $intro, $matches)) { $title = Title::newFromText($matches[1]); $aid = $title->getArticleID(); if ($aid <= 0) { fwrite(STDERR, "ERROR: article id does not exist url: {$url}\n"); continue; } else { $a = getLastPatrolledRevision(&$title); $intro = Article::getSection($a->getContent(true), 0); } } $intro = ereg_replace("\\{\\{.*\\}\\}", "", $intro); if (in_array($aid, $aid_arr)) { fwrite(STDERR, "ERROR: article id duplicate for id: {$aid} and url: {$url} \n"); continue; } else { $aid_arr[] = $aid; } //GET IDs $yqID = 'whq' . $aid; $yaID = 'wha' . $aid; //GET TITLE $title_text = $title->getPrefixedText(); $prefix_idx = rand(0, count($qPrefix) - 1);
/** * The main function */ function execute($par) { global $wgRequest, $wgUser, $wgOut, $wgImportVideoSources; if ($wgUser->isBlocked()) { $wgOut->blockedPage(); return; } wfLoadExtensionMessages('Importvideo'); if ($wgRequest->getVal('popup') == 'true') { $wgOut->setArticleBodyOnly(true); } $this->setHeaders(); $source = $this->mSource = $wgRequest->getVal('source', 'youtube'); $target = isset($par) ? $par : $wgRequest->getVal('target'); $query = $wgRequest->getVal('q'); $me = Title::makeTitle(NS_SPECIAL, "Importvideo"); $wasnew = $this->getRequest()->getVal('wasnew'); // some sanity checks on the target if ($target && !$wasnew) { $title = Title::newFromURL($target); if (!$title || !$title->exists()) { $wgOut->addHTML("Error: target article does not exist."); return; } else { $article = new Article($title); $article->loadPageData(); if ($article->mIsRedirect) { $wgOut->addHTML("Error: target article is a redirect."); return; } } } $wgOut->addHTML("<div id='importvideo'>"); $wgOut->addHTML("<h2>" . wfMsg('add_a_video') . "</h2>"); # changing target article feature $search = $wgRequest->getVal("dosearch", null); if ($search != null) { $this->doSearch($target, $orderby, $query, $search); return; } $sp = null; switch ($source) { case 'howcast': $sp = new ImportvideoHowcast($source); break; case 'youtube': default: $sp = new ImportvideoYoutube($source); break; } // handle special cases where user is adding a video to a new article or by category if ($wgRequest->getVal('new') || $wgRequest->getVal('wasnew')) { if ($wgRequest->getVal('new')) { $t = $this->getNewArticleWithoutVideo(); $target = $t->getText(); } else { $t = Title::newFromText($target); } $wgRequest->setVal('target', $target); } else { if ($wgRequest->getVal('category') && $target == '') { $t = $this->getTitleFromCategory($wgRequest->getVal('category')); $target = $t->getText(); $wgRequest->setVal('target', $target); } } // construct base url to switch between sources $url = $me->getFullURL() . "?target=" . urlencode($target) . "&q=" . urlencode($query) . $this->getURLExtras() . "&source="; $title = Title::newFromText($target); if (!trim($target)) { $wgOut->addHTML("Error: no target specified."); return; } $target = $title->getText(); //get the steps and intro to show to the user $r = Revision::newFromTitle($title); $text = ""; if ($r) { $text = $r->getText(); } $article = new Article($title); $extra = $article->getSection($text, 0); $steps = ""; for ($i = 1; $i < 3; $i++) { $xx = $article->getSection($text, $i); if (preg_match("/^==[ ]+" . wfMsg('steps') . "/", $xx)) { $steps = $xx; break; } } $extra = preg_replace("/{{[^}]*}}/", "", $extra); $extra = $wgOut->parse($extra); $steps = $wgOut->parse($steps); $cancel = ""; $nextlink = "/Special:Importvideo?new=1&skip={$title->getArticleID()}"; if ($wgRequest->getVal('category')) { $nextlink = "/Special:Importvideo?category=" . urlencode($wgRequest->getVal('category')); } if ($wgRequest->getVal('popup') != 'true') { $wgOut->addHTML("<div class='article_title'>\n\t\t\t\t" . wfMsg('importvideo_article') . "- <a href='{$title->getFullURL()}' target='new'>" . wfMsg('howto', $title->getText()) . "</a>"); $wgOut->addHTML("<spanid='showhide' style='font-size: 80%; text-align:right; font-weight: normal;'>\n\t\t\t\t\t(<a href='{$nextlink}' accesskey='s'>next article</a> |\n\t\t\t\t\t<a href='{$url}&dosearch=1' accesskey='s'>" . wfMsg('importvideo_searchforarticle') . "</a> {$cancel} )\n\t\t\t\t</span>"); if ($wgRequest->getVal('category')) { $wgOut->addHTML("You are adding videos to articles from the \"{$wgRequest->getVal('category')}\" category.\n\t\t\t\t\t(<a href='#'>change</a>)"); } $wgOut->addHTML("</div>"); $wgOut->addHTML("<div class='video_related wh_block'>\n\t\t\t\t\t<h2>Introduction</h2>\n\t\t\t\t\t{$extra}\n\t\t\t\t\t<br clear='all'/>\n\t\t\t\t\t<div id='showhide' style='font-size: 80%; text-align:right;'>\n\t\t\t\t\t\t<span id='showsteps'><a href='#' onclick='javascript:showhidesteps(); return false;'>" . wfMsg('importvideo_showsteps') . "</a></span>\n\t\t\t\t\t\t<span id='hidesteps' style='display: none;'><a href='#' onclick='javascript:showhidesteps(); return false;'>" . wfMsg('importvideo_hidesteps') . "</a></span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div id='stepsarea' style='display: none;'>\n\t\t\t\t\t{$steps}\n\t\t\t\t\t</div>\n\t\t\t\t\t<br clear='all'/>\n\t\t\t\t</div>\n\t\t\t"); } $wgOut->addHTML("<script type='text/javascript' src='" . wfGetPad('/extensions/min/f/extensions/wikihow/video/importvideo.js?rev=') . WH_SITEREV . "'> </script>\t"); $wgOut->addHTML("<link rel='stylesheet' type='text/css' href='" . wfGetPad('/extensions/min/f/extensions/wikihow/video/importvideo.css?rev=') . WH_SITEREV . "' />"); $wgOut->addHTML("<script type='text/javascript'>\n\t\t\tvar isPopUp = " . ($wgRequest->getVal('popup') ? "true" : "false") . ";\n\t\t\t</script>"); if (!$wgRequest->wasPosted()) { $wgOut->addHTML(wfMsgWikiHtml('add_video_info')); # HEADER for import page $url = $me->getFullURL() . "?target=" . urlencode($target) . "&q=" . urlencode($query) . $this->getURLExtras() . "&source="; // refine form $orderby = $wgRequest->getVal('orderby', 'relevance'); $wgOut->addHTML($this->refineForm($me, $target, $wgRequest->getVal('popup') == 'true', $query, $orderby)); // sources tab $wgOut->addHTML("<ul id='importvideo_search_tabs'>"); foreach ($wgImportVideoSources as $s) { $selected = $s == $source ? ' class="iv_selected"' : ''; $wgOut->addHTML("<li{$selected}><a href='{$url}{$s}'>" . wfMsg('importvideo_source_' . $s) . "</a></li>"); } $wgOut->addHTML("</ul>"); $vt = Title::makeTitle(NS_VIDEO, $target); if ($vt->getArticleID() > 0 && $wgRequest->getVal('popup') != 'true') { $wgOut->addHTML("<div class='wh_block importvideo_main'>" . wfMsgExt('importvideo_videoexists', 'parse', $vt->getFullText()) . "</div>"); } } //special class just for pop-ups if ($wgRequest->getVal('popup')) { $pop_class = 'importvideo_pop'; } $wgOut->addHTML("<div class='wh_block importvideo_main {$pop_class}'>"); $sp->execute($par); $wgOut->addHTML("</div>"); //Bebeth: took out extra closing div $wgOut->addHTML("</div>"); //Scott: put a brand new extra closing div in (take that, Bebeth!) }
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(); }
function getIntroText(&$t) { $r = Revision::newFromTitle($t); $intro = Article::getSection($r->getText(), 0); return Wikitext::flatten($intro); }
$res = $dbr->select('page', array('page_title', 'page_namespace'), array('page_is_redirect' => 0, 'page_namespace=0'), "findInlineImages", array("ORDER BY" => "page_counter desc", "LIMIT" => "1000")); echo "<Results>\n"; echo "<AuthorInfo description='How-to subscribed links' author='wikiHow'/>\n"; while ($row = $dbr->fetchObject($res)) { $t = Title::makeTitle($row->page_namespace, $row->page_title); if (!$t) { continue; } if ($t->getText() == "Main Page" || $t->getText() == "Spam Blacklist" || $t->getText() == "Categories") { continue; } $wgTitle = $t; // just cuz // get the summary $r = Revision::newFromTitle($t); $summary = Article::getSection($r->getText(), 0); $summary = strip_tags($wgOut->parse($summary)); // trip out all MW and HTML tags $summary = ereg_replace("<.*>", "", $summary); $summary = ereg_replace("\\[\\[.*\\]\\]", "", $summary); $summary = ereg_replace("\\{\\{.*\\}\\}", "", $summary); // split up the first setence of the summary into 3 chunks of less than $maxTextLength chars $t_array = array('', '', ''); $s_index = 0; //if (strpos($summary, ".") !== false) // $summary = substr($summary, 0, strpos($summary, ".")); $s_array = split(" ", $summary); for ($i = 0; $i < sizeof($t_array) && $s_index < sizeof($s_array); $i++) { while (strlen($t_array[$i] . " " . FeedItem::xmlEncode($s_array[$s_index])) < $maxTextLength && $s_index < sizeof($s_array)) { $t_array[$i] .= " " . FeedItem::xmlEncode($s_array[$s_index]); $s_index++;
camp_html_display_error(getGS('Invalid input: $1', Input::GetErrorString()), $_SERVER['REQUEST_URI']); exit; } // Fetch article $articleObj = new Article($f_language_selected, $f_article_number); if (!$articleObj->exists()) { camp_html_display_error(getGS('No such article.')); exit; } // detect if blogger can edit $userIsBlogger = false; $blogService = \Zend_Registry::get('container')->getService('blog'); if ($blogService->isBlogger($g_user)) { $userIsBlogger = true; $userSection = $blogService->getSection($g_user); if (empty($userSection) || $userSection->getSectionId() != $articleObj->getSection()->getSectionId()) { camp_html_display_error(getGS("You're not allowed to edit article.")); exit; } } $articleData = $articleObj->getArticleData(); // Get article type fields. $dbColumns = $articleData->getUserDefinedColumns(FALSE, TRUE); $articleType = new ArticleType($articleObj->getType()); $articleImages = ArticleImage::GetImagesByArticleNumber($f_article_number); $lockUserObj = new User($articleObj->getLockedByUser()); $articleCreator = new User($articleObj->getCreatorId()); $articleEvents = ArticlePublish::GetArticleEvents($f_article_number, $f_language_selected, TRUE); $articleTopics = ArticleTopic::GetArticleTopics($f_article_number); $articleFiles = ArticleAttachment::GetAttachmentsByArticleNumber($f_article_number, $f_language_selected); $articleLanguages = $articleObj->getLanguages();
function execute($par) { global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc, $wgDBname, $wgScriptPath; global $wgRequest, $wgSitename, $wgLanguageCode; global $wgScript; $fname = "wfSpecialEmailLink"; if ($wgRequest->getVal('fromajax')) { $wgOut->setArticleBodyOnly(true); } $this->setHeaders(); $me = Title::makeTitle(NS_SPECIAL, "EmailLink"); $action = $me->getFullURL(); $fc = new FancyCaptcha(); $pass_captcha = true; $name = $from = $r1 = $r2 = $r3 = $m = ""; if ($wgRequest->wasPosted()) { $pass_captcha = $fc->passCaptcha(); $email = $wgRequest->getVal("email"); $name = $wgRequest->getVal("name"); $recipient1 = $wgRequest->getVal('recipient1'); $recipient2 = $wgRequest->getVal('recipient2'); $recipient3 = $wgRequest->getVal('recipient3'); if (preg_match("@kittens683\\@aol.com@", $recipient1) || preg_match("@kittens683\\@aol.com@", $recipient2) || preg_match("@kittens683\\@aol.com@", $recipient3)) { return; } $message = $wgRequest->getVal('message'); } if (!$wgRequest->wasPosted() || !$pass_captcha) { if ($wgUser->getID() > 0 && !$wgUser->canSendEmail()) { $userEmail = $wgUser->getEmail(); // If there is no verification time stamp and no email on record, show initial message to have a user input a valid email address if (empty($userEmail)) { wfDebug("User can't send.\n"); $wgOut->errorpage("mailnologin", "mailnologintext"); } else { // When user does have an email on record, but has not verified it yet wfDebug("User can't send without verification.\n"); $wgOut->errorpage("mailnologin", "mailnotverified"); } return; } $titleKey = isset($par) ? $par : $wgRequest->getVal('target'); if ($titleKey == "") { $wgOut->addHTML("<br/></br><font color=red>" . wfMsg('error-no-title') . "</font>"); return; } $titleObj = Title::newFromURL($titleKey); if (!$titleObj) { $titleObj = Title::newFromURL(urldecode($titleKey)); } if (!$titleObj || $titleObj->getArticleID() < 0) { $wgOut->addHTML("<br/></br><font color=red>" . wfMsg('error-article-not-found') . "</font>"); return; } else { $titleKey = $titleObj->getDBKey(); } $articleObj = new Article($titleObj); $subject = $titleObj->getText(); $titleText = $titleObj->getText(); if (WikihowArticleEditor::articleIsWikiHow($articleObj)) { $subject = wfMsg('howto', $subject); $titleText = wfMsg('howto', $titleText); } $subject = wfMsg('wikihow-article-subject', $subject); if ($titleObj->getText() == wfMsg('mainpage')) { $subject = wfMsg('wikihow-article-subject-main-page'); } // add the form HTML $article_title = wfMsg('article') . ":"; if ($titleObj->getNamespace() == NS_ARTICLE_REQUEST) { $wgOut->addHTML("<br/><br/>" . wfMsg('know-someone-answer-topic-request')); $article_title = wfMsg('topic-requested') . ":"; } if ($titleObj->getNamespace() != NS_MAIN && $titleObj->getNamespace() != NS_ARTICLE_REQUEST && $titleObj->getNamespace() != NS_PROJECT) { $wgOut->errorPage('emaillink', 'emaillink_invalidpage'); return; } if ($titleObj->getText() == "Books For Africa") { $message = wfMsg('friend-sends-article-email-africa-body'); } $titleKey = urlencode($titleKey); $token = $this->getToken1(); $wgOut->addHTML("\n<link type='text/css' rel='stylesheet' href='" . wfGetPad('/extensions/wikihow/common/jquery-ui-themes/jquery-ui.css?rev=' . WH_SITEREV) . "' />\n<form id=\"emaillink\" method=\"post\" action=\"{$action}\">\n<input type=\"hidden\" name=\"target\" value=\"{$titleKey}\">\n<input type=\"hidden\" name=\"token\" value=\"{$token}\">\n<table border=\"0\">\n<tr>\n<td valign=\"top\" colspan=\"1\" class='mw-label'>{$article_title}</td>\n<td valign=\"top\" colspan=\"2\">{$titleText}</td>\n</tr>\n"); if ($wgUser->getID() <= 0) { $wgOut->addHTML("\n<tr>\n<td valign=\"top\" colspan=\"1\" class='mw-label'>" . wfMsg('your-name') . ":</td>\n<td valign=\"top\" colspan=\"2\"><input type=text size=\"40\" name=\"name\" value=\"{$name}\" class='input_med'></td>\n</tr>\n<tr>\n<td valign=\"top\" colspan=\"1\" class='mw-label'>" . wfMsg('your-email') . ":</td>\n<td valign=\"top\" colspan=\"2\"><input type=text size=\"40\" name=\"email\" value=\"{$email}\" class='input_med'></td>\n</tr>"); } $wgOut->addHTML("\n<tr>\n<td valign=\"top\" width=\"300px\" colspan=\"1\" rowspan='3' class='mw-label'>" . wfMsg('recipient-emails') . ":</td>\n<td valign=\"top\" colspan=\"2\"><input type=text size=\"40\" name=\"recipient1\" value=\"{$recipient1}\" class='input_med'></td>\n</tr>\n<tr>\n<td valign=\"top\" colspan=\"2\"><input type=text size=\"40\" name=\"recipient2\" value=\"{$recipient2}\" class='input_med'></td>\n</tr>\n<tr>\n<td valign=\"top\" colspan=\"2\"><input type=text size=\"40\" name=\"recipient3\" value=\"{$recipient3}\" class='input_med'></td>\n</tr>\n<!--<tr>\n<td valign=\"top\" colspan=\"1\">" . wfMsg('emailsubject') . ":</td>\n<td valign=\"top\" colspan=\"2\"><input type=text size=\"40\" name=\"subject\" value=\"{$subject}\" class='input_med'></td>\n</tr>-->\n<tr>\n<td colspan=\"1\" valign=\"top\" class='mw-label'>" . wfMsg('emailmessage') . ":</td>\n<td colspan=\"2\"><TEXTAREA rows=\"5\" cols=\"55\" name=\"message\">{$message}</TEXTAREA></td>\n</tr>\n<tr>\n<TD> </TD>\n<TD colspan=\"2\"><br/>\n" . wfMsgWikiHTML('emaillink_captcha') . "\n" . ($pass_captcha ? "" : "<br><br/><font color='red'>Sorry, that phrase was incorrect, try again.</font><br/><br/>") . "\n" . $fc->getForm('') . "\n</TD>\n</tr>\n<tr>\n<TD> </TD>\n<TD colspan=\"2\"><br/>\n<input type='submit' name=\"wpEmaiLinkSubmit\" value=\"" . wfMsg('submit') . "\" class=\"button primary\" />\n</td>\n</tr>\n<tr>\n<TD colspan=\"3\">\n<br/><br/>\n" . wfMsg('share-message-three-friends') . "\n</TD>\n</TR>\n\n"); // do this if the user isn't logged in $wgOut->addHTML("</table> </form>"); } else { if ($wgUser->pingLimiter('emailfriend')) { $wgOut->rateLimited(); wfProfileOut("{$fname}-checks"); wfProfileOut($fname); return false; } $usertoken = $wgRequest->getVal('token'); $token1 = $this->getToken1(); $token2 = $this->getToken2(); if ($usertoken != $token1 && $usertoken != $token2) { $this->reject(); echo "token {$usertoken} {$token1} {$token2}\n"; exit; return; } // check referrer $good_referer = Title::makeTitle(NS_SPECIAL, "EmailLink")->getFullURL(); $referer = $_SERVER["HTTP_REFERER"]; if (strpos($refer, $good_referer) != 0) { $this->reject(); echo "referrer bad\n"; exit; } // this is a post, accept the POST data and create the Request article $recipient1 = $_POST['recipient1']; $recipient2 = $_POST['recipient2']; $recipient3 = $_POST['recipient3']; $titleKey = $_POST['target']; $message = $_POST['message']; if ($titleKey == "Books-For-Africa") { $titleKey = "wikiHow:" . $titleKey; } $titleKey = urldecode($titleKey); $titleObj = Title::newFromDBKey($titleKey); if ($titleObj->getArticleID() <= 0) { $this->reject(); echo "no article id\n"; exit; } $dbkey = $titleObj->getDBKey(); $articleObj = new Article($titleObj); $subject = $titleObj->getText(); $how_to = $subject; if (WikihowArticleEditor::articleIsWikiHow($articleObj)) { $subject = wfMsg("howto", $subject); } $how_to = $subject; if ($titleObj->getNamespace() == NS_ARTICLE_REQUEST) { $subject = wfMsg('subject-requested-howto') . ": " . wfMsg("howto", $subject); } else { if ($titleObj->getNamespace() == NS_PROJECT) { $subject = wfMsg('friend-sends-article-email-africa-subject'); } else { $subject = wfMsg('wikihow-article-subject', $subject); } } if ($titleObj->getNamespace() != NS_MAIN && $titleObj->getNamespace() != NS_ARTICLE_REQUEST && $titleObj->getNamespace() != NS_PROJECT) { $wgOut->errorPage('emaillink', 'emaillink_invalidpage'); return; } // for the body of the email $titleText = $titleObj->getText(); if ($titleText != wfMsg('mainpage')) { $summary = Article::getSection($articleObj->getContent(true), 0); // trip out all MW and HTML tags $summary = ereg_replace("<.*>", "", $summary); $summary = ereg_replace("\\[\\[.*\\]\\]", "", $summary); $summary = ereg_replace("\\{\\{.*\\}\\}", "", $summary); } $url = $titleObj->getFullURL(); $from_name = ""; $validEmail = ""; if ($wgUser->getID() > 0) { $from_name = $wgUser->getName(); $real_name = $wgUser->getRealName(); if ($real_name != "") { $from_name = $real_name; } $email = $wgUser->getEmail(); if ($email != "") { $validEmail = $email; $from_name .= "<{$email}>"; } else { $from_name .= "<*****@*****.**>"; } } else { $email = $wgRequest->getVal("email"); $name = $wgRequest->getVal("name"); if ($email == "") { $email = "*****@*****.**"; } else { $validEmail = $email; } $from_name = "{$name} <{$email}>"; } if (strpos($email, "\n") !== false || strpos($recipient1, "\n") !== false || strpos($recipient2, "\n") !== false || strpos($recipient3, "\n") !== false || strpos($title, "\n") !== false) { echo "reciep\n"; exit; $this->reject(); return; } $r_array = array(); $num_recipients = 0; if ($recipient1 != "") { $num_recipients++; $x = split(";", $recipient1); $r_array[] = $x[0]; } if ($recipient2 != "") { $num_recipients++; $x = split(";", $recipient2); $r_array[] = $x[0]; } if ($recipient3 != "") { $num_recipients++; $x = split(";", $recipient3); $r_array[] = $x[0]; } if ($titleObj->getNamespace() == NS_PROJECT) { $r_array[] = '*****@*****.**'; } if ($validEmail != "" && !in_array($validEmail, $r_array)) { $num_recipients++; $r_array[] = $validEmail; } if ($titleObj->getNamespace() == NS_ARTICLE_REQUEST) { $body = "{$message}\n\n----------------\n\n\t" . wfMsg('article-request-email', $how_to, "http://www.wikihow.com/index.php?title2={$dbkey}&action=easy&requested={$dbkey}", "http://www.wikihow.com/Request:{$dbkey}", "http://www.wikihow.com/" . wfMsg('writers-guide-url'), "http://www.wikihow.com/" . wfMsg('about-wikihow-url') . ""); } else { if ($titleObj->getText() == wfMsg('mainpage')) { $body = "{$message}\n\n----------------\n\n\t" . wfMsg('friend-sends-article-email-main-page') . "\n\n\t"; } else { if ($titleObj->getNamespace() == NS_PROJECT) { $body = "{$message}"; } else { $body = "{$message}\n\n----------------\n\n" . wfMsg('friend-sends-article-email', $how_to, $summary, $url) . "\n\n\t"; } } } $from = new MailAddress($email); foreach ($r_array as $address) { $address = preg_replace("@,.*@", "", $address); $to = new MailAddress($address); $sbody = $body; if ($address == $validEmail) { $sbody = wfMsg('copy-email-from-yourself') . "\n\n" . $sbody; } if (!userMailer($to, $from, $subject, $sbody, false)) { //echo "got an en error\n"; } } SiteStatsUpdate::addLinksEmailed($num_recipients); $this->thanks(); } }
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? | </td><td >' . "<fb:share-button class='url' href='{$title->getFullURL()}'/> </td></tr></table>"; break; } $html .= '<fb:if-is-own-profile> <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; }
private static function getAbstract($title) { $abstract = ''; $ami = new ArticleMetaInfo($title); if ($ami) { // meta description $abstract = $ami->getFacebookDescription(); } if (!$abstract) { $rev = Revision::newFromTitle($title); if ($rev) { $wikitext = $rev->getText(); $abstract = Article::getSection($wikitext, 0); } } return $abstract; }
public function addRelated($t1, $t2, $summary = "Adding related wikihow from NAB", $top = false, $linkedtext = null) { #echo "putting a link in '{$t1->getText()}' to '{$t2->getText()}'\n\n"; if ($linkedtext) { $link = "*[[{$t2->getText()}|" . wfMsg('howto', $linkedtext) . "]]"; } else { $link = "*[[{$t2->getText()}|" . wfMsg('howto', $t2->getText()) . "]]"; } $article = new Article($t1); $wikitext = $article->getContent(true); for ($i = 0; $i < 30; $i++) { $s = $article->getSection($wikitext, $i); if (preg_match("@^==[ ]*" . wfMsg('relatedwikihows') . "@m", $s)) { if (preg_match("@{$t2->getText()}@m", $s)) { $found = true; break; } if ($top) { $s = preg_replace("@==\n@", "==\n{$link}\n", $s); } else { $s .= "\n{$link}\n"; } $wikitext = $article->replaceSection($i, $s); $found = true; break; } else { if (preg_match("@^==[ ]*(" . wfMsg('sources') . ")@m", $s)) { // we have gone too far $s = "\n== " . wfMsg('relatedwikihows') . " ==\n{$link}\n\n" . $s; $wikitext = $article->replaceSection($i, $s); $found = true; break; } } } if (!$found) { $wikitext .= "\n\n== " . wfMsg('relatedwikihows') . " ==\n{$link}\n"; } if (!$article->doEdit($wikitext, $summary)) { echo "Didn't save\n"; } }
function execute($par) { global $wgRequest, $wgUser, $wgOut; $wgOut->setArticleBodyOnly(true); $wgOut->clearHTML(); $target = isset($par) ? $par : $wgRequest->getVal('target'); $title = Title::newFromUrl($target); if (!$title || !$title->exists()) { $wgOut->addHTML('Title no longer exists: ' . $target); return; } $article = new Article($title); $text = $article->getContent(true); $snippet = $article->getSection($text, 0) . "\n" . $article->getSection($text, 1); $html = $wgOut->parse($snippet); $wgOut->addHTML($html); }
function execute($par) { global $wgOut, $wgRequest, $wgUser; if (!$wgRequest->wasPosted()) { return; } $wgOut->disable(); $friends = split(",", $wgRequest->getVal('friends')); $target = Title::newFromURL($wgRequest->getVal('target')); if (!$target) { return; } $rev = Revision::newFromTitle($target); if (!$rev) { return; } $summary = Article::getSection($rev->getText(), 0); $summary = ereg_replace("<.*>", "", $summary); $summary = ereg_replace("\\[\\[.*\\]\\]", "", $summary); $summary = ereg_replace("\\{\\{.*\\}\\}", "", $summary); $body = wfMsg('createpage_email_body', $target->getFullText(), $summary, $target->getFullURL()); $subject = wfMsg('createpage_email_subject', $target->getFullText()); $count = 0; $from = $wgUser->getID() == 0 || $wgUser->getEmail() == '' ? "*****@*****.**" : $wgUser->getEmail(); $from = new MailAddress($from); foreach ($friends as $f) { $to = new MailAddress($f); UserMailer::send($to, $from, $subject, $body); $count++; if ($count == 3) { break; } } }
/** * hasProblems * (returns TRUE if there's a problem) * - Checks to see if there's an {{nfd}} template * - Makes sure an article has been NABbed * - Makes sure last edit has been patrolled **/ function hasProblems($t, $dbr) { $r = Revision::newFromTitle($t); if ($r) { $intro = Article::getSection($r->getText(), 0); //check for {{nfd}} template if (preg_match('/{{nfd/', $intro)) { return true; } //is it NABbed? $is_nabbed = Newarticleboost::isNABbed($dbr, $t->getArticleId()); if (!$is_nabbed) { return true; } //last edit patrolled? if (!GoodRevision::patrolledGood($t)) { return true; } } //all clear? return false; }
function execute($par) { global $wgRequest, $wgUser, $wgOut, $wgEmbedVideoServiceList; /* disabled this check, per Eliz and Jack. added noindex meta tag. if ( !in_array( 'importxml', $wgUser->getRights() ) ) { $wgOut->showErrorPage( 'nosuchspecialpage', 'nospecialpagetext' ); return; } */ if (!$wgRequest->wasPosted()) { $wgOut->addMeta('robots', 'noindex'); $wgOut->addHTML(<<<END \t\t\t<form action='/Special:ExportXML' method='post' enctype="multipart/form-data" > \t\t\tURLS to export: <textarea name='xml'></textarea> \t\t\tWOI category mappings: <input type="file" name="uploadFile"> <br/> \t\t\t<input type='submit'> \t\t\t</form> END ); return; } $dbr = wfGetDB(DB_SLAVE); $urls = split("\n", $wgRequest->getVal('xml')); $valid_sections = array("steps", "tips", "warnings", "things", "sources", "videos"); $dom = new DOMDocument("1.0"); $root = $dom->createElement("wikihowmedia"); $dom->appendChild($root); // did we get a WOI category mapping sent to us? $woi_map = array(); foreach ($_FILES as $f) { if (trim($f['tmp_name']) == "") { continue; } $text = preg_replace('@\\r@', "\n", file_get_contents($f['tmp_name'])); $lines = split("\n", $text); foreach ($lines as $l) { $tokens = split(",", $l); $url = array_shift($tokens); $key = urldecode(preg_replace("@http://www.wikihow.com/@im", "", $url)); if (preg_match("@index.php?@", $url)) { $parts = parse_url($url); $query = $parts['query']; $params = array(); $tx = split("&", $query); foreach ($tx as $v) { $xx = split("=", $v); if ($xx[0] == "title") { $key = urldecode($xx[1]); break; } } } if ($key == "") { continue; } $woi_map[$key] = $tokens; $urls[] = $url; } } foreach ($urls as $url) { $origUrl = $url; if (trim($url) == "") { continue; } $url = trim($url); $url = str_replace("http://www.wikihow.com/", "", $url); $url = preg_replace('@^\\s*index\\.php\\?@', '', $url); $kv = split('&', $url); $urlParams = array(); # decode URLs that look like this: # http://www.wikihow.com/index.php?title=Sing&oldid=4956082 foreach ($kv as $pair) { $a = split('=', $pair); if (count($a) < 2) { $urlParams['title'] = $a[0]; } else { $urlParams[$a[0]] = $a[1]; } } $t = Title::newFromDBKey(urldecode($urlParams['title'])); if (!$t) { echo "Can't get title from {$origUrl}\n"; continue; } $revid = !empty($urlParams['oldid']) ? $urlParams['oldid'] : ''; $r = Revision::newFromTitle($t, $revid); if (!$r) { echo "Can't get revision from {$origUrl}\n"; continue; } $text = $r->getText(); $a = $dom->createElement("article"); // title $x = $dom->createElement("title"); // make sure the title is in the form "How to x y z" $title = $t->getText(); if (!preg_match('@' . wfMsg('howto', '') . '@', $title)) { $title = wfMsg('howto', $title); } $x->appendChild($dom->createTextNode($title)); $a->appendChild($x); // intro $content = $dom->createElement("content"); $intro = Article::getSection($text, 0); $i = $dom->createElement("introduction"); self::handleImages($intro, $dom, $i); $intro = self::cleanupText($intro); $n = $dom->createElement("text"); $n->appendChild($dom->createTextNode($intro)); $i->appendChild($n); $content->appendChild($i); # woi tags and categories if (isset($woi_map[$t->getDBKey()])) { $params = $woi_map[$t->getDBKey()]; //tags $tags = array(); for ($i = 2; $i < 4; $i++) { if ($params[$i] != "None") { $tags[] = $params[$i]; } } if (sizeof($tags) > 0) { $xx = $dom->createElement("tags"); $xx->appendChild($dom->createTextNode(implode(",", $tags))); $a->appendChild($xx); } $yy = $dom->createElement("categories"); if ($params[0] != "None") { $zz = $dom->createElement("category"); $zz->setAttribute("type", "mainmenu"); $zz->appendChild($dom->createTextNode($params[0])); $yy->appendChild($zz); } if ($params[1] != "None") { $zz = $dom->createElement("category"); $zz->setAttribute("type", "featured"); $zz->appendChild($dom->createTextNode($params[1])); $yy->appendChild($zz); } $a->appendChild($yy); } $parts = preg_split("@(^==[^=]*==)@im", $text, 0, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $sources_element = null; while (sizeof($parts) > 0) { $x = trim(strtolower(str_replace('==', '', array_shift($parts)))); // title $x = preg_replace("@[^a-z]@", "", $x); if ($x == "thingsyoullneed") { $x = "things"; } if ($x == "sourcesandcitations") { $x = "sources"; } if ($x == "video") { $x = "videos"; } if (!in_array($x, $valid_sections)) { continue; } $section = $dom->createElement($x); if ($x == "sources") { $sources_element = $section; } // process subsections $beef = array_shift($parts); if ($x == "steps") { if (preg_match("@(^===[^=]*===)@im", $beef)) { $subs = preg_split("@(^===[^=]*===)@im", $beef, 0, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); while (sizeof($subs) > 0) { $y = array_shift($subs); $sub = null; if (preg_match("@(^===[^=]*===)@", $y)) { // this is a subsection $sub = $dom->createElement("subsection"); $x = str_replace("=", "", $y); $tnode = $dom->createElement("title"); $ttext = self::cleanupText($x); $tnode->appendChild($dom->createTextNode($ttext)); $sub->appendChild($tnode); $body = array_shift($subs); self::processListSection($dom, $sub, $body); $section->appendChild($sub); } else { // this is not a subsection, it could be a set of steps preceeding a subsection $body = $y; self::processListSection($dom, $section, $y); } } } else { self::processListSection($dom, $section, $beef); } } else { if ($x == "videos") { // {{Video:...}} embeds can point to other videos, so // we need a loop here $title = $t->getText(); while (true) { $vid_t = Title::makeTitle(NS_VIDEO, $title); $vid_r = Revision::newFromTitle($vid_t); if ($vid_r) { $vid_text = $vid_r->getText(); $tokens = split("\\|", $vid_text); if (preg_match('@^{{video:([^|}]*)@i', $tokens[0], $m)) { $title = $m[1]; if (!empty($title)) { continue; } } else { $provider = $tokens[1]; $id = $tokens[2]; // special hack for wonderhowto videos that // are actually youtube videos if ($provider == 'wonderhowto' && preg_match('@http://www.youtube.com/v/([^&/">]*)@', $vid_text, $m)) { $provider = 'youtube'; $id = $m[1]; } $found = false; foreach ($wgEmbedVideoServiceList as $service => $params) { if ($provider == $service) { $url = str_replace("\$1", $id, $params['url']); if ($url != "") { $vid = $dom->createElement("video"); $vid->appendChild($dom->createTextNode($url)); $section->appendChild($vid); $found = true; break; } } } if (!$found) { $text = htmlspecialchars_decode($vid_text); preg_match("@src&61;\"[^\"]*@", $text, $matches); if (sizeof($matches[0]) > 0) { $url = preg_replace("@.*\"@", "", $matches[0]); $vid = $dom->createElement("video"); $vid->appendChild($dom->createTextNode($url)); $section->appendChild($vid); } } } } break; } } else { self::processListSection($dom, $section, $beef, false, preg_replace("@s\$@", "", $x)); } } // append the section $content->appendChild($section); } // process references preg_match_all("@<ref[^>]*>.*</ref>@imU", $text, $matches); foreach ($matches[0] as $m) { if (!$sources_element) { $sources_element = $dom->createElement("sources"); } $m = preg_replace("@<[/]*ref[^>]*>@", "", $m); $e = $dom->createElement("source"); $tx = $dom->createElement("text"); $m = self::convertLinks($m); $m = self::cleanUpText($m, true); $tx->appendChild($dom->createTextNode($m)); $e->appendChild($tx); $sources_element->appendChild($e); $content->appendChild($sources_element); } $a->appendChild($content); //attribution $attr = $dom->createElement("attribution"); $num = $dom->createElement("numeditors"); $users = array(); $res = $dbr->select("revision", array("distinct(rev_user_text)"), array("rev_page" => $t->getArticleID(), "rev_user != 0"), "generate_xml.php", array("ORDER BY" => "rev_timestamp DESC")); $num->appendChild($dom->createTextNode($dbr->numRows($res))); $attr->appendChild($num); while ($row = $dbr->fetchObject($res)) { $u = User::newFromName($row->rev_user_text); $u->load(); $name = $u->getRealName() != "" ? $u->getRealName() : $u->getName(); $users[] = $name; } $names = $dom->createElement("names"); $names_text = $dom->createElement("text"); $names_text->appendChild($dom->createTextNode(implode(", ", $users))); $names->appendChild($names_text); $attr->appendChild($names); $a->appendChild($attr); $root->appendChild($a); } $wgOut->disable(); header("Content-type: text/xml;"); echo $dom->saveXML(); }
/** * Process item * @param Article $article * @return array */ public function processItem(Article $article) { global $g_user, $Campsite; $articleLinkParams = '?f_publication_id=' . $article->getPublicationId() . '&f_issue_number=' . $article->getIssueNumber() . '&f_section_number=' . $article->getSectionNumber() . '&f_article_number=' . $article->getArticleNumber() . '&f_language_id=' . $article->getLanguageId() . '&f_language_selected=' . $article->getLanguageId(); $articleLinkParamsTranslate = $articleLinkParams . '&f_action=translate&f_action_workflow=' . $article->getWorkflowStatus() . '&f_article_code=' . $article->getArticleNumber() . '_' . $article->getLanguageId(); $articleLink = $Campsite['WEBSITE_URL'] . '/admin/articles/edit.php' . $articleLinkParams; $previewLink = $Campsite['WEBSITE_URL'] . '/admin/articles/preview.php' . $articleLinkParams; $htmlPreviewLink = '<a href="' . $previewLink . '" target="_blank" title="' . getGS('Preview') . '">' . getGS('Preview') . '</a>'; $translateLink = $Campsite['WEBSITE_URL'] . '/admin/articles/translate.php' . $articleLinkParamsTranslate; $htmlTranslateLink = '<a href="' . $translateLink . '" target="_blank" title="' . getGS('Translate') . '">' . getGS('Translate') . '</a>'; $lockInfo = ''; $lockHighlight = false; $timeDiff = camp_time_diff_str($article->getLockTime()); if ($article->isLocked() && $timeDiff['days'] <= 0) { $lockUser = new User($article->getLockedByUser()); if ($timeDiff['hours'] > 0) { $lockInfo = getGS('The article has been locked by $1 ($2) $3 hour(s) and $4 minute(s) ago.', htmlspecialchars($lockUser->getRealName()), htmlspecialchars($lockUser->getUserName()), $timeDiff['hours'], $timeDiff['minutes']); } else { $lockInfo = getGS('The article has been locked by $1 ($2) $3 minute(s) ago.', htmlspecialchars($lockUser->getRealName()), htmlspecialchars($lockUser->getUserName()), $timeDiff['minutes']); } if ($article->getLockedByUser() != $g_user->getUserId()) { $lockHighlight = true; } } $tmpUser = new User($article->getCreatorId()); $tmpArticleType = new ArticleType($article->getType()); $tmpAuthor = new Author(); $articleAuthors = ArticleAuthor::GetAuthorsByArticle($article->getArticleNumber(), $article->getLanguageId()); foreach ((array) $articleAuthors as $author) { if (strtolower($author->getAuthorType()->getName()) == 'author') { $tmpAuthor = $author; break; } } if (!$tmpAuthor->exists() && isset($articleAuthors[0])) { $tmpAuthor = $articleAuthors[0]; } $onFrontPage = $article->onFrontPage() ? getGS('Yes') : getGS('No'); $onSectionPage = $article->onSectionPage() ? getGS('Yes') : getGS('No'); $imagesNo = (int) ArticleImage::GetImagesByArticleNumber($article->getArticleNumber(), true); $topicsNo = (int) ArticleTopic::GetArticleTopics($article->getArticleNumber(), true); $commentsNo = ''; if ($article->commentsEnabled()) { global $controller; $repositoryComments = $controller->getHelper('entity')->getRepository('Newscoop\\Entity\\Comment'); $filter = array('thread' => $article->getArticleNumber(), 'language' => $article->getLanguageId()); $params = array('sFilter' => $filter); $commentsNo = $repositoryComments->getCount($params); } else { $commentsNo = 'No'; } // get language code $language = new Language($article->getLanguageId()); return array($article->getArticleNumber(), $article->getLanguageId(), $article->getOrder(), sprintf('%s <a href="%s" title="%s %s">%s</a>', $article->isLocked() ? '<span class="ui-icon ui-icon-locked' . (!$lockHighlight ? ' current-user' : '') . '" title="' . $lockInfo . '"></span>' : '', $articleLink, getGS('Edit'), htmlspecialchars($article->getName() . " ({$article->getLanguageName()})"), htmlspecialchars($article->getName() . (empty($_REQUEST['language']) ? " ({$language->getCode()})" : ''))), htmlspecialchars($article->getSection()->getName()), $article->getWebcode(), htmlspecialchars($tmpArticleType->getDisplayName()), htmlspecialchars($tmpUser->getRealName()), htmlspecialchars($tmpAuthor->getName()), $article->getWorkflowStatus(), $onFrontPage, $onSectionPage, $imagesNo, $topicsNo, $commentsNo, (int) $article->getReads(), Geo_Map::GetArticleMapId($article) != NULL ? getGS('Yes') : getGS('No'), (int) sizeof(Geo_Map::GetLocationsByArticle($article)), $article->getCreationDate(), $article->getPublishDate(), $article->getLastModified(), $htmlPreviewLink, $htmlTranslateLink); }
public function getVideo() { wfProfileIn(__METHOD__); $pic = null; $r = $this->r; if ($r) { $intro = Article::getSection($r->getText(), 0); $pic = QCRuleIntroImage::getPicture($intro); if ($pic) { $pic = $pic->getThumbnail(290, 194); $pic->width = floor($pic->getWidth() * 0.75); $pic->height = floor($pic->getHeight() * 0.75); } } wfProfileOut(__METHOD__); return $pic; }
function getVideoSection($text) { $index = 0; $vidsection = null; while ($section = Article::getSection($text, $index)) { if (preg_match("@^==\\s*" . wfMsg('video') . "@", $section)) { $vidsection = $section; $vidname = preg_replace("@^==\\s" . wfMsg('video') . "\\s==\\s{{([^}]*)\\}}@", "\$1", $section); break; } $index++; } //format the video name if (!empty($vidname)) { $parts = split('\\|', $vidname); $vidname = $parts[0]; } if (!empty($vidsection)) { $vidresult = array(); $vidresult['vidtitle'] = self::getVideoTitle($vidname); $vidresult['vidsection'] = trim($vidsection); } return $vidresult; }
$dbr = wfGetDB(DB_SLAVE); $sql = "SELECT page_title, page_id FROM page WHERE page_is_redirect=0 AND page_namespace=" . NS_MAIN; $res = $dbr->query($sql, __FILE__); $fp = fopen('short-intros.csv', 'w'); if (!$fp) { die("could not open file for write\n"); } fputcsv($fp, array('page_id', 'URL', 'has_template', 'intro_length', 'intro')); foreach ($res as $row) { $title = Title::newFromDBkey($row->page_title); if (!$title) { print "Can't make title out of {$row->page_title}\n"; continue; } $rev = Revision::newFromTitle($title); $wikitext = $rev->getText(); $intro = Article::getSection($wikitext, 0); $flat = Wikitext::flatten($intro); $flat = trim($flat); $len = mb_strlen($flat); if ($len < 50) { // check whether it has either the {{intro or {{introduction template $hasTemplate = strpos(strtolower($intro), '{{intro') !== false; $fields = array($row->page_id, 'http://www.wikihow.com/' . $title->getPartialURL(), $hasTemplate ? 'y' : 'n', $len, $flat); fputcsv($fp, $fields); if (@++$i % 100 == 0) { print "article {$i}\n"; } } } fclose($fp);
function printDDGdata(&$titles) { global $baseMemory; foreach ($titles as $title) { $rev = Revision::newFromTitle($title); if (!$rev) { continue; } $full_url = $title->getFullURL(); $wikitext = $rev->getText(); // pull out intro $intro = Article::getSection($wikitext, 0); // try to generate the abstract using a couple different ways $abstract = synthesizeSummary($wikitext, 3, $full_url); if (!$abstract) { // meta description $ami = new ArticleMetaInfo($title); if ($ami) { $abstract = $ami->getDescription(); } } if (!$abstract) { $abstract = $intro; } // intro image $photo = ""; preg_match_all("@\\[\\[Image:[^\\]]*\\]\\]@", $wikitext, $matches); if (sizeof($matches) > 0) { $img = preg_replace("@.*Image:@", "", $matches[0][0]); $img = ucfirst(preg_replace("@[\\|].*\\]\\]@", "", $img)); $img = Title::makeTitle(NS_IMAGE, $img); $file = wfFindFile($img); if ($file) { $photo = wfGetPad($file->getURL()); } } $images = $photo ? '[[Image:' . $photo . ']]' : ''; // category info $cats = $title->getParentCategories(); $cat_strs = array(); $bad_cats = array('Featured Articles'); foreach ($cats as $cat => $a) { if ($cat) { $cat_title = Title::newFromURL($cat); if ($cat_title && $cat_title->getNamespace() == NS_CATEGORY) { $cat_text = $cat_title->getText(); if (!in_array($cat_text, $bad_cats)) { $cat_strs[] = $cat_text; } } } } $categories = implode("\\\\n", $cat_strs); $regular_title = $title->getText(); $howto_title = wfMsg('howto', $regular_title); print "{$howto_title}\tA\t\t\t{$categories}\t\t\t\t\t\t{$images}\t{$abstract}\t{$full_url}\n"; //if (@$index++ % 1000 == 0) { // print "#" . date("r") . " - " . (memory_get_usage() - $baseMemory) . "\n"; //} } }
function execute($par) { global $wgRequest, $wgSitename, $wgLanguageCode; global $wgDeferredUpdateList, $wgOut, $wgUser; $fname = "wfArticlestats"; $sk = $wgUser->getSkin(); $this->setHeaders(); $target = $par != '' ? $par : $wgRequest->getVal('target'); if ($target == '') { $wgOut->addHTML(wfMsg('articlestats_notitle')); return; } $t = Title::newFromText($target); $id = $t->getArticleID(); if ($id == 0) { $wgOut->addHTML(wfMsg("checkquality_titlenonexistant")); return; } $dbr =& wfGetDB(DB_SLAVE); $related = $dbr->selectField("pagelinks", "count(*)", array('pl_from' => $id), "wfSpecialArticlestats"); $inbound = $dbr->selectField(array("pagelinks", "page"), "count(*)", array('pl_namespace' => $t->getNamespace(), 'pl_title' => $t->getDBKey(), 'page_id=pl_from', 'page_namespace=0'), "wfSpecialArticlestats"); $sources = $dbr->selectField(array("externallinks"), "count(*)", array('el_from' => $t->getArticleID()), "wfSpecialArticlestats"); $langlinks = $dbr->selectField(array("langlinks"), "count(*)", array('ll_from' => $t->getArticleID()), "wfSpecialArticlestats"); // talk page $f = Title::newFromText("Featured", NS_TEMPLATE); $tp = $t->getTalkPage(); $featured = $dbr->selectField("templatelinks", "count(*)", array('tl_from' => $tp->getArticleID(), 'tl_namespace' => 10, 'tl_title' => 'Featured'), "wfSpecialArticlestats"); $fadate = ""; if ($featured > 0) { $rev = Revision::newFromTitle($tp); $text = $rev->getText(); $matches = array(); preg_match('/{{Featured.*}}/', $text, $matches); $fadate = $matches[0]; $fadate = str_replace("{{Featured|", "", $fadate); $fadate = str_replace("}}", "", $fadate); $fadate = "({$fadate})"; $featured = wfMsg('articlestats_yes'); } else { $featured = wfMsg('articlestats_no'); } $rev = Revision::newFromTitle($t); $section = Article::getSection($rev->getText(), 0); $intro_photo = preg_match('/\\[\\[Image:/', $section) == 1 ? wfMsg('articlestats_yes') : wfMsg('articlestats_no'); $section = Article::getSection($rev->getText(), 1); preg_match("/==[ ]*" . wfMsg('steps') . "/", $section, $matches, PREG_OFFSET_CAPTURE); if (sizeof($matches) == 0 || $matches[0][1] != 0) { $section = Article::getSection($rev->getText(), 2); } $num_steps = preg_match_all('/^#/im', $section, $matches); $num_step_photos = preg_match_all('/\\[\\[Image:/', $section, $matches); $has_stepbystep_photos = wfMsg('articlestats_no'); if ($num_steps > 0) { $has_stepbystep_photos = $num_step_photos / $num_steps > 0.5 ? wfMsg('articlestats_yes') : wfMsg('articlestats_no'); } $linkshere = Title::newFromText("Whatlinkshere", NS_SPECIAL); $linksherelink = $sk->makeLinkObj($linkshere, $inbound, "target=" . $t->getPrefixedURL()); $articlelink = $sk->makeLinkObj($t, wfMsg('howto', $t->getFullText())); $numvotes = $dbr->selectField("rating", "count(*)", array('rat_page' => $t->getArticleID(), "rat_isdeleted=0"), "wfSpecialArticlestats"); $rating = $dbr->selectField("rating", "avg(rat_rating)", array('rat_page' => $t->getArticleID(), 'rat_isdeleted' => 0), "wfSpecialArticlestats"); $unique = $dbr->selectField("rating", "count(distinct(rat_user_text))", array('rat_page' => $t->getArticleID(), "rat_isdeleted=0"), "wfSpecialArticlestats"); $rating = number_format($rating * 100, 0, "", ""); $a = new Article($t); $count = $a->getCount(); $pageviews = number_format($count, 0, "", ","); $accuracy = '<img src="/skins/WikiHow/images/grey_ball.png"> ' . wfMsg('articlestats_notenoughvotes'); if ($numvotes >= 5) { if ($rating > 70) { $accuracy = '<img src="/skins/WikiHow/images/green_ball.png">'; } else { if ($rating > 40) { $accuracy = '<img src="/skins/WikiHow/images/yellow_ball.png">'; } else { $accuracy = '<img src="/skins/WikiHow/images/red_ball.png">'; } } $accuracy .= " " . wfMsg('articlestats_rating', $rating, $numvotes, $unique); } if ($index > 10 || $index == 0) { $index = wfMsg('articlestats_notintopten', wfMsg('howto', urlencode($t->getText()))); $index .= "<br/>" . wfMsg('articlestats_lastchecked', substr($max, 0, 10)); } else { if ($index < 0) { $index = wfMsg('articlestats_notcheckedyet', wfMsg('howto', urlencode($t->getText()))); } else { $index = wfMsg('articlestats_indexrank', wfMsg('howto', urlencode($t->getText())), $index); $index .= wfMsg('articlestats_lastchecked', substr($max, 0, 10)); } } $cl = SpecialPage::getTitleFor('Clearratings', $t->getText()); $wgOut->addHTML("\n\t\n\t\t<p> {$articlelink}<br/>\n\t\t<table border=0 cellpadding=5>\n\t\t\t\t<tr><td width='350px;' valign='middle' > \n\t\t\t\t\t\t" . wfMsgExt('articlestats_accuracy', 'parseinline', $cl->getFullText()) . " </td><td valign='middle'> {$accuracy}<br/>\t\t\t</td></tr>\n\t\t\t\t<tr><td>" . wfMsgExt('articlestats_hasphotoinintro', 'parseinline') . "</td><td>{$intro_photo} </td></tr>\n\t\t\t\t<tr><td>" . wfMsgExt('articlestats_stepbystepphotos', 'parseinline') . "</td><td> {$has_stepbystep_photos} </td></tr>\n\t\t\t\t<tr><td>" . wfMsgExt('articlestats_isfeatured', 'parseinline') . "</td><td> {$featured} {$fadate} </td></tr>\n\t\t\t\t<tr><td>" . wfMsgExt('articlestats_numinboundlinks', 'parseinline') . "</td><td> {$linksherelink}</td></tr>\n\t\t\t\t<tr><td>" . wfMsgExt('articlestats_outboundlinks', 'parseinline') . "</td><td> {$related} </td></tr>\n\t\t\t\t<tr><td>" . wfMsgExt('articlestats_sources', 'parseinline') . "</td><td> {$sources}</td></tr>\n\t\t\t\t<tr><td>" . wfMsgExt('articlestats_langlinks', 'parseinline') . "</td><td> {$langlinks}</td></tr>\n\t \t</table> \n\t\t</p> " . wfMsgExt('articlestats_footer', 'parseinline') . "\n\t\t\t\t"); }
/** * Remove all of the sections that have no content * */ function removeEmptySections($wikitext) { $newtext = Article::getSection($wikitext, 0) . "\n\n"; $index = 1; while ($section = Article::getSection($wikitext, $index)) { $n = trim(preg_replace("@^==.*==@", "", $section)); wfDebug("SECTION: old {$section} new {$section}\n"); if ($n != "") { $newtext .= $section . "\n\n"; } $index++; } return trim($newtext); }
/** * Retrieve the current version of the page or section being edited... * @param EditPage $editPage * @param string $section * @return string * @access private */ function loadText($editPage, $section) { $rev = Revision::newFromTitle($editPage->mTitle); if (is_null($rev)) { return ""; } else { $text = $rev->getText(); if ($section != '') { return Article::getSection($text, $section); } else { return $text; } } }
private function loadFromText($text) { global $wgContLang; $this->mLoadText = $text; // extract the category if there is one // TODO: make this an array $this->mCategories = array(); // just extract 1 category for now //while ($index !== false && $index >= 0) { // fix for multiple categories preg_match_all("/\\[\\[" . $wgContLang->getNSText(NS_CATEGORY) . ":[^\\]]*\\]\\]/im", $text, $matches); foreach ($matches[0] as $cat) { $cat = str_replace("[[" . $wgContLang->getNSText(NS_CATEGORY) . ":", "", $cat); $cat = trim(str_replace("]]", "", $cat)); $this->mCategories[] = $cat; $text = str_replace("[[" . $wgContLang->getNSText(NS_CATEGORY) . ":" . $cat . "]]", "", $text); } // extract interlanguage links $matches = array(); if (preg_match_all('/\\[\\[[a-z][a-z]:.*\\]\\]/', $text, $matches)) { foreach ($matches[0] as $match) { $text = str_replace($match, "", $text); $this->mLangLinks .= "\n" . $match; } } $this->mLangLinks = trim($this->mLangLinks); // get the number of sections $sectionCount = self::getSectionCount($text); $found_summary = false; for ($i = 0; $i < $sectionCount; $i++) { $section = Article::getSection($text, $i); $title = self::getSectionTitle($section); $section = trim(preg_replace("@^==.*==@", "", $section)); $title = strtolower($title); $title = trim($title); if ($title == "" && !$found_summary) { $this->section_array["summary"] = $section; $this->section_ids["summary"] = $i; $found_summary = true; } else { $orig = $title; $counter = 0; while (isset($section_array[$title])) { $title = $orig + $counter; } $title = trim($title); $this->section_array[$title] = $section; $this->section_ids[$title] = $i; } } // set the steps // AA $index = strpos($text, "== Steps =="); // AA if (!$index) { if ($this->hasSection("steps") == false) { $this->mIsWikiHow = false; return; } $this->mSummary = $this->getSection("summary"); $this->mSteps = $this->getSection(wfMsg('steps')); // TODO: get we get tips and warnings from getSection? $this->mIsNew = false; }