Exemple #1
0
 function resize(&$target, $widths)
 {
     set_time_limit(30);
     trigger_error(sprintf(AMP_TEXT_ACTION_NOTICE, AMP_TEXT_RECALCULATE, $target->getName()));
     #$content_image = &new Content_Image( $target->getName() );
     $crop_path = AMP_image_path($target->getName(), AMP_IMAGE_CLASS_CROP);
     $thumb_path = AMP_image_path($target->getName(), AMP_IMAGE_CLASS_THUMB);
     $pic_path = AMP_image_path($target->getName());
     $action_flag = false;
     if (isset($widths['thumb'])) {
         if (file_exists($crop_path)) {
             $crop_target =& new AMP_System_File_Image($crop_path);
         } else {
             $crop_target =& $target;
         }
         if ($this->_rewriteVersion($crop_target, $widths['thumb'], $thumb_path)) {
             $action_flag = true;
         }
     }
     if (isset($widths['tall']) && $target->height >= $target->width) {
         if ($this->_rewriteVersion($target, $widths['tall'], $pic_path)) {
             $action_flag = true;
         }
     }
     if (isset($widths['wide']) && $target->width > $target->height) {
         if ($this->_rewriteVersion($target, $widths['wide'], $pic_path)) {
             $action_flag = true;
         }
     }
     if ($action_flag) {
         ++$this->_committed_qty;
     }
 }
Exemple #2
0
 function getImageFile()
 {
     if (!($img_name = $this->getImageFileName())) {
         return false;
     }
     require_once 'AMP/System/File/Image.php';
     $image = new AMP_System_File_Image(AMP_image_path($img_name));
     return $image;
 }
Exemple #3
0
 function _update_image_cache_delete($image_name)
 {
     $imageRef =& new AMP_System_File_Image(AMP_image_path($image_name, AMP_IMAGE_CLASS_ORIGINAL));
     $image_cache_key = $imageRef->getCacheKeySearch();
     $image_cache =& AMP_cache_get($image_cache_key);
     if (!$image_cache) {
         return;
     }
     unset($image_cache[$image_name]);
     AMP_cache_set($image_cache_key, $image_cache);
 }
Exemple #4
0
 function render_jump_set()
 {
     if ($this->_qty_total < $this->_qty_page) {
         return false;
     }
     if (empty($this->_jump_values)) {
         return false;
     }
     $output = '';
     foreach ($this->_jump_values as $offset_url => $image_name) {
         $pager_thumb = new AMP_System_File_Image(AMP_image_path($image_name, AMP_IMAGE_CLASS_THUMB));
         $thumb_class = array('pager-thumb');
         if ($offset_url == $_SERVER['REQUEST_URI']) {
             $thumb_class[] = 'pager-thumb-current';
         }
         $output[] = $this->_renderer->link($offset_url, $this->_renderer->image($pager_thumb->display->render_url_for_scaled($pager_thumb, AMP_IMAGE_GALLERY_PAGER_THUMB_WIDTH), array('class' => join(" ", $thumb_class))));
     }
     return $this->_renderer->div(join("\n", $output), array('class' => 'pager-thumb-set'));
 }
Exemple #5
0
 function read_request()
 {
     if (!(isset($_REQUEST['filename']) && ($image_file = $_REQUEST['filename']))) {
         return;
     }
     $image_class = isset($_REQUEST['image_class']) && $_REQUEST['image_class'] ? $_REQUEST['image_class'] : AMP_IMAGE_CLASS_ORIGINAL;
     $image_path = AMP_image_path($image_file, $image_class);
     if (!file_exists($image_path)) {
         return;
     }
     $this->set_file($image_path);
     $action = isset($_REQUEST['action']) && $_REQUEST['action'] ? $_REQUEST['action'] : $this->_default_action;
     $this->_keep_proportions = isset($_REQUEST['keep_proportions']) && $_REQUEST['keep_proportions'];
     //validate request
     if (!(AMP_local_request() || AMP_Authenticate('admin'))) {
         $action = $this->_default_action;
     }
     $display =& $this->get_display();
     $display->set_action($action);
     $this->read_request_sizes($action);
 }
