File indexing completed on 2024-12-15 05:21:37
0001 <?php 0002 0003 /** 0004 * ocs-apiserver 0005 * 0006 * Copyright 2016 by pling GmbH. 0007 * 0008 * This file is part of ocs-apiserver. 0009 * 0010 * This program is free software: you can redistribute it and/or modify 0011 * it under the terms of the GNU Affero General Public License as 0012 * published by the Free Software Foundation, either version 3 of the 0013 * License, or (at your option) any later version. 0014 * 0015 * This program is distributed in the hope that it will be useful, 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0018 * GNU Affero General Public License for more details. 0019 * 0020 * You should have received a copy of the GNU Affero General Public License 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0022 **/ 0023 class Application_View_Helper_Image extends Zend_View_Helper_Abstract 0024 { 0025 0026 protected $_operations = array( 0027 'crop' => '%d', 0028 'width' => '%d', 0029 'height' => '%d', 0030 'quality' => '%d', 0031 'bgColor' => '%s', 0032 'progressive' => '%d' 0033 ); 0034 0035 protected $_options = array( 0036 'temporal' => false 0037 ); 0038 0039 protected $_separator = '-'; 0040 0041 public function Image($filename, $options = array()) 0042 { 0043 if (strpos($filename, 'http', 0) === 0) { 0044 return $filename; 0045 } 0046 0047 $operations = ""; 0048 0049 if (isset($options['width']) && isset($options['height'])) { 0050 $operations .= $options['width'] . 'x' . $options['height']; 0051 } else { 0052 //$operations .= '80x80'; 0053 $operations .= ''; 0054 } 0055 if (isset($options['crop'])) { 0056 $operations .= '-' . $options['crop']; 0057 } else { 0058 //$operations .= '-2'; 0059 $operations .= ''; 0060 } 0061 0062 if ($filename == "") { 0063 $filename = 'default-ocs.png'; 0064 } 0065 0066 if (isset($options['temporal'])) { 0067 $filename = '/img/default/tmp/' . $filename; 0068 $url = $filename; 0069 } else { 0070 if (strpos($filename, '.gif') > 0 || $operations == '') { 0071 $url = IMAGES_MEDIA_SERVER . '/img/' . $filename; 0072 } else { 0073 $url = IMAGES_MEDIA_SERVER . '/cache/' . $operations . '/img/' . $filename; 0074 } 0075 } 0076 0077 return $url; 0078 } 0079 0080 }