function fetchElement($name, $value, &$node, $control_name)
 {
     $class = $node->attributes('class') ? 'class="' . $node->attributes('class') . '"' : 'class="inputbox"';
     // user-friendly names for image processing libraries
     $items = array();
     foreach ($node->children() as $o) {
         $val = $o->attributes('value');
         $textkey = $o->data();
         $items[$val] = $textkey;
     }
     // test which image processing libraries are supported
     $supported = array();
     if (is_gd_supported()) {
         $supported['gd'] = 'GD';
     }
     if (is_imagick_supported()) {
         $supported['imagick'] = 'ImageMagick';
     }
     if (empty($supported)) {
         // no library is supported
         if (isset($items['none'])) {
             $textkey = $items['none'];
         } else {
             $textkey = 'none';
         }
         return $this->renderNone($textkey, $control_name . '[' . $name . ']', $class, $control_name . $name);
     } else {
         // at least a single library is supported
         $supported['default'] = 'default';
         foreach ($items as $key => $textkey) {
             if (isset($supported[$key])) {
                 $supported[$key] = $textkey;
             }
         }
         return $this->renderHtmlSelect($supported, $control_name . '[' . $name . ']', $class, $value, $control_name . $name);
     }
 }
示例#2
0
 public function validate()
 {
     $this->multilingual = (bool) $this->multilingual;
     $this->thumbscache = (bool) $this->thumbscache;
     $this->contentcache = (bool) $this->contentcache;
     switch ($this->library) {
         case 'gd':
             if (!is_gd_supported()) {
                 $this->library = 'default';
             }
             break;
         case 'imagick':
             if (!is_imagick_supported()) {
                 $this->library = 'default';
             }
             break;
         default:
             $this->library = 'default';
     }
 }
示例#3
0
 public function getInput()
 {
     $class = isset($this->element['class']) ? 'class="' . (string) $this->element['class'] . '"' : 'class="inputbox"';
     // user-friendly names for image processing libraries
     $items = array();
     foreach ($this->element->option as $o) {
         $val = (string) $o['value'];
         // attribute "value"
         $textkey = (string) $o;
         // element content
         $items[$val] = $textkey;
     }
     // test which image processing libraries are supported
     $supported = array();
     if (is_gd_supported()) {
         $supported['gd'] = 'GD';
     }
     if (is_imagick_supported()) {
         $supported['imagick'] = 'ImageMagick';
     }
     if (empty($supported)) {
         // no library is supported
         if (isset($items['none'])) {
             $textkey = $items['none'];
         } else {
             $textkey = 'none';
         }
         return $this->renderNone($textkey, $this->name, $class);
     } else {
         // at least a single library is supported
         $supported['default'] = 'default';
         foreach ($items as $key => $textkey) {
             if (isset($supported[$key])) {
                 $supported[$key] = $textkey;
             }
         }
         return $this->renderHtmlSelect($supported, $this->name, $class, $this->value);
     }
 }
示例#4
0
 public static function instantiate($library)
 {
     if ($library == 'default') {
         if (is_imagick_supported()) {
             $library = 'imagick';
         } else {
             $library = 'gd';
         }
     }
     switch ($library) {
         case 'imagick':
             if (is_imagick_supported()) {
                 return new SIGPlusImageLibraryImagick();
             }
         case 'gd':
             if (is_gd_supported()) {
                 return new SIGPlusImageLibraryGD();
             }
     }
     return new SIGPlusImageLibrary();
     // all operations will throw an image library unavailable exception
 }