コード例 #1
0
ファイル: NewsRenderer.php プロジェクト: andreascian/News
 static function renderFeedLink($text, $argv, $parser)
 {
     $t = @$argv['feed'];
     if ($t) {
         $t = NewsRenderer::replaceVariables($parser, $t);
     }
     $title = $t === null ? null : Title::newFromText($t);
     if (!$title) {
         $title = $GLOBALS['wgTitle'];
     }
     #$id = @$argv['id'];
     $format = @$argv['format'];
     if (!$format) {
         $format = 'rss';
     } else {
         $format = strtolower(trim($format));
     }
     $icon = @$argv['icon'];
     $iconright = false;
     if (preg_match('/^(.+)\\|(\\w+)$/', $icon, $m)) {
         $icon = $m[1];
         $iconright = strtolower(trim($m[2])) === 'right';
     }
     $ticon = $icon ? Title::newFromText($icon, NS_IMAGE) : null;
     if ($ticon) {
         $image = wfFindFile($ticon);
         if (!$image->exists()) {
             $image = false;
         }
     } else {
         $image = false;
     }
     $thumb = $image ? $image->transform(array('width' => 80, 'height' => 16), 0) : null;
     if ($image && !$thumb) {
         $thumb = $image;
     }
     $iconurl = $thumb ? $thumb->getUrl() : null;
     $url = NewsRenderer::getFeedURL($title, $format);
     $ttl = @$argv['title'];
     if ($ttl) {
         $ttl = NewsRenderer::replaceVariables($parser, $ttl);
     }
     $s = '';
     if ($text) {
         $s .= $parser->recursiveTagParse($text);
         if (!$ttl) {
             $ttl = $text . ' (' . $format . ')';
         }
     } else {
         if (!$ttl) {
             $ttl = $format;
         }
     }
     if ($iconurl) {
         $ic = '<img border="0" src="' . htmlspecialchars($iconurl) . '" alt="' . htmlspecialchars($ttl) . '" title="' . htmlspecialchars($ttl) . '"/>';
         if ($s === '') {
             $s = $ic;
         } elseif ($iconright) {
             $s = "{$s}&#160;{$ic}";
         } else {
             $s = "{$ic}&#160;{$s}";
         }
     }
     $html = '<a href="' . htmlspecialchars($url) . '" title="' . htmlspecialchars($ttl) . '">' . $s . '</a>';
     return $html;
 }
コード例 #2
0
ファイル: News.php プロジェクト: Tjorriemorrie/app
function wfNewsSkinTemplateOutputPageBeforeExec($skin, $tpl)
{
    $feeds = $tpl->data['feeds'];
    if (!$feeds) {
        return true;
    }
    $title = $skin->getTitle();
    //hack...
    foreach ($feeds as $format => $e) {
        $e['href'] = NewsRenderer::getFeedURL($title, $format);
        $feeds[$format] = $e;
    }
    $tpl->setRef('feeds', $feeds);
    return true;
}