[ 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_xml.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_xml.inc.php 20295 2006-02-15 12:31:25Z  $ */
  13  
  14  class module_xml extends Module
  15  {
  16  
  17      var $filenumber;
  18  
  19  	function module_xml()
  20      {
  21          $this->arguments = array(
  22              'dirpath' => array('type' => 'textfield', 'label' => lang('Filesystem path of the directory where XML files are stored')),
  23              'filename' => array('type' => 'textfield', 'label' => lang('the XML files\' common name')),
  24              'xsltfile' => array('type' => 'textfield', 'label' => lang('Full path of the XSLT file that should be applied to the XML files'))
  25          );
  26          $this->post = array(
  27              'prev' => array(
  28                  'type' => 'submit',
  29                  'value' => lang('Previous')
  30              ),
  31              'next' => array(
  32                  'type' => 'submit',
  33                  'value' => lang('Next')
  34              )
  35          );
  36          $this->session = array('filenumber');
  37          $this->title = lang('XML browser');
  38          $this->description = lang('This module permits browsing through XML files stored in a directory, and transformed by XSLT');
  39      }
  40  
  41  	function set_block(&$block,$produce=False)
  42      {
  43          parent::set_block($block,$produce);
  44  
  45          if ($produce)
  46          {
  47              if (!$this->block->arguments['filenumber'])
  48              {
  49                  $this->block->arguments['filenumber'] = 1;
  50              }
  51              else
  52              {
  53                  $this->block->arguments['filenumber'] = (int)$this->block->arguments['filenumber'];
  54              }
  55              if ($this->block->arguments['next'])
  56              {
  57                  $this->block->arguments['filenumber']++;
  58              }
  59              elseif ($this->block->arguments['prev'])
  60              {
  61                  $this->block->arguments['filenumber']--;
  62              }
  63              if ($this->block->arguments['filenumber'] < 1 || !file_exists(
  64                      $this->block->arguments['dirpath'] . SEP . $this->block->arguments['filename'] . 
  65                      $this->block->arguments['filenumber'] . '.xml'
  66                  ))
  67              {
  68                  $this->block->arguments['filenumber'] = 1;
  69              }
  70  
  71              require_once (EGW_INCLUDE_ROOT . SEP . 'sitemgr' . SEP . 'inc' . SEP . 'class.xslt_transform.inc.php');
  72              $this->add_transformer(new xslt_transform($this->block->arguments['xsltfile']));
  73  
  74              $prevlink = ($this->block->arguments['filenumber'] > 1) ? $this->build_post_element('prev') : '';
  75              $nextlink = 
  76                  (file_exists(
  77                      $this->block->arguments['dirpath'] . SEP . $this->block->arguments['filename'] . 
  78                      ($this->block->arguments['filenumber'] + 1) . '.xml'
  79                  )) ?
  80                  $this->build_post_element('next') : 
  81                  '';
  82              require_once (EGW_INCLUDE_ROOT . SEP . 'sitemgr' . SEP . 'inc' . SEP . 'class.browser_transform.inc.php');
  83              $this->add_transformer(new browser_transform($prevlink,$nextlink,$this->block->module_name));
  84          }
  85      }
  86  
  87  	function get_content(&$arguments,$properties)
  88      {
  89          return implode('',@file($arguments['dirpath'] . SEP . $arguments['filename'] . $arguments['filenumber'] . '.xml'));
  90      }
  91  }


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