Пример #1
0
 /**
  * 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)
  */
 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[] = 'validated';
     if (is_null($main_news_category)) {
         $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, false, true);
     $cats2 = nice_get_news_categories(is_null($news_category) || count($news_category) == 0 ? array(get_param_integer('cat', NULL)) : $news_category, false, true, true, false);
     $fields = new ocp_tempcode();
     $fields2 = new ocp_tempcode();
     $hidden = 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));
     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', 'cms_news', $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));
         }
     }
     if ($cats1->is_empty()) {
         warn_exit(do_lang_tempcode('NO_CATEGORIES'));
     }
     if (addon_installed('authors')) {
         $hidden->attach(form_input_hidden('author', $author));
     }
     $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => (is_null($news_category) || count($news_category) == 0) && $image == '' && (is_null($news_category) || $news_category == array()), 'TITLE' => do_lang_tempcode('ADVANCED'))));
     $fields2->attach(form_input_text_comcode(do_lang_tempcode('BLOG_NEWS_SUMMARY'), do_lang_tempcode('DESCRIPTION_NEWS_SUMMARY'), 'news', $news, false));
     if (get_value('disable_secondary_news') !== '1') {
         $fields2->attach(form_input_list(do_lang_tempcode('MAIN_CATEGORY'), do_lang_tempcode('DESCRIPTION_MAIN_CATEGORY'), 'main_news_category', $cats1));
     } else {
         $fields2->attach(form_input_hidden('main_news_category', is_null($main_news_category) ? 'personal' : strval($main_news_category)));
     }
     if (get_value('disable_secondary_news') !== '1') {
         $fields2->attach(form_input_multi_list(do_lang_tempcode('SECONDARY_CATEGORIES'), do_lang_tempcode('DESCRIPTION_SECONDARY_CATEGORIES'), 'news_category', $cats2));
     }
     $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'))));
     //handle_max_file_size($hidden,'image'); Attachments will add this
     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));
     }
     require_code('feedback2');
     $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()));
 }
