b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (CVS HEAD) [ class tree: evocore ] [ index: evocore ] [ all elements ]

Source for file _coll_xml_feeds.widget.php

Documentation is available at _coll_xml_feeds.widget.php

  1. <?php
  2. /**
  3.  * This file implements the xyz 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-2010 by Francois PLANQUE - {@link http://fplanque.net/}
  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,v 1.22 2010/02/08 17:54:48 efy-yury Exp $
  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. {
  38.     /**
  39.      * Constructor
  40.      */
  41.     function coll_xml_feeds_Widget$db_row NULL )
  42.     {
  43.         // Call parent constructor:
  44.         parent::ComponentWidget$db_row'core''coll_xml_feeds' );
  45.     }
  46.  
  47.  
  48.     /**
  49.      * Get name of widget
  50.      */
  51.     function get_name()
  52.     {
  53.         return T_('XML Feeds (RSS / Atom)');
  54.     }
  55.  
  56.  
  57.     /**
  58.      * Get a very short desc. Used in the widget list.
  59.      */
  60.     function get_short_desc()
  61.     {
  62.         return format_to_output($this->get_title());
  63.     }
  64.  
  65.  
  66.   /**
  67.      * Get short description
  68.      */
  69.     function get_desc()
  70.     {
  71.         return T_('List of all available XML feeds.');
  72.     }
  73.  
  74.  
  75.   /**
  76.    * Get definitions for editable params
  77.    *
  78.      * @see Plugin::GetDefaultSettings()
  79.      * @param local params like 'for_editing' => true
  80.      */
  81.     function get_param_definitions$params )
  82.     {
  83.         global $use_strict;
  84.         $r array_mergearray(
  85.                 'title' => array(
  86.                     'label' => T_'Title' ),
  87.                     'size' => 40,
  88.                     'note' => T_'This is the title to display, $icon$ will be replaced by the feed icon' ),
  89.                     'defaultvalue' => '$icon$ '.T_('XML Feeds'),
  90.                 ),
  91.                 'disp_info_link' => array(
  92.                     'label' => T_'Help link' ),
  93.                     'type' => 'checkbox',
  94.                     'note' => T_'Check this to display "What is RSS?" link' ),
  95.                     'defaultvalue' => 1,
  96.                 ),
  97.                 'info_link' => array(
  98.                     'label' => T_'New Window' ),
  99.                     'type' => 'checkbox',
  100.                     'note' => T_'Check this to add target="_blank" to the "What is RSS?" link' ),
  101.                     'defaultvalue' => !$use_strict,
  102.                 ),
  103.             )parent::get_param_definitions$params )    );
  104.  
  105.         return $r;
  106.     }
  107.  
  108.  
  109.     function get_title()
  110.     {
  111.         global $rsc_url;
  112.  
  113.         $title str_replace'$icon$''<img src="'.$rsc_url.'icons/feed-icon-16x16.gif" width="16" height="16" class="top" alt="" /> '$this->disp_params['title']);
  114.         // fp> TODO: support for different icon sizes and backgrounds (at least black and white; mid grey would be cool also)
  115.  
  116.         return $title;
  117.     }
  118.  
  119.  
  120.     /**
  121.      * Display the widget!
  122.      *
  123.      * @param array MUST contain at least the basic display params
  124.      */
  125.     function display$params )
  126.     {
  127.         global $Blog;
  128.  
  129.         $this->init_display$params );
  130.  
  131.         // Available XML feeds:
  132.         echo $this->disp_params['block_start'];
  133.  
  134.         $this->disp_title$this->get_title() );
  135.  
  136.         echo $this->disp_params['list_start'];
  137.  
  138.         $SkinCache get_SkinCache();
  139.         $SkinCache->load_by_type'feed' );
  140.  
  141.         // TODO: this is like touching private parts :>
  142.         foreach$SkinCache->cache as $Skin )
  143.         {
  144.             if$Skin->type != 'feed' )
  145.             {    // This skin cannot be used here...
  146.                 continue;
  147.             }
  148.  
  149.             echo $this->disp_params['item_start'];
  150.             echo $Skin->name.': ';
  151.             echo '<a href="'.$Blog->get_item_feed_url$Skin->folder ).'">'.T_('Posts').'</a>';
  152.             if $Blog->allowcomments != 'never' )
  153.             {
  154.                 echo ', <a href="'.$Blog->get_comment_feed_url$Skin->folder ).'">'.T_('Comments').'</a>';
  155.             }
  156.  
  157.             echo $this->disp_params['item_end'];
  158.         }
  159.  
  160.         echo $this->disp_params['list_end'];
  161.  
  162.  
  163.         // Display "info" link, if activated.
  164.         if$this->disp_params['disp_info_link')
  165.         {
  166.             /**
  167.              * @var AbstractSettings
  168.              */
  169.             global $global_Cache;
  170.  
  171.             $feedhlp $global_Cache->get'feedhlp' );
  172.             ifempty$feedhlp ) )
  173.             {    // Use basic default: (fp> needs serious update) -- Note: no localization because destination is in English anyway.
  174.                 $feedhlp arrayarray'http://webreference.fr/2006/08/30/rss_atom_xml''What is RSS?' ) );
  175.             }
  176.  
  177.             if$this->disp_params'info_link' )
  178.             {
  179.                 $link_params array'target' => '_blank' );
  180.             }
  181.             else
  182.             {
  183.                 $link_params array'target' => '' );
  184.             }
  185.             display_list$feedhlp$this->disp_params['notes_start']$this->disp_params['notes_end']' '''''NULL1$link_params );
  186.         }
  187.  
  188.         echo $this->disp_params['block_end'];
  189.  
  190.         return true;
  191.     }
  192. }
  193.  
  194.  
  195. /*
  196.  * $Log: _coll_xml_feeds.widget.php,v $
  197.  * Revision 1.22  2010/02/08 17:54:48  efy-yury
  198.  * copyright 2009 -> 2010
  199.  *
  200.  * Revision 1.21  2009/09/26 12:00:44  tblue246
  201.  * Minor/coding style
  202.  *
  203.  * Revision 1.20  2009/09/25 07:33:31  efy-cantor
  204.  * replace get_cache to get_*cache
  205.  *
  206.  * Revision 1.19  2009/09/14 13:54:13  efy-arrin
  207.  * Included the ClassName in load_class() call with proper UpperCase
  208.  *
  209.  * Revision 1.18  2009/09/12 11:03:13  efy-arrin
  210.  * Included the ClassName in the loadclass() with proper UpperCase
  211.  *
  212.  * Revision 1.17  2009/06/12 13:24:09  waltercruz
  213.  * Don't show links for blog comments feed if the blog doesn't allow comments
  214.  *
  215.  * Revision 1.16  2009/03/14 19:22:30  fplanque
  216.  * minor
  217.  *
  218.  * Revision 1.15  2009/03/13 14:20:50  tblue246
  219.  * doc
  220.  *
  221.  * Revision 1.14  2009/03/13 02:32:07  fplanque
  222.  * Cleaned up widgets.
  223.  * Removed stupid widget_name param.
  224.  *
  225.  * Revision 1.13  2009/03/08 23:57:46  fplanque
  226.  * 2009
  227.  *
  228.  * Revision 1.12  2009/03/04 00:53:42  fplanque
  229.  * minor
  230.  *
  231.  * Revision 1.11  2009/02/27 19:51:35  blueyed
  232.  * XML feeds widget: add a 'disp_info_link' config option, defaulting to false. Since the help is very outdated, it makes no sense to eventually load the global_Cache just for that. Also makes the widget cleaner. Might default to true, when it provides more valuable info.
  233.  *
  234.  * Revision 1.10  2008/09/15 03:12:22  fplanque
  235.  * help link update
  236.  *
  237.  * Revision 1.9  2008/05/06 23:35:47  fplanque
  238.  * The correct way to add linebreaks to widgets is to add them to $disp_params when the container is called, right after the array_merge with defaults.
  239.  *
  240.  * Revision 1.7  2008/01/21 09:35:37  fplanque
  241.  * (c) 2008
  242.  *
  243.  * Revision 1.6  2007/12/23 16:16:18  fplanque
  244.  * Wording improvements
  245.  *
  246.  * Revision 1.5  2007/12/23 14:14:25  fplanque
  247.  * Enhanced widget name display
  248.  *
  249.  * Revision 1.4  2007/12/22 19:55:00  yabs
  250.  * cleanup from adding core params
  251.  *
  252.  * Revision 1.3  2007/11/28 17:50:24  fplanque
  253.  * normalization
  254.  *
  255.  * Revision 1.2  2007/11/27 10:02:04  yabs
  256.  * added params
  257.  *
  258.  * Revision 1.1  2007/06/25 11:02:23  fplanque
  259.  * MODULES (refactored MVC)
  260.  *
  261.  * Revision 1.2  2007/06/20 21:42:13  fplanque
  262.  * implemented working widget/plugin params
  263.  *
  264.  * Revision 1.1  2007/06/18 21:25:47  fplanque
  265.  * one class per core widget
  266.  *
  267.  */
  268. ?>

Documentation generated on Sat, 06 Mar 2010 04:06:18 +0100 by phpDocumentor 1.4.2. This site is hosted and maintained by Daniel HAHLER (Contact).