[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/template/templatesets/ -> templatefinder.class.php (source)

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH.'class/file/finder/filefinder.class.php' );
   4      lt_include( PLOG_CLASS_PATH.'class/template/templatesets/templatesetstorage.class.php' );
   5      lt_include( PLOG_CLASS_PATH.'class/template/templatesets/templatesets.class.php' );
   6      
   7      /**
   8       * \ingroup Template
   9       *
  10       * This class looks for new templates, be it new blog-specifc templates or global templates. It
  11       * will just scan the contents of a given folder and add any new templates it can find.
  12       *
  13       * @see FileFinder
  14       */
  15      class TemplateFinder extends FileFinder
  16      {
  17          
  18          /**
  19           * constructor
  20           *
  21           * @param templateFolder Starting folder where we will look for files. If none
  22           * is specified, the default ./templates folder will be used (or the one that has
  23           * been configured in the "templates_folder" parameter in the plog_config table
  24           * @see FileFinder::FileFinder
  25           */
  26  		function TemplateFinder( $templateFolder = null )
  27          {
  28              // if there is no template folder, use the default one
  29              if( $templateFolder == null )
  30                  $templateFolder = TemplateSetStorage::getBaseTemplateFolder();
  31                  
  32              $this->_templateFolder = $templateFolder;
  33              
  34              $this->FileFinder( $templateFolder );
  35          }
  36          
  37          /**
  38           * reimplemented from FileFinder::findKeyForFile
  39           *
  40           * @param fileName
  41           */
  42  		function getKeyForFile( $fileName )
  43          {
  44              // regular expression that determines which files should be ignored. This should
  45              // be updated every time we add a new folder to the templates/ folder that shoulnd't
  46              // be considered an additional template!!
  47              $ignoreRegexp = '/(default|rss|wizard|summary|misc|admin|blog_[0-9]*|^\..+)$/i';
  48              
  49              // get base name from the current full path
  50              $fileKey = basename( $fileName );
  51  
  52              // see if the ignore expression matches
  53              if( preg_match( $ignoreRegexp, $fileKey, $matches ))
  54                  $fileKey = null;
  55                  
  56              return( $fileKey );
  57          }
  58          
  59          /**
  60           * @see FileFinder::find()
  61           * @return An array with the ids of the new template sets
  62           */
  63  		function find( $currentTemplates = null )
  64          {
  65              // if no parameter, then use the list of default global templates
  66              if( $currentTemplates == null ) {
  67                  $currentTemplates = TemplateSets::getGlobalTemplates();
  68              }
  69              
  70              // call the parent method after the preparations
  71              parent::find( $currentTemplates );
  72              
  73              // and return any new templates
  74              return( $this->getNew());
  75          }
  76      }
  77  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics