[ Index ]

PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09)

title

Body

[close]

/include/inc_front/content/ -> cnt22.article.inc.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
   6   
   7     This script is part of PHPWCMS. The PHPWCMS web content management system is
   8     free software; you can redistribute it and/or modify it under the terms of
   9     the GNU General Public License as published by the Free Software Foundation;
  10     either version 2 of the License, or (at your option) any later version.
  11    
  12     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13     A copy is found in the textfile GPL.txt and important notices to the license 
  14     from the author is found in LICENSE.txt distributed with these scripts.
  15    
  16     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19   
  20     This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  // ----------------------------------------------------------------
  24  // obligate check for phpwcms constants
  25  if (!defined('PHPWCMS_ROOT')) {
  26     die("You Cannot Access This Script Directly, Have a Nice Day.");
  27  }
  28  // ----------------------------------------------------------------
  29  
  30  // RSS feed
  31  
  32  //$CNT_TMP .= headline($crow["acontent_title"], $crow["acontent_subtitle"], $template_default["article"]);
  33  
  34  if( !empty($crow["acontent_form"]) && is_string($crow["acontent_form"]) ) {
  35      $rssfeed = unserialize($crow["acontent_form"]);
  36  } elseif( empty($rssfeed) || !is_array($rssfeed) ) {
  37      $rssfeed = array();
  38  }
  39  
  40  // Feed
  41  if( isset($rssfeed['rssurl']) && !empty($rssfeed['rssurl']) ) {
  42      
  43      if( empty($rssfeed['template']) || !is_file(PHPWCMS_TEMPLATE.'inc_cntpart/rssfeed/'.$rssfeed['template']) ) {
  44          $rssfeed['template'] = @file_get_contents(PHPWCMS_TEMPLATE.'inc_default/rssfeed.tmpl');
  45      } else {
  46          $rssfeed['template'] = @file_get_contents(PHPWCMS_TEMPLATE.'inc_cntpart/rssfeed/'.$rssfeed['template']);
  47      }
  48      if(!$rssfeed['template']) {
  49  
  50          $rssfeed['template'] = '<!--ITEM_START//--><p><a href="{LINK}" target="_blank">{TITLE}</a></p><!--ITEM_END//-->
  51  <!--DIVIDER_START//--><div style="padding:0;margin:0;border-top:1px dotted #B2B2B2;height:1px;overflow:hidden;"><img src="img/leer.gif" width="1" height="1" alt="" /></div><!--DIVIDER_END//-->
  52  <!--FEEDINFO_START//--><p style="margin-left:3px;margin-bottom:8px;">{IMAGE}</p><!--FEEDINFO_END//-->
  53  <!--RSSFEED_START//-->[TITLE]<h3>{TITLE}</h3>[/TITLE][SUBTITLE]<h4>{SUBTITLE}</h4>[/SUBTITLE]<div>{FEEDINFO}{ITEMS}</div><!--RSSFEED_END//-->';
  54      
  55      }
  56      
  57      // Get Template
  58      $rss['template_ITEM']        = get_tmpl_section('ITEM',        $rssfeed['template']);
  59      $rss['template_DIVIDER']    = get_tmpl_section('DIVIDER',    $rssfeed['template']);
  60      $rss['template_FEEDINFO']    = get_tmpl_section('FEEDINFO',    $rssfeed['template']);
  61      $rss['template_RSSFEED']    = get_tmpl_section('RSSFEED',    $rssfeed['template']);
  62  
  63      
  64      // Load SimplePie
  65      require_once(PHPWCMS_ROOT.'/include/inc_ext/SimplePie/simplepie.inc.php');
  66      //require_once(PHPWCMS_ROOT.'/include/inc_ext/SimplePie/idn/idna_convert.class.php');
  67      
  68      $rss_obj = new SimplePie();
  69      
  70      //$CNT_TMP .= dumpVar($rssfeed['rssurl'], 2);
  71      
  72      // Feed URL
  73      $rss_obj->set_feed_url( $rssfeed['rssurl'] );
  74      
  75      // Output Encoding Charset
  76      $rss_obj->set_output_encoding( PHPWCMS_CHARSET );
  77      
  78      // Input Encoding Charset
  79      if(!empty($rssfeed['content_type'])) {
  80          $rss_obj->set_input_encoding( $rssfeed['content_type'] );
  81      }
  82      
  83      
  84      // Feed Cache Timeout
  85      if(!$rssfeed["timeout"]) {
  86          // set to default value = 3600 seconds = 1 hour
  87          $rssfeed["timeout"] = 3600;
  88      }
  89      if($rssfeed["cacheoff"]) {
  90          // check if cache enabled or not
  91          $rssfeed["timeout"] = 0;
  92      }
  93      
  94      if($rssfeed["timeout"]) {
  95      
  96          $rss_obj->enable_cache( true );
  97          $rss_obj->set_cache_duration ( $rssfeed["timeout"] );
  98          $rss_obj->set_cache_location ( PHPWCMS_RSS );
  99          
 100      } else {
 101          
 102          $rss_obj->enable_cache( false );
 103      
 104      }
 105      
 106      //$rss_obj->enable_cache( false );
 107      
 108      // Remove surrounding DIV
 109      $rss_obj->remove_div( true );
 110      
 111      // Strip all HTML Tags
 112      $rss_obj->strip_htmltags( true );
 113      
 114      // Limit items
 115      if($rssfeed["item"]) {
 116          $rss_obj->set_item_limit( $rssfeed["item"] );
 117      }
 118      
 119      // Init Feed
 120      $rss_obj->init();
 121      
 122      /*
 123      if($rss_obj->error()) {
 124      
 125          $CNT_TMP .= $rss_obj->error();
 126      
 127      }
 128      */
 129      
 130      if( $rss_obj->data ) {
 131      
 132          // check RSS image
 133          if( $rss_obj->get_image_url() ) {
 134          
 135              $rss['temp_feedinfo']  = '<a href="'. ( $rss_obj->get_image_link() ? $rss_obj->get_image_link() : $rss_obj->get_permalink() ) .'" target="_blank">';
 136              $rss['temp_feedinfo'] .= '<img src="' . $rss_obj->get_image_url() . '" border="0" alt="' . $rss_obj->get_image_title() . '" />';
 137              $rss['temp_feedinfo'] .= '</a>';
 138  
 139              $rss['template_FEEDINFO'] = render_cnt_template($rss['template_FEEDINFO'], 'IMAGE', $rss['temp_feedinfo']);
 140          
 141          } else {
 142              
 143              $rss['template_FEEDINFO'] = render_cnt_template($rss['template_FEEDINFO'], 'IMAGE', '');
 144          
 145          }
 146          
 147          $rss['template_FEEDINFO'] = render_cnt_template($rss['template_FEEDINFO'], 'TITLE', $rss_obj->get_title());
 148          $rss['template_FEEDINFO'] = render_cnt_template($rss['template_FEEDINFO'], 'DESCRIPTION', $rss_obj->get_description());
 149          
 150          
 151          $c                = 0;
 152          $rss['items']    = array();
 153          
 154          foreach($rss_obj->get_items() as $rssvalue) {
 155          
 156              // general item info
 157              $rss['items'][$c] = render_cnt_template($rss['template_ITEM'], 'LINK', $rssvalue->get_permalink() );
 158              $rss['items'][$c] = render_cnt_template($rss['items'][$c], 'TITLE', $rssvalue->get_title() );
 159              $rss['items'][$c] = render_cnt_template($rss['items'][$c], 'DESCRIPTION', $rssvalue->get_content() );
 160              
 161              // item date
 162              $rss['items'][$c] = render_cnt_date($rss['items'][$c], $rssvalue->get_date('U') );
 163              
 164              $c++;
 165              
 166              if($rssfeed["item"] && $rssfeed["item"] == $c) {
 167              
 168                  break;
 169              
 170              }
 171          }
 172          
 173          // whole rss feed
 174          $rss['template_RSSFEED'] = render_cnt_template($rss['template_RSSFEED'], 'TITLE', html_entities($crow['acontent_title']) );
 175          $rss['template_RSSFEED'] = render_cnt_template($rss['template_RSSFEED'], 'SUBTITLE', html_entities($crow['acontent_subtitle']) );
 176          $rss['template_RSSFEED'] = str_replace('{DIVIDER}', $rss['template_DIVIDER'], $rss['template_RSSFEED']);
 177          $rss['template_RSSFEED'] = str_replace('{ITEMS}', implode( $rss['template_DIVIDER'] , $rss['items'] ), $rss['template_RSSFEED']);
 178          $rss['template_RSSFEED'] = str_replace('{FEEDINFO}', $rss['template_FEEDINFO'], $rss['template_RSSFEED']);
 179          $rss['template_RSSFEED'] = render_cnt_template($rss['template_RSSFEED'], 'LINK', $rss_obj->get_permalink() );
 180          
 181          $CNT_TMP .= $rss['template_RSSFEED'];
 182          
 183      }
 184  
 185  }
 186  unset($rss, $rssfeed);
 187  
 188  ?>


Generated: Wed Dec 30 05:55:15 2009 Cross-referenced by PHPXref 0.7