/** * The UI for managing redirects. * * @return tempcode The UI */ function gui() { $title = get_page_title('REDIRECTS'); $post_url = build_url(array('page' => '_SELF', 'type' => 'actual'), '_SELF'); $fields = new ocp_tempcode(); $rows = $GLOBALS['SITE_DB']->query_select('redirects', array('*')); $num_zones = $GLOBALS['SITE_DB']->query_value('zones', 'COUNT(*)'); require_code('zones3'); foreach ($rows as $i => $row) { $from_zones = $num_zones > 50 ? new ocp_tempcode() : nice_get_zones($row['r_from_zone']); $to_zones = $num_zones > 50 ? new ocp_tempcode() : nice_get_zones($row['r_to_zone']); $fields->attach(do_template('REDIRECTE_TABLE_REDIRECT', array('_GUID' => 'fd1ea392a98e588bb1f553464d315ef0', 'I' => strval($i), 'FROM_ZONE' => $row['r_from_zone'], 'TO_ZONE' => $row['r_to_zone'], 'TO_ZONES' => $to_zones, 'FROM_ZONES' => $from_zones, 'FROM_PAGE' => $row['r_from_page'], 'TO_PAGE' => $row['r_to_page'], 'TICKED' => $row['r_is_transparent'] == 1, 'NAME' => 'is_transparent_' . strval($i)))); } $default = explode(':', get_param('page_link', ':'), 2); $zones = $num_zones > 50 ? new ocp_tempcode() : nice_get_zones($default[0]); $new = do_template('REDIRECTE_TABLE_REDIRECT', array('_GUID' => 'cbf0eb4f745a6bf7b10e1f7d6d95d10f', 'I' => 'new', 'FROM_ZONE' => '', 'TO_ZONE' => '', 'TO_ZONES' => $zones, 'FROM_ZONES' => $zones, 'FROM_PAGE' => $default[1], 'TO_PAGE' => '', 'TICKED' => false, 'NAME' => 'is_transparent_new')); require_code('form_templates'); list($warning_details, $ping_url) = handle_conflict_resolution(); $notes = get_long_value('notes'); if (is_null($notes)) { $notes = ''; } return do_template('REDIRECTE_TABLE_SCREEN', array('_GUID' => '2a9add73f6dd0b8288c0c84fc7242763', 'NOTES' => $notes, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TITLE' => $title, 'FIELDS' => $fields, 'NEW' => $new, 'URL' => $post_url)); }
/** * The UI for managing banned IPs. * * @return tempcode The UI */ function gui() { $title = get_page_title('IP_BANS'); $lookup_url = build_url(array('page' => 'admin_lookup'), get_module_zone('admin_lookup')); $GLOBALS['HELPER_PANEL_TEXT'] = comcode_to_tempcode(do_lang('IP_BANNING_WILDCARDS', $lookup_url->evaluate())); $bans = ''; $rows = $GLOBALS['SITE_DB']->query_select('usersubmitban_ip', array('ip', 'i_descrip')); foreach ($rows as $row) { $bans .= $row['ip'] . ' ' . str_replace("\n", ' ', $row['i_descrip']) . chr(10); } $post_url = build_url(array('page' => '_SELF', 'type' => 'actual'), '_SELF'); require_code('form_templates'); list($warning_details, $ping_url) = handle_conflict_resolution(); return do_template('IPBAN_SCREEN', array('_GUID' => '963d24852ba87e9aa84e588862bcfecb', 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TITLE' => $title, 'BANS' => $bans, 'URL' => $post_url)); }
/** * Standard modular UI to edit an entry. * * @return tempcode The UI */ function _ed() { $doing = 'EDIT_' . $this->lang_type; if ($this->catalogue && get_param('catalogue_name', '') != '') { $catalogue_title = get_translated_text($GLOBALS['SITE_DB']->query_value('catalogues', 'c_title', array('c_name' => get_param('catalogue_name')))); if ($this->type_code == 'd') { $doing = do_lang('CATALOGUE_GENERIC_EDIT', escape_html($catalogue_title)); } elseif ($this->type_code == 'c') { $doing = do_lang('CATALOGUE_GENERIC_EDIT_CATEGORY', escape_html($catalogue_title)); } } $title = get_page_title($doing); //$submit_name=(strpos($doing,' ')!==false)?protect_from_escaping($doing):do_lang($doing); //if (!is_null($this->edit_submit_name)) $submit_name=$this->edit_submit_name; $submit_name = do_lang_tempcode('SAVE'); //$test=$this->choose_catalogue($title); //if (!is_null($test)) return $test; $id = mixed(); // Define type as mixed $id = $this->non_integer_id ? get_param('id', false, true) : strval(get_param_integer('id')); $map = array('page' => '_SELF', 'type' => '__e' . $this->type_code, 'id' => $id); if (get_param('catalogue_name', '') != '') { $map['catalogue_name'] = get_param('catalogue_name'); } if (!is_null(get_param('redirect', NULL))) { $map['redirect'] = get_param('redirect'); } if (!is_null(get_param('continue', NULL))) { $map['continue'] = get_param('continue'); } if (!is_null($this->upload) || $this->possibly_some_kind_of_upload) { $map['uploading'] = 1; } $post_url = build_url($map, '_SELF'); if (multi_lang() && has_actual_page_access(get_member(), 'admin_lang') && user_lang() != get_site_default_lang()) { require_code('lang2'); $switch_url = get_self_url(false, false, array('keep_lang' => get_site_default_lang())); attach_message(do_lang_tempcode('lang:EDITING_CONTENT_IN_LANGUAGE_STAFF', escape_html(lookup_language_full_name(user_lang())), escape_html(lookup_language_full_name(get_site_default_lang())), escape_html($switch_url->evaluate())), 'warn'); } if (method_exists($this, 'get_submitter')) { list($submitter, $date_and_time) = $this->get_submitter($id); } else { $submitter = NULL; $date_and_time = NULL; } if (!is_null($this->permissions_require)) { check_edit_permission($this->permissions_require, $submitter, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? NULL : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? NULL : $this->get_cat_b($id)), $this->permission_page_name); } if (!is_null($this->permissions_cat_require) && !has_category_access(get_member(), $this->permissions_cat_require, $this->get_cat($id))) { access_denied('CATEGORY_ACCESS'); } if (!is_null($this->permissions_cat_require_b) && !has_category_access(get_member(), $this->permissions_cat_require_b, $this->get_cat_b($id))) { access_denied('CATEGORY_ACCESS'); } $bits = $this->fill_in_edit_form($id); $delete_fields = new ocp_tempcode(); $all_delete_fields_given = false; $fields2 = new ocp_tempcode(); if (is_array($bits)) { $fields = $bits[0]; $hidden = $bits[1]; if (array_key_exists(2, $bits) && !is_null($bits[2])) { $delete_fields = $bits[2]; } if (array_key_exists(3, $bits) && !is_null($bits[3])) { $this->edit_text = $bits[3]; } if (array_key_exists(4, $bits) && $bits[4]) { $all_delete_fields_given = true; } if (array_key_exists(5, $bits) && !is_null($bits[5])) { $this->posting_form_text = $bits[5]; } if (array_key_exists(6, $bits) && !is_null($bits[6])) { $fields2 = $bits[6]; } if (array_key_exists(7, $bits)) { $this->posting_form_text_parsed = $bits[7]; } } else { $fields = $bits; $hidden = new ocp_tempcode(); } // Add in custom fields if ($this->has_tied_catalogue()) { require_code('fields'); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('MORE')))); append_form_custom_fields($this->award_type, $id, $fields, $hidden); } // SEO? if (!is_null($this->seo_type)) { require_code('seo2'); $fields2->attach(seo_get_fields($this->seo_type, $id)); } // Awards? if (addon_installed('awards')) { if (!is_null($this->award_type)) { require_code('awards'); $fields2->attach(get_award_fields($this->award_type, $id)); } } // Action fields / deletion options $delete_permission = true; if (!is_null($this->permissions_require)) { $delete_permission = has_delete_permission($this->permissions_require, get_member(), $submitter, is_null($this->permission_page_name) ? get_page_name() : $this->permission_page_name, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? NULL : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? NULL : $this->get_cat_b($id))); } $may_delete = (!method_exists($this, 'may_delete_this') || $this->may_delete_this($id)) && (!is_numeric($id) || intval($id) >= db_get_first_id() + $this->protect_first) && $delete_permission; // Deletion options $action_fields = new ocp_tempcode(); if ($may_delete) { if (!$all_delete_fields_given) { $action_fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false)); } if (addon_installed('points') && !is_null($submitter) && !is_null($date_and_time)) { $points_test = $GLOBALS['SITE_DB']->query_value_null_ok('gifts', 'id', array('date_and_time' => $date_and_time, 'gift_to' => $submitter, 'gift_from' => $GLOBALS['FORUM_DRIVER']->get_guest_id())); if (!is_null($points_test)) { require_lang('points'); $action_fields->attach(form_input_tick(do_lang_tempcode('REVERSE_TITLE'), do_lang_tempcode('REVERSE_TITLE_DESCRIPTION'), 'reverse_point_transaction', false)); } } $action_fields->attach($delete_fields); } if (!$this->appended_actions_already && !$action_fields->is_empty()) { $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS')))); } $fields2->attach($action_fields); if (!is_object($this->edit_text)) { $this->edit_text = make_string_tempcode(is_null($this->edit_text) ? '' : $this->edit_text); } if (!is_null($this->upload)) { if ($this->upload == 'image') { require_code('images'); $max = floatval(get_max_image_size()) / floatval(1024 * 1024); if ($max < 3.0) { require_code('files2'); $config_url = get_upload_limit_config_url(); $this->edit_text->attach(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 { require_code('files2'); $max = floatval(get_max_file_size()) / floatval(1024 * 1024); if ($max < 30.0) { $config_url = get_upload_limit_config_url(); $this->edit_text->attach(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)))); } } } if (get_param('type', '_ed') == '_edit_catalogue') { require_javascript('javascript_catalogues'); // Existing fields $field_count = 0; $c_name = get_param('id', false, true); $rows = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('*'), array('c_name' => $c_name), 'ORDER BY cf_order'); $fields_existing = new ocp_tempcode(); foreach ($rows as $i => $myrow) { $name = get_translated_text($myrow['cf_name']); $description = get_translated_text($myrow['cf_description']); $prefix = 'existing_field_' . strval($myrow['id']) . '_'; list($_fields_existing, $_fields_hidden) = $this->get_field_fields($i == 0 && substr($c_name, 0, 1) != '_', count($rows) + 10, $prefix, $field_count, $name, $description, $myrow['cf_type'], $myrow['cf_defines_order'], $myrow['cf_visible'], $myrow['cf_searchable'], $myrow['cf_default'], $myrow['cf_required'], $myrow['cf_put_in_category'], $myrow['cf_put_in_search']); if (!is_ecommerce_catalogue($c_name) || $i > 9) { $_fields_existing->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS')))); $_fields_existing->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), $prefix . 'delete', false)); } $temp = do_template('FORM_FIELD_SET_GROUPER', array('_GUID' => '1492d973db45cbecff892ad4ac1af28f' . get_class($this), 'NAME' => $name, 'ID' => 'FIELD_' . strval($i + 1), 'FIELDS' => $_fields_existing->evaluate())); $fields_existing->attach($temp); $hidden->attach($_fields_hidden); $field_count++; } // New field $fields_new = new ocp_tempcode(); for ($i = 0; $i < 5; $i++) { list($_fields_new, $_fields_hidden) = $this->get_field_fields(false, count($rows) + 10, 'new_field_' . strval($i) . '_', $field_count); $temp = do_template('FORM_FIELD_SET_GROUPER', array('_GUID' => '8b9a632eafae003ccc6b007eefb0ce3d' . get_class($this), 'NAME' => do_lang_tempcode('NEW_FIELD', strval($i + 1)), 'ID' => 'NEW_FIELD_' . strval($i + 1), 'FIELDS' => $_fields_new->evaluate())); $fields_new->attach($temp); $hidden->attach($_fields_hidden); $field_count++; } $fields->attach($fields2); return do_template('CATALOGUE_EDITING_SCREEN', array('_GUID' => '584d7dc7c2c13939626102374f13f508' . get_class($this), 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => $this->add_text, 'URL' => $post_url, 'FIELDS' => $fields->evaluate(), 'FIELDS_EXISTING' => $fields_existing->evaluate(), 'FIELDS_NEW' => $fields_new->evaluate(), 'SUBMIT_NAME' => $submit_name, 'JAVASCRIPT' => $this->javascript)); } list($warning_details, $ping_url) = handle_conflict_resolution(); if (!is_null($this->posting_form_title)) { $posting_form = get_posting_form($submit_name, $this->posting_form_text, $post_url, $hidden, $fields, $this->posting_form_title, '', $fields2, $this->posting_form_text_parsed, $this->javascript, NULL, $this->posting_field_required); return do_template('POSTING_SCREEN', array('_GUID' => '841b9af3aa80bcab86b907e4b942786a' . get_class($this), 'PREVIEW' => $this->do_preview, 'TITLE' => $title, 'SEPARATE_PREVIEW' => $this->second_stage_preview, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TEXT' => $this->add_text, 'POSTING_FORM' => $posting_form->evaluate(), 'JAVASCRIPT' => $this->javascript)); } else { $fields->attach($fields2); return do_template('FORM_SCREEN', array('_GUID' => '2d70be34595a16c6f170d966b894bfe2' . get_class($this), 'PREVIEW' => $this->do_preview, 'SEPARATE_PREVIEW' => $this->second_stage_preview, 'TITLE' => $title, 'SKIP_VALIDATION' => $this->skip_validation, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'HIDDEN' => $hidden, 'TEXT' => $this->edit_text, 'URL' => $post_url, 'FIELDS' => $fields->evaluate(), 'SUBMIT_NAME' => $submit_name, 'JAVASCRIPT' => $this->javascript)); } }
/** * The UI for the zone editor. * * @return tempcode The UI */ function _editor() { $id = get_param('id', ''); // '' needed for short URLs if ($id == '/') { $id = ''; } $GLOBALS['EXTRA_HEAD']->attach(make_string_tempcode('<base target="_blank" />')); $nice_zone_name = $id == '' ? do_lang('_WELCOME') : $id; $title = get_page_title('_ZONE_EDITOR', true, array(escape_html($nice_zone_name))); $lang = choose_language($title, true); if (is_object($lang)) { return $lang; } require_javascript('javascript_zone_editor'); require_javascript('javascript_ajax'); require_javascript('javascript_more'); require_javascript('javascript_posting'); require_javascript('javascript_editing'); require_javascript('javascript_validation'); require_code('form_templates'); require_lang('comcode'); if (!has_js()) { // Send them to the page permissions screen $url = build_url(array('page' => '_SELF', 'type' => 'edit'), '_SELF'); require_code('site2'); assign_refresh($url, 5.0); return do_template('REDIRECT_SCREEN', array('_GUID' => '20ed5fa100b87756a77c48988ef856ae', 'URL' => $url, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('NO_JS_ADVANCED_SCREEN_ZONE_EDITOR'))); } // After completion prep/relay $_default_redirect = build_url(array('page' => ''), $id); $default_redirect = $_default_redirect->evaluate(); $post_url = build_url(array('page' => '_SELF', 'type' => '__editor', 'lang' => $lang, 'redirect' => get_param('redirect', $default_redirect), 'id' => $id), '_SELF'); // Zone editing stuff $rows = $GLOBALS['SITE_DB']->query_select('zones', array('*'), array('zone_name' => $id), '', 1); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $row = $rows[0]; $header_text = get_translated_text($row['zone_header_text'], NULL, $lang); $default_page = $row['zone_default_page']; list($fields, , ) = $this->get_form_fields(true, get_translated_text($row['zone_title'], NULL, $lang), $default_page, $header_text, $row['zone_theme'], $row['zone_wide'], $row['zone_require_session'], $row['zone_displayed_in_menu'], $id); // Page editing stuff $editor = array(); foreach (array('panel_left', $default_page, 'panel_right') as $i => $for) { $page_info = _request_page($for, $id, NULL, $lang); if ($page_info === false) { $page_info = array('COMCODE_CUSTOM', $id, $for, $lang); } $is_comcode = false; $redirecting_to = NULL; $current_for = $for; $pure = false; switch ($page_info[0]) { case 'COMCODE_CUSTOM_PURE': $pure = true; case 'COMCODE': case 'COMCODE_CUSTOM': $is_comcode = true; $type = do_lang_tempcode('COMCODE_PAGE'); break; case 'HTML': case 'HTML_CUSTOM': $type = protect_from_escaping(escape_html('HTML')); break; case 'MODULES': case 'MODULES_CUSTOM': $type = do_lang_tempcode('MODULE'); break; case 'MINIMODULES': case 'MINIMODULES_CUSTOM': $type = do_lang_tempcode('MINIMODULE'); break; case 'REDIRECT': $type = do_lang_tempcode('REDIRECT_PAGE_TO', escape_html($page_info[1]['r_to_zone']), escape_html($page_info[1]['r_to_page'])); $redirecting_to = $page_info[1]['r_to_zone']; $current_for = $page_info[1]['r_to_page']; $page_info = _request_page($current_for, $redirecting_to, NULL, $lang); if ($page_info !== false) { switch ($page_info[0]) { case 'COMCODE_CUSTOM_PURE': $pure = true; case 'COMCODE': case 'COMCODE_CUSTOM': $is_comcode = true; break; } } break; default: $type = do_lang_tempcode('UNKNOWN'); break; } $class = ''; $w = false; $current_zone = is_null($redirecting_to) ? $id : $redirecting_to; $default_parsed = NULL; if ($is_comcode) { $fullpath = zone_black_magic_filterer(($page_info[0] == 'comcode' || $pure ? get_file_base() : get_custom_file_base()) . '/' . $current_zone . '/pages/' . strtolower($page_info[0]) . '/' . $lang . '/' . $current_for . '.txt'); if (!file_exists($fullpath)) { $fullpath = zone_black_magic_filterer(($page_info[0] == 'comcode' || $pure ? get_file_base() : get_custom_file_base()) . '/' . $current_zone . '/pages/' . strtolower($page_info[0]) . '/' . get_site_default_lang() . '/' . $current_for . '.txt'); } if (file_exists($fullpath)) { $comcode = file_get_contents($fullpath, FILE_TEXT); $default_parsed = comcode_to_tempcode($comcode, NULL, false, 60, NULL, NULL, true); } else { $comcode = ''; } $edit_url = build_url(array('page' => 'cms_comcode_pages', 'type' => '_ed', 'page_link' => $current_zone . ':' . $current_for), get_module_zone('cms_comcode_pages')); // WYSIWYG? require_javascript('javascript_editing'); $w = has_js() && (browser_matches('wysiwyg') && strpos($comcode, '{$,page hint: no_wysiwyg}') === false); global $JAVASCRIPT, $WYSIWYG_ATTACHED; if (!$WYSIWYG_ATTACHED) { $JAVASCRIPT->attach(do_template('HTML_EDIT')); } $WYSIWYG_ATTACHED = true; if ($w) { @header('Content-type: text/html; charset=' . get_charset()); $class .= ' wysiwyg'; } } else { $comcode = NULL; $edit_url = new ocp_tempcode(); } $field_name = 'edit_' . $for . '_textarea'; if ($i == 1) { $settings = $fields; $comcode_editor = get_comcode_editor($field_name); } else { $settings = NULL; $button = 'block'; $comcode_editor = new ocp_tempcode(); $comcode_editor->attach(do_template('COMCODE_EDITOR_BUTTON', array('_GUID' => '0acc5dcf299325d0cf55871923148a54', 'DIVIDER' => false, 'FIELD_NAME' => $field_name, 'TITLE' => do_lang_tempcode('INPUT_COMCODE_' . $button), 'B' => $button))); $button = 'comcode'; $comcode_editor->attach(do_template('COMCODE_EDITOR_BUTTON', array('_GUID' => '1acc5dcf299325d0cf55871923148a54', 'DIVIDER' => false, 'FIELD_NAME' => $field_name, 'TITLE' => do_lang_tempcode('INPUT_COMCODE_' . $button), 'B' => $button))); } global $TEMPCODE_SETGET; if ($for == $default_page) { $TEMPCODE_SETGET['in_panel'] = '0'; } else { $TEMPCODE_SETGET['in_panel'] = '1'; } $preview = substr($page_info[0], 0, 6) == 'MODULE' ? NULL : request_page($for, false, $id, NULL, true); if (!is_null($preview)) { $_preview = $preview->evaluate(); if (!$is_comcode || strpos($comcode, '<') !== false) { require_code('xhtml'); $_preview = xhtmlise_html($_preview, true); // Fix potential errors by passing it through our XHTML fixer functions } else { $new = $_preview; if (preg_replace('#\\s+#', '', $new) != preg_replace('#\\s+#', '', $_preview)) { $_preview = $new; $_preview .= do_lang('BROKEN_XHTML_FIXED'); } } } else { $_preview = NULL; } $is_panel = substr($for, 0, 6) == 'panel_'; require_code('zones3'); $zone_list = $for == $current_for ? nice_get_zones($redirecting_to, array($id)) : new ocp_tempcode(); $editor[$for] = static_evaluate_tempcode(do_template('ZONE_EDITOR_PANEL', array('_GUID' => 'f32ac84fe18b90497acd4afa27698bf0', 'DEFAULT_PARSED' => $default_parsed, 'CLASS' => $class, 'CURRENT_ZONE' => $current_zone, 'ZONES' => $zone_list, 'COMCODE' => $comcode, 'PREVIEW' => $_preview, 'ZONE' => $id, 'ID' => $for, 'IS_PANEL' => $is_panel, 'TYPE' => $type, 'EDIT_URL' => $edit_url, 'SETTINGS' => $settings, 'COMCODE_EDITOR' => $comcode_editor))); } breadcrumb_set_parents(array(array('_SELF:_SELF:editor', do_lang_tempcode('CHOOSE')))); breadcrumb_set_self($nice_zone_name); list($warning_details, $ping_url) = handle_conflict_resolution($id); $GLOBALS['HELPER_PANEL_PIC'] = ''; $GLOBALS['HELPER_PANEL_TUTORIAL'] = ''; $GLOBALS['HELPER_PANEL_TEXT'] = ''; return do_template('ZONE_EDITOR_SCREEN', array('_GUID' => '3cb1aab6b16444484e82d22f2c8f1e9a', 'ID' => $id, 'LANG' => $lang, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TITLE' => $title, 'URL' => $post_url, 'LEFT_EDITOR' => $editor['panel_left'], 'RIGHT_EDITOR' => $editor['panel_right'], 'MIDDLE_EDITOR' => $editor[$default_page])); }
/** * The UI to edit a configuration page. * * @return tempcode The UI */ function config_category() { require_javascript('javascript_validation'); /*$GLOBALS['HELPER_PANEL_PIC']='pagepics/config'; $GLOBALS['HELPER_PANEL_TUTORIAL']='tut_adv_configuration';*/ $page = get_param('id'); $title = get_page_title(do_lang_tempcode('CONFIG_CATEGORY_' . $page), false); $post_url = build_url(array('page' => '_SELF', 'type' => 'set', 'id' => $page, 'redirect' => get_param('redirect', NULL)), '_SELF'); $category_description = do_lang_tempcode('CONFIG_CATEGORY_DESCRIPTION__' . $page); $rows = $GLOBALS['SITE_DB']->query_select('config', array('*'), array('the_page' => $page)); // Addin special ones if ($page == 'SITE') { $rows[] = array('the_name' => 'timezone', 'human_name' => 'TIME_ZONE', 'config_value' => '', 'the_type' => 'special', 'eval' => '', 'the_page' => 'SITE', 'section' => 'GENERAL', 'explanation' => '', 'shared_hosting_restricted' => 0); } /*global $M_SORT_KEY; This is a lame sort - it doesn't preserve internal order $M_SORT_KEY='section'; usort($rows,'multi_sort');*/ // Better sort $all_known_groups = array(); foreach ($rows as $myrow) { $_group = do_lang($myrow['section'], NULL, NULL, NULL, NULL, false); if (is_null($_group)) { $_group = $myrow['section']; } $_group = strtolower(trim(preg_replace('#(&.*;)|[^\\w\\d\\s]#U', '', $_group))); if (array_key_exists($_group, $all_known_groups) && $all_known_groups[$_group] != $myrow['section']) { $_group = 'std_' . $myrow['section']; } // If cat names translate to same things or are in non-latin characters like Cyrillic $all_known_groups[$_group] = $myrow['section']; } $old_rows = $rows; $rows = array(); ksort($all_known_groups); foreach ($all_known_groups as $group_codename) { foreach ($old_rows as $myrow) { if ($myrow['section'] == $group_codename) { $rows[] = $myrow; } } } // Move advanced group options to the end $rows2 = array(); foreach ($rows as $i => $row) { if ($row['section'] == 'ADVANCED') { $rows2[] = $row; unset($rows[$i]); } } $rows = array_merge($rows, $rows2); // UI hooks $ui_hooks = find_all_hooks('modules', 'admin_config'); $upload_max_filesize = ini_get('upload_max_filesize') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('upload_max_filesize'))); $post_max_size = ini_get('post_max_size') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('post_max_size'))); $groups = new ocp_tempcode(); require_code('form_templates'); $current_group = ''; $out = ''; $_groups = array(); foreach ($rows as $myrow) { if ($myrow['eval'] != '' && $myrow['the_name'] != 'detect_lang_forum') { if (defined('HIPHOP_PHP')) { require_code('hooks/systems/config_default/' . $myrow['the_name']); $hook = object_factory('Hook_config_default_' . $myrow['the_name']); if (is_null($hook->get_default())) { continue; } } else { $GLOBALS['REQUIRE_LANG_LOOP'] = 10; // LEGACY Workaround for corrupt webhost installers if (is_null(@eval($myrow['eval'] . ';'))) { continue; } // @'d in case default is corrupt, don't want it to give errors forever $GLOBALS['REQUIRE_LANG_LOOP'] = 0; // LEGACY } } $_group = do_lang($myrow['section'], NULL, NULL, NULL, NULL, false); $name = do_lang($myrow['human_name'], NULL, NULL, NULL, NULL, false); $_group_tempcode = is_null($_group) ? make_string_tempcode($myrow['section']) : do_lang_tempcode($myrow['section']); $name_tempcode = is_null($name) ? make_string_tempcode($myrow['human_name']) : do_lang_tempcode($myrow['human_name']); if (get_forum_type() == 'ocf' && $myrow['explanation'] == 'CONFIG_OPTION_forum_in_portal') { $exp_string = $myrow['explanation'] . '__ocf'; } else { $exp_string = $myrow['explanation']; } $_explanation = do_lang($exp_string, NULL, NULL, NULL, NULL, false); if (is_null($_explanation)) { $_explanation = do_lang('CONFIG_GROUP_DEFAULT_DESCRIP_' . $myrow['section'], NULL, NULL, NULL, NULL, false); if (is_null($_explanation)) { $explanation = new ocp_tempcode(); } else { $explanation = do_lang_tempcode('CONFIG_GROUP_DEFAULT_DESCRIP_' . $myrow['section']); } } else { $explanation = do_lang_tempcode($exp_string); } if ($myrow['shared_hosting_restricted'] == 1 && !is_null($GLOBALS['CURRENT_SHARE_USER'])) { continue; } if ($myrow['section'] != $current_group && $current_group != '') { $_current_group = do_lang_tempcode($current_group); $_group_description = do_lang('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize), NULL, NULL, false); if (is_null($_group_description)) { $group_description = new ocp_tempcode(); } else { $group_description = do_lang_tempcode('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize)); } $group = do_template('CONFIG_GROUP', array('_GUID' => 'af4c31daa1bc39714ab83b11bd6d3e51', 'GROUP_DESCRIPTION' => $group_description, 'GROUP_NAME' => $current_group, 'GROUP' => $out, 'CURRENT_GROUP' => $_current_group)); $groups->attach($group->evaluate()); $out = ''; } $_groups[$myrow['section']] = $_group_tempcode; switch ($myrow['the_type']) { case 'special': switch ($myrow['the_name']) { case 'timezone': $list = ''; $timezone = get_site_timezone(); foreach (get_timezone_list() as $_timezone => $timezone_nice) { $list .= static_evaluate_tempcode(form_input_list_entry($_timezone, $_timezone == $timezone, $timezone_nice)); } $out .= static_evaluate_tempcode(form_input_list(do_lang_tempcode('TIME_ZONE'), do_lang_tempcode('DESCRIPTION_TIMEZONE_SITE'), 'timezone', make_string_tempcode($list))); break; default: require_code('hooks/modules/admin_config/' . filter_naughty_harsh($myrow['the_name'])); $hook_ob = object_factory('Hook_admin_config_' . filter_naughty_harsh($myrow['the_name'])); $out .= static_evaluate_tempcode($hook_ob->run($myrow)); break; } break; case 'integer': $out .= static_evaluate_tempcode(form_input_integer($name_tempcode, $explanation, $myrow['the_name'], intval(get_option($myrow['the_name'])), false)); break; case 'line': if (strpos($myrow['the_name'], 'colour') !== false && substr(get_option($myrow['the_name']), 0, 1) == '#') { $out .= static_evaluate_tempcode(form_input_colour($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false, NULL, true)); } elseif ($myrow['the_name'] == 'currency') { $list = ''; require_code('currency'); $currencies = array_keys(get_currency_map()); foreach ($currencies as $currency) { $list .= static_evaluate_tempcode(form_input_list_entry($currency, $currency == get_option($myrow['the_name']))); } $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], make_string_tempcode($list))); } elseif ($myrow['the_name'] == 'payment_gateway') { $list = ''; $all_via = find_all_hooks('systems', 'ecommerce_via'); foreach (array_keys($all_via) as $via) { $list .= static_evaluate_tempcode(form_input_list_entry($via, $via == get_option($myrow['the_name']))); } $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], make_string_tempcode($list))); } else { /*if (strpos($myrow['the_name'],'password')!==false) password fields can't take defaults $out.=static_evaluate_tempcode(form_input_password($name_tempcode,$explanation,$myrow['the_name'],get_option($myrow['the_name']),false)); else */ $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false)); } break; case 'list': $list = ''; $_value = get_option($myrow['the_name']); $values = explode('|', $myrow['c_data']); foreach ($values as $value) { $_option_text = do_lang('CONFIG_OPTION_' . $myrow['the_name'] . '_VALUE_' . $value, NULL, NULL, NULL, NULL, false); if (!is_null($_option_text)) { $option_text = do_lang_tempcode('CONFIG_OPTION_' . $myrow['the_name'] . '_VALUE_' . $value); } else { $option_text = make_string_tempcode($value); } $list .= static_evaluate_tempcode(form_input_list_entry($value, $_value == $value, $option_text)); } $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], make_string_tempcode($list), NULL, false, false)); break; case 'transline': $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false)); break; case 'text': $out .= static_evaluate_tempcode(form_input_text($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false, NULL, true)); break; case 'transtext': $out .= static_evaluate_tempcode(form_input_text($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false, NULL, true)); break; case 'float': $out .= static_evaluate_tempcode(form_input_float($name_tempcode, $explanation, $myrow['the_name'], floatval(get_option($myrow['the_name'])), false)); break; case 'tick': $out .= static_evaluate_tempcode(form_input_tick($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']) == '1')); break; case 'date': $out .= static_evaluate_tempcode(form_input_date($name_tempcode, $explanation, $myrow['the_name'], false, false, false, intval(get_option($myrow['the_name'])), 40, intval(date('Y')) - 20, NULL, false)); break; case 'forum': case '?forum': if (get_forum_type() == 'ocf' && addon_installed('ocf_forum')) { $current_setting = get_option($myrow['the_name']); if (!is_numeric($current_setting)) { $_current_setting = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'id', array('f_name' => $current_setting)); if (is_null($_current_setting)) { if ($myrow['the_type'] == '?forum') { $current_setting = NULL; } else { $current_setting = strval(db_get_first_id()); attach_message(do_lang_tempcode('FORUM_CURRENTLY_UNSET', $name_tempcode), 'notice'); } } else { $current_setting = strval($_current_setting); } } $out .= static_evaluate_tempcode(form_input_tree_list($name_tempcode, $explanation, $myrow['the_name'], NULL, 'choose_forum', array(), false, $current_setting)); } else { $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false)); } break; case 'category': if (get_forum_type() == 'ocf') { $tmp_value = $GLOBALS['FORUM_DB']->query_value_null_ok('f_categories', 'id', array('c_title' => get_option($myrow['the_name']))); require_code('ocf_forums2'); $_list = ocf_nice_get_categories(NULL, $tmp_value); $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], $_list)); } else { $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false)); } break; case 'usergroup': if (get_forum_type() == 'ocf') { $tmp_value = $GLOBALS['FORUM_DB']->query_value_null_ok('f_groups g LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON t.id=g.g_name', 'g.id', array('text_original' => get_option($myrow['the_name']))); require_code('ocf_groups'); $_list = ocf_nice_get_usergroups($tmp_value); $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], $_list)); } else { $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false)); } break; } $current_group = $myrow['section']; } if ($out != '') { $_group_description = do_lang('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize), NULL, NULL, false); if (is_null($_group_description)) { $group_description = new ocp_tempcode(); } else { $group_description = do_lang_tempcode('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize)); } $group = do_template('CONFIG_GROUP', array('_GUID' => '84c0db86002a33a383a7c2e195dd3913', 'GROUP_DESCRIPTION' => $group_description, 'GROUP_NAME' => $current_group, 'GROUP' => $out, 'CURRENT_GROUP' => $_group_tempcode)); $groups->attach($group->evaluate()); } list($warning_details, $ping_url) = handle_conflict_resolution(); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CONFIGURATION')))); breadcrumb_set_self(do_lang_tempcode('CONFIG_CATEGORY_' . $page)); return do_template('CONFIG_CATEGORY_SCREEN', array('_GUID' => 'd01b28b71c38bbb52b6aaf877c7f7b0e', 'CATEGORY_DESCRIPTION' => $category_description, '_GROUPS' => $_groups, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TITLE' => $title, 'URL' => $post_url, 'GROUPS' => $groups, 'SUBMIT_NAME' => do_lang_tempcode('SAVE'))); }
/** * The UI to either show an existing ticket and allow a reply, or to start a new ticket. * * @return tempcode The UI */ function do_ticket() { require_lang('comcode'); $id = get_param('id', NULL); if ($id == '') { $id = NULL; } if (!is_null($id)) { $_temp = explode('_', $id); if (!isset($_temp[1])) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } // Normal topic, not a ticket! $ticket_owner = intval($_temp[0]); $ticket_id = $_temp[1]; if (is_guest()) { access_denied('NOT_AS_GUEST'); } $this->check_id($id); } else { $ticket_owner = get_member(); $ticket_id = uniqid('', true); } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('SUPPORT_TICKETS')))); $poster = ''; $new = true; $serialized_options = mixed(); $hash = mixed(); if (!is_guest() || is_null($id)) { $member = get_member(); $new = is_null($id); $num_to_show_limit = get_param_integer('max_comments', intval(get_option('comments_to_show_in_thread'))); $start = get_param_integer('start_comments', 0); if ($new) { $id = strval($member) . '_' . $ticket_id; $title = get_page_title('ADD_TICKET'); } else { $ticket_type = $GLOBALS['SITE_DB']->query_value_null_ok('tickets', 'ticket_type', array('ticket_id' => $id)); $ticket_type_text = get_translated_text($ticket_type); $ticket_type_details = get_ticket_type($ticket_type); $forum = 1; $topic_id = 1; $_ticket_type = 1; // These will be returned by reference $_comments = get_ticket_posts($id, $forum, $topic_id, $_ticket_type, $start, $num_to_show_limit); $_comments_all = get_ticket_posts($id, $forum, $topic_id, $_ticket_type); if (!is_array($_comments) || !array_key_exists(0, $_comments)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $ticket_title = $_comments[0]['title']; if ($ticket_title == '') { $ticket_title = do_lang('UNKNOWN'); } $title = get_page_title('_VIEW_SUPPORT_TICKET', true, array(escape_html($ticket_title), escape_html($ticket_type_text))); breadcrumb_set_self($ticket_title); } $ticket_page_text = comcode_to_tempcode(get_option('ticket_text'), NULL, true); $staff_details = new ocp_tempcode(); $types = $this->build_types_list(get_param('default', '')); $results_browser = NULL; if (!$new) { require_code('templates_internalise_screen'); $test_tpl = internalise_own_screen($title, 30, $_comments_all); if (is_object($test_tpl)) { return $test_tpl; } if (is_null($_comments)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } if (has_specific_permission(get_member(), 'support_operator')) { $staff_details = make_string_tempcode($GLOBALS['FORUM_DRIVER']->topic_url($topic_id, escape_html(get_option('ticket_forum_name')))); } else { $staff_details = new ocp_tempcode(); } require_code('topics'); $renderer = new OCP_Topic(); $renderer->_inject_posts_for_scoring_algorithm($_comments); $renderer->topic_id = $topic_id; // Posts $max_thread_depth = get_param_integer('max_thread_depth', intval(get_option('max_thread_depth'))); list($comments, $serialized_options, $hash) = $renderer->render_posts($num_to_show_limit, $max_thread_depth, true, $ticket_owner, array(), $forum); // Pagination if (!$renderer->is_threaded) { if (count($_comments_all) > $num_to_show_limit) { require_code('templates_results_browser'); $results_browser = results_browser(do_lang_tempcode('COMMENTS'), NULL, $start, 'start_comments', $num_to_show_limit, 'max_comments', count($_comments_all), NULL, NULL, true); } } $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $_comments[0]['date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($_comments[0]['user']), 'publisher' => '', 'modified' => '', 'type' => 'Support ticket', 'title' => $_comments[0]['title'], 'identifier' => '_SEARCH:tickets:ticket:' . $id, 'description' => '', 'image' => find_theme_image('bigicons/tickets')); // "Staff only reply" tickbox if (get_forum_type() == 'ocf' && $GLOBALS['FORUM_DRIVER']->is_staff(get_member())) { require_code('form_templates'); $staff_only = form_input_tick(do_lang('TICKET_STAFF_ONLY'), do_lang('TICKET_STAFF_ONLY_DESCRIPTION'), 'staff_only', false); } else { $staff_only = new ocp_tempcode(); } } else { $comments = new ocp_tempcode(); $staff_only = new ocp_tempcode(); $ticket_type_details = get_ticket_type(NULL); } if ($poster == '' || $GLOBALS['FORUM_DRIVER']->get_guest_id() != intval($poster)) { $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser(); require_javascript('javascript_editing'); require_javascript('javascript_validation'); require_javascript('javascript_posting'); require_javascript('javascript_swfupload'); require_css('swfupload'); require_code('form_templates'); list($attachments, $attach_size_field) = get_forum_type() == 'ocf' ? get_attachments('post') : array(NULL, NULL); if (addon_installed('captcha')) { require_code('captcha'); $use_captcha = get_option('captcha_on_feedback') == '1' && use_captcha(); if ($use_captcha) { generate_captcha(); } } else { $use_captcha = false; } $comment_form = do_template('COMMENTS_POSTING_FORM', array('_GUID' => 'aaa32620f3eb68d9cc820b18265792d7', 'JOIN_BITS' => '', 'FIRST_POST_URL' => '', 'FIRST_POST' => '', 'USE_CAPTCHA' => $use_captcha, 'ATTACHMENTS' => $attachments, 'ATTACH_SIZE_FIELD' => $attach_size_field, 'POST_WARNING' => '', 'COMMENT_TEXT' => '', 'GET_EMAIL' => is_guest(), 'EMAIL_OPTIONAL' => is_guest() && $ticket_type_details['guest_emails_mandatory'], 'GET_TITLE' => true, 'EM' => $em, 'DISPLAY' => 'block', 'COMMENT_URL' => '', 'SUBMIT_NAME' => do_lang_tempcode('MAKE_POST'), 'TITLE' => do_lang_tempcode($new ? 'CREATE_TICKET_MAKE_POST' : 'MAKE_POST'))); } else { $comment_form = new ocp_tempcode(); } $post_url = build_url(array('page' => '_SELF', 'id' => $id, 'type' => 'post', 'redirect' => get_param('redirect', NULL)), '_SELF'); require_code('form_templates'); require_code('feedback'); list($warning_details, $ping_url) = handle_conflict_resolution(NULL, true); $other_tickets = new ocp_tempcode(); $our_topic = NULL; if (!is_guest($ticket_owner)) { $tickets_of_member = get_tickets($ticket_owner, NULL, true); if (!is_null($tickets_of_member)) { foreach ($tickets_of_member as $topic) { $ticket_id = extract_topic_identifier($topic['description']); if ($id != $ticket_id) { $url = build_url(array('page' => '_SELF', 'type' => 'ticket', 'id' => $ticket_id), '_SELF'); $_title = $topic['firsttitle']; $date = get_timezoned_date($topic['lasttime']); $ticket_owner_name = $GLOBALS['FORUM_DRIVER']->get_username($ticket_owner); if (is_null($ticket_owner_name)) { $profile_link = ''; } else { $profile_link = $GLOBALS['FORUM_DRIVER']->member_profile_url($ticket_owner, false, true); } $last_poster = $topic['lastusername']; $unclosed = !$GLOBALS['FORUM_DRIVER']->is_staff($topic['lastmemberid']); $params = array('NUM_POSTS' => integer_format($topic['num'] - 1), 'CLOSED' => strval($topic['closed']), 'URL' => $url, 'TITLE' => $_title, 'DATE' => $date, 'DATE_RAW' => strval($topic['lasttime']), 'PROFILE_LINK' => $profile_link, 'LAST_POSTER' => $last_poster, 'UNCLOSED' => $unclosed); $other_tickets->attach(do_template('SUPPORT_TICKET_LINK', $params)); } else { $our_topic = $topic; } } } } $toggle_ticket_closed_url = NULL; if (get_forum_type() == 'ocf' && !$new) { $toggle_ticket_closed_url = build_url(array('page' => '_SELF', 'type' => 'toggle_ticket_closed', 'id' => $id), '_SELF'); } $map = array('page' => '_SELF', 'type' => 'ticket'); if (get_param('default', '') != '') { $map['default'] = get_param('default'); } $add_ticket_url = build_url($map, '_SELF'); return do_template('SUPPORT_TICKET_SCREEN', array('_GUID' => 'd21a9d161008c6c44fe7309a14be2c5b', 'SERIALIZED_OPTIONS' => $serialized_options, 'HASH' => $hash, 'TOGGLE_TICKET_CLOSED_URL' => $toggle_ticket_closed_url, 'CLOSED' => is_null($our_topic) ? '0' : strval($our_topic['closed']), 'OTHER_TICKETS' => $other_tickets, 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($ticket_owner), 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'NEW' => $new, 'TICKET_PAGE_TEXT' => $ticket_page_text, 'TYPES' => $types, 'STAFF_ONLY' => $staff_only, 'POSTER' => $poster, 'TITLE' => $title, 'COMMENTS' => $comments, 'COMMENT_FORM' => $comment_form, 'STAFF_DETAILS' => $staff_details, 'URL' => $post_url, 'ADD_TICKET_URL' => $add_ticket_url, 'RESULTS_BROWSER' => $results_browser)); } else { return inform_screen(get_page_title('ADD_TICKET'), do_lang_tempcode('SUCCESS')); } }
/** * The UI to edit a poll. * * @return tempcode The UI */ function edit_poll() { $topic_id = get_param_integer('id'); $poll_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_topics', 't_poll_id', array('id' => $topic_id)); if (is_null($poll_id)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $this->check_has_mod_access($topic_id); $post_url = build_url(array('page' => '_SELF', 'type' => '_edit_poll', 'id' => $poll_id), '_SELF'); $poll_info = $GLOBALS['FORUM_DB']->query_select('f_polls', array('*'), array('id' => $poll_id), '', 1); if (!array_key_exists(0, $poll_info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $poll = $poll_info[0]; $topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('*'), array('id' => $topic_id), '', 1); if (!array_key_exists(0, $topic_info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $this->handle_topic_breadcrumbs($topic_info[0]['t_forum_id'], $topic_id, $topic_info[0]['t_cache_first_title'], do_lang_tempcode('EDIT_TOPIC_POLL')); $answers = collapse_1d_complexity('pa_answer', $GLOBALS['FORUM_DB']->query_select('f_poll_answers', array('pa_answer'), array('pa_poll_id' => $poll_id))); $question = $poll['po_question']; $is_private = $poll['po_is_private']; $is_open = $poll['po_is_open']; $requires_reply = $poll['po_requires_reply']; $minimum_selections = $poll['po_minimum_selections']; $maximum_selections = $poll['po_maximum_selections']; $fields = $this->get_poll_form_fields($question, $answers, $is_private, $is_open, $requires_reply, $minimum_selections, $maximum_selections); $fields->attach(form_input_line(do_lang_tempcode('REASON'), do_lang_tempcode('DESCRIPTION_REASON'), 'reason', '', false)); $title = get_page_title('EDIT_TOPIC_POLL'); $submit_name = do_lang_tempcode('SAVE'); list($warning_details, $ping_url) = handle_conflict_resolution(); return do_template('FORM_SCREEN', array('_GUID' => '992a1bfd025e3fabea9d13307cfd2a91', 'STAFF_HELP_URL' => brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_mod', 'PREVIEW' => true, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'HIDDEN' => '', 'TITLE' => $title, 'FIELDS' => $fields, 'TEXT' => '', 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url)); }
/** * The UI to edit a menu. * * @return tempcode The UI */ function edit_menu() { if (!has_js()) { warn_exit(do_lang_tempcode('MSG_JS_NEEDED')); } $id = get_param('id', ''); if ($id == '') { $id = get_param('id_new'); } if (substr($id, 0, 1) == '_') { warn_exit(do_lang_tempcode('MENU_UNDERSCORE_RESERVED')); } require_code('type_validation'); if (!is_alphanumeric($id, true)) { warn_exit(do_lang_tempcode('BAD_CODENAME')); } if ($id == 'zone_menu' && get_option('use_custom_zone_menu') == '0') { $config_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => 'THEME'), get_module_zone('admin_config')); attach_message(do_lang_tempcode('EDITING_UNUSED_MENU', escape_html($config_url->evaluate())), 'notice'); } $title = get_page_title('_EDIT_MENU', true, array(escape_html($id))); $clickable_sections = get_param_integer('clickable_sections', 0) == 1; // This is set to '1 if we have a menu type where pop out sections may be clicked on to be loaded. If we do then we make no UI distinction between page nodes and contracted/expanded, so people don't get compelled to choose a URL for everything, it simply becomes an option for them. // This will be a templates for branches created dynamically $t_id = 'replace_me_with_random'; $branch = do_template('MENU_EDITOR_BRANCH', array('_GUID' => '59d5c9bebecdac1440112ef8301d7c67', 'CLICKABLE_SECTIONS' => $clickable_sections ? 'true' : 'false', 'I' => $t_id, 'CHILD_BRANCH_TEMPLATE' => '', 'CHILD_BRANCHES' => '')); $child_branch_template = do_template('MENU_EDITOR_BRANCH_WRAP', array('_GUID' => 'fb16265f553127b47dfdaf33a420136b', 'DISPLAY' => $clickable_sections ? 'display: block' : 'display: none', 'CLICKABLE_SECTIONS' => $clickable_sections, 'ORDER' => 'replace_me_with_order', 'PARENT' => 'replace_me_with_parent', 'BRANCH_TYPE' => '0', 'NEW_WINDOW' => '0', 'CHECK_PERMS' => '0', 'CAPTION_LONG' => '', 'CAPTION' => '', 'URL' => '', 'PAGE_ONLY' => '', 'THEME_IMG_CODE' => '', 'I' => $t_id, 'BRANCH' => $branch)); $order = 0; $menu_items = $GLOBALS['SITE_DB']->query_select('menu_items', array('*'), array('i_menu' => $id), 'ORDER BY i_parent,i_order'); $child_branches = $this->menu_branch($id, NULL, $order, $clickable_sections, $menu_items); $root_branch = do_template('MENU_EDITOR_BRANCH', array('CLICKABLE_SECTIONS' => $clickable_sections ? 'true' : 'false', 'CHILD_BRANCH_TEMPLATE' => $child_branch_template, 'CHILD_BRANCHES' => $child_branches, 'I' => '')); $map = array('page' => '_SELF', 'type' => '_edit', 'id' => $id); if (get_param('redirect', '!') != '!') { $map['redirect'] = get_param('redirect'); } $post_url = build_url($map, '_SELF'); $map = array('page' => '_SELF', 'type' => '_edit', 'id' => $id); // Actually same as edit URL, just we put this into an empty post form if (get_param('redirect', '!') != '!') { $map['redirect'] = get_param('redirect'); } $delete_url = build_url($map, '_SELF'); require_code('form_templates'); $fields_template = new ocp_tempcode(); //$fields_template->attach(form_input_line(do_lang_tempcode('CAPTION'),do_lang_tempcode('MENU_ENTRY_CAPTION'),'caption','',true)); This is editable in the tree structure instead $fields_template->attach(form_input_line(do_lang_tempcode('LINK'), do_lang_tempcode('MENU_ENTRY_URL'), 'url', '', false)); $options = array(array(do_lang_tempcode('MENU_ENTRY_NEW_WINDOW'), 'new_window', false, new ocp_tempcode()), array(do_lang_tempcode('MENU_ENTRY_CHECK_PERMS'), 'check_perms', true, do_lang_tempcode('DESCRIPTION_MENU_ENTRY_CHECK_PERMS'))); $fields_template->attach(form_input_various_ticks($options, '', NULL, do_lang_tempcode('OPTIONS'), false)); $list = new ocp_tempcode(); if (!$clickable_sections) { $list->attach(form_input_list_entry('page', false, do_lang_tempcode('PAGE'))); } $list->attach(form_input_list_entry('branch_minus', false, do_lang_tempcode('CONTRACTED_BRANCH'))); $list->attach(form_input_list_entry('branch_plus', false, do_lang_tempcode('EXPANDED_BRANCH'))); $fields_template->attach(form_input_list(do_lang_tempcode('BRANCH_TYPE'), do_lang_tempcode('MENU_ENTRY_BRANCH'), 'branch_type', $list)); $fields_template->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields_template->attach(form_input_line(do_lang_tempcode('CAPTION_LONG'), do_lang_tempcode('MENU_ENTRY_CAPTION_LONG'), 'caption_long', '', false)); $list = new ocp_tempcode(); $list->attach(form_input_list_entry('', false, do_lang_tempcode('NONE_EM'))); require_code('themes2'); $list->attach(nice_get_theme_images(NULL, NULL, false, true, 'menu_items/')); $fields_template->attach(form_input_list(do_lang_tempcode('THEME_IMAGE'), do_lang_tempcode('DESCRIPTION_THEME_IMAGE_FOR_MENU_ITEM'), 'theme_img_code', $list, NULL, false, false)); $fields_template->attach(form_input_line(do_lang_tempcode('RESTRICT_PAGE_VISIBILITY'), do_lang_tempcode('MENU_ENTRY_MATCH_KEYS'), 'match_tags', '', false)); require_javascript('javascript_ajax'); require_javascript('javascript_more'); require_javascript('javascript_tree_list'); list($warning_details, $ping_url) = handle_conflict_resolution(); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MENU_MANAGEMENT')))); $all_menus = array(); $menu_rows = $GLOBALS['SITE_DB']->query_select('menu_items', array('DISTINCT i_menu'), NULL, 'ORDER BY i_menu'); foreach ($menu_rows as $menu_row) { if ($menu_row['i_menu'] != $id) { $all_menus[] = $menu_row['i_menu']; } } return do_template('MENU_EDITOR_SCREEN', array('_GUID' => 'd2bc26eaea38f3d5b3221be903ff541e', 'ALL_MENUS' => $all_menus, 'MENU_NAME' => $id, 'DELETE_URL' => $delete_url, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'FIELDS_TEMPLATE' => $fields_template, 'HIGHEST_ORDER' => strval($order), 'URL' => $post_url, 'CHILD_BRANCH_TEMPLATE' => $child_branch_template, 'ROOT_BRANCH' => $root_branch, 'TITLE' => $title)); }
/** * The UI to choose a template to edit. * * @return tempcode The UI */ function edit_templates() { $title = get_page_title('EDIT_TEMPLATES'); $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_markup'; $GLOBALS['HELPER_PANEL_TEXT'] = comcode_lang_string('DOC_TEMPLATES'); require_javascript('javascript_ajax'); $theme = get_param('theme', ''); if ($theme == '') { return $this->choose_theme($title); } //if ((get_file_base()!=get_custom_file_base()) && ($theme=='default')) warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT')); $filesarray = $this->get_template_files_array($theme); require_code('form_templates'); $temp = form_input_list_entry('', false, do_lang_tempcode('NA_EM')); $files = ''; $stub = ''; foreach ($filesarray as $file) { if (!is_null($GLOBALS['CURRENT_SHARE_USER']) && strpos($file, 'BANNER_TYPED') !== false) { continue; } $new_stub = dirname($file); if ($stub != $new_stub) { $temp = form_input_list_entry('!' . $new_stub, false, $new_stub . ':', true, true); $files .= $temp->evaluate(); // XHTMLXHTML $stub = $new_stub; } $_file = substr($file, strrpos($file, '/') + 1); $temp = form_input_list_entry($_file, false, basename($file)); $files .= $temp->evaluate(); // XHTMLXHTML } $fields = new ocp_tempcode(); $fields->attach(form_input_multi_list(do_lang_tempcode('EXISTING'), '', 'f0file', make_string_tempcode($files), NULL, 35)); $fields->attach(form_input_line(do_lang_tempcode('SEARCH'), do_lang_tempcode('DESCRIPTION_TEMPLATES_SEARCH'), 'search', '', false)); $fields->attach(form_input_codename(do_lang_tempcode('NEW'), do_lang_tempcode('NEW_TEMPLATE'), 'f0file2', '', false)); $post_url = build_url(array('page' => '_SELF', 'type' => '_edit_templates', 'theme' => $theme), '_SELF'); $edit_form = do_template('FORM', array('_GUID' => 'b26747b4a29281baf83b31167c63582a', 'GET' => true, 'HIDDEN' => '', 'TEXT' => '', 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => do_lang_tempcode('CHOOSE'), 'JAVASCRIPT' => 'standardAlternateFields(\'f0file\',\'f0file2\',\'search\');')); list($warning_details, $ping_url) = handle_conflict_resolution(''); // Intentionally blank, because only one person should edit any of all templates at any time (because they depend on each other) breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_THEMES')))); breadcrumb_set_self(do_lang_tempcode('CHOOSE')); return do_template('TEMPLATE_MANAGE_SCREEN', array('_GUID' => '529cd009f85a84f60b7934b5e969c55b', 'THEME' => $theme, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TITLE' => $title, 'EDIT_FORM' => $edit_form)); }
/** * The UI to edit a page. * * @return tempcode The UI */ function _ed() { $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/comcode_page_edit'; require_lang('menus'); $GLOBALS['HELPER_PANEL_TEXT'] = comcode_lang_string('DOC_WRITING'); $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_comcode_pages'; $simple_add = get_param_integer('simple_add', 0) == 1; $lang = choose_language(get_page_title($simple_add ? 'COMCODE_PAGE_ADD' : 'COMCODE_PAGE_EDIT'), true); if (is_object($lang)) { return $lang; } if (addon_installed('page_management')) { // Add to menu if (get_param('menu', STRING_MAGIC_NULL) != STRING_MAGIC_NULL && has_actual_page_access(get_member(), 'admin_sitetree')) { require_code('menus2'); add_menu_item_simple(get_param('menu'), NULL, get_param('title'), get_param('page_link'), 0, 0, false); } } // Work out what we're editing, and where it's coming from (support for two pagelink specifying parameters for destination, with addition of restore_from to override source if different from destination) $page_link = filter_naughty(get_param('page_link', '')); if ($page_link == '') { $page_link = get_param('page_link_2'); } if (strpos($page_link, ':') === false) { $page_link = ':' . $page_link; } $page_link_parts = explode(':', $page_link); if (count($page_link_parts) != 2) { warn_exit(do_lang_tempcode('ZONE_COLON_FILE')); } $zone = $page_link_parts[0]; if ($zone != '' && !file_exists(get_file_base() . '/' . $zone . '/pages')) { warn_exit(do_lang_tempcode('NO_SUCH_ZONE')); } $file = $page_link_parts[1]; require_code('type_validation'); if (!is_alphanumeric($file, true)) { warn_exit(do_lang_tempcode('BAD_CODENAME')); } $resource_owner = $GLOBALS['SITE_DB']->query_value_null_ok('comcode_pages', 'p_submitter', array('the_zone' => $zone, 'the_page' => $file)); check_edit_permission('high', $resource_owner); if (is_null($resource_owner)) { check_submit_permission('high'); } $restore_from = $this->find_comcode_page($lang, $file, $zone); // Check no redirects in our way if (addon_installed('redirects_editor')) { $test = $GLOBALS['SITE_DB']->query_value_null_ok('redirects', 'r_to_zone', array('r_from_page' => $file, 'r_from_zone' => $zone)); if (!is_null($test)) { $redirect_url = build_url(array('page' => 'admin_redirects'), get_module_zone('admin_redirects')); attach_message(do_lang_tempcode('BLOCKING_REDIRECT_IN_PLACE', escape_html($redirect_url->evaluate())), 'notice'); } } $title = get_page_title($simple_add || $file == '' ? 'COMCODE_PAGE_ADD' : '_COMCODE_PAGE_EDIT', true, array(escape_html($zone), escape_html($file))); if (!$simple_add && $file != '') { breadcrumb_set_self(do_lang_tempcode('COMCODE_PAGE_EDIT')); } if (!has_actual_page_access(get_member(), $file, $zone)) { access_denied('PAGE_ACCESS'); } // Default file contents $contents = post_param('new', ''); $parsed = NULL; if ($contents == '') { $file_base = strpos($restore_from, 'comcode_custom/') ? get_custom_file_base() : get_file_base(); if (!is_file($file_base . '/' . $restore_from)) { $file_base = get_file_base(); } if (is_file($file_base . '/' . $restore_from)) { $contents = file_get_contents($file_base . '/' . $restore_from, FILE_TEXT); if (is_null(get_param('restore_from', NULL))) { $string_index = $GLOBALS['SITE_DB']->query_value_null_ok('cached_comcode_pages', 'string_index', array('the_zone' => $zone, 'the_page' => $file)); if (!is_null($string_index)) { $parsed = get_translated_tempcode($string_index, NULL, $lang); } } $new = false; } elseif (get_param('title', '') != '') { $page_pretty_title = get_param('title', ''); $contents = '[title]' . $page_pretty_title . "[/title]\n\n" . do_lang('PAGE_DEFAULT_TEXT'); $new = true; } else { $contents = '[title]' . do_lang('PAGE_DEFAULT_TITLE') . "[/title]\n\n"; $new = true; } if ($new && get_option('is_on_comcode_page_children') == '1') { $contents .= chr(10) . chr(10) . '[block]main_comcode_page_children[/block]'; } } else { $new = false; } $map = array('page' => '_SELF', 'type' => '__ed', 'wide' => 1); if ($simple_add) { $map['simple_add'] = '1'; } $post_url = build_url($map, '_SELF'); // Revision history $filesarray = $this->get_comcode_revisions($zone, 'comcode_custom/' . $lang, $file . '.txt'); rsort($filesarray); $i = 0; $revision_history = new ocp_tempcode(); $max = intval(get_option('number_revisions_show')); $last_path = $file_base . '/' . $restore_from; if (is_file($last_path)) { foreach ($filesarray as $iterator => $stuff) { list($filepath, $time) = $stuff; // Find who did the revision $editor = $GLOBALS['SITE_DB']->query_value_null_ok('adminlogs', 'the_user', array('date_and_time' => $time, 'the_type' => 'COMCODE_PAGE_EDIT', 'param_a' => $file)); if (has_specific_permission(get_member(), 'view_revision_history') || $editor == get_member()) { if (is_null($editor)) { $editor = do_lang('UNKNOWN'); } else { $editor = $GLOBALS['FORUM_DRIVER']->get_username($editor); if (is_null($editor)) { $editor = do_lang('UNKNOWN'); } } $old_file = (strpos($filepath, '_custom/') ? get_custom_file_base() : get_file_base()) . '/' . $filepath; $size = filesize($old_file); $date = get_timezoned_date($time); $url = get_custom_base_url() . '/' . $zone . '/' . 'pages/comcode_custom/' . $lang . '/' . $file . '.txt.' . strval($time); $restore_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $zone . ':' . $file, 'restore_from' => zone_black_magic_filterer($zone . ($zone != '' ? '/' : '') . 'pages/comcode_custom/' . $lang . '/' . $file . '.txt.' . strval($time), true)), '_SELF'); require_code('diff'); if (function_exists('diff_simple')) { $rendered_diff = diff_simple($old_file, $last_path); $last_path = $old_file; if ($rendered_diff == '' && $iterator == 0) { continue; } // the version records are often saved on create not replace $revision_history->attach(do_template('REVISION_HISTORY_LINE', array('_GUID' => '57e2c81fd621d1c8d6e283a5a4991001', 'REFERENCE_POINT_EXACT' => true, 'RENDERED_DIFF' => $rendered_diff, 'EDITOR' => $editor, 'DATE' => $date, 'DATE_RAW' => strval($time), 'RESTORE_URL' => $restore_url, 'URL' => $url, 'SIZE' => clean_file_size($size)))); $i++; } if ($i == $max) { break; } } } if (strpos($restore_from, '/comcode_custom/') !== false && zone_black_magic_filterer($zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt', true) != $restore_from && is_file(zone_black_magic_filterer(get_file_base() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt'))) { $url = get_base_url() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt'; $size = filesize(zone_black_magic_filterer(get_file_base() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt')); $restore_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $zone . ':' . $file, 'restore_from' => $zone . ($zone == '' ? '' : '/') . 'pages/comcode/' . $lang . '/' . $file . '.txt'), '_SELF'); require_code('diff'); if (function_exists('diff_simple')) { $rendered_diff = diff_simple(zone_black_magic_filterer(get_file_base() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt'), $last_path); $revision_history->attach(do_template('REVISION_HISTORY_LINE', array('_GUID' => 'ed0b29f26cf93d4d6e0348a7e75d259d', 'REFERENCE_POINT_EXACT' => true, 'RENDERED_DIFF' => $rendered_diff, 'RESTORE_URL' => $restore_url, 'URL' => $url, 'SIZE' => clean_file_size($size)))); $i++; } } } if (!$revision_history->is_empty() && get_param('restore_from', '') == '') { $revision_history = do_template('REVISION_HISTORY_WRAP', array('_GUID' => '2349ee62cae037ec3cf1766403c92b39', 'CONTENT' => $revision_history)); } elseif (!$revision_history->is_empty()) { $revision_history = do_template('REVISION_RESTORE'); } $meta_keywords = post_param('meta_keywords', ''); $meta_description = post_param('meta_description', ''); if ($meta_keywords == '' && $meta_description == '') { list($meta_keywords, $meta_description) = seo_meta_get_for('comcode_page', $zone . ':' . $file); } $hidden_fields = new ocp_tempcode(); if (addon_installed('page_management') && has_actual_page_access(get_member(), 'adminzone')) { $delete_url = build_url(array('page' => 'admin_sitetree', 'type' => '_delete', 'page__' . $file => 1, 'zone' => $zone), get_module_zone('admin_sitetree')); } else { $delete_url = new ocp_tempcode(); } $fields = new ocp_tempcode(); $fields2 = new ocp_tempcode(); require_code('form_templates'); if (addon_installed('page_management')) { if (has_actual_page_access(get_member(), 'admin_sitetree')) { if ($simple_add) { $hidden_fields->attach(form_input_hidden('title', $file)); } else { $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_CODENAME'), 'title', $file, true)); } } } $rows = $GLOBALS['SITE_DB']->query_select('comcode_pages', array('*'), array('the_zone' => $zone, 'the_page' => $file)); if (array_key_exists(0, $rows)) { $validated = $rows[0]['p_validated'] == 1; $parent_page = $rows[0]['p_parent_page']; $show_as_edit = $rows[0]['p_show_as_edit'] == 1; $owner = $rows[0]['p_submitter']; } else { global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'parent_page'; $validated = true; $parent_page = get_param('parent_page', ''); $show_as_edit = false; $owner = get_member(); } $_pages = find_all_pages($zone, 'comcode/' . $lang, 'txt', false, NULL, FIND_ALL_PAGES__NEWEST); $_pages += find_all_pages($zone, 'comcode_custom/' . $lang, 'txt', false, NULL, FIND_ALL_PAGES__NEWEST); $_pages += find_all_pages($zone, 'comcode/' . get_site_default_lang(), 'txt', false, NULL, FIND_ALL_PAGES__NEWEST); $_pages += find_all_pages($zone, 'comcode_custom/' . get_site_default_lang(), 'txt', false, NULL, FIND_ALL_PAGES__NEWEST); ksort($_pages); $pages = form_input_list_entry('', false, do_lang_tempcode('NA_EM')); foreach (array_keys($_pages) as $page) { if (!is_string($page)) { $page = strval($page); } if ($page != $file) { $pages->attach(form_input_list_entry($page, $parent_page == $page)); } } if (!$simple_add) { if (!$validated) { $validated = get_param_integer('validated', 0) == 1; } if (has_specific_permission(get_member(), 'bypass_validation_highrange_content')) { if (addon_installed('unvalidated')) { $fields2->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated)); } } if (!$new) { if ($delete_url->is_empty()) { $fields2->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false)); } } } else { $hidden_fields->attach(form_input_hidden('validated', '1')); } if (get_option('is_on_comcode_page_children') == '1') { $fields2->attach(form_input_list(do_lang_tempcode('PARENT_PAGE'), do_lang_tempcode('DESCRIPTION_PARENT_PAGE'), 'parent_page', $pages, NULL, false, false)); } if (!$simple_add) { $fields2->attach(form_input_tick(do_lang_tempcode('SHOW_AS_EDITED'), do_lang_tempcode('DESCRIPTION_SHOW_AS_EDITED'), 'show_as_edit', $show_as_edit)); if ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) { $fields2->attach(form_input_username(do_lang_tempcode('OWNER'), do_lang_tempcode('DESCRIPTION_OWNER'), 'owner', $GLOBALS['FORUM_DRIVER']->get_username($owner), true)); } $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('SEO'), 'SECTION_HIDDEN' => true, 'HELP' => get_option('show_docs') == '0' ? NULL : protect_from_escaping(symbol_tempcode('URLISE_LANG', array(do_lang('TUTORIAL_ON_THIS'), brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_seo', 'tut_seo', '1')))))); $fields2->attach(form_input_line_multi(do_lang_tempcode('KEYWORDS'), do_lang_tempcode('DESCRIPTION_META_KEYWORDS'), 'meta_keywords[]', array_map('trim', explode(',', preg_replace('#,+#', ',', $meta_keywords))), 0)); $fields2->attach(form_input_line(do_lang_tempcode('META_DESCRIPTION'), do_lang_tempcode('DESCRIPTION_META_DESCRIPTION'), 'meta_description', $meta_description, false)); } // Awards? if (addon_installed('awards')) { require_code('awards'); $fields2->attach(get_award_fields('comcode_page', $zone . ':' . $file)); } require_code('permissions2'); $fields2->attach(get_page_permissions_for_environment($zone, $file)); $hidden_fields->attach(form_input_hidden('file', $file)); $hidden_fields->attach(form_input_hidden('lang', $lang)); $hidden_fields->attach(form_input_hidden('zone', $zone)); $hidden_fields->attach(form_input_hidden('redirect', get_param('redirect', ''))); $posting_form = get_posting_form(do_lang($simple_add ? 'COMCODE_PAGE_ADD' : 'SAVE'), $contents, $post_url, $hidden_fields, $fields, do_lang_tempcode('COMCODE_PAGE'), '', $fields2, $parsed, NULL, NULL, false); $export_url = build_url(array('page' => '_SELF', 'type' => 'export', 'page_link' => $page_link, 'export' => $restore_from, 'lang' => $lang), '_SELF'); $text = new ocp_tempcode(); if (addon_installed('points')) { $login_url = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => get_self_url(true, true)), get_module_zone('login')); $_login_url = escape_html($login_url->evaluate()); if (is_guest() && (get_forum_type() != 'ocf' || has_actual_page_access(get_member(), 'join'))) { $text->attach(paragraph(do_lang_tempcode('NOT_LOGGED_IN_NO_CREDIT', $_login_url))); } } list($warning_details, $ping_url) = handle_conflict_resolution($page_link); if (!$simple_add) { breadcrumb_set_parents(array(array('_SELF:_SELF:misc:lang=' . $lang, do_lang_tempcode('CHOOSE')))); } return do_template('COMCODE_EDIT_SCREEN', array('_GUID' => 'ec1d773684757f5bf6f39cf931555bf2', 'NEW' => $new, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TEXT' => $text, 'TITLE' => $title, 'DELETE_URL' => $delete_url, 'ZONE' => $zone, 'FILE' => $file, 'EXPORT_URL' => $export_url, 'POSTING_FORM' => $posting_form, 'REVISION_HISTORY' => $revision_history)); }
/** * The UI for managing the CEDI children of a page. * * @return tempcode The UI. */ function edit_tree() { $title = get_page_title('CEDI_EDIT_TREE'); list($id, $chain) = get_param_cedi_chain('id'); check_specific_permission('seedy_manage_tree', array('seedy_page', $id)); if (!has_category_access(get_member(), 'seedy_page', strval($id))) { access_denied('CATEGORY_ACCESS'); } $children_entries = $GLOBALS['SITE_DB']->query_select('seedy_children', array('child_id', 'title'), array('parent_id' => $id), 'ORDER BY the_order'); $children = ''; foreach ($children_entries as $entry) { $child_id = $entry['child_id']; $child_title = $entry['title']; $children .= strval($child_id) . '!' . $child_title . "\n"; } $redir_url = get_param('redirect', NULL); if (is_null($redir_url)) { $_redir_url = build_url(array('page' => 'cedi', 'type' => 'misc', 'id' => get_param('id', false, true) == strval(db_get_first_id()) ? NULL : get_param('id', false, true)), get_module_zone('cedi')); $redir_url = $_redir_url->evaluate(); } $post_url = build_url(array('page' => '_SELF', 'id' => get_param('id', false, true), 'redirect' => $redir_url, 'type' => '_edit_tree'), '_SELF'); $cedi_tree = cedi_show_tree($id, NULL, '', true, false, true); require_code('form_templates'); list($warning_details, $ping_url) = handle_conflict_resolution(); $tree = cedi_breadcrumbs($chain, NULL, true, true); breadcrumb_add_segment($tree, do_lang_tempcode('CEDI_EDIT_TREE')); $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_text(do_lang_tempcode('CHILD_PAGES'), new ocp_tempcode(), 'children', $children, false, NULL, true)); $form = do_template('FORM', array('_GUID' => 'b908438ccfc9be6166cf7c5c81d5de8b', 'FIELDS' => $fields, 'URL' => $post_url, 'HIDDEN' => '', 'TEXT' => '', 'SUBMIT_NAME' => do_lang_tempcode('SAVE'))); return do_template('CEDI_MANAGE_TREE_SCREEN', array('_GUID' => '83da3f20799b66b8846eafa4251a5d01', 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TREE' => $tree, 'TITLE' => $title, 'FORM' => $form, 'CEDI_TREE' => $cedi_tree)); }
/** * 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)); }