429
回編集
細 (→2011年12月14日(水)) |
|||
9行目: | 9行目: | ||
if (isset($fp['caption']) && !empty($fp['caption']) && $fp['caption'] != "Image:" . $orginal) { | if (isset($fp['caption']) && !empty($fp['caption']) && $fp['caption'] != "Image:" . $orginal) { | ||
$ret .= "alt=\"".htmlspecialchars($fp['caption'])."\" "; | $ret .= "alt=\"".htmlspecialchars($fp['caption'])."\" "; | ||
} | |||
</pre> | |||
=== keywords meta タグを入れたい === | |||
* 作ってみた. | |||
<pre> | |||
<?php | |||
$wgExtensionCredits['other'][] = array( | |||
'name' => 'AddKeywordsMetaTag', | |||
'status' => 'Experimental', | |||
'author' => 'Yoshihiro OKUMURA', | |||
'version' => '1.0', | |||
'url' => 'http://www.neuroinf.jp/', | |||
'description' => 'Mediawiki:Keywords ページの内容を keywords meta タグとして出力します.', | |||
); | |||
$wgHooks['OutputPageBeforeHTML'][] = 'wfAddKeywordsMetaTag'; | |||
function wfAddKeywordsMetaTag(&$out, &$text) { | |||
global $wgTitle, $wgParser, $wgRequest, $action; | |||
if ($action !== 'edit' && | |||
$action !== 'history' && | |||
$action !== 'delete' && | |||
$action !== 'watch' && | |||
strpos($wgParser->mTitle->mPrefixedText, 'Special:') === false && | |||
$wgParser->mTitle->mNamespace !== 8) { | |||
$title = Title::MakeTitle(NS_MEDIAWIKI, 'Keywords'); | |||
$article = new Article($title); | |||
$keywords = trim($article->getRawText()); | |||
$out->addMeta('keywords', $keywords); | |||
} | |||
return true; | |||
} | } | ||
</pre> | </pre> |