b2evolution PHP Cross Reference Blogging Systems

Source: /inc/_core/ui/_iconlegend.class.php - 114 lines - 2659 bytes - Summary - Text - Print

Description: This file implements displaying of an Icons legend. 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 displaying of an Icons legend.
   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://cvs.sourceforge.net/viewcvs.py/evocms/)
  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   * {@internal Open Source relicensing agreement:
  20   * PROGIDISTRI grants Francois PLANQUE the right to license
  21   * PROGIDISTRI's contributions to this file and the b2evolution project
  22   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  23   * }}
  24   *
  25   * @package evocore
  26   *
  27   * @author fplanque: Francois PLANQUE.
  28   * @author mbruneau: Marc BRUNEAU / PROGIDISTRI
  29   *
  30   * @version $Id: _iconlegend.class.php 6136 2014-03-08 07:59:48Z manuel $
  31   */
  32  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  33  
  34  
  35  /**
  36   * Display icon legend.
  37   *
  38   * Use {@link get_IconLegend()} to get the instance.
  39   *
  40   * @package evocore
  41   */
  42  class IconLegend
  43  {
  44      /**
  45       * List of used icon names
  46       * @var array
  47       */
  48      var $icons = array();
  49  
  50  
  51      /**
  52       * Add an icon with his legend to the icons array
  53       *
  54       * @param string name of the icon
  55       */
  56  	function add_icon( $icon )
  57      {
  58          if( !in_array( $icon, $this->icons ) )
  59          {
  60              $this->icons[] = $icon;
  61          }
  62      }
  63  
  64  
  65      /**
  66       * Display the icon legend
  67       */
  68  	function display_legend()
  69      {
  70          if( empty( $this->icons ) )
  71          {
  72              return;
  73          }
  74  
  75          // There are some icons to display:
  76          echo '<div id="icon_legend">'.T_('Legend').': ';
  77  
  78          // Loop on all map array of filenames for icons to display icons list in the same order:
  79          foreach( $this->icons as $icon )
  80          {
  81              $icon_info = get_icon_info($icon);
  82              if( ! $icon_info )
  83              {
  84                  continue;
  85              }
  86  
  87              echo '<span class="legend_element">'.get_icon( $icon ).' ';
  88  
  89              if( isset( $icon_info['legend'] ) )
  90              { // Icon has a legend:
  91                  echo $icon_info['legend'] . ' ';
  92              }
  93              else
  94              { // Icon has no legend so we use the alt:
  95                  echo $icon_info['alt'] . ' ';
  96              }
  97  
  98              echo '</span>';
  99          }
 100  
 101          echo '</div>';
 102      }
 103  
 104  
 105      /**
 106       * Reset icons array
 107       */
 108  	function reset()
 109      {
 110          $this->icons[] = array();
 111      }
 112  }
 113  
 114  ?>

title

Description

title

Description

title

Description

title

title

Body