ListSubBlogsRSS (php)

De GirinoWiki

[editar] License

SpecialPageListSubBlogs.php/SpecialPagesListAllBlogs.php 
  - Adds Blog functionality to MediaWiki

Copyright (C) 2005  Shannon McNaught

SpecialPageListSubBlogsRSS.php
  - Adds RSS functionality to SpecialPageListSubBlogs.php

Copyright (C) 2007  Girino Vey!

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

[editar] Code

<?php
$wgExtensionFunctions[] = "loadSpecialListSubBlogsRSS";
require_once("includes/SpecialPage.php");
 
class SpecialListSubBlogsRSS extends SpecialPage {
 
  function SpecialListSubBlogsRSS() {
    SpecialPage::SpecialPage('ListSubBlogsRSS', '', false);
    $this->includable(true);
  }
 
  function execute( $parent = null ) {
    global $wgRequest, $wgOut, $wgUser, $wgFeedClasses, $wgFeedCacheTimeout;
    $fname = 'listsubpages';
 
 
    // Handle Errors
    $target = $this->including() ? $wgRequest->getVal( 'title' ) :
      (isset( $parent ) ? $parent : $wgRequest->getVal( 'target' ));
 
    if (is_null($target)) {
      $wgOut->errorpage( 'notargettitle', 'notargettext' );
      return;
    }
 
    $target = Title::newFromURL( $target );
    if( !$target ) {
      $wgOut->errorpage( 'notargettitle', 'notargettext' );
      return;
    }
 
    $feedFormat = $wgRequest->getVal( 'feed', 'rss');
    if( !isset( $wgFeedClasses[$feedFormat] ) ) {
        wfHttpError( 500, "Internal Server Error", "Unsupported feed type." );
        return false;
    }
 
    # Create feed    
    $feed = new $wgFeedClasses[$feedFormat]($target->getPrefixedText().":Blog", $target->getPrefixedText().":Blog",  $target->getFullUrl());
 
    $feed->outHeader();
 
    // Do query
    list($limit, $offset) = $wgRequest->getLimitOffset();
 
    $dbr =& wfGetDB( DB_READ );
 
    $result = $dbr->select( 'page' ,
                            array( 'page_namespace', 'page_title' ),
                            array(  'page_namespace' => $target->getNamespace(),
                                    "page_title LIKE " . $dbr->addQuotes($target->getDbKey() . '/%') ),
                            $fname,
                            array( 'ORDER BY'=>'page_touched DESC','LIMIT' => $limit, 'OFFSET' => $offset ) );
 
    // Output results
    if ( 0 == $dbr->numRows( $result ) ) {
      $feed->outFooter();
      return;
    }
 
    $rows = array();
 
    while ($row = $dbr->fetchObject($result)) {
      if (ereg("BlogEntry",$row->page_title)) {
 
        $link = Title::makeTitle( $row->page_namespace, $row->page_title);
	$article = new Article($link);
	$content = $wgOut->parse($article->getContent()."\n__NOEDITSECTION__ __NOTOC__");
        list($user1,$date1) = explode("/BlogEntry:_",$row->page_title,2);
        $date1 = preg_replace('/_/', ' ', $date1);
	$item = new FeedItem($row->page_title, $content, $link->getFullUrl(), $article->getTimestamp(), "$user1");
	$feed->outItem($item);
 
      }
    }
 
    $dbr->freeResult($result);
    $feed->outFooter();
    return;
  }
}
 
 
function loadSpecialListSubBlogsRSS()
{
  SpecialPage::addPage(new SpecialListSubBlogsRSS);
}
 
?>
Ferramentas pessoais
Social Blogging
  • StumbleUpon
  • Adicionar aos Favoritos BlogBlogs
  • Adicionar esta página no Linkk
  • Add to Technorati Favorites
patrocinadores
Espaço comercial