本文整理汇总了PHP中Article::getSection方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::getSection方法的具体用法?PHP Article::getSection怎么用?PHP Article::getSection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Article
的用法示例。
在下文中一共展示了Article::getSection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addIntroImage
/**
* 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);
}
示例2: getArticleSummary
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;
}
示例3: wfSpecialCheckquality
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");
}
示例4: upload
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);
}
}
}
}
示例5: wfSpecialListFeed
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>');
}
示例6: while
$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;
示例7: array
$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);
示例8: execute
/**
* 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'));
//.........这里部分代码省略.........
示例9: execute
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++;
//.........这里部分代码省略.........
示例10: getIntroText
function getIntroText(&$t)
{
$r = Revision::newFromTitle($t);
$intro = Article::getSection($r->getText(), 0);
return Wikitext::flatten($intro);
}
示例11: array
$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++;
示例12: Article
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();
示例13: execute
//.........这里部分代码省略.........
$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 .= "<do_not_reply@wikihow.com>";
}
} else {
$email = $wgRequest->getVal("email");
$name = $wgRequest->getVal("name");
if ($email == "") {
$email = "do_not_reply@wikihow.com";
} 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) {
示例14: getFacebookHTML
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;
}
示例15: getAbstract
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;
}