本文整理汇总了PHP中Xml::escapeJsString方法的典型用法代码示例。如果您正苦于以下问题:PHP Xml::escapeJsString方法的具体用法?PHP Xml::escapeJsString怎么用?PHP Xml::escapeJsString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xml
的用法示例。
在下文中一共展示了Xml::escapeJsString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: redircite_render
function redircite_render($input, $args, &$parser) {
// Generate HTML code and add it to the $redirciteMarkerList array
// Add "xx-redircite-marker-NUMBER-redircite-xx" to the output,
// which will be translated to the HTML stored in $redirciteMarkerList by
// redircite_afterTidy()
global $redirciteMarkerList;
# Verify that $input is a valid title
$inputTitle = Title::newFromText($input);
if(!$inputTitle)
return $input;
$link1 = $parser->recursiveTagParse("[[$input]]");
$title1 = Title::newFromText($input);
if(!$title1->exists()) // Page doesn't exist
// Just output a normal (red) link
return $link1;
$articleObj = new Article($title1);
$title2 = Title::newFromRedirect($articleObj->fetchContent());
if(!$title2) // Page is not a redirect
// Just output a normal link
return $link1;
$link2 = $parser->recursiveTagParse("[[{$title2->getPrefixedText()}|$input]]");
$marker = "xx-redircite-marker-" . count($redirciteMarkerList) . "-redircite-xx";
$onmouseout = 'this.firstChild.innerHTML = "'. Xml::escapeJsString($input) . '";';
$onmouseover = 'this.firstChild.innerHTML = "' . Xml::escapeJsString($title2->getPrefixedText()) . '";';
return Xml::tags('span', array(
'onmouseout' => $onmouseout,
'onmouseover' => $onmouseover),
$link2);
}
示例2: encodeJsVar
/**
* Encode a variable of unknown type to JavaScript.
* Arrays are converted to JS arrays, objects are converted to JS associative
* arrays (objects). So cast your PHP associative arrays to objects before
* passing them to here.
*
* This is a copy of
* @see Xml::encodeJsVar
* which fixes incorrect behaviour with floats.
*
* @since 0.7.1
*
* @param mixed $value
*
* @return tring
*/
public static function encodeJsVar($value)
{
if (is_bool($value)) {
$s = $value ? 'true' : 'false';
} elseif (is_null($value)) {
$s = 'null';
} elseif (is_int($value) || is_float($value)) {
$s = $value;
} elseif (is_array($value) && array_keys($value) === range(0, count($value) - 1) || count($value) == 0) {
$s = '[';
foreach ($value as $elt) {
if ($s != '[') {
$s .= ', ';
}
$s .= self::encodeJsVar($elt);
}
$s .= ']';
} elseif (is_object($value) || is_array($value)) {
// Objects and associative arrays
$s = '{';
foreach ((array) $value as $name => $elt) {
if ($s != '{') {
$s .= ', ';
}
$s .= '"' . Xml::escapeJsString($name) . '": ' . self::encodeJsVar($elt);
}
$s .= '}';
} else {
$s = '"' . Xml::escapeJsString($value) . '"';
}
return $s;
}
示例3: addResources
/**
* AjaxAddScript hook
* Adds scripts
*/
public static function addResources($out)
{
global $wgExtensionAssetsPath, $wgJsMimeType;
global $wgUsabilityInitiativeResourceMode;
global $wgEnableJS2system, $wgEditToolbarRunTests;
global $wgStyleVersion;
wfRunHooks('UsabilityInitiativeLoadModules');
if (!self::$doOutput) {
return true;
}
// Default to raw
$mode = $wgUsabilityInitiativeResourceMode;
// Just an alias
if (!isset(self::$scriptFiles['base_sets'][$mode])) {
$mode = 'raw';
}
// Include base-set of scripts
self::$scripts = array_merge(self::$scriptFiles['base_sets'][$mode], self::$scriptFiles['modules'][$mode], self::$scripts);
// Provide enough support to make things work, even when js2 is not
// in use (eventually it will be standard, but right now it's not)
if (!$wgEnableJS2system) {
$out->includeJQuery();
}
// Include base-set of styles
self::$styles = array_merge(self::$styleFiles['base_sets'][$mode], self::$styles);
if ($wgEditToolbarRunTests) {
// Include client side tests
self::$scripts = array_merge(self::$scripts, self::$scriptFiles['tests']);
}
// Loops over each script
foreach (self::$scripts as $script) {
// Add javascript to document
if ($script['src'][0] == '/') {
// Path is relative to $wgScriptPath
global $wgScriptPath;
$src = "{$wgScriptPath}{$script['src']}";
} else {
// Path is relative to $wgExtensionAssetsPath
$src = "{$wgExtensionAssetsPath}/UsabilityInitiative/{$script['src']}";
}
$version = isset($script['version']) ? $script['version'] : $wgStyleVersion;
$out->addScriptFile($src, $version);
}
// Transforms messages into javascript object members
foreach (self::$messages as $i => $message) {
$escapedMessageValue = Xml::escapeJsString(wfMsg($message));
$escapedMessageKey = Xml::escapeJsString($message);
self::$messages[$i] = "'{$escapedMessageKey}':'{$escapedMessageValue}'";
}
// Add javascript to document
if (count(self::$messages) > 0) {
$out->addScript(Xml::tags('script', array('type' => $wgJsMimeType), 'mw.usability.addMessages({' . implode(',', self::$messages) . '});'));
}
// Loops over each style
foreach (self::$styles as $style) {
// Add css for various styles
$out->addLink(array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => $wgExtensionAssetsPath . "/UsabilityInitiative/" . "{$style['src']}?{$style['version']}"));
}
return true;
}
示例4: setup
/**
* Static setup method for input type "menuselect".
* Adds the Javascript code and css used by all menuselects.
*/
private static function setup()
{
global $wgOut, $wgLang;
static $hasRun = false;
if (!$hasRun) {
$hasRun = true;
// set localized messages (use MW i18n, not jQuery i18n)
$jstext = "jQuery(function(){mw.loader.using('jquery.ui.datepicker', function(){\n" . "\tjQuery.datepicker.regional['wiki'] = {\n" . "\t\tcloseText: '" . Xml::escapeJsString(wfMsg('semanticformsinputs-close')) . "',\n" . "\t\tprevText: '" . Xml::escapeJsString(wfMsg('semanticformsinputs-prev')) . "',\n" . "\t\tnextText: '" . Xml::escapeJsString(wfMsg('semanticformsinputs-next')) . "',\n" . "\t\tcurrentText: '" . Xml::escapeJsString(wfMsg('semanticformsinputs-today')) . "',\n" . "\t\tmonthNames: ['" . Xml::escapeJsString(wfMsg('january')) . "','" . Xml::escapeJsString(wfMsg('february')) . "','" . Xml::escapeJsString(wfMsg('march')) . "','" . Xml::escapeJsString(wfMsg('april')) . "','" . Xml::escapeJsString(wfMsg('may_long')) . "','" . Xml::escapeJsString(wfMsg('june')) . "','" . Xml::escapeJsString(wfMsg('july')) . "','" . Xml::escapeJsString(wfMsg('august')) . "','" . Xml::escapeJsString(wfMsg('september')) . "','" . Xml::escapeJsString(wfMsg('october')) . "','" . Xml::escapeJsString(wfMsg('november')) . "','" . Xml::escapeJsString(wfMsg('december')) . "'],\n" . "\t\tmonthNamesShort: ['" . Xml::escapeJsString(wfMsg('jan')) . "','" . Xml::escapeJsString(wfMsg('feb')) . "','" . Xml::escapeJsString(wfMsg('mar')) . "','" . Xml::escapeJsString(wfMsg('apr')) . "','" . Xml::escapeJsString(wfMsg('may')) . "','" . Xml::escapeJsString(wfMsg('jun')) . "','" . Xml::escapeJsString(wfMsg('jul')) . "','" . Xml::escapeJsString(wfMsg('aug')) . "','" . Xml::escapeJsString(wfMsg('sep')) . "','" . Xml::escapeJsString(wfMsg('oct')) . "','" . Xml::escapeJsString(wfMsg('nov')) . "','" . Xml::escapeJsString(wfMsg('dec')) . "'],\n" . "\t\tdayNames: ['" . Xml::escapeJsString(wfMsg('sunday')) . "','" . Xml::escapeJsString(wfMsg('monday')) . "','" . Xml::escapeJsString(wfMsg('tuesday')) . "','" . Xml::escapeJsString(wfMsg('wednesday')) . "','" . Xml::escapeJsString(wfMsg('thursday')) . "','" . Xml::escapeJsString(wfMsg('friday')) . "','" . Xml::escapeJsString(wfMsg('saturday')) . "'],\n" . "\t\tdayNamesShort: ['" . Xml::escapeJsString(wfMsg('sun')) . "','" . Xml::escapeJsString(wfMsg('mon')) . "','" . Xml::escapeJsString(wfMsg('tue')) . "','" . Xml::escapeJsString(wfMsg('wed')) . "','" . Xml::escapeJsString(wfMsg('thu')) . "','" . Xml::escapeJsString(wfMsg('fri')) . "','" . Xml::escapeJsString(wfMsg('sat')) . "'],\n" . "\t\tdayNamesMin: ['" . Xml::escapeJsString($wgLang->firstChar(wfMsg('sun'))) . "','" . Xml::escapeJsString($wgLang->firstChar(wfMsg('mon'))) . "','" . Xml::escapeJsString($wgLang->firstChar(wfMsg('tue'))) . "','" . Xml::escapeJsString($wgLang->firstChar(wfMsg('wed'))) . "','" . Xml::escapeJsString($wgLang->firstChar(wfMsg('thu'))) . "','" . Xml::escapeJsString($wgLang->firstChar(wfMsg('fri'))) . "','" . Xml::escapeJsString($wgLang->firstChar(wfMsg('sat'))) . "'],\n" . "\t\tweekHeader: '',\n" . "\t\tdateFormat: '" . Xml::escapeJsString(wfMsg('semanticformsinputs-dateformatshort')) . "',\n" . "\t\tfirstDay: '" . Xml::escapeJsString(wfMsg('semanticformsinputs-firstdayofweek')) . "',\n" . "\t\tisRTL: " . ($wgLang->isRTL() ? "true" : "false") . ",\n" . "\t\tshowMonthAfterYear: false,\n" . "\t\tyearSuffix: ''};\n" . "\tjQuery.datepicker.setDefaults(jQuery.datepicker.regional['wiki']);\n" . "});});\n";
$wgOut->addScript(Html::inlineScript($jstext));
}
}
示例5: addSpecificMapHTML
/**
* @see MapsBaseMap::addSpecificMapHTML()
*
*/
public function addSpecificMapHTML(Parser $parser)
{
global $egValidatorErrorLevel;
MapsGoogleMaps::addOverlayOutput($this->output, $this->mapName, $this->overlays, $this->controls);
if ($egValidatorErrorLevel >= Validator_ERRORS_WARN) {
$couldNotGeocodeMsg = Xml::escapeJsString(wfMsg('ukgeocoding_couldNotGeocode'));
$showErrorJs = "document.getElementById( '{$this->mapName}_errors' ).innerHTML = '{$couldNotGeocodeMsg}';";
} else {
$showErrorJs = '';
}
$this->output .= Html::element('div', array('id' => $this->mapName, 'style' => "width: {$this->width}; height: {$this->height}; background-color: #cccccc;"), wfMsg('maps-loading-map')) . "<div id='{$this->mapName}_errors'></div>";
$parser->getOutput()->addHeadItem(Html::inlineScript(<<<EOT
\$(function() {
\tvar map = initializeGoogleMap('{$this->mapName}',
\t\t{
\t\tlat: 0,
\t\tlon: 0,
\t\tzoom: {$this->zoom},
\t\ttype: {$this->type},
\t\ttypes: [{$this->types}],
\t\tcontrols: [{$this->controls}],
\t\tscrollWheelZoom: {$this->autozoom}
\t\t},
\t\t[]
\t);
\tvar localSearch = new GlocalSearch();
\tfunction usePointFromPostcode( marker, callbackFunction ) {
\t\tlocalSearch.setSearchCompleteCallback( null,
\t\t\tfunction() {
\t\t\t\tif ( localSearch.results[0] ) {
\t\t\t\t\tcallbackFunction(new GLatLng(localSearch.results[0].lat, localSearch.results[0].lng), marker);
\t\t\t\t} else {
\t\t\t\t\t{$showErrorJs}
\t\t\t\t}
\t\t\t}
\t\t);
\t\tlocalSearch.execute(marker.location + ", UK");
\t}
\tfunction updateGoogleMap(point, marker) {
\t\tmap.addOverlay(createGMarker(point, marker.title, marker.label, marker.icon));
\t\tbounds.extend(point);
\t\tmap.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
\t\tif({$this->zoom}!=null) map.setZoom({$this->zoom});
\t}
\tvar markers = [{$this->markerString}];
\tvar bounds = new GLatLngBounds();
\tfor(i in markers) {
\t\tusePointFromPostcode(markers[i], updateGoogleMap);
\t}
});\t\t\t\t
EOT
));
}
示例6: getJsObject
static function getJsObject($method_name)
{
$args = func_get_args();
array_shift($args);
// remove $method_name from $args
$result = '{ ';
$firstElem = true;
foreach ($args as &$arg) {
if ($firstElem) {
$firstElem = false;
} else {
$result .= ', ';
}
$result .= $arg . ': "' . Xml::escapeJsString(call_user_func(array('self', $method_name), $arg)) . '"';
}
$result .= ' }';
return $result;
}
示例7: fnWoopraJavascript
function fnWoopraJavascript($out)
{
global $wgUser, $wgWoopraSitekey;
if ( $wgWoopraSitekey === false )
return true;
$html = "<script type=\"text/javascript\">\r\n";
$html .= "woopra_id = '" . Xml::escapeJsString( $wgWoopraSitekey ) . "';\r\n";
if (!$wgUser->isAnon())
{
$html .= "var woopra_array = new Array();\r\n";
$html .= "woopra_array['name'] = '" . Xml::escapeJsString( $wgUser->getRealName() ) . "';\r\n";
$html .= "woopra_array['Email'] = '" . Xml::escapeJsString( $wgUser->getEmail() ) . "';\r\n";
// Add custom tracking code here!
}
$html .= "</script>\r\n";
$html .= "<script type=\"text/javascript\" src=\"http://static.woopra.com/js/woopra.js\"></script>";
$out->addScript($html);
return true;
}
示例8: showRedirectedFromHeader
/**
* If this request is a redirect view, send "redirected from" subtitle to
* the output. Returns true if the header was needed, false if this is not
* a redirect view. Handles both local and remote redirects.
*
* @return boolean
*/
public function showRedirectedFromHeader()
{
global $wgRedirectSources;
$outputPage = $this->getContext()->getOutput();
$rdfrom = $this->getContext()->getRequest()->getVal('rdfrom');
if (isset($this->mRedirectedFrom)) {
// This is an internally redirected page view.
// We'll need a backlink to the source page for navigation.
if (wfRunHooks('ArticleViewRedirect', array(&$this))) {
$redir = Linker::linkKnown($this->mRedirectedFrom, null, array(), array('redirect' => 'no'));
$outputPage->addSubtitle(wfMessage('redirectedfrom')->rawParams($redir));
// Set the fragment if one was specified in the redirect
if (strval($this->getTitle()->getFragment()) != '') {
$fragment = Xml::escapeJsString($this->getTitle()->getFragmentForURL());
$outputPage->addInlineScript("redirectToFragment(\"{$fragment}\");");
}
// Add a <link rel="canonical"> tag
$outputPage->addLink(array('rel' => 'canonical', 'href' => $this->getTitle()->getLocalURL()));
// Tell the output object that the user arrived at this article through a redirect
$outputPage->setRedirectedFrom($this->mRedirectedFrom);
return true;
}
} elseif ($rdfrom) {
// This is an externally redirected view, from some other wiki.
// If it was reported from a trusted site, supply a backlink.
if ($wgRedirectSources && preg_match($wgRedirectSources, $rdfrom)) {
$redir = Linker::makeExternalLink($rdfrom, $rdfrom);
$outputPage->addSubtitle(wfMessage('redirectedfrom')->rawParams($redir));
return true;
}
}
return false;
}
示例9: doAddJsVar
private function doAddJsVar($key, $value)
{
global $wgOut;
$wgOut->addScript('<script type="text/javascript"> var ' . $key . '="' . Xml::escapeJsString($value) . '"; </script>');
}
示例10: renderNodeInfo
//.........这里部分代码省略.........
$subcatCount = $cat ? intval($cat->getSubcatCount()) : 0;
$fileCount = $cat ? intval($cat->getFileCount()) : 0;
if ($ns == NS_CATEGORY) {
if ($cat) {
if ($mode == CT_MODE_CATEGORIES) {
$count = $subcatCount;
} elseif ($mode == CT_MODE_PAGES) {
$count = $allCount - $fileCount;
} else {
$count = $allCount;
}
}
if ($count === 0) {
$bullet = wfMsgNoTrans('categorytree-empty-bullet') . ' ';
$attr['class'] = 'CategoryTreeEmptyBullet';
} else {
$linkattr = array();
if ($load) {
$linkattr['id'] = $load;
}
$linkattr['class'] = "CategoryTreeToggle";
$linkattr['style'] = 'display: none;';
// Unhidden by JS
$linkattr['data-ct-title'] = $key;
if ($children == 0 || $loadchildren) {
$tag = 'span';
$txt = wfMsgNoTrans('categorytree-expand-bullet');
# Don't load this message for ajax requests, so that we don't have to initialise $wgLang
$linkattr['title'] = $this->mIsAjaxRequest ? '##LOAD##' : wfMsgNoTrans('categorytree-expand');
$linkattr['data-ct-state'] = 'collapsed';
} else {
$tag = 'span';
$txt = wfMsgNoTrans('categorytree-collapse-bullet');
$linkattr['title'] = wfMsgNoTrans('categorytree-collapse');
$linkattr['data-ct-loaded'] = true;
$linkattr['data-ct-state'] = 'expanded';
}
if ($tag == 'a') {
$linkattr['href'] = $wikiLink;
}
$bullet = Xml::openElement($tag, $linkattr) . $txt . Xml::closeElement($tag) . ' ';
}
} else {
$bullet = wfMsgNoTrans('categorytree-page-bullet');
}
$s .= Xml::tags('span', $attr, $bullet) . ' ';
$s .= Xml::openElement('a', array('class' => $labelClass, 'href' => $wikiLink)) . $label . Xml::closeElement('a');
if ($count !== false && $this->getOption('showcount')) {
$pages = $allCount - $subcatCount - $fileCount;
global $wgContLang, $wgLang;
$attr = array('title' => wfMsgExt('categorytree-member-counts', 'parsemag', $subcatCount, $pages, $fileCount, $allCount, $count), 'dir' => $wgLang->getDir());
$s .= $wgContLang->getDirMark() . ' ';
# Create a list of category members with only non-zero member counts
$memberNums = array();
if ($subcatCount) {
$memberNums[] = wfMessage('categorytree-num-categories', $wgLang->formatNum($subcatCount))->text();
}
if ($pages) {
$memberNums[] = wfMessage('categorytree-num-pages', $wgLang->formatNum($pages))->text();
}
if ($fileCount) {
$memberNums[] = wfMessage('categorytree-num-files', $wgLang->formatNum($fileCount))->text();
}
$memberNumsShort = $memberNums ? $wgLang->commaList($memberNums) : wfMessage('categorytree-num-empty')->text();
# Only $5 is actually used in the default message.
# Other arguments can be used in a customized message.
$s .= Xml::tags('span', $attr, wfMsgExt('categorytree-member-num', array('parsemag', 'escapenoentities'), $subcatCount, $pages, $fileCount, $allCount, $memberNumsShort));
}
$s .= Xml::closeElement('div');
$s .= "\n\t\t";
$s .= Xml::openElement('div', array('class' => 'CategoryTreeChildren', 'style' => $children > 0 ? "display:block" : "display:none"));
if ($ns == NS_CATEGORY && $children > 0 && !$loadchildren) {
$children = $this->renderChildren($title, $children);
if ($children == '') {
$s .= Xml::openElement('i', array('class' => 'CategoryTreeNotice'));
if ($mode == CT_MODE_CATEGORIES) {
$s .= wfMsgExt('categorytree-no-subcategories', 'parsemag');
} elseif ($mode == CT_MODE_PAGES) {
$s .= wfMsgExt('categorytree-no-pages', 'parsemag');
} elseif ($mode == CT_MODE_PARENTS) {
$s .= wfMsgExt('categorytree-no-parent-categories', 'parsemag');
} else {
$s .= wfMsgExt('categorytree-nothing-found', 'parsemag');
}
$s .= Xml::closeElement('i');
} else {
$s .= $children;
}
}
$s .= Xml::closeElement('div');
$s .= Xml::closeElement('div');
if ($load) {
$s .= "\n\t\t";
$s .= Xml::openElement('script', array('type' => 'text/javascript'));
$s .= 'categoryTreeExpandNode("' . Xml::escapeJsString($key) . '", ' . $this->getOptionsAsJsStructure($children) . ', document.getElementById("' . $load . '"));';
$s .= Xml::closeElement('script');
}
$s .= "\n\t\t";
return $s;
}
示例11: setup
/**
* Static setup method for input type "menuselect".
* Adds the Javascript code and css used by all menuselects.
*/
static private function setup() {
global $wgOut, $wgLang;
global $sfgScriptPath, $sfigSettings;
static $hasRun = false;
if ( !$hasRun ) {
$hasRun = true;
$wgOut->addExtensionStyle( $sfgScriptPath . '/skins/jquery-ui/base/jquery.ui.datepicker.css' );
$wgOut->addExtensionStyle( $sfgScriptPath . '/skins/jquery-ui/base/jquery.ui.theme.css' );
$wgOut->addScript( '<script type="text/javascript" src="' . $sfgScriptPath . '/libs/jquery-ui/jquery.ui.datepicker.min.js"></script> ' );
$wgOut->addScript( '<script type="text/javascript" src="' . $sfigSettings->scriptPath . '/libs/datepicker.js"></script> ' );
// set localized messages (use MW i18n, not jQuery i18n)
$jstext =
"jQuery(function(){\n"
. " jQuery.datepicker.regional['wiki'] = {\n"
. " closeText: '" . Xml::escapeJsString( wfMsg( 'semanticformsinputs-close' ) ) . "',\n"
. " prevText: '" . Xml::escapeJsString( wfMsg( 'semanticformsinputs-prev' ) ) . "',\n"
. " nextText: '" . Xml::escapeJsString( wfMsg( 'semanticformsinputs-next' ) ) . "',\n"
. " currentText: '" . Xml::escapeJsString( wfMsg( 'semanticformsinputs-today' ) ) . "',\n"
. " monthNames: ['"
. Xml::escapeJsString( wfMsg( 'january' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'february' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'march' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'april' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'may_long' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'june' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'july' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'august' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'september' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'october' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'november' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'december' ) ) . "'],\n"
. " monthNamesShort: ['"
. Xml::escapeJsString( wfMsg( 'jan' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'feb' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'mar' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'apr' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'may' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'jun' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'jul' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'aug' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'sep' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'oct' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'nov' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'dec' ) ) . "'],\n"
. " dayNames: ['"
. Xml::escapeJsString( wfMsg( 'sunday' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'monday' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'tuesday' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'wednesday' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'thursday' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'friday' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'saturday' ) ) . "'],\n"
. " dayNamesShort: ['"
. Xml::escapeJsString( wfMsg( 'sun' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'mon' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'tue' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'wed' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'thu' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'fri' ) ) . "','"
. Xml::escapeJsString( wfMsg( 'sat' ) ) . "'],\n"
. " dayNamesMin: ['"
. Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'sun' ) ) ) . "','"
. Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'mon' ) ) ) . "','"
. Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'tue' ) ) ) . "','"
. Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'wed' ) ) ) . "','"
. Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'thu' ) ) ) . "','"
. Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'fri' ) ) ) . "','"
. Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'sat' ) ) ) . "'],\n"
. " weekHeader: '',\n"
. " dateFormat: '" . Xml::escapeJsString( wfMsg( 'semanticformsinputs-dateformatshort' ) ) . "',\n"
. " firstDay: '" . Xml::escapeJsString( wfMsg( 'semanticformsinputs-firstdayofweek' ) ) . "',\n"
. " isRTL: " . ( $wgLang->isRTL() ? "true" : "false" ) . ",\n"
. " showMonthAfterYear: false,\n"
. " yearSuffix: ''};\n"
. " jQuery.datepicker.setDefaults(jQuery.datepicker.regional['wiki']);\n"
. "});\n";
$wgOut->addScript( Html::inlineScript( $jstext ) );
}
}
示例12: getAjaxPlaceholder
function getAjaxPlaceholder($attributes, $pageopt)
{
global $wgUser, $wgPlayerExtensionPath, $wgUseAjax;
$sk = $wgUser->getSkin();
$this->assertAllowedType();
if ($pageopt) {
$pagequery = "options=" . urlencode(urlencodeMap($pageopt));
} else {
$pagequery = '';
}
$sptitle = $this->getPlayerTitle();
$spurl = $sptitle->getLocalURL($pagequery);
$ajaxopt = $this->options;
$ajaxopt['width'] = $this->width;
$ajaxopt['height'] = $this->height;
unset($ajaxopt['caption']);
$ajaxopt = urlencodeMap($ajaxopt);
if ($wgUseAjax) {
$js = ' this.href="javascript:void(0);"; loadPlayer("' . Xml::escapeJsString($this->title->getDBkey()) . '", "' . Xml::escapeJsString($ajaxopt) . '", "' . Xml::escapeJsString($this->uniq) . '");';
} else {
$js = '';
}
$alt = htmlspecialchars(wfMsg('player-clicktoplay', $this->title->getText()));
$blank = "<img src=\"{$wgPlayerExtensionPath}/blank.gif\" width=\"{$this->width}\" height=\"{$this->height}\" border=\"0\" alt=\"{$alt}\" class=\"thumbimage\" style=\"width:{$this->width} ! important; height:{$this->height} ! important;\"/>";
$thumbstyle = '';
$thumbimg = null;
$thumbname = @$attributes['thumb'];
if ($thumbname) {
$thumbimg = wfFindFile($thumbname);
}
if ($thumbimg && $thumbimg->exists()) {
$tni = $thumbimg->transform(array('width' => $this->width, 'height' => $this->height), 0);
if ($tni) {
$thumbstyle = 'background-image:url(' . $tni->getUrl() . '); background-position:center; background-repeat:no-repeat; text-decoration:none;';
}
}
$placeholder = '<a href="' . htmlspecialchars($spurl) . '" onclick="' . htmlspecialchars($js) . '" title="' . $alt . '" class="internal" style="display:block; ' . $thumbstyle . '">' . $blank . '</a>';
$overlay = "<a id=\"{$this->uniq}-overlay\" href=\"" . htmlspecialchars($spurl) . "\" onclick=\"" . htmlspecialchars($js) . "\" title=\"{$alt}\" class=\"internal\" style=\"display:block; position:absolute; top:0; left:0; width:{$this->width}; height:{$this->height}; background-image:url({$wgPlayerExtensionPath}/play.gif); background-position:center; background-repeat:no-repeat; text-decoration:none; \">" . $blank . "</a>";
return "<div style='position:relative; width:{$this->width}; height:{$this->height};'>{$placeholder} {$overlay}</div>";
}
示例13: showRedirectedFromHeader
/**
* If this request is a redirect view, send "redirected from" subtitle to
* $wgOut. Returns true if the header was needed, false if this is not a
* redirect view. Handles both local and remote redirects.
*
* @return boolean
*/
public function showRedirectedFromHeader()
{
global $wgOut, $wgUser, $wgRequest, $wgRedirectSources;
$rdfrom = $wgRequest->getVal('rdfrom');
$sk = $wgUser->getSkin();
if (isset($this->mRedirectedFrom)) {
// This is an internally redirected page view.
// We'll need a backlink to the source page for navigation.
if (wfRunHooks('ArticleViewRedirect', array(&$this))) {
$redir = $sk->link($this->mRedirectedFrom, null, array(), array('redirect' => 'no'), array('known', 'noclasses'));
$s = wfMsgExt('redirectedfrom', array('parseinline', 'replaceafter'), $redir);
$wgOut->setSubtitle($s);
// Set the fragment if one was specified in the redirect
if (strval($this->mTitle->getFragment()) != '') {
$fragment = Xml::escapeJsString($this->mTitle->getFragmentForURL());
$wgOut->addInlineScript("redirectToFragment(\"{$fragment}\");");
}
// Add a <link rel="canonical"> tag
$wgOut->addLink(array('rel' => 'canonical', 'href' => $this->mTitle->getLocalURL()));
return true;
}
} elseif ($rdfrom) {
// This is an externally redirected view, from some other wiki.
// If it was reported from a trusted site, supply a backlink.
if ($wgRedirectSources && preg_match($wgRedirectSources, $rdfrom)) {
$redir = $sk->makeExternalLink($rdfrom, $rdfrom);
$s = wfMsgExt('redirectedfrom', array('parseinline', 'replaceafter'), $redir);
$wgOut->setSubtitle($s);
return true;
}
}
return false;
}
示例14: wfDismissableSiteNotice
function wfDismissableSiteNotice(&$notice)
{
global $wgMajorSiteNoticeID, $wgUser;
if (!$notice) {
return true;
}
wfLoadExtensionMessages('DismissableSiteNotice');
$encNotice = Xml::escapeJsString($notice);
$encClose = Xml::escapeJsString(wfMsg('sitenotice_close'));
$id = intval($wgMajorSiteNoticeID) . "." . intval(wfMsgForContent('sitenotice_id'));
// No dismissal for anons
if ($wgUser->isAnon()) {
$notice = <<<EOT
<script type="text/javascript" language="JavaScript">
<!--
document.writeln("{$encNotice}");
-->
</script>
EOT;
return true;
}
$notice = <<<EOT
<script type="text/javascript" language="JavaScript">
<!--
var cookieName = "dismissSiteNotice=";
var cookiePos = document.cookie.indexOf(cookieName);
var siteNoticeID = "{$id}";
var siteNoticeValue = "{$encNotice}";
var cookieValue = "";
var msgClose = "{$encClose}";
if (cookiePos > -1) {
\tcookiePos = cookiePos + cookieName.length;
\tvar endPos = document.cookie.indexOf(";", cookiePos);
\tif (endPos > -1) {
\t\tcookieValue = document.cookie.substring(cookiePos, endPos);
\t} else {
\t\tcookieValue = document.cookie.substring(cookiePos);
\t}
}
if (cookieValue != siteNoticeID) {
\tfunction dismissNotice() {
\t\tvar date = new Date();
\t\tdate.setTime(date.getTime() + 30*86400*1000);
\t\tdocument.cookie = cookieName + siteNoticeID + "; expires="+date.toGMTString() + "; path=/";
\t\tvar element = document.getElementById('siteNotice');
\t\telement.parentNode.removeChild(element);
\t}
\tdocument.writeln('<table width="100%" id="mw-dismissable-notice"><tr><td width="80%">'+siteNoticeValue+'</td>');
\tdocument.writeln('<td width="20%" align="right">[<a href="javascript:dismissNotice();">'+msgClose+'</a>]</td></tr></table>');
}
-->
</script>
EOT;
// Compact the string a bit
/*
$notice = strtr( $notice, array(
"\r\n" => '',
"\n" => '',
"\t" => '',
'cookieName' => 'n',
'cookiePos' => 'p',
'siteNoticeID' => 'i',
'siteNoticeValue' => 'sv',
'cookieValue' => 'cv',
'msgClose' => 'c',
'endPos' => 'e',
));*/
return true;
}
示例15: testEscapeJsStringSpecialChars
/**
* @covers Xml::escapeJsString
*/
public function testEscapeJsStringSpecialChars()
{
$this->assertEquals('\\\\\\r\\n', Xml::escapeJsString("\\\r\n"), 'escapeJsString() with special characters');
}