Exemple #6
0
 function move($folder_name, $create_folder_name = null)
 {
     if ($create_folder_name) {
         if (!AMP_add_image_subfolder($create_folder_name)) {
             return false;
         }
         $folder_name = $create_folder_name;
     }
     if (!$folder_name) {
         return false;
     }
     if (file_exists(AMP_image_path($this->getNameForFolder($folder_name)))) {
         AMP_flashMessage(sprintf(AMP_TEXT_ERROR_FILE_EXISTS, $this->getNameForFolder($folder_name)));
         return false;
     }
     foreach (AMP_lookup('image_classes') as $image_class => $image_class_name) {
         if (!file_exists(AMP_image_path($this->getName(), $image_class))) {
             continue;
         }
         rename(AMP_image_path($this->getName(), $image_class), AMP_image_path($this->getNameForFolder($folder_name), $image_class));
     }
     //save new location to database
     $this->update_database_folder($folder_name);
     return true;
 }
Exemple #7
0
 function &getImageFile()
 {
     $false = false;
     if (!($name = $this->getImageFileName())) {
         return $false;
     }
     $img_class = $this->getImageClass();
     if (!$img_class) {
         $img_class = AMP_IMAGE_CLASS_OPTIMIZED;
     }
     $image = new AMP_System_File_Image(AMP_image_path($name, $img_class));
     if (!$image->getPath()) {
         return $false;
     }
     $image->set_display_metadata($this->getImageData());
     return $image;
 }
Exemple #8
0
 function setImageFile($filename)
 {
     if (!file_exists($filename)) {
         return false;
     }
     $image_ref = new AMP_System_File_Image($filename);
     if (array_search($image_ref->get_mimetype(), $this->_allowed_mimetypes) === FALSE) {
         $this->addError(AMP_TEXT_ERROR_IMAGE_NOT_ALLOWED);
         return false;
     }
     $this->_paths = array(AMP_IMAGE_CLASS_OPTIMIZED => AMP_image_path($image_ref->getName(), AMP_IMAGE_CLASS_OPTIMIZED), AMP_IMAGE_CLASS_THUMB => AMP_image_path($image_ref->getName(), AMP_IMAGE_CLASS_THUMB), AMP_IMAGE_CLASS_ORIGINAL => AMP_image_path($image_ref->getName(), AMP_IMAGE_CLASS_ORIGINAL), AMP_IMAGE_CLASS_CROP => AMP_image_path($image_ref->getName(), AMP_IMAGE_CLASS_CROP));
     $image_ref->getFilename();
     $this->_image_ref =& $image_ref;
     $this->_initCrop();
     $this->_setWidths();
     return true;
 }
Exemple #9
0
 function _showThumbNail($data, $column)
 {
     $column = 'name';
     if (!(isset($data[$column]) && $data[$column])) {
         return false;
     }
     require_once 'AMP/System/File/Image.php';
     $image_file = new AMP_System_File_Image(AMP_image_path($data[$column]));
     if (!($path = $image_file->getPath())) {
         return $data[$column];
     }
     $this->dropField('filename');
     $this->dropField('image');
     $renderer = AMP_get_renderer();
     return $data[$column] . $image_file->display->execute();
     /*
             $renderer = AMP_get_renderer( );
             return $renderer->link( $content_image->getURL( AMP_IMAGE_CLASS_ORIGINAL ), $renderer->image( $content_image->getURL( AMP_IMAGE_CLASS_OPTIMIZED)), array( 'target' => '_blank'))
      . $renderer->newline( )
     .  $renderer->link( $content_image->getURL( AMP_IMAGE_CLASS_ORIGINAL ), $data[$column], array( 'target' => '_blank'));
     */
 }
Exemple #10
0
 function get_source_version($source, $class)
 {
     if ($this->source_class($source) == $class) {
         return $source;
     }
     return new AMP_System_File_Image(AMP_image_path($source->getName(), $class));
 }