[ 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_galerie.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_galerie.inc.php 20295 2006-02-15 12:31:25Z  $ */
  13  
  14  class module_galerie extends Module
  15  {
  16  	function module_galerie()
  17      {
  18          $this->i18n = True;
  19          $this->arguments = array(
  20              'imagedirurl' => array(
  21                  'type' => 'textfield', 
  22                  'label' => lang('URL pointing to the image-directory'),
  23                  'params' => array('size' => 50),
  24              ),
  25              'imagedirpath' => array(
  26                  'type' => 'textfield', 
  27                  'label' => lang('Filesystem path of the image-directory'),
  28                  'params' => array('size' => 50),
  29              ),
  30              'imagename' => array(
  31                  'type' => 'textfield', 
  32                  'label' => lang('common prefix of the image-name (a number starting with 1 will be appended)')
  33              ),
  34              'imagetype' => array(
  35                  'type' => 'select', 
  36                  'label' => lang('image type'), 
  37                  'options' => array(
  38                      'jpeg' => 'jpeg',
  39                      'jpg' => 'jpg',
  40                      'gif' => 'gif',
  41                      'png' => 'png'
  42                  )
  43              ),
  44          );
  45          $this->title = lang('Galerie');
  46          $this->post = array(
  47              'prev' => array(
  48                  'type' => 'submit',
  49                  'value' => "&lt;---"
  50              ),
  51              'next' => array(
  52                  'type' => 'submit',
  53                  'value' => "---&gt;"
  54              )
  55          );
  56          $this->session = array('filenumber');
  57          $this->description = lang('A simple picture galery');
  58      }
  59  
  60  	function get_user_interface()
  61      {
  62          $this->set_subtext_args();
  63          return parent::get_user_interface();
  64      }
  65  
  66  	function get_translation_interface($fromblock,$toblock)
  67      {
  68          $this->set_subtext_args();
  69          return parent::get_translation_interface($fromblock,$toblock);
  70      }
  71      
  72  	function set_subtext_args()
  73      {
  74          $defaults = $this->block->arguments;
  75          if ($defaults['imagedirpath'] && is_dir($defaults['imagedirpath']))
  76          {
  77              $i = 1;
  78              $this->arguments['subtext'] = array(
  79                  'type' => "array",
  80              );
  81              while (file_exists($defaults['imagedirpath'] . SEP . $defaults['imagename'] . $i . '.' . $defaults['imagetype']))
  82              {
  83                  $this->arguments['subtext'][$i-1] = array(
  84                      'type' => 'textfield',
  85                      'label' => lang('Subtext for image %1',$i) . '<br /><img src="' .
  86                          $defaults['imagedirurl'] . SEP . $defaults['imagename'] . $i . '.' . $defaults['imagetype'] . '" />',
  87                  );
  88                  $i++;
  89              }
  90          }
  91      }
  92  
  93  	function set_block(&$block,$produce=False)
  94      {
  95          parent::set_block($block,$produce);
  96  
  97          if ($produce)
  98          {
  99              if (!$this->block->arguments['filenumber'])
 100              {
 101                  $this->block->arguments['filenumber'] = 1;
 102              }
 103              else
 104              {
 105                  $this->block->arguments['filenumber'] = (int)$this->block->arguments['filenumber'];
 106              }
 107              if ($this->block->arguments['next'])
 108              {
 109                  $this->block->arguments['filenumber']++;
 110              }
 111              elseif ($this->block->arguments['prev'])
 112              {
 113                  $this->block->arguments['filenumber']--;
 114              }
 115              if ($this->block->arguments['filenumber'] < 1 || !file_exists(
 116                      $this->block->arguments['imagedirpath'] . SEP . $this->block->arguments['imagename'] . 
 117                      $this->block->arguments['filenumber'] . '.' . $this->block->arguments['imagetype']
 118                  ))
 119              {
 120                  $this->block->arguments['filenumber'] = 1;
 121              }
 122              $prevlink = ($this->block->arguments['filenumber'] > 1) ? $this->build_post_element('prev') : '';
 123              $nextlink = 
 124                  (file_exists(
 125                      $this->block->arguments['imagedirpath'] . SEP . $this->block->arguments['imagename'] . 
 126                      ($this->block->arguments['filenumber'] + 1) . '.' . $this->block->arguments['imagetype']
 127                  )) ?
 128                  $this->build_post_element('next') : 
 129                  '';
 130              require_once (EGW_INCLUDE_ROOT . SEP . 'sitemgr' . SEP . 'inc' . SEP . 'class.browser_transform.inc.php');
 131              $this->add_transformer(new browser_transform($prevlink,$nextlink));
 132          }
 133      }
 134  
 135  	function validate(&$data)
 136      {
 137          // remove trailing slash
 138          foreach(array('imagedirpath','imagedirurl') as $name)
 139          {
 140              if (($last_char = substr($data[$name],-1) == '/') || $last_char == '\\')
 141              {
 142                  $data[$name] = substr($data[$name],0,-1);
 143              }
 144          }
 145          if (!@is_dir($data['imagedirpath']) || !@is_readable($data['imagedirpath']))
 146          {
 147              $this->validation_error = lang("Path to image-directory '%1' is not valid or readable by the webserver !!!",$data['imagedirpath']);
 148              return False;
 149          }
 150          return True;
 151      }
 152  
 153  	function get_content(&$arguments,$properties)
 154      {
 155          $content .= '<div align="center"><img  hspace="20" align="absmiddle" src="'. $arguments['imagedirurl'] . SEP . $arguments['imagename'] . $arguments['filenumber'] . '.' . $arguments['imagetype'] . '" /></div>';
 156          $content .= '<div align="center" style="margin:5mm">' . $arguments['subtext'][$arguments['filenumber']-1] . '</div>';
 157          return $content;
 158      }
 159  }


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