From 12950af29756d926c85c6c7bb4275cba8df17b58 Mon Sep 17 00:00:00 2001 From: Jose Date: Wed, 17 Sep 2014 12:53:23 +0200 Subject: [PATCH 01/35] =?UTF-8?q?a=C3=B1ado=20funcionalidad=20para=20que?= =?UTF-8?q?=20mediante=20parametros=20se=20pueda=20hacer=20crop=20de=20una?= =?UTF-8?q?=20imagen.=20Ademas=20permito=20buscar=20por=20posicion=20en=20?= =?UTF-8?q?etiquetas.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Config/core.php | 2 +- .../Component/ImageResizerComponent.php | 18 + Controller/MediaController.php | 67 +- Vendor/phpthumb/phpthumb.class.php | 6 +- webroot/ccss/OpenLayers/img/close.gif | Bin 0 -> 1078 bytes webroot/ccss/OpenLayers/style.css | 484 ++++ webroot/ccss/_jquery_ui.sass | 1470 ++++++++++++ webroot/ccss/backend.css | 1970 +++++++++++++++++ webroot/ccss/backend.sass | 25 + webroot/ccss/backend/_form.sass | 106 + webroot/ccss/backend/_layout.sass | 78 + webroot/ccss/backend/_menu.sass | 41 + webroot/ccss/backend/_table.sass | 27 + webroot/ccss/backend/_text.sass | 39 + webroot/ccss/breadcrumb.css | 63 + webroot/ccss/cake.generic.css | 478 ++++ webroot/ccss/comment.css | 44 + .../images/ui-bg_flat_0_123e78_40x100.png | Bin 0 -> 213 bytes .../images/ui-bg_flat_0_1a8301_40x100.png | Bin 0 -> 180 bytes .../images/ui-bg_flat_0_222222_40x100.png | Bin 0 -> 180 bytes .../images/ui-bg_flat_0_333333_40x100.png | Bin 0 -> 180 bytes .../images/ui-bg_flat_0_aaaaaa_40x100.png | Bin 0 -> 180 bytes .../images/ui-bg_flat_0_ad0900_40x100.png | Bin 0 -> 181 bytes .../images/ui-bg_flat_40_2259a5_40x100.png | Bin 0 -> 213 bytes .../images/ui-bg_flat_75_000000_40x100.png | Bin 0 -> 178 bytes .../ui-bg_highlight-hard_50_aaaaaa_1x100.png | Bin 0 -> 107 bytes .../images/ui-icons_aaaaaa_256x240.png | Bin 0 -> 4369 bytes .../images/ui-icons_cccccc_256x240.png | Bin 0 -> 4369 bytes .../images/ui-icons_dddddd_256x240.png | Bin 0 -> 4369 bytes .../images/ui-icons_ffffff_256x240.png | Bin 0 -> 4369 bytes .../custom-phtagr/jquery-ui-1.8.14.custom.css | 568 +++++ webroot/ccss/debug.css | 43 + webroot/ccss/default.css | 1253 +++++++++++ webroot/ccss/default.sass | 13 + webroot/ccss/default/_colors.sass | 34 + webroot/ccss/default/_explorer.sass | 278 +++ webroot/ccss/default/_form.sass | 153 ++ webroot/ccss/default/_home.sass | 57 + webroot/ccss/default/_image.sass | 81 + webroot/ccss/default/_layout.sass | 142 ++ webroot/ccss/default/_map.sass | 56 + webroot/ccss/default/_text.sass | 68 + webroot/ccss/default/_upload.sass | 30 + webroot/ccss/explorer.css | 252 +++ webroot/ccss/formular.css | 157 ++ webroot/ccss/images/debug.png | Bin 0 -> 1855 bytes webroot/ccss/images/error.png | Bin 0 -> 1371 bytes webroot/ccss/images/header.png | Bin 0 -> 4655 bytes webroot/ccss/images/header.svg | 273 +++ webroot/ccss/images/icon.png | Bin 0 -> 5048 bytes webroot/ccss/images/info.png | Bin 0 -> 1417 bytes webroot/ccss/images/question.png | Bin 0 -> 1535 bytes webroot/ccss/images/success.png | Bin 0 -> 1279 bytes webroot/ccss/images/vote-none.png | Bin 0 -> 582 bytes webroot/ccss/images/vote-select.png | Bin 0 -> 579 bytes webroot/ccss/images/vote-set.png | Bin 0 -> 466 bytes webroot/ccss/images/warning.png | Bin 0 -> 1218 bytes webroot/ccss/messages.css | 40 + webroot/ccss/patches/patch_phtagr.css | 47 + webroot/ccss/phtagr.css | 31 + webroot/ccss/phtagr.generic.css | 62 + webroot/ccss/screen/basemod.css | 154 ++ webroot/ccss/screen/content.css | 182 ++ .../screen/images/gfxborder/border_bottom.gif | Bin 0 -> 116 bytes .../screen/images/gfxborder/border_left.gif | Bin 0 -> 116 bytes .../screen/images/gfxborder/border_right.gif | Bin 0 -> 116 bytes .../screen/images/gfxborder/border_top.gif | Bin 0 -> 116 bytes .../screen/images/gfxborder/corner_bl.gif | Bin 0 -> 264 bytes .../screen/images/gfxborder/corner_br.gif | Bin 0 -> 266 bytes .../screen/images/gfxborder/corner_tl.gif | Bin 0 -> 266 bytes .../screen/images/gfxborder/corner_tr.gif | Bin 0 -> 266 bytes webroot/ccss/tab.css | 34 + webroot/ccss/table.css | 38 + 73 files changed, 8952 insertions(+), 12 deletions(-) create mode 100644 webroot/ccss/OpenLayers/img/close.gif create mode 100644 webroot/ccss/OpenLayers/style.css create mode 100644 webroot/ccss/_jquery_ui.sass create mode 100644 webroot/ccss/backend.css create mode 100644 webroot/ccss/backend.sass create mode 100644 webroot/ccss/backend/_form.sass create mode 100644 webroot/ccss/backend/_layout.sass create mode 100644 webroot/ccss/backend/_menu.sass create mode 100644 webroot/ccss/backend/_table.sass create mode 100644 webroot/ccss/backend/_text.sass create mode 100644 webroot/ccss/breadcrumb.css create mode 100644 webroot/ccss/cake.generic.css create mode 100644 webroot/ccss/comment.css create mode 100644 webroot/ccss/custom-phtagr/images/ui-bg_flat_0_123e78_40x100.png create mode 100644 webroot/ccss/custom-phtagr/images/ui-bg_flat_0_1a8301_40x100.png create mode 100644 webroot/ccss/custom-phtagr/images/ui-bg_flat_0_222222_40x100.png create mode 100644 webroot/ccss/custom-phtagr/images/ui-bg_flat_0_333333_40x100.png create mode 100644 webroot/ccss/custom-phtagr/images/ui-bg_flat_0_aaaaaa_40x100.png create mode 100644 webroot/ccss/custom-phtagr/images/ui-bg_flat_0_ad0900_40x100.png create mode 100644 webroot/ccss/custom-phtagr/images/ui-bg_flat_40_2259a5_40x100.png create mode 100644 webroot/ccss/custom-phtagr/images/ui-bg_flat_75_000000_40x100.png create mode 100644 webroot/ccss/custom-phtagr/images/ui-bg_highlight-hard_50_aaaaaa_1x100.png create mode 100644 webroot/ccss/custom-phtagr/images/ui-icons_aaaaaa_256x240.png create mode 100644 webroot/ccss/custom-phtagr/images/ui-icons_cccccc_256x240.png create mode 100644 webroot/ccss/custom-phtagr/images/ui-icons_dddddd_256x240.png create mode 100644 webroot/ccss/custom-phtagr/images/ui-icons_ffffff_256x240.png create mode 100644 webroot/ccss/custom-phtagr/jquery-ui-1.8.14.custom.css create mode 100644 webroot/ccss/debug.css create mode 100644 webroot/ccss/default.css create mode 100644 webroot/ccss/default.sass create mode 100644 webroot/ccss/default/_colors.sass create mode 100644 webroot/ccss/default/_explorer.sass create mode 100644 webroot/ccss/default/_form.sass create mode 100644 webroot/ccss/default/_home.sass create mode 100644 webroot/ccss/default/_image.sass create mode 100644 webroot/ccss/default/_layout.sass create mode 100644 webroot/ccss/default/_map.sass create mode 100644 webroot/ccss/default/_text.sass create mode 100644 webroot/ccss/default/_upload.sass create mode 100644 webroot/ccss/explorer.css create mode 100644 webroot/ccss/formular.css create mode 100644 webroot/ccss/images/debug.png create mode 100644 webroot/ccss/images/error.png create mode 100644 webroot/ccss/images/header.png create mode 100644 webroot/ccss/images/header.svg create mode 100644 webroot/ccss/images/icon.png create mode 100644 webroot/ccss/images/info.png create mode 100644 webroot/ccss/images/question.png create mode 100644 webroot/ccss/images/success.png create mode 100644 webroot/ccss/images/vote-none.png create mode 100644 webroot/ccss/images/vote-select.png create mode 100644 webroot/ccss/images/vote-set.png create mode 100644 webroot/ccss/images/warning.png create mode 100644 webroot/ccss/messages.css create mode 100644 webroot/ccss/patches/patch_phtagr.css create mode 100644 webroot/ccss/phtagr.css create mode 100644 webroot/ccss/phtagr.generic.css create mode 100644 webroot/ccss/screen/basemod.css create mode 100644 webroot/ccss/screen/content.css create mode 100644 webroot/ccss/screen/images/gfxborder/border_bottom.gif create mode 100644 webroot/ccss/screen/images/gfxborder/border_left.gif create mode 100644 webroot/ccss/screen/images/gfxborder/border_right.gif create mode 100644 webroot/ccss/screen/images/gfxborder/border_top.gif create mode 100644 webroot/ccss/screen/images/gfxborder/corner_bl.gif create mode 100644 webroot/ccss/screen/images/gfxborder/corner_br.gif create mode 100644 webroot/ccss/screen/images/gfxborder/corner_tl.gif create mode 100644 webroot/ccss/screen/images/gfxborder/corner_tr.gif create mode 100644 webroot/ccss/tab.css create mode 100644 webroot/ccss/table.css diff --git a/Config/core.php b/Config/core.php index 871622a6..64229155 100644 --- a/Config/core.php +++ b/Config/core.php @@ -263,7 +263,7 @@ /** * A random string used in security hashing methods. */ - Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi'); + Configure::write('Security.salt', '2Q6HX62YKE7FEtJsg4KS9Mg1tOyedpOV5KcSGVqRi'); /** * A random numeric string (digits only) used to encrypt/decrypt strings. diff --git a/Controller/Component/ImageResizerComponent.php b/Controller/Component/ImageResizerComponent.php index c387fdf6..09d8946d 100644 --- a/Controller/Component/ImageResizerComponent.php +++ b/Controller/Component/ImageResizerComponent.php @@ -54,6 +54,7 @@ public function resize($src, $dst, $options = array()) { 'clearMetaData' => true, 'isOriginal' => false ), $options); + if (!is_readable($src)) { CakeLog::error("Could not read source $src"); @@ -128,6 +129,15 @@ private function _configurePhpThump(&$phpThumb, &$src, &$dst, &$options) { private function _configureOptions(&$phpThumb, &$options) { $phpThumb->w = $options['size']; $phpThumb->h = $options['size']; + + if(isset($options['w'])){ + $phpThumb->w = $options['w']; + } + + if(isset($options['h'])){ + $phpThumb->h = $options['h']; + } + $phpThumb->q = $options['quality']; $phpThumb->ra = $options['rotation']; @@ -136,6 +146,14 @@ private function _configureOptions(&$phpThumb, &$options) { $phpThumb->w = $options['size']; $phpThumb->h = $options['size']; } + + if(isset($options['zc'])){ + $phpThumb->zc = $options['zc']; + } + + + + } /** diff --git a/Controller/MediaController.php b/Controller/MediaController.php index 71d6dc92..ed1717ec 100644 --- a/Controller/MediaController.php +++ b/Controller/MediaController.php @@ -22,7 +22,7 @@ class MediaController extends AppController var $config = array( 'video' => array('size' => OUTPUT_SIZE_VIDEO, 'bitrate' => OUTPUT_BITRATE_VIDEO) ); - var $components = array('PreviewManager'); + var $components = array('PreviewManager','Search'); // JOSE: Anado search. public function beforeFilter() { // Reduce security level for this controller if required. Security level @@ -113,9 +113,9 @@ private function _getMedia($id, $type = 'preview') { return $media; } - private function _sendPreview($id, $type) { + private function _sendPreview($id, $type,$options=array()) { $media = $this->_getMedia($id, $type); - $preview = $this->PreviewManager->getPreview($media, $type); + $preview = $this->PreviewManager->getPreview($media, $type, $options); if (!$preview) { CakeLog::error("Fetching preview type '{$type}' for {$this->Media->toString($media)} failed"); $this->redirect(null, 403); @@ -145,23 +145,33 @@ private function _createFlashVideo($id) { } public function mini($id) { - return $this->_sendPreview($id, 'mini'); + $params = $this->_getParamsResize(); + $name = (count($params>0)) ? 'mini_'.md5(implode('_',$params)) : 'mini'; + return $this->_sendPreview($id, $name, $params); } public function thumb($id) { - return $this->_sendPreview($id, 'thumb'); + $params = $this->_getParamsResize(); + $name = (count($params>0)) ? 'thumb_'.md5(implode('_',$params)) : 'thumb'; + return $this->_sendPreview($id, $name, $params); } public function preview($id) { - return $this->_sendPreview($id, 'preview'); + $params = $this->_getParamsResize(); + $name = (count($params>0)) ? 'preview_'.md5(implode('_',$params)) : 'preview'; + return $this->_sendPreview($id, $name, $params); } public function high($id) { - return $this->_sendPreview($id, 'high'); + $params = $this->_getParamsResize(); + $name = (count($params>0)) ? 'high_'.md5(implode('_',$params)) : 'high'; + return $this->_sendPreview($id, $name, $params); } public function hd($id) { - return $this->_sendPreview($id, 'hd'); + $params = $this->_getParamsResize(); + $name = (count($params>0)) ? 'hd_'.md5(implode('_',$params)) : 'hd'; + return $this->_sendPreview($id, $name, $params); } public function video($id) { @@ -332,4 +342,45 @@ public function zip($format) { $zipName = 'phtagr-' . date('Y-m-d_H-i-s') . '.zip'; $this->_createZipFile($zipName, $files); } + + /** + * @author Jose + * Con esta funcion permito que mediante una busqueda se pueda devolver + * una imagen determinada. + */ + public function show($number){ + $medias = $this->_getListPhotos(); + $number = ($number>0) ? $number-1 : 0; + + if(isset($medias[$number])){ + $params = $this->_getParamsResize(); + $name = (count($params>0)) ? 'high_'.md5(implode('_',$params)) : 'high'; + return $this->_sendPreview($medias[$number]['Media']['id'], $name,$params); + } + return false; + } + + /** + * @author Jose + * @date 17-09-2014 + * Obtengo todas las fotos con unos determinados argumentos. Esto es + * porque media trabaja con el ID de la foto y no con la posicion dentro + * de la etiqueta + * @return type + */ + private function _getListPhotos(){ + $this->crumbs = $this->Search->urlToCrumbs($this->request->url, 2); + return $this->Search->paginateByCrumbs($this->crumbs); + + } + + private function _getParamsResize(){ + $params = array(); + foreach(array('w','h','zc') as $p){ + if(isset($_GET[$p])) $params[$p] = $_GET[$p]; + } + + return $params; + + } } diff --git a/Vendor/phpthumb/phpthumb.class.php b/Vendor/phpthumb/phpthumb.class.php index b3f9a8a8..90ed7247 100644 --- a/Vendor/phpthumb/phpthumb.class.php +++ b/Vendor/phpthumb/phpthumb.class.php @@ -347,7 +347,7 @@ function GenerateThumbnail() { $this->phpThumbDebug('8g'); $this->CreateGDoutput(); $this->phpThumbDebug('8h'); - + switch ($this->far) { case 'L': case 'TL': @@ -1303,7 +1303,7 @@ function ImageMagickThumbnailToGD() { // $UnAllowedParameters contains options that can only be processed in GD, not ImageMagick // note: 'fltr' *may* need to be processed by GD, but we'll check that in more detail below $UnAllowedParameters = array('xto', 'ar', 'bg', 'bc'); - // 'ra' may be part of this list, if not a multiple of 90° + // 'ra' may be part of this list, if not a multiple of 90� foreach ($UnAllowedParameters as $parameter) { if (isset($this->$parameter)) { $this->DebugMessage('$this->useRawIMoutput=false because "'.$parameter.'" is set', __FILE__, __LINE__); @@ -1479,6 +1479,7 @@ function ImageMagickThumbnailToGD() { $commandline .= ' -gravity center'; break; } + echo $comandline;exit; if (($wAll > 0) && ($hAll > 0)) { $commandline .= ' -crop '.escapeshellarg($wAll.'x'.$hAll.'+0+0'); @@ -3398,7 +3399,6 @@ function SourceImageToGD() { return true; } $this->DebugMessage('starting SourceImageToGD()', __FILE__, __LINE__); - if ($this->config_prefer_imagemagick) { if (empty($this->sourceFilename) && !empty($this->rawImageData)) { $this->DebugMessage('Copying raw image data to temp file and trying again with ImageMagick', __FILE__, __LINE__); diff --git a/webroot/ccss/OpenLayers/img/close.gif b/webroot/ccss/OpenLayers/img/close.gif new file mode 100644 index 0000000000000000000000000000000000000000..a8958de9b429ae00f56bb282c4b133ecbaf334bd GIT binary patch literal 1078 zcmZ?wbhEHb6l4%&_|5bmP+{ z8=fxT^nBIU?+>5;c=qzk<7f96^e*$8T;?~uENp&7)bfg`)n!quD`Hlc#jGv?Npb7T z5;m8BNYduAlsu4mLePHK3b)AGKc z>vvYy?~Ja`8C~BqdcMbXy-w@-o;M0SZs2#)(C>ti{{_>K3ud9`%tFqahh1=qzu=N^ z(KYdcYr!BJ0Fg_9;)jvY-3rJ@d_b z;g|p1FaMce!3+O_m%+ua)0*F9w!O`4eV5h#CadjzZr8iq&UblTZ>lH1shjq;e)_w{ z8SffrzH6KFdg79A^EdrixaIreZQqw{`|CMFrPsOqym&D7&!hjSaZsFY+6^S6WB|jz|Trx{Mnn_1s z(GvD44549L9x7aLo?~ylhNYlD*^7bAh~uKBLckGOm;R=dk17q5h291JB`GLjy9F{oMb+*G{n z$vj&$l*#1B#1xKc48bu6R^EK+G(&`W$q9!^nnL`#vm$DCCS2l?64B-|G