File indexing completed on 2024-12-22 05:36:23
0001 <?php 0002 /** 0003 * ocs-webserver 0004 * 0005 * Copyright 2016 by pling GmbH. 0006 * 0007 * This file is part of ocs-webserver. 0008 * 0009 * This program is free software: you can redistribute it and/or modify 0010 * it under the terms of the GNU Affero General Public License as 0011 * published by the Free Software Foundation, either version 3 of the 0012 * License, or (at your option) any later version. 0013 * 0014 * This program is distributed in the hope that it will be useful, 0015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 * GNU Affero General Public License for more details. 0018 * 0019 * You should have received a copy of the GNU Affero General Public License 0020 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 **/ 0022 0023 class Local_Form_Decorator_File extends Zend_Form_Decorator_File 0024 { 0025 0026 public function render($content) 0027 { 0028 $element = $this->getElement(); 0029 if (!$element instanceof Zend_Form_Element) { 0030 return $content; 0031 } 0032 0033 $view = $element->getView(); 0034 if (!$view instanceof Zend_View_Interface) { 0035 return $content; 0036 } 0037 0038 $name = $element->getName(); 0039 $attribs = $this->getAttribs(); 0040 if (!array_key_exists('id', $attribs)) { 0041 $attribs['id'] = $name; 0042 } 0043 0044 $separator = $this->getSeparator(); 0045 $placement = $this->getPlacement(); 0046 $markup = array(); 0047 $size = $element->getMaxFileSize(); 0048 if ($size > 0) { 0049 $markup[] = $view->formHidden('MAX_FILE_SIZE', $size); 0050 } 0051 0052 if (Zend_File_Transfer_Adapter_Http::isApcAvailable()) { 0053 $markup[] = $view->formHidden(ini_get('apc.rfc1867_name'), uniqid(), array('id' => 'progress_key')); 0054 } else { 0055 if (Zend_File_Transfer_Adapter_Http::isUploadProgressAvailable()) { 0056 $markup[] = $view->formHidden('UPLOAD_IDENTIFIER', uniqid(), array('id' => 'progress_key')); 0057 } 0058 } 0059 0060 $helper = $element->helper; 0061 if ($element->isArray()) { 0062 $name .= "[]"; 0063 $count = $element->getMultiFile(); 0064 for ($i = 0; $i < $count; ++$i) { 0065 $htmlAttribs = $attribs; 0066 $htmlAttribs['id'] .= '-' . $i; 0067 $markup[] = $view->$helper($name, $htmlAttribs); 0068 } 0069 } else { 0070 $markup[] = $view->$helper($name, $attribs); 0071 } 0072 0073 $markup = implode($separator, $markup); 0074 0075 switch ($placement) { 0076 case self::PREPEND: 0077 return $markup . $separator . $content; 0078 case self::APPEND: 0079 default: 0080 return $content . $separator . $markup; 0081 } 0082 } 0083 0084 }