[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/news_admin/website/ -> export.php (source)

   1  <?php
   2      /**************************************************************************\
   3      * eGroupWare - Webpage news admin                                          *
   4      * http://www.egroupware.org                                                *
   5      * --------------------------------------------                             *
   6      *  This program is free software; you can redistribute it and/or modify it *
   7      *  under the terms of the GNU General Public License as published by the   *
   8      *  Free Software Foundation; either version 2 of the License, or (at your  *
   9      *  option) any later version.                                              *
  10      * --------------------------------------------                             *
  11      * This program was sponsered by Golden Glair productions                   *
  12      * http://www.goldenglair.com                                               *
  13      \**************************************************************************/
  14  
  15      /* $Id: export.php 22172 2006-07-24 15:43:45Z nelius_weiss $ */
  16      
  17      /**
  18       * Check if we allow anon access and with which creditials
  19       * 
  20       * @param array &$anon_account anon account_info with keys 'login', 'passwd' and optional 'passwd_type'
  21       * @return boolean true if we allow anon access, false otherwise
  22       */
  23  	function registration_check_anon_access(&$anon_account)
  24      {
  25          //quick hack for std installations...
  26          $anon_account = array(
  27              'login'  => 'anonymous',
  28              'passwd' => 'anonymous',
  29              'passwd_type' => 'text',
  30          );
  31          return true;
  32      }
  33      
  34      $GLOBALS['egw_info']['flags'] = array(
  35          'noheader'  => True,
  36          'nonavbar' => True,
  37          'currentapp' => 'sitemgr-link',
  38          'autocreate_session_callback' => 'registration_check_anon_access',
  39      );
  40      include('../../header.inc.php');
  41      
  42      $news_obj =& CreateObject('news_admin.sonews');
  43      $export_obj =& CreateObject('news_admin.soexport');
  44      $tpl =& $GLOBALS['egw']->template;
  45      
  46      $cat_id = (int)$_GET['cat_id'];
  47  //    $format = (isset($_GET['format']) ? strtolower(trim($_GET['format'])) : 'rss');
  48      $limit    = (isset($_GET['limit']) ? trim($_GET['limit']) : 5);
  49  //    $all    = (isset($_GET['all']) ? True : False);
  50  
  51      $site = $export_obj->readconfig($cat_id);
  52  
  53      //TODO allow override of configured value by a configurable flag
  54      //validate format
  55  
  56  //     $available_formats = array('rss'    => True, //RSS 0.91
  57  //                 'rdf-chan'    => True, //RDF 1.0
  58  //                 'rdf2'        => True, //RDF/RSS 2.0
  59  //                 );
  60  
  61  //     if(!$available_formats[$format])
  62  //     {
  63  //         $format = 'rss';
  64  //     }
  65  
  66      if(!$site['type'])
  67      {
  68          echo "THIS CATEGORY IS NOT PUBLICLY ACCESSIBLE";
  69          die();
  70      }
  71  
  72      header('Content-type: text/xml; charset='.$GLOBALS['egw']->translation->charset());
  73  
  74      $formats = array(1 => 'rss091', 2 => 'rss1', 3 => 'rss2');
  75      $itemsyntaxs = array(
  76          0 => '?item=',
  77          1 => '&item=',
  78          2 => '?news%5Bitem%5D=',
  79          3 => '&news%5Bitem%5D='
  80      );
  81      $format = $formats[$site['type']];
  82      $itemsyntax = $itemsyntaxs[$site['itemsyntax']];
  83      
  84      $tpl->root = EGW_SERVER_ROOT. '/news_admin/website/templates/';
  85      $tpl->set_file(array('news' => $format . '.tpl'));
  86      $tpl->set_block('news', 'item', 'items');
  87      if($format == 'rss1')
  88      {
  89          $tpl->set_block('news', 'seq', 'seqs');
  90      }
  91  
  92      $tpl->set_var('encoding', $GLOBALS['egw']->translation->charset());
  93      $tpl->set_var($site);
  94  
  95  //     if($all)
  96  //     {
  97  //         $news = $news_obj->get_all_public_news($limit);
  98  //     }
  99  //     else
 100  //     {
 101          $news = $news_obj->get_newslist($cat_id, 0,'','',$limit,True);
 102  //     }
 103      if(is_array($news))
 104      {
 105          foreach($news as $news_id => $news_data) 
 106          {
 107              $tpl->set_var($news_data);
 108  
 109              $tpl->set_var('item_link', $site['link'] . $itemsyntax . $news_id);
 110              $tpl->set_var('pub_date', date("r",$news_data['date']));
 111              if($format == 'rss1')
 112              {
 113                  $tpl->parse('seqs','seq',True);
 114              }
 115          
 116              $tpl->parse('items','item',True);
 117          }
 118      }
 119      else
 120      {
 121          $tpl->set_var('items', '');
 122      }
 123      $tpl->pparse('out','news');
 124  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7