b2evolution PHP Cross Reference Blogging Systems

Source: /inc/widgets/views/_widget_list.view.php - 222 lines - 7050 bytes - Summary - Text - Print

Description: This file implements the UI view for the widgets installed on a blog. This file is part of the b2evolution/evocms project - {@link http://b2evolution.net/}. See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file implements the UI view for the widgets installed on a blog.
   4   *
   5   * This file is part of the b2evolution/evocms project - {@link http://b2evolution.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   * @license http://b2evolution.net/about/license.html GNU General Public License (GPL)
  11   *
  12   * @package admin
  13   *
  14   * @version $Id: _widget_list.view.php 6136 2014-03-08 07:59:48Z manuel $
  15   */
  16  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  17  
  18  global $Blog;
  19  
  20  global $container_Widget_array;
  21  
  22  global $container_list;
  23  
  24  if(    $current_User->check_perm( 'options', 'edit', false ) )
  25  {
  26      echo '<div class="floatright small">'.action_icon( TS_('Reload containers!'), 'reload',
  27                              '?ctrl=widgets&amp;blog='.$Blog->ID.'&amp;action=reload&amp;'.url_crumb('widget'), T_('Reload containers!') ).'</div>';
  28  }
  29  
  30  // Load widgets for current collection:
  31  $WidgetCache = & get_WidgetCache();
  32  $container_Widget_array = & $WidgetCache->get_by_coll_ID( $Blog->ID );
  33  
  34  /**
  35   * @param string Title of the container. This gets passed to T_()!
  36   * @param string Suffix of legend
  37   */
  38  function display_container( $container, $legend_suffix = '' )
  39  {
  40      global $Blog;
  41      global $Session;
  42  
  43      $Table = new Table();
  44  
  45      $Table->title = '<span class="container_name">'.T_($container).'</span>'.$legend_suffix;
  46  
  47      // Table ID - fp> needs to be handled cleanly by Table object
  48      $table_id = str_replace( ' ', '_', $container ); // fp> Using the container name which has special chars is a bad idea. Counter would be better
  49  
  50      $Table->global_icon( T_('Add a widget...'), 'new',
  51              regenerate_url( '', 'action=new&amp;container='.rawurlencode($container) ), /* TRANS: ling used to add a new widget */ T_('Add widget').' &raquo;', 3, 4, array( 'id' => 'add_new_'.$table_id ) );
  52  
  53      $Table->cols = array(
  54              array(
  55                  'th' => /* TRANS: shortcut for enabled */ T_( 'En' ),
  56                  'th_class' => 'shrinkwrap',
  57                  'td_class' => 'shrinkwrap' ),
  58              array( 'th' => T_('Widget') ),
  59              array( 'th' => T_('Type') ),
  60              array(
  61                  'th' => T_('Move'),
  62                  'th_class' => 'shrinkwrap',
  63                  'td_class' => 'shrinkwrap' ),
  64              array(
  65                  'th' => T_('Actions'),
  66                  'th_class' => 'shrinkwrap',
  67                  'td_class' => 'shrinkwrap' ),
  68          );
  69      //enable fadeouts here
  70      $Table->display_init( NULL, array('fadeouts' => true) );
  71      // add ID for jQuery
  72      // TODO: fp> Awfully dirty. This should be handled by the Table object
  73      $Table->params['list_start'] = str_replace( '<table', '<table id="'.$table_id.'"', $Table->params['list_start'] );
  74  
  75      /*
  76      if( $legend_suffix )
  77      {    // add jQuery no-drop -- fp> what do we need this one for?
  78          $Table->params['head_title'] = str_replace( 'class="grouped"', 'class="grouped no-drop"', $Table->params['head_title'] );
  79      }
  80      */
  81  
  82      $Table->display_list_start();
  83  
  84      // TITLE / COLUMN HEADERS:
  85      $Table->display_head();
  86  
  87      // BODY START:
  88      $Table->display_body_start();
  89  
  90      /**
  91       * @var WidgetCache
  92       */
  93      $WidgetCache = & get_WidgetCache();
  94      $Widget_array = & $WidgetCache->get_by_coll_container( $Blog->ID, $container );
  95  
  96      if( empty($Widget_array) )
  97      {    // TODO: cleanup
  98          $Table->display_line_start( true );
  99          $Table->display_col_start( array( 'colspan' => 5 ) );
 100          echo '<span class="new_widget">'.T_('There is no widget in this container yet.').'</span>';
 101          $Table->display_col_end();
 102          $Table->display_line_end();
 103      }
 104      else
 105      {
 106          $widget_count = 0;
 107          foreach( $Widget_array as $ComponentWidget )
 108          {
 109              $widget_count++;
 110              $enabled = $ComponentWidget->get( 'enabled' );
 111  
 112              $fadeout_id = $Session->get( 'fadeout_id' );
 113              if( isset($fadeout_id) && $ComponentWidget->ID == $fadeout_id )
 114              {
 115                  $fadeout = true;
 116                  $Session->delete( 'fadeout_id' );
 117              }
 118              else
 119              {
 120                  $fadeout = false;
 121              }
 122  
 123              $Table->display_line_start( false, $fadeout );
 124  
 125              $Table->display_col_start();
 126              if ( $enabled )
 127              {
 128                  // Indicator for the JS UI:
 129                  echo '<span class="widget_is_enabled">';
 130                  echo get_icon( 'enabled', 'imgtag', array( 'title' => T_( 'The widget is enabled.' ) ) );
 131                  echo '</span>';
 132              }
 133              else
 134              {
 135                  echo get_icon( 'disabled', 'imgtag', array( 'title' => T_( 'The widget is disabled.' ) ) );
 136              }
 137              $Table->display_col_end();
 138  
 139              $Table->display_col_start();
 140              $ComponentWidget->init_display( array() );
 141              echo '<a href="'.regenerate_url( 'blog', 'action=edit&amp;wi_ID='.$ComponentWidget->ID).'" class="widget_name">'
 142                          .$ComponentWidget->get_desc_for_list().'</a>';
 143              $Table->display_col_end();
 144  
 145              // Note: this is totally useless, but we need more cols for the screen to feel "right":
 146              $Table->display_col_start();
 147              echo $ComponentWidget->type;
 148              $Table->display_col_end();
 149  
 150              // Move
 151              $Table->display_col_start();
 152              //echo $ComponentWidget->order.' ';
 153              if( $widget_count > 1 )
 154              {
 155                  echo action_icon( T_('Move up!'), 'move_up', regenerate_url( 'blog', 'action=move_up&amp;wi_ID='.$ComponentWidget->ID.'&amp;'.url_crumb('widget') ) );
 156              }
 157              else
 158              {
 159                  echo get_icon( 'nomove', 'imgtag', array( 'class'=>'action_icon' ) );
 160              }
 161              if( $widget_count < count($Widget_array))
 162              {
 163                  echo action_icon( T_('Move down!'), 'move_down', regenerate_url( 'blog', 'action=move_down&amp;wi_ID='.$ComponentWidget->ID.'&amp;'.url_crumb('widget') ) );
 164              }
 165              else
 166              {
 167                  echo get_icon( 'nomove', 'imgtag', array( 'class'=>'action_icon' ) );
 168              }
 169              $Table->display_col_end();
 170  
 171              // Actions
 172              $Table->display_col_start();
 173              if ( $enabled )
 174              {
 175                  echo action_icon( T_( 'Disable this widget!' ), 'deactivate', regenerate_url( 'blog', 'action=toggle&amp;wi_ID='.$ComponentWidget->ID.'&amp;'.url_crumb('widget') ) );
 176              }
 177              else
 178              {
 179                  echo action_icon( T_( 'Enable this widget!' ), 'activate', regenerate_url( 'blog', 'action=toggle&amp;wi_ID='.$ComponentWidget->ID.'&amp;'.url_crumb('widget') ) );
 180              }
 181              echo '<span class="edit_icon_hook">'.action_icon( T_('Edit widget settings!'), 'edit', regenerate_url( 'blog', 'action=edit&amp;wi_ID='.$ComponentWidget->ID ) ).'</span>';
 182              echo '<span class="delete_icon_hook">'.action_icon( T_('Remove this widget!'), 'delete', regenerate_url( 'blog', 'action=delete&amp;wi_ID='.$ComponentWidget->ID.'&amp;'.url_crumb('widget') ) ).'</span>';
 183              $Table->display_col_end();
 184  
 185              $Table->display_line_end();
 186          }
 187      }
 188  
 189      // BODY END:
 190      $Table->display_body_end();
 191  
 192      $Table->display_list_end();
 193  }
 194  
 195  // fp> what browser do we need a fielset for?
 196  echo '<fieldset id="current_widgets">'."\n"; // fieldsets are cool at remembering their width ;)
 197  
 198  // Display containers for current skin:
 199  foreach( $container_list as $container )
 200  {
 201      display_container( $container );
 202  }
 203  
 204  // Display containers not in current skin:
 205  foreach( $container_Widget_array as $container=>$dummy )
 206  {
 207      if( !in_array( $container, $container_list ) )
 208      {
 209          display_container( $container, ' '.T_('[NOT INCLUDED IN SELECTED SKIN!]') );
 210      }
 211  }
 212  
 213  global $rsc_url;
 214  
 215  echo '<!--[if IE]>'.get_icon( 'pixel' ).'<![endif]-->';
 216  
 217  echo '</fieldset>'."\n";
 218  
 219  
 220  echo get_icon( 'pixel', 'imgtag', array( 'class' => 'clear' ) );
 221  
 222  ?>

title

Description

title

Description

title

Description

title

title

Body