/** * Get the tempcode for a bank of tick boxes. * * @param array A list of tuples: (prettyname, name, value, description, [disabled]) * @param mixed A description for this input field * @param ?integer The tab index of the field (NULL: not specified) * @param mixed A human intelligible name for this input field (blank: use default) * @param boolean Whether to place each tick on a new line * @return tempcode The input field */ function form_input_various_ticks($options, $description, $_tabindex = NULL, $_pretty_name = '', $simple_style = false) { if (count($options) == 0) { return new ocp_tempcode(); } $options = array_values($options); if (is_null($_tabindex)) { $tabindex = get_form_field_tabindex(NULL); } else { $_tabindex++; $tabindex = $_tabindex; } if (is_string($_pretty_name) && $_pretty_name == '') { $_pretty_name = do_lang_tempcode('OPTIONS'); } $input = new ocp_tempcode(); if (count($options[0]) != 3) { $options = array(array($options, NULL, new ocp_tempcode())); } foreach ($options as $_option) { $out = array(); foreach ($_option[0] as $option) { // $disabled has been added to the API, so we must emulate the // previous behaviour if it isn't supplied (ie. $disabled='0') if (count($option) == 4) { list($pretty_name, $name, $value, $_description) = $option; $disabled = '0'; } elseif (count($option) == 5) { list($pretty_name, $name, $value, $_description, $_disabled) = $option; $disabled = $_disabled ? '1' : '0'; } $value = filter_form_field_default($name, $value ? '1' : '0') == '1'; $out[] = array('CHECKED' => $value, 'TABINDEX' => strval($tabindex), 'NAME' => $name, 'PRETTY_NAME' => $pretty_name, 'DESCRIPTION' => $_description, 'DISABLED' => $disabled); } $input->attach(do_template('FORM_SCREEN_INPUT_VARIOUS_TICKS', array('_GUID' => 'a6212f61304a101fb2754e334a8b4212', 'SECTION_TITLE' => $_option[2], 'EXPANDED' => $_option[1], 'SIMPLE_STYLE' => $simple_style, 'BRETHREN_COUNT' => strval(count($out)), 'OUT' => $out))); } return _form_input('', $_pretty_name, $description, $input, false, false, $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 * @param boolean Whether this is the last field in the catalogue * @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, $last = true) { if (is_null($actual_value)) { $actual_value = ''; } // Plug anomaly due to unusual corruption require_lang('javascript'); require_javascript('javascript_posting'); require_javascript('javascript_editing'); require_javascript('javascript_ajax'); require_javascript('javascript_swfupload'); require_css('swfupload'); require_lang('comcode'); $tabindex = get_form_field_tabindex(); $actual_value = filter_form_field_default($_cf_name, $actual_value); list($attachments, $attach_size_field) = get_attachments('field_' . strval($field['id'])); $hidden_fields = new ocp_tempcode(); $hidden_fields->attach($attach_size_field); $comcode_help = build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false)); $emoticon_chooser = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser('field_' . strval($field['id'])); $comcode_editor = get_comcode_editor('field_' . strval($field['id'])); $comcode_editor_small = get_comcode_editor('field_' . strval($field['id']), true); $w = has_js() && (browser_matches('wysiwyg') && strpos($actual_value, '{$,page hint: no_wysiwyg}') === false); $class = ''; global $JAVASCRIPT, $WYSIWYG_ATTACHED; if (!$WYSIWYG_ATTACHED) { $JAVASCRIPT->attach(do_template('HTML_EDIT')); } $WYSIWYG_ATTACHED = true; @header('Content-type: text/html; charset=' . get_charset()); if ($w) { $class .= ' wysiwyg'; } global $LAX_COMCODE; $temp = $LAX_COMCODE; $LAX_COMCODE = true; $GLOBALS['COMCODE_PARSE_URLS_CHECKED'] = 100; // Little hack to stop it checking any URLs /*if (is_null($default_parsed)) */ $default_parsed = comcode_to_tempcode($actual_value, NULL, false, 60, NULL, NULL, true); $LAX_COMCODE = $temp; $attachments_done = true; $ret = do_template('POSTING_FIELD', array('REQUIRED' => $field['cf_required'] == 1, 'DESCRIPTION' => $_cf_description, 'HIDDEN_FIELDS' => $hidden_fields, 'PRETTY_NAME' => $_cf_name, 'NAME' => 'field_' . strval($field['id']), 'TABINDEX_PF' => strval($tabindex), 'COMCODE_EDITOR' => $comcode_editor, 'COMCODE_EDITOR_SMALL' => $comcode_editor_small, 'CLASS' => $class, 'COMCODE_URL' => build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false)), 'EMOTICON_CHOOSER' => $emoticon_chooser, 'COMCODE_HELP' => $comcode_help, 'POST' => $actual_value, 'DEFAULT_PARSED' => $default_parsed, 'ATTACHMENTS' => $attachments)); if (!$last) { $ret->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ADDITIONAL_INFO')))); } return $ret; }
/** * The UI to import news * * @return tempcode The UI */ function import_wordpress() { check_specific_permission('mass_import', NULL, NULL, 'cms_news'); $lang = post_param('lang', user_lang()); $title = get_page_title('IMPORT_WP_DB'); $submit_name = do_lang_tempcode('IMPORT_WP_DB'); require_code('form_templates'); //------------------------------------------------ // Build up form $fields_xml = new ocp_tempcode(); $fields_xml->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_WP_XML'), 'file_novalidate', false, NULL, NULL, true, 'xml')); $fields_xml->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'xml_url', '', false)); $hidden = form_input_hidden('lang', $lang); $javascript = 'standardAlternateFields(\'file_novalidate\',\'xml_url\');'; $xml_post_url = build_url(array('page' => '_SELF', 'type' => '_import_wordpress', 'method' => 'xml'), '_SELF'); $xml_upload_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'TEXT' => '', 'HIDDEN' => $hidden, 'FIELDS' => $fields_xml, 'SUBMIT_NAME' => $submit_name, 'URL' => $xml_post_url, 'JAVASCRIPT' => $javascript)); //-------------------------------------------- $fields = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('WORDPRESS_HOST_NAME'), do_lang_tempcode('DESCRIPTION_WORDPRESS_HOST_NAME'), 'wp_host', 'localhost', false)); $fields->attach(form_input_line(do_lang_tempcode('WORDPRESS_DB_NAME'), do_lang_tempcode('DESCRIPTION_WORDPRESS_DB_NAME'), 'wp_db', 'wordpress', false)); $fields->attach(form_input_line(do_lang_tempcode('WORDPRESS_TABLE_PREFIX'), do_lang_tempcode('DESCRIPTION_WORDPRESS_TABLE_PREFIX'), 'wp_table_prefix', 'wp', false)); $fields->attach(form_input_line(do_lang_tempcode('WORDPRESS_DB_USERNAME'), do_lang_tempcode('DESCRIPTION_WORDPRESS_DB_USERNAME'), 'wp_db_user', 'root', false)); $fields->attach(form_input_password(do_lang_tempcode('WORDPRESS_DB_PASSWORD'), do_lang_tempcode('DESCRIPTION_WORDPRESS_DB_PASSWORD'), 'wp_db_password', false)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => false, 'TITLE' => do_lang_tempcode('ADVANCED_OPTIONS')))); $fields->attach(form_input_tick(do_lang_tempcode('IMPORT_WORDPRESS_USERS'), do_lang_tempcode('DESCRIPTION_IMPORT_WORDPRESS_USER'), 'wp_import_wordpress_users', true)); $fields->attach(form_input_tick(do_lang_tempcode('IMPORT_BLOG_COMMENTS'), do_lang_tempcode('DESCRIPTION_IMPORT_BLOG_COMMENTS'), 'wp_import_blog_comments', true)); $fields->attach(form_input_tick(do_lang_tempcode('AUTO_VALIDATE_ALL_POSTS'), do_lang_tempcode('DESCRIPTION_VALIDATE_ALL_POSTS'), 'wp_auto_validate', true)); $fields->attach(form_input_tick(do_lang_tempcode('ADD_TO_OWN_ACCOUNT'), do_lang_tempcode('DESCRIPTION_ADD_TO_OWN_ACCOUNT'), 'wp_add_to_own', false)); $hidden = new ocp_tempcode(); $hidden->attach(form_input_hidden('lang', $lang)); handle_max_file_size($hidden); $javascript = ''; $db_post_url = build_url(array('page' => '_SELF', 'type' => '_import_wordpress', 'method' => 'db'), '_SELF'); $db_import_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'TEXT' => '', 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $db_post_url, 'JAVASCRIPT' => $javascript)); return do_template('NEWS_WORDPRESS_IMPORT_SCREEN', array('TITLE' => get_page_title('DB_IMPORT_FORM'), 'XML_UPLOAD_FORM' => $xml_upload_form, 'DB_IMPORT_FORM' => $db_import_form)); }
/** * The UI to choose a ticket type to edit, or to add a ticket. * * @return tempcode The UI */ function ticket_type_interface() { $title = get_page_title('MANAGE_TICKET_TYPES'); require_lang('permissions'); $list = new ocp_tempcode(); require_code('form_templates'); $ticket_types = collapse_1d_complexity('ticket_type', $GLOBALS['SITE_DB']->query_select('ticket_types', array('*'), NULL, 'ORDER BY ticket_type')); foreach ($ticket_types as $ticket_type) { $list->attach(form_input_list_entry(strval($ticket_type), false, get_translated_text($ticket_type))); } if (!$list->is_empty()) { $edit_url = build_url(array('page' => '_SELF', 'type' => 'edit'), '_SELF', NULL, false, true); $submit_name = do_lang_tempcode('CHOOSE'); $fields = form_input_list(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TICKET_TYPE'), 'ticket_type', $list); $tpl = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'GET' => true, 'HIDDEN' => '', 'TEXT' => '', 'FIELDS' => $fields, 'URL' => $edit_url, 'SUBMIT_NAME' => $submit_name)); } else { $tpl = new ocp_tempcode(); } // Do a form so people can add $post_url = build_url(array('page' => '_SELF', 'type' => 'add'), '_SELF'); $submit_name = do_lang_tempcode('ADD_TICKET_TYPE'); $fields = form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TICKET_TYPE'), 'ticket_type_2', '', false); $fields->attach(form_input_tick(do_lang_tempcode('TICKET_GUEST_EMAILS_MANDATORY'), do_lang_tempcode('DESCRIPTION_TICKET_GUEST_EMAILS_MANDATORY'), 'guest_emails_mandatory', false)); $fields->attach(form_input_tick(do_lang_tempcode('TICKET_SEARCH_FAQ'), do_lang_tempcode('DESCRIPTION_TICKET_SEARCH_FAQ'), 'search_faq', false)); // Permissions $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups(); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true); foreach ($groups as $id => $group_name) { if (in_array($id, $admin_groups)) { continue; } $fields->attach(form_input_tick(do_lang_tempcode('ACCESS_FOR', escape_html($group_name)), do_lang_tempcode('DESCRIPTION_ACCESS_FOR', escape_html($group_name)), 'access_' . strval($id), true)); } $add_form = do_template('FORM', array('_GUID' => '382f6fab6c563d81303ecb26495e76ec', 'TABINDEX' => strval(get_form_field_tabindex()), 'SECONDARY_FORM' => true, 'HIDDEN' => '', 'TEXT' => '', 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url)); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_TICKET_TYPES')))); return do_template('SUPPORT_TICKET_TYPE_SCREEN', array('_GUID' => '28645dc4a86086fa865ec7e166b84bb6', 'TITLE' => $title, 'TPL' => $tpl, 'ADD_FORM' => $add_form)); }
/** * The UI to set point-store prices. * * @return tempcode The UI */ function interface_set_prices() { $also_url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF'); attach_message(do_lang_tempcode('ALSO_SEE_USAGE', escape_html($also_url->evaluate())), 'inform'); $title = get_page_title('POINTSTORE_MANAGE_INVENTORY'); $field_groups = new ocp_tempcode(); $add_forms = new ocp_tempcode(); // Load up configuration from hooks $_hooks = find_all_hooks('modules', 'pointstore'); foreach (array_keys($_hooks) as $hook) { require_code('hooks/modules/pointstore/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_pointstore_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } if (method_exists($object, 'config')) { $fg = $object->config(); if (!is_null($fg)) { foreach ($fg[0] as $__fg) { $_fg = do_template('FORM_GROUP', array('_GUID' => '58a0948313f0e8e69c06ee01fb7ee48a', 'FIELDS' => $__fg[0], 'HIDDEN' => $__fg[1])); $field_groups->attach(do_template('POINTSTORE_PRICES_FORM_WRAP', array('_GUID' => '938143162b418de982cdb6ce8d8a92ee', 'TITLE' => $__fg[2], 'FORM' => $_fg))); } if (!$fg[2]->is_empty()) { $submit_name = do_lang_tempcode('ADD'); $post_url = build_url(array('page' => '_SELF', 'type' => '_p'), '_SELF'); $fg[2] = do_template('FORM', array('SECONDARY_FORM' => true, 'TABINDEX' => strval(get_form_field_tabindex(NULL)), 'HIDDEN' => '', 'TEXT' => '', 'FIELDS' => $fg[2], 'SUBMIT_BUTTON_CLASS' => 'proceed_button_left', 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url)); $add_forms->attach(do_template('POINTSTORE_PRICES_FORM_WRAP', array('_GUID' => '3956550ebff14bbb923b57c8341b0862', 'TITLE' => $fg[1], 'FORM' => $fg[2]))); } } } } $submit_name = do_lang_tempcode('SAVE_ALL'); $post_url = build_url(array('page' => '_SELF', 'type' => '_p'), '_SELF'); $edit_form = $field_groups->is_empty() ? new ocp_tempcode() : do_template('FORM_GROUPED', array('_GUID' => 'bf025026dcfc86cfd0a8ef3728bbf6d8', 'TEXT' => '', 'FIELD_GROUPS' => $field_groups, 'SUBMIT_NAME' => $submit_name, 'SUBMIT_BUTTON_CLASS' => 'proceed_button_left_2', 'URL' => $post_url)); list($warning_details, $ping_url) = handle_conflict_resolution(); return do_template('POINTSTORE_PRICE_SCREEN', array('_GUID' => '278c8244c7f1743370198dfc437b7bbf', 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TITLE' => $title, 'EDIT_FORM' => $edit_form, 'ADD_FORMS' => $add_forms)); }
/** * The UI to edit an author (effectively deleting and re-adding them). * * @return tempcode The UI */ function ed() { $title = get_page_title('EDIT_MERGE_AUTHORS'); $authors = $this->nice_get_authors(); if ($authors->is_empty()) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } require_code('form_templates'); $fields = form_input_list(do_lang_tempcode('NAME'), '', 'author', $authors, NULL, true); $post_url = build_url(array('page' => '_SELF', 'type' => '_ad'), '_SELF'); $submit_name = do_lang_tempcode('PROCEED'); $define_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'HIDDEN' => '', 'TEXT' => '', 'FIELDS' => $fields, 'GET' => true, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name)); if (has_specific_permission(get_member(), 'delete_midrange_content')) { $fields = form_input_list(do_lang_tempcode('NAME'), '', 'mauthor', $authors); $fields->attach(form_input_list(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'mauthor2', $authors)); $post_url = build_url(array('page' => '_SELF', 'type' => '_mg'), '_SELF'); $submit_name = do_lang_tempcode('MERGE_AUTHORS'); $merge_form = do_template('FORM', array('_GUID' => 'd0dd075a54b72cfe47d3c2d9fe987c89', 'TABINDEX' => strval(get_form_field_tabindex()), 'SECONDARY_FORM' => true, 'HIDDEN' => '', 'TEXT' => '', 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name)); } else { $merge_form = new ocp_tempcode(); } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('AUTHOR_MANAGE')))); return do_template('AUTHOR_MANAGE_SCREEN', array('_GUID' => '84f8de5d53090d138cb653bb861f2f70', 'TITLE' => $title, 'MERGE_FORM' => $merge_form, 'DEFINE_FORM' => $define_form)); }
/** * The UI to import into a gallery. * * @return tempcode The UI */ function _gimp() { $cat = get_param('name', 'root'); check_specific_permission('mass_import'); if (substr($cat, 0, 7) != 'member_') { $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'name', array('name' => $cat)); if (is_null($test)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } } $title = get_page_title('GALLERY_IMPORT'); require_code('form_templates'); require_lang('trackbacks'); // To choose to batch import from an attached tar or zip file (zip file only supported if zip module running on php install) $post_url = build_url(array('page' => '_SELF', 'type' => '__gimp', 'cat' => $cat, 'uploading' => 1, 'redirect' => get_param('redirect', NULL)), '_SELF'); $fields = new ocp_tempcode(); $supported = 'tar'; if (function_exists('zip_open') || get_option('unzip_cmd') != '') { $supported .= ', zip'; } $fields->attach(form_input_upload_multi(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_ARCHIVE_MEDIA', escape_html($supported), escape_html(str_replace(',', ', ', get_option('valid_images') . ',' . get_allowed_video_file_types()))), 'file', true, NULL, NULL, true, str_replace(' ', '', get_option('valid_images') . ',' . $supported))); $hidden = new ocp_tempcode(); handle_max_file_size($hidden); if (get_option('is_on_gd') == '1') { if ($this->has_at_least_one_watermark($cat)) { $fields->attach(form_input_tick(do_lang_tempcode('WATERMARK'), do_lang_tempcode('DESCRIPTION_WATERMARK'), 'watermark', true)); } } // Feedback require_code('feedback2'); $fields->attach(feedback_fields(true, true, true, false, '')); // Max upload limit require_code('files2'); $max = floatval(get_max_file_size()) / floatval(1024 * 1024); if ($max < 30.0) { $config_url = get_upload_limit_config_url(); $text = paragraph(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max)), escape_html(is_null($config_url) ? '' : $config_url))); } else { $text = new ocp_tempcode(); } // Show form $hidden->attach(form_input_hidden('test', '1')); $form = do_template('FORM', array('_GUID' => '05de2bc134ed0b1ab703ac8bfbfabce4', 'TABINDEX' => strval(get_form_field_tabindex()), 'FIELDS' => $fields, 'SUBMIT_NAME' => do_lang_tempcode('BATCH_IMPORT_ARCHIVE_CONTENTS'), 'URL' => $post_url, 'TEXT' => $text, 'HIDDEN' => $hidden)); // Orphaned upload form // To choose to batch import what already exists in gallery directory, but is orphaned $orphaned_content = new ocp_tempcode(); if ($GLOBALS['FORUM_DRIVER']->is_staff(get_member()) && $GLOBALS['SITE_DB']->query_value('images', 'COUNT(*)') + $GLOBALS['SITE_DB']->query_value('videos', 'COUNT(*)') < 4000) { require_code('images'); $there = array(); $_dir = opendir(get_custom_file_base() . '/uploads/galleries/'); while (false !== ($file = readdir($_dir))) { if ($file != 'index.html' && !is_dir(get_custom_file_base() . '/uploads/galleries/' . $file) && (is_image($file) || is_video($file))) { $there[$file] = filemtime(get_custom_file_base() . '/uploads/galleries/' . $file); } } closedir($_dir); $_dir = @opendir(get_custom_file_base() . '/uploads/galleries/' . filter_naughty($cat)); if ($_dir !== false) { while (false !== ($file = readdir($_dir))) { if ($file != 'index.html' && !is_dir(get_custom_file_base() . '/uploads/galleries/' . $cat . '/' . $file) && (is_image($file) || is_video($file))) { $there[$cat . '/' . $file] = filemtime(get_custom_file_base() . '/uploads/galleries/' . $cat . '/' . $file); } } closedir($_dir); } if (count($there) != 0) { asort($there); $test1 = collapse_1d_complexity('url', $GLOBALS['SITE_DB']->query_select('images', array('url'))); $test2 = collapse_1d_complexity('url', $GLOBALS['SITE_DB']->query_select('videos', array('url'))); arsort($there); $temp_keys = array_keys($there); $last_time = $there[$temp_keys[0]]; foreach ($there as $file => $time) { if (!in_array('uploads/galleries/' . str_replace('%2F', '/', rawurlencode($file)), $test1) && !in_array('uploads/galleries/' . str_replace('%2F', '/', rawurlencode($file)), $test2)) { $orphaned_content->attach(form_input_list_entry($file, $time >= $last_time - 60 * 60 * 3 || strpos($file, '/') !== false, $file)); } } } $add_url = build_url(array('page' => '_SELF', 'type' => 'ss'), '_SELF'); if (!$orphaned_content->is_empty()) { $fields_2 = new ocp_tempcode(); $hidden_2 = new ocp_tempcode(); if (get_param_integer('keep_de_orphan', 0) == 1) { $cats = nice_get_gallery_tree($cat, NULL, false, false, false, false, NULL, true); $fields_2->attach(form_input_list(do_lang_tempcode('GALLERY'), '', 'cat', $cats)); } else { $hidden_2->attach(form_input_hidden('cat', $cat)); } $fields_2->attach(form_input_multi_list(do_lang_tempcode('ENTRIES'), '', 'files', $orphaned_content)); if ($this->has_at_least_one_watermark($cat)) { $fields_2->attach(form_input_various_ticks(array(array(do_lang_tempcode('WATERMARK'), 'watermark', true, ''), array(do_lang_tempcode('ALLOW_RATING'), 'allow_rating', true, ''), array(do_lang_tempcode('ALLOW_COMMENTS'), 'allow_comments', true, ''), array(do_lang_tempcode('ALLOW_REVIEWS'), 'allow_reviews', false, ''), array(do_lang_tempcode('ALLOW_TRACKBACKS'), 'allow_trackbacks', true, '')), '', NULL, do_lang_tempcode('OPTIONS'))); } $radios = new ocp_tempcode(); $radios->attach(form_input_radio_entry('type', 'sa', true, do_lang_tempcode('ADD_GALLERY_SELECTION'))); $radios->attach(form_input_radio_entry('type', 'sd', false, do_lang_tempcode('DELETE_GALLERY_SELECTION'))); $fields_2->attach(form_input_radio(do_lang_tempcode('ACTION'), '', 'type', $radios, true)); // Feedback require_code('feedback2'); $fields_2->attach(feedback_fields(true, true, true, false, '')); $form2 = do_template('FORM', array('SECONDARY_FORM' => true, 'TABINDEX' => strval(get_form_field_tabindex()), 'FIELDS' => $fields_2, 'SUBMIT_NAME' => do_lang_tempcode('PROCEED'), 'URL' => $add_url, 'TEXT' => '', 'HIDDEN' => $hidden_2)); } else { $form2 = new ocp_tempcode(); } } else { $form2 = new ocp_tempcode(); } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_GALLERIES')), array('_SELF:_SELF:gimp', do_lang_tempcode('GALLERY')))); breadcrumb_set_self(do_lang_tempcode('UPLOAD')); return do_template('GALLERY_IMPORT_SCREEN', array('_GUID' => '607c819ff751268294e5e590a0d41533', 'TITLE' => $title, 'FORM2' => $form2, 'FORM' => $form)); }
/** * The main user interface for the file dump. * * @return tempcode The UI. */ function module_do_gui() { $title = get_page_title('FILE_DUMP'); $place = filter_naughty(get_param('place', '/')); if (substr($place, -1, 1) != '/') { $place .= '/'; } $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=filedump&filter=' . $place; // Show tree $dirs = explode('/', substr($place, 0, strlen($place) - 1)); $i = 0; $pre = ''; $file_tree = new ocp_tempcode(); while (array_key_exists($i, $dirs)) { if ($i > 0) { $d = $dirs[$i]; } else { $d = do_lang('FILE_DUMP'); } if (array_key_exists($i + 1, $dirs)) { $tree_url = build_url(array('page' => '_SELF', 'place' => $pre . $dirs[$i] . '/'), '_SELF'); if (!$file_tree->is_empty()) { $file_tree->attach(do_template('BREADCRUMB', array('_GUID' => '7ee62e230d53344a7d9667dc59be21c6'))); } $file_tree->attach(hyperlink($tree_url, $d)); } $pre .= $dirs[$i] . '/'; $i++; } if (!$file_tree->is_empty()) { breadcrumb_add_segment($file_tree, $d); } else { breadcrumb_set_self($i == 1 ? do_lang_tempcode('FILE_DUMP') : make_string_tempcode(escape_html($d))); } // Check directory exists $fullpath = get_custom_file_base() . '/uploads/filedump' . $place; if (!file_exists(get_custom_file_base() . '/uploads/filedump' . $place)) { if (has_specific_permission(get_member(), 'upload_filedump')) { @mkdir($fullpath, 0777) or warn_exit(do_lang_tempcode('WRITE_ERROR_DIRECTORY', escape_html($fullpath), escape_html(dirname($fullpath)))); fix_permissions($fullpath, 0777); sync_file($fullpath); } } // Find all files in the incoming directory $handle = opendir(get_custom_file_base() . '/uploads/filedump' . $place); $i = 0; $filename = array(); $description = array(); $filesize = array(); $filetime = array(); $directory = array(); $deletable = array(); while (false !== ($file = readdir($handle))) { if (!should_ignore_file('uploads/filedump' . $place . $file, IGNORE_ACCESS_CONTROLLERS | IGNORE_HIDDEN_FILES)) { $directory[$i] = !is_file(get_custom_file_base() . '/uploads/filedump' . $place . $file); $filename[$i] = $directory[$i] ? $file . '/' : $file; if ($directory[$i]) { $filesize[$i] = do_lang_tempcode('NA_EM'); } $dbrows = $GLOBALS['SITE_DB']->query_select('filedump', array('description', 'the_member'), array('name' => $file, 'path' => $place)); if (!array_key_exists(0, $dbrows)) { $description[$i] = $directory[$i] ? do_lang_tempcode('NA_EM') : do_lang_tempcode('NONE_EM'); } else { $description[$i] = make_string_tempcode(escape_html(get_translated_text($dbrows[0]['description']))); } if ($description[$i]->is_empty()) { $description[$i] = do_lang_tempcode('NONE_EM'); } $deletable[$i] = array_key_exists(0, $dbrows) && $dbrows[0]['the_member'] == get_member() || has_specific_permission(get_member(), 'delete_anything_filedump'); if ($directory[$i]) { $size = get_directory_size(get_custom_file_base() . '/uploads/filedump' . $place . $file); $timestamp = NULL; } else { $size = filesize(get_custom_file_base() . '/uploads/filedump' . $place . $file); $timestamp = filemtime(get_custom_file_base() . '/uploads/filedump' . $place . $file); } $filesize[$i] = clean_file_size($size); $filetime[$i] = is_null($timestamp) ? NULL : get_timezoned_date($timestamp); $i++; } } closedir($handle); if ($i != 0) { require_code('templates_table_table'); $header_row = table_table_header_row(array(do_lang_tempcode('FILENAME'), do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('SIZE'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('ACTIONS'))); $rows = new ocp_tempcode(); for ($a = 0; $a < $i; $a++) { if ($directory[$a]) { $link = build_url(array('page' => '_SELF', 'place' => $place . $filename[$a]), '_SELF'); } else { $link = make_string_tempcode(get_custom_base_url() . '/uploads/filedump' . str_replace('%2F', '/', rawurlencode($place . $filename[$a]))); } if (!$directory[$a]) { if ($deletable[$a]) { $delete_url = build_url(array('page' => '_SELF', 'type' => 'ed', 'file' => $filename[$a], 'place' => $place), '_SELF'); $actions = do_template('TABLE_TABLE_ACTION_DELETE_ENTRY', array('_GUID' => '9b91e485d80417b1664145f9bca5a2f5', 'NAME' => $filename[$a], 'URL' => $delete_url)); } else { $actions = new ocp_tempcode(); } } else { $delete_url = build_url(array('page' => '_SELF', 'type' => 'ec', 'file' => $filename[$a], 'place' => $place), '_SELF'); $actions = do_template('TABLE_TABLE_ACTION_DELETE_CATEGORY', array('_GUID' => '0fa7d4090c6195328191399a14799169', 'NAME' => $filename[$a], 'URL' => $delete_url)); } $rows->attach(table_table_row(array(hyperlink($link, escape_html($filename[$a]), !$directory[$a]), escape_html($description[$a]), escape_html($filesize[$a]), is_null($filetime[$a]) ? do_lang_tempcode('NA') : make_string_tempcode(escape_html($filetime[$a])), $actions))); } $files = do_template('TABLE_TABLE', array('_GUID' => '1c0a91d47c5fc8a7c2b35c7d9b36132f', 'HEADER_ROW' => $header_row, 'ROWS' => $rows)); } else { $files = new ocp_tempcode(); } // Do a form so people can upload their own stuff if (has_specific_permission(get_member(), 'upload_filedump')) { $post_url = build_url(array('page' => '_SELF', 'type' => 'ad', 'uploading' => 1), '_SELF'); $submit_name = do_lang_tempcode('FILEDUMP_UPLOAD'); $max = floatval(get_max_file_size()); $text = new ocp_tempcode(); if ($max < 30.0) { $config_url = get_upload_limit_config_url(); $text->attach(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max / 1024.0 / 1024.0)), escape_html(is_null($config_url) ? '' : $config_url))); } require_code('form_templates'); $fields = form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('_DESCRIPTION_UPLOAD'), 'file', true); $fields->attach(form_input_line(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', '', false)); $hidden = new ocp_tempcode(); $hidden->attach(form_input_hidden('place', $place)); handle_max_file_size($hidden); $upload_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'SKIP_REQUIRED' => true, 'HIDDEN' => $hidden, 'TEXT' => $text, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url)); } else { $upload_form = new ocp_tempcode(); } // Do a form so people can make folders if (get_option('is_on_folder_create') == '1') { $post_url = build_url(array('page' => '_SELF', 'type' => 'ac'), '_SELF'); require_code('form_templates'); $fields = form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'name', '', true); $hidden = form_input_hidden('place', $place); $submit_name = do_lang_tempcode('FILEDUMP_CREATE_FOLDER'); $create_folder_form = do_template('FORM', array('_GUID' => '043f9b595d3699b7d8cd7f2284cdaf98', 'TABINDEX' => strval(get_form_field_tabindex()), 'SKIP_REQUIRED' => true, 'SECONDARY_FORM' => true, 'HIDDEN' => $hidden, 'TEXT' => '', 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url)); } else { $create_folder_form = new ocp_tempcode(); } return do_template('FILE_DUMP_SCREEN', array('_GUID' => '3f49a8277a11f543eff6488622949c84', 'TITLE' => $title, 'PLACE' => $place, 'FILES' => $files, 'UPLOAD_FORM' => $upload_form, 'CREATE_FOLDER_FORM' => $create_folder_form)); }
/** * Standard modular render function for profile tabs edit hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return ?array A tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set) */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $title = do_lang_tempcode('SIGNATURE'); $order = 40; // Actualiser $new_signature = post_param('signature', NULL); if ($new_signature !== NULL) { require_code('ocf_members_action'); require_code('ocf_members_action2'); ocf_member_choose_signature($new_signature, $member_id_of); require_code('autosave'); clear_ocp_autosave(); attach_message(do_lang_tempcode('SUCCESS_SAVE'), 'inform'); } if ($leave_to_ajax_if_possible) { return NULL; } // UI $_signature = get_translated_tempcode($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_signature'), $GLOBALS['FORUM_DB']); $signature = $_signature->is_empty() ? do_lang_tempcode('NONE_EM') : $_signature; $_signature_original = get_translated_text($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_signature'), $GLOBALS['FORUM_DB']); $size = ocf_get_member_best_group_property($member_id_of, 'max_sig_length_comcode'); $javascript = "\n\t\t\tvar form=document.getElementById('signature').form;\n\t\t\tform.old_submit=form.onsubmit;\n\t\t\tform.onsubmit=function()\n\t\t\t\t{\n\t\t\t\t\tvar post=form.elements['signature'];\n\t\t\t\t\tif ((!post.value) && (post[1])) post=post[1];\n\t\t\t\t\tif (post.value.length>" . strval($size) . ")\n\t\t\t\t\t{\n\t\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('SIGNATURE_TOO_BIG')) . "');\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\t\treturn true;\n\t\t\t\t};\n\t\t"; require_code('form_templates'); $required = false; $has_preview = true; require_lang('javascript'); require_javascript('javascript_posting'); require_javascript('javascript_editing'); require_javascript('javascript_ajax'); require_javascript('javascript_swfupload'); require_css('swfupload'); require_lang('comcode'); $tabindex = get_form_field_tabindex(); $post_comment = do_lang_tempcode('SIGNATURE'); list($attachments, $attach_size_field) = get_attachments('signature'); $hidden_fields = new ocp_tempcode(); $hidden_fields->attach($attach_size_field); $continue_url = get_self_url(); $comcode_help = build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false)); $emoticon_chooser = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser(); $comcode_editor = get_comcode_editor(); $comcode_editor_small = get_comcode_editor('signature', true); $w = has_js() && (browser_matches('wysiwyg') && strpos($_signature_original, '{$,page hint: no_wysiwyg}') === false); $class = ''; global $JAVASCRIPT, $WYSIWYG_ATTACHED; if (!$WYSIWYG_ATTACHED) { $JAVASCRIPT->attach(do_template('HTML_EDIT')); } $WYSIWYG_ATTACHED = true; @header('Content-type: text/html; charset=' . get_charset()); if ($w) { $class .= ' wysiwyg'; } global $LAX_COMCODE; $temp = $LAX_COMCODE; $LAX_COMCODE = true; $GLOBALS['COMCODE_PARSE_URLS_CHECKED'] = 100; // Little hack to stop it checking any URLs /*if (is_null($default_parsed)) */ $default_parsed = comcode_to_tempcode($_signature_original, NULL, false, 60, NULL, NULL, true); $LAX_COMCODE = $temp; $fields = new ocp_tempcode(); $fields->attach(do_template('POSTING_FIELD', array('PRETTY_NAME' => do_lang_tempcode('SIGNATURE'), 'DESCRIPTION' => '', 'HIDDEN_FIELDS' => $hidden_fields, 'NAME' => 'signature', 'REQUIRED' => $required, 'TABINDEX_PF' => strval($tabindex), 'COMCODE_EDITOR' => $comcode_editor, 'COMCODE_EDITOR_SMALL' => $comcode_editor_small, 'CLASS' => $class, 'COMCODE_URL' => build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false)), 'EXTRA' => '', 'POST_COMMENT' => $post_comment, 'EMOTICON_CHOOSER' => $emoticon_chooser, 'COMCODE_HELP' => $comcode_help, 'POST' => $_signature_original, 'DEFAULT_PARSED' => $default_parsed, 'CONTINUE_URL' => $continue_url, 'ATTACHMENTS' => $attachments))); $text = do_template('OCF_EDIT_SIGNATURE_TAB', array('_GUID' => 'f5f2eb2552c34840c9cf46886422401e', 'SIZE' => integer_format($size), 'SIGNATURE' => $signature, 'TITLE' => $title)); return array($title, $fields, $text, $javascript, $order); }
/** * 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); }
/** * Interface to import/export. * * @return tempcode The interface. */ function ui() { $title = get_page_title('XML_DATA_MANAGEMENT'); require_code('form_templates'); $import_url = build_url(array('page' => '_SELF', 'type' => '_import'), '_SELF'); $import_fields = new ocp_tempcode(); $import_fields->attach(form_input_huge(do_lang_tempcode('XML_DATA'), '', 'xml', '', true)); $import_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'URL' => $import_url, 'HIDDEN' => '', 'TEXT' => do_lang_tempcode('XML_IMPORT_TEXT'), 'FIELDS' => $import_fields, 'SUBMIT_NAME' => do_lang_tempcode('IMPORT'))); $all_tables = find_all_xml_tables(); $export_url = build_url(array('page' => '_SELF', 'type' => '_export'), '_SELF'); $export_fields = new ocp_tempcode(); $nice_tables = new ocp_tempcode(); foreach ($all_tables as $table) { $nice_tables->attach(form_input_list_entry($table)); } $export_fields->attach(form_input_multi_list(do_lang_tempcode('TABLES'), do_lang_tempcode('DESCRIPTION_TABLES'), 'tables', $nice_tables, NULL, 15)); $export_fields->attach(form_input_tick(do_lang_tempcode('EXPORT_WITH_COMCODE_XML'), do_lang_tempcode('DESCRIPTION_EXPORT_WITH_COMCODE_XML'), 'comcode_xml', false)); $export_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'URL' => $export_url, 'HIDDEN' => '', 'TEXT' => do_lang_tempcode('XML_EXPORT_TEXT'), 'FIELDS' => $export_fields, 'SUBMIT_NAME' => do_lang_tempcode('EXPORT'))); return do_template('XML_STORAGE_SCREEN', array('TITLE' => $title, 'IMPORT_FORM' => $import_form, 'EXPORT_FORM' => $export_form)); }
/** * Get the tempcode for a radio input. (You would gather together the outputs of several of these functions, then put them in as the $content in a form_input_radio function call). * * @param string The name of the radio button group this will be put in (i.e. the name the value presented here will be possibly matched against) * @param string The value for this entry * @param boolean Whether this entry is selected by default or not * @param mixed The text associated with this choice (blank: just use value for text) * @param ?integer The tab index of the field (NULL: not specified) * @param string An additional long description (blank: no description) * @return tempcode The input field */ function form_input_radio_entry($name, $value, $selected = false, $text = '', $tabindex = NULL, $description = '') { $tabindex = get_form_field_tabindex($tabindex); if (is_string($text) && $text == '') { $text = $value; } $selected = filter_form_field_default($name, $selected ? '1' : '') == '1'; return do_template('FORM_SCREEN_INPUT_RADIO_LIST_ENTRY', array('_GUID' => 'e2fe4ba6e8b3f705651dba13ea27f61d', 'DESCRIPTION' => $description, 'CHECKED' => $selected, 'TABINDEX' => strval($tabindex), 'NAME' => $name, 'VALUE' => $value, 'TEXT' => $text)); }
/** * The UI to do a search. * * @return tempcode The UI */ function form() { global $NON_CANONICAL_PARAMS; $id = get_param('id', ''); $title = get_page_title('SEARCH_TITLE'); require_code('templates_internalise_screen'); if ($id != '') { require_code('hooks/modules/search/' . filter_naughty_harsh($id), true); $object = object_factory('Hook_search_' . filter_naughty_harsh($id)); $info = $object->info(); if (!is_null($info)) { $title = get_page_title('_SEARCH_TITLE', true, array($info['lang'])); } breadcrumb_set_parents(array(array('_SELF:_SELF', do_lang_tempcode('SEARCH_FOR')))); breadcrumb_set_self($info['lang']); $under = get_param('search_under', '!', true); if (!is_null($info) && method_exists($object, 'get_tree')) { $object->get_tree($under); } if (!is_null($info)) { $test_tpl = internalise_own_screen($title); } else { $test_tpl = NULL; } } else { $test_tpl = internalise_own_screen($title); } if (is_object($test_tpl)) { return $test_tpl; } require_javascript('javascript_ajax'); require_javascript('javascript_ajax_people_lists'); $content = get_param('content', NULL, true); $user_label = do_lang_tempcode('SEARCH_USER'); $days_label = do_lang_tempcode('SUBMITTED_WITHIN'); $extra_sort_fields = array(); if ($id != '') { $url_map = array('page' => '_SELF', 'type' => 'results', 'id' => $id, 'specific' => 1); $catalogue_name = get_param('catalogue_name', ''); if ($catalogue_name != '') { $url_map['catalogue_name'] = $catalogue_name; } $force_non_tabular = get_param_integer('force_non_tabular', 0); if ($force_non_tabular == 1) { $url_map['force_non_tabular'] = 1; } $url = build_url($url_map, '_SELF', NULL, false, true); require_code('hooks/modules/search/' . filter_naughty_harsh($id), true); $object = object_factory('Hook_search_' . filter_naughty_harsh($id)); $info = $object->info(); if (is_null($info)) { warn_exit(do_lang_tempcode('SEARCH_HOOK_NOT_AVAILABLE')); } if (array_key_exists('user_label', $info)) { $user_label = $info['user_label']; } if (array_key_exists('days_label', $info)) { $days_label = $info['days_label']; } $extra_sort_fields = array_key_exists('extra_sort_fields', $info) ? $info['extra_sort_fields'] : array(); $under = NULL; if (method_exists($object, 'ajax_tree')) { require_javascript('javascript_tree_list'); require_javascript('javascript_more'); $ajax = true; $under = get_param('search_under', '', true); list($ajax_hook, $ajax_options) = $object->ajax_tree(); require_code('hooks/systems/ajax_tree/' . $ajax_hook); $tree_hook_object = object_factory('Hook_' . $ajax_hook); $simple_content = $tree_hook_object->simple(NULL, $ajax_options, preg_replace('#,.*$#', '', $under)); $nice_label = $under; if (!is_null($under)) { $simple_content_evaluated = $simple_content->evaluate(); $matches = array(); if (preg_match('#<option [^>]*value="' . str_replace('#', '\\#', preg_quote($under)) . '(' . (strpos($under, ',') === false ? ',' : '') . '[^"]*)?"[^>]*>([^>]* > )?([^>]*)</option>#', $simple_content_evaluated, $matches) != 0) { if (strpos($under, ',') === false) { $under = $under . $matches[1]; } $nice_label = trim($matches[3]); } } require_code('form_templates'); $tree = do_template('FORM_SCREEN_INPUT_TREE_LIST', array('_GUID' => '25368e562be3b4b9c6163aa008b47c91', 'TABINDEX' => strval(get_form_field_tabindex()), 'NICE_LABEL' => is_null($nice_label) || $nice_label == '-1' ? '' : $nice_label, 'END_OF_FORM' => true, 'REQUIRED' => '', 'USE_SERVER_ID' => false, 'NAME' => 'search_under', 'DEFAULT' => $under, 'HOOK' => $ajax_hook, 'ROOT_ID' => '', 'OPTIONS' => serialize($ajax_options))); } else { $ajax = false; $tree = form_input_list_entry('!', false, do_lang_tempcode('NA_EM')); if (method_exists($object, 'get_tree')) { $under = get_param('search_under', '!', true); $tree->attach($object->get_tree($under)); } } $options = new ocp_tempcode(); if (array_key_exists('special_on', $info)) { foreach ($info['special_on'] as $name => $display) { $options->attach(do_template('SEARCH_FOR_SEARCH_DOMAIN_OPTION', array('_GUID' => 'c1853f42d0a110026453f8b94c9f623c', 'CHECKED' => is_null($content) || get_param_integer('option_' . $id . '_' . $name, 0) == 1, 'NAME' => 'option_' . $id . '_' . $name, 'DISPLAY' => $display))); } } if (array_key_exists('special_off', $info)) { foreach ($info['special_off'] as $name => $display) { $options->attach(do_template('SEARCH_FOR_SEARCH_DOMAIN_OPTION', array('_GUID' => '2223ada7636c85e6879feb9a6f6885d2', 'CHECKED' => get_param_integer('option_' . $id . '_' . $name, 0) == 1, 'NAME' => 'option_' . $id . '_' . $name, 'DISPLAY' => $display))); } } if (method_exists($object, 'get_fields')) { $fields = $object->get_fields(); foreach ($fields as $field) { $options->attach(do_template('SEARCH_FOR_SEARCH_DOMAIN_OPTION' . $field['TYPE'], array('_GUID' => 'a223ada7636c85e6879feb9a6f6885d2', 'NAME' => 'option_' . $field['NAME'], 'DISPLAY' => $field['DISPLAY'], 'SPECIAL' => $field['SPECIAL'], 'CHECKED' => array_key_exists('checked', $field) ? $field['CHECKED'] : false))); } } $specialisation = do_template('SEARCH_ADVANCED', array('_GUID' => 'fad0c147b8291ba972f105c65715f1ac', 'AJAX' => $ajax, 'OPTIONS' => $options, 'TREE' => $tree, 'UNDERNEATH' => !is_null($under))); } else { $map = array('page' => '_SELF', 'type' => 'results'); $under = get_param('search_under', '-1', true); if ($under != '-1') { $map['search_under'] = $under; } $url = build_url($map, '_SELF', NULL, false, true); $search_domains = new ocp_tempcode(); $_search_domains = array(); $_hooks = find_all_hooks('modules', 'search'); foreach (array_keys($_hooks) as $hook) { require_code('hooks/modules/search/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_search_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } $info = $object->info(); if (is_null($info)) { continue; } $NON_CANONICAL_PARAMS[] = 'search_' . $hook; $is_default_or_advanced = $info['default'] && $id == '' || $hook == $id; $checked = get_param_integer('search_' . $hook, is_null($content) || get_param_integer('all_defaults', 0) == 1 ? $is_default_or_advanced ? 1 : 0 : 0) == 1; $options = array_key_exists('special_on', $info) || array_key_exists('special_off', $info) || array_key_exists('extra_sort_fields', $info) || method_exists($object, 'get_fields') || method_exists($object, 'get_tree') || method_exists($object, 'get_ajax_tree') ? build_url(array('page' => '_SELF', 'id' => $hook), '_SELF', NULL, false, true) : new ocp_tempcode(); $_search_domains[] = array('_GUID' => '3d3099872184923aec0f49388f52c750', 'ADVANCED_ONLY' => array_key_exists('advanced_only', $info) && $info['advanced_only'], 'CHECKED' => $checked, 'OPTIONS' => $options, 'LANG' => $info['lang'], 'NAME' => $hook); } global $M_SORT_KEY; $M_SORT_KEY = 'LANG'; usort($_search_domains, 'multi_sort'); foreach ($_search_domains as $sd) { $search_domains->attach(do_template('SEARCH_FOR_SEARCH_DOMAIN', $sd)); } $specialisation = do_template('SEARCH_DOMAINS', array('_GUID' => '1fd8718b540ec475988070ee7a444dc1', 'SEARCH_DOMAINS' => $search_domains)); } $author = get_param('author', ''); $author_id = $author != '' ? $GLOBALS['FORUM_DRIVER']->get_member_from_username($author) : NULL; $days = get_param_integer('days', 60); $sort = get_param('sort', 'relevance'); $direction = get_param('direction', 'DESC'); if (!in_array(strtoupper($direction), array('ASC', 'DESC'))) { log_hack_attack_and_exit('ORDERBY_HACK'); } $NON_CANONICAL_PARAMS[] = 'sort'; $NON_CANONICAL_PARAMS[] = 'direction'; $only_titles = get_param_integer('only_titles', 0) == 1; $search_under = get_param('search_under', '!', true); if ($search_under == '') { $search_under = '!'; } $boolean_operator = get_param('conjunctive_operator', 'OR'); $NON_CANONICAL_PARAMS[] = 'search_under'; $NON_CANONICAL_PARAMS[] = 'all_defaults'; $NON_CANONICAL_PARAMS[] = 'days'; $NON_CANONICAL_PARAMS[] = 'only_titles'; $NON_CANONICAL_PARAMS[] = 'conjunctive_operator'; $NON_CANONICAL_PARAMS[] = 'boolean_search'; $NON_CANONICAL_PARAMS[] = 'only_search_meta'; $NON_CANONICAL_PARAMS[] = 'content'; $NON_CANONICAL_PARAMS[] = 'author'; $test = db_has_full_text($GLOBALS['SITE_DB']->connection_read); $old_mysql = !$test; $can_order_by_rating = db_has_subqueries($GLOBALS['SITE_DB']->connection_read); // Perform search, if we did one $out = NULL; $results_browser = ''; $num_results = 0; if (!is_null($content)) { list($out, $results_browser, $num_results) = $this->results($id, $author, $author_id, $days, $sort, $direction, $only_titles, $search_under); if (has_zone_access(get_member(), 'adminzone')) { $admin_search_url = build_url(array('page' => 'admin', 'type' => 'search', 'search_content' => $content), 'adminzone'); attach_message(do_lang_tempcode('ALSO_ADMIN_ZONE_SEARCH', escape_html($admin_search_url->evaluate())), 'inform'); } } return do_template('SEARCH_FORM_SCREEN', array('_GUID' => '8bb208185740183323a6fe6e89d55de5', 'SEARCH_TERM' => is_null($content) ? '' : $content, 'NUM_RESULTS' => integer_format($num_results), 'CAN_ORDER_BY_RATING' => $can_order_by_rating, 'EXTRA_SORT_FIELDS' => $extra_sort_fields, 'USER_LABEL' => $user_label, 'DAYS_LABEL' => $days_label, 'BOOLEAN_SEARCH' => $this->_is_boolean_search(), 'AND' => $boolean_operator == 'AND', 'ONLY_TITLES' => $only_titles, 'DAYS' => is_null($days) ? '' : strval($days), 'SORT' => $sort, 'DIRECTION' => $direction, 'CONTENT' => $content, 'RESULTS' => $out, 'RESULTS_BROWSER' => $results_browser, 'OLD_MYSQL' => $old_mysql, 'TITLE' => $title, 'AUTHOR' => $author, 'SPECIALISATION' => $specialisation, 'URL' => $url)); }
/** * Choose an emoticon for a topic. * * @param ID_TEXT The currently selected emoticon * @return tempcode The emoticon input field */ function choose_topic_emoticon($selected_path = '') { $tabindex = get_form_field_tabindex(NULL); $content = array(); $extra = has_specific_permission(get_member(), 'use_special_emoticons') ? '' : ' AND e_is_special=0'; $rows = $GLOBALS['FORUM_DB']->query('SELECT e_theme_img_code FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_emoticons WHERE e_use_topics=1' . $extra); $content[] = do_template('FORM_SCREEN_INPUT_RADIO_LIST_ENTRY_PICTURE_3_NA', array('_GUID' => 'd9f9399072af3f19f21695aef01168c7', 'CHECKED' => $selected_path == '', 'NAME' => 'emoticon')); foreach ($rows as $row) { $path = $row['e_theme_img_code']; $url = find_theme_image($path); $content[] = do_template('FORM_SCREEN_INPUT_RADIO_LIST_ENTRY_PICTURE_3', array('PRETTY' => '', 'CHECKED' => $path == $selected_path, 'NAME' => 'emoticon', 'CODE' => $path, 'URL' => $url)); } if (count($content) == 0) { return new ocp_tempcode(); } $_content = wrap_image_radio_list($content); $input = do_template('FORM_SCREEN_INPUT_RADIO_LIST', array('NAME' => 'emoticon', 'REQUIRED' => false, 'CODE' => $selected_path, 'TABINDEX' => strval($tabindex), 'CONTENT' => $_content)); return _form_input('', do_lang_tempcode('TOPIC_EMOTICON'), '', $input, false); }
/** * The UI for managing temporary usergroup memberships. * * @return tempcode The UI */ function group_member_timeouts() { $title = get_page_title('GROUP_MEMBER_TIMEOUTS'); if (!cron_installed()) { attach_message(do_lang_tempcode('CRON_NEEDED_TO_WORK', escape_html(brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_configuration')), 'warn'); } $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/usergroups_temp'; breadcrumb_set_parents(array(array('_SEARCH:admin_ocf_join:menu', do_lang_tempcode('MEMBERS')))); require_code('form_templates'); require_code('templates_results_table'); $start = get_param_integer('start', 0); $max = get_param_integer('max', 100); $max_rows = $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_value('f_group_member_timeouts', 'COUNT(*)'); $fields_title = results_field_title(array(do_lang_tempcode('USERNAME'), do_lang_tempcode('_USERGROUP'), do_lang_tempcode('TIME'))); $timeouts = $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_select('f_group_member_timeouts', array('member_id', 'group_id', 'timeout'), NULL, '', $max, $start); $usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(); $tfields = new ocp_tempcode(); foreach ($timeouts as $timeout) { $tfields->attach(results_entry(array($GLOBALS['FORUM_DRIVER']->get_username($timeout['member_id']), isset($usergroups[$timeout['group_id']]) ? $usergroups[$timeout['group_id']] : do_lang('UNKNOWN'), display_time_period($timeout['timeout'] - time())), true)); } $results_table = results_table(do_lang('GROUP_MEMBER_TIMEOUTS'), $start, 'start', $max, 'max', $max_rows, $fields_title, $tfields); $fields = new ocp_tempcode(); $fields->attach(form_input_username(do_lang_tempcode('USERNAME'), '', 'username', '', true)); $_usergroups = new ocp_tempcode(); foreach ($usergroups as $uid => $name) { if ($uid != db_get_first_id()) { $_usergroups->attach(form_input_list_entry($uid, false, $name)); } } require_lang('dates'); $fields->attach(form_input_list(do_lang_tempcode('_USERGROUP'), '', 'group_id', $_usergroups, NULL, false, true)); $fields->attach(form_input_integer(do_lang_tempcode('_MINUTES'), do_lang_tempcode('DESCRIPTION_GROUPMT_MINUTES'), 'num_minutes', 60, true)); $post_url = build_url(array('page' => '_SELF', 'type' => '_group_member_timeouts'), '_SELF'); $submit_name = do_lang_tempcode('ADD'); $form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'HIDDEN' => '', 'TEXT' => '', 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name)); return do_template('RESULTS_TABLE_SCREEN', array('TITLE' => $title, 'RESULTS_TABLE' => $results_table, 'FORM' => $form)); }
/** * Create a form field input matrix for permission setting. * * @param ID_TEXT Permission ID (pagelink style) for the resource being set * @param array An inverted list showing what view permissions are set for what we're setting permissions for * @param array List of overridable privilege codes for what we're setting permissions for * @param array List of privilege settings relating to what we're setting permissions for, from the database * @param array Multi-dimensional array showing what the inherited defaults for this permission would be * @param boolean Whether to not include the stuff to make it fit alongside other form fields in a normal form table * @param ?tempcode Label for view permissions (NULL: default) * @return tempcode The form field matrix */ function get_permissions_matrix($server_id, $access, $overridables, $specific_permissions, $default_access, $no_outer = false, $pinterface_view = NULL) { require_lang('permissions'); require_javascript('javascript_permissions'); $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups(); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true, true); if (is_null($pinterface_view)) { $pinterface_view = do_lang_tempcode('PINTERFACE_VIEW'); } // Permission rows for matrix $permission_rows = new ocp_tempcode(); $all_groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true); foreach (array_keys($access) as $id) { if (!array_key_exists($id, $groups) && array_key_exists($id, $all_groups)) { $groups[$id] = $all_groups[$id]; } } foreach ($groups as $id => $group_name) { if (!in_array($id, $admin_groups)) { $perhaps = count($access) == 0 ? 1 : $access[$id]; $view_access = $perhaps == 1; $tabindex = get_form_field_tabindex(NULL); $overrides = new ocp_tempcode(); $all_global = true; foreach (array_keys($overridables) as $override) { if (isset($specific_permissions[$override][$id])) { $all_global = false; } } foreach ($overridables as $override => $cat_support) { $lang_string = do_lang_tempcode('PT_' . $override); if (is_array($cat_support)) { $lang_string = do_lang_tempcode($cat_support[1]); } if (is_array($cat_support)) { $cat_support = $cat_support[0]; } if ($cat_support == 0) { continue; } $overrides->attach(do_template('FORM_SCREEN_INPUT_PERMISSION_OVERRIDE', array('FORCE_PRESETS' => $no_outer, 'GROUP_NAME' => $group_name, 'VIEW_ACCESS' => $view_access, 'TABINDEX' => strval($tabindex), 'GROUP_ID' => strval($id), 'SP' => $override, 'ALL_GLOBAL' => $all_global, 'TITLE' => $lang_string, 'DEFAULT_ACCESS' => $default_access[$id][$override], 'CODE' => isset($specific_permissions[$override][$id]) ? $specific_permissions[$override][$id] : '-1'))); } $permission_rows->attach(do_template('FORM_SCREEN_INPUT_PERMISSION', array('_GUID' => 'e2c4459ae995d33376c07e498f1d973a', 'FORCE_PRESETS' => $no_outer, 'GROUP_NAME' => $group_name, 'OVERRIDES' => $overrides->evaluate(), 'ALL_GLOBAL' => $all_global, 'VIEW_ACCESS' => $view_access, 'TABINDEX' => strval($tabindex), 'GROUP_ID' => strval($id), 'PINTERFACE_VIEW' => $pinterface_view))); } else { $overridables_filtered = array(); foreach ($overridables as $override => $cat_support) { if (is_array($cat_support)) { $cat_support = $cat_support[0]; } if ($cat_support == 1) { $overridables_filtered[$override] = 1; } } $permission_rows->attach(do_template('FORM_SCREEN_INPUT_PERMISSION_ADMIN', array('FORCE_PRESETS' => $no_outer, 'OVERRIDES' => $overridables_filtered, 'GROUP_NAME' => $group_name, 'GROUP_ID' => strval($id), 'PINTERFACE_VIEW' => $pinterface_view))); } } if (count($overridables) == 0 && !$no_outer) { return $permission_rows; } // Find out colour for our vertical text image headings (CSS can't rotate text), using the CSS as a basis $tmp_file = @file_get_contents(get_custom_file_base() . '/themes/' . $GLOBALS['FORUM_DRIVER']->get_theme() . '/templates_cached/' . user_lang() . '/global.css'); $color = 'FF00FF'; $matches = array(); if ($tmp_file !== false) { if (preg_match('#\\nth.*\\sbackground-color:\\s*\\#([\\dA-Fa-f]*);.*\\}#sU', $tmp_file, $matches) != 0) { $color = $matches[1]; } } // For heading up the table matrix $overrides_array = array(); foreach ($overridables as $override => $cat_support) { $lang_string = do_lang_tempcode('PT_' . $override); if (is_array($cat_support)) { $lang_string = do_lang_tempcode($cat_support[1]); } if (is_array($cat_support)) { $cat_support = $cat_support[0]; } if ($cat_support == 0) { continue; } $overrides_array[$override] = array('TITLE' => $lang_string); } // Finish off the matrix and return $inner = do_template('FORM_SCREEN_INPUT_PERMISSION_MATRIX', array('_GUID' => '0f019c7e60366fa04058097ee6f3829a', 'SERVER_ID' => $server_id, 'COLOR' => $color, 'OVERRIDES' => $overrides_array, 'PERMISSION_ROWS' => $permission_rows)); if ($no_outer) { return make_string_tempcode(static_evaluate_tempcode($inner)); } return make_string_tempcode(static_evaluate_tempcode(do_template('FORM_SCREEN_INPUT_PERMISSION_MATRIX_OUTER', array('_GUID' => '2a2f9f78f3639185300c92cab50767c5', 'INNER' => $inner)))); }
/** * Get a captcha (aka security code) form field. * * @return tempcode The field */ function form_input_captcha() { $tabindex = get_form_field_tabindex(NULL); generate_captcha(); // Show template $input = do_template('FORM_SCREEN_INPUT_CAPTCHA', array('_GUID' => 'f7452af9b83db36685ae8a86f9762d30', 'TABINDEX' => strval($tabindex))); return _form_input('security_image', do_lang_tempcode('SECURITY_IMAGE'), do_lang_tempcode('DESCRIPTION_SECURITY_IMAGE'), $input, true, false); }
/** * The UI to send a newsletter. * * @param LONG_TEXT Default newsletter to put in * @return tempcode The UI */ function send_gui($_existing = '') { // If this is a periodic newsletter, we make some changes to the regular // language strings. $periodic_action_raw = post_param('periodic_choice', ''); $periodic_subject = ''; $defaults = mixed(); switch (preg_replace('#\\_\\d+$#', '', $periodic_action_raw)) { case 'remove_existing': // Remove whatever is already set. We don't need any changes for // this, but we do need a hidden form field. $periodic_action = 'remove'; break; case 'replace_existing': // Make the current newsletter periodic. This requires language // fiddling. $periodic_action = 'replace'; $periodic_subject = do_lang('PERIODIC_SUBJECT_HELP'); $periodic_id = intval(preg_replace('#^[^\\d]+#', '', $periodic_action_raw)); $_defaults = $GLOBALS['SITE_DB']->query_select('newsletter_periodic', array('*'), array('id' => $periodic_id), '', 1); if (!array_key_exists(0, $_defaults)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $defaults = $_defaults[0]; break; case 'make_periodic': // Make the current newsletter periodic. This requires language // fiddling. $periodic_action = 'make'; $periodic_subject = do_lang('PERIODIC_SUBJECT_HELP'); break; case 'no_change': default: // The default action is to leave the current settings as-is. $periodic_action = 'none'; break; } $title = get_page_title('NEWSLETTER_SEND'); $lang = choose_language($title); if (is_object($lang)) { return $lang; } $comcode_given = $_existing != '' && strpos($_existing, '<html') !== false; $_existing = post_param('message', $_existing); if ($_existing == '') { $from_news = get_param_integer('from_news', -1); if ($from_news != -1 && addon_installed('news')) { $rows = $GLOBALS['SITE_DB']->query_select('news', array('*'), array('id' => $from_news), 'ORDER BY id DESC', 1); if (!array_key_exists(0, $rows)) { require_lang('news'); return warn_screen(get_page_title('NEWS'), do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; $_existing = get_translated_text($myrow['news_article'], NULL, $lang); if ($_existing == '') { $_existing = get_translated_text($myrow['news'], NULL, $lang); } } $existing = do_template('NEWSLETTER_DEFAULT', array('_GUID' => '53c02947915806e519fe14c318813f42', 'CONTENT' => $_existing, 'LANG' => $lang)); } else { $default = do_template('NEWSLETTER_DEFAULT', array('_GUID' => '53c02947915806e519fe14c318813f44', 'CONTENT' => $_existing, 'LANG' => $lang)); if (strpos($default->evaluate(), '<html') !== false) { if ($comcode_given) { $default = do_template('NEWSLETTER_DEFAULT', array('_GUID' => '53c02947915806e519fe14c318813f46', 'CONTENT' => comcode_to_tempcode($_existing), 'LANG' => $lang)); } $existing = $default; } else { $existing = make_string_tempcode($_existing); } } $post_url = build_url(array('page' => '_SELF', 'type' => 'confirm', 'old_type' => get_param('type', '')), '_SELF'); $submit_name = do_lang_tempcode('PREVIEW'); $hidden = new ocp_tempcode(); $hidden->attach(form_input_hidden('lang', $lang)); // Build up form $fields = new ocp_tempcode(); require_code('form_templates'); $default_subject = get_option('newsletter_title'); if (!is_null($defaults)) { $default_subject = $defaults['np_subject']; } if ($periodic_action != 'make' && $periodic_action != 'replace') { $default_subject .= ' - ' . get_timezoned_date(time(), false, false, false, true); } $default_subject = post_param('subject', $default_subject); $fields->attach(form_input_line_comcode(do_lang_tempcode('SUBJECT'), do_lang_tempcode('NEWSLETTER_DESCRIPTION_TITLE', $periodic_subject), 'subject', $default_subject, true)); $in_full = post_param_integer('in_full', 0); $chosen_categories = post_param('chosen_categories', ''); if ($periodic_action == 'make' || $periodic_action == 'replace') { // We are making a periodic newsletter. This means we need to pass // through the chosen categories if (!is_null($defaults)) { $chosen_categories = $defaults['np_message']; $in_full = $defaults['np_in_full']; $fields->attach(form_input_tick(do_lang_tempcode('EMBED_FULL_ARTICLES'), do_lang_tempcode('DESCRIPTION_EMBED_FULL_ARTICLES'), 'in_full', $in_full == 1)); $fields->attach(form_input_huge(do_lang_tempcode('NEWSLETTER_CONTENT'), do_lang('NEWSLETTER_CONTENT_SELECT'), 'chosen_categories', $chosen_categories, true)); } else { $hidden->attach(form_input_hidden('chosen_categories', $chosen_categories)); $hidden->attach(form_input_hidden('in_full', strval($in_full))); } $hidden->attach(form_input_hidden('cutoff_day', post_param('cutoff_day'))); $hidden->attach(form_input_hidden('cutoff_month', post_param('cutoff_month'))); $hidden->attach(form_input_hidden('cutoff_year', post_param('cutoff_year'))); $hidden->attach(form_input_hidden('cutoff_hour', post_param('cutoff_hour'))); $hidden->attach(form_input_hidden('cutoff_minute', post_param('cutoff_minute'))); $hidden->attach(form_input_hidden('message', $existing->evaluate())); } else { $hidden->attach(form_input_hidden('in_full', strval($in_full))); if (strpos($existing->evaluate(), '<html') === false) { $fields->attach(form_input_huge_comcode(do_lang_tempcode('MESSAGE'), do_lang_tempcode('DESCRIPTION_MESSAGE_NEWSLETTER'), 'message', $existing->evaluate(), true)); } else { $fields->attach(form_input_huge(do_lang_tempcode('MESSAGE'), do_lang_tempcode('DESCRIPTION_MESSAGE_NEWSLETTER'), 'message', $existing->evaluate(), true)); } } if (addon_installed('calendar') && $periodic_action == 'none' && cron_installed()) { $fields->attach(form_input_date__scheduler(do_lang_tempcode('DEFER_TIME'), do_lang_tempcode('DESCRIPTION_DEFER_TIME'), 'schedule', true, true, true)); } $from_email = post_param('from_email', get_option('staff_address')); if (!is_null($defaults)) { $from_email = post_param('from_email', $defaults['np_from_email']); } $fields->attach(form_input_email(do_lang_tempcode('FROM_EMAIL'), do_lang_tempcode('DESCRIPTION_NEWSLETTER_FROM_EMAIL'), 'from_email', $from_email, true)); $from_name = post_param('from_name', get_site_name()); if (!is_null($defaults)) { $from_name = post_param('from_name', $defaults['np_from_name']); } $fields->attach(form_input_line(do_lang_tempcode('FROM_NAME'), do_lang_tempcode('DESCRIPTION_NEWSLETTER_FROM_NAME'), 'from_name', $from_name, true)); $_html_only = post_param_integer('html_only', NULL); if (is_null($_html_only)) { $html_only = strpos($existing->evaluate(), '<html') !== false; if (!is_null($defaults)) { $html_only = $defaults['np_html_only']; } } else { $html_only = $_html_only == 1; } if (get_value('force_html_only') === '1') { $hidden->attach(form_input_hidden('html_only', '1')); } else { $fields->attach(form_input_tick(do_lang_tempcode('HTML_ONLY'), do_lang_tempcode('DESCRIPTION_HTML_ONLY'), 'html_only', $html_only)); } $l = new ocp_tempcode(); $priority = post_param_integer('priority', 3); if (!is_null($defaults)) { $priority = post_param_integer('priority', $defaults['np_priority']); } for ($i = 1; $i <= 5; $i++) { $l->attach(form_input_list_entry(strval($i), $i == $priority, do_lang_tempcode('PRIORITY_' . strval($i)))); } $fields->attach(form_input_list(do_lang_tempcode('PRIORITY'), do_lang_tempcode('DESCRIPTION_NEWSLETTER_PRIORITY'), 'priority', $l)); // Where to send to $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('CHOOSE_SEND_TO')))); $newsletters = $GLOBALS['SITE_DB']->query_select('newsletters', array('*')); foreach ($newsletters as $newsletter) { $level = post_param_integer(strval($newsletter['id']), post_param_integer('level', -1)); $c4 = $this->count_level($newsletter['id'], 4, $lang); $c3 = $this->count_level($newsletter['id'], 3, $lang); $c2 = $this->count_level($newsletter['id'], 2, $lang); $c1 = $this->count_level($newsletter['id'], 1, $lang); if ($c1 != 0) { $newsletter_title = get_translated_text($newsletter['title']); $newsletter_description = get_translated_text($newsletter['description']); if ($c1 == $c2 && $c1 == $c3 && $c1 == $c4) { $fields->attach(form_input_tick(do_lang_tempcode('NEWSLETTER_PREFIX', escape_html($newsletter_title)), do_lang_tempcode('DESCRIPTION_NOSUBSCRIPTION_LEVEL', escape_html(integer_format($c4)), escape_html($newsletter_description)), strval($newsletter['id']), $level >= 1, NULL, '4')); } else { $l = new ocp_tempcode(); $l->attach(form_input_list_entry('0', $level == 0, do_lang_tempcode('NNR', do_lang_tempcode('NEWSLETTER_0_ALT'), do_lang_tempcode('NUM_READERS', integer_format(0))))); $l->attach(form_input_list_entry('1', $level == 1, do_lang_tempcode('NNR', do_lang_tempcode('NEWSLETTER_1'), do_lang_tempcode('NUM_READERS', integer_format($c1))))); $l->attach(form_input_list_entry('2', $level == 2, do_lang_tempcode('NNR', do_lang_tempcode('NEWSLETTER_2'), do_lang_tempcode('NUM_READERS', integer_format($c2))))); $l->attach(form_input_list_entry('3', $level == 3, do_lang_tempcode('NNR', do_lang_tempcode('NEWSLETTER_3'), do_lang_tempcode('NUM_READERS', integer_format($c3))))); $l->attach(form_input_list_entry('4', $level == 4, do_lang_tempcode('NNR', do_lang_tempcode('NEWSLETTER_4'), do_lang_tempcode('NUM_READERS', integer_format($c4))))); $fields->attach(form_input_list(do_lang_tempcode('SUBSCRIPTION_LEVEL_FOR', escape_html($newsletter_title)), do_lang_tempcode('DESCRIPTION_SUBSCRIPTION_LEVEL', escape_html($newsletter_description)), strval($newsletter['id']), $l)); } } } if (get_forum_type() == 'ocf') { $c5 = $this->count_level(-1, 5, $lang); $fields->attach(form_input_tick(do_lang_tempcode('NEWSLETTER_OCF'), do_lang_tempcode('NUM_READERS', integer_format($c5)), '-1', false)); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(); foreach ($groups as $group_id => $group) { if ($group_id != db_get_first_id()) { $map = array(); $map['g' . strval($group_id)] = 1; $_c = newsletter_who_send_to($map, $lang, 0, 0); $c6 = $_c[6]['g' . strval($group_id)]; if ($c6 != 0) { $fields->attach(form_input_tick(do_lang_tempcode('THIS_WITH', do_lang_tempcode('GROUP'), make_string_tempcode(escape_html($group))), do_lang_tempcode('NUM_READERS', integer_format($c6)), 'g' . strval($group_id), post_param_integer('g' . strval($group_id), 0) == 1)); } } } } $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD_CSV'), 'file', false, NULL, NULL, true, 'csv,txt')); //if ($fields->is_empty()) inform_exit(do_lang_tempcode('NOBODY_TO_SEND_TO')); handle_max_file_size($hidden); $template_choices = new ocp_tempcode(); $dh = opendir(get_custom_file_base() . '/themes/default/templates_custom'); while (($f = readdir($dh)) !== false) { if (preg_match('#^MAIL.*\\.tpl$#', $f) != 0) { $tpl = basename($f, '.tpl'); $template_choices->attach(form_input_list_entry($tpl, post_param('template', 'MAIL') == $tpl, $tpl)); } } if (!file_exists(get_custom_file_base() . '/themes/default/templates_custom/MAIL.tpl')) { $template_choices->attach(form_input_list_entry('MAIL', true, 'MAIL')); } closedir($dh); $fields->attach(form_input_list(do_lang_tempcode('NEWSLETTER_TEMPLATE'), do_lang_tempcode('DESCRIPTION_NEWSLETTER_TEMPLATE'), 'template', $template_choices, NULL, false, true)); // If we're making a periodic newsletter then we need to know when it // should be sent if ($periodic_action == 'make' || $periodic_action == 'replace') { $hidden->attach(form_input_hidden('make_periodic', '1')); $hidden->attach(form_input_hidden('periodic_choice', post_param('periodic_choice'))); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang('PERIODIC_WHEN'), 'HELP' => do_lang('PERIODIC_WHEN_HELP')))); // The choices are given as radio buttons: weekly or bi-weekly or monthly? // In the labels for these radio buttons, we put a dropdown for day of // the week and day of the month. $frequency = post_param('periodic_when', 'weekly'); if (!is_null($defaults)) { $frequency = post_param('periodic_when', $defaults['np_frequency']); } $current_day_weekly = post_param_integer('periodic_weekly', 5); if (!is_null($defaults)) { $current_day_weekly = post_param_integer('periodic_weekly', $defaults['np_day']); } $current_day_biweekly = post_param_integer('periodic_biweekly', 5); if (!is_null($defaults)) { $current_day_biweekly = post_param_integer('periodic_biweekly', $defaults['np_day']); } $current_day_of_month = post_param_integer('periodic_monthly', 1); if (!is_null($defaults)) { $current_day_of_month = post_param_integer('periodic_monthly', $defaults['np_day']); } $radios = new ocp_tempcode(); $week_days_weekly = new ocp_tempcode(); $week_days_biweekly = new ocp_tempcode(); require_lang('dates'); $week_days = array(1 => do_lang('MONDAY'), 2 => do_lang('TUESDAY'), 3 => do_lang('WEDNESDAY'), 4 => do_lang('THURSDAY'), 5 => do_lang('FRIDAY'), 6 => do_lang('SATURDAY'), 7 => do_lang('SUNDAY')); foreach ($week_days as $i => $this_day) { $week_days_weekly->attach(form_input_list_entry(strval($i), $i == $current_day_weekly, $this_day, false, false)); $week_days_biweekly->attach(form_input_list_entry(strval($i), $i == $current_day_biweekly, $this_day, false, false)); } $weekly_desc = new ocp_tempcode(); $weekly_desc->attach(do_lang('PERIODIC_WEEKLY_ON')); $weekly_desc->attach(do_template('FORM_SCREEN_INPUT_LIST', array('TABINDEX' => strval(get_form_field_tabindex(NULL)), 'REQUIRED' => '0', 'NAME' => 'periodic_weekday_weekly', 'CONTENT' => $week_days_weekly, 'INLINE_LIST' => '0'))); $radios->attach(form_input_radio_entry('periodic_when', 'weekly', $frequency == 'weekly', $weekly_desc, NULL, '')); $weekly_desc = new ocp_tempcode(); $weekly_desc->attach(do_lang('PERIODIC_BIWEEKLY_ON')); $weekly_desc->attach(do_template('FORM_SCREEN_INPUT_LIST', array('TABINDEX' => strval(get_form_field_tabindex(NULL)), 'REQUIRED' => '0', 'NAME' => 'periodic_weekday_biweekly', 'CONTENT' => $week_days_biweekly, 'INLINE_LIST' => '0'))); $radios->attach(form_input_radio_entry('periodic_when', 'biweekly', $frequency == 'biweekly', $weekly_desc, NULL, '')); $month_days = new ocp_tempcode(); foreach (range(1, 28) as $this_day) { $suffix = gmdate('S', gmmktime(0, 0, 0, 1, $this_day, 1990)); $month_days->attach(form_input_list_entry(strval($this_day), $this_day == 1, strval($this_day) . $suffix, $current_day_of_month == $this_day)); } $monthly_desc = new ocp_tempcode(); $monthly_desc->attach(do_lang('PERIODIC_MONTHLY_ON')); $monthly_desc->attach(do_template('FORM_SCREEN_INPUT_LIST', array('TABINDEX' => strval(get_form_field_tabindex(NULL)), 'REQUIRED' => '0', 'NAME' => 'periodic_monthly', 'CONTENT' => $month_days, 'INLINE_LIST' => '0'))); $radios->attach(form_input_radio_entry('periodic_when', 'monthly', $frequency == 'monthly', $monthly_desc, NULL, '')); $fields->attach(form_input_radio(do_lang('PERIODIC_WHEN_CHOICE'), '', 'periodic_when', $radios, true)); $radios = new ocp_tempcode(); $radios->attach(form_input_radio_entry('periodic_for', 'all', false, do_lang_tempcode('CREATE_PERIODIC_FOR_ALL'), NULL, '')); $radios->attach(form_input_radio_entry('periodic_for', 'future', true, do_lang_tempcode('CREATE_PERIODIC_FOR_FUTURE'), NULL, '')); $fields->attach(form_input_radio(do_lang('CREATE_PERIODIC_FOR'), '', 'periodic_for', $radios, true)); } return do_template('FORM_SCREEN', array('_GUID' => '0b2a4825ec586d9ff557026d9a1e0cca', 'TITLE' => $title, 'TEXT' => $periodic_action == 'make' || $periodic_action == 'replace' ? do_lang_tempcode('PERIODIC_NO_EDIT') : do_lang_tempcode('NEWSLETTER_SEND_TEXT'), 'HIDDEN' => $hidden, 'FIELDS' => $fields->evaluate(), 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url)); }
/** * The UI to choose a filtered-word to edit, or to add a filtered-word. * * @return tempcode The UI */ function word_filter_interface() { $title = get_page_title('MANAGE_WORDFILTER'); require_code('form_templates'); $list = new ocp_tempcode(); $words = $GLOBALS['SITE_DB']->query_select('wordfilter', array('*'), NULL, 'ORDER BY word'); foreach ($words as $word) { $word_text = ($word['w_substr'] == 1 ? '*' : '') . $word['word'] . ($word['w_substr'] == 1 ? '*' : ''); if ($word['w_replacement'] != '') { $word_text .= ' -> ' . $word['w_replacement']; } $list->attach(form_input_list_entry($word['word'], false, $word_text)); } if (!$list->is_empty()) { $delete_url = build_url(array('page' => '_SELF', 'type' => 'remove'), '_SELF'); $submit_name = do_lang_tempcode('DELETE_WORDFILTER'); $fields = form_input_list(do_lang_tempcode('WORD'), '', 'word', $list); $tpl = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'HIDDEN' => '', 'TEXT' => '', 'FIELDS' => $fields, 'URL' => $delete_url, 'SUBMIT_NAME' => $submit_name)); } else { $tpl = new ocp_tempcode(); } // Do a form so people can add $post_url = build_url(array('page' => '_SELF', 'type' => 'add'), '_SELF'); $submit_name = do_lang_tempcode('ADD_WORDFILTER'); $fields = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('WORD'), do_lang_tempcode('DESCRIPTION_WORD'), 'word_2', '', true)); $fields->attach(form_input_line(do_lang_tempcode('REPLACEMENT'), do_lang_tempcode('DESCRIPTION_REPLACEMENT'), 'replacement', '', false)); $fields->attach(form_input_tick(do_lang_tempcode('WORD_SUBSTR'), do_lang_tempcode('DESCRIPTION_WORD_SUBSTR'), 'substr', false)); $add_form = do_template('FORM', array('_GUID' => '5b1d45b374e15392b9f5496de8db2e1c', 'TABINDEX' => strval(get_form_field_tabindex()), 'SECONDARY_FORM' => true, 'SKIP_REQUIRED' => true, 'HIDDEN' => '', 'TEXT' => '', 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url)); return do_template('WORDFILTER_SCREEN', array('_GUID' => '4b355f5d2cecc0bc26e76a69716cc841', 'TITLE' => $title, 'TPL' => $tpl, 'ADD_FORM' => $add_form)); }