Пример #2
0
 /**
  * Get tempcode for an IOTD adding/editing form.
  *
  * @param  URLPATH			The URL to the image
  * @param  URLPATH			The URL to the thumbnail
  * @param  SHORT_TEXT		The title
  * @param  LONG_TEXT			The caption
  * @param  boolean			Whether the IOTD is/will-be currently active
  * @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 IOTD
  * @return array				A pair: the tempcode for the visible fields, and the tempcode for the hidden fields
  */
 function get_form_fields($url = '', $thumb_url = '', $title = '', $caption = '', $current = false, $allow_rating = 1, $allow_comments = 1, $allow_trackbacks = 1, $notes = '')
 {
     list($allow_rating, $allow_comments, $allow_trackbacks) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, $allow_trackbacks);
     $fields = new ocp_tempcode();
     $hidden = new ocp_tempcode();
     require_code('form_templates');
     handle_max_file_size($hidden, 'image');
     $fields->attach(form_input_line_comcode(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true));
     $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'file', 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'), 'url', $url, false));
     if (get_option('is_on_gd') == '0' || !function_exists('imagetypes')) {
         $thumb_width = get_option('thumb_width');
         $fields->attach(form_input_upload(do_lang_tempcode('THUMBNAIL'), do_lang_tempcode('DESCRIPTION_THUMBNAIL', escape_html($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));
     }
     $fields->attach(form_input_text_comcode(do_lang_tempcode('CAPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'caption', $caption, false));
     if (has_specific_permission(get_member(), 'choose_iotd')) {
         if ($caption == '') {
             $test = $GLOBALS['SITE_DB']->query_value_null_ok('iotd', 'is_current', array('is_current' => 1));
             if (is_null($test)) {
                 $current = true;
             }
         }
         $fields->attach(form_input_tick(do_lang_tempcode('IMMEDIATE_USE'), do_lang_tempcode('DESCRIPTION_IMMEDIATE_USE'), 'validated', $current));
     }
     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);
 }
Пример #3
0
 /**
  * Get tempcode for a catalogue entry adding/editing form.
  *
  * @param  ?ID_TEXT			The catalogue for the entry (NULL: detect)
  * @param  ?AUTO_LINK		The category for the entry (NULL: first)
  * @param  BINARY				Whether the entry is validated
  * @param  LONG_TEXT			Staff notes
  * @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  ?AUTO_LINK		The ID of the entry (NULL: not yet added)
  * @return array				A pair: the tempcode for the visible fields, and the tempcode for the hidden fields
  */
 function get_form_fields($catalogue_name = NULL, $category_id = NULL, $validated = 1, $notes = '', $allow_rating = NULL, $allow_comments = NULL, $allow_trackbacks = NULL, $id = NULL)
 {
     list($allow_rating, $allow_comments, $allow_trackbacks) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, $allow_trackbacks);
     if (is_null($catalogue_name)) {
         $catalogue_name = get_param('catalogue_name');
     }
     require_code('feedback');
     require_code('form_templates');
     $fields = new ocp_tempcode();
     $hidden = form_input_hidden('catalogue_name', $catalogue_name);
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'validated';
     if (is_null($id) && is_null($category_id)) {
         $category_id = get_param_integer('category_id', NULL);
         $NON_CANONICAL_PARAMS[] = 'category_id';
         $NON_CANONICAL_PARAMS[] = 'category_id_suggest';
     }
     $this->add_text = do_lang('CATALOGUE_' . $catalogue_name . '_ADD_TEXT', escape_html(get_base_url()), NULL, NULL, NULL, false);
     $this->edit_text = do_lang('CATALOGUE_' . $catalogue_name . '_EDIT_TEXT', escape_html(get_base_url()), NULL, NULL, NULL, false);
     // Standard fields
     // ===============
     // Category
     if (is_null($id) && is_null($category_id) && get_value('no_confirm_url_spec_cats') !== '1') {
         $category_id = $GLOBALS['SITE_DB']->query_value_null_ok('catalogue_categories', 'MIN(id)', array('c_name' => $catalogue_name));
     }
     if (!is_null($category_id) && (is_null($id) && get_value('no_confirm_url_spec_cats') === '1' || get_value('no_spec_cat__' . $catalogue_name) === '1')) {
         $hidden->attach(form_input_hidden('category_id', strval($category_id)));
     } else {
         if (is_null($id) && is_null($category_id)) {
             $category_id = get_param_integer('category_id_suggest', NULL);
             // Less forceful than 'category_id', as may be changed even with 'no_confirm_url_spec_cats' on
         }
         $fields->attach(form_input_tree_list(do_lang_tempcode('CATEGORY'), do_lang_tempcode('DESCRIPTION_CATEGORY_TREE'), 'category_id', NULL, 'choose_catalogue_category', array('catalogue_name' => $catalogue_name, 'addable_filter' => true), true, is_null($category_id) ? '' : strval($category_id)));
     }
     // Special fields
     // ==============
     if (!is_null($id)) {
         $special_fields = get_catalogue_entry_field_values($catalogue_name, $id);
     } else {
         $special_fields = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('*'), array('c_name' => $catalogue_name), 'ORDER BY cf_order');
     }
     $field_groups = array();
     require_code('fields');
     foreach ($special_fields as $field_num => $field) {
         $NON_CANONICAL_PARAMS[] = 'field_' . strval($field['id']);
         $ob = get_fields_hook($field['cf_type']);
         $default = get_param('field_' . strval($field['id']), $field['cf_default']);
         if (array_key_exists('effective_value_pure', $field)) {
             $default = $field['effective_value_pure'];
         } elseif (array_key_exists('effective_value', $field)) {
             $default = $field['effective_value'];
         }
         $_cf_name = get_translated_text($field['cf_name']);
         $field_cat = '';
         if (strpos($_cf_name, ': ') !== false) {
             $field_cat = substr($_cf_name, 0, strpos($_cf_name, ': '));
             if ($field_cat . ': ' == $_cf_name) {
                 $_cf_name = $field_cat;
                 // Just been pulled out as heading, nothing after ": "
             } else {
                 $_cf_name = substr($_cf_name, strpos($_cf_name, ': ') + 2);
             }
         }
         if (!array_key_exists($field_cat, $field_groups)) {
             $field_groups[$field_cat] = new ocp_tempcode();
         }
         $_cf_description = escape_html(get_translated_text($field['cf_description']));
         $GLOBALS['NO_DEBUG_MODE_FULLSTOP_CHECK'] = true;
         $result = $ob->get_field_inputter($_cf_name, $_cf_description, $field, $default, is_null($id), !array_key_exists($field_num + 1, $special_fields));
         $GLOBALS['NO_DEBUG_MODE_FULLSTOP_CHECK'] = false;
         if (is_null($result)) {
             continue;
         }
         if (is_array($result)) {
             $field_groups[$field_cat]->attach($result[0]);
             $hidden->attach($result[1]);
         } else {
             $field_groups[$field_cat]->attach($result);
         }
         if (strpos($field['cf_type'], '_trans') !== false) {
             $this->do_preview = true;
         }
         unset($result);
         unset($ob);
     }
     if (array_key_exists('', $field_groups)) {
         $field_groups_blank = $field_groups[''];
         unset($field_groups['']);
         $field_groups = array_merge(array($field_groups_blank), $field_groups);
     }
     foreach ($field_groups as $field_group_title => $extra_fields) {
         if (is_integer($field_group_title)) {
             $field_group_title = $field_group_title == 0 ? '' : strval($field_group_title);
         }
         if ($field_group_title != '') {
             $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => $field_group_title)));
         }
         $fields->attach($extra_fields);
     }
     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_b) || has_some_cat_specific_permission(get_member(), 'bypass_validation_' . $this->permissions_require . 'range_content', NULL, $this->permissions_cat_require)) {
         if (addon_installed('unvalidated')) {
             if (count($field_groups) != 1) {
                 $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('SETTINGS'))));
             }
             $fields->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated == 1));
         }
     }
     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);
 }
