[ Index ]
 

Code source de b2evolution 2.1.0-beta

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/blogs/inc/tools/ -> tools.ctrl.php (source)

   1  <?php
   2  /**

   3   * This file implements the UI controller for additional tools.

   4   *

   5   * b2evolution - {@link http://b2evolution.net/}

   6   * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}

   7   * @copyright (c)2003-2007 by Francois PLANQUE - {@link http://fplanque.net/}

   8   *

   9   * @package admin

  10   * @author blueyed: Daniel HAHLER

  11   *

  12   * @version $Id: tools.ctrl.php,v 1.3 2007/10/09 01:18:12 fplanque Exp $

  13   */
  14  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  15  
  16  
  17  load_funcs('plugins/_plugin.funcs.php');
  18  
  19  
  20  param( 'tab', 'string', '', true );
  21  
  22  $tab_Plugin = NULL;
  23  $tab_plugin_ID = false;
  24  
  25  if( ! empty($tab) )
  26  {    // We have requested a tab which is handled by a plugin:
  27      if( preg_match( '~^plug_ID_(\d+)$~', $tab, $match ) )
  28      { // Instanciate the invoked plugin:
  29          $tab_plugin_ID = $match[1];
  30          $tab_Plugin = & $Plugins->get_by_ID( $match[1] );
  31          if( ! $tab_Plugin )
  32          { // Plugin does not exist
  33              $Messages->add( sprintf( T_( 'The plugin with ID %d could not get instantiated.' ), $tab_plugin_ID ), 'error' );
  34              $tab_plugin_ID = false;
  35              $tab_Plugin = false;
  36              $tab = '';
  37          }
  38          else
  39          {
  40              $Plugins->call_method_if_active( $tab_plugin_ID, 'AdminTabAction', $params = array() );
  41          }
  42      }
  43      else
  44      {
  45          $tab = '';
  46          $Messages->add( 'Invalid sub-menu!' ); // Should need no translation, prevented by GUI

  47      }
  48  }
  49  
  50  // Highlight the requested tab (if valid):

  51  $AdminUI->set_path( 'tools', $tab );
  52  
  53  
  54  if( empty($tab) )
  55  { // "Main tab" actions:
  56      param( 'action', 'string', '' );
  57  
  58      switch( $action )
  59      {
  60          case 'del_itemprecache':
  61              // TODO: dh> this should really be a separate permission.. ("tools", "exec") or similar!

  62              $current_User->check_perm('options', 'edit', true);
  63  
  64              $DB->query('DELETE FROM T_items__prerendering WHERE 1=1');
  65  
  66              $Messages->add( sprintf( T_('Removed %d cached entries.'), $DB->rows_affected ), 'success' );
  67  
  68              break;
  69      }
  70  }
  71  
  72  
  73  // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)

  74  $AdminUI->disp_html_head();
  75  
  76  // Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)

  77  $AdminUI->disp_body_top();
  78  
  79  // Begin payload block:

  80  $AdminUI->disp_payload_begin();
  81  
  82  
  83  if( empty($tab) )
  84  {
  85  
  86      $block_item_Widget = & new Widget( 'block_item' );
  87  
  88  
  89      // Event AdminToolPayload for each Plugin:

  90      $tool_plugins = $Plugins->get_list_by_event( 'AdminToolPayload' );
  91      foreach( $tool_plugins as $loop_Plugin )
  92      {
  93          $block_item_Widget->title = format_to_output($loop_Plugin->name);
  94          $block_item_Widget->disp_template_replaced( 'block_start' );
  95          $Plugins->call_method_if_active( $loop_Plugin->ID, 'AdminToolPayload', $params = array() );
  96          $block_item_Widget->disp_template_raw( 'block_end' );
  97      }
  98  
  99  
 100      // TODO: dh> this should really be a separate permission.. ("tools", "exec") or similar!

 101      if( $current_User->check_perm('options', 'edit') )
 102      { // default admin actions:
 103          $block_item_Widget->title = T_('Contents cached in the database');
 104          $block_item_Widget->disp_template_replaced( 'block_start' );
 105          echo '&raquo; <a href="'.regenerate_url('action', 'action=del_itemprecache').'">'.T_('Delete pre-renderered item cache.').'</a>';
 106          $block_item_Widget->disp_template_raw( 'block_end' );
 107      }
 108  
 109  
 110      // fp> TODO: pluginize MT! :P

 111      $block_item_Widget->title = T_('Movable Type Import');
 112      $block_item_Widget->disp_template_replaced( 'block_start' );
 113      ?>
 114          <ol>
 115              <li><?php echo T_('Use MT\'s export functionnality to create a .TXT file containing your posts;') ?></li>
 116              <li><?php printf( T_('Follow the insctructions in <a %s>Daniel\'s Movable Type Importer</a>.'), ' href="?ctrl=mtimport"' ) ?></li>
 117          </ol>
 118      <?php
 119      $block_item_Widget->disp_template_raw( 'block_end' );
 120  
 121  
 122      $block_item_Widget->title = T_('WordPress Import');
 123      $block_item_Widget->disp_template_replaced( 'block_start' );
 124      printf( '<p>'.T_('You can import contents from your WordPress 2.3 database into your b2evolution database by using <a %s>Hari\'s WordPress Importer</a>.').'</p>', ' href="?ctrl=wpimport"' );
 125      $block_item_Widget->disp_template_raw( 'block_end' );
 126  
 127  }
 128  elseif( $tab_Plugin )
 129  { // Plugin tab
 130  
 131      // Icons:

 132      ?>
 133  
 134      <div class="right_icons">
 135  
 136      <?php
 137      echo $tab_Plugin->get_edit_settings_link()
 138          .' '.$tab_Plugin->get_help_link('$help_url')
 139          .' '.$tab_Plugin->get_help_link('$readme');
 140      ?>
 141  
 142      </div>
 143  
 144      <?php
 145      $Plugins->call_method_if_active( $tab_plugin_ID, 'AdminTabPayload', $params = array() );
 146  }
 147  
 148  
 149  // End payload block:

 150  $AdminUI->disp_payload_end();
 151  
 152  // Display body bottom, debug info and close </html>:

 153  $AdminUI->disp_global_footer();
 154  
 155  /*

 156   * $Log: tools.ctrl.php,v $

 157   * Revision 1.3  2007/10/09 01:18:12  fplanque

 158   * Hari's WordPress importer

 159   *

 160   * Revision 1.2  2007/09/04 14:57:07  fplanque

 161   * interface cleanup

 162   *

 163   * Revision 1.1  2007/06/25 11:01:42  fplanque

 164   * MODULES (refactored MVC)

 165   *

 166   */
 167  ?>


Généré le : Thu Nov 29 23:58:50 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics