[ Index ]
 

Code source de eZ Publish 3.9.0

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

title

Body

[fermer]

/lib/ezimage/classes/ -> ezimageanalyzer.php (source)

   1  <?php
   2  //
   3  // Definition of eZImageAnalyzer class
   4  //
   5  // Created on: <03-Nov-2003 15:19:16 amos>
   6  //
   7  // SOFTWARE NAME: eZ publish
   8  // SOFTWARE RELEASE: 3.9.0
   9  // BUILD VERSION: 17785
  10  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
  11  // SOFTWARE LICENSE: GNU General Public License v2.0
  12  // NOTICE: >
  13  //   This program is free software; you can redistribute it and/or
  14  //   modify it under the terms of version 2.0  of the GNU General
  15  //   Public License as published by the Free Software Foundation.
  16  //
  17  //   This program is distributed in the hope that it will be useful,
  18  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20  //   GNU General Public License for more details.
  21  //
  22  //   You should have received a copy of version 2.0 of the GNU General
  23  //   Public License along with this program; if not, write to the Free
  24  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  25  //   MA 02110-1301, USA.
  26  //
  27  //
  28  
  29  /*! \file ezimageanalyzer.php
  30  */
  31  
  32  /*! \defgroup eZImageAnalyzer Image analysis
  33      \ingroup eZImage
  34  */
  35  
  36  /*!
  37    \class eZImageAnalyzer ezimageanalyzer.php
  38    \ingroup eZImageAnalyzer
  39    \brief The class eZImageAnalyzer does
  40  
  41  */
  42  
  43  
  44  define( 'EZ_IMAGE_MODE_INDEXED', 1 );
  45  define( 'EZ_IMAGE_MODE_TRUECOLOR', 2 );
  46  
  47  define( 'EZ_IMAGE_TIMER_HUNDRETHS_OF_A_SECOND', 1 );
  48  
  49  define( 'EZ_IMAGE_TRANSPARENCY_OPAQUE', 1 );
  50  define( 'EZ_IMAGE_TRANSPARENCY_TRANSPARENT', 2 );
  51  define( 'EZ_IMAGE_TRANSPARENCY_TRANSLUCENT', 3 );
  52  
  53  class eZImageAnalyzer
  54  {
  55      /*!
  56       Constructor
  57      */
  58      function eZImageAnalyzer()
  59      {
  60          $this->Name = false;
  61          $this->MIMEList = array();
  62      }
  63  
  64      /*!
  65       \pure
  66       Process the file based on the MIME data \a $mimeData and returns
  67       information on the analysis.
  68       \return \c false if the analysis fails.
  69      */
  70      function process( $mimeData, $parameters = array() )
  71      {
  72          return false;
  73      }
  74  
  75      /*!
  76       Creates an analyzer for the analyzer name \a $analyzerName and returns it.
  77      */
  78      function createForMIME( $mimeData )
  79      {
  80          $analyzerData =& eZImageAnalyzer::analyzerData();
  81          $mimeType = $mimeData['name'];
  82          if ( !isset( $analyzerData['analyzer_map'][$mimeType] ) )
  83              return false;
  84          $analyzerName = $analyzerData['analyzer_map'][$mimeType];
  85          $handlerName = $analyzerData['analyzer'][$analyzerName]['handler'];
  86          return eZImageAnalyzer::create( $handlerName );
  87      }
  88  
  89      /*!
  90       Creates an analyzer for the analyzer name \a $analyzerName and returns it.
  91      */
  92      function create( $analyzerName )
  93      {
  94          $analyzerData =& eZImageAnalyzer::analyzerData();
  95          if ( !isset( $analyzerData['handlers'][$analyzerName] ) )
  96          {
  97              include_once ( 'lib/ezutils/classes/ezextension.php' );
  98              if ( eZExtension::findExtensionType( array( 'ini-name' => 'image.ini',
  99                                                          'repository-group' => 'AnalyzerSettings',
 100                                                          'repository-variable' => 'RepositoryList',
 101                                                          'extension-group' => 'AnalyzerSettings',
 102                                                          'extension-variable' => 'ExtensionList',
 103                                                          'extension-subdir' => 'imageanalyzer',
 104                                                          'alias-group' => 'AnalyzerSettings',
 105                                                          'alias-variable' => 'ImageAnalyzerAlias',
 106                                                          'suffix-name' => 'imageanalyzer.php',
 107                                                          'type-directory' => false,
 108                                                          'type' => $analyzerName ),
 109                                                   $result ) )
 110              {
 111                  $filepath = $result['found-file-path'];
 112                  include_once( $filepath );
 113                  $className = $result['type'] . 'imageanalyzer';
 114                  $analyzerData['handlers'][$analyzerName] = array( 'classname' => $className,
 115                                                                    'filepath' => $filepath );
 116              }
 117              else
 118              {
 119                  eZDebug::writeWarning( "Could not locate Image Analyzer for $analyzerName",
 120                                         'eZImageAnalyzer::instance' );
 121              }
 122          }
 123          if ( isset( $analyzerData['handlers'][$analyzerName] ) )
 124          {
 125              $analyzer = $analyzerData['handlers'][$analyzerName];
 126              $className = $analyzer['classname'];
 127              if ( class_exists( $className ) )
 128              {
 129                  return new $className();
 130              }
 131              else
 132              {
 133                  eZDebug::writeWarning( "The Image Analyzer class $className was not found, cannot create analyzer",
 134                                         'eZImageAnalyzer::instance' );
 135              }
 136          }
 137          return false;
 138      }
 139  
 140      /*!
 141       \static
 142       \private
 143      */
 144      function &analyzerData()
 145      {
 146          $analyzerData =& $GLOBALS['eZImageAnalyzer'];
 147          if ( isset( $analyzerData ) )
 148              return $analyzerData;
 149  
 150          $ini =& eZINI::instance( 'image.ini' );
 151          $analyzerData['analyzers'] = $ini->variable( 'AnalyzerSettings', 'ImageAnalyzers' );
 152          $analyzerData['mime_list'] = $ini->variable( 'AnalyzerSettings', 'AnalyzerMIMEList' );
 153          $analyzerData['analyzer_map'] = array();
 154          $analyzerData['analyzer'] = array();
 155          return $analyzerData;
 156      }
 157  
 158      /*!
 159       \static
 160      */
 161      function readAnalyzerSettingsFromINI()
 162      {
 163          $analyzerData =& eZImageAnalyzer::analyzerData();
 164          $ini =& eZINI::instance( 'image.ini' );
 165          foreach ( $analyzerData['analyzers'] as $analyzerName )
 166          {
 167              $iniGroup = $analyzerName . 'Analyzer';
 168              if ( $ini->hasGroup( $iniGroup ) )
 169              {
 170                  $handler = $ini->variable( $iniGroup, 'Handler' );
 171                  $mimeList = $ini->variable( $iniGroup, 'MIMEList' );
 172                  $analyzerData['analyzer'][$analyzerName] = array( 'handler' => $handler,
 173                                                                    'mime_list' => $mimeList );
 174                  foreach ( $mimeList as $mimeItem )
 175                  {
 176                      $analyzerData['analyzer_map'][$mimeItem] = $analyzerName;
 177                  }
 178              }
 179              else
 180                  eZDebug::writeWarning( "INI group $iniGroup does not exist in image.ini",
 181                                         'eZImageAnalyzer::readAnalyzerSettingsFromINI' );
 182          }
 183      }
 184  
 185      /// \privatesection
 186  
 187      var $MIMEList;
 188      var $Name;
 189  }
 190  
 191  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7