Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezimageanalyzer.php
Go to the documentation of this file.
1 <?php
22 class eZImageAnalyzer
23 {
24 const MODE_INDEXED = 1;
25 const MODE_TRUECOLOR = 2;
26
27 const TIMER_HUNDRETHS_OF_A_SECOND = 1;
28
29 const TRANSPARENCY_OPAQUE = 1;
30 const TRANSPARENCY_TRANSPARENT = 2;
31 const TRANSPARENCY_TRANSLUCENT = 3;
32
33 public function __construct()
34 {
35 $this->Name = false;
36 $this->MIMEList = array();
37 }
38
45 function process( $mimeData, $parameters = array() )
46 {
47 return false;
48 }
49
53 static function createForMIME( $mimeData )
54 {
55 $analyzerData = eZImageAnalyzer::analyzerData();
56 $mimeType = $mimeData['name'];
57 if ( !isset( $analyzerData['analyzer_map'][$mimeType] ) )
58 return false;
59 $analyzerName = $analyzerData['analyzer_map'][$mimeType];
60 $handlerName = $analyzerData['analyzer'][$analyzerName]['handler'];
61 return eZImageAnalyzer::create( $handlerName );
62 }
63
67 static function create( $analyzerName )
68 {
69 $analyzerData = eZImageAnalyzer::analyzerData();
70 if ( !isset( $analyzerData['handlers'][$analyzerName] ) )
71 {
72 if ( eZExtension::findExtensionType( array( 'ini-name' => 'image.ini',
73 'repository-group' => 'AnalyzerSettings',
74 'repository-variable' => 'RepositoryList',
75 'extension-group' => 'AnalyzerSettings',
76 'extension-variable' => 'ExtensionList',
77 'extension-subdir' => 'imageanalyzer',
78 'alias-group' => 'AnalyzerSettings',
79 'alias-variable' => 'ImageAnalyzerAlias',
80 'suffix-name' => 'imageanalyzer.php',
81 'type-directory' => false,
82 'type' => $analyzerName ),
83 $result ) )
84 {
85 $filepath = $result['found-file-path'];
86 include_once( $filepath );
87 $className = $result['type'] . 'imageanalyzer';
88 $analyzerData['handlers'][$analyzerName] = array( 'classname' => $className,
89 'filepath' => $filepath );
90 }
91 else
92 {
93 eZDebug::writeWarning( "Could not locate Image Analyzer for $analyzerName", __METHOD__ );
94 }
95 }
96 if ( isset( $analyzerData['handlers'][$analyzerName] ) )
97 {
98 $analyzer = $analyzerData['handlers'][$analyzerName];
99 $className = $analyzer['classname'];
100 if ( class_exists( $className ) )
101 {
102 return new $className();
103 }
104 else
105 {
106 eZDebug::writeWarning( "The Image Analyzer class $className was not found, cannot create analyzer", __METHOD__ );
107 }
108 }
109 return false;
110 }
111
116 static function analyzerData()
117 {
118 $analyzerData =& $GLOBALS['eZImageAnalyzer'];
119 if ( isset( $analyzerData ) )
120 return $analyzerData;
121
122 $ini = eZINI::instance( 'image.ini' );
123 $analyzerData['analyzers'] = $ini->variable( 'AnalyzerSettings', 'ImageAnalyzers' );
124 $analyzerData['mime_list'] = $ini->variable( 'AnalyzerSettings', 'AnalyzerMIMEList' );
125 $analyzerData['analyzer_map'] = array();
126 $analyzerData['analyzer'] = array();
127 return $analyzerData;
128 }
129
133 static function readAnalyzerSettingsFromINI()
134 {
135 $analyzerData = eZImageAnalyzer::analyzerData();
136 $ini = eZINI::instance( 'image.ini' );
137 foreach ( $analyzerData['analyzers'] as $analyzerName )
138 {
139 $iniGroup = $analyzerName . 'Analyzer';
140 if ( $ini->hasGroup( $iniGroup ) )
141 {
142 $handler = $ini->variable( $iniGroup, 'Handler' );
143 $mimeList = $ini->variable( $iniGroup, 'MIMEList' );
144 $analyzerData['analyzer'][$analyzerName] = array( 'handler' => $handler,
145 'mime_list' => $mimeList );
146 foreach ( $mimeList as $mimeItem )
147 {
148 $analyzerData['analyzer_map'][$mimeItem] = $analyzerName;
149 }
150 }
151 else
152 eZDebug::writeWarning( "INI group $iniGroup does not exist in image.ini", __METHOD__ );
153 }
154
155 $GLOBALS['eZImageAnalyzer'] = $analyzerData;
156 }
157
159
160 public $MIMEList;
161 public $Name;
162 }
163
164 ?>
eZDebug\writeWarning
static writeWarning( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:502
eZExtension\findExtensionType
static findExtensionType( $parameters, &$out)
Definition: ezextension.php:385
eZImageAnalyzer
The class eZImageAnalyzer does.
Definition: ezimageanalyzer.php:23
eZImageAnalyzer\createForMIME
static createForMIME( $mimeData)
Definition: ezimageanalyzer.php:53
eZImageAnalyzer\analyzerData
static analyzerData()
Definition: ezimageanalyzer.php:116
eZImageAnalyzer\TRANSPARENCY_OPAQUE
const TRANSPARENCY_OPAQUE
Definition: ezimageanalyzer.php:29
eZImageAnalyzer\create
static create( $analyzerName)
Definition: ezimageanalyzer.php:67
eZImageAnalyzer\MODE_INDEXED
const MODE_INDEXED
Definition: ezimageanalyzer.php:24
eZImageAnalyzer\TRANSPARENCY_TRANSLUCENT
const TRANSPARENCY_TRANSLUCENT
Definition: ezimageanalyzer.php:31
eZImageAnalyzer\$Name
$Name
Definition: ezimageanalyzer.php:161
eZImageAnalyzer\MODE_TRUECOLOR
const MODE_TRUECOLOR
Definition: ezimageanalyzer.php:25
eZImageAnalyzer\process
process( $mimeData, $parameters=array())
Definition: ezimageanalyzer.php:45
eZImageAnalyzer\TRANSPARENCY_TRANSPARENT
const TRANSPARENCY_TRANSPARENT
Definition: ezimageanalyzer.php:30
eZImageAnalyzer\TIMER_HUNDRETHS_OF_A_SECOND
const TIMER_HUNDRETHS_OF_A_SECOND
Definition: ezimageanalyzer.php:27
eZImageAnalyzer\readAnalyzerSettingsFromINI
static readAnalyzerSettingsFromINI()
Definition: ezimageanalyzer.php:133
eZImageAnalyzer\$MIMEList
$MIMEList
Definition: ezimageanalyzer.php:160
eZImageAnalyzer\__construct
__construct()
Definition: ezimageanalyzer.php:33
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.