本文整理汇总了PHP中SpecialVersion::getExtLicenseFileName方法的典型用法代码示例。如果您正苦于以下问题:PHP SpecialVersion::getExtLicenseFileName方法的具体用法?PHP SpecialVersion::getExtLicenseFileName怎么用?PHP SpecialVersion::getExtLicenseFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpecialVersion
的用法示例。
在下文中一共展示了SpecialVersion::getExtLicenseFileName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHelpInternal
/**
* Recursively-called function to actually construct the help
*
* @param IContextSource $context
* @param ApiBase[] $modules
* @param array $options
* @param array &$haveModules
* @return string
*/
private static function getHelpInternal(IContextSource $context, array $modules, array $options, &$haveModules)
{
$out = '';
$level = empty($options['headerlevel']) ? 2 : $options['headerlevel'];
if (empty($options['tocnumber'])) {
$tocnumber = array(2 => 0);
} else {
$tocnumber =& $options['tocnumber'];
}
foreach ($modules as $module) {
$tocnumber[$level]++;
$path = $module->getModulePath();
$module->setContext($context);
$help = array('header' => '', 'flags' => '', 'description' => '', 'help-urls' => '', 'parameters' => '', 'examples' => '', 'submodules' => '');
if (empty($options['noheader']) || !empty($options['toc'])) {
$anchor = $path;
$i = 1;
while (isset($haveModules[$anchor])) {
$anchor = $path . '|' . ++$i;
}
if ($module->isMain()) {
$header = $context->msg('api-help-main-header')->parse();
} else {
$name = $module->getModuleName();
$header = $module->getParent()->getModuleManager()->getModuleGroup($name) . "={$name}";
if ($module->getModulePrefix() !== '') {
$header .= ' ' . $context->msg('parentheses', $module->getModulePrefix())->parse();
}
}
$haveModules[$anchor] = array('toclevel' => count($tocnumber), 'level' => $level, 'anchor' => $anchor, 'line' => $header, 'number' => join('.', $tocnumber), 'index' => false);
if (empty($options['noheader'])) {
$help['header'] .= Html::element('h' . min(6, $level), array('id' => $anchor, 'class' => 'apihelp-header'), $header);
}
} else {
$haveModules[$path] = true;
}
$links = array();
$any = false;
for ($m = $module; $m !== null; $m = $m->getParent()) {
$name = $m->getModuleName();
if ($name === 'main_int') {
$name = 'main';
}
if (count($modules) === 1 && $m === $modules[0] && !(!empty($options['submodules']) && $m->getModuleManager())) {
$link = Html::element('b', null, $name);
} else {
$link = SpecialPage::getTitleFor('ApiHelp', $m->getModulePath())->getLocalURL();
$link = Html::element('a', array('href' => $link, 'class' => 'apihelp-linktrail'), $name);
$any = true;
}
array_unshift($links, $link);
}
if ($any) {
$help['header'] .= self::wrap($context->msg('parentheses')->rawParams($context->getLanguage()->pipeList($links)), 'apihelp-linktrail', 'div');
}
$flags = $module->getHelpFlags();
$help['flags'] .= Html::openElement('div', array('class' => 'apihelp-block apihelp-flags'));
$msg = $context->msg('api-help-flags');
if (!$msg->isDisabled()) {
$help['flags'] .= self::wrap($msg->numParams(count($flags)), 'apihelp-block-head', 'div');
}
$help['flags'] .= Html::openElement('ul');
foreach ($flags as $flag) {
$help['flags'] .= Html::rawElement('li', null, self::wrap($context->msg("api-help-flag-{$flag}"), "apihelp-flag-{$flag}"));
}
$sourceInfo = $module->getModuleSourceInfo();
if ($sourceInfo) {
if (isset($sourceInfo['namemsg'])) {
$extname = $context->msg($sourceInfo['namemsg'])->text();
} else {
$extname = $sourceInfo['name'];
}
$help['flags'] .= Html::rawElement('li', null, self::wrap($context->msg('api-help-source', $extname, $sourceInfo['name']), 'apihelp-source'));
$link = SpecialPage::getTitleFor('Version', 'License/' . $sourceInfo['name']);
if (isset($sourceInfo['license-name'])) {
$msg = $context->msg('api-help-license', $link, $sourceInfo['license-name']);
} elseif (SpecialVersion::getExtLicenseFileName(dirname($sourceInfo['path']))) {
$msg = $context->msg('api-help-license-noname', $link);
} else {
$msg = $context->msg('api-help-license-unknown');
}
$help['flags'] .= Html::rawElement('li', null, self::wrap($msg, 'apihelp-license'));
} else {
$help['flags'] .= Html::rawElement('li', null, self::wrap($context->msg('api-help-source-unknown'), 'apihelp-source'));
$help['flags'] .= Html::rawElement('li', null, self::wrap($context->msg('api-help-license-unknown'), 'apihelp-license'));
}
$help['flags'] .= Html::closeElement('ul');
$help['flags'] .= Html::closeElement('div');
foreach ($module->getFinalDescription() as $msg) {
$msg->setContext($context);
$help['description'] .= $msg->parseAsBlock();
//.........这里部分代码省略.........
示例2: getModuleInfo
/**
* @param ApiBase $module
* @return ApiResult
*/
private function getModuleInfo($module)
{
$ret = [];
$path = $module->getModulePath();
$ret['name'] = $module->getModuleName();
$ret['classname'] = get_class($module);
$ret['path'] = $path;
if (!$module->isMain()) {
$ret['group'] = $module->getParent()->getModuleManager()->getModuleGroup($module->getModuleName());
}
$ret['prefix'] = $module->getModulePrefix();
$sourceInfo = $module->getModuleSourceInfo();
if ($sourceInfo) {
$ret['source'] = $sourceInfo['name'];
if (isset($sourceInfo['namemsg'])) {
$ret['sourcename'] = $this->context->msg($sourceInfo['namemsg'])->text();
} else {
$ret['sourcename'] = $ret['source'];
}
$link = SpecialPage::getTitleFor('Version', 'License/' . $sourceInfo['name'])->getFullURL();
if (isset($sourceInfo['license-name'])) {
$ret['licensetag'] = $sourceInfo['license-name'];
$ret['licenselink'] = (string) $link;
} elseif (SpecialVersion::getExtLicenseFileName(dirname($sourceInfo['path']))) {
$ret['licenselink'] = (string) $link;
}
}
$this->formatHelpMessages($ret, 'description', $module->getFinalDescription());
foreach ($module->getHelpFlags() as $flag) {
$ret[$flag] = true;
}
$ret['helpurls'] = (array) $module->getHelpUrls();
if (isset($ret['helpurls'][0]) && $ret['helpurls'][0] === false) {
$ret['helpurls'] = [];
}
ApiResult::setIndexedTagName($ret['helpurls'], 'helpurl');
if ($this->helpFormat !== 'none') {
$ret['examples'] = [];
$examples = $module->getExamplesMessages();
foreach ($examples as $qs => $msg) {
$item = ['query' => $qs];
$msg = ApiBase::makeMessage($msg, $this->context, [$module->getModulePrefix(), $module->getModuleName(), $module->getModulePath()]);
$this->formatHelpMessages($item, 'description', [$msg]);
if (isset($item['description'])) {
if (is_array($item['description'])) {
$item['description'] = $item['description'][0];
} else {
ApiResult::setSubelementsList($item, 'description');
}
}
$ret['examples'][] = $item;
}
ApiResult::setIndexedTagName($ret['examples'], 'example');
}
$ret['parameters'] = [];
$params = $module->getFinalParams(ApiBase::GET_VALUES_FOR_HELP);
$paramDesc = $module->getFinalParamDescription();
foreach ($params as $name => $settings) {
if (!is_array($settings)) {
$settings = [ApiBase::PARAM_DFLT => $settings];
}
$item = ['name' => $name];
if (isset($paramDesc[$name])) {
$this->formatHelpMessages($item, 'description', $paramDesc[$name], true);
}
$item['required'] = !empty($settings[ApiBase::PARAM_REQUIRED]);
if (!empty($settings[ApiBase::PARAM_DEPRECATED])) {
$item['deprecated'] = true;
}
if ($name === 'token' && $module->needsToken()) {
$item['tokentype'] = $module->needsToken();
}
if (!isset($settings[ApiBase::PARAM_TYPE])) {
$dflt = isset($settings[ApiBase::PARAM_DFLT]) ? $settings[ApiBase::PARAM_DFLT] : null;
if (is_bool($dflt)) {
$settings[ApiBase::PARAM_TYPE] = 'boolean';
} elseif (is_string($dflt) || is_null($dflt)) {
$settings[ApiBase::PARAM_TYPE] = 'string';
} elseif (is_int($dflt)) {
$settings[ApiBase::PARAM_TYPE] = 'integer';
}
}
if (isset($settings[ApiBase::PARAM_DFLT])) {
switch ($settings[ApiBase::PARAM_TYPE]) {
case 'boolean':
$item['default'] = (bool) $settings[ApiBase::PARAM_DFLT];
break;
case 'string':
case 'text':
case 'password':
$item['default'] = strval($settings[ApiBase::PARAM_DFLT]);
break;
case 'integer':
case 'limit':
$item['default'] = intval($settings[ApiBase::PARAM_DFLT]);
break;
//.........这里部分代码省略.........
示例3: appendExtensions
protected function appendExtensions($property)
{
global $wgExtensionCredits;
$data = array();
foreach ($wgExtensionCredits as $type => $extensions) {
foreach ($extensions as $ext) {
$ret = array();
$ret['type'] = $type;
if (isset($ext['name'])) {
$ret['name'] = $ext['name'];
}
if (isset($ext['description'])) {
$ret['description'] = $ext['description'];
}
if (isset($ext['descriptionmsg'])) {
// Can be a string or array( key, param1, param2, ... )
if (is_array($ext['descriptionmsg'])) {
$ret['descriptionmsg'] = $ext['descriptionmsg'][0];
$ret['descriptionmsgparams'] = array_slice($ext['descriptionmsg'], 1);
$this->getResult()->setIndexedTagName($ret['descriptionmsgparams'], 'param');
} else {
$ret['descriptionmsg'] = $ext['descriptionmsg'];
}
}
if (isset($ext['author'])) {
$ret['author'] = is_array($ext['author']) ? implode(', ', $ext['author']) : $ext['author'];
}
if (isset($ext['url'])) {
$ret['url'] = $ext['url'];
}
if (isset($ext['version'])) {
$ret['version'] = $ext['version'];
} elseif (isset($ext['svn-revision']) && preg_match('/\\$(?:Rev|LastChangedRevision|Revision): *(\\d+)/', $ext['svn-revision'], $m)) {
$ret['version'] = 'r' . $m[1];
}
if (isset($ext['path'])) {
$extensionPath = dirname($ext['path']);
$gitInfo = new GitInfo($extensionPath);
$vcsVersion = $gitInfo->getHeadSHA1();
if ($vcsVersion !== false) {
$ret['vcs-system'] = 'git';
$ret['vcs-version'] = $vcsVersion;
$ret['vcs-url'] = $gitInfo->getHeadViewUrl();
$vcsDate = $gitInfo->getHeadCommitDate();
if ($vcsDate !== false) {
$ret['vcs-date'] = wfTimestamp(TS_ISO_8601, $vcsDate);
}
} else {
$svnInfo = SpecialVersion::getSvnInfo($extensionPath);
if ($svnInfo !== false) {
$ret['vcs-system'] = 'svn';
$ret['vcs-version'] = $svnInfo['checkout-rev'];
$ret['vcs-url'] = isset($svnInfo['viewvc-url']) ? $svnInfo['viewvc-url'] : '';
}
}
if (SpecialVersion::getExtLicenseFileName($extensionPath)) {
$ret['license-name'] = isset($ext['license-name']) ? $ext['license-name'] : '';
$ret['license'] = SpecialPage::getTitleFor('Version', "License/{$ext['name']}")->getLinkURL();
}
if (SpecialVersion::getExtAuthorsFileName($extensionPath)) {
$ret['credits'] = SpecialPage::getTitleFor('Version', "Credits/{$ext['name']}")->getLinkURL();
}
}
$data[] = $ret;
}
}
$this->getResult()->setIndexedTagName($data, 'ext');
return $this->getResult()->addValue('query', $property, $data);
}
示例4: appendExtensions
protected function appendExtensions($property)
{
$data = [];
foreach ($this->getConfig()->get('ExtensionCredits') as $type => $extensions) {
foreach ($extensions as $ext) {
$ret = [];
$ret['type'] = $type;
if (isset($ext['name'])) {
$ret['name'] = $ext['name'];
}
if (isset($ext['namemsg'])) {
$ret['namemsg'] = $ext['namemsg'];
}
if (isset($ext['description'])) {
$ret['description'] = $ext['description'];
}
if (isset($ext['descriptionmsg'])) {
// Can be a string or array( key, param1, param2, ... )
if (is_array($ext['descriptionmsg'])) {
$ret['descriptionmsg'] = $ext['descriptionmsg'][0];
$ret['descriptionmsgparams'] = array_slice($ext['descriptionmsg'], 1);
ApiResult::setIndexedTagName($ret['descriptionmsgparams'], 'param');
} else {
$ret['descriptionmsg'] = $ext['descriptionmsg'];
}
}
if (isset($ext['author'])) {
$ret['author'] = is_array($ext['author']) ? implode(', ', $ext['author']) : $ext['author'];
}
if (isset($ext['url'])) {
$ret['url'] = $ext['url'];
}
if (isset($ext['version'])) {
$ret['version'] = $ext['version'];
}
if (isset($ext['path'])) {
$extensionPath = dirname($ext['path']);
$gitInfo = new GitInfo($extensionPath);
$vcsVersion = $gitInfo->getHeadSHA1();
if ($vcsVersion !== false) {
$ret['vcs-system'] = 'git';
$ret['vcs-version'] = $vcsVersion;
$ret['vcs-url'] = $gitInfo->getHeadViewUrl();
$vcsDate = $gitInfo->getHeadCommitDate();
if ($vcsDate !== false) {
$ret['vcs-date'] = wfTimestamp(TS_ISO_8601, $vcsDate);
}
}
if (SpecialVersion::getExtLicenseFileName($extensionPath)) {
$ret['license-name'] = isset($ext['license-name']) ? $ext['license-name'] : '';
$ret['license'] = SpecialPage::getTitleFor('Version', "License/{$ext['name']}")->getLinkURL();
}
if (SpecialVersion::getExtAuthorsFileName($extensionPath)) {
$ret['credits'] = SpecialPage::getTitleFor('Version', "Credits/{$ext['name']}")->getLinkURL();
}
}
$data[] = $ret;
}
}
ApiResult::setIndexedTagName($data, 'ext');
return $this->getResult()->addValue('query', $property, $data);
}