b2evolution PHP Cross Reference Blogging Systems

Source: /inc/widgets/widgets/_coll_comment_list.widget.php - 196 lines - 5401 bytes - Summary - Text - Print

Description: This file implements the Comment List 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 Comment List 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   * @author Yabba    - {@link http://www.astonishme.co.uk/}
  24   *
  25   * @version $Id: _coll_comment_list.widget.php 6136 2014-03-08 07:59:48Z manuel $
  26   */
  27  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  28  
  29  load_class( 'widgets/model/_widget.class.php', 'ComponentWidget' );
  30  
  31  /**
  32   * ComponentWidget Class
  33   *
  34   * A ComponentWidget is a displayable entity that can be placed into a Container on a web page.
  35   *
  36   * @package evocore
  37   */
  38  class coll_comment_list_Widget extends ComponentWidget
  39  {
  40      /**
  41       * Constructor
  42       */
  43  	function coll_comment_list_Widget( $db_row = NULL )
  44      {
  45          // Call parent constructor:
  46          parent::ComponentWidget( $db_row, 'core', 'coll_comment_list' );
  47      }
  48  
  49  
  50    /**
  51     * Get definitions for editable params
  52     *
  53       * @see Plugin::GetDefaultSettings()
  54       * @param local params like 'for_editing' => true
  55       */
  56  	function get_param_definitions( $params )
  57      {
  58          $r = array_merge( array(
  59              'title' => array(
  60                  'label' => T_('Block title'),
  61                  'note' => T_( 'Title to display in your skin.' ),
  62                  'size' => 40,
  63                  'defaultvalue' => T_('Recent comments'),
  64              ),
  65              'disp_order' => array(
  66                  'label' => T_('Order'),
  67                  'note' => T_('Order to display items'),
  68                  'type' => 'select',
  69                  'options' => array( 'DESC' => T_( 'Newest to oldest' ), 'ASC' => T_( 'Oldest to newest' ), 'RAND' => T_( 'Random selection' ) ),
  70                  'defaultvalue' => 'DESC',
  71              ),
  72              'limit' => array(
  73                  'label' => T_( 'Max items' ),
  74                  'note' => T_( 'Maximum number of items to display.' ),
  75                  'size' => 4,
  76                  'defaultvalue' => 20,
  77              ),
  78              'author_links' => array(
  79                  'label' => T_( 'Link to author'),
  80                  'note' => T_( 'Link the author to their url' ),
  81                  'defaultvalue' => true,
  82                  'type' => 'checkbox',
  83              ),
  84              'hover_text' => array(
  85                  'label' => T_( 'Hover text'),
  86                  'note' => T_( 'Text to show when hovering over the link' ),
  87                  'size' => 40,
  88                  'defaultvalue' => T_( 'Read the full comment' ),
  89                  'type' => 'text',
  90              ),
  91              'blog_ID' => array(
  92                  'label' => T_( 'Blog' ),
  93                  'note' => T_( 'ID of the blog to use, leave empty for the current blog.' ),
  94                  'size' => 4,
  95              ),
  96          ), parent::get_param_definitions( $params )    );
  97  
  98          return $r;
  99      }
 100  
 101  
 102      /**
 103       * Get name of widget
 104       */
 105  	function get_name()
 106      {
 107          return T_('Comment list');
 108      }
 109  
 110  
 111      /**
 112       * Get a very short desc. Used in the widget list.
 113       */
 114  	function get_short_desc()
 115      {
 116          return format_to_output($this->disp_params['title']);
 117      }
 118  
 119  
 120    /**
 121       * Get short description
 122       */
 123  	function get_desc()
 124      {
 125          return T_('List of comments; click goes to comment.');
 126      }
 127  
 128  
 129      /**
 130       * Display the widget!
 131       *
 132       * @param array MUST contain at least the basic display params
 133       */
 134  	function display( $params )
 135      {
 136          $this->init_display( $params );
 137  
 138          global $Blog;
 139  
 140          $blogCache = & get_BlogCache();
 141          $listBlog = ( $this->disp_params[ 'blog_ID' ] ? $blogCache->get_by_ID( $this->disp_params[ 'blog_ID' ] ) : $Blog );
 142  
 143          // Create ItemList
 144          // Note: we pass a widget specific prefix in order to make sure to never interfere with the mainlist
 145          $limit = $this->disp_params[ 'limit' ];
 146          $order = $this->disp_params[ 'disp_order' ];
 147  
 148          $CommentList = new CommentList2( $listBlog );
 149  
 150          // Filter list:
 151          $CommentList->set_filters( array(
 152                  'types' => array( 'comment','trackback','pingback' ),
 153                  'statuses' => array( 'published' ),
 154                  'order' => $order,
 155                  'comments' => $limit,
 156              ) );
 157  
 158          // Get ready for display (runs the query):
 159          $CommentList->display_init();
 160  
 161          echo $this->disp_params[ 'block_start'];
 162  
 163          // Display title if requested
 164          $this->disp_title();
 165  
 166          echo $this->disp_params[ 'list_start' ];
 167  
 168          if( empty( $this->disp_params[ 'author_link_text' ] ) )
 169          {
 170              $this->disp_params[ 'author_link_text' ] = 'login';
 171          }
 172  
 173          /**
 174           * @var Comment
 175           */
 176          while( $Comment = & $CommentList->get_next() )
 177          { // Loop through comments:
 178              // Load comment's Item object:
 179              $Comment->get_Item();
 180              echo $this->disp_params[ 'item_start' ];
 181              $Comment->author( '', ' ', '', ' ', 'htmlbody', $this->disp_params[ 'author_links' ], $this->disp_params[ 'author_link_text' ] );
 182              echo T_( 'on ' );
 183              $Comment->permanent_link( array(
 184                  'text'        => $Comment->Item->title,
 185                  'title'       => $this->disp_params[ 'hover_text' ],
 186                  ) );
 187              echo $this->disp_params[ 'item_end' ];
 188          }    // End of comment loop.}
 189          echo $this->disp_params[ 'list_end' ];
 190          echo $this->disp_params[ 'block_end' ];
 191  
 192          return true;
 193      }
 194  }
 195  
 196  ?>

title

Description

title

Description

title

Description

title

title

Body