[ 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/generic/model/ -> _genericelement.class.php (source)

   1  <?php
   2  /**

   3   * This file implements the Generic Element class, which manages user groups.

   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-2007 by Francois PLANQUE - {@link http://fplanque.net/}

   9   * Parts of this file are copyright (c)2005-2006 by PROGIDISTRI - {@link http://progidistri.com/}.

  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   * {@internal Open Source relicensing agreement:

  21   * PROGIDISTRI S.A.S. grants Francois PLANQUE the right to license

  22   * PROGIDISTRI S.A.S.'s contributions to this file and the b2evolution project

  23   * under any OSI approved OSS license (http://www.opensource.org/licenses/).

  24   * }}

  25   *

  26   * @package evocore

  27   *

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

  29   * @author fplanque: Francois PLANQUE.

  30   * @author mbruneau: Marc BRUNEAU / PROGIDISTRI

  31   *

  32   * @version $Id: _genericelement.class.php,v 1.1 2007/06/25 11:00:17 fplanque Exp $

  33   */
  34  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  35  
  36  load_class('_core/model/dataobjects/_dataobject.class.php');
  37  
  38  /**

  39   * User Element

  40   *

  41   * Generic Element of users with specific permissions.

  42   *

  43   * @package evocore

  44   */
  45  class GenericElement extends DataObject
  46  {
  47      /**

  48       * Name of Generic Element

  49       *

  50       * @var string

  51       * @access protected

  52       */
  53      var $name;
  54  
  55  
  56      /**

  57       * Constructor

  58       *

  59       * @param string Name of table in database

  60       * @param string Prefix of fields in the table

  61       * @param string Name of the ID field (including prefix)

  62       * @param object DB row

  63       */
  64  	function GenericElement( $tablename, $prefix = '', $dbIDname = 'ID', $db_row = NULL )
  65      {
  66          global $Debuglog;
  67  
  68          // Call parent constructor:

  69          parent::DataObject( $tablename, $prefix, $dbIDname );
  70  
  71          if( $db_row != NULL )
  72          {
  73              // echo 'Instanciating existing group';

  74              $this->ID = $db_row->$dbIDname;
  75              $this->name = $db_row->{$prefix.'name'};
  76          }
  77  
  78          $Debuglog->add( "Created element <strong>$this->name</strong>", 'dataobjects' );
  79      }
  80  
  81  
  82      /**

  83       * Load data from Request form fields.

  84       *

  85       * @return boolean true if loaded data seems valid.

  86       */
  87  	function load_from_Request()
  88      {
  89  
  90  
  91          param_string_not_empty( $this->dbprefix.'name', T_('Please enter a name.') );
  92          $this->set_from_Request( 'name' );
  93  
  94          return ! param_errors_detected();
  95      }
  96  
  97  
  98      /**

  99       * TODO

 100       *

 101       */
 102  	function disp_form()
 103      {
 104          global $ctrl, $action, $edited_name_maxlen, $form_below_list;
 105  
 106          // Determine if we are creating or updating...

 107          $creating = is_create_action( $action );
 108  
 109          $Form = & new Form( NULL, 'form' );
 110  
 111          if( !$form_below_list )
 112          { // We need to display a link to cancel editing:
 113              $Form->global_icon( T_('Cancel editing!'), 'close', regenerate_url( 'action' ) );
 114          }
 115  
 116          $Form->begin_form( 'fform', $creating ?  T_('New element') : T_('Element') );
 117  
 118          $Form->hidden( 'action', $creating ? 'create' : 'update' );
 119  
 120          $Form->hidden( 'ctrl', $ctrl );
 121  
 122          $Form->hiddens_by_key( get_memorized( 'action, ctrl' ) );
 123  
 124          $Form->text_input( $this->dbprefix.'name', $this->name, $edited_name_maxlen, T_('name'), '', array( 'required' => true ) );
 125  
 126          if( ! $creating ) $Form->hidden( $this->dbIDname, $this->ID );
 127  
 128          if( $creating )
 129          {
 130              $Form->end_form( array( array( 'submit', 'submit', T_('Record'), 'SaveButton' ),
 131                                                              array( 'reset', '', T_('Reset'), 'ResetButton' ) ) );
 132          }
 133          else
 134          {
 135              $Form->end_form( array( array( 'submit', 'submit', T_('Update'), 'SaveButton' ),
 136                                                              array( 'reset', '', T_('Reset'), 'ResetButton' ) ) );
 137          }
 138      }
 139  
 140  
 141      /**

 142       * Template function: return name of item

 143       *

 144       * @param string Output format, see {@link format_to_output()}

 145       * @return string

 146       */
 147  	function get_name( $format = 'htmlbody' )
 148      {
 149          return $this->dget( 'name', $format );
 150      }
 151  
 152  }
 153  
 154  /*

 155   * $Log: _genericelement.class.php,v $

 156   * Revision 1.1  2007/06/25 11:00:17  fplanque

 157   * MODULES (refactored MVC)

 158   *

 159   * Revision 1.9  2007/04/26 00:11:11  fplanque

 160   * (c) 2007

 161   *

 162   * Revision 1.8  2006/12/09 01:55:35  fplanque

 163   * feel free to fill in some missing notes

 164   * hint: "login" does not need a note! :P

 165   *

 166   * Revision 1.7  2006/11/24 18:27:24  blueyed

 167   * Fixed link to b2evo CVS browsing interface in file docblocks

 168   */
 169  ?>


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