本文整理汇总了PHP中TranslateUtils::assetPath方法的典型用法代码示例。如果您正苦于以下问题:PHP TranslateUtils::assetPath方法的具体用法?PHP TranslateUtils::assetPath怎么用?PHP TranslateUtils::assetPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TranslateUtils
的用法示例。
在下文中一共展示了TranslateUtils::assetPath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: languages
/**
* @param $data
* @param $params
* @param $parser Parser
* @return string
*/
public static function languages($data, $params, $parser)
{
$title = $parser->getTitle();
// Check if this is a source page or a translation page
$page = TranslatablePage::newFromTitle($title);
if ($page->getMarkedTag() === false) {
$page = TranslatablePage::isTranslationPage($title);
}
if ($page === false || $page->getMarkedTag() === false) {
return '';
}
$status = $page->getTranslationPercentages();
if (!$status) {
return '';
}
// Fix title
$title = $page->getTitle();
// Sort by language code, which seems to be the only sane method
ksort($status);
$options = $parser->getOptions();
if (method_exists($options, 'getUserLang')) {
$userLangCode = $options->getUserLang();
} else {
// Backward compat for MediaWiki 1.17
global $wgLang;
$userLangCode = $wgLang->getCode();
}
// BC for <1.19
$linker = class_exists('DummyLinker') ? new DummyLinker() : new Linker();
$languages = array();
foreach ($status as $code => $percent) {
$name = TranslateUtils::getLanguageName($code, false, $userLangCode);
$name = htmlspecialchars($name);
// Unlikely, but better safe
/* Percentages are too accurate and take more
* space than simple images */
$percent *= 100;
if ($percent < 20) {
$image = 1;
} elseif ($percent < 40) {
$image = 2;
} elseif ($percent < 60) {
$image = 3;
} elseif ($percent < 80) {
$image = 4;
} else {
$image = 5;
}
$percent = Xml::element('img', array('src' => TranslateUtils::assetPath("resources/images/prog-{$image}.png"), 'alt' => "{$percent}%", 'title' => "{$percent}%", 'width' => '9', 'height' => '9'));
// Add links to other languages
$suffix = $code === 'en' ? '' : "/{$code}";
$_title = Title::makeTitle($title->getNamespace(), $title->getDBkey() . $suffix);
if ($parser->getTitle()->getText() === $_title->getText()) {
$name = Html::rawElement('span', array('class' => 'mw-pt-languages-selected'), $name);
$languages[] = "{$name} {$percent}";
} else {
if ($code === $userLangCode) {
$name = Html::rawElement('span', array('class' => 'mw-pt-languages-ui'), $name);
}
$languages[] = $linker->linkKnown($_title, "{$name} {$percent}");
}
}
$legend = wfMsg('tpt-languages-legend');
$languages = implode(wfMsg('tpt-languages-separator'), $languages);
return <<<FOO
<div class="mw-pt-languages">
<table><tbody>
<tr valign="top">
<td class="mw-pt-languages-label"><b>{$legend}</b></td>
<td class="mw-pt-languages-list">{$languages}</td></tr>
</tbody></table>
</div>
FOO;
}