コード例 #1
0
 /**
  */
 public function editRTMP()
 {
     $form = new PHPWS_Form();
     $form->setFormId('file-form');
     $form->addHidden('multimedia_id', $this->multimedia->id);
     $form->addHidden('module', 'filecabinet');
     $form->addHidden('mop', 'post_rtmp');
     $form->addHidden('folder_id', $this->multimedia->folder_id);
     $form->addText('title', $this->multimedia->getTitle());
     $form->setLabel('title', 'Stream title');
     $form->setClass('title', 'form-control');
     $form->addText('rtmp_server', $this->multimedia->file_directory);
     $form->setLabel('rtmp_server', 'RTMP server');
     $form->setClass('rtmp_server', 'form-control');
     $form->addText('rtmp_file', $this->multimedia->file_name);
     $form->setLabel('rtmp_file', 'Stream/File name');
     $form->setClass('rtmp_file', 'form-control');
     $form->addText('width', $this->multimedia->width);
     $form->setLabel('width', 'Width');
     $form->setClass('width', 'form-control');
     $form->addText('height', $this->multimedia->height);
     $form->setLabel('height', 'Height');
     $form->setClass('height', 'form-control');
     $tpl = $form->getTemplate();
     $this->title = dgettext('filecabinet', 'Create/Update RTMP Stream');
     $this->content = PHPWS_Template::process($tpl, 'filecabinet', 'Forms/rtmp_edit.tpl');
 }
コード例 #2
0
ファイル: Image_Manager.php プロジェクト: HaldunA/phpwebsite
 /**
  * Upload image form
  */
 public function edit($force_width = 0, $force_height = 0)
 {
     $form = new PHPWS_Form();
     $form->setFormId('file-form');
     $form->addHidden('module', 'filecabinet');
     $form->addHidden('iop', 'post_image_upload');
     $form->addHidden('ms', $this->max_size);
     $form->addHidden('mh', $this->max_height);
     $form->addHidden('mw', $this->max_width);
     $form->addHidden('folder_id', $this->folder->id);
     if ($this->image->id && Current_User::allow('filecabinet', 'edit_folders', $this->folder->id, 'folder', true)) {
         Cabinet::moveToForm($form, $this->folder);
     }
     // if 'im' is set, then we are inside the image manage interface
     // the post needs to be aware of that to respond correctly
     if (isset($_GET['im'])) {
         $form->addHidden('im', 1);
     }
     if ($this->image->id) {
         $form->addHidden('image_id', $this->image->id);
         $this->title = dgettext('filecabinet', 'Update image');
     } else {
         $this->title = dgettext('filecabinet', 'Upload image');
     }
     $form->addFile('file_name');
     $form->setClass('file_name', 'form-control');
     $form->setSize('file_name', 30);
     $form->setMaxFileSize($this->max_size);
     $form->setLabel('file_name', dgettext('filecabinet', 'Image location'));
     $form->addText('title', $this->image->title);
     $form->setLabel('title', dgettext('filecabinet', 'Title'));
     $form->setClass('title', 'form-control');
     $form->addTextArea('description', $this->image->description);
     $form->setRows('description', 8);
     $form->setCols('description', 45);
     $form->setLabel('description', dgettext('filecabinet', 'Description'));
     if ($this->image->folder_id) {
         $folder = new Folder($this->image->folder_id);
         if ($folder->public_folder) {
             $link_choice['folder'] = dgettext('filecabinet', 'Link to image folder');
         }
     }
     if ($this->folder->max_image_dimension && $this->folder->max_image_dimension < $this->max_width) {
         $max_width = $this->folder->max_image_dimension;
     } else {
         $max_width = $this->max_width;
     }
     if ($force_width && $force_height) {
         $form->addHidden('fw', $force_width);
         $form->addHidden('fh', $force_height);
         $form->addTplTag('RESIZE_LABEL', dgettext('filecabinet', 'Images resized to:'));
         $form->addTplTag('RESIZE', sprintf('%s x %spx', $force_width, $force_height));
     } elseif (!$this->image->id) {
         $resizes = Cabinet::getResizes($max_width);
         if (!empty($resizes)) {
             $form->addSelect('resize', $resizes);
             $form->setLabel('resize', dgettext('filecabinet', 'Resize image if over'));
         }
     }
     switch (1) {
         case empty($this->image->url):
             $form->setMatch('link', 'none');
             $form->addTplTag('VISIBLE', 'none');
             $form->setValue('url', 'http://');
             break;
         case $this->image->url == 'parent':
             $form->setMatch('link', 'parent');
             $form->addTplTag('VISIBLE', 'none');
             break;
         case $this->image->url == 'folder':
             $form->setMatch('link', 'folder');
             $form->addTplTag('VISIBLE', 'none');
             break;
         default:
             $form->setMatch('link', 'url');
             $form->setValue('url', $this->image->url);
             $form->addTplTag('VISIBLE', 'table-row');
             break;
     }
     if (!empty($this->image->id)) {
         $form->addSubmit('submit', dgettext('filecabinet', 'Update'));
     } else {
         $form->addSubmit('submit', dgettext('filecabinet', 'Upload'));
     }
     $form->setClass('submit', 'btn btn-primary');
     $template = $form->getTemplate();
     $template['CANCEL'] = sprintf('<input type="button" value="%s" onclick="javascript:window.close()" />', dgettext('filecabinet', 'Cancel'));
     if ($this->image->id) {
         $template['CURRENT_IMAGE_LABEL'] = dgettext('filecabinet', 'Current image');
         $template['CURRENT_IMAGE'] = $this->image->getJSView(TRUE);
         $template['SIZE'] = sprintf('%s x %s', $this->image->width, $this->image->height);
     }
     $template['MAX_SIZE_LABEL'] = dgettext('filecabinet', 'Maximum file size');
     $template['MAX_DIMENSION_LABEL'] = dgettext('filecabinet', 'Maximum image dimension');
     $template['MAX_DIMENSION'] = $this->max_width;
     $sys_size = str_replace('M', '', ini_get('upload_max_filesize'));
     $sys_size = $sys_size * 1000000;
     $form_max = $form->max_file_size;
     if ($form_max < $sys_size && $form_max < $this->max_size) {
         $max_size =& $form_max;
     } elseif ($sys_size < $form_max && $sys_size < $this->max_size) {
         $max_size =& $sys_size;
     } else {
         $max_size =& $this->max_size;
     }
     $template['MAX_SIZE'] = File_Common::humanReadable($max_size);
     $template['ERRORS'] = $this->image->printErrors();
     $this->content = PHPWS_Template::process($template, 'filecabinet', 'Forms/image_edit.tpl');
 }