File indexing completed on 2024-12-22 05:33:28
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 * Description of Backend_Form_Project 0024 * 0025 * @author Björn Schramke 0026 */ 0027 class Backend_Form_Project extends Zend_Form 0028 { 0029 0030 public function init() 0031 { 0032 $filterStripSlashes = new Zend_Filter_Callback('stripslashes'); 0033 0034 $validStringLength = new Zend_Validate_StringLength(); 0035 $validStringLength->setMax(140); 0036 $validStringLength->setMin(1); 0037 0038 $imageTable = new Default_Model_DbTable_Image(); 0039 0040 0041 $title = $this->createElement('text', 'title') 0042 ->setLabel('Product Name') 0043 ->setRequired(true) 0044 ->setFilters(array('StringTrim', $filterStripSlashes)); 0045 0046 0047 $category = $this->createElement('select', 'project_category_id') 0048 ->setLabel('Category') 0049 ->setRequired(true); 0050 $projCattable = new Default_Model_DbTable_ProjectCategory(); 0051 $categoryList = $projCattable->getSelectList(); 0052 $categoryValidator = new Zend_Validate_InArray(array_keys(array_slice($categoryList, 1, null, true))); 0053 $category->addValidator($categoryValidator); 0054 $category->addMultiOptions($categoryList); 0055 0056 0057 $member = $this->createElement('select', 'member_id') 0058 ->setLabel('Zu welchem Mitglied gehört dieses Projekt?') 0059 ->setRequired(true); 0060 $memberTable = new Default_Model_Member(); 0061 $memberList = $memberTable->getMembersForSelectList(); 0062 $memberValidator = new Zend_Validate_InArray(array_keys(array_slice($memberList, 1, null, true))); 0063 $member->addValidator($memberValidator) 0064 ->addMultiOptions($memberList); 0065 0066 0067 $description = $this->createElement('textarea', 'description', array('cols' => 30, 'rows' => 3)) 0068 ->setLabel('Product Description') 0069 ->setRequired(true); 0070 0071 0072 $short_description = $this->createElement('textarea', 'short_text', array('cols' => 30, 'rows' => 3)) 0073 ->setLabel('Product Short Description') 0074 ->setRequired(true) 0075 ->addValidator($validStringLength); 0076 0077 $member = $this->createElement('select', 'member_id') 0078 ->setLabel('Zu welchem Mitglied gehört dieses Projekt?') 0079 ->setRequired(true) 0080 ->addErrorMessage("Sie müssen ein Projekt auswählen"); 0081 0082 $memberTable = new Default_Model_Member(); 0083 $memberList = $memberTable->getMembersForSelectList(); 0084 $memberValidator = new Zend_Validate_InArray(array_keys(array_slice($memberList, 1, null, true))); 0085 $member->addValidator($memberValidator) 0086 ->addMultiOptions($memberList); 0087 0088 0089 $activeProject = $this->createElement('checkbox', 'is_active') 0090 ->setLabel("Projekt aktivieren und im Frontend anzeigen"); 0091 0092 0093 $video = $this->createElement('textarea', 'embed_code', array('cols' => 30, 'rows' => 3)) 0094 ->setLabel('HTML or Embed Media Code (Youtube, Vimeo, Soundcloud etc.)') 0095 ->setRequired(false) 0096 ->setAttrib('placeholder', '<iframe src="https://www.youtube.com/embed/XXXXXXXX" style="width:641px;height:360px;" width="641" height="360" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>') 0097 ->setAttrib("stylestyle", "padding: 0;"); 0098 0099 0100 $link_1 = $this->createElement('text', 'link_1', array()) 0101 ->setLabel('Link to your product') 0102 ->setRequired(false) 0103 ->setFilters(array('StringTrim')); 0104 0105 $facebook = $this->createElement('text', 'facebook_code', array()) 0106 ->setLabel('Your Product on Facebook') 0107 ->setRequired(false) 0108 ->setFilters(array('StringTrim')); 0109 0110 $twitter_code = $this->createElement('text', 'twitter_code', array()) 0111 ->setLabel('Your Product on Twitter') 0112 ->setRequired(false) 0113 ->setFilters(array('StringTrim')); 0114 0115 0116 $hiddenProductPicture = $this->createElement('hidden', 'image_small') 0117 ->setAttrib('data-target', '#product-picture-preview'); 0118 0119 $previewProductPicture = new Local_Form_Element_Note('note', array('name' => 'image_small_preview', 'value' => '<img id="product-picture-preview" src="" alt="product picture" width="110">')); 0120 0121 $productPicture = $this->createElement('file', 'image_small_upload') 0122 ->setDisableLoadDefaultDecorators(true) 0123 ->setLabel('Product Logo (min. 20x20, max. 2000x2000, max. 2MB)') 0124 //->setDescription('(min. 50x50, max. 1000x1000, 2MB)') 0125 ->setRequired(true) 0126 ->setAttrib('class', 'product-picture') 0127 ->setAttrib('onchange', 'ImagePreview.previewImage(this, \'product-picture-preview\');') 0128 ->addValidator('Count', false, 1) 0129 //->addValidator('Size', false, 2097152) 0130 ->addValidator('FilesSize', false, 2000000) 0131 ->addValidator('Extension', false, $imageTable->getAllowedFileExtension()) 0132 ->addValidator('Size', false, array('min' => '5B', 'max' => '2MB')) 0133 ->addValidator('ImageSize', false, 0134 array('minwidth' => 20, 0135 'minheight' => 20, 0136 'maxwidth' => 2000, 0137 'maxheight' => 2000 0138 )) 0139 ->addValidator('MimeType', false, $imageTable->getAllowedMimeTypes()); 0140 0141 $hiddenTitlePicture = $this->createElement('hidden', 'image_big') 0142 ->setAttrib('data-target', '#image_big-element'); 0143 0144 $previewTitlePicture = new Local_Form_Element_Note('note', array('name' => 'image_big_preview', 'value' => '<img id="title-picture-preview" src="" alt="title picture" width="110">')); 0145 0146 $titlePicture = $this->createElement('file', 'image_big_upload') 0147 ->setDisableLoadDefaultDecorators(true) 0148 ->setLabel('Banner (min. 100x100, max. 2000x1200, max. 2MB)') 0149 ->setRequired(false) 0150 ->setAttrib('class', 'title-picture') 0151 ->setAttrib('onchange', 'ImagePreview.previewImage(this, \'title-picture-preview\');') 0152 ->addValidator('Count', false, 1) 0153 ->addValidator('Size', false, 2097152) 0154 ->addValidator('FilesSize', false, 2000000) 0155 ->addValidator('Extension', false, $imageTable->getAllowedFileExtension()) 0156 ->addValidator('ImageSize', false, 0157 array('minwidth' => 100, 0158 'maxwidth' => 2000, 0159 'minheight' => 100, 0160 'maxheight' => 1200 0161 )) 0162 ->addValidator('MimeType', false, $imageTable->getAllowedMimeTypes()); 0163 0164 0165 $this->addElement($activeProject) 0166 ->addElement($title) 0167 ->addElement($category) 0168 ->addElement($member) 0169 ->addElement($short_description) 0170 ->addElement($description) 0171 ->addElement($hiddenProductPicture) 0172 ->addElement($previewProductPicture) 0173 ->addElement($productPicture) 0174 ->addElement($hiddenTitlePicture) 0175 ->addElement($previewTitlePicture) 0176 ->addElement($titlePicture) 0177 ->addElement($video) 0178 ->addElement($facebook) 0179 ->addElement($twitter_code) 0180 ->addElement($link_1) 0181 ->addElement('submit', 'send', array('label' => 'Speichern')) 0182 ->addElement('submit', 'sendclose', array('label' => 'Speichern & Schließen')); 0183 } 0184 0185 }