b2evolution

Multilingual multiuser multiblog engine

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

Source for file _coll_avatar.widget.php

Documentation is available at _coll_avatar.widget.php

  1. <?php
  2. /**
  3.  * This file implements the coll_avatar_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.  *  Parts of this file are copyright (c)2008 by Daniel HAHLER - {@link http://daniel.hahler.de/}.
  10.  *
  11.  *  {@internal License choice
  12.  *  - If you have received this file as part of a package, please find the license.txt file in
  13.  *    the same folder or the closest folder above for complete license terms.
  14.  *  - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  15.  *    then you must choose one of the following licenses before using the file:
  16.  *    - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  17.  *    - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  18.  *  }}}
  19.  *
  20.  * @package evocore
  21.  *
  22.  *  {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  23.  * @author blueyed: Daniel HAHLER
  24.  * @author fplanque: Francois PLANQUE.
  25.  *
  26.  * @version $Id: _coll_avatar.widget.php,v 1.8 2010/02/08 17:54:47 efy-yury Exp $
  27.  */
  28. if!defined('EVO_MAIN_INIT') ) die'Please, do not access this page directly.' );
  29.  
  30. load_class'widgets/model/_widget.class.php''ComponentWidget' );
  31.  
  32. /**
  33.  * coll_avatar_Widget Class.
  34.  *
  35.  * This displays the blog owner's avatar.
  36.  *
  37.  * @package evocore
  38.  */
  39. {
  40.     /**
  41.      * Constructor
  42.      */
  43.     function coll_avatar_Widget$db_row NULL )
  44.     {
  45.         // Call parent constructor:
  46.         parent::ComponentWidget$db_row'core''coll_avatar' );
  47.     }
  48.  
  49.  
  50.     /**
  51.      * Get name of widget
  52.      */
  53.     function get_name()
  54.     {
  55.         return T_('Avatar');
  56.     }
  57.  
  58.  
  59.     /**
  60.      * Get short description
  61.      */
  62.     function get_desc()
  63.     {
  64.         return T_('Display the avatar of the blog owner.');
  65.     }
  66.  
  67.  
  68.     /**
  69.      * Get definitions for editable params
  70.      *
  71.      * @see Plugin::GetDefaultSettings()
  72.      * @param array local params
  73.      *   - 'size': Size definition, see {@link $thumbnail_sizes}. E.g. 'fit-160x160'.
  74.      */
  75.     function get_param_definitions$params )
  76.     {
  77.         global $thumbnail_sizes;
  78.  
  79.         $options array();
  80.         // PHP 4 replacement for array_combine():
  81.         foreacharray_keys$thumbnail_sizes as $thumb_size )
  82.         {
  83.             $options[$thumb_size$thumb_size;
  84.         }
  85.  
  86.         $r array_mergearray(
  87.             'thumb_size' => array(
  88.                     'type' => 'select',
  89.                     'label' => T_('Image size'),
  90.                     'options' => $options,
  91.                     'note' => sprintf/* TRANS: %s is a config variable name */ T_('List of available image sizes is defined in %s.')'$thumbnail_sizes' ),
  92.                     'defaultvalue' => 'fit-160x160',
  93.                 ),
  94.             )parent::get_param_definitions$params ) );
  95.  
  96.         return $r;
  97.     }
  98.  
  99.  
  100.     /**
  101.      * Display the widget!
  102.      *
  103.      * @param array MUST contain at least the basic display params
  104.      */
  105.     function display$params )
  106.     {
  107.         global $cat_modifier;
  108.         global $Blog;
  109.  
  110.         $this->init_display$params );
  111.  
  112.         $owner_User $Blog->get_owner_User();
  113.  
  114.         if$owner_User->has_avatar() )
  115.         {
  116.             return false;
  117.         }
  118.  
  119.         // START DISPLAY:
  120.         echo $this->disp_params['block_start'];
  121.  
  122.         // Display title if requested
  123.         $this->disp_title();
  124.  
  125.         echo $owner_User->get_linkarray(
  126.                 'link_to'           => 'userpage',  // TODO: make configurable $this->disp_params['link_to']
  127.                 'link_text'    => 'avatar',
  128.                 'thumb_size'     => $this->disp_params['thumb_size'],
  129.             ) );
  130.  
  131.         echo $this->disp_params['block_end'];
  132.  
  133.         return true;
  134.     }
  135.  
  136.  
  137.     /**
  138.      * Maybe be overriden by some widgets, depending on what THEY depend on..
  139.      *
  140.      * @return array of keys this widget depends on
  141.      */
  142.     function get_cache_keys()
  143.     {
  144.         global $Blog;
  145.  
  146.         $owner_User $Blog->get_owner_User();
  147.  
  148.         return array(
  149.                 'wi_ID'   => $this->ID,                    // Have the widget settings changed ?
  150.                 'set_coll_ID' => $Blog->ID,            // Have the settings of the blog changed ? (ex: new owner, new skin)
  151.                 'user_ID' => $owner_User->ID,     // Has the owner User changed? (name, avatar, etc..)
  152.             );
  153.     }
  154. }
  155.  
  156.  
  157. /*
  158.  * $Log: _coll_avatar.widget.php,v $
  159.  * Revision 1.8  2010/02/08 17:54:47  efy-yury
  160.  * copyright 2009 -> 2010
  161.  *
  162.  * Revision 1.7  2009/12/01 04:19:25  fplanque
  163.  * even more invalidation dimensions
  164.  *
  165.  * Revision 1.6  2009/12/01 03:45:37  fplanque
  166.  * multi dimensional invalidation
  167.  *
  168.  * Revision 1.5  2009/10/03 21:00:50  tblue246
  169.  * Bugfixes
  170.  *
  171.  * Revision 1.4  2009/09/30 19:09:39  blueyed
  172.  * trans fix
  173.  *
  174.  * Revision 1.3  2009/09/20 01:35:52  fplanque
  175.  * Factorized User::get_link()
  176.  *
  177.  * Revision 1.2  2009/09/20 00:51:43  fplanque
  178.  * OMG!!
  179.  *
  180.  * Revision 1.1  2009/09/20 00:33:59  blueyed
  181.  * Add widget to display avatar of collection/blog owner. Install it for all new blogs by default.
  182.  *
  183.  */
  184. ?>

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