public function init() { // Set form attributes $this->setTitle('Create Advertisement'); $this->setDescription('Follow this guide to design and create a new advertisement.'); $this->setAttrib('id', 'form-upload'); $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array())); // Title $this->addElement('Text', 'name', array('label' => 'Advertisement Name', 'allowEmpty' => false, 'required' => true, 'validators' => array(array('NotEmpty', true), array('StringLength', false, array(1, 64))), 'filters' => array('StripTags', new Engine_Filter_Censor(), new Engine_Filter_EnableLinks()))); $this->addElement('Radio', 'media_type', array('id' => 'mediatype', 'label' => 'Advertisement Media', 'onchange' => "updateTextFields(this)", 'multiOptions' => array("0" => "Upload Banner Image", "1" => "Insert Banner HTML"), 'description' => 'CORE_FORM_ADMIN_ADS_AD_MEDIATYPE_DESCRIPTION')); // $this->media->getDecorator('Description')->setOption('placement', 'append'); // Init file $fancyUpload = new Engine_Form_Element_FancyUpload('file'); $fancyUpload->clearDecorators()->addDecorator('FormFancyUpload')->addDecorator('viewScript', array('viewScript' => '_FancyUpload.tpl', 'placement' => '')); Engine_Form::addDefaultDecorators($fancyUpload); $fancyUpload->setLabel("Upload Banner Image"); $this->addElement($fancyUpload); $this->addElement('Hidden', 'photo_id'); $this->addDisplayGroup(array('file'), 'upload_image'); $upload_image_group = $this->getDisplayGroup('upload_image'); $this->addElement('Textarea', 'html_code', array('label' => 'HTML Code')); // Buttons $this->addElement('Button', 'preview_html', array('label' => 'Preview', 'ignore' => true, 'onclick' => 'javascript:preview();', 'decorators' => array('ViewHelper'))); $this->addDisplayGroup(array('html_code', 'preview_html'), 'html_field'); $html_code_group = $this->getDisplayGroup('html_code'); // init submit $this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true)); }
public function init() { $auth = Engine_Api::_()->authorization()->context; $user = Engine_Api::_()->user()->getViewer(); // Init form $this->setTitle('Add New Songs')->setDescription('Choose music from your computer to add to this playlist.')->setAttrib('id', 'form-upload-music')->setAttrib('name', 'playlist_create')->setAttrib('enctype', 'multipart/form-data')->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array())); // Init name $this->addElement('Text', 'title', array('label' => 'Playlist Name', 'maxlength' => '63', 'filters' => array(new Engine_Filter_Censor(), new Engine_Filter_StringLength(array('max' => '63'))))); // Init descriptions $this->addElement('Textarea', 'description', array('label' => 'Playlist Description', 'maxlength' => '300', 'filters' => array('StripTags', new Engine_Filter_Censor(), new Engine_Filter_StringLength(array('max' => '300')), new Engine_Filter_EnableLinks()))); // Init search checkbox $this->addElement('Checkbox', 'search', array('label' => "Show this playlist in search results", 'value' => 1, 'checked' => true)); // AUTHORIZATIONS $availableLabels = $this->_roles; // Element: auth_view $viewOptions = (array) Engine_Api::_()->authorization()->getAdapter('levels')->getAllowed('music_playlist', $user, 'auth_view'); $viewOptions = array_intersect_key($availableLabels, array_flip($viewOptions)); if (count($viewOptions) >= 1) { $this->addElement('Select', 'auth_view', array('label' => 'Privacy', 'description' => 'Who may see this playlist?', 'multiOptions' => $viewOptions, 'value' => key($viewOptions))); $this->auth_view->getDecorator('Description')->setOption('placement', 'append'); } // Element: auth_comment $commentOptions = (array) Engine_Api::_()->authorization()->getAdapter('levels')->getAllowed('music_playlist', $user, 'auth_comment'); $commentOptions = array_intersect_key($availableLabels, array_flip($commentOptions)); if (count($commentOptions) >= 1) { $this->addElement('Select', 'auth_comment', array('label' => 'Comment Privacy', 'description' => 'Who may post comments on this playlist?', 'multiOptions' => $commentOptions, 'value' => key($commentOptions))); $this->auth_comment->getDecorator('Description')->setOption('placement', 'append'); } // Init playlist art $this->addElement('File', 'art', array('label' => 'Playlist Artwork')); $this->art->addValidator('Extension', false, 'jpg,png,gif,jpeg'); // Init file uploader $fancyUpload = new Engine_Form_Element_FancyUpload('file'); $fancyUpload->clearDecorators()->addDecorator('FormFancyUpload')->addDecorator('viewScript', array('viewScript' => '_FancyUpload.tpl', 'placement' => '')); Engine_Form::addDefaultDecorators($fancyUpload); $this->addElement($fancyUpload); // Init hidden file IDs $this->addElement('Hidden', 'fancyuploadfileids'); // Init submit $this->addElement('Button', 'submit', array('label' => 'Save Music to Playlist', 'type' => 'submit')); }
public function init() { // Init form $this->setTitle('Add New Photos')->setDescription('Choose photos on your computer to add to this classified listing. (2MB maximum)')->setAttrib('id', 'form-upload')->setAttrib('class', 'global_form classified_form_upload')->setAttrib('name', 'albums_create')->setAttrib('enctype', 'multipart/form-data')->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array())); $fancyUpload = new Engine_Form_Element_FancyUpload('file'); $fancyUpload->clearDecorators()->addDecorator('FormFancyUpload')->addDecorator('viewScript', array('viewScript' => '_FancyUpload.tpl', 'placement' => '')); Engine_Form::addDefaultDecorators($fancyUpload); $this->addElement($fancyUpload); $this->addElement('Hidden', 'fancyuploadfileids'); //$this->addElement('FancyUpload', 'file'); /* $this->addElement('Hidden', 'file', array( 'decorators' => array( array('ViewScript', array( 'viewScript' => '_formUpload.tpl', )) ) )); self::addDefaultDecorators($this->file); */ // Init submit $this->addElement('Button', 'submit', array('label' => 'Save Photos', 'type' => 'submit')); }
public function init() { // Init form $this->setTitle('Add New Video')->setAttrib('id', 'form-upload')->setAttrib('name', 'video_create')->setAttrib('enctype', 'multipart/form-data')->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array())); //->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array('module'=>'album', 'controller'=>'album', 'action'=>'upload-photo', 'format' => 'json'), 'default')); $user = Engine_Api::_()->user()->getViewer(); // Init name $this->addElement('Text', 'title', array('label' => 'Video Title', 'maxlength' => '100', 'allowEmpty' => false, 'required' => true, 'filters' => array('StripTags', new Engine_Filter_Censor(), new Engine_Filter_StringLength(array('max' => '100'))))); // init tag $this->addElement('Text', 'tags', array('label' => 'Tags (Keywords)', 'autocomplete' => 'off', 'description' => 'Separate tags with commas.', 'filters' => array(new Engine_Filter_Censor()))); $this->tags->getDecorator("Description")->setOption("placement", "append"); // Init descriptions $this->addElement('Textarea', 'description', array('label' => 'Video Description', 'filters' => array('StripTags', new Engine_Filter_Censor(), new Engine_Filter_EnableLinks()))); // prepare categories $categories = Engine_Api::_()->video()->getCategories(); if (count($categories) != 0) { $categories_prepared[0] = ""; foreach ($categories as $category) { $categories_prepared[$category->category_id] = $category->category_name; } // category field $this->addElement('Select', 'category_id', array('label' => 'Category', 'multiOptions' => $categories_prepared)); } // Init search $this->addElement('Checkbox', 'search', array('label' => "Show this video in search results", 'value' => 1)); // View $availableLabels = array('everyone' => 'Everyone', 'registered' => 'All Registered Members', 'owner_network' => 'Friends and Networks', 'owner_member_member' => 'Friends of Friends', 'owner_member' => 'Friends Only', 'owner' => 'Just Me'); $viewOptions = (array) Engine_Api::_()->authorization()->getAdapter('levels')->getAllowed('video', $user, 'auth_view'); $viewOptions = array_intersect_key($availableLabels, array_flip($viewOptions)); if (!empty($viewOptions) && count($viewOptions) >= 1) { $this->addElement('Select', 'auth_view', array('label' => 'Privacy', 'description' => 'Who may see this video?', 'multiOptions' => $viewOptions, 'value' => key($viewOptions))); $this->auth_view->getDecorator('Description')->setOption('placement', 'append'); } // Comment $commentOptions = (array) Engine_Api::_()->authorization()->getAdapter('levels')->getAllowed('video', $user, 'auth_comment'); $commentOptions = array_intersect_key($availableLabels, array_flip($commentOptions)); if (!empty($commentOptions) && count($commentOptions) >= 1) { $this->addElement('Select', 'auth_comment', array('label' => 'Comment Privacy', 'description' => 'Who may post comments on this video?', 'multiOptions' => $commentOptions, 'value' => key($commentOptions))); $this->auth_comment->getDecorator('Description')->setOption('placement', 'append'); } // Init video $this->addElement('Select', 'type', array('label' => 'Video Source', 'multiOptions' => array('0' => ' '), 'onchange' => "updateTextFields()")); //YouTube, Vimeo $video_options = array(); $video_options[1] = "YouTube"; $video_options[2] = "Vimeo"; //My Computer $allowed_upload = Engine_Api::_()->authorization()->getAdapter('levels')->getAllowed('video', $user, 'upload'); $ffmpeg_path = Engine_Api::_()->getApi('settings', 'core')->video_ffmpeg_path; if (!empty($ffmpeg_path) && $allowed_upload) { $video_options[3] = "My Computer"; } $this->type->addMultiOptions($video_options); //ADD AUTH STUFF HERE // Init url $this->addElement('Text', 'url', array('label' => 'Video Link (URL)', 'description' => 'Paste the web address of the video here.', 'maxlength' => '50')); $this->url->getDecorator("Description")->setOption("placement", "append"); $this->addElement('Hidden', 'code', array('order' => 1)); $this->addElement('Hidden', 'id', array('order' => 2)); $this->addElement('Hidden', 'ignore', array('order' => 3)); // Init file //$this->addElement('FancyUpload', 'file'); $fancyUpload = new Engine_Form_Element_FancyUpload('file'); $fancyUpload->clearDecorators()->addDecorator('FormFancyUpload')->addDecorator('viewScript', array('viewScript' => '_FancyUpload.tpl', 'placement' => '')); Engine_Form::addDefaultDecorators($fancyUpload); $this->addElement($fancyUpload); // Init submit $this->addElement('Button', 'upload', array('label' => 'Save Video', 'type' => 'submit')); //$this->addElements(Array($album, $name, $description, $search, $file, $submit)); }