/** * Get tempcode for a news adding/editing form. * * @param ?AUTO_LINK The primary category for the news (NULL: personal) * @param ?array A list of categories the news is in (NULL: not known) * @param SHORT_TEXT The news title * @param LONG_TEXT The news summary * @param SHORT_TEXT The name of the author * @param BINARY Whether the news is validated * @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 BINARY Whether to show the "send trackback" field * @param LONG_TEXT Notes for the video * @param URLPATH URL to the image for the news entry (blank: use cat image) * @param ?array Scheduled go-live time (NULL: N/A) * @return array A tuple of lots of info (fields, hidden fields, trailing fields, tabindex for posting form) */ function get_form_fields($main_news_category = NULL, $news_category = NULL, $title = '', $news = '', $author = '', $validated = 1, $allow_rating = NULL, $allow_comments = NULL, $allow_trackbacks = NULL, $send_trackbacks = 1, $notes = '', $image = '', $scheduled = 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[] = 'title'; $NON_CANONICAL_PARAMS[] = 'author'; $NON_CANONICAL_PARAMS[] = 'notes'; $NON_CANONICAL_PARAMS[] = 'validated'; if ($title == '') { $main_news_category = get_param_integer('cat', $main_news_category); $title = get_param('title', $title); $author = get_param('author', $author); $notes = get_param('notes', $notes); } require_lang('menus'); $GLOBALS['HELPER_PANEL_TEXT'] = comcode_lang_string('DOC_WRITING'); $GLOBALS['HELPER_PANEL_PIC'] = ''; if (is_null($main_news_category)) { global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'cat'; $param_cat = get_param('cat', ''); if ($param_cat == '') { $news_category = array(); $main_news_category = NULL; } elseif (strpos($param_cat, ',') === false) { $news_category = array(); $main_news_category = intval($param_cat); } else { require_code('ocfiltering'); $news_category = ocfilter_to_idlist_using_db($param_cat, 'id', 'news_categories', 'news_categories', NULL, 'id', 'id'); $main_news_category = NULL; } $author = $GLOBALS['FORUM_DRIVER']->get_username(get_member()); } $cats1 = nice_get_news_categories($main_news_category, false, true, is_integer($main_news_category), NULL, true); $cats2 = nice_get_news_categories(is_null($news_category) ? array() : $news_category, false, true, is_integer($main_news_category), NULL, true); $fields = new ocp_tempcode(); $fields2 = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_line_comcode(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true)); $fields->attach(form_input_list(do_lang_tempcode('MAIN_CATEGORY'), do_lang_tempcode('DESCRIPTION_MAIN_CATEGORY'), 'main_news_category', $cats1)); if (addon_installed('authors')) { $fields->attach(form_input_author(do_lang_tempcode('SOURCE'), do_lang_tempcode('DESCRIPTION_SOURCE'), 'author', $author, true)); } require_code('feedback2'); $posting_form_tabindex = get_form_field_tabindex(NULL); if ($validated == 0) { $validated = get_param_integer('validated', 0); if ($validated == 1) { attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING')); } } if (has_some_cat_specific_permission(get_member(), 'bypass_validation_' . $this->permissions_require . 'range_content', NULL, $this->permissions_cat_require)) { if (addon_installed('unvalidated')) { $fields2->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated == 1)); } } $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $news == '' && $image == '' && is_null($scheduled) && (is_null($news_category) || $news_category == array()), 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields2->attach(form_input_text_comcode(do_lang_tempcode('NEWS_SUMMARY'), do_lang_tempcode('DESCRIPTION_NEWS_SUMMARY'), 'news', $news, false)); $fields2->attach(form_input_multi_list(do_lang_tempcode('SECONDARY_CATEGORIES'), do_lang_tempcode('DESCRIPTION_SECONDARY_CATEGORIES'), 'news_category', $cats2)); $hidden = new ocp_tempcode(); //handle_max_file_size($hidden,'image'); Attachments will add this $fields2->attach(form_input_upload(do_lang_tempcode('IMAGE'), do_lang_tempcode('DESCRIPTION_NEWS_IMAGE_OVERRIDE'), 'file', false, $image, NULL, true, str_replace(' ', '', get_option('valid_images')))); if (addon_installed('calendar') && has_specific_permission(get_member(), 'scheduled_publication_times')) { $fields2->attach(form_input_date__scheduler(do_lang_tempcode('PUBLICATION_TIME'), do_lang_tempcode('DESCRIPTION_PUBLICATION_TIME'), 'schedule', true, true, true, $scheduled, intval(date('Y')) - 1970 + 2, 1970)); } $fields2->attach(feedback_fields($allow_rating == 1, $allow_comments == 1, $allow_trackbacks == 1, $send_trackbacks == 1, $notes, $allow_comments == 2)); $fields2->attach(get_syndication_option_fields()); return array($fields, $hidden, NULL, NULL, NULL, NULL, make_string_tempcode($fields2->evaluate()), $posting_form_tabindex); }
/** * 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 ?tempcode The Tempcode for the input field (NULL: skip the field - it's not input) */ function get_field_inputter($_cf_name, $_cf_description, $field, $actual_value, $new) { if (is_null($actual_value)) { $actual_value = ''; } // Plug anomaly due to unusual corruption return form_input_author($_cf_name, $_cf_description, 'field_' . strval($field['id']), $actual_value, $field['cf_required'] == 1); }