Ejemplo n.º 1
0
 /**
  * Get form inputter.
  *
  * @param  string			The field name
  * @param  string			The field description
  * @param  array			The field details
  * @param  ?string		The actual current value of the field (NULL: none)
  * @param  boolean		Whether this is for a new entry
  * @return ?array			A pair: The Tempcode for the input field, Tempcode for hidden fields (NULL: skip the field - it's not input)
  */
 function get_field_inputter($_cf_name, $_cf_description, $field, $actual_value, $new)
 {
     $say_required = $field['cf_required'] == 1 && ($actual_value == '' || is_null($actual_value));
     require_code('galleries');
     $ffield = form_input_upload($_cf_name, $_cf_description, 'field_' . strval($field['id']), $say_required, $field['cf_required'] == 1 ? NULL : $actual_value, NULL, true, get_allowed_video_file_types());
     $hidden = new ocp_tempcode();
     handle_max_file_size($hidden);
     return array($ffield, $hidden);
 }
Ejemplo n.º 2
0
 /**
  * Get tempcode for a video adding/editing form.
  *
  * @param  SHORT_TEXT		The title
  * @param  ID_TEXT			The gallery
  * @param  LONG_TEXT			The video description
  * @param  URLPATH			The URL to the video file (blank: not yet added)
  * @param  URLPATH			The URL to the thumbnail
  * @param  BINARY				Video validation status
  * @param  ?BINARY			Whether rating is allowed (NULL: decide statistically, based on existing choices)
  * @param  ?SHORT_INTEGER	Whether comments are allowed (0=no, 1=yes, 2=review style) (NULL: decide statistically, based on existing choices)
  * @param  ?BINARY			Whether trackbacks are allowed (NULL: decide statistically, based on existing choices)
  * @param  LONG_TEXT			Notes for the video
  * @param  ?integer			The length of the video (NULL: not yet added, so not yet known)
  * @param  ?integer			The width of the video (NULL: not yet added, so not yet known)
  * @param  ?integer			The height of the video (NULL: not yet added, so not yet known)
  * @return array				A pair: the tempcode for the visible fields, and the tempcode for the hidden fields
  */
 function get_form_fields($title = '', $cat = '', $comments = '', $url = '', $thumb_url = '', $validated = 1, $allow_rating = NULL, $allow_comments = NULL, $allow_trackbacks = NULL, $notes = '', $video_length = NULL, $video_width = NULL, $video_height = NULL)
 {
     list($allow_rating, $allow_comments, $allow_trackbacks) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, $allow_trackbacks);
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'cat';
     $NON_CANONICAL_PARAMS[] = 'validated';
     $no_thumb_needed = get_option('ffmpeg_path') != '' || class_exists('ffmpeg_movie');
     if (!$no_thumb_needed) {
         $this->javascript = 'standardAlternateFields(\'file\',\'url\'); standardAlternateFields(\'file2\',\'thumb_url\',null,true);';
     } else {
         $this->javascript = 'standardAlternateFields(\'file\',\'url\');';
     }
     if ($cat == '') {
         $cat = get_param('cat', '');
     }
     $fields = new ocp_tempcode();
     $hidden = new ocp_tempcode();
     require_code('form_templates');
     handle_max_file_size($hidden);
     if (strpos($cat, '?') !== false) {
         $cat = str_replace('?', strval(get_member()), $cat);
     }
     $fields->attach(form_input_line(do_lang_tempcode('TITLE', do_lang_tempcode('TITLE')), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, false));
     $fields->attach(form_input_tree_list(do_lang_tempcode('GALLERY'), do_lang_tempcode('DESCRIPTION_GALLERY'), 'cat', NULL, 'choose_gallery', array('filter' => 'only_conventional_galleries', 'must_accept_videos' => true, 'addable_filter' => true), true, $cat));
     $supported = get_allowed_video_file_types();
     $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'file', false, NULL, NULL, true, $supported));
     $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'url', $url, false));
     if ($validated == 0) {
         $validated = get_param_integer('validated', 0);
         if ($validated == 1) {
             attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING'));
         }
     }
     $thumb_width = intval(get_option('thumb_width'));
     $validated_field = new ocp_tempcode();
     if (has_some_cat_specific_permission(get_member(), 'bypass_validation_' . $this->permissions_require . 'range_content', NULL, $this->permissions_cat_require)) {
         if (addon_installed('unvalidated')) {
             $validated_field = form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated == 1);
         }
     }
     $description_field = form_input_text_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION_ACCESSIBILITY'), 'comments', $comments, false);
     if ($no_thumb_needed) {
         $fields->attach($description_field);
         $fields->attach($validated_field);
         $temp = do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ADVANCED'), 'SECTION_HIDDEN' => true));
         $fields->attach($temp);
     }
     $fields->attach(form_input_upload(do_lang_tempcode('THUMBNAIL'), do_lang_tempcode('_DESCRIPTION_THUMBNAIL', integer_format($thumb_width)), 'file2', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images'))));
     $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'thumb_url', $thumb_url, false));
     if (!$no_thumb_needed) {
         $fields->attach($description_field);
     }
     $fields->attach(form_input_integer(do_lang_tempcode('VIDEO_LENGTH'), do_lang_tempcode('DESCRIPTION_VIDEO_LENGTH'), 'video_length', $video_length, false));
     $fields->attach(form_input_integer(do_lang_tempcode('WIDTH'), do_lang_tempcode('DESCRIPTION_VIDEO_WIDTH'), 'video_width', $video_width, false));
     $fields->attach(form_input_integer(do_lang_tempcode('HEIGHT'), do_lang_tempcode('DESCRIPTION_VIDEO_HEIGHT'), 'video_height', $video_height, false));
     if (!$no_thumb_needed) {
         $fields->attach($validated_field);
     }
     require_code('feedback2');
     $fields->attach(feedback_fields($allow_rating == 1, $allow_comments == 1, $allow_trackbacks == 1, false, $notes, $allow_comments == 2));
     return array($fields, $hidden);
 }