plugins/SpecialRSS.php
changeset 1 327d3c7cd3f3
parent 0 cdf76b0e1aa1
child 2 882c793b0f37
equal deleted inserted replaced
0:cdf76b0e1aa1 1:327d3c7cd3f3
     1 <?php
     1 <?php
     2 /*
     2 /*
     3 Plugin Name: RSS Backend
     3 Plugin Name: RSS Frontend
     4 Plugin URI: http://enano.homelinux.org/Feed_me
     4 Plugin URI: http://enanocms.org/Feed_me
     5 Description: Provides the page Special:RSS, which is used to generate RSS feeds of site and page content changes.
     5 Description: Provides the page Special:RSS, which is used to generate RSS feeds of site and page content changes.
     6 Author: Dan Fuhry
     6 Author: Dan Fuhry
     7 Version: 1.0
     7 Version: 1.0
     8 Author URI: http://enano.homelinux.org/
     8 Author URI: http://enanocms.org/
     9 */
     9 */
    10 
    10 
    11 /*
    11 /*
    12  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
    12  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
    13  * Version 1.0 release candidate 2
    13  * Version 1.0 release candidate 2
   132     
   132     
   133     $this->channels = Array();
   133     $this->channels = Array();
   134     $guid = md5(microtime() . mt_rand());
   134     $guid = md5(microtime() . mt_rand());
   135     $this->channels[$guid] = Array(
   135     $this->channels[$guid] = Array(
   136         'title' => $title,
   136         'title' => $title,
       
   137         'desc' => $desc,
   137         'link' => $link,
   138         'link' => $link,
   138         'gen' => $gen,
   139         'gen' => $gen,
   139         'email' => $email,
   140         'email' => $email,
   140         'lang' => 'en-us',
   141         'lang' => 'en-us',
   141         'items' => Array()
   142         'items' => Array()
   234   
   235   
   235 }
   236 }
   236 
   237 
   237 // function names are IMPORTANT!!! The name pattern is: page_<namespace ID>_<page URLname, without namespace>
   238 // function names are IMPORTANT!!! The name pattern is: page_<namespace ID>_<page URLname, without namespace>
   238 
   239 
   239 function page_Special_RSS() {
   240 function page_Special_RSS()
       
   241 {
   240   global $db, $session, $paths, $template, $plugins; // Common objects
   242   global $db, $session, $paths, $template, $plugins; // Common objects
   241   header('Content-type: text/xml; charset=windows-1252'); //application/rss+xml');
   243   header('Content-type: text/xml; charset=windows-1252'); //application/rss+xml');
       
   244   global $aggressive_optimize_html;
       
   245   $aggressive_optimize_html = false;
       
   246   $session->sid_super = false;
       
   247   if ( $session->auth_level > USER_LEVEL_MEMBER )
       
   248     $session->auth_level = USER_LEVEL_MEMBER;
   242   $mode = $paths->getParam(0);
   249   $mode = $paths->getParam(0);
   243   $n = $paths->getParam(1);
   250   $n = $paths->getParam(1);
   244   if(!preg_match('#^([0-9]+)$#', $n) || (int)$n > 50) $n = 20;
   251   if(!preg_match('#^([0-9]+)$#', $n) || (int)$n > 50) $n = 20;
   245   else $n = (int)$n;
   252   else $n = (int)$n;
   246   switch($mode)
   253   switch($mode)
   247   {
   254   {
   248     case "recent":
   255     case "recent":
   249     case false:
       
   250       $title = getConfig('site_name') . ' Recent Changes';
   256       $title = getConfig('site_name') . ' Recent Changes';
   251       $desc = getConfig('site_desc');
   257       $desc = getConfig('site_desc');
   252       
   258       
   253       $rss = new RSS($title, $desc);
   259       $rss = new RSS($title, $desc);
   254       
   260       
   259       }
   265       }
   260       else
   266       else
   261       {
   267       {
   262         while($row = $db->fetchrow())
   268         while($row = $db->fetchrow())
   263         {
   269         {
   264           $link = 'http' . ( isset($_SERVER['HTTPS']) ? 's' : '' ) . '://'.$_SERVER['HTTP_HOST'] . makeUrlNS($row['namespace'], $row['page_id']);
   270           $link = makeUrlComplete($row['namespace'], $row['page_id'], "oldid={$row['time_id']}"); // makeUrlComplete($row['namespace'], $row['page_id']);
   265           $title = $paths->pages[$paths->nslist[$row['namespace']].$row['page_id']]['name'];
   271           $title = $paths->pages[$paths->nslist[$row['namespace']].$row['page_id']]['name'];
   266           $desc = ( $row['edit_summary'] != '' ) ? $row['edit_summary'] : 'No edit summary given.';
   272           $desc = "Change by {$row['author']}:<br />";
       
   273           $desc .= ( $row['edit_summary'] != '' ) ? $row['edit_summary'] : 'No edit summary given.';
   267           $date = $row['time_id'];
   274           $date = $row['time_id'];
   268           $guid = 'http' . ( isset($_SERVER['HTTPS']) ? 's' : '' ) . '://'.$_SERVER['HTTP_HOST'] . makeUrlNS($row['namespace'], $row['page_id']).'?oldid='.$row['time_id'];
   275           $guid = false;
   269           
   276           
   270           $rss->add_item($title, $link, $desc, $date, $guid);
   277           $rss->add_item($title, $link, $desc, $date, $guid);
   271         }
   278         }
   272       }
   279       }
   273       
   280