[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/etemplate/doc/et_media/inc/ -> class.ui_et_media.inc.php (source)

   1  <?php
   2  /**
   3   * eGroupWare editable Templates - Example media database (et_media)
   4   *
   5   * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
   6   * @package etemplate
   7   * @subpackage et_media
   8   * @link http://www.egroupware.org
   9   * @author Ralf Becker <RalfBecker@outdoor-training.de>
  10   * @version $Id: class.ui_et_media.inc.php 22855 2006-11-18 07:38:09Z ralfbecker $ 
  11   */
  12  
  13  include_once (EGW_INCLUDE_ROOT . '/et_media/inc/class.bo_et_media.inc.php');
  14  
  15  class ui_et_media extends bo_et_media
  16  {
  17      /**
  18       * Public functions callable via menuaction
  19       *
  20       * @var array
  21       */
  22      var $public_functions = array(
  23          'edit' => True,
  24          'writeLangFile' => True
  25      );
  26  
  27      /**
  28       * Constructor
  29       *
  30       * @return ui_et_media
  31       */
  32  	function ui_et_media()
  33      {
  34          $this->bo_et_media();    // calling the constructor of the extended bo object
  35  
  36          $this->tmpl =& CreateObject('etemplate.etemplate','et_media.edit');
  37      }
  38  
  39      /**
  40       * Edit a media database entry
  41       *
  42       * @param array $content=null
  43       * @param string $msg=''
  44       */
  45  	function edit($content=null,$msg = '')
  46      {
  47          if (is_array($content))    // not first call from index
  48          {
  49              if ($content['id'] > 0)
  50              {
  51                  $this->read($content);
  52              }
  53              //echo "<p>edit: content ="; _debug_array($content);
  54              $this->data_merge($content);
  55              //echo "<p>edit: data ="; _debug_array($this->data);
  56  
  57              if (isset($content['save']))
  58              {
  59                  $msg .= !$this->save() ? lang('Entry saved') : lang('Error: while saving !!!');
  60              }
  61              elseif (isset($content['read']))
  62              {
  63                  unset($content['id']);
  64                  unset($content['read']);
  65                  $found = $this->search($content,False,'name,author');
  66  
  67                  if (!$found)
  68                  {
  69                      $msg .= lang('Nothing matched search criteria !!!');
  70                  }
  71                  elseif (count($found) == 1)
  72                  {
  73                      $this->init($found[0]);
  74                  }
  75                  else
  76                  {
  77                      $this->show($found);
  78                      return;
  79                  }
  80              }
  81              elseif (isset($content['cancel']))
  82              {
  83                  $this->init();
  84              }
  85              elseif (isset($content['delete']))
  86              {
  87                  $this->delete();
  88                  $this->init();
  89              }
  90              elseif (isset($content['entry']['edit']))
  91              {
  92                  list($id) = each($content['entry']['edit']);
  93                  if ($id > 0)
  94                  {
  95                      $this->read(array('id' => $id));
  96                  }
  97              }
  98          }
  99  
 100          // now we filling the content array for the next call to etemplate.exec
 101  
 102          $content = $this->data + array(
 103              'msg' => $msg
 104          );
 105          $sel_options = array(
 106              'type' => $this->types
 107          );
 108          $no_button = array(
 109              'delete' => !$this->data[$this->db_key_cols[$this->autoinc_id]]
 110          );
 111          $this->tmpl->exec('et_media.ui_et_media.edit',$content,$sel_options,$no_button,array(
 112              'id' => $this->data['id']
 113          ));
 114      }
 115  
 116      /**
 117       * Showing entries from the media database
 118       *
 119       * @param array $found
 120       */
 121  	function show($found=null)
 122      {
 123          if (!is_array($found) || !count($found))
 124          {
 125              $this->edit();
 126              return;
 127          }
 128          array_unshift($found,false);    // change the array to start with index 1
 129          $content = array(
 130              'msg' => lang('%1 matches on search criteria',count($found)),
 131              'entry' => $found,
 132          );
 133          $this->tmpl->read('et_media.show');
 134  
 135          $this->tmpl->exec('et_media.ui_et_media.edit',$content);
 136      }
 137  }


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7