[ Index ]
 

Code source de Mantis 1.1.0rc3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/ -> news_rss.php (source)

   1  <?php
   2  # Mantis - a php based bugtracking system
   3  
   4  # Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
   5  # Copyright (C) 2002 - 2007  Mantis Team   - mantisbt-dev@lists.sourceforge.net
   6  
   7  # Mantis is free software: you can redistribute it and/or modify
   8  # it under the terms of the GNU General Public License as published by
   9  # the Free Software Foundation, either version 2 of the License, or
  10  # (at your option) any later version.
  11  #
  12  # Mantis is distributed in the hope that it will be useful,
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15  # GNU General Public License for more details.
  16  #
  17  # You should have received a copy of the GNU General Public License
  18  # along with Mantis.  If not, see <http://www.gnu.org/licenses/>.
  19  
  20      # --------------------------------------------------------
  21      # $Id: news_rss.php,v 1.11.2.1 2007-10-13 22:34:08 giallu Exp $
  22      # --------------------------------------------------------
  23  ?>
  24  <?php
  25      require_once ( 'core.php' );
  26  
  27      $t_core_path = config_get( 'core_path' );
  28  
  29      require_once( $t_core_path . 'class.RSSBuilder.inc.php' );
  30      require_once( $t_core_path . 'news_api.php' );
  31      require_once( $t_core_path . 'project_api.php' );
  32      require_once( $t_core_path . 'print_api.php' );
  33      require_once( $t_core_path . 'rss_api.php' );
  34  
  35      $f_username = gpc_get_string( 'username', null );
  36      $f_key = gpc_get_string( 'key', null );
  37      $f_project_id = gpc_get_int( 'project_id', ALL_PROJECTS );
  38  
  39      # make sure RSS syndication is enabled.
  40      if ( OFF == config_get( 'rss_enabled' ) ) {
  41          access_denied();
  42      }
  43  
  44      # authenticate the user
  45      if ( $f_username !== null ) {
  46          if ( !rss_login( $f_username, $f_key ) ) {
  47              access_denied();
  48          }
  49      } else {
  50          if ( OFF == config_get( 'allow_anonymous_login' ) ) {
  51              access_denied();
  52          }
  53      }
  54  
  55      # Make sure that the current user has access to the selected project (if not ALL PROJECTS).
  56      if ( $f_project_id != ALL_PROJECTS ) {
  57          access_ensure_project_level( VIEWER, $f_project_id );
  58      }
  59  
  60      # construct rss file
  61  
  62      $encoding = lang_get( 'charset' );
  63      $about = config_get( 'path' );
  64      $title = string_rss_links( config_get( 'window_title' ) . ' - ' . lang_get( 'news' ) );
  65  
  66      if ( $f_username !== null ) {
  67          $title .= " - ($f_username)";
  68      }
  69  
  70      $description = $title;
  71      $image_link = config_get( 'path' ) . 'images/mantis_logo_button.gif';
  72  
  73      # only rss 2.0
  74      $category = string_rss_links( project_get_name( $f_project_id ) );
  75  
  76      # in minutes (only rss 2.0)
  77      $cache = '60';
  78  
  79      $rssfile = new RSSBuilder(    $encoding, $about, $title, $description,
  80                      $image_link, $category, $cache);
  81  
  82      # person, an organization, or a service
  83      $publisher = '';
  84  
  85      # person, an organization, or a service
  86      $creator = '';
  87  
  88      $date = (string) date( 'r' );
  89      $language = lang_get( 'phpmailer_language' );
  90      $rights = '';
  91  
  92      # spatial location , temporal period or jurisdiction
  93      $coverage = (string) '';
  94  
  95      # person, an organization, or a service
  96      $contributor = (string) '';
  97  
  98      $rssfile->setPublisher( $publisher );
  99      $rssfile->setCreator( $creator );
 100      $rssfile->setRights( $rights );
 101      $rssfile->setCoverage( $coverage );
 102      $rssfile->setContributor( $contributor );
 103  
 104      # hourly / daily / weekly / ...
 105      $period = (string) 'daily';
 106  
 107      # every X hours/days/...
 108      $frequency = (int) 1;
 109  
 110      $base = (string) date('Y-m-d\TH:i:sO');
 111  
 112      # add missing : in the O part of the date.  PHP 5 supports a 'c' format which will output the format
 113      # exactly as we want it.
 114      # // 2002-10-02T10:00:00-0500 -> // 2002-10-02T10:00:00-05:00
 115      $base = substr( $base, 0, 22 ) . ':' . substr( $base, -2 );
 116  
 117      $rssfile->addSYdata( $period, $frequency, $base );
 118  
 119      $news_rows = news_get_limited_rows( 0 /* offset */, $f_project_id );
 120  
 121      # Loop through results
 122      for ( $i = 0; $i < count( $news_rows ); $i++ ) {
 123          $row = $news_rows[$i];
 124          extract( $row, EXTR_PREFIX_ALL, 'v' );
 125  
 126          # skip news item if private, or
 127          # belongs to a private project (will only happen
 128          if ( VS_PRIVATE == $v_view_state ) {
 129              continue;
 130          }
 131  
 132          $v_headline     = string_rss_links( $v_headline );
 133          $v_body     = string_rss_links( $v_body );
 134          $v_date_posted     = date( 'Y-m-d\TH:i:sO', $v_date_posted );
 135  
 136          $about = $link = config_get( 'path' ) . "news_view_page.php?news_id=$v_id";
 137          $title = $v_headline;
 138          $description = $v_body;
 139  
 140          # optional DC value
 141          $subject = $title;
 142  
 143          # optional DC value
 144          $date = $v_date_posted;
 145  
 146          # author of item
 147          $author = string_rss_links( user_get_name( $v_poster_id ) );
 148          if ( access_has_global_level( config_get( 'show_user_email_threshold' ) ) ) {
 149              $t_author_email = user_get_field( $v_poster_id, 'email' );
 150              if ( is_blank( $t_author_email ) ) {
 151                  $t_author_email = $author . '@example.com';
 152              }
 153          } else {
 154              $t_author_email = $author . '@example.com';
 155          }
 156          $author .= ' &lt;' . $t_author_email . '&gt;';
 157  
 158          # $comments = 'http://www.example.com/sometext.php?somevariable=somevalue&comments=1';    # url to comment page rss 2.0 value
 159          $comments = '';
 160  
 161          # optional mod_im value for dispaying a different pic for every item
 162          $image = '';
 163  
 164          $rssfile->addItem(    $about, $title, $link, $description, $subject, $date,
 165                      $author, $comments, $image);
 166      }
 167  
 168      # @@@ consider making this a configuration option.
 169      # 0.91 / 1.0 / 2.0
 170      $version = '2.0';
 171  
 172      $rssfile->outputRSS( $version );
 173  ?>


Généré le : Thu Nov 29 09:42:17 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics