[ Index ]
 

Code source de eGroupWare 1.2.106-2

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

title

Body

[fermer]

/sitemgr/modules/ -> class.module_appdir.inc.php (source)

   1  <?php
   2      /**************************************************************************\
   3      * eGroupWare SiteMgr - Web Content Management                              *
   4      * http://www.egroupware.org                                                *
   5      * --------------------------------------------                             *
   6      *  This program is free software; you can redistribute it and/or modify it *
   7      *  under the terms of the GNU General Public License as published by the   *
   8      *  Free Software Foundation; either version 2 of the License, or (at your  *
   9      *  option) any later version.                                              *
  10      \**************************************************************************/
  11  
  12      /* $Id: class.module_appdir.inc.php 20295 2006-02-15 12:31:25Z  $ */
  13  
  14  // this module is only for demonstrative purposes,
  15  // a real appdir would be better defined as a real phpgw application 
  16  // and a sitemgr module would not have to handle the data, but only to fetch it
  17  class module_appdir extends Module
  18  {
  19  
  20  	function module_appdir()
  21      {
  22          $this->arguments = array();
  23          $this->title = lang('An application directory');
  24          $this->description = lang('This module demonstrates how handling data stored in XML and building an interacvite interface from it');
  25      }
  26  
  27  	function get_user_interface()
  28      {
  29          $interface = array();
  30  
  31          $allapps = $this->block->arguments['directory'];
  32          //xmltool2 is a slightly modified version of phpgwapi.xmltool of HEAD
  33          $xmltool =& CreateObject('sitemgr.xmltool2');
  34          $xmltool->import_xml($allapps);
  35          $apparray = $xmltool->export_var();        
  36          $i = 0;
  37          while (list(,$app) = @each($apparray['app']))
  38          {
  39              $element['label'] = '<hr>';
  40              $element['form'] = '<hr>';
  41              $interface[] = $element;
  42              $element['label'] = '<b>'.$app['name'][0].'</b>';
  43              $element['form'] = '';
  44              $interface[] = $element;
  45              foreach(array('name','maintainer','url','description') as $key)
  46              {
  47                  $elementname = 'element[' . $this->block->version . '][' .$key . '][' . $i .']';
  48                  $element['label'] = ucfirst($key);
  49                  $element['form'] = $this->build_input_element(
  50                      array(
  51                          'type' => ($key == 'description') ? 'textarea' : 'textfield',
  52                          'params' => ($key == 'description') ? array('cols' => 50,'rows' => 15) : array('size' => 50)),
  53                      $app[$key][0],
  54                      $elementname
  55                  );
  56                  $interface[] = $element;
  57              }
  58              $element['label'] = lang('Delete this application');
  59              $element['form'] = $this->build_input_element(
  60                  array('type' => 'checkbox'),
  61                  False,
  62                  'element[' . $this->block->version . '][delete][' . $i . ']'
  63              );
  64              $interface[] = $element;
  65              $i++;
  66          }
  67          $element['label'] = '<hr>';
  68          $element['form'] = '<hr>';
  69          $interface[] = $element;
  70          $element['label'] = lang('Add a new application');
  71          $element['form'] = $this->build_input_element(
  72              array('type' => 'checkbox'),
  73              False,
  74              'element[' . $this->block->version . '][addnew]'
  75          );
  76          $interface[] = $element;
  77          return $interface;
  78      }
  79  
  80  	function validate(&$data)
  81      {
  82          $xmltool =& CreateObject('sitemgr.xmltool2','node','directory','');
  83          $i = 0;
  84          while (isset($data['name'][$i]))
  85          {
  86              if (!$data['delete'][$i])
  87              {
  88                  $xmltool->import_var(
  89                      'app',
  90                      array(
  91                          'name' => $data['name'][$i],
  92                          'maintainer' => $data['maintainer'][$i],
  93                          'url'  => $data['url'][$i],
  94                          'description' => $data['description'][$i],
  95                      )
  96                  );
  97              }
  98              $i++;
  99          }
 100          if ($data['addnew'])
 101          {
 102              $xmltool->import_var(
 103                  'app',
 104                  array(
 105                      'name' => lang('New application'),
 106                      'maintainer' => lang('Maintainer'),
 107                      'url' => 'http://',
 108                      'description' => lang('Description')
 109                  )
 110              );
 111          }
 112              
 113          $newdata['directory'] = $xmltool->export_xml();
 114          $data = $newdata;
 115          return true;
 116      }
 117  
 118  	function set_block(&$block,$produce=False)
 119      {
 120          parent::set_block($block,$produce);
 121  
 122          if ($produce)
 123          {
 124              require_once (EGW_INCLUDE_ROOT . SEP . 'sitemgr' . SEP . 'inc' . SEP . 'class.xslt_transform.inc.php');
 125              $this->add_transformer(new xslt_transform($this->find_template_dir() . SEP . 'list.xsl'));
 126          }
 127      }
 128  
 129  	function get_content(&$arguments,$properties)
 130      {
 131          return $arguments['directory'];
 132      }
 133  }


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