[ Index ]
 

Code source de Plume CMS 1.2.2

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/manager/inc/ -> class.rss.php (source)

   1  <?php
   2  /* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
   3  /*
   4  # ***** BEGIN LICENSE BLOCK *****
   5  # This file is part of Plume CMS, a website management application.
   6  # Copyright (C) 2001-2005 Loic d'Anterroches and contributors.
   7  #
   8  # Plume CMS is free software; you can redistribute it and/or modify
   9  # it under the terms of the GNU General Public License as published by
  10  # the Free Software Foundation; either version 2 of the License, or
  11  # (at your option) any later version.
  12  #
  13  # Plume CMS is distributed in the hope that it will be useful,
  14  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16  # GNU General Public License for more details.
  17  #
  18  # You should have received a copy of the GNU General Public License
  19  # along with this program; if not, write to the Free Software
  20  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  21  #
  22  # ***** END LICENSE BLOCK ***** */
  23  
  24  
  25  
  26  class RSS
  27  {
  28      /**
  29       * Action to display the RSS feeds.
  30       *
  31       * @param string Server query string
  32       * @return int Success code
  33       */
  34      function action($query)
  35      {
  36          Hook::register('onInitTemplate', 'RSS', 'hookOnInitTemplate');
  37          config::setVar('category_page', 1);
  38          $category_id = '';
  39          $path = RSS::parseQueryString($query);
  40          if ($path != '/') {
  41              $sql = SQL::getCategoryByPath($path, config::f('website_id'));
  42              $con =& pxDBConnect();
  43              if (($cat = $con->select($sql, 'Category')) !== false) {
  44                  if (!$cat->isEmpty()) {
  45                      $category_id = $cat->f('category_id');
  46                  }
  47              }
  48          }
  49          $GLOBALS['_PX_render']['last'] = '';
  50          $last =& $GLOBALS['_PX_render']['last']; 
  51          $GLOBALS['_PX_render']['website'] = '';
  52          $website =& $GLOBALS['_PX_render']['website']; 
  53  
  54          $cache = new Cache(urlencode('rss'));
  55          $cache->setCacheDirectory(config::getCacheDir());
  56          $cache->debug = config::f('debug');
  57  
  58          header(FrontEnd::getHeader('feed.atom'));
  59          header('Content-Disposition: attachment; filename="feed.xml"');
  60          // Load the template
  61          include config::f('manager_path').'/templates/'
  62              .config::f('theme_id').'/feed.atom';
  63          return 200;
  64      }
  65  
  66      /**
  67       * Hook on the initialization of the templates.
  68       *
  69       * @param array Default parameters (not used)
  70       * @return bool Success
  71       */
  72      function hookOnInitTemplate($param)
  73      {
  74          if (config::f('action') == 'RSS') {
  75              $GLOBALS['_PX_render']['website'] = FrontEnd::getWebsite();
  76          }
  77          return true;
  78      }
  79  
  80      /**
  81       * Parse query string.
  82       *
  83       * @param string Query string
  84       * @return string Category path
  85       */
  86      function parseQueryString($query)
  87      {
  88          $category = '';
  89          if (preg_match('#^/feed(.*/)$#i', $query, $match)) {
  90              $category = $match[1];
  91          } else {
  92              $category = '/';
  93          }
  94          return $category;
  95      }
  96  
  97  }
  98  
  99  ?>


Généré le : Mon Nov 26 11:57:01 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics