[ Index ]
 

Code source de eGroupWare 1.2.106-2

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

title

Body

[fermer]

/sitemgr/inc/ -> class.Theme_BO.inc.php (source)

   1  <?php
   2      /**************************************************************************\
   3      * eGroupWare SiteMgr - Web Content Management                              *
   4      * http://www.egroupware.org                                                *
   5      * Written and (c) by RalfBecker@outdoor-training.de                        *
   6      * --------------------------------------------                             *
   7      *  This program is free software; you can redistribute it and/or modify it *
   8      *  under the terms of the GNU General Public License as published by the   *
   9      *  Free Software Foundation; either version 2 of the License, or (at your  *
  10      *  option) any later version.                                              *
  11      \**************************************************************************/
  12  
  13      /* $Id: class.Theme_BO.inc.php 13985 2004-03-09 14:14:55Z ralfbecker $ */
  14  
  15      class Theme_BO
  16      {
  17  		function Theme_BO()
  18          {
  19          }
  20  
  21  		function getAvailableThemes()
  22          {
  23              $templates_dir = $GLOBALS['Common_BO']->sites->current_site['site_dir'] . SEP . 'templates' . SEP;
  24              $result_array=array();
  25  
  26              if ($handle = @opendir($templates_dir))
  27              {
  28                  while ($file = readdir($handle))
  29                  {
  30                      if (is_dir($templates_dir . $file) && $file != '..' && $file != '.' && $file != 'CVS')
  31                      {
  32                          if ($info = $this->getThemeInfos($file))
  33                          {
  34                              $result_array[$file] = $info;
  35                          }
  36                      }
  37                  }
  38                  closedir($handle);
  39  
  40                  uksort($result_array,'strcasecmp');
  41              }
  42              //echo "<p>Theme_BO::getAvailableThemes('$templates_dir')=".print_r(array_keys($result_array),true)."</p>";
  43              return $result_array ? $result_array : array(array('value'=>'','display'=>lang('No templates found.')));
  44          }
  45  
  46  		function getThemeInfos($theme)
  47          {
  48              //echo "<p>Theme_BO::getThemeInfos('$theme')</p>";
  49              $templates_dir = $GLOBALS['Common_BO']->sites->current_site['site_dir'] . SEP . 'templates' . SEP;
  50              $info = False;
  51              if (!is_dir($dir = $templates_dir . $theme))
  52              {
  53                  return False;
  54              }
  55              if (file_exists($dir . SEP . 'main.tpl'))
  56              {
  57                  $info = array(
  58                      'value' => $theme,
  59                      'type'  => 'SiteMgr',
  60                  );
  61              }
  62              elseif (file_exists($dir . SEP . 'index.php'))
  63              {
  64                  $info = array(
  65                      'value'=> $theme,
  66                      'type'  => 'Mambo',
  67                  );
  68              }
  69              if ($info)
  70              {
  71                  if (file_exists($xml_details = $dir . SEP . 'templateDetails.xml'))
  72                  {
  73                      //if (ereg('<description>(.*)</description>',$info['xml']=implode("\n",file($xml_details)),$parts))
  74                      if (preg_match_all('/<(description|author|authorEmail|authorUrl|copyright|version|name|creationDate)>([^>]+)</',implode("\n",file($xml_details)),$matches))
  75                      {
  76                          foreach($matches[1] as $n => $name)
  77                          {
  78                              $info[$name] = $matches[2][$n];
  79                          }
  80                          $info['title'] = $info['description'];
  81                          if ($info['authorUrl'] && substr($info['authorUrl'],0,4) != 'http')
  82                          {
  83                              $info['authorUrl'] = 'http://'.$info['authorUrl'];
  84                          }
  85                      }
  86                  }
  87                  if (file_exists($dir . SEP . 'template_thumbnail.png'))
  88                  {
  89                      $info['thumbnail'] = $GLOBALS['Common_BO']->sites->current_site['site_url']."templates/$theme/template_thumbnail.png";
  90                  }
  91                  if (!isset($info['name']) || !$info['name'])
  92                  {
  93                      $info['name'] = $info['value'];
  94                  }
  95                  // "create" some nicer names
  96                  $info['name'] = ucwords(str_replace('_',' ',$info['name']));
  97                  $info['display'] = $info['name'] . " ($info[type])";
  98              }
  99              return $info;
 100          }
 101      }
 102  ?>


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