[ 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/skins/ -> skins.ctrl.php (source)

   1  <?php
   2  /**

   3   * This file implements the UI controller for skins management.

   4   *

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

   6   *

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

   8   * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.

   9   *

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

  11   *

  12   * {@internal Open Source relicensing agreement:

  13   * }}

  14   *

  15   * @package admin

  16   *

  17   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}

  18   * @author fplanque: Francois PLANQUE.

  19   *

  20   * @version $Id: skins.ctrl.php,v 1.2 2007/09/29 03:42:13 fplanque Exp $

  21   */
  22  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  23  
  24  load_class( 'skins/model/_skin.class.php' );
  25  
  26  // Check permission to display:

  27  $current_User->check_perm( 'options', 'view', true );
  28  
  29  param( 'action', 'string', 'list' );
  30  
  31  param( 'redirect_to', 'string', '?ctrl=skins' );
  32  
  33  if( param( 'skin_ID', 'integer', '', true) )
  34  {// Load file type:
  35      $SkinCache = & get_Cache( 'SkinCache' );
  36      if( ($edited_Skin = & $SkinCache->get_by_ID( $skin_ID, false )) === false )
  37      {    // We could not find the skin to edit:
  38          unset( $edited_Skin );
  39          forget_param( 'skin_ID' );
  40          $Messages->head = T_('Cannot edit skin!');
  41          $Messages->add( T_('Requested skin is not installed any longer.'), 'error' );
  42          $action = 'nil';
  43      }
  44  }
  45  
  46  
  47  /**

  48   * Perform action:

  49   */
  50  switch( $action )
  51  {
  52      case 'create':
  53          param( 'skin_folder', 'string', true );
  54  
  55          // Check permission to edit:

  56          $current_User->check_perm( 'options', 'edit', true );
  57  
  58          // CREATE NEW SKIN:

  59          $edited_Skin = & new Skin();
  60          $edited_Skin->install( $skin_folder );
  61  
  62          $Messages->add( T_('Skin has been installed.'), 'success' );
  63  
  64          // We want to highlight the edited object on next list display:

  65           $Session->set( 'fadeout_array', array( 'skin_ID' => array($edited_Skin->ID) ) );
  66  
  67          // PREVENT RELOAD & Switch to list mode:

  68          header_redirect( $redirect_to );
  69          break;
  70  
  71  
  72      case 'update':
  73          // Update skin properties:

  74  
  75          // Check permission:

  76          $current_User->check_perm( 'options', 'edit', true );
  77  
  78          // Make sure we got an skin_ID:

  79          param( 'skin_ID', 'integer', true );
  80  
  81          // load data from request

  82          if( $edited_Skin->load_from_Request() )
  83          {    // We could load data from form without errors:
  84              // Update in DB:

  85              $edited_Skin->dbupdate();
  86              $Messages->add( T_('Skin properties updated.'), 'success' );
  87  
  88              // We want to highlight the edited object on next list display:

  89               $Session->set( 'fadeout_array', array( 'skin_ID' => array($edited_Skin->ID) ) );
  90  
  91              $action = 'list';
  92          }
  93          break;
  94  
  95  
  96      case 'reload':
  97          // Reload containers:

  98  
  99           // Check permission:

 100          $current_User->check_perm( 'options', 'edit', true );
 101  
 102          // Make sure we got an skin_ID:

 103          param( 'skin_ID', 'integer', true );
 104  
 105          // Look for containers in skin file:

 106          $edited_Skin->discover_containers();
 107  
 108          // Save to DB:

 109          $edited_Skin->db_save_containers();
 110  
 111          // We want to highlight the edited object on next list display:

 112           $Session->set( 'fadeout_array', array( 'skin_ID' => array($edited_Skin->ID) ) );
 113  
 114          $action = 'list';
 115          break;
 116  
 117  
 118      case 'delete':
 119          // Uninstall a skin:

 120  
 121          // Check permission:

 122          $current_User->check_perm( 'options', 'edit', true );
 123  
 124          // Make sure we got an skin_ID:

 125          param( 'skin_ID', 'integer', true );
 126  
 127          if( param( 'confirm', 'integer', 0 ) )
 128          { // confirmed, Delete from DB:
 129              $msg = sprintf( T_('Skin &laquo;%s&raquo; uninstalled.'), $edited_Skin->dget('name') );
 130              $edited_Skin->dbdelete( true );
 131              unset( $edited_Skin );
 132              forget_param( 'skin_ID' );
 133              $Messages->add( $msg, 'success' );
 134  
 135              // PREVENT RELOAD & Switch to list mode:

 136              header_redirect( '?ctrl=skins' );
 137          }
 138          else
 139          {    // not confirmed, Check for restrictions:
 140              if( ! $edited_Skin->check_delete( sprintf( T_('Cannot uninstall skin &laquo;%s&raquo;'), $edited_Skin->dget('name') ) ) )
 141              {    // There are restrictions:
 142                  $action = 'edit';
 143              }
 144          }
 145  
 146          break;
 147  }
 148  
 149  
 150  $AdminUI->set_path( 'options', 'skins' );
 151  
 152  // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)

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

 156  $AdminUI->disp_body_top();
 157  
 158  // Begin payload block:

 159  $AdminUI->disp_payload_begin();
 160  
 161  /**

 162   * Display Payload:

 163   */
 164  switch( $action )
 165  {
 166      case 'new':
 167          // Display VIEW:

 168          $AdminUI->disp_view( 'skins/views/_skin_list_available.view.php' );
 169          break;
 170  
 171      case 'delete':
 172          // We need to ask for confirmation:

 173          $edited_Skin->confirm_delete(
 174                  sprintf( T_('Uninstall skin &laquo;%s&raquo;?'),  $edited_Skin->dget( 'name' ) ),
 175                  $action, get_memorized( 'action' ) );
 176      case 'edit':
 177      case 'update':    // we return in this state after a validation error
 178          // Display VIEW:

 179          $AdminUI->disp_view( 'skins/views/_skin.form.php' );
 180          break;
 181  
 182      case 'list':
 183          // Display VIEW:

 184          $AdminUI->disp_view( 'skins/views/_skin_list.view.php' );
 185          break;
 186  }
 187  
 188  // End payload block:

 189  $AdminUI->disp_payload_end();
 190  
 191  // Display body bottom, debug info and close </html>:

 192  $AdminUI->disp_global_footer();
 193  
 194  /*

 195   * $Log: skins.ctrl.php,v $

 196   * Revision 1.2  2007/09/29 03:42:13  fplanque

 197   * skin install UI improvements

 198   *

 199   * Revision 1.1  2007/06/25 11:01:31  fplanque

 200   * MODULES (refactored MVC)

 201   *

 202   * Revision 1.10  2007/06/24 18:28:56  fplanque

 203   * refactored skin install

 204   *

 205   * Revision 1.9  2007/04/26 00:11:15  fplanque

 206   * (c) 2007

 207   *

 208   * Revision 1.8  2007/01/23 21:45:26  fplanque

 209   * "enforce" foreign keys

 210   *

 211   * Revision 1.7  2007/01/09 00:55:16  blueyed

 212   * fixed typo(s)

 213   *

 214   * Revision 1.6  2007/01/08 02:11:56  fplanque

 215   * Blogs now make use of installed skins

 216   * next step: make use of widgets inside of skins

 217   *

 218   * Revision 1.5  2007/01/07 23:38:21  fplanque

 219   * discovery of skin containers

 220   *

 221   * Revision 1.4  2007/01/07 19:40:18  fplanque

 222   * discover skin containers

 223   *

 224   * Revision 1.3  2007/01/07 05:32:12  fplanque

 225   * added some more DB skin handling (install+uninstall+edit properties ok)

 226   * still useless though :P

 227   * next step: discover containers in installed skins

 228   *

 229   * Revision 1.2  2006/12/29 01:10:06  fplanque

 230   * basic skin registering

 231   *

 232   * Revision 1.1  2006/12/05 05:41:42  fplanque

 233   * created playground for skin management

 234   *

 235   */
 236  ?>


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