Author: Tobias Schlitt
Date: 2006-01-13 16:29:30 +0100 (Fri, 13 Jan 2006)
New Revision: 1843

Log:
- Fix signatures of ezcImageMethodcallHandler and ezcImageHandler classes to 
properly reflect settings.
- Renamed weired $settings prioperty in ezcImageHandlerSettings struct to be 
$options.
- Introduced explicit setting of ImageMagick "convert" binary through 
ezcImageHandlerOptions::$settings['binary'] (needed on some windows systems).

Modified:
   packages/ImageConversion/trunk/src/handlers/imagemagick.php
   packages/ImageConversion/trunk/src/interfaces/handler.php
   packages/ImageConversion/trunk/src/interfaces/methodcall_handler.php
   packages/ImageConversion/trunk/src/structs/handler_settings.php

Modified: packages/ImageConversion/trunk/src/handlers/imagemagick.php
===================================================================
--- packages/ImageConversion/trunk/src/handlers/imagemagick.php 2006-01-13 
15:27:16 UTC (rev 1842)
+++ packages/ImageConversion/trunk/src/handlers/imagemagick.php 2006-01-13 
15:29:30 UTC (rev 1843)
@@ -33,16 +33,21 @@
      * but only through the manager for configuration reasons. One can
      * get a direct refernce through manager afterwards.
      *
+     * This handler has an option 'binary' available, which allows you to 
+     * explicitly set the path to your ImageMagicks "convert" binary (this
+     * may be necessary on Windows, since there may be an obscure "convert.exe"
+     * in the $PATH variable available, which has nothing to do with
+     * ImageMagick).
+     *
      * @throws ezcImageHandlerNotAvailableException
      *         If the ImageMagick binary is not found.
      *
-     * @param ezcImageHandlerSettings $settings
-     *        Settings for the handler.
+     * @param ezcImageHandlerSettings $settings Settings for the handler.
      */
     public function __construct( ezcImageHandlerSettings $settings )
     {
         // Check for ImageMagick
-        $this->checkImageMagick();
+        $this->checkImageMagick( $settings );
         $this->determineTypes();
         parent::__construct( $settings );
     }
@@ -223,31 +228,41 @@
     /**
      * Checks for ImageMagick on the system.
      *
+     * @param ezcImageHandlerSettings The settings object of the current 
handler instance.
      * @return void
      *
      * @throws ezcImageHandlerNotAvailableException
      *         If the ImageMagick binary is not found.
      */
-    private function checkImageMagick()
+    private function checkImageMagick( ezcImageHandlerSettings $settings )
     {
-        switch ( PHP_OS )
+        if ( !isset( $settings->options['binary'] ) )
         {
-            case 'Linux':
-            case 'Unix':
-            case 'FreeBSD':
-            case 'MacOS':
-            case 'Darwin':
-                $this->binary = 'convert';
-                break;
-            case 'Windows':
-            case 'WINNT':
-            case 'WIN32':
-                $this->binary = 'convert.exe';
-                break;
-            default:
-                throw new ezcImageHandlerNotAvailableException( $this->name, 
'System <'.PHP_OS.'> not supported by handler <'.$this->name.'>.' );
-                break;
+            // Try to use basic binary names only, if not provided (standard 
case 
+            // on Unix, binary should be in the $PATH, so is accessable).
+            switch ( PHP_OS )
+            {
+                case 'Linux':
+                case 'Unix':
+                case 'FreeBSD':
+                case 'MacOS':
+                case 'Darwin':
+                    $this->binary = 'convert';
+                    break;
+                case 'Windows':
+                case 'WINNT':
+                case 'WIN32':
+                    $this->binary = 'convert.exe';
+                    break;
+                default:
+                    throw new ezcImageHandlerNotAvailableException( 
$this->name, 'System <'.PHP_OS.'> not supported by handler <'.$this->name.'>.' 
);
+                    break;
+            }
         }
+        else
+        {
+            $this->binary = $settings->options['binary'];
+        }
         
         // Prepare to run ImageMagick command
         $descriptors = array( 

Modified: packages/ImageConversion/trunk/src/interfaces/handler.php
===================================================================
--- packages/ImageConversion/trunk/src/interfaces/handler.php   2006-01-13 
15:27:16 UTC (rev 1842)
+++ packages/ImageConversion/trunk/src/interfaces/handler.php   2006-01-13 
15:29:30 UTC (rev 1843)
@@ -28,6 +28,13 @@
     protected $name;
 
     /**
+     * Settings of the handlers 
+     * 
+     * @var ezcImageHandlerSettings
+     */
+    protected $settings;
+
+    /**
      * Create a new image handler.
      * Creates an image handler. This should never be done directly,
      * but only through the manager for configuration reasons. One can
@@ -40,6 +47,7 @@
     public function __construct( ezcImageHandlerSettings $settings )
     {
         $this->name = $settings->referenceName;
+        $this->settings = $settings;
     }
 
     /**

Modified: packages/ImageConversion/trunk/src/interfaces/methodcall_handler.php
===================================================================
--- packages/ImageConversion/trunk/src/interfaces/methodcall_handler.php        
2006-01-13 15:27:16 UTC (rev 1842)
+++ packages/ImageConversion/trunk/src/interfaces/methodcall_handler.php        
2006-01-13 15:29:30 UTC (rev 1843)
@@ -86,12 +86,15 @@
      * get a direct refernce through manager afterwards. When overwriting
      * the constructor.
      *
-     * @param string $name
-     *        Displayable name for handler.
+     * The contents of the $settings parameter may change from handler to 
+     * handler. For detailed information take a look at the specific handler
+     * classes.
+     *
+     * @param ezcImageHandlerSettings $settings Settings for the handler.
      */
-    public function __construct( $name )
+    public function __construct( ezcImageHandlerSettings $settings )
     {
-        parent::__construct( $name );
+        parent::__construct( $settings );
         $this->filters = null;
     }
 

Modified: packages/ImageConversion/trunk/src/structs/handler_settings.php
===================================================================
--- packages/ImageConversion/trunk/src/structs/handler_settings.php     
2006-01-13 15:27:16 UTC (rev 1842)
+++ packages/ImageConversion/trunk/src/structs/handler_settings.php     
2006-01-13 15:29:30 UTC (rev 1843)
@@ -42,21 +42,21 @@
     public $name;
 
     /**
-     * Associative array of settings for the handler.
-     * These settings will be read by the handler class and varies from handler
+     * Associative array of misc options for the handler.
+     * These options will be read by the handler class and varies from handler
      * to handler. Consult the handler class for the available settings.
      *
-     * The settings array has the following structure:
+     * The options array has the following structure:
      * <code>
      * array(
-     *     <settingName> => <settingValue>,
-     *     [ <settingName> => <settingValue>, ...]
+     *     <optionName> => <optionValue>,
+     *     [ <optionName> => <optionValue>, ...]
      * )
      * </code>
      *
      * @var array
      */
-    public $settings = array();
+    public $options = array();
 
     /**
      * Initialise settings to be used by image handler.
@@ -76,11 +76,11 @@
      * @param array  $settings
      *        Associative array of settings for the handler.
      */
-    public function __construct( $referenceName, $className, array $settings = 
array() )
+    public function __construct( $referenceName, $className, array $options = 
array() )
     {
         $this->referenceName = $referenceName;
         $this->className     = $className;
-        $this->settings      = $settings;
+        $this->options       = $options;
     }
 }
 ?>

-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to