b2evolution PHP Cross Reference Blogging Systems

Source: /inc/widgets/widgets/_coll_xml_feeds.widget.php - 195 lines - 5158 bytes - Summary - Text - Print

Description: This file implements the coll_xml_feeds Widget class. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file implements the coll_xml_feeds Widget class.
   4   *
   5   * This file is part of the evoCore framework - {@link http://evocore.net/}
   6   * See also {@link http://sourceforge.net/projects/evocms/}.
   7   *
   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
   9   *
  10   * {@internal License choice
  11   * - If you have received this file as part of a package, please find the license.txt file in
  12   *   the same folder or the closest folder above for complete license terms.
  13   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  14   *   then you must choose one of the following licenses before using the file:
  15   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  16   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  17   * }}
  18   *
  19   * @package evocore
  20   *
  21   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  22   * @author fplanque: Francois PLANQUE.
  23   *
  24   * @version $Id: _coll_xml_feeds.widget.php 6136 2014-03-08 07:59:48Z manuel $
  25   */
  26  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  27  
  28  load_class( 'widgets/model/_widget.class.php', 'ComponentWidget' );
  29  
  30  /**
  31   * ComponentWidget Class
  32   *
  33   * A ComponentWidget is a displayable entity that can be placed into a Container on a web page.
  34   *
  35   * @package evocore
  36   */
  37  class coll_xml_feeds_Widget extends ComponentWidget
  38  {
  39      /**
  40       * Constructor
  41       */
  42  	function coll_xml_feeds_Widget( $db_row = NULL )
  43      {
  44          // Call parent constructor:
  45          parent::ComponentWidget( $db_row, 'core', 'coll_xml_feeds' );
  46      }
  47  
  48  
  49      /**
  50       * Get name of widget
  51       */
  52  	function get_name()
  53      {
  54          return T_('XML Feeds (RSS / Atom)');
  55      }
  56  
  57  
  58      /**
  59       * Get a very short desc. Used in the widget list.
  60       */
  61  	function get_short_desc()
  62      {
  63          return format_to_output($this->get_title());
  64      }
  65  
  66  
  67    /**
  68       * Get short description
  69       */
  70  	function get_desc()
  71      {
  72          return T_('List of all available XML feeds.');
  73      }
  74  
  75  
  76    /**
  77     * Get definitions for editable params
  78     *
  79       * @see Plugin::GetDefaultSettings()
  80       * @param local params like 'for_editing' => true
  81       */
  82  	function get_param_definitions( $params )
  83      {
  84          global $use_strict;
  85          $r = array_merge( array(
  86                  'title' => array(
  87                      'label' => T_( 'Title' ),
  88                      'size' => 40,
  89                      'note' => T_( 'This is the title to display, $icon$ will be replaced by the feed icon' ),
  90                      'defaultvalue' => '$icon$ '.T_('XML Feeds'),
  91                  ),
  92                  'disp_info_link' => array(
  93                      'label' => T_( 'Help link' ),
  94                      'type' => 'checkbox',
  95                      'note' => T_( 'Check this to display "What is RSS?" link' ),
  96                      'defaultvalue' => 1,
  97                  ),
  98                  'info_link' => array(
  99                      'label' => T_( 'New Window' ),
 100                      'type' => 'checkbox',
 101                      'note' => T_( 'Check this to add target="_blank" to the "What is RSS?" link' ),
 102                      'defaultvalue' => !$use_strict,
 103                  ),
 104              ), parent::get_param_definitions( $params )    );
 105  
 106          return $r;
 107      }
 108  
 109  
 110  	function get_title()
 111      {
 112          global $rsc_uri;
 113  
 114          $title = str_replace( '$icon$', get_icon('feed'), $this->disp_params['title']);
 115          // fp> TODO: support for different icon sizes and backgrounds (at least black and white; mid grey would be cool also)
 116  
 117          return $title;
 118      }
 119  
 120  
 121      /**
 122       * Display the widget!
 123       *
 124       * @param array MUST contain at least the basic display params
 125       */
 126  	function display( $params )
 127      {
 128          global $Blog;
 129  
 130          $this->init_display( $params );
 131  
 132          // Available XML feeds:
 133          echo $this->disp_params['block_start'];
 134  
 135          $this->disp_title( $this->get_title() );
 136  
 137          echo $this->disp_params['list_start'];
 138  
 139          $SkinCache = & get_SkinCache();
 140          $SkinCache->load_by_type( 'feed' );
 141  
 142          // TODO: this is like touching private parts :>
 143          foreach( $SkinCache->cache as $Skin )
 144          {
 145              if( $Skin->type != 'feed' )
 146              {    // This skin cannot be used here...
 147                  continue;
 148              }
 149  
 150              echo $this->disp_params['item_start'];
 151              echo $Skin->name.': ';
 152              echo '<a href="'.$Blog->get_item_feed_url( $Skin->folder ).'">'.T_('Posts').'</a>';
 153              if ( $Blog->get_setting( 'allow_comments' ) != 'never' && $Blog->get_setting( 'comment_feed_content' ) != 'none' && $Blog->get_setting( 'comments_latest' ) )
 154              {
 155                  echo ', <a href="'.$Blog->get_comment_feed_url( $Skin->folder ).'">'.T_('Comments').'</a>';
 156              }
 157  
 158              echo $this->disp_params['item_end'];
 159          }
 160  
 161          echo $this->disp_params['list_end'];
 162  
 163  
 164          // Display "info" link, if activated.
 165          if( $this->disp_params['disp_info_link'] )
 166          {
 167              /**
 168               * @var AbstractSettings
 169               */
 170              global $global_Cache;
 171  
 172              $feedhlp = $global_Cache->get( 'feedhlp' );
 173              if( empty( $feedhlp ) )
 174              {    // Use basic default: (fp> needs serious update) -- Note: no localization because destination is in English anyway.
 175                  $feedhlp = array( array( 'http://www.webreference.fr/defintions/rss-atom-xml', 'What is RSS?' ) );
 176              }
 177  
 178              if( $this->disp_params[ 'info_link' ] )
 179              {
 180                  $link_params = array( 'target' => '_blank' );
 181              }
 182              else
 183              {
 184                  $link_params = array( 'target' => '' );
 185              }
 186              display_list( $feedhlp, $this->disp_params['notes_start'], $this->disp_params['notes_end'], ' ', '', '', NULL, 1, $link_params );
 187          }
 188  
 189          echo $this->disp_params['block_end'];
 190  
 191          return true;
 192      }
 193  }
 194  
 195  ?>

title

Description

title

Description

title

Description

title

title

Body