Пример #1
0
 public static function instantiate($library)
 {
     if ($library == 'default') {
         if (ShowPlusLibrarian::is_imagick_supported()) {
             $library = 'imagick';
         } else {
             $library = 'gd';
         }
     }
     switch ($library) {
         case 'imagick':
             if (ShowPlusLibrarian::is_imagick_supported()) {
                 return new ShowPlusImageLibraryImagick();
             }
         case 'gd':
             if (ShowPlusLibrarian::is_gd_supported()) {
                 return new ShowPlusImageLibraryGD();
             }
     }
     return new ShowPlusImageLibrary();
     // all operations will throw an image library unavailable exception
 }
Пример #2
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'];
         $textkey = (string) $o;
         $items[$val] = $textkey;
     }
     // test which image processing libraries are supported
     $supported = array();
     if (ShowPlusLibrarian::is_gd_supported()) {
         $supported['gd'] = 'GD';
     }
     if (ShowPlusLibrarian::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);
     }
 }
Пример #3
0
 private function validate()
 {
     $this->folder = str_replace("\\", '/', trim($this->folder, " /\\\n\r\t"));
     // dimensions
     $this->width = self::as_positive_integer($this->width, 600);
     $this->height = self::as_positive_integer($this->height, 400);
     $this->thumb_width = self::as_positive_integer($this->thumb_width, 60);
     $this->thumb_height = self::as_positive_integer($this->thumb_height, 40);
     // slideshow alignment and thumbnail bar orientation
     $language = JFactory::getLanguage();
     switch ($this->alignment) {
         case 'left':
         case 'left-clear':
         case 'left-float':
         case 'right':
         case 'right-clear':
         case 'right-float':
             str_replace(array('left', 'right'), $language->isRTL() ? array('after', 'before') : array('before', 'after'), $this->alignment);
             break;
         case 'before':
         case 'center':
         case 'right':
         case 'before-clear':
         case 'after-clear':
         case 'before-float':
         case 'after-float':
             break;
         default:
             $this->alignment = 'center';
     }
     if ($this->orientation !== false) {
         switch ($this->orientation) {
             case 'horizontal':
                 // horizontal bottom
             // horizontal bottom
             case 'horizontal-bottom':
             case 'horizontal-top':
             case 'vertical':
                 // vertical right
             // vertical right
             case 'vertical-right':
             case 'vertical-left':
                 break;
             case 'disabled':
             default:
                 $this->orientation = false;
         }
     }
     $this->autohide = (bool) $this->autohide;
     // overlay buttons and captions
     if ($this->buttons) {
         switch ($this->buttons) {
             case 'full':
             case 'minimalistic':
                 break;
             default:
                 $this->buttons = 'full';
         }
     } else {
         $this->buttons = false;
     }
     $this->captions = (bool) $this->captions;
     $this->defcaption = self::as_optional_string($this->defcaption);
     $this->deflink = self::as_optional_string($this->deflink);
     $this->target = self::as_optional_string($this->target);
     // delay times [ms]
     $this->delay = self::as_nonnegative_integer($this->delay);
     $this->duration = self::as_nonnegative_integer($this->duration);
     switch ($this->transition) {
         case 'fade':
         case 'flash':
         case 'fold':
         case 'kenburns':
         case 'push':
             break;
         default:
             $this->transition = 'fade';
     }
     switch ($this->transition_easing) {
         case 'linear':
         case 'quad':
         case 'cubic':
         case 'quart':
         case 'quint':
         case 'expo':
         case 'circ':
         case 'sine':
         case 'back':
         case 'bounce':
         case 'elastic':
             break;
         default:
             $this->transition_easing = 'linear';
     }
     $this->transition_pan = self::as_percentage($this->transition_pan);
     $this->transition_zoom = self::as_percentage($this->transition_zoom);
     $this->scroll_speed = self::as_percentage($this->scroll_speed);
     // style
     $this->margin = self::as_nonnegative_integer($this->margin);
     $this->border_width = self::as_nonnegative_integer($this->border_width);
     switch ($this->border_style) {
         case 'none':
         case 'dotted':
         case 'dashed':
         case 'solid':
         case 'double':
         case 'groove':
         case 'ridge':
         case 'inset':
         case 'outset':
             break;
         default:
             $this->border_style = false;
     }
     $this->border_color = self::as_color($this->border_color);
     $this->padding = self::as_nonnegative_integer($this->padding);
     $this->background_color = self::as_color($this->background_color);
     // navigation links
     $this->links = (bool) $this->links;
     // overlay image
     switch ($this->overlay_position) {
         case 'left-top':
         case 'left-center':
         case 'left-bottom':
         case 'center-top':
         case 'center-center':
         case 'center-bottom':
         case 'right-top':
         case 'right-center':
         case 'right-bottom':
             break;
         case 'none':
         default:
             $this->overlay_position = false;
     }
     // thumbnail image generation
     $this->thumb_cache = (bool) $this->thumb_cache;
     $this->thumb_color_active = self::as_color($this->thumb_color_active);
     $this->thumb_color_hover = self::as_color($this->thumb_color_hover);
     $this->thumb_quality = self::as_percentage($this->thumb_quality);
     // image labels
     $this->labels = preg_replace('/[^A-Za-z0-9_\\-]/', '', str_replace('.', '_', $this->labels));
     $this->labels_multilingual = (bool) $this->labels_multilingual;
     $this->labels_update = (bool) $this->labels_update;
     // sort criterion and sort order
     if (is_numeric($this->sort_criterion)) {
         $this->sort_criterion = (int) $this->sort_criterion;
     } else {
         switch ($this->sort_criterion) {
             case 'labels':
             case 'labels-filename':
             case 'labels-fname':
                 $this->sort_criterion = SHOWPLUS_SORT_LABELS_OR_FILENAME;
                 break;
             case 'labels-mtime':
                 $this->sort_criterion = SHOWPLUS_SORT_LABELS_OR_MTIME;
                 break;
             case 'filename':
             case 'fname':
                 $this->sort_criterion = SHOWPLUS_SORT_FILENAME;
                 break;
             case 'mtime':
                 $this->sort_criterion = SHOWPLUS_SORT_MTIME;
                 break;
             case 'random':
                 $this->sort_criterion = SHOWPLUS_SORT_RANDOM;
                 break;
             case 'randomlabels':
                 $this->sort_criterion = SHOWPLUS_SORT_RANDOMLABELS;
                 break;
             default:
                 $this->sort_criterion = SHOWPLUS_SORT_LABELS_OR_FILENAME;
         }
     }
     if (is_numeric($this->sort_order)) {
         $this->sort_order = (int) $this->sort_order;
     } else {
         switch ($this->sort_order) {
             case 'asc':
             case 'ascending':
                 $this->sort_order = SHOWPLUS_SORT_ASCENDING;
                 break;
             case 'desc':
             case 'descending':
                 $this->sort_order = SHOWPLUS_SORT_DESCENDING;
                 break;
             default:
                 $this->sort_order = SHOWPLUS_SORT_ASCENDING;
         }
     }
     // image library
     switch ($this->library) {
         case 'gd':
             if (!ShowPlusLibrarian::is_gd_supported()) {
                 $this->library = 'default';
             }
             break;
         case 'imagick':
             if (!ShowPlusLibrarian::is_imagick_supported()) {
                 $this->library = 'default';
             }
             break;
         default:
             $this->library = 'default';
     }
     switch ($this->library) {
         case 'default':
             if (ShowPlusLibrarian::is_imagick_supported()) {
                 $this->library = 'imagick';
             } elseif (ShowPlusLibrarian::is_gd_supported()) {
                 $this->library = 'gd';
             } else {
                 $this->library = 'none';
             }
             break;
         default:
     }
     $this->debug = (bool) $this->debug;
 }