File modules/cms/action/ImageAction.class.php

Last commit: Sun Dec 5 20:33:24 2021 +0100	dankert	Cleanup: Removed unusable properties from class 'Value' and 'BaseObject'.
1 <?php 2 3 namespace cms\action; 4 5 use cms\model\Image; 6 use util\Html; 7 8 9 /** 10 * Action-Klasse zum Bearbeiten eines Bildes. 11 * @author Jan Dankert 12 * @version $Revision$ 13 * @package openrat.actions 14 */ 15 class ImageAction extends FileAction 16 { 17 /** 18 * @var Image 19 */ 20 protected $image; 21 22 /** 23 * Konstruktor 24 */ 25 public function __construct() 26 { 27 parent::__construct(); 28 29 } 30 31 32 public function init() 33 { 34 $image = new Image( $this->request->getId() ); 35 $image->load(); 36 37 $this->setBaseObject( $image ); 38 39 } 40 41 42 protected function setBaseObject( $image ) { 43 $this->image = $image; 44 45 parent::setBaseObject($image); 46 } 47 48 49 50 protected function imageFormat() 51 { 52 if ( ! function_exists( 'imagetypes' ) ) 53 return 0; 54 55 $ext = strtolower($this->image->getRealExtension()); 56 $types = imagetypes(); 57 $formats = array( 'gif' =>IMG_GIF, 58 'jpg' =>IMG_JPG, 59 'jpeg'=>IMG_JPG, 60 'png' =>IMG_PNG ); 61 62 if ( !isset($formats[$ext]) ) 63 return 0; 64 65 if ( $types & $formats[$ext] ) 66 return $formats[$ext]; 67 68 return 0; 69 } 70 71 72 73 protected function imageExt() 74 { 75 switch( $this->imageFormat() ) 76 { 77 case IMG_GIF: 78 return 'GIF'; 79 case IMG_JPG: 80 return 'JPEG'; 81 case IMG_PNG: 82 return 'PNG'; 83 } 84 } 85 86 87 88 protected function imageFormats() 89 { 90 if ( ! function_exists( 'imagetypes' ) ) 91 return array(); 92 93 $types = imagetypes(); 94 $formats = array( IMG_GIF => 'gif', 95 IMG_JPG => 'jpeg', 96 IMG_PNG => 'png' ); 97 $formats2 = $formats; 98 99 foreach( $formats as $b=>$f ) 100 if ( !($types & $b) ) 101 unset( $formats2[$b] ); 102 103 return $formats2; 104 } 105 106 107 108 }
Download modules/cms/action/ImageAction.class.php
History Sun, 5 Dec 2021 20:33:24 +0100 dankert Cleanup: Removed unusable properties from class 'Value' and 'BaseObject'. Sat, 6 Mar 2021 02:50:20 +0100 Jan Dankert New: Enable actions for guest users. Fri, 26 Feb 2021 01:06:01 +0100 Jan Dankert Refactoring accessing the request parameter values. Wed, 18 Nov 2020 00:18:10 +0100 Jan Dankert Refactoring Part 2: Removing all unnecessary methods in the action base classes. Tue, 17 Nov 2020 23:51:00 +0100 Jan Dankert Refactoring: Every Actionmethod has now its own class. Wed, 11 Nov 2020 23:24:28 +0100 Jan Dankert Fixing editing value of files,images,texts. Fri, 2 Oct 2020 23:11:48 +0200 Jan Dankert Cleanup: No '.inputholder' any more, notices with links to objects. Tue, 29 Sep 2020 22:17:11 +0200 Jan Dankert Refactoring: Do not use global constants. Sat, 26 Sep 2020 04:03:53 +0200 Jan Dankert Refactoring: read language keys with a class. Sun, 23 Feb 2020 04:01:30 +0100 Jan Dankert Refactoring with Namespaces for the cms modules, part 1: moving.