本文整理汇总了PHP中Skin::makeVariablesScript方法的典型用法代码示例。如果您正苦于以下问题:PHP Skin::makeVariablesScript方法的具体用法?PHP Skin::makeVariablesScript怎么用?PHP Skin::makeVariablesScript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Skin
的用法示例。
在下文中一共展示了Skin::makeVariablesScript方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFormatOutput
/**
* Prepare data output
*
* @since 1.8
*
* @param array $data label => value
*/
protected function getFormatOutput(array $data)
{
//Init
$dataObject = array();
static $statNr = 0;
$chartID = 'sparkline-' . $this->params['charttype'] . '-' . ++$statNr;
$this->isHTML = true;
// Prepare data array
foreach ($data as $key => $value) {
if ($value >= $this->params['min']) {
$dataObject['label'][] = $key;
$dataObject['value'][] = $value;
}
}
$dataObject['charttype'] = $this->params['charttype'];
// Encode data objects
$requireHeadItem = array($chartID => FormatJson::encode($dataObject));
SMWOutputs::requireHeadItem($chartID, Skin::makeVariablesScript($requireHeadItem));
// RL module
SMWOutputs::requireResource('ext.srf.sparkline');
// Processing placeholder
$processing = SRFUtils::htmlProcessingElement(false);
// Chart/graph placeholder
$chart = Html::rawElement('div', array('id' => $chartID, 'class' => 'container', 'style' => "display:none;"), null);
// Beautify class selector
$class = $this->params['class'] ? ' ' . $this->params['class'] : '';
// Chart/graph wrappper
return Html::rawElement('span', array('class' => 'srf-sparkline' . $class), $processing . $chart);
}
示例2: getFormatOutput
/**
* @see SMWResultPrinter::getFormatOutput
*
* @since 1.8
*
* @param array $data label => value
* @return string
*/
protected function getFormatOutput(array $data)
{
// Object count
static $statNr = 0;
$d3chartID = 'd3-chart-' . ++$statNr;
$this->isHTML = true;
// Reorganize the raw data
foreach ($data as $name => $value) {
if ($value >= $this->params['min']) {
$dataObject[] = array('label' => $name, 'value' => $value);
}
}
// Ensure right conversion
$width = strstr($this->params['width'], "%") ? $this->params['width'] : $this->params['width'] . 'px';
// Prepare transfer objects
$d3data = array('data' => $dataObject, 'parameters' => array('colorscheme' => $this->params['colorscheme'] ? $this->params['colorscheme'] : null, 'charttitle' => $this->params['charttitle'], 'charttext' => $this->params['charttext'], 'datalabels' => $this->params['datalabels']));
// Encoding
$requireHeadItem = array($d3chartID => FormatJson::encode($d3data));
SMWOutputs::requireHeadItem($d3chartID, Skin::makeVariablesScript($requireHeadItem));
// RL module
$resource = 'ext.srf.d3.chart.' . $this->params['charttype'];
SMWOutputs::requireResource($resource);
// Chart/graph placeholder
$chart = Html::rawElement('div', array('id' => $d3chartID, 'class' => 'container', 'style' => 'display:none;'), null);
// Processing placeholder
$processing = SRFUtils::htmlProcessingElement($this->isHTML);
// Beautify class selector
$class = $this->params['charttype'] ? '-' . $this->params['charttype'] : '';
$class = $this->params['class'] ? $class . ' ' . $this->params['class'] : $class . ' d3-chart-common';
// D3 wrappper
return Html::rawElement('div', array('class' => 'srf-d3-chart' . $class, 'style' => "width:{$width}; height:{$this->params['height']}px;"), $processing . $chart);
}
示例3: getFormatOutput
/**
* Prepare data output
*
* @since 1.8
*
* @param array $data label => value
*/
protected function getFormatOutput(array $data)
{
static $statNr = 0;
$chartID = 'jqplot-' . $this->params['charttype'] . '-' . ++$statNr;
$this->isHTML = true;
// Prepare data objects
if (in_array($this->params['charttype'], array('bar', 'line'))) {
// Parse bar relevant data
$dataObject = $this->prepareBarData($data);
} elseif (in_array($this->params['charttype'], array('pie', 'donut'))) {
//Parse pie/donut relevant data
$dataObject = $this->preparePieData($data);
} else {
// Return with an error
return Html::rawElement('span', array('class' => "error"), wfMessage('srf-error-missing-layout')->inContentLanguage()->text());
}
// Encode data objects
$requireHeadItem = array($chartID => FormatJson::encode($dataObject));
SMWOutputs::requireHeadItem($chartID, Skin::makeVariablesScript($requireHeadItem));
// Processing placeholder
$processing = SRFUtils::htmlProcessingElement($this->isHTML);
// Ensure right conversion
$width = strstr($this->params['width'], "%") ? $this->params['width'] : $this->params['width'] . 'px';
// Chart/graph placeholder
$chart = Html::rawElement('div', array('id' => $chartID, 'class' => 'container', 'style' => "display:none; width: {$width}; height: {$this->params['height']}px;"), null);
// Beautify class selector
$class = $this->params['charttype'] ? '-' . $this->params['charttype'] : '';
$class = $this->params['class'] ? $class . ' ' . $this->params['class'] : $class . ' jqplot-common';
// Chart/graph wrappper
return Html::rawElement('div', array('class' => 'srf-jqplot' . $class), $processing . $chart);
}
示例4: render
/**
* Renrder the survey div.
*
* @since 0.1
*
* @param Parser $parser
*
* @return string
*/
public function render(Parser $parser)
{
static $loadedJs = false;
if (!$loadedJs) {
$parser->getOutput()->addModules('ext.survey.tag');
$parser->getOutput()->addHeadItem(Skin::makeVariablesScript(array('wgSurveyDebug' => SurveySettings::get('JSDebug'))));
}
return Html::element('span', $this->parameters, $this->contents);
}
示例5: renderMap
/**
* Handles the request from the parser hook by doing the work that's common for all
* mapping services, calling the specific methods and finally returning the resulting output.
*
* @param array $params
* @param Parser $parser
*
* @return html
*/
public final function renderMap(array $params, Parser $parser)
{
$this->handleMarkerData($params, $parser);
$mapName = $this->service->getMapId();
$output = $this->getMapHTML($params, $parser, $mapName);
$configVars = Skin::makeVariablesScript($this->service->getConfigVariables());
$this->service->addDependencies($parser);
$parser->getOutput()->addHeadItem($configVars);
return $output;
}
示例6: includeAssets
public function includeAssets() {
global $wgOut;
TranslationHelpers::addModules( $wgOut );
$pages = array();
foreach ( $this->collection->getTitles() as $title ) {
$pages[] = $title->getPrefixedDBKey();
}
$vars = array( 'trlKeys' => $pages );
$wgOut->addScript( Skin::makeVariablesScript( $vars ) );
$wgOut->addModules( 'ext.translate.messagetable' );
}
示例7: index
public function index()
{
$this->checkGameAllowed();
//AppCache disabled for now, it generates more problems than expected
//$this->response->setVal( 'appCacheManifestPath', self::CACHE_MANIFEST_PATH . "&cb={$this->wg->CacheBuster}" );//$this->wg->StyleVersion
//Minimize the output size, we don't need all the global variables being exported in MW
$jsMsg = F::build('JSMessages');
$jsMsg->enqueuePackage(self::JS_MESSAGES_PACKAGE, JSMessages::INLINE);
$jsVars = array('wgCacheBuster' => $this->wg->CacheBuster, 'wgMessages' => $jsMsg->getPackages(array(self::JS_MESSAGES_PACKAGE)));
//getting WikiaTracker global JS vars
F::build('WikiaTrackerController')->onMakeGlobalVariablesScript($jsVars);
$this->response->setVal('globalVariablesScript', Skin::makeVariablesScript($jsVars));
$this->response->setVal('scripts', AssetsManager::getInstance()->getGroupCommonURL('photopop'));
$this->response->setVal('dataMain', $this->wg->ExtensionsPath . '/wikia/PhotoPop/shared/lib/main');
$this->response->setVal('cssLink', AssetsManager::getInstance()->getOneCommonURL("extensions/wikia/PhotoPop/shared/css/homescreen.css"));
$this->response->setVal('trackingCode', AnalyticsEngine::track('GA_Urchin', AnalyticsEngine::EVENT_PAGEVIEW));
}
示例8: renderMap
/**
* Handles the request from the parser hook by doing the work that's common for all
* mapping services, calling the specific methods and finally returning the resulting output.
*
* @param array $params
* @param Parser $parser
*
* @return html
*/
public final function renderMap(array $params, Parser $parser)
{
$this->handleMarkerData($params, $parser);
$mapName = $this->service->getMapId();
$output = $this->getMapHTML($params, $parser, $mapName) . $this->getJSON($params, $parser, $mapName);
$configVars = Skin::makeVariablesScript($this->service->getConfigVariables());
// MediaWiki 1.17 does not play nice with addScript, so add the vars via the globals hook.
if (version_compare($GLOBALS['wgVersion'], '1.18', '<')) {
$GLOBALS['egMapsGlobalJSVars'] += $this->service->getConfigVariables();
}
global $wgTitle;
if (!is_null($wgTitle) && $wgTitle->isSpecialPage()) {
global $wgOut;
$this->service->addDependencies($wgOut);
$wgOut->addScript($configVars);
} else {
$this->service->addDependencies($parser);
$parser->getOutput()->addHeadItem($configVars);
}
return $output;
}
示例9: showTranslations
/**
* Builds a table with all translations of $title.
*
* @param $title Title (default: null)
* @return void
*/
function showTranslations(Title $title)
{
global $wgOut, $wgUser, $wgLang;
$sk = $wgUser->getSkin();
$namespace = $title->getNamespace();
$message = $title->getDBkey();
$inMessageGroup = TranslateUtils::messageKeyToGroup($title->getNamespace(), $title->getText());
if (!$inMessageGroup) {
$wgOut->addWikiMsg('translate-translations-no-message', $title->getPrefixedText());
return;
}
$dbr = wfGetDB(DB_SLAVE);
$res = $dbr->select('page', array('page_namespace', 'page_title'), array('page_namespace' => $namespace, 'page_title ' . $dbr->buildLike("{$message}/", $dbr->anyString())), __METHOD__, array('ORDER BY' => 'page_title', 'USE INDEX' => 'name_title'));
if (!$res->numRows()) {
$wgOut->addWikiMsg('translate-translations-no-message', $title->getPrefixedText());
return;
} else {
$wgOut->addWikiMsg('translate-translations-count', $wgLang->formatNum($res->numRows()));
}
// Normal output.
$titles = array();
foreach ($res as $s) {
$titles[] = $s->page_title;
}
$pageInfo = TranslateUtils::getContents($titles, $namespace);
$tableheader = Xml::openElement('table', array('class' => 'mw-sp-translate-table sortable'));
$tableheader .= Xml::openElement('tr');
$tableheader .= Xml::element('th', null, wfMsg('allmessagesname'));
$tableheader .= Xml::element('th', null, wfMsg('allmessagescurrent'));
$tableheader .= Xml::closeElement('tr');
// Adapted version of TranslateUtils:makeListing() by Nikerabbit.
$out = $tableheader;
$canTranslate = $wgUser->isAllowed('translate');
$ajaxPageList = array();
$historyText = " <sup>" . wfMsgHtml('translate-translations-history-short') . "</sup> ";
foreach ($res as $s) {
$key = $s->page_title;
$tTitle = Title::makeTitle($s->page_namespace, $key);
$ajaxPageList[] = $tTitle->getPrefixedDBkey();
$code = $this->getCode($s->page_title);
$text = TranslateUtils::getLanguageName($code, false, $wgLang->getCode()) . " ({$code})";
$text = htmlspecialchars($text);
if ($canTranslate) {
$tools['edit'] = TranslationHelpers::ajaxEditLink($tTitle, $text);
} else {
$tools['edit'] = $sk->link($tTitle, $text);
}
$tools['history'] = $sk->link($tTitle, $historyText, array('action', 'title' => wfMsg('history-title', $tTitle->getPrefixedDBkey())), array('action' => 'history'));
if (TranslateEditAddons::isFuzzy($tTitle)) {
$class = 'orig';
} else {
$class = 'def';
}
$leftColumn = $tools['history'] . $tools['edit'];
$out .= Xml::tags('tr', array('class' => $class), Xml::tags('td', null, $leftColumn) . Xml::tags('td', array('lang' => $code, 'dir' => Language::factory($code)->getDir()), TranslateUtils::convertWhiteSpaceToHTML($pageInfo[$key][0])));
}
$out .= Xml::closeElement('table');
$wgOut->addHTML($out);
$vars = array('trlKeys' => $ajaxPageList);
$wgOut->addScript(Skin::makeVariablesScript($vars));
}
示例10: execute
/**
* Execute the subpage.
* @param $params array Array of subpage parameters.
*/
function execute( $params ) {
global $wgOut, $wgUser, $wgStylePath;
if ( !count( $params ) ) {
$wgOut->addWikiMsg( 'securepoll-too-few-params' );
return;
}
$electionId = intval( $params[0] );
$this->election = $this->context->getElection( $electionId );
if ( !$this->election ) {
$wgOut->addWikiMsg( 'securepoll-invalid-election', $electionId );
return;
}
$this->initLanguage( $wgUser, $this->election );
$wgOut->setPageTitle( wfMsg(
'securepoll-list-title', $this->election->getMessage( 'title' ) ) );
$pager = new SecurePoll_ListPager( $this );
$wgOut->addHTML(
$pager->getLimitForm() .
$pager->getNavigationBar() .
$pager->getBody() .
$pager->getNavigationBar()
);
if ( $this->election->isAdmin( $wgUser ) ) {
$msgStrike = wfMsgHtml( 'securepoll-strike-button' );
$msgUnstrike = wfMsgHtml( 'securepoll-unstrike-button' );
$msgCancel = wfMsgHtml( 'securepoll-strike-cancel' );
$msgReason = wfMsgHtml( 'securepoll-strike-reason' );
$encAction = htmlspecialchars( $this->getTitle()->getLocalUrl() );
$encSpinner = htmlspecialchars( "$wgStylePath/common/images/spinner.gif" );
$script = Skin::makeVariablesScript( array(
'securepoll_strike_button' => wfMsg( 'securepoll-strike-button' ),
'securepoll_unstrike_button' => wfMsg( 'securepoll-unstrike-button' )
) );
$wgOut->addHTML( <<<EOT
$script
<div class="securepoll-popup" id="securepoll-popup">
<form id="securepoll-strike-form" action="$encAction" method="post" onsubmit="securepoll_strike('submit');return false;">
<input type="hidden" id="securepoll-vote-id" name="vote_id" value=""/>
<input type="hidden" id="securepoll-action" name="action" value=""/>
<label for="securepoll-strike-reason">{$msgReason}</label>
<input type="text" size="45" id="securepoll-strike-reason"/>
<p>
<input class="securepoll-confirm-button" type="button" value="$msgCancel"
onclick="securepoll_strike('cancel');"/>
<input class="securepoll-confirm-button" id="securepoll-strike-button"
type="button" value="$msgStrike" onclick="securepoll_strike('strike');" />
<input class="securepoll-confirm-button" id="securepoll-unstrike-button"
type="button" value="$msgUnstrike" onclick="securepoll_strike('unstrike');" />
</p>
</form>
<div id="securepoll-strike-result"></div>
<div id="securepoll-strike-spinner"><img src="$encSpinner"/></div>
</div>
EOT
);
}
}
示例11: getFormatOutput
/**
* Prepare data for the output
*
* @since 1.8
*
* @param array $data
*
* @return string
*/
protected function getFormatOutput(array $data, $options)
{
// Object count
static $statNr = 0;
$chartID = 'timeseries-' . ++$statNr;
$this->isHTML = true;
// Reorganize the raw data
foreach ($data as $key => $values) {
$dataObject[] = array('label' => $key, 'data' => $values);
}
// Series colour
$seriescolors = $this->params['chartcolor'] !== '' ? array_filter(explode(",", $this->params['chartcolor'])) : array();
// Prepare transfer array
$chartData = array('data' => $dataObject, 'fcolumntypeid' => '_dat', 'sask' => $options['sask'], 'parameters' => array('width' => $this->params['width'], 'height' => $this->params['height'], 'charttitle' => $this->params['charttitle'], 'charttext' => $this->params['charttext'], 'infotext' => $this->params['infotext'], 'charttype' => $this->params['charttype'], 'gridview' => $this->params['gridview'], 'zoom' => $this->params['zoompane'], 'seriescolors' => $seriescolors));
// Array encoding and output
$requireHeadItem = array($chartID => FormatJson::encode($chartData));
SMWOutputs::requireHeadItem($chartID, Skin::makeVariablesScript($requireHeadItem));
// RL module
SMWOutputs::requireResource('ext.srf.timeseries.flot');
if ($this->params['gridview'] === 'tabs') {
SMWOutputs::requireResource('ext.srf.util.grid');
}
// Chart/graph placeholder
$chart = Html::rawElement('div', array('id' => $chartID, 'class' => 'container', 'style' => "display:none;"), null);
// Processing/loading image
$processing = SRFUtils::htmlProcessingElement($this->isHTML);
// Beautify class selector
$class = $this->params['class'] ? ' ' . $this->params['class'] : ' flot-chart-common';
// General output marker
return Html::rawElement('div', array('class' => 'srf-timeseries' . $class), $processing . $chart);
}
示例12: getResultText
/**
* Builds up and returns the HTML for the map, with the queried coordinate data on it.
*
* @param SMWQueryResult $res
* @param $outputmode
*
* @return array or string
*/
public final function getResultText(SMWQueryResult $res, $outputmode)
{
if ($this->fatalErrorMsg !== false) {
return $this->fatalErrorMsg;
}
/**
* @var Parser $wgParser
*/
global $wgParser;
$params = $this->params;
$queryHandler = new SMQueryHandler($res, $outputmode);
$queryHandler->setLinkStyle($params['link']);
$queryHandler->setHeaderStyle($params['headers']);
$queryHandler->setShowSubject($params['showtitle']);
$queryHandler->setTemplate($params['template']);
$queryHandler->setHideNamespace($params['hidenamespace']);
$queryHandler->setActiveIcon($params['activeicon']);
$this->handleMarkerData($params, $queryHandler);
$locationAmount = count($params['locations']);
if ($locationAmount > 0) {
// We can only take care of the zoom defaulting here,
// as not all locations are available in whats passed to Validator.
if ($this->fullParams['zoom']->wasSetToDefault() && $locationAmount > 1) {
$params['zoom'] = false;
}
$mapName = $this->service->getMapId();
SMWOutputs::requireHeadItem($mapName, $this->service->getDependencyHtml() . ($configVars = Skin::makeVariablesScript($this->service->getConfigVariables())));
foreach ($this->service->getResourceModules() as $resourceModule) {
SMWOutputs::requireResource($resourceModule);
}
if (array_key_exists('source', $params)) {
unset($params['source']);
}
return $this->getMapHTML($params, $wgParser, $mapName);
} else {
return $params['default'];
}
}
示例13: addUploadJS
/**
* Add upload JS to $wgOut
*
* @param bool $autofill Whether or not to autofill the destination
* filename text box
*/
protected function addUploadJS()
{
global $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview, $wgEnableAPI;
global $wgOut;
$useAjaxDestCheck = $wgUseAjax && $wgAjaxUploadDestCheck;
$useAjaxLicensePreview = $wgUseAjax && $wgAjaxLicensePreview && $wgEnableAPI;
$scriptVars = array('wgAjaxUploadDestCheck' => $useAjaxDestCheck, 'wgAjaxLicensePreview' => $useAjaxLicensePreview, 'wgUploadAutoFill' => !$this->mForReUpload && $this->mDestFile === '', 'wgUploadSourceIds' => $this->mSourceIds);
$wgOut->addScript(Skin::makeVariablesScript($scriptVars));
// For <charinsert> support
$wgOut->addScriptFile('edit.js');
$wgOut->addScriptFile('upload.js');
}
示例14: addUploadJS
/**
* Add upload JavaScript to $wgOut
*/
protected function addUploadJS()
{
global $wgExtensionsPath, $wgFileExtensions;
global $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview, $wgEnableAPI;
$useAjaxDestCheck = $wgUseAjax && $wgAjaxUploadDestCheck;
$useAjaxLicensePreview = $wgUseAjax && $wgAjaxLicensePreview && $wgEnableAPI;
$scriptVars = array('wgAjaxUploadDestCheck' => $useAjaxDestCheck, 'wgAjaxLicensePreview' => $useAjaxLicensePreview, 'wgUploadAutoFill' => !$this->mForReUpload && $this->mDestFile === '', 'wgUploadSourceIds' => $this->mSourceIds);
$out = $this->getOutput();
$out->addScript(Skin::makeVariablesScript($scriptVars));
// changed
$out->addScriptFile("{$wgExtensionsPath}/MultiUpload/multiupload.js");
$newscriptVars = array('wgMaxUploadFiles' => MultipleUpload::getMaxUploadFiles(), 'wgFileExtensions' => $wgFileExtensions);
$out->addScript(Skin::makeVariablesScript($newscriptVars));
}
示例15: addJsVars
/**
* Adds some global variables for our use, as well as initializes the UploadWizard
*
* TODO once bug https://bugzilla.wikimedia.org/show_bug.cgi?id=26901
* is fixed we should package configuration with the upload wizard instead of
* in uploadWizard output page.
*
* @param subpage, e.g. the "foo" in Special:UploadWizard/foo
*/
public function addJsVars($subPage)
{
global $wgSitename;
$config = UploadWizardConfig::getConfig($this->campaign);
$labelPageContent = $this->getPageContent($config['idFieldLabelPage']);
if ($labelPageContent !== false) {
$config['idFieldLabel'] = $labelPageContent;
}
$config['thanksLabel'] = $this->getPageContent($config['thanksLabelPage'], true);
$defaultLicense = $this->getUser()->getGlobalPreference('upwiz_deflicense');
if ($defaultLicense !== 'default') {
$defaultLicense = explode('-', $defaultLicense, 2);
$licenseType = $defaultLicense[0];
$defaultLicense = $defaultLicense[1];
if (in_array($defaultLicense, $config['licensesOwnWork']['licenses']) || in_array($defaultLicense, UploadWizardConfig::getThirdPartyLicenses())) {
$licenseGroup = $licenseType === 'ownwork' ? 'licensesOwnWork' : 'licensesThirdParty';
$config[$licenseGroup]['defaults'] = array($defaultLicense);
$config['defaultLicenseType'] = $licenseType;
}
}
$this->getOutput()->addScript(Skin::makeVariablesScript(array('UploadWizardConfig' => $config) + array('wgSiteName' => $wgSitename)));
}