当前位置: 首页>>代码示例>>PHP>>正文


PHP Title::newFromDBKey方法代码示例

本文整理汇总了PHP中Title::newFromDBKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::newFromDBKey方法的具体用法?PHP Title::newFromDBKey怎么用?PHP Title::newFromDBKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Title的用法示例。


在下文中一共展示了Title::newFromDBKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: listArticles

 static function listArticles($includeDatesAndFullURLs, $touchedSince)
 {
     $PAGE_SIZE = 2000;
     $dbr = wfGetDB(DB_SLAVE);
     for ($page = 0;; $page++) {
         $offset = $PAGE_SIZE * $page;
         if ($touchedSince) {
             $sql = "SELECT page_id, page_title, page_touched FROM page, recentchanges WHERE page_id = rc_cur_id AND page_namespace = 0 AND page_is_redirect = 0 AND rc_timestamp >= '{$touchedSince}' AND rc_minor = 0 GROUP BY page_id ORDER BY page_touched DESC LIMIT {$offset},{$PAGE_SIZE}";
         } else {
             $sql = "SELECT page_id, page_title, page_touched FROM page WHERE page_namespace = " . NS_MAIN . " AND page_is_redirect = 0 ORDER BY page_touched DESC LIMIT {$offset},{$PAGE_SIZE}";
         }
         $res = $dbr->query($sql, __FILE__);
         if (!$res->numRows()) {
             break;
         }
         foreach ($res as $row) {
             $title = Title::newFromDBKey($row->page_title);
             if (!$title) {
                 continue;
             }
             if (class_exists('RobotPolicy')) {
                 $indexed = RobotPolicy::isIndexable($title);
                 if (!$indexed) {
                     continue;
                 }
             }
             if ($includeDatesAndFullURLs) {
                 $line = $title->getFullUrl() . ' lastmod=' . self::iso8601_date($row->page_touched);
             } else {
                 $line = $row->page_id . ' ' . $title->getDBkey();
             }
             print "{$line}\n";
         }
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:35,代码来源:generateUrls.php

示例2: listArticles

 static function listArticles()
 {
     $PAGE_SIZE = 2000;
     $dbr = wfGetDB(DB_SLAVE);
     $titles = array();
     for ($page = 0;; $page++) {
         $offset = $PAGE_SIZE * $page;
         $sql = "SELECT page_id, page_title, page_touched FROM page WHERE page_namespace = " . NS_MAIN . " AND page_is_redirect = 0 ORDER BY page_touched DESC LIMIT {$offset},{$PAGE_SIZE}";
         $res = $dbr->query($sql, __FILE__);
         if (!$res->numRows()) {
             break;
         }
         foreach ($res as $row) {
             $title = Title::newFromDBKey($row->page_title);
             if (!$title) {
                 continue;
             }
             $text = $title->getText();
             $crc = crc32($text);
             $titles[] = array('uri' => $title->getFullUrl(), 'percent' => $crc % 100);
         }
     }
     usort($titles, function ($i, $j) {
         if ($i['percent'] == $j['percent']) {
             return strcasecmp($i['uri'], $j['uri']);
         } elseif ($i['percent'] < $j['percent']) {
             return -1;
         } else {
             return 1;
         }
     });
     foreach ($titles as $title) {
         print $title['uri'] . "\n";
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:35,代码来源:listArticlesByRolloutOrder.php

示例3: execute

 function execute($par)
 {
     global $wgRequest, $wgOut, $wgUser;
     $target = isset($par) ? $par : $wgRequest->getVal('target');
     $createdate = $wgRequest->getVal('createdate');
     if (!in_array('sysop', $wgUser->getGroups())) {
         $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     // get the averages
     $dbr = wfGetDB(DB_SLAVE);
     $row = $dbr->selectRow('google_indexed', array('avg(gi_indexed) as A', 'count(*) as C'), array('gi_times_checked > 0'));
     $wgOut->addHTML("Number of pages checked: {$row->C} <br/>Average of those indexed: " . number_format($row->A * 100, 2) . "%<br/>");
     $left = $dbr->selectField('google_indexed', array('count(*) as C'), array('gi_times_checked' => 0));
     $wgOut->addHTML("Pages which have not been checked: " . number_format($left, 0, "", ",") . "<br/><br/>");
     // do we have a target ?
     if ($createdate && $target) {
         $sql = "select page_title, gl_err, gl_page, gl_pos, substr(gi_page_created, 1, 8) as createdate\n                    from google_indexed_log left join google_indexed on gi_page=gl_page left join page on page_id=gl_page\n\t\t\t\t\twhere substr(gi_page_created, 1, 8)='{$createdate}' and substr(gl_checked, 1, 8) = '{$target}';";
         $res = $dbr->query($sql);
         $f = preg_replace("@([0-9]{4})([0-9]{2})([0-9]{2})@", "\$1-\$2-\$3", $target);
         $c = preg_replace("@([0-9]{4})([0-9]{2})([0-9]{2})@", "\$1-\$2-\$3", $createdate);
         $wgOut->addHTML("<h2>Detailed report for the {$f} check for pages created on {$c}</h2>\n\t\t\t\t\t<table width='80%' align='center'>\n\t\t\t\t\t<tr><td>Article</td><td>Indexed?</td><td>Error?</td><td>Check</td></tr>\n\t\t\t\t");
         while ($row = $dbr->fetchObject($res)) {
             $t = Title::newFromDBKey($row->page_title);
             $query = $t->getText() . " site:wikihow.com";
             $url = "http://www.google.com/search?q=" . urlencode($query) . "&num=100";
             $wgOut->addHTML("<tr><td><a href='{$t->getFullURL()}'>{$t->getText()}</td><td>{$row->gl_pos}</td><td>{$row->gl_err}</td><td><a href='{$url}' target='new'>Link</a></td></tr>");
         }
         $wgOut->addHTML("</table>");
     } else {
         if ($target) {
             $sql = "select substr(gi_page_created, 1, 8) as D, count(*) as C, avg(gl_pos)  as A\n                    from google_indexed_log left join google_indexed on gi_page=gl_page                     \n\t\t\t\t\twhere gl_err = 0 group by D order by D desc;";
             $f = preg_replace("@([0-9]{4})([0-9]{2})([0-9]{2})@", "\$1-\$2-\$3", $target);
             $wgOut->addHTML("<h2>Report for the {$f} check</h2>\n\t\t\t\t\t<table width='80%' align='center'><tr><td>Page creation date</td><td># of pages checked</td><td>Average indexed</td></tr>");
             $res = $dbr->query($sql);
             while ($row = $dbr->fetchObject($res)) {
                 $avg = number_format($row->A * 100, 2);
                 $count = number_format($row->C, 0, "", ",");
                 $f = preg_replace("@([0-9]{4})([0-9]{2})([0-9]{2})@", "\$1-\$2-\$3", $row->D);
                 $wgOut->addHTML("<tr><td><a href='/Special:CheckG/{$target}?createdate={$row->D}'>{$f}</a></td><td>{$count}</td><td>{$avg}%</td></tr>");
             }
             $wgOut->addHTML("</table>");
             $errs = $dbr->selectField("google_indexed_log", array("count(*)"), array("gl_checked like '{$target}%'", "gl_err" => 1));
             $wgOut->addHTML("<br/><br/>Number of errors occurred in this check: {$errs}<br/>");
         }
     }
     // list the individual reports we ran
     $wgOut->addHTML("<br/><br/><h2>Individual reports</h2><ul>");
     $sql = "select substr(gl_checked, 1, 8) as D from google_indexed_log group by D order by D desc;";
     $res = $dbr->query($sql);
     while ($row = $dbr->fetchObject($res)) {
         $f = preg_replace("@([0-9]{4})([0-9]{2})([0-9]{2})@", "\$1-\$2-\$3", $row->D);
         if ($target == $row->D) {
             $wgOut->addHTML("<li>{$f} (you are looking at it)</li>\n");
         } else {
             $wgOut->addHTML("<li><a href='/Special:CheckG/{$row->D}'>{$f}</a></li>\n");
         }
     }
     $wgOut->addHTML("</ul>");
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:60,代码来源:CheckG.body.php

示例4: execute

 /**
  * Executes special page rendering and data processing
  *
  * @param $sub Mixed: MediaWiki supplied sub-page path
  * @throws PermissionsError
  */
 public function execute($sub)
 {
     $out = $this->getOutput();
     $user = $this->getUser();
     $request = $this->getRequest();
     // Begin output
     $this->setHeaders();
     // Make sure the user is logged in
     if (!$user->isLoggedIn()) {
         throw new PermissionsError('read');
     }
     // Handle discarding
     $draft = Draft::newFromID($request->getIntOrNull('discard'));
     if ($draft->exists()) {
         // Discard draft
         $draft->discard();
         // Redirect to the article editor or view if returnto was set
         $section = $request->getIntOrNull('section');
         $urlSection = $section !== null ? "&section={$section}" : '';
         switch ($request->getText('returnto')) {
             case 'edit':
                 $title = Title::newFromDBKey($draft->getTitle());
                 $out->redirect(wfExpandURL($title->getEditURL() . $urlSection));
                 break;
             case 'view':
                 $title = Title::newFromDBKey($draft->getTitle());
                 $out->redirect(wfExpandURL($title->getFullURL() . $urlSection));
                 break;
         }
     }
     // Show list of drafts, or a message that there are none
     if (Drafts::display() == 0) {
         $out->addWikiMsg('drafts-view-nonesaved');
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:41,代码来源:SpecialDrafts.php

示例5: newSearchKeyRow

function newSearchKeyRow($dbr, $row)
{
    $t = Title::newFromDBKey($row->page_title);
    if (!$t) {
        print "Got null title for {$row->page_title}\n";
        return null;
    }
    $search_key = generateSearchKey($t->getText());
    $featured = intval($row->tl_from != null);
    return array('tsk_title' => $row->page_title, 'tsk_namespace' => NS_MAIN, 'tsk_key' => $search_key, 'tsk_wasfeatured' => $featured);
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:11,代码来源:rebuildTitleSearchKeys.php

示例6: fnWatchHeldPage

function fnWatchHeldPage($user)
{
    global $wgOut, $wgCookiePrefix, $wgCookieDomain, $wgCookieSecure;
    $watch_page = isset($_COOKIE["{$wgCookiePrefix}wsWatchHold"]) ? $_COOKIE["{$wgCookiePrefix}wsWatchHold"] : '';
    //user had clicked to watch page
    if (isset($watch_page) && $watch_page != "") {
        $watched_title = Title::newFromDBKey($watch_page);
        $user->addWatch($watched_title);
        setCookie("{$wgCookiePrefix}wsWatchHold", '', time() - 86400, '/', $wgCookieDomain, $wgCookieSecure);
        $wgOut->redirect($watched_title->getFullURL());
    }
}
开发者ID:yusufchang,项目名称:app,代码行数:12,代码来源:Answers.php

示例7: renderFanBoxTag

 /**
  * On preg_replace_callback
  * Found a match of [[Fan:]], so get parameters and construct <fan> hook
  *
  * @param $matches Array
  * @return String: HTML
  */
 public static function renderFanBoxTag($matches)
 {
     $name = $matches[2];
     $params = explode('|', $name);
     $fan_name = $params[0];
     $fan_name = Title::newFromDBKey($fan_name);
     if (!is_object($fan_name)) {
         return '';
     }
     $fan = FanBox::newFromName($fan_name->getText());
     if ($fan->exists()) {
         $output = "<fan name=\"{$fan->getName()}\"></fan>";
         return $output;
     }
     return $matches[0];
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:23,代码来源:FanBoxHooks.php

示例8: wfSpamDiffLink

function wfSpamDiffLink( $title ) {
	global $wgUser, $wgRequest, $wgSpamBlacklistArticle;
	$sk = $wgUser->getSkin();
	$sb = Title::newFromDBKey( $wgSpamBlacklistArticle );
	if ( !$sb->userCan( 'edit' ) ) {
		return '';
	}
	$link = '[' . $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'SpamDiffTool' ),
		wfMsg( 'spamdifftool_spam_link_text' ),
		'target=' . $title->getPrefixedURL().
		'&oldid2=' . $wgRequest->getVal( 'oldid' ) .
		'&rcid='. $wgRequest->getVal( 'rcid' ) .
		'&diff2='. $wgRequest->getVal( 'diff' )  .
		'&returnto=' . urlencode( $_SERVER['QUERY_STRING'] )
		) .
		']';

	return $link;
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:19,代码来源:SpamDiffTool.php

示例9: wfSpecialRevisionReel

function wfSpecialRevisionReel($par)
{
    global $wgOut, $wgParser, $wgRequest, $wgLang, $wgUser;
    $fname = "wfRevisionReel";
    if ($wgUser->getId() == 0) {
        $wgOut->showErrorPage('revisionreel', 'revisionreel_loggedin');
        return;
    }
    if ($wgRequest->getVal('rev', null)) {
        $wgOut->setArticleBodyOnly(true);
        $r = Revision::newFromId($wgRequest->getVal('rev'));
        $title = Title::newFromDBKey($wgRequest->getVal('target'));
        $output = $wgParser->parse($r->getText(), $title, new ParserOptions());
        $wgOut->addHTML($output->getText());
        return;
    }
    // landing page
    if ($wgRequest->getVal('target', null)) {
        $title = Title::newFromDBKey($wgRequest->getVal('target'));
        if ($title->getText() == wfMsg('mainpage')) {
            $wgOut->setPageTitle('Now Playing: ' . wfMsg('mainpage'));
        } else {
            $wgOut->setPageTitle('Now Playing: ' . wfMsg('howto', $title->getText()));
        }
        $dbr =& wfGetDB(DB_SLAVE);
        $res = $dbr->select('revision', array('rev_id', 'rev_timestamp'), array('rev_page=' . $title->getArticleID()), array('ORDER BY' => 'rev_id'));
        $revs = array();
        $rev_timestamps = array();
        while ($row = $dbr->fetchObject($res)) {
            $revs[] = $row->rev_id;
            $rev_timestamps[] = "'" . $wgLang->timeanddate(wfTimestamp(TS_MW, $row->rev_timestamp), true) . "'";
            //$rev_timestamps[] = "'" .  wfTimestamp( TS_MW, $row->rev_timestamp ) . "'";
        }
        $dbr->freeResult($res);
        $revisions = implode(',', $revs);
        $timestamps = implode(',', $rev_timestamps);
        $size = sizeof($revs);
        $wgOut->addHTML("\n\t\n<script type='text/javascript'>\n\n\t\tvar index = 0;\n\t\tvar stop = 0;\n\t\tvar size = {$size};\n\t\tvar revisions = new Array({$revisions});\n\t\tvar timestamps = new Array({$timestamps});\n\t\tvar requester = null;\n\t\tfunction showRevision() {\n\t\t\tvar box = document.getElementById('output_html');\n\t\t\tif ( requester.readyState == 4) {\n        \t\tif ( requester.status == 200) {\n\t\t\t\t\tbox.innerHTML = requester.responseText;\n\t\t\t\t\trevision_date = document.getElementById('revision_date');\n\t\t\t\t\trevision_date.innerHTML = timestamps[index] + ' Revision #' + (index + 1) + ' of ' + size;\n\t\t\t\t\tindex++;\n\t\t\t\t\tif (index != size)\n\t\t\t\t\t\tsetTimeout(\"showReel()\", 3000);\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\t\n\t\tfunction showReel() {\n\t\t\tif (stop == 1) return;\n    \t\ttry {\n        \t\trequester = new XMLHttpRequest();\n    \t\t} catch (error) {\n        \t\ttry {\n          \t \t\t requester = new ActiveXObject('Microsoft.XMLHTTP');\n        \t\t} catch (error) {\n\t\t\t\t\talert(error);\n           \t \t\treturn false;\n        \t\t}\n\t\t\t}\n\t\t\turl = location.href + '&rev=' + revisions[index];\n\t\t\trequester.onreadystatechange = showRevision;\n\t\t\trequester.open('GET', url);\n           \trequester.send(null);\n\t\t}\t\n\t\tsetTimeout(\"showReel()\", 1000);\n</script>\n\t\t<div style='border: 1px solid #ccc; padding: 5px;'>\n\t\t\t<input type='button' value='Stop!' onclick='stop = 1; this.value=\"Stopped.\";'>\n\t\t\t<input type='button' value='Go back 5' onclick='if (index > 5) index =- 5; else index = 0;'>\n\t\t\t<input type='button' value='Go forward 5' onclick='index += 5'>\n<span id='revision_date' style='margin-left:20px; font-weight: bold;'> </span>\n\t\t</div>\n\n\t\t\t<br/>\n\t\t\t<div id='output_html' style='margin-top: 20px;'>\n\t\t\t\tGenerating slideshow....\n\t\t\t</div>\n\t\t");
        return;
    }
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:41,代码来源:RevisionReel.php

示例10: execute

 /**
  * Executes special page rendering and data processing
  *
  * @param $sub Mixed: MediaWiki supplied sub-page path
  */
 public function execute($sub)
 {
     global $wgRequest, $wgOut, $wgUser;
     // Begin output
     $this->setHeaders();
     // Make sure the user is logged in
     if (!$wgUser->isLoggedIn()) {
         // If not, let them know they need to
         $wgOut->loginToUse();
         // Continue
         return true;
     }
     // Handle discarding
     $draft = Draft::newFromID($wgRequest->getIntOrNull('discard'));
     if ($draft->exists()) {
         // Discard draft
         $draft->discard();
         // Redirect to the article editor or view if returnto was set
         $section = $wgRequest->getIntOrNull('section');
         $urlSection = $section !== null ? "&section={$section}" : '';
         switch ($wgRequest->getText('returnto')) {
             case 'edit':
                 $title = Title::newFromDBKey($draft->getTitle());
                 $wgOut->redirect(wfExpandURL($title->getEditURL() . $urlSection));
                 break;
             case 'view':
                 $title = Title::newFromDBKey($draft->getTitle());
                 $wgOut->redirect(wfExpandURL($title->getFullURL() . $urlSection));
                 break;
         }
     }
     // Show list of drafts, or a message that there are none
     if (Drafts::display() == 0) {
         $wgOut->addHTML(wfMsgHTML('drafts-view-nonesaved'));
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:41,代码来源:Drafts.pages.php

示例11: 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>');
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:36,代码来源:ListFeed.php

示例12: execute

	function execute( $par ) {
		global $wgUser, $wgOut, $wgLang, $wgMemc, $wgDBname;
		global $wgRequest, $wgSitename, $wgLanguageCode;
		global $wgFilterCallback, $wgWhitelistEdit;

		//echo "topic: " . $wgRequest->getVal("topic_name") . "<br />";
		//echo "title: " . $wgRequest->getVal("title") . "<br />";
		//echo "comment: " . $wgRequest->getVal("comment_text") . "<br />";
		//echo "new_topic id " . $wgRequest->getVal("new_topic") . "<br />";

		if ( wfReadOnly() ) {
			$wgOut->readOnlyPage();
			return;
		}

		$t = Title::newFromDBKey( $wgRequest->getVal( 'target' ) );

		if ( $t == null ) {
			$wgOut->showErrorPage( 'postcomment', 'postcomment_invalidrequest' );
			return;
		}

		$errors = $t->getUserPermissionsErrors( 'edit', $wgUser );
		if ( count( $errors ) ) {
			$wgOut->showPermissionsErrorPage( $errors, 'edit' );
			return;
		}

		if ( $wgUser->pingLimiter() ) {
			$wgOut->rateLimited();
			return;
		}

		$article = new Article( $t );
		$update = $article->exists();

		$comment = $wgRequest->getVal( 'comment_text' );
		$topic = $wgRequest->getVal( 'topic_name' );

		if ( trim( $comment ) == '' ) {
			$wgOut->showErrorPage( 'postcomment', 'postcomment_nopostingtoadd' );
			return;
		}

		$user = $wgUser->getName();
		$real_name = $wgUser->getRealName();
		if ( $real_name == '' ) {
			$real_name = $user;
		}
		$dateStr = $wgLang->timeanddate( wfTimestampNow() );

		$formattedComment = "
	<div id=\"discussion_entry\"><table width=\"100%\">
		<tr><td width=\"50%\" valign=\"top\" class=\"discussion_entry_user\">" .
			wfMsgExt( 'postcomment-userwrote', array( 'parsemag' ), $user, $real_name ) . "
</td><td align=\"right\" width=\"50%\" class=\"discussion_entry_date\">" . wfMsg( 'postcomment_on', $dateStr ) . "<br />
	</td></tr><tr>
<td colspan=2 class=\"discussion_entry_comment\">
	$comment</td></tr>
	<tr><td colspan=\"2\" class=\"discussion_entry_date\" padding=5>[[User_talk:$user#post|" . wfMsg('postcomment_replyto', $real_name) . "]]</td></tr>
	</table></div>
";

		$text = '';

		if ( $update ) {
			$r = Revision::newFromTitle( $t );
			$text = $r->getText();
		}

		$text .= "\n\n$formattedComment\n\n";

		$tmp = "";
		if ( $wgFilterCallback && $wgFilterCallback( $t, $text, $tmp) ) {
			# Error messages or other handling should be performed by the filter function
			return;
		}

		$article->doEdit( $text, '' );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:80,代码来源:Postcomment.php

示例13: execute


//.........这里部分代码省略.........
         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);
开发者ID:ErdemA,项目名称:wikihow,代码行数:67,代码来源:EmailLink.body.php

示例14: writeOutput

 function writeOutput($par)
 {
     global $wgLang, $wgMemc, $wgDBname, $wgUser;
     global $wgSitename, $wgLanguageCode;
     global $wgFeedClasses, $wgFilterCallback, $wgWhitelistEdit, $wgParser;
     $this->getOutput()->setRobotpolicy("noindex,nofollow");
     $target = !empty($par) ? $par : $this->getRequest()->getVal("target");
     $t = Title::newFromDBKey($target);
     $update = true;
     if (!$t || !$t->userCan('edit')) {
         return;
     }
     if (!$this->getUser()->isAllowed('edit')) {
         return;
     }
     $article = new Article($t);
     $user = $this->getUser()->getName();
     $real_name = User::whoIsReal($this->getUser()->getID());
     if ($real_name == "") {
         $real_name = $user;
     }
     $dateStr = $wgLang->timeanddate(wfTimestampNow());
     $comment = $this->getRequest()->getVal("comment_text");
     foreach ($this->getRequest()->getValues() as $key => $value) {
         if (strpos($key, "comment_text") === 0) {
             $comment = $value;
             break;
         }
     }
     $topic = $this->getRequest()->getVal("topic_name");
     //echo "$dateStr<br/>";
     // remove leading space, tends to be a problem with a lot of talk page comments as it breaks the
     // HTML on the page
     $comment = preg_replace('/\\n[ ]*/', "\n", trim($comment));
     // Check to see if the user is also getting a thumbs up. If so, append the thumbs message and give a thumbs up
     if ($this->getRequest()->getVal('thumb')) {
         $comment .= "\n\n" . wfMsg('qn_thumbs_up');
         $userName = explode(":", $this->getRequest()->getVal('target'));
         ThumbsUp::quickNoteThumb($this->getRequest()->getVal('revold'), $this->getRequest()->getVal('revnew'), $this->getRequest()->getVal('pageid'), $userName[1]);
     }
     $formattedComment = wfMsg('postcomment_formatted_comment', $dateStr, $user, $real_name, $comment);
     if ($this->getRequest()->getVal('fromajax') == 'true') {
         $this->getOutput()->setArticleBodyOnly(true);
     }
     $text = "";
     $r = Revision::newFromTitle($t);
     if ($r) {
         $text = $r->getText();
     }
     $text .= "\n\n{$formattedComment}\n\n";
     $this->getOutput()->setStatusCode(409);
     //echo "updating with text:<br/> $text";
     //exit;
     $tmp = "";
     if ($this->getUser()->isBlocked()) {
         $this->getOutput()->blockedPage();
         return;
     }
     if (!$this->getUser()->getID() && $wgWhitelistEdit) {
         $this->userNotLoggedInPage();
         return;
     }
     if (wfReadOnly()) {
         $this->getOutput()->readOnlyPage();
         return;
     }
     if ($target == "Spam-Blacklist") {
         $this->getOutput()->readOnlyPage();
         return;
     }
     if ($this->getUser()->pingLimiter()) {
         $this->getOutput()->rateLimited();
         return;
     }
     $editPage = new EditPage($article);
     $contentModel = $t->getContentModel();
     $handler = ContentHandler::getForModelID($contentModel);
     $contentFormat = $handler->getDefaultFormat();
     $content = ContentHandler::makeContent($text, $t, $contentModel, $contentFormat);
     $status = Status::newGood();
     if (!wfRunHooks('EditFilterMergedContent', array($this->getContext(), $content, &$status, '', $wgUser, false))) {
         return;
     }
     if (!$status->isGood()) {
         $errors = $status->getErrorsArray(true);
         foreach ($errors as $error) {
             if (is_array($error)) {
                 $error = count($error) ? $error[0] : '';
             }
             if (preg_match('@^spamprotection@', $error)) {
                 $message = 'Error: found spam link';
                 $this->getOutput()->addHTML($message);
                 return;
             }
         }
         $message = 'EditFilterMergedContent returned an error -- cannot post comment';
         return;
     }
     $matches = array();
     $preg = "/http:\\/\\/[^] \n'\">]*/";
//.........这里部分代码省略.........
开发者ID:biribogos,项目名称:wikihow-src,代码行数:101,代码来源:SpecialPostComment.body.php

示例15: execute

    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));
//.........这里部分代码省略.........
开发者ID:biribogos,项目名称:wikihow-src,代码行数:101,代码来源:ImportXML.body.php


注:本文中的Title::newFromDBKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。