本文整理汇总了PHP中Parser::transformMsg方法的典型用法代码示例。如果您正苦于以下问题:PHP Parser::transformMsg方法的具体用法?PHP Parser::transformMsg怎么用?PHP Parser::transformMsg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parser
的用法示例。
在下文中一共展示了Parser::transformMsg方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderpageTools
function renderpageTools($input)
{
global $wgUser, $wgTitle, $wgOut, $IP;
require_once "{$IP}/extensions/ListPages/ListPagesClass.php";
$parser = new Parser();
$list = new ListPages();
$list->setBool("ShowCtg", "yes");
$relatedctgArray = explode(",", strip_tags($list->getCategoryLinks($wgTitle->mArticleID, 7)));
foreach ($relatedctgArray as $ctg) {
if ($ctg != "") {
$ctg = trim(strtoupper($ctg));
if ($ctg != "NEWS" && $ctg != "OPINIONS") {
if ($ctgstr != "") {
$ctgstr .= ",";
}
$CtgTitle = Title::newFromText($parser->transformMsg(trim($ctg), $wgOut->parserOptions()));
$ctgstr .= $CtgTitle->getDbKey();
}
}
}
$output = "";
$output .= '<a href="#pageToolsTop"></a><table cellpadding="0" cellspacing="0" border="0"><tr>';
$output .= '<td width="100" id="commentsBtn" class="toptabsOn" onmousedown=\'javascript:$("commentsBtn").className="toptabsOn";$("historyBtn").className="toptabs";$("emailBtn").className="toptabs";$("relatedBtn").className="toptabs";getContent("index.php?title=Special:CommentAction&Action=2","pid=' . $wgTitle->mArticleID . '&shwform=1&ord=0","pageToolsContent")\'>Comments</td>';
$output .= '<td width="5" class="topright"> </td>';
$output .= '<td width="100" id="emailBtn" class="toptabs" onmousedown=\'javascript:$("emailBtn").className="toptabsOn";$("historyBtn").className="toptabs";$("commentsBtn").className="toptabs";$("relatedBtn").className="toptabs";getContent("index.php?title=Special:EmailThis&pageid=' . $wgTitle->mArticleID . '","","pageToolsContent")\'>Email This</td>';
$output .= '<td width="5" class="topright"> </td>';
$output .= '<td width="100" id="relatedBtn" class="toptabs" onmousedown=\'$("relatedBtn").className="toptabsOn";$("historyBtn").className="toptabs";$("commentsBtn").className="toptabs";$("emailBtn").className="toptabs";javascript:getContent("index.php?title=Special:ListPagesAction","shw=15&ctg=' . $ctgstr . '&ord=PUBLISHEDDATE&lv=1&shwctg=1&det=0&pub=1","pageToolsContent")\'>Related Articles</td>';
$output .= '<td width="5" class="topright"> </td>';
$output .= '<td width="100" id="historyBtn" class="toptabs" onmousedown=\'$("historyBtn").className="toptabsOn";$("relatedBtn").className="toptabs";$("commentsBtn").className="toptabs";$("emailBtn").className="toptabs";javascript:getContent("index.php?title=Special:PageHistoryAJAX&pid=' . $wgTitle->mArticleID . '","","pageToolsContent")\'>Page History</td><td width="300" class="topright"> </td>';
$output .= '</tr></table><br/><div id="pageToolsContent">';
return $output;
}
示例2: renderclubHouse
function renderclubHouse($input)
{
$parser = new Parser();
$CtgTitle = Title::newFromText($parser->transformMsg(trim($input), null));
$User = $CtgTitle->getDbKey();
$output = "";
$output .= '<a href=#pageToolsTop></a><table cellpadding=0 cellspacing=0 border=0><tr>';
$output .= '<td id=commentsBtn class="toptabsOn" onMouseDown=javascript:$("commentsBtn").className="toptabsOn";$("emailBtn").className="toptabs";$("relatedBtn").className="toptabs";getContent("extensions/ListPagesAction.php","shw=7&ctg=OPINIONS_BY_USER_' . $User . '&ord=NEW&lv=0&shwctg=1&det=1&pub=0","pageToolsContent")> Recent Opinions </td>';
$output .= '<td width=5 class="topright"> </td>';
$output .= '<td id=emailBtn class="toptabs" onMouseDown=javascript:$("emailBtn").className="toptabsOn";$("commentsBtn").className="toptabs";$("relatedBtn").className="toptabs";getContent("extensions/ListPagesAction.php","shw=7&ctg=OPINIONS_BY_USER_' . $User . '&ord=VOTES&lv=0&shwctg=1&det=1&pub=0","pageToolsContent")>Most Voted On</td>';
$output .= '<td width=5 class="topright"> </td>';
$output .= '<td id=relatedBtn class="toptabs" onMouseDown=$("relatedBtn").className="toptabsOn";$("commentsBtn").className="toptabs";$("emailBtn").className="toptabs";javascript:getContent("extensions/ListPagesAction.php","shw=7&ctg=OPINIONS_BY_USER_' . $User . '&ord=COMMENTS&lv=0&shwctg=1&det=1&pub=0","pageToolsContent")> Most Commented On </td></td>';
$output .= '<td width=30 class="topright"> </td>';
$output .= '</tr></table><BR><div id=pageToolsContent>';
return $output;
}
示例3: setCategory
function setCategory($ctg)
{
global $wgUser;
global $wgLang;
global $wgContLang;
global $wgTitle;
global $wgOut;
$parser = new Parser();
$ctg = str_replace("\\,", "#comma#", $ctg);
$aCat = explode(",", $ctg);
$CtgTitle = "";
foreach ($aCat as $sCat) {
if ($sCat != "") {
if ($this->CategoriesStr != "") {
$this->CategoriesStr .= ",";
}
$CtgTitle = Title::newFromText($parser->transformMsg(trim(str_replace("#comma#", ",", $sCat)), $wgOut->parserOptions()));
$this->CategoriesStr .= $CtgTitle->getDbKey();
$this->Categories[] = $CtgTitle;
}
}
}
示例4: getFeedItem
/**
*
* @param int $date
* @return FeaturedFeedItem
*/
public function getFeedItem($date)
{
self::$parserOptions->setTimestamp($date);
self::$parserOptions->setUserLang($this->language);
$titleText = self::$parser->transformMsg($this->page, self::$parserOptions);
$title = Title::newFromText($titleText);
if (!$title) {
return false;
}
$rev = Revision::newFromTitle($title);
if (!$rev) {
return false;
// page does not exist
}
$text = $rev->getText();
if (!$text) {
return false;
}
$text = self::$parser->parse($text, $title, self::$parserOptions)->getText();
$url = SpecialPage::getTitleFor('FeedItem', $this->name . '/' . wfTimestamp(TS_MW, $date) . '/' . $this->language->getCode())->getFullURL();
return new FeaturedFeedItem(self::$parser->transformMsg($this->entryName, self::$parserOptions), wfExpandUrl($url), $text, $date);
}
示例5: addNotify
static public function addNotify( $rawquery, $name, $rep_all, $show_all, $delegate ) {
global $wgTitle;
// Take care at least of some templates -- for better template support use #ask
$parser = new Parser();
$parserOptions = new ParserOptions();
$rawquery = $parser->transformMsg( $rawquery, $parserOptions, $wgTitle );
wfProfileIn( 'SMWNotifyProcessor::createNotify (SMW)' );
$sStore = NMStorage::getDatabase();
global $wgUser;
$user_id = $wgUser->getId();
if ( $user_id == 0 ) {
wfProfileOut( 'SMWNotifyProcessor::createNotify (SMW)' );
return wfMsg( 'smw_nm_proc_notlogin' );
}
// check notify query first, use QueryParser from SMW
SMWQueryProcessor::processFunctionParams( SMWNotifyProcessor::getQueryRawParams( $rawquery ), $querystring, $params, $printouts );
$qp = new SMWQueryParser();
$qp->setDefaultNamespaces( $smwgQDefaultNamespaces );
$desc = $qp->getQueryDescription( $querystring );
if ( count( $qp->getErrors() ) > 0 ) {
wfProfileOut( 'SMWNotifyProcessor::createNotify (SMW)' );
return wfMsg( 'smw_nm_proc_createfail', implode( "\n", $qp->getErrors() ) );
}
$notify_id = $sStore->addNotifyQuery( $user_id, $rawquery, $name, $rep_all, $show_all, $delegate );
if ( $notify_id == 0 ) {
wfProfileOut( 'SMWNotifyProcessor::createNotify (SMW)' );
return wfMsg( 'smw_nm_proc_savefail' );
}
wfProfileOut( 'SMWNotifyProcessor::createNotify (SMW)' );
wfProfileIn( 'SMWNotifyProcessor::enableNotify (SMW)' );
$msg = '';
$result = SMWNotifyProcessor::enableNotify( $notify_id, $rawquery, $msg );
wfProfileOut( 'SMWNotifyProcessor::enableNotify (SMW)' );
return "1" . ( $result ? "1":"0" ) . "$notify_id,$msg";
}
示例6: msgExt
/**
* Returns message in the requested format after parsing wikitext to html
* This is meant to be equivalent to wfMsgExt() with parse, parsemag and
* escape as available options but using the DPL local parser instead of
* the global one (bugfix).
*/
function msgExt($key, $options)
{
$args = func_get_args();
array_shift($args);
array_shift($args);
if (!is_array($options)) {
$options = array($options);
}
$string = wfMsgNoTrans($key);
$string = wfMsgReplaceArgs($string, $args);
if (in_array('parse', $options)) {
$this->mParserOptions->setInterfaceMessage(true);
$string = $this->mParser->recursiveTagParse($string);
$this->mParserOptions->setInterfaceMessage(false);
// $string = $parserOutput->getText();
} elseif (in_array('parsemag', $options)) {
$parser = new Parser();
$parserOptions = new ParserOptions();
$parserOptions->setInterfaceMessage(true);
$parser->startExternalParse($this->mParserTitle, $parserOptions, OT_MSG);
$string = $parser->transformMsg($string, $parserOptions);
}
if (in_array('escape', $options)) {
$string = htmlspecialchars($string);
}
return $string;
}
示例7: dynamicPageList
//.........这里部分代码省略.........
$sArg[0] = '';
}
if ($sArg != '' && $sArg[0] == '-') {
// categories are NOT headings
$bNotHeading = true;
$sArg[0] = '';
}
$op = 'OR';
// we expand html entities because they contain an '& 'which would be interpreted as an AND condition
$sArg = html_entity_decode($sArg, ENT_QUOTES);
if (strpos($sArg, '&') !== false) {
$aParams = explode('&', $sArg);
$op = 'AND';
} else {
$aParams = explode('|', $sArg);
}
foreach ($aParams as $sParam) {
$sParam = trim($sParam);
if ($sParam == '') {
// ignore empty line
} elseif ($sParam == '_none_') {
// include uncategorized pages (special value: empty string)
$aParams[$sParam] = '';
$bIncludeUncat = true;
$aCategories[] = '';
} else {
if ($sParam[0] == '*' && strlen($sParam) >= 2) {
if ($sParam[1] == '*') {
$sParamList = explode('|', self::getSubcategories(substr($sParam, 2), $sPageTable, 2));
} else {
$sParamList = explode('|', self::getSubcategories(substr($sParam, 1), $sPageTable, 1));
}
foreach ($sParamList as $sPar) {
$title = Title::newFromText($localParser->transformMsg($sPar, $pOptions));
if (!is_null($title)) {
$aCategories[] = $title->getDBkey();
}
}
} else {
$title = Title::newFromText($localParser->transformMsg($sParam, $pOptions));
if (!is_null($title)) {
$aCategories[] = $title->getDBkey();
}
}
}
}
if (!empty($aCategories)) {
if ($op == 'OR') {
$aIncludeCategories[] = $aCategories;
} else {
foreach ($aCategories as $aParams) {
$sParam = array();
$sParam[] = $aParams;
$aIncludeCategories[] = $sParam;
}
}
if ($bHeading) {
$aCatHeadings = array_unique($aCatHeadings + $aCategories);
}
if ($bNotHeading) {
$aCatNotHeadings = array_unique($aCatNotHeadings + $aCategories);
}
$bConflictsWithOpenReferences = true;
}
break;
case 'hiddencategories':
示例8: updatePublishedOpinionsCount
function updatePublishedOpinionsCount()
{
global $wgUser, $wgOut, $wgStatsStartTimestamp;
$parser = new Parser();
$dbr =& wfGetDB(DB_MASTER);
$ctg = "OPINIONS BY USER " . strtoupper($this->user_name);
$CtgTitle = Title::newFromText($parser->transformMsg(trim($ctg), $wgOut->parserOptions()));
$CtgTitle = $CtgTitle->getDbKey();
if ($wgStatsStartTimestamp) {
$timeSQL = " AND (select UNIX_TIMESTAMP(rev_timestamp) from {$dbr->tableName('revision')} where rev_page=page_id order by rev_timestamp asc limit 1) > " . $wgStatsStartTimestamp;
}
$sql = "update user_stats set stats_opinions_published = ";
$sql .= "(SELECT count(*) as PromotedOpinions FROM {$dbr->tableName('page')} INNER JOIN {$dbr->tableName('categorylinks')} ON page_id = cl_from INNER JOIN published_page ON page_id=published_page_id WHERE UPPER(cl_to) = " . $dbr->addQuotes($CtgTitle) . " AND published_type=1 " . " " . $timeSQL;
$sql .= ")";
$sql .= " WHERE stats_user_id = " . $this->user_id . " AND stats_year_id = " . $this->year_id;
echo $sql . "<BR>";
$res = $dbr->query($sql);
$this->updateTotalPoints();
}
示例9: transformMsg
/**
* Expand templates and variables in the provided text
*
* @param string $text The text to preprocess
* @param ParserOptions $options Options
* @param Title|null $title Title object or null to use $wgTitle
* @return string
*/
public function transformMsg($text, $options, $title = null)
{
$p = new Parser();
return $p->transformMsg($text, $options, $title);
}
示例10: wfMsgExt
/**
* Returns message in the requested format
* @param string $key Key of the message
* @param array $options Processing rules:
* <i>parse<i>: parses wikitext to html
* <i>parseinline<i>: parses wikitext to html and removes the surrounding p's added by parser or tidy
* <i>escape<i>: filters message trough htmlspecialchars
* <i>replaceafter<i>: parameters are substituted after parsing or escaping
*/
function wfMsgExt($key, $options)
{
global $wgOut, $wgMsgParserOptions, $wgParser;
$args = func_get_args();
array_shift($args);
array_shift($args);
if (!is_array($options)) {
$options = array($options);
}
$string = wfMsgGetKey($key, true, false, false);
if (!in_array('replaceafter', $options)) {
$string = wfMsgReplaceArgs($string, $args);
}
if (in_array('parse', $options)) {
$string = $wgOut->parse($string, true, true);
} elseif (in_array('parseinline', $options)) {
$string = $wgOut->parse($string, true, true);
$m = array();
if (preg_match("~^<p>(.*)\n?</p>\$~", $string, $m)) {
$string = $m[1];
}
} elseif (in_array('parsemag', $options)) {
global $wgTitle;
$parser = new Parser();
$parserOptions = new ParserOptions();
$parserOptions->setInterfaceMessage(true);
$parser->startExternalParse($wgTitle, $parserOptions, OT_MSG);
$string = $parser->transformMsg($string, $parserOptions);
}
if (in_array('escape', $options)) {
$string = htmlspecialchars($string);
}
if (in_array('replaceafter', $options)) {
$string = wfMsgReplaceArgs($string, $args);
}
return $string;
}
示例11: renderDynamicPageList
function renderDynamicPageList($input, $args, $mwParser)
{
global $wgUser, $wgContLang;
global $wgDisableCounters;
// to determine if to allow sorting by #hits.
global $wgDLPmaxCategories, $wgDLPMaxResultCount, $wgDLPMaxCacheTime;
global $wgDLPAllowUnlimitedResults, $wgDLPAllowUnlimitedCategories;
if ($wgDLPMaxCacheTime !== false) {
$mwParser->getOutput()->updateCacheExpiry($wgDLPMaxCacheTime);
}
$countSet = false;
$startList = '<ul>';
$endList = '</ul>';
$startItem = '<li>';
$endItem = '</li>';
$inlineMode = false;
$useGallery = false;
$galleryFileSize = false;
$galleryFileName = true;
$galleryImageHeight = 0;
$galleryImageWidth = 0;
$galleryNumbRows = 0;
$galleryCaption = '';
$gallery = null;
$orderMethod = 'categoryadd';
$order = 'descending';
$redirects = 'exclude';
$stable = $quality = 'include';
$flaggedRevs = false;
$namespaceFiltering = false;
$namespaceIndex = 0;
$offset = 0;
$googleHack = false;
$suppressErrors = false;
$showNamespace = true;
$addFirstCategoryDate = false;
$dateFormat = '';
$stripYear = false;
$linkOptions = array();
$categories = array();
$excludeCategories = array();
$parameters = explode("\n", $input);
$parser = new Parser();
$poptions = new ParserOptions();
foreach ($parameters as $parameter) {
$paramField = explode('=', $parameter, 2);
if (count($paramField) < 2) {
continue;
}
$type = trim($paramField[0]);
$arg = trim($paramField[1]);
switch ($type) {
case 'category':
$title = Title::makeTitleSafe(NS_CATEGORY, $parser->transformMsg($arg, $poptions));
if (is_null($title)) {
continue;
}
$categories[] = $title;
break;
case 'notcategory':
$title = Title::makeTitleSafe(NS_CATEGORY, $parser->transformMsg($arg, $poptions));
if (is_null($title)) {
continue;
}
$excludeCategories[] = $title;
break;
case 'namespace':
$ns = $wgContLang->getNsIndex($arg);
if ($ns != null) {
$namespaceIndex = $ns;
$namespaceFiltering = true;
} else {
// Note, since intval("some string") = 0
// this considers pretty much anything
// invalid here as the main namespace.
// This was probably originally a bug,
// but is now depended upon by people
// writing things like namespace=main
// so be careful when changing this code.
$namespaceIndex = intval($arg);
if ($namespaceIndex >= 0) {
$namespaceFiltering = true;
} else {
$namespaceFiltering = false;
}
}
break;
case 'count':
// ensure that $count is a number;
$count = intval($arg);
$countSet = true;
break;
case 'offset':
$offset = intval($arg);
break;
case 'imagewidth':
$galleryImageWidth = intval($arg);
break;
case 'imageheight':
$galleryImageHeight = intval($arg);
//.........这里部分代码省略.........
示例12: updatePublishedOpinionsCount
/**
* Updates the amount of published opinions by the current user.
* Currently this is ugly, unused and a leftover from ArmchairGM days.
*/
function updatePublishedOpinionsCount()
{
global $wgOut;
$parser = new Parser();
$dbw = wfGetDB(DB_MASTER);
$ctg = 'Opinions by User ' . $this->user_name;
$ctgTitle = Title::newFromText($parser->transformMsg(trim($ctg), $wgOut->parserOptions()));
$ctgTitle = $ctgTitle->getDBkey();
$opinions = $dbw->select(array('page', 'categorylinks', 'published_page'), array('COUNT(*) AS PromotedOpinions'), array('cl_to' => $ctgTitle, 'published_type' => 1), __METHOD__, array(), array('categorylinks' => array('INNER JOIN', 'page_id = cl_from'), 'published_page' => array('INNER JOIN', 'page_id = published_page_id')));
$res = $dbw->update('user_stats', array('stats_opinions_published' => $opinions->PromotedOpinions), array('stats_user_id' => $this->user_id), __METHOD__);
$this->clearCache();
}
示例13: getPromotedOpinions
function getPromotedOpinions()
{
$parser = new Parser();
$dbr =& wfGetDB(DB_SLAVE);
$ctg = "OPINIONS BY USER " . strtoupper($this->Username);
$CtgTitle = Title::newFromText($parser->transformMsg(trim($ctg), null));
$CtgTitle = $CtgTitle->getDbKey();
if ($this->timeFrame == 1) {
$timeSQL = " AND (select UNIX_TIMESTAMP(rev_timestamp) from {$dbr->tableName('revision')} where rev_page=page_id order by rev_timestamp asc limit 1) > " . $this->unix_time_30daysago;
}
$sql = "SELECT count(*) as PromotedOpinions FROM {$dbr->tableName('page')} INNER JOIN {$dbr->tableName('categorylinks')} ON page_id = cl_from INNER JOIN published_page ON page_id=published_page_id WHERE UPPER(cl_to) = " . $dbr->addQuotes($CtgTitle) . " AND published_type=1 " . " " . $timeSQL;
$res = $dbr->query($sql);
while ($row = $dbr->fetchObject($res)) {
$this->PromotedOpinions = $row->PromotedOpinions;
}
return $this->PromotedOpinions;
}