本文整理汇总了PHP中wfBoolToStr函数的典型用法代码示例。如果您正苦于以下问题:PHP wfBoolToStr函数的具体用法?PHP wfBoolToStr怎么用?PHP wfBoolToStr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfBoolToStr函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
function show( $string, $value ) {
if ( $value === null ) {
$value = 'null';
} elseif ( is_bool( $value ) ) {
$value = wfBoolToStr( $value );
} else {
$value = htmlspecialchars( $value );
}
return Html::openElement( 'tr' ) .
Html::openElement( 'td' ) . $string . Html::closeElement( 'td' ) .
Html::openElement( 'td' ) . $value . Html::closeElement( 'td' ) .
Html::closeElement( 'tr' ) . "\n";
}
示例2: formatRsdApiList
/**
* Formats the internal list of exposed APIs into an array suitable
* to pass to the API's XML formatter.
*
* @return array
*/
protected function formatRsdApiList()
{
$apis = $this->getRsdApiList();
$outputData = array();
foreach ($apis as $name => $info) {
$data = array('name' => $name, 'preferred' => wfBoolToStr($name == 'MediaWiki'), 'apiLink' => $info['apiLink'], 'blogID' => isset($info['blogID']) ? $info['blogID'] : '');
$settings = array();
if (isset($info['docs'])) {
$settings['docs'] = $info['docs'];
ApiResult::setSubelementsList($settings, 'docs');
}
if (isset($info['settings'])) {
foreach ($info['settings'] as $setting => $val) {
if (is_bool($val)) {
$xmlVal = wfBoolToStr($val);
} else {
$xmlVal = $val;
}
$setting = array('name' => $setting);
ApiResult::setContentValue($setting, 'value', $xmlVal);
$settings[] = $setting;
}
}
if (count($settings)) {
ApiResult::setIndexedTagName($settings, 'setting');
$data['settings'] = $settings;
}
$outputData[] = $data;
}
return $outputData;
}
示例3: getDefaultText
/**
* @return string
*/
protected function getDefaultText()
{
if (!$this->values['wgImageMagickConvertCommand']) {
$this->values['wgImageMagickConvertCommand'] = '/usr/bin/convert';
$magic = '#';
} else {
$magic = '';
}
if (!$this->values['wgShellLocale']) {
$this->values['wgShellLocale'] = 'en_US.UTF-8';
$locale = '#';
} else {
$locale = '';
}
$hashedUploads = $this->safeMode ? '' : '#';
$metaNamespace = '';
if ($this->values['wgMetaNamespace'] !== $this->values['wgSitename']) {
$metaNamespace = "\$wgMetaNamespace = \"{$this->values['wgMetaNamespace']}\";\n";
}
$groupRights = '';
$noFollow = '';
if ($this->groupPermissions) {
$groupRights .= "# The following permissions were set based on your choice in the installer\n";
foreach ($this->groupPermissions as $group => $rightArr) {
$group = self::escapePhpString($group);
foreach ($rightArr as $right => $perm) {
$right = self::escapePhpString($right);
$groupRights .= "\$wgGroupPermissions['{$group}']['{$right}'] = " . wfBoolToStr($perm) . ";\n";
}
}
$groupRights .= "\n";
if (isset($this->groupPermissions['*']['edit']) && $this->groupPermissions['*']['edit'] === false && (isset($this->groupPermissions['*']['createaccount']) && $this->groupPermissions['*']['createaccount'] === false) && (isset($this->groupPermissions['*']['read']) && $this->groupPermissions['*']['read'] !== false)) {
$noFollow = "# Set \$wgNoFollowLinks to true if you open up your wiki to editing by\n" . "# the general public and wish to apply nofollow to external links as a\n" . "# deterrent to spammers. Nofollow is not a comprehensive anti-spam solution\n" . "# and open wikis will generally require other anti-spam measures; for more\n" . "# information, see https://www.mediawiki.org/wiki/Manual:Combating_spam\n" . "\$wgNoFollowLinks = false;\n\n";
}
}
$serverSetting = "";
if (array_key_exists('wgServer', $this->values) && $this->values['wgServer'] !== null) {
$serverSetting = "\n## The protocol and server name to use in fully-qualified URLs\n";
$serverSetting .= "\$wgServer = \"{$this->values['wgServer']}\";\n";
}
switch ($this->values['wgMainCacheType']) {
case 'anything':
case 'db':
case 'memcached':
case 'accel':
$cacheType = 'CACHE_' . strtoupper($this->values['wgMainCacheType']);
break;
case 'none':
default:
$cacheType = 'CACHE_NONE';
}
$mcservers = $this->buildMemcachedServerList();
return "<?php\n# This file was automatically generated by the MediaWiki {$GLOBALS['wgVersion']}\n# installer. If you make manual changes, please keep track in case you\n# need to recreate them later.\n#\n# See includes/DefaultSettings.php for all configurable settings\n# and their default values, but don't forget to make changes in _this_\n# file, not there.\n#\n# Further documentation for configuration settings may be found at:\n# https://www.mediawiki.org/wiki/Manual:Configuration_settings\n\n# Protect against web entry\nif ( !defined( 'MEDIAWIKI' ) ) {\n\texit;\n}\n\n## Uncomment this to disable output compression\n# \$wgDisableOutputCompression = true;\n\n\$wgSitename = \"{$this->values['wgSitename']}\";\n{$metaNamespace}\n## The URL base path to the directory containing the wiki;\n## defaults for all runtime URL paths are based off of this.\n## For more information on customizing the URLs\n## (like /w/index.php/Page_title to /wiki/Page_title) please see:\n## https://www.mediawiki.org/wiki/Manual:Short_URL\n\$wgScriptPath = \"{$this->values['wgScriptPath']}\";\n{$serverSetting}\n\n## The relative URL path to the logo. Make sure you change this from the default,\n## or else you'll overwrite your logo when you upgrade!\n\$wgLogo = \"{$this->values['wgLogo']}\";\n\n## UPO means: this is also a user preference option\n\n\$wgEnableEmail = {$this->values['wgEnableEmail']};\n\$wgEnableUserEmail = {$this->values['wgEnableUserEmail']}; # UPO\n\n\$wgEmergencyContact = \"{$this->values['wgEmergencyContact']}\";\n\$wgPasswordSender = \"{$this->values['wgPasswordSender']}\";\n\n\$wgEnotifUserTalk = {$this->values['wgEnotifUserTalk']}; # UPO\n\$wgEnotifWatchlist = {$this->values['wgEnotifWatchlist']}; # UPO\n\$wgEmailAuthentication = {$this->values['wgEmailAuthentication']};\n\n## Database settings\n\$wgDBtype = \"{$this->values['wgDBtype']}\";\n\$wgDBserver = \"{$this->values['wgDBserver']}\";\n\$wgDBname = \"{$this->values['wgDBname']}\";\n\$wgDBuser = \"{$this->values['wgDBuser']}\";\n\$wgDBpassword = \"{$this->values['wgDBpassword']}\";\n\n{$this->dbSettings}\n\n## Shared memory settings\n\$wgMainCacheType = {$cacheType};\n\$wgMemCachedServers = {$mcservers};\n\n## To enable image uploads, make sure the 'images' directory\n## is writable, then set this to true:\n\$wgEnableUploads = {$this->values['wgEnableUploads']};\n{$magic}\$wgUseImageMagick = true;\n{$magic}\$wgImageMagickConvertCommand = \"{$this->values['wgImageMagickConvertCommand']}\";\n\n# InstantCommons allows wiki to use images from https://commons.wikimedia.org\n\$wgUseInstantCommons = {$this->values['wgUseInstantCommons']};\n\n## If you use ImageMagick (or any other shell command) on a\n## Linux server, this will need to be set to the name of an\n## available UTF-8 locale\n{$locale}\$wgShellLocale = \"{$this->values['wgShellLocale']}\";\n\n## If you want to use image uploads under safe mode,\n## create the directories images/archive, images/thumb and\n## images/temp, and make them all writable. Then uncomment\n## this, if it's not already uncommented:\n{$hashedUploads}\$wgHashedUploadDirectory = false;\n\n## Set \$wgCacheDirectory to a writable directory on the web server\n## to make your wiki go slightly faster. The directory should not\n## be publically accessible from the web.\n#\$wgCacheDirectory = \"\$IP/cache\";\n\n# Site language code, should be one of the list in ./languages/Names.php\n\$wgLanguageCode = \"{$this->values['wgLanguageCode']}\";\n\n\$wgSecretKey = \"{$this->values['wgSecretKey']}\";\n\n# Site upgrade key. Must be set to a string (default provided) to turn on the\n# web installer while LocalSettings.php is in place\n\$wgUpgradeKey = \"{$this->values['wgUpgradeKey']}\";\n\n## For attaching licensing metadata to pages, and displaying an\n## appropriate copyright notice / icon. GNU Free Documentation\n## License and Creative Commons licenses are supported so far.\n\$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright\n\$wgRightsUrl = \"{$this->values['wgRightsUrl']}\";\n\$wgRightsText = \"{$this->values['wgRightsText']}\";\n\$wgRightsIcon = \"{$this->values['wgRightsIcon']}\";\n\n# Path to the GNU diff3 utility. Used for conflict resolution.\n\$wgDiff3 = \"{$this->values['wgDiff3']}\";\n\n{$groupRights}{$noFollow}## Default skin: you can change the default skin. Use the internal symbolic\n## names, ie 'vector', 'monobook':\n\$wgDefaultSkin = \"{$this->values['wgDefaultSkin']}\";\n";
}
示例4: getLocalSettings
public function getLocalSettings()
{
$dbmysql5 = wfBoolToStr($this->getVar('wgDBmysql5', true));
$prefix = LocalSettingsGenerator::escapePhpString($this->getVar('wgDBprefix'));
$tblOpts = LocalSettingsGenerator::escapePhpString($this->getTableOptions());
return "# MySQL specific settings\n\$wgDBprefix = \"{$prefix}\";\n\n# MySQL table options to use during installation or update\n\$wgDBTableOptions = \"{$tblOpts}\";\n\n# Experimental charset support for MySQL 5.0.\n\$wgDBmysql5 = {$dbmysql5};";
}
示例5: testClientAcceptsGzipTest
/**
* @covers ::wfClientAcceptsGzip
*/
public function testClientAcceptsGzipTest()
{
$settings = array('gzip' => true, 'bzip' => false, '*' => false, 'compress, gzip' => true, 'gzip;q=1.0' => true, 'foozip' => false, 'foo*zip' => false, 'gzip;q=abcde' => true, 'gzip;q=12345678.9' => true, ' gzip' => true);
if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
$old_server_setting = $_SERVER['HTTP_ACCEPT_ENCODING'];
}
foreach ($settings as $encoding => $expect) {
$_SERVER['HTTP_ACCEPT_ENCODING'] = $encoding;
$this->assertEquals($expect, wfClientAcceptsGzip(true), "'{$encoding}' => " . wfBoolToStr($expect));
}
if (isset($old_server_setting)) {
$_SERVER['HTTP_ACCEPT_ENCODING'] = $old_server_setting;
}
}
示例6: getDefaultText
/**
* @return String
*/
private function getDefaultText()
{
if (!$this->values['wgImageMagickConvertCommand']) {
$this->values['wgImageMagickConvertCommand'] = '/usr/bin/convert';
$magic = '#';
} else {
$magic = '';
}
if (!$this->values['wgShellLocale']) {
$this->values['wgShellLocale'] = 'en_US.UTF-8';
$locale = '#';
} else {
$locale = '';
}
$rightsUrl = $this->values['wgRightsUrl'] ? '' : '#';
$hashedUploads = $this->safeMode ? '' : '#';
$metaNamespace = '';
if ($this->values['wgMetaNamespace'] !== $this->values['wgSitename']) {
$metaNamespace = "\$wgMetaNamespace = \"{$this->values['wgMetaNamespace']}\";\n";
}
$groupRights = '';
if ($this->groupPermissions) {
$groupRights .= "# The following permissions were set based on your choice in the installer\n";
foreach ($this->groupPermissions as $group => $rightArr) {
$group = self::escapePhpString($group);
foreach ($rightArr as $right => $perm) {
$right = self::escapePhpString($right);
$groupRights .= "\$wgGroupPermissions['{$group}']['{$right}'] = " . wfBoolToStr($perm) . ";\n";
}
}
}
switch ($this->values['wgMainCacheType']) {
case 'anything':
case 'db':
case 'memcached':
case 'accel':
$cacheType = 'CACHE_' . strtoupper($this->values['wgMainCacheType']);
break;
case 'none':
default:
$cacheType = 'CACHE_NONE';
}
$mcservers = $this->buildMemcachedServerList();
return "<?php\n# This file was automatically generated by the MediaWiki {$GLOBALS['wgVersion']}\n# installer. If you make manual changes, please keep track in case you\n# need to recreate them later.\n#\n# See includes/DefaultSettings.php for all configurable settings\n# and their default values, but don't forget to make changes in _this_\n# file, not there.\n#\n# Further documentation for configuration settings may be found at:\n# http://www.mediawiki.org/wiki/Manual:Configuration_settings\n\n# Protect against web entry\nif ( !defined( 'MEDIAWIKI' ) ) {\n\texit;\n}\n\n## Uncomment this to disable output compression\n# \$wgDisableOutputCompression = true;\n\n\$wgSitename = \"{$this->values['wgSitename']}\";\n{$metaNamespace}\n## The URL base path to the directory containing the wiki;\n## defaults for all runtime URL paths are based off of this.\n## For more information on customizing the URLs please see:\n## http://www.mediawiki.org/wiki/Manual:Short_URL\n\$wgScriptPath = \"{$this->values['wgScriptPath']}\";\n\$wgScriptExtension = \"{$this->values['wgScriptExtension']}\";\n\n## The relative URL path to the skins directory\n\$wgStylePath = \"\$wgScriptPath/skins\";\n\n## The relative URL path to the logo. Make sure you change this from the default,\n## or else you'll overwrite your logo when you upgrade!\n\$wgLogo = \"\$wgStylePath/common/images/wiki.png\";\n\n## UPO means: this is also a user preference option\n\n\$wgEnableEmail = {$this->values['wgEnableEmail']};\n\$wgEnableUserEmail = {$this->values['wgEnableUserEmail']}; # UPO\n\n\$wgEmergencyContact = \"{$this->values['wgEmergencyContact']}\";\n\$wgPasswordSender = \"{$this->values['wgPasswordSender']}\";\n\n\$wgEnotifUserTalk = {$this->values['wgEnotifUserTalk']}; # UPO\n\$wgEnotifWatchlist = {$this->values['wgEnotifWatchlist']}; # UPO\n\$wgEmailAuthentication = {$this->values['wgEmailAuthentication']};\n\n## Database settings\n\$wgDBtype = \"{$this->values['wgDBtype']}\";\n\$wgDBserver = \"{$this->values['wgDBserver']}\";\n\$wgDBname = \"{$this->values['wgDBname']}\";\n\$wgDBuser = \"{$this->values['wgDBuser']}\";\n\$wgDBpassword = \"{$this->values['wgDBpassword']}\";\n\n{$this->dbSettings}\n\n## Shared memory settings\n\$wgMainCacheType = {$cacheType};\n\$wgMemCachedServers = {$mcservers};\n\n## To enable image uploads, make sure the 'images' directory\n## is writable, then set this to true:\n\$wgEnableUploads = {$this->values['wgEnableUploads']};\n{$magic}\$wgUseImageMagick = true;\n{$magic}\$wgImageMagickConvertCommand = \"{$this->values['wgImageMagickConvertCommand']}\";\n\n# InstantCommons allows wiki to use images from http://commons.wikimedia.org\n\$wgUseInstantCommons = {$this->values['wgUseInstantCommons']};\n\n## If you use ImageMagick (or any other shell command) on a\n## Linux server, this will need to be set to the name of an\n## available UTF-8 locale\n{$locale}\$wgShellLocale = \"{$this->values['wgShellLocale']}\";\n\n## If you want to use image uploads under safe mode,\n## create the directories images/archive, images/thumb and\n## images/temp, and make them all writable. Then uncomment\n## this, if it's not already uncommented:\n{$hashedUploads}\$wgHashedUploadDirectory = false;\n\n## If you have the appropriate support software installed\n## you can enable inline LaTeX equations:\n\$wgUseTeX = false;\n\n## Set \$wgCacheDirectory to a writable directory on the web server\n## to make your wiki go slightly faster. The directory should not\n## be publically accessible from the web.\n#\$wgCacheDirectory = \"\$IP/cache\";\n\n# Site language code, should be one of ./languages/Language(.*).php\n\$wgLanguageCode = \"{$this->values['wgLanguageCode']}\";\n\n\$wgSecretKey = \"{$this->values['wgSecretKey']}\";\n\n# Site upgrade key. Must be set to a string (default provided) to turn on the\n# web installer while LocalSettings.php is in place\n\$wgUpgradeKey = \"{$this->values['wgUpgradeKey']}\";\n\n## Default skin: you can change the default skin. Use the internal symbolic\n## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook', 'vector':\n\$wgDefaultSkin = \"{$this->values['wgDefaultSkin']}\";\n\n## For attaching licensing metadata to pages, and displaying an\n## appropriate copyright notice / icon. GNU Free Documentation\n## License and Creative Commons licenses are supported so far.\n{$rightsUrl}\$wgEnableCreativeCommonsRdf = true;\n\$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright\n\$wgRightsUrl = \"{$this->values['wgRightsUrl']}\";\n\$wgRightsText = \"{$this->values['wgRightsText']}\";\n\$wgRightsIcon = \"{$this->values['wgRightsIcon']}\";\n# \$wgRightsCode = \"{$this->values['wgRightsCode']}\"; # Not yet used\n\n# Path to the GNU diff3 utility. Used for conflict resolution.\n\$wgDiff3 = \"{$this->values['wgDiff3']}\";\n\n{$groupRights}\n\n# Query string length limit for ResourceLoader. You should only set this if\n# your web server has a query string length limit (then set it to that limit),\n# or if you have suhosin.get.max_value_length set in php.ini (then set it to\n# that value)\n\$wgResourceLoaderMaxQueryLength = {$this->values['wgResourceLoaderMaxQueryLength']};\n";
}
示例7: execute
function execute($par)
{
global $wgOut, $wgUser, $wgRequest;
global $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview;
if ($wgUser->isBlocked()) {
$wgOut->blockedPage();
return;
}
if ($wgUser->getID() == 0) {
$wgOut->setRobotpolicy('noindex,nofollow');
$wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
return;
}
if (!in_array('staff', $wgUser->getGroups())) {
$wgOut->setRobotpolicy('noindex,nofollow');
$wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
return;
}
$this->errorFile = "";
$this->errorTitle = "";
if ($wgRequest->getVal('delete')) {
$wgOut->setArticleBodyOnly(true);
$hpid = str_replace('delete_', '', $wgRequest->getVal('delete'));
$html = self::deleteHPImage($hpid);
$wgOut->addHTML($html);
return;
}
$this->postSuccessful = true;
if ($wgRequest->wasPosted()) {
if ($wgRequest->getVal("updateActive")) {
$dbw = wfGetDB(DB_MASTER);
//first clear them all
$dbw->update(WikihowHomepageAdmin::HP_TABLE, array('hp_active' => 0, 'hp_order' => 0), '*', __METHOD__);
$images = $wgRequest->getArray("hp_images");
$count = 1;
foreach ($images as $image) {
if (!$image) {
continue;
}
$dbw->update(WikihowHomepageAdmin::HP_TABLE, array('hp_active' => 1, 'hp_order' => $count), array('hp_id' => $image));
$count++;
}
} else {
$title = WikiPhoto::getArticleTitleNoCheck($wgRequest->getVal('articleName'));
if (!$title->exists()) {
$this->postSuccessful = false;
$this->errorTitle = "* That article does not exist.";
}
if ($this->postSuccessful) {
//keep going
$imageTitle = Title::newFromText($wgRequest->getVal('wpDestFile'), NS_IMAGE);
$file = new LocalFile($imageTitle, RepoGroup::singleton()->getLocalRepo());
$file->upload($wgRequest->getFileTempName('wpUploadFile'), '', '');
$filesize = $file->getSize();
if ($filesize > 0) {
$dbw = wfGetDB(DB_MASTER);
$dbw->insert(WikihowHomepageAdmin::HP_TABLE, array('hp_page' => $title->getArticleID(), 'hp_image' => $imageTitle->getArticleID()));
$article = new Article($imageTitle);
$limit = array();
$limit['move'] = "sysop";
$limit['edit'] = "sysop";
$protectResult = $article->updateRestrictions($limit, "Used on homepage");
} else {
$this->postSuccessful = false;
$this->errorFile = "* We encountered an error uploading that file.";
}
}
}
}
$useAjaxDestCheck = $wgUseAjax && $wgAjaxUploadDestCheck;
$useAjaxLicensePreview = $wgUseAjax && $wgAjaxLicensePreview;
$adc = wfBoolToStr($useAjaxDestCheck);
$alp = wfBoolToStr($useAjaxLicensePreview);
$wgOut->setPageTitle('WikiHow Homepage Admin');
$wgOut->addScript("<script type=\"text/javascript\">\nwgAjaxUploadDestCheck = {$adc};\nwgAjaxLicensePreview = {$alp};\n</script>");
$wgOut->addScript(HtmlSnips::makeUrlTags('js', array('jquery-ui-1.8.custom.min.js'), 'extensions/wikihow/common/ui/js', false));
$wgOut->addScript(HtmlSnips::makeUrlTags('js', array('wikihowhomepageadmin.js'), 'extensions/wikihow/homepage', false));
$wgOut->addScript(HtmlSnips::makeUrlTags('css', array('wikihowhomepageadmin.css'), 'extensions/wikihow/homepage', false));
$wgOut->addScript(HtmlSnips::makeUrlTags('js', array('upload.js'), 'skins/common', false));
$this->displayHomepageData();
$this->displayForm();
}
示例8: mainUploadForm
function mainUploadForm($msg = '')
{
global $wgOut, $wgUser, $wgLang, $wgMaxUploadSize;
global $wgUseCopyrightUpload, $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview;
global $wgRequest, $wgAllowCopyUploads;
global $wgStylePath, $wgStyleVersion;
$useAjaxDestCheck = $wgUseAjax && $wgAjaxUploadDestCheck;
$useAjaxLicensePreview = $wgUseAjax && $wgAjaxLicensePreview;
$adc = wfBoolToStr($useAjaxDestCheck);
$alp = wfBoolToStr($useAjaxLicensePreview);
$autofill = wfBoolToStr($this->mDesiredDestName == '');
$wgOut->addScript("<script type=\"text/javascript\">\nwgAjaxUploadDestCheck = {$adc};\nwgAjaxLicensePreview = {$alp};\nwgUploadAutoFill = {$autofill};\n</script>\n<script type=\"text/javascript\" src=\"{$wgStylePath}/common/upload.js?{$wgStyleVersion}\"></script>\n\t\t");
if (!wfRunHooks('UploadForm:initial', array(&$this))) {
wfDebug("Hook 'UploadForm:initial' broke output of the upload form");
return false;
}
if ($this->mDesiredDestName) {
$title = Title::makeTitleSafe(NS_IMAGE, $this->mDesiredDestName);
// Show a subtitle link to deleted revisions (to sysops et al only)
if ($title instanceof Title && ($count = $title->isDeleted()) > 0 && $wgUser->isAllowed('deletedhistory')) {
$link = wfMsgExt($wgUser->isAllowed('delete') ? 'thisisdeleted' : 'viewdeleted', array('parse', 'replaceafter'), $wgUser->getSkin()->makeKnownLinkObj(SpecialPage::getTitleFor('Undelete', $title->getPrefixedText()), wfMsgExt('restorelink', array('parsemag', 'escape'), $count)));
$wgOut->addHtml("<div id=\"contentSub2\">{$link}</div>");
}
// Show the relevant lines from deletion log (for still deleted files only)
if ($title instanceof Title && $title->isDeleted() > 0 && !$title->exists()) {
$this->showDeletionLog($wgOut, $title->getPrefixedText());
}
}
$cols = intval($wgUser->getOption('cols'));
if ($wgUser->getOption('editwidth')) {
$width = " style=\"width:100%\"";
} else {
$width = '';
}
if ('' != $msg) {
$sub = wfMsgHtml('uploaderror');
$wgOut->addHTML("<h2>{$sub}</h2>\n" . "<span class='error'>{$msg}</span>\n");
}
//$wgOut->addHTML( '<div id="uploadtext">' );
//$wgOut->addWikiMsg( 'uploadtext', $this->mDesiredDestName );
//$wgOut->addHTML( "</div>\n" );
# Print a list of allowed file extensions, if so configured. We ignore
# MIME type here, it's incomprehensible to most people and too long.
global $wgCheckFileExtensions, $wgStrictFileExtensions, $wgFileExtensions, $wgFileBlacklist;
$allowedExtensions = '';
if ($wgCheckFileExtensions) {
$delim = wfMsgExt('comma-separator', array('escapenoentities'));
if ($wgStrictFileExtensions) {
# Everything not permitted is banned
$extensionsList = '<div id="mw-upload-permitted">' . wfMsgWikiHtml('upload-permitted', implode($wgFileExtensions, $delim)) . "</div>\n";
} else {
# We have to list both preferred and prohibited
$extensionsList = '<div id="mw-upload-preferred">' . wfMsgWikiHtml('upload-preferred', implode($wgFileExtensions, $delim)) . "</div>\n" . '<div id="mw-upload-prohibited">' . wfMsgWikiHtml('upload-prohibited', implode($wgFileBlacklist, $delim)) . "</div>\n";
}
}
# Get the maximum file size from php.ini as $wgMaxUploadSize works for uploads from URL via CURL only
# See http://www.php.net/manual/en/ini.core.php#ini.upload-max-filesize for possible values of upload_max_filesize
$val = trim(ini_get('upload_max_filesize'));
$last = strtoupper(substr($val, -1));
switch ($last) {
case 'G':
$val2 = substr($val, 0, -1) * 1024 * 1024 * 1024;
break;
case 'M':
$val2 = substr($val, 0, -1) * 1024 * 1024;
break;
case 'K':
$val2 = substr($val, 0, -1) * 1024;
break;
default:
$val2 = $val;
}
$val2 = $wgAllowCopyUploads ? min($wgMaxUploadSize, $val2) : $val2;
$maxUploadSize = wfMsgExt('upload-maxfilesize', array('parseinline', 'escapenoentities'), $wgLang->formatSize($val2));
$sourcefilename = wfMsgExt('sourcefilename', 'escapenoentities');
$destfilename = wfMsgExt('destfilename', 'escapenoentities');
$summary = wfMsgExt('fileuploadsummary', 'parseinline');
$licenses = new Licenses();
$license = wfMsgExt('license', array('parseinline'));
$nolicense = wfMsgHtml('nolicense');
$licenseshtml = $licenses->getHtml();
$ulb = wfMsgHtml('uploadbtn');
$titleObj = SpecialPage::getTitleFor('Mv_special_upload');
$encDestName = htmlspecialchars($this->mDesiredDestName);
$watchChecked = $this->watchCheck() ? 'checked="checked"' : '';
$warningChecked = $this->mIgnoreWarning ? 'checked' : '';
// Prepare form for upload or upload/copy
if ($wgAllowCopyUploads && $wgUser->isAllowed('upload_by_url')) {
$filename_form = "<input type='radio' id='wpSourceTypeFile' name='wpSourceType' value='file' " . "onchange='toggle_element_activation(\"wpUploadFileURL\",\"wpUploadFile\")' checked='checked' />" . "<input tabindex='1' type='file' name='wpUploadFile' id='wpUploadFile' " . "onfocus='" . "toggle_element_activation(\"wpUploadFileURL\",\"wpUploadFile\");" . "toggle_element_check(\"wpSourceTypeFile\",\"wpSourceTypeURL\")' " . "onchange='fillDestFilename(\"wpUploadFile\")' size='60' />" . wfMsgHTML('upload_source_file') . "<br/>" . "<input type='radio' id='wpSourceTypeURL' name='wpSourceType' value='web' " . "onchange='toggle_element_activation(\"wpUploadFile\",\"wpUploadFileURL\")' />" . "<input tabindex='1' type='text' name='wpUploadFileURL' id='wpUploadFileURL' " . "onfocus='" . "toggle_element_activation(\"wpUploadFile\",\"wpUploadFileURL\");" . "toggle_element_check(\"wpSourceTypeURL\",\"wpSourceTypeFile\")' " . "onchange='fillDestFilename(\"wpUploadFileURL\")' size='60' disabled='disabled' />" . wfMsgHtml('upload_source_url');
} else {
$filename_form = "<input tabindex='1' type='file' name='wpUploadFile' id='wpUploadFile' " . ($this->mDesiredDestName ? "" : "onchange='fillDestFilename(\"wpUploadFile\")' ") . "size='60' />" . "<input type='hidden' name='wpSourceType' value='file' />";
}
if ($useAjaxDestCheck) {
$warningRow = "<tr><td colspan='2' id='wpDestFile-warning'> </td></tr>";
$destOnkeyup = 'onkeyup="wgUploadWarningObj.keypress();"';
} else {
$warningRow = '';
$destOnkeyup = '';
}
$encComment = htmlspecialchars($this->mComment);
//.........这里部分代码省略.........
示例9: buildInput
/**
* Build an input for $conf setting with $default as default value
*
* @param String $conf name of the setting
* @param String $type type of the setting
* @param String $default default value
* @return String xhtml fragment
*/
protected function buildInput($conf, $type, $default)
{
$allowed = !in_array($conf, self::$restricted) || $this->isUserAllowedAll();
if ($type == 'text' || $type == 'int') {
if (!$allowed) {
return htmlspecialchars($default);
}
return Xml::element('input', array('name' => 'wp' . $conf, 'type' => 'text', 'value' => $default));
}
if ($type == 'bool') {
if (!$allowed) {
return wfBoolToStr($default);
}
if ($default) {
$checked = array('checked' => 'checked');
} else {
$checked = array();
}
return Xml::element('input', array('name' => 'wp' . $conf, 'type' => 'checkbox', 'value' => '1') + $checked);
}
if ($type == 'array') {
return $this->buildArrayInput($conf, $default, $allowed);
}
if ($type == 'lang') {
// Code taken from Xml.php, Xml::LanguageSelector only available since 1.11 and Xml::option since 1.8
$languages = Language::getLanguageNames(true);
if (!array_key_exists($default, $languages)) {
$languages[$default] = $default;
}
ksort($languages);
$options = "\n";
foreach ($languages as $code => $name) {
$attribs = array('value' => $code);
if ($code == $default) {
$attribs['selected'] = 'selected';
}
$options .= Xml::element('option', $attribs, "{$code} - {$name}") . "\n";
}
return Xml::openElement('select', array('id' => 'wp' . $conf, 'name' => 'wp' . $conf)) . $options . "</select>";
}
if (is_array($type)) {
if (!$allowed) {
return htmlspecialchars($default);
}
$ret = "\n";
foreach ($type as $val => $name) {
$ret .= Xml::radioLabel($name, 'wp' . $conf, $val, 'wp' . $conf . $val, $default == $val) . "\n";
}
return $ret;
}
}
示例10: prettifyForDisplay
/**
* Prettify boolean settings to be correctly displayed
*
* @return String
*/
public static function prettifyForDisplay($val)
{
if (is_bool($val)) {
return wfBoolToStr($val);
} else {
return $val;
}
}
示例11: mainUploadForm
/**
* Displays the main upload form, optionally with a highlighted
* error message up at the top.
*
* @param string $msg as HTML
* @access private
*/
function mainUploadForm($msg = '')
{
global $wgOut, $wgUser, $wgContLang;
global $wgUseCopyrightUpload, $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview;
global $wgRequest, $wgAllowCopyUploads;
global $wgStylePath, $wgStyleVersion;
$useAjaxDestCheck = $wgUseAjax && $wgAjaxUploadDestCheck;
$useAjaxLicensePreview = $wgUseAjax && $wgAjaxLicensePreview;
$adc = wfBoolToStr($useAjaxDestCheck);
$alp = wfBoolToStr($useAjaxLicensePreview);
$wgOut->addScript("<script type=\"text/javascript\">\nwgAjaxUploadDestCheck = {$adc};\nwgAjaxLicensePreview = {$alp};\n</script>\n<script type=\"text/javascript\" src=\"{$wgStylePath}/common/upload.js?{$wgStyleVersion}\"></script>\n\t\t");
if (!wfRunHooks('UploadForm:initial', array(&$this))) {
wfDebug("Hook 'UploadForm:initial' broke output of the upload form");
return false;
}
if ($this->mDesiredDestName) {
$title = Title::makeTitleSafe(NS_IMAGE, $this->mDesiredDestName);
// Show a subtitle link to deleted revisions (to sysops et al only)
if ($title instanceof Title && ($count = $title->isDeleted()) > 0 && $wgUser->isAllowed('deletedhistory')) {
$link = wfMsgExt($wgUser->isAllowed('delete') ? 'thisisdeleted' : 'viewdeleted', array('parse', 'replaceafter'), $wgUser->getSkin()->makeKnownLinkObj(SpecialPage::getTitleFor('Undelete', $title->getPrefixedText()), wfMsgExt('restorelink', array('parsemag', 'escape'), $count)));
$wgOut->addHtml("<div id=\"contentSub2\">{$link}</div>");
}
// Show the relevant lines from deletion log (for still deleted files only)
if ($title instanceof Title && $title->isDeleted() > 0 && !$title->exists()) {
$this->showDeletionLog($wgOut, $title->getPrefixedText());
}
}
$cols = intval($wgUser->getOption('cols'));
if ($wgUser->getOption('editwidth')) {
$width = " style=\"width:100%\"";
} else {
$width = '';
}
if ('' != $msg) {
$sub = wfMsgHtml('uploaderror');
$wgOut->addHTML("<h2>{$sub}</h2>\n" . "<span class='error'>{$msg}</span>\n");
}
$wgOut->addHTML('<div id="uploadtext">');
$wgOut->addWikiMsg('uploadtext', $this->mDesiredDestName);
$wgOut->addHTML("</div>\n");
# Print a list of allowed file extensions, if so configured. We ignore
# MIME type here, it's incomprehensible to most people and too long.
global $wgCheckFileExtensions, $wgStrictFileExtensions, $wgFileExtensions, $wgFileBlacklist;
if ($wgCheckFileExtensions) {
$delim = wfMsgExt('comma-separator', array('escapenoentities'));
if ($wgStrictFileExtensions) {
# Everything not permitted is banned
$wgOut->addHTML('<div id="mw-upload-permitted">' . wfMsgWikiHtml('upload-permitted', implode($wgFileExtensions, $delim)) . "</div>\n");
} else {
# We have to list both preferred and prohibited
$wgOut->addHTML('<div id="mw-upload-preferred">' . wfMsgWikiHtml('upload-preferred', implode($wgFileExtensions, $delim)) . "</div>\n" . '<div id="mw-upload-prohibited">' . wfMsgWikiHtml('upload-prohibited', implode($wgFileBlacklist, $delim)) . "</div>\n");
}
}
$sourcefilename = wfMsgHtml('sourcefilename');
$destfilename = wfMsgHtml('destfilename');
$summary = wfMsgExt('fileuploadsummary', 'parseinline');
$licenses = new Licenses();
$license = wfMsgExt('license', array('parseinline'));
$nolicense = wfMsgHtml('nolicense');
$licenseshtml = $licenses->getHtml();
$ulb = wfMsgHtml('uploadbtn');
$titleObj = SpecialPage::getTitleFor('Upload');
$action = $titleObj->escapeLocalURL();
$encDestName = htmlspecialchars($this->mDesiredDestName);
$watchChecked = $wgUser->getOption('watchdefault') || $wgUser->getOption('watchcreations') && $this->mDesiredDestName == '' ? 'checked="checked"' : '';
$warningChecked = $this->mIgnoreWarning ? 'checked' : '';
// Prepare form for upload or upload/copy
if ($wgAllowCopyUploads && $wgUser->isAllowed('upload_by_url')) {
$filename_form = "<input type='radio' id='wpSourceTypeFile' name='wpSourceType' value='file' " . "onchange='toggle_element_activation(\"wpUploadFileURL\",\"wpUploadFile\")' checked />" . "<input tabindex='1' type='file' name='wpUploadFile' id='wpUploadFile' " . "onfocus='" . "toggle_element_activation(\"wpUploadFileURL\",\"wpUploadFile\");" . "toggle_element_check(\"wpSourceTypeFile\",\"wpSourceTypeURL\")'" . ($this->mDesiredDestName ? "" : "onchange='fillDestFilename(\"wpUploadFile\")' ") . "size='40' />" . wfMsgHTML('upload_source_file') . "<br/>" . "<input type='radio' id='wpSourceTypeURL' name='wpSourceType' value='web' " . "onchange='toggle_element_activation(\"wpUploadFile\",\"wpUploadFileURL\")' />" . "<input tabindex='1' type='text' name='wpUploadFileURL' id='wpUploadFileURL' " . "onfocus='" . "toggle_element_activation(\"wpUploadFile\",\"wpUploadFileURL\");" . "toggle_element_check(\"wpSourceTypeURL\",\"wpSourceTypeFile\")'" . ($this->mDesiredDestName ? "" : "onchange='fillDestFilename(\"wpUploadFileURL\")' ") . "size='40' DISABLED />" . wfMsgHtml('upload_source_url');
} else {
$filename_form = "<input tabindex='1' type='file' name='wpUploadFile' id='wpUploadFile' " . ($this->mDesiredDestName ? "" : "onchange='fillDestFilename(\"wpUploadFile\")' ") . "size='40' />" . "<input type='hidden' name='wpSourceType' value='file' />";
}
if ($useAjaxDestCheck) {
$warningRow = "<tr><td colspan='2' id='wpDestFile-warning'> </td></tr>";
$destOnkeyup = 'onkeyup="wgUploadWarningObj.keypress();"';
} else {
$warningRow = '';
$destOnkeyup = '';
}
$encComment = htmlspecialchars($this->mComment);
$align1 = $wgContLang->isRTL() ? 'left' : 'right';
$align2 = $wgContLang->isRTL() ? 'right' : 'left';
$wgOut->addHTML(<<<EOT
\t<form id='upload' method='post' enctype='multipart/form-data' action="{$action}">
\t\t<table border='0'>
\t\t<tr>
\t {$this->uploadFormTextTop}
\t\t\t<td align='{$align1}' valign='top'><label for='wpUploadFile'>{$sourcefilename}:</label></td>
\t\t\t<td align='{$align2}'>
\t\t\t\t{$filename_form}
\t\t\t</td>
\t\t</tr>
\t\t<tr>
//.........这里部分代码省略.........
示例12: runLaTeX
function runLaTeX($file = 'Main', $sort = false, $bibtex = false)
{
global $wgUser;
$timer_start = microtime(true);
$this->debug = $wgUser->getOption('w2lDebug');
$this->is_admin = in_array('sysop', $wgUser->getGroups());
$command = str_replace('%file%', $file, $this->command);
$cur_dir = getcwd();
chdir($this->path);
$go = true;
$i = 1;
$msg = $this->msg;
if ($this->debug == true && $this->is_admin == true) {
$msg .= "\n== Debug Information ==\n";
$msg .= wfMsg('w2l_compile_command', $command) . "\n";
$msg .= wfMsg('w2l_temppath', $this->path) . "\n";
$msg .= "Current directory: " . getcwd() . "\n";
$msg .= "User: " . wfShellExec("whoami") . "\n";
$msg .= "== PDF-LaTeX Information ==\n" . wfShellExec("pdflatex -version");
}
while (true == $go or $i > 5) {
$msg .= "\n" . wfMsg('w2l_compile_run', $i) . "\n";
$msg .= wfShellExec($command);
if (!file_exists($file . '.pdf')) {
$msg .= wfMsg('w2l_pdf_not_created', $file . '.pdf') . "\n";
$msg .= "Current directory: " . getcwd() . "\n";
$msg .= "Is it writable? " . wfBoolToStr(is_writable(getcwd())) . "\n";
$msg .= "Is it a font-problem maybe? " . wfShellExec('kpsewhich -var-value TFMFONTS') . "\n";
$msg .= "Is it a path maybe? " . wfShellExec('kpsewhich -var-value HOME') . "\n";
$compile_error = true;
$go = false;
} else {
$compile_error = false;
/*
if ( true == $sort ) {
// sort it, baby
$msg .= '===Sort-Result==='."\n";
$msg .= $this->sortIndexFile($file);
$msg .= "\n";
}
if ( true == $bibtex ) {
// run bibtex
$msg .= '===BibTeX-Result==='."\n";
$msg .= $this->doBibTex($file);
$msg .= "\n";
}
*/
if ($this->repeat == $i) {
$go = false;
}
++$i;
}
}
// Now chmod-ing some files
$mod = 0666;
if (is_dir($this->path)) {
$directory = dir($this->path);
while (false !== ($tmp_file = $directory->read())) {
if (is_file($tmp_file)) {
$res = chmod($tmp_file, $mod);
}
}
$directory->close();
}
if (file_exists($file . '.log')) {
$this->log = file_get_contents($file . '.log');
} else {
$this->log = 'Log file was not created...';
}
chdir($cur_dir);
$timer_end = microtime(true);
$this->timer = $timer_end - $timer_start;
$this->timer = round($this->timer, 3);
$msg .= "Running time LaTeX: " . $timer . " seconds";
$this->msg = $msg;
return $compile_error;
}