Пример #4
0
 /**
  * Get tempcode for a gallery adding/editing form.
  *
  * @param  ID_TEXT			The gallery codename
  * @param  SHORT_TEXT		The full human-readeable name of the gallery
  * @param  LONG_TEXT			The description of the gallery
  * @param  SHORT_TEXT		Teaser text for the gallery
  * @param  LONG_TEXT			Hidden notes associated with the gallery
  * @param  ID_TEXT			The parent gallery (blank: no parent)
  * @param  BINARY				Whether images may be put in this gallery
  * @param  BINARY				Whether videos may be put in this gallery
  * @param  BINARY				Whether the gallery serves as a container for automatically created member galleries
  * @param  ?BINARY			Whether the gallery uses the flow mode interface (NULL: pick statistically based on current usage of other galleries)
  * @param  ?URLPATH			The representative image of the gallery (NULL: none)
  * @param  ?URLPATH			Watermark (NULL: none)
  * @param  ?URLPATH			Watermark (NULL: none)
  * @param  ?URLPATH			Watermark (NULL: none)
  * @param  ?URLPATH			Watermark (NULL: none)
  * @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)
  * @return array				A pair: the tempcode for the visible fields, and the tempcode for the hidden fields
  */
 function get_form_fields($name = '', $fullname = '', $description = '', $teaser = '', $notes = '', $parent_id = '', $accept_images = 1, $accept_videos = 1, $is_member_synched = 0, $flow_mode_interface = NULL, $rep_image = NULL, $watermark_top_left = NULL, $watermark_top_right = NULL, $watermark_bottom_left = NULL, $watermark_bottom_right = NULL, $allow_rating = NULL, $allow_comments = NULL)
 {
     list($allow_rating, $allow_comments, ) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, 1);
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'cat';
     $NON_CANONICAL_PARAMS[] = 'validated';
     if (is_null($flow_mode_interface)) {
         $cnt = $GLOBALS['SITE_DB']->query_value('galleries', 'COUNT(*)');
         if ($cnt < 5000) {
             $flow_mode_interface = intval(round($GLOBALS['SITE_DB']->query_value('galleries', 'AVG(flow_mode_interface)')));
             // Determine default based on what is 'the norm' currently. Sometimes maths is beautiful :)
         } else {
             $flow_mode_interface = intval(round($GLOBALS['SITE_DB']->query_value('galleries', 'AVG(flow_mode_interface)', array('parent_id' => 'root'))));
             // Determine default based on what is 'the norm' currently. Sometimes maths is beautiful :)
         }
     }
     $fields = new ocp_tempcode();
     require_code('form_templates');
     $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'fullname', $fullname, true));
     if ($name != 'root') {
         $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_CODENAME'), 'name', $name, true));
     }
     $fields->attach(form_input_text_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', $description, false));
     if ($parent_id == '') {
         $parent_id = get_param('cat', '');
     }
     if ($name != 'root') {
         $fields->attach(form_input_tree_list(do_lang_tempcode('PARENT'), do_lang_tempcode('DESCRIPTION_PARENT'), 'parent_id', NULL, 'choose_gallery', array('filter' => 'only_conventional_galleries', 'purity' => true, 'addable_filter' => true), true, $parent_id));
     }
     $fields->attach(form_input_various_ticks(array(array(do_lang_tempcode('ACCEPT_IMAGES'), 'accept_images', $accept_images == 1, do_lang_tempcode('DESCRIPTION_ACCEPT_IMAGES')), array(do_lang_tempcode('ACCEPT_VIDEOS'), 'accept_videos', $accept_videos == 1, do_lang_tempcode('DESCRIPTION_ACCEPT_VIDEOS'))), new ocp_tempcode(), NULL, do_lang_tempcode('ACCEPTED_MEDIA_TYPES')));
     $fields->attach(form_input_tick(do_lang_tempcode('FLOW_MODE_INTERFACE'), do_lang_tempcode('DESCRIPTION_FLOW_MODE_INTERFACE'), 'flow_mode_interface', $flow_mode_interface == 1));
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $rep_image == '' && $teaser == '' && $is_member_synched == 0, 'TITLE' => do_lang_tempcode('ADVANCED'))));
     $fields->attach(form_input_upload(do_lang_tempcode('REPRESENTATIVE_IMAGE'), do_lang_tempcode('DESCRIPTION_REPRESENTATIVE_IMAGE_GALLERY'), 'rep_image', false, $rep_image, NULL, true, str_replace(' ', '', get_option('valid_images'))));
     // Only show tease option if tease block being used
     $teaser_shows = false;
     $zones = find_all_zones(false, true);
     $pages = array();
     foreach ($zones as $_zone) {
         $pages[$_zone[0]] = find_all_pages_wrap($_zone[0], true);
     }
     foreach ($pages as $zone => $under) {
         foreach ($under as $filename => $type) {
             if (substr(strtolower($filename), -4) == '.txt') {
                 $matches = array();
                 $contents = file_get_contents(zone_black_magic_filterer((substr($type, 0, 15) == 'comcode_custom/' ? get_custom_file_base() : get_file_base()) . '/' . ($zone == '' ? '' : $zone . '/') . 'pages/' . $type . '/' . $filename));
                 $fallback = get_file_base() . '/' . ($zone == '' ? '' : $zone . '/') . 'pages/comcode/' . fallback_lang() . '/' . $filename;
                 if (file_exists($fallback)) {
                     $contents .= file_get_contents($fallback);
                 }
                 if (preg_match('#\\[block[^\\]]*\\]main_gallery_tease\\[/block\\]#', $contents, $matches) != 0) {
                     $teaser_shows = true;
                 }
             }
         }
     }
     if ($teaser_shows) {
         $fields->attach(form_input_line_comcode(do_lang_tempcode('TEASER'), do_lang_tempcode('DESCRIPTION_TEASER'), 'teaser', $teaser, false));
     }
     $fields->attach(form_input_tick(do_lang_tempcode('IS_MEMBER_SYNCHED'), do_lang_tempcode('DESCRIPTION_IS_MEMBER_SYNCHED_GALLERY'), 'is_member_synched', $is_member_synched == 1));
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => is_null($watermark_top_left) && is_null($watermark_top_right) && is_null($watermark_bottom_left) && is_null($watermark_bottom_right), 'TITLE' => do_lang_tempcode('WATERMARKING'))));
     $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('TOP_LEFT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('TOP_LEFT')), 'watermark_top_left', false, $watermark_top_left, NULL, true, str_replace(' ', '', get_option('valid_images'))));
     $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('TOP_RIGHT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('TOP_RIGHT')), 'watermark_top_right', false, $watermark_top_right, NULL, true, str_replace(' ', '', get_option('valid_images'))));
     $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('BOTTOM_LEFT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('BOTTOM_LEFT')), 'watermark_bottom_left', false, $watermark_bottom_left, NULL, true, str_replace(' ', '', get_option('valid_images'))));
     $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('BOTTOM_RIGHT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('BOTTOM_RIGHT')), 'watermark_bottom_right', false, $watermark_bottom_right, NULL, true, str_replace(' ', '', get_option('valid_images'))));
     $hidden = new ocp_tempcode();
     handle_max_file_size($hidden, 'image');
     require_code('feedback2');
     $fields->attach(feedback_fields($allow_rating == 1, $allow_comments == 1, NULL, false, $notes, $allow_comments == 2, true));
     // Permissions
     $fields->attach($this->get_permission_fields($name, NULL, $name == ''));
     return array($fields, $hidden);
 }
Пример #5
0
 /**
  * Get the form fields for an event input form.
  *
  * @param  ?AUTO_LINK		The event type (NULL: default)
  * @param  ?integer			The year the event starts at (NULL: default)
  * @param  ?integer			The month the event starts at (NULL: default)
  * @param  ?integer			The day the event starts at (NULL: default)
  * @param  ?integer			The hour the event starts at (NULL: default)
  * @param  ?integer			The minute the event starts at (NULL: default)
  * @param  SHORT_TEXT		The title of the event
  * @param  LONG_TEXT			The full text describing the event
  * @param  SHORT_TEXT		The recurrence code
  * @param  ?integer			The number of recurrences (NULL: none/infinite)
  * @param  BINARY				Whether to segregate the comment-topics/rating/trackbacks per-recurrence
  * @param  BINARY				Whether it is a public event
  * @param  integer			The priority
  * @range  1 5
  * @param  ?integer			The year the event ends at (NULL: not a multi day event)
  * @param  ?integer			The month the event ends at (NULL: not a multi day event)
  * @param  ?integer			The day the event ends at (NULL: not a multi day event)
  * @param  ?integer			The hour the event ends at (NULL: not a multi day event)
  * @param  ?integer			The minute the event ends at (NULL: not a multi day event)
  * @param  ?ID_TEXT			The timezone for the event (NULL: current user's timezone)
  * @param  BINARY				Whether the time should be presented in the viewer's own timezone
  * @param  BINARY				Whether the event 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  LONG_TEXT			Notes
  * @return array				A tuple of: (fields, hidden-fields, delete-fields, edit-text, whether all delete fields are specified, posting form text, more fields)
  */
 function get_form_fields($type = NULL, $start_year = NULL, $start_month = NULL, $start_day = NULL, $start_hour = NULL, $start_minute = NULL, $title = '', $content = '', $recurrence = 'none', $recurrences = NULL, $seg_recurrences = 0, $is_public = 1, $priority = 3, $end_year = NULL, $end_month = NULL, $end_day = NULL, $end_hour = NULL, $end_minute = NULL, $timezone = NULL, $do_timezone_conv = 0, $validated = 1, $allow_rating = NULL, $allow_comments = NULL, $allow_trackbacks = NULL, $notes = '')
 {
     list($allow_rating, $allow_comments, $allow_trackbacks) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, $allow_trackbacks);
     unset($content);
     if (is_null($timezone) || $timezone == '') {
         $timezone = get_users_timezone();
     }
     require_code('form_templates');
     if (is_null($type)) {
         global $NON_CANONICAL_PARAMS;
         $NON_CANONICAL_PARAMS[] = 'date';
         $NON_CANONICAL_PARAMS[] = 'e_type';
         $NON_CANONICAL_PARAMS[] = 'validated';
         $date = get_param('date', '');
         $start_hour = NULL;
         $start_minute = NULL;
         if ($date != '') {
             $date2 = explode(' ', $date);
             $exploded = explode('-', $date2[0]);
             //if (count($exploded)!=3) warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
             $start_year = intval($exploded[0]);
             $start_month = intval($exploded[1]);
             $start_day = intval($exploded[2]);
             if (array_key_exists(1, $date2)) {
                 $exploded = explode(':', $date2[1]);
                 //if (count($exploded)!=2) warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
                 $start_hour = intval($exploded[0]);
                 $start_minute = intval($exploded[1]);
             }
         } else {
             list($start_year, $start_month, $start_day) = array(NULL, NULL, NULL);
         }
         $type = get_param_integer('e_type', -1);
         if ($type == -1) {
             $type = NULL;
         }
         $adding = true;
     } else {
         $adding = false;
     }
     if (is_null($type)) {
         $type = db_get_first_id() + 1;
     }
     if (is_null($start_month)) {
         $start_year = intval(date('Y'));
         $start_month = intval(date('m'));
         $start_day = intval(date('d'));
         $start_hour = NULL;
         $start_minute = NULL;
     }
     if ((is_null($end_year) || is_null($end_month) || is_null($end_day)) && $adding) {
         $end_year = NULL;
         //$start_year;
         $end_month = NULL;
         //$start_month;
         $end_day = NULL;
         //$start_day;
         $end_hour = NULL;
         $end_minute = NULL;
     }
     $fields = new ocp_tempcode();
     $hidden = new ocp_tempcode();
     $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true));
     //$fields->attach(form_input_text_comcode(do_lang_tempcode('EVENT_TEXT'),do_lang_tempcode('DESCRIPTION_EVENT_TEXT'),'content',$content,false));
     // Type
     $type_list = nice_get_event_types($type);
     $fields->attach(form_input_list(do_lang_tempcode('TYPE'), do_lang_tempcode('DESCRIPTION_EVENT_TYPE'), 'type', $type_list));
     // Dates
     $fields->attach(form_input_tick(do_lang_tempcode('ALL_DAY_EVENT'), do_lang_tempcode('DESCRIPTION_ALL_DAY_EVENT'), 'all_day_event', is_null($start_hour)));
     $fields->attach(form_input_date(do_lang_tempcode('DATE_TIME'), '', 'start', false, false, true, array(is_null($start_minute) ? find_timezone_start_minute_in_utc($timezone, $start_year, $start_month, $start_day) : $start_minute, is_null($start_hour) ? find_timezone_start_hour_in_utc($timezone, $start_year, $start_month, $start_day) : $start_hour, $start_month, $start_day, $start_year), 120, intval(date('Y')) - 100, NULL, NULL, true, $timezone, get_param('date', '') == ''));
     $fields->attach(form_input_date(do_lang_tempcode('END_DATE_AND_TIME'), do_lang_tempcode('DESCRIPTION_END_DATE_AND_TIME'), 'end', true, is_null($end_year), true, array(is_null($end_minute) ? find_timezone_end_minute_in_utc($timezone, $end_year, $end_month, $end_day) : $end_minute, is_null($end_hour) ? find_timezone_end_hour_in_utc($timezone, $end_year, $end_month, $end_day) : $end_hour, $end_month, $end_day, $end_year), 120, intval(date('Y')) - 100, NULL, NULL, true, $timezone));
     if ($validated == 0) {
         $validated = get_param_integer('validated', 0);
     }
     if (has_some_cat_specific_permission(get_member(), 'bypass_validation_' . $this->permissions_require . 'range_content', NULL, $this->permissions_cat_require)) {
         if (addon_installed('unvalidated')) {
             $fields->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated == 1));
         }
     }
     $fields2 = new ocp_tempcode();
     $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('ADVANCED'))));
     // More date stuff
     $list = '';
     foreach (get_timezone_list() as $_timezone => $timezone_nice) {
         $list .= static_evaluate_tempcode(form_input_list_entry($_timezone, $_timezone == $timezone, $timezone_nice));
     }
     $fields2->attach(form_input_list(do_lang_tempcode('EVENT_TIMEZONE'), do_lang_tempcode('DESCRIPTION_EVENT_TIMEZONE'), 'timezone', make_string_tempcode($list)));
     $fields2->attach(form_input_tick(do_lang_tempcode('DO_TIMEZONE_CONV'), do_lang_tempcode('DESCRIPTION_DO_TIMEZONE_CONV'), 'do_timezone_conv', $do_timezone_conv == 1));
     if (has_specific_permission(get_member(), 'add_public_events')) {
         $fields2->attach(form_input_tick(do_lang_tempcode('IS_PUBLIC'), do_lang_tempcode('DESCRIPTION_IS_PUBLIC'), 'is_public', $is_public == 1));
     }
     // Priority
     $priority_list = new ocp_tempcode();
     $priority_list->attach(form_input_list_entry('1', $priority == 1, do_lang_tempcode('PRIORITY_1')));
     $priority_list->attach(form_input_list_entry('2', $priority == 2, do_lang_tempcode('PRIORITY_2')));
     $priority_list->attach(form_input_list_entry('3', $priority == 3, do_lang_tempcode('PRIORITY_3')));
     $priority_list->attach(form_input_list_entry('4', $priority == 4, do_lang_tempcode('PRIORITY_4')));
     $priority_list->attach(form_input_list_entry('5', $priority == 5, do_lang_tempcode('PRIORITY_5')));
     $fields2->attach(form_input_list(do_lang_tempcode('PRIORITY'), '', 'priority', $priority_list));
     // Recurrence
     $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('RECURRENCE'))));
     if (strpos($recurrence, ' ') === false) {
         $recurrence_main = $recurrence;
         $recurrence_pattern = '';
     } else {
         list($recurrence_main, $recurrence_pattern) = explode(' ', $recurrence);
     }
     $radios = form_input_radio_entry('recurrence', 'none', true, do_lang_tempcode('NA_EM'));
     $radios->attach(form_input_radio_entry('recurrence', 'daily', $recurrence_main == 'daily', do_lang_tempcode('DAILY')));
     $radios->attach(form_input_radio_entry('recurrence', 'weekly', $recurrence_main == 'weekly', do_lang_tempcode('WEEKLY')));
     $radios->attach(form_input_radio_entry('recurrence', 'monthly', $recurrence_main == 'monthly', do_lang_tempcode('MONTHLY')));
     $radios->attach(form_input_radio_entry('recurrence', 'yearly', $recurrence_main == 'yearly', do_lang_tempcode('YEARLY')));
     $fields2->attach(form_input_radio(do_lang_tempcode('RECURRENCE'), do_lang_tempcode('DESCRIPTION_RECURRENCE'), 'recurrence', $radios));
     // xth_dotw_of_monthly
     $fields2->attach(form_input_line(do_lang_tempcode('RECURRENCE_PATTERN'), do_lang_tempcode('DESCRIPTION_RECURRENCE_PATTERN'), 'recurrence_pattern', $recurrence_pattern, false));
     $fields2->attach(form_input_integer(do_lang_tempcode('RECURRENCES'), do_lang_tempcode('DESCRIPTION_RECURRENCES'), 'recurrences', $recurrences, false));
     $fields2->attach(form_input_tick(do_lang_tempcode('SEG_RECURRENCES'), do_lang_tempcode('DESCRIPTION_SEG_RECURRENCES'), 'seg_recurrences', $seg_recurrences == 1));
     if ($adding && cron_installed()) {
         $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('REMINDERS'))));
         $fields2->attach(form_input_tick(do_lang_tempcode('SIGN_UP_REMINDER'), do_lang_tempcode('DESCRIPTION_SIGN_UP_REMINDER'), 'sign_up_reminder', true));
         if (has_specific_permission(get_member(), 'add_public_events')) {
             $usergroup_list = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true);
             if (get_forum_type() == 'ocf') {
                 unset($usergroup_list[db_get_first_id()]);
             }
             $t_usergroup_list = new ocp_tempcode();
             foreach ($usergroup_list as $id => $name) {
                 $t_usergroup_list->attach(form_input_list_entry(strval($id), false, $name));
             }
             $fields2->attach(form_input_all_and_not(do_lang_tempcode('SIGN_UP_REMINDER_GROUPS'), do_lang_tempcode('DESCRIPTION_SIGN_UP_REMINDER_GROUPS'), 'sign_up_reminder_groups', $t_usergroup_list));
         }
         $fields2->attach(form_input_float(do_lang_tempcode('REMINDER_TIME'), do_lang_tempcode('DESCRIPTION_REMINDER_TIME'), 'hours_before', 1.0, true));
     }
     require_code('feedback2');
     $fields2->attach(feedback_fields($allow_rating == 1, $allow_comments == 1, $allow_trackbacks == 1, false, $notes, $allow_comments == 2));
     $fields2->attach(get_syndication_option_fields());
     return array($fields, $hidden, NULL, NULL, true, NULL, $fields2);
 }
Пример #6
0
 /**
  * Get tempcode for a poll adding/editing form.
  *
  * @param  SHORT_TEXT		The question
  * @param  SHORT_TEXT		The first answer
  * @param  SHORT_TEXT		The second answer
  * @param  SHORT_TEXT		The third answer
  * @param  SHORT_TEXT		The fourth answer
  * @param  SHORT_TEXT		The fifth answer
  * @param  SHORT_TEXT		The sixth answer
  * @param  SHORT_TEXT		The seventh answer
  * @param  SHORT_TEXT		The eigth answer
  * @param  SHORT_TEXT		The ninth answer
  * @param  SHORT_TEXT		The tenth answer
  * @param  boolean			Whether the poll is/will-be currently active
  * @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 poll
  * @return tempcode			The tempcode for the visible fields
  */
 function get_form_fields($question = '', $a1 = '', $a2 = '', $a3 = '', $a4 = '', $a5 = '', $a6 = '', $a7 = '', $a8 = '', $a9 = '', $a10 = '', $current = false, $allow_rating = 1, $allow_comments = 1, $allow_trackbacks = 1, $notes = '')
 {
     list($allow_rating, $allow_comments, $allow_trackbacks) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, $allow_trackbacks);
     $fields = new ocp_tempcode();
     require_code('form_templates');
     $fields->attach(form_input_line_comcode(do_lang_tempcode('QUESTION'), do_lang_tempcode('DESCRIPTION_QUESTION'), 'question', $question, true));
     $fields->attach(form_input_line_comcode(do_lang_tempcode('ANSWER_X', integer_format(1)), do_lang_tempcode('DESCRIPTION_ANSWER'), 'option1', $a1, true));
     $fields->attach(form_input_line_comcode(do_lang_tempcode('ANSWER_X', integer_format(2)), do_lang_tempcode('DESCRIPTION_ANSWER'), 'option2', $a2, true));
     $fields->attach(form_input_line_comcode(do_lang_tempcode('ANSWER_X', integer_format(3)), do_lang_tempcode('DESCRIPTION_ANSWER'), 'option3', $a3, false));
     $fields->attach(form_input_line_comcode(do_lang_tempcode('ANSWER_X', integer_format(4)), do_lang_tempcode('DESCRIPTION_ANSWER'), 'option4', $a4, false));
     $fields->attach(form_input_line_comcode(do_lang_tempcode('ANSWER_X', integer_format(5)), do_lang_tempcode('DESCRIPTION_ANSWER'), 'option5', $a5, false));
     $fields->attach(form_input_line_comcode(do_lang_tempcode('ANSWER_X', integer_format(6)), do_lang_tempcode('DESCRIPTION_ANSWER'), 'option6', $a6, false));
     $fields->attach(form_input_line_comcode(do_lang_tempcode('ANSWER_X', integer_format(7)), do_lang_tempcode('DESCRIPTION_ANSWER'), 'option7', $a7, false));
     $fields->attach(form_input_line_comcode(do_lang_tempcode('ANSWER_X', integer_format(8)), do_lang_tempcode('DESCRIPTION_ANSWER'), 'option8', $a8, false));
     $fields->attach(form_input_line_comcode(do_lang_tempcode('ANSWER_X', integer_format(9)), do_lang_tempcode('DESCRIPTION_ANSWER'), 'option9', $a9, false));
     $fields->attach(form_input_line_comcode(do_lang_tempcode('ANSWER_X', integer_format(10)), do_lang_tempcode('DESCRIPTION_ANSWER'), 'option10', $a10, false));
     if (has_specific_permission(get_member(), 'choose_poll')) {
         if ($question == '') {
             $test = $GLOBALS['SITE_DB']->query_value_null_ok('poll', 'is_current', array('is_current' => 1));
             if (is_null($test)) {
                 $current = true;
             }
         }
         $fields->attach(form_input_tick(do_lang_tempcode('IMMEDIATE_USE'), do_lang_tempcode('DESCRIPTION_IMMEDIATE_USE'), 'validated', $current));
     }
     require_code('feedback2');
     $fields->attach(feedback_fields($allow_rating == 1, $allow_comments == 1, $allow_trackbacks == 1, false, $notes, $allow_comments == 2));
     return $fields;
 }