Beispiel #1
0
/**
 * Get template fields to insert into a form page, for manipulation of seo fields.
 *
 * @param  ID_TEXT		The type of resource (e.g. download)
 * @param  ?ID_TEXT		The ID of the resource (NULL: adding)
 * @return tempcode		Form page tempcode fragment
 */
function seo_get_fields($type, $id = NULL)
{
    require_code('form_templates');
    if (is_null($id)) {
        list($keywords, $description) = array('', '');
    } else {
        list($keywords, $description) = seo_meta_get_for($type, $id);
    }
    $fields = new ocp_tempcode();
    if (get_value('disable_seo') !== '1' && (get_value('disable_seo') !== '2' || !is_null($id))) {
        $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $keywords == '' && $description == '', 'TITLE' => do_lang_tempcode('SEO'), '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'))))));
        $fields->attach(form_input_line_multi(do_lang_tempcode('KEYWORDS'), do_lang_tempcode('DESCRIPTION_META_KEYWORDS'), 'meta_keywords[]', array_map('trim', explode(',', preg_replace('#,+#', ',', $keywords))), 0));
        $fields->attach(form_input_line(do_lang_tempcode('META_DESCRIPTION'), do_lang_tempcode('DESCRIPTION_META_DESCRIPTION'), 'meta_description', $description, false));
    }
    return $fields;
}
Beispiel #2
0
 /**
  * The UI for recommending the site.
  *
  * @return tempcode	The UI.
  */
 function gui()
 {
     require_code('form_templates');
     global $EXTRA_HEAD;
     $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />');
     // XHTMLXHTML
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'page_title';
     $NON_CANONICAL_PARAMS[] = 'subject';
     $NON_CANONICAL_PARAMS[] = 's_message';
     $NON_CANONICAL_PARAMS[] = 'from';
     $NON_CANONICAL_PARAMS[] = 'title';
     $NON_CANONICAL_PARAMS[] = 'ocp';
     $page_title = get_param('page_title', NULL, true);
     $submit_name = !is_null($page_title) ? make_string_tempcode($page_title) : do_lang_tempcode('SEND');
     $post_url = build_url(array('page' => '_SELF', 'type' => 'actual'), '_SELF', NULL, true);
     $hidden = new ocp_tempcode();
     $name = post_param('name', is_guest() ? '' : $GLOBALS['FORUM_DRIVER']->get_username(get_member()));
     $recommender_email_address = post_param('recommender_email_address', $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member()));
     $fields = new ocp_tempcode();
     $fields->attach(form_input_line(do_lang_tempcode('YOUR_NAME'), '', 'name', $name, true));
     $fields->attach(form_input_email(do_lang_tempcode('YOUR_EMAIL_ADDRESS'), '', 'recommender_email_address', $recommender_email_address, true));
     $already = array();
     foreach ($_POST as $key => $email_address) {
         if (substr($key, 0, 14) != 'email_address_') {
             continue;
         }
         if (get_magic_quotes_gpc()) {
             $email_address = stripslashes($email_address);
         }
         $already[] = $email_address;
     }
     if (is_guest()) {
         $fields->attach(form_input_email(do_lang_tempcode('FRIEND_EMAIL_ADDRESS'), '', 'email_address_0', array_key_exists(0, $already) ? $already[0] : '', true));
     } else {
         $fields->attach(form_input_line_multi(do_lang_tempcode('FRIEND_EMAIL_ADDRESS'), do_lang_tempcode('THEIR_ADDRESS'), 'email_address_', $already, 1, NULL, 'email'));
     }
     if (may_use_invites() && get_forum_type() == 'ocf' && !is_guest()) {
         $invites = get_num_invites(get_member());
         if ($invites > 0) {
             require_lang('ocf');
             $invite = count($_POST) == 0 ? true : post_param_integer('invite', 0) == 1;
             $fields->attach(form_input_tick(do_lang_tempcode('USE_INVITE'), do_lang_tempcode('USE_INVITE_DESCRIPTION', $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member()) ? do_lang('NA_EM') : integer_format($invites)), 'invite', $invite));
         }
     }
     $message = post_param('message', NULL);
     $subject = get_param('subject', do_lang('RECOMMEND_MEMBER_SUBJECT', get_site_name()), true);
     if (is_null($message)) {
         $message = get_param('s_message', '', true);
         if ($message == '') {
             $from = get_param('from', NULL, true);
             if (!is_null($from)) {
                 $resource_title = get_param('title', '', true);
                 if ($resource_title == '') {
                     $downloaded_at_link = http_download_file($from, 3000, false);
                     if (is_string($downloaded_at_link)) {
                         $matches = array();
                         if (preg_match('#\\s*<title[^>]*\\s*>\\s*(.*)\\s*\\s*<\\s*/title\\s*>#mi', $downloaded_at_link, $matches) != 0) {
                             $resource_title = trim(str_replace('&ndash;', '-', str_replace('&mdash;', '-', @html_entity_decode($matches[1], ENT_QUOTES, get_charset()))));
                             $resource_title = preg_replace('#^' . str_replace('#', '\\#', preg_quote(get_site_name())) . ' - #', '', $resource_title);
                             $resource_title = preg_replace('#\\s+[^\\d\\s][^\\d\\s]?[^\\d\\s]?\\s+' . str_replace('#', '\\#', preg_quote(get_site_name())) . '$#i', '', $resource_title);
                         }
                     }
                 }
                 if ($resource_title == '') {
                     $resource_title = do_lang('THIS');
                     // Could not find at all, so say 'this'
                 } else {
                     $subject = get_param('subject', do_lang('RECOMMEND_MEMBER_SUBJECT_SPECIFIC', get_site_name(), $resource_title), true);
                 }
                 $message = do_lang('FOUND_THIS_ON', get_site_name(), comcode_escape($from), comcode_escape($resource_title));
             }
         }
         if (get_param_integer('ocp', 0) == 1) {
             $message = do_lang('RECOMMEND_OCPORTAL');
         }
     }
     $text = is_null($page_title) ? do_lang_tempcode('RECOMMEND_SITE_TEXT') : new ocp_tempcode();
     if (!is_null(get_param('from', NULL, true))) {
         if (is_null($page_title)) {
             $title = get_page_title('RECOMMEND_LINK');
         } else {
             $title = get_page_title($page_title, false);
         }
         $submit_name = do_lang_tempcode('SEND');
         $text = do_lang_tempcode('RECOMMEND_AUTO_TEXT', get_site_name());
         $need_message = true;
     } else {
         if (is_null($page_title)) {
             $title = get_page_title('_RECOMMEND_SITE', true, array(escape_html(get_site_name())));
         } else {
             $title = get_page_title($page_title, false);
         }
         $hidden->attach(form_input_hidden('wrap_message', '1'));
         $need_message = false;
     }
     //add an upload CSV contacts file field
     $_help_url = build_url(array('page' => 'recommend_help'), get_page_zone('recommend_help'));
     $help_url = $_help_url->evaluate();
     if (get_value('disable_csv_recommend') !== '1' && !is_guest()) {
         $fields->attach(form_input_upload(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('UPLOAD')), do_lang_tempcode('DESCRIPTION_UPLOAD_CSV_FILE', escape_html($help_url)), 'upload', false, NULL, NULL, false));
     }
     handle_max_file_size($hidden);
     $fields->attach(form_input_line(do_lang_tempcode('SUBJECT'), '', 'subject', $subject, true));
     $fields->attach(form_input_text_comcode(do_lang_tempcode('MESSAGE'), do_lang_tempcode('RECOMMEND_SUP_MESSAGE'), 'message', $message, $need_message));
     if (addon_installed('captcha')) {
         require_code('captcha');
         if (use_captcha()) {
             $fields->attach(form_input_captcha());
             $text->attach(' ');
             $text->attach(do_lang_tempcode('FORM_TIME_SECURITY'));
         }
     }
     $hidden->attach(form_input_hidden('comcode__message', '1'));
     if (get_value('disable_csv_recommend') !== '1' && !is_guest()) {
         $javascript = 'standardAlternateFields(\'upload\',\'email_address_0\');';
     } else {
         $javascript = '';
     }
     $javascript .= function_exists('captcha_ajax_check') ? captcha_ajax_check() : '';
     return do_template('FORM_SCREEN', array('_GUID' => '08a538ca8d78597b0417f464758a59fd', 'JAVASCRIPT' => $javascript, 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name, 'TEXT' => $text));
 }
 /**
  * Get form inputter.
  *
  * @param  string			The field name
  * @param  string			The field description
  * @param  array			The field details
  * @param  ?string		The actual current value of the field (NULL: none)
  * @param  boolean		Whether this is for a new entry
  * @return ?tempcode		The Tempcode for the input field (NULL: skip the field - it's not input)
  */
 function get_field_inputter($_cf_name, $_cf_description, $field, $actual_value, $new)
 {
     if (is_null($actual_value)) {
         $actual_value = '';
     }
     // Plug anomaly due to unusual corruption
     return form_input_line_multi($_cf_name, $_cf_description, 'field_' . strval($field['id']), explode(chr(10), $actual_value), $field['cf_required'] == 1 ? 1 : 0);
 }
Beispiel #4
0
 /**
  * Get tempcode for a poll adding/editing form.
  *
  * @param  SHORT_TEXT	The poll question
  * @param  ?array			A list of current answers for the poll (NULL: none yet)
  * @param  BINARY			Whether it is a private poll (blind poll, where the results aren't visible until made public)
  * @param  BINARY			Whether the poll is open for voting
  * @param  BINARY			Whether a reply to the poll topic is required before voting
  * @param  BINARY			The minimum number of selections for voters
  * @param  BINARY			The maximum number of selections for voters
  * @return tempcode		The tempcode for the fields
  */
 function get_poll_form_fields($question = '', $answers = NULL, $is_private = 0, $is_open = 1, $requires_reply = 0, $minimum_selections = 1, $maximum_selections = 1)
 {
     require_lang('polls');
     if (is_null($answers)) {
         $answers = array();
     }
     $fields = new ocp_tempcode();
     $fields->attach(form_input_line(do_lang_tempcode('QUESTION'), do_lang_tempcode('DESCRIPTION_QUESTION'), 'question', $question, true));
     $fields->attach(form_input_line_multi(do_lang_tempcode('ANSWER'), do_lang_tempcode('_DESCRIPTION_ANSWER'), 'answer_', $answers, 2));
     $options = array(array(do_lang_tempcode('POLL_IS_OPEN'), 'is_open', $is_open == 1, do_lang_tempcode('DESCRIPTION_POLL_IS_OPEN')), array(do_lang_tempcode('_POLL_REQUIRES_REPLY'), 'requires_reply', $requires_reply == 1, do_lang_tempcode('DESCRIPTION_POLL_REQUIRES_REPLY')));
     if (has_specific_permission(get_member(), 'may_unblind_own_poll') && !is_null($is_private)) {
         $options[] = array(do_lang_tempcode('POLL_IS_PRIVATE'), 'is_private', $is_private == 1, do_lang_tempcode('DESCRIPTION_POLL_IS_PRIVATE'));
     }
     $fields->attach(form_input_various_ticks($options, ''));
     $fields->attach(form_input_integer(do_lang_tempcode('MINIMUM_SELECTIONS'), do_lang_tempcode('DESCRIPTION_MINIMUM_SELECTIONS'), 'minimum_selections', $minimum_selections, true));
     $fields->attach(form_input_integer(do_lang_tempcode('MAXIMUM_SELECTIONS'), do_lang_tempcode('DESCRIPTION_MAXIMUM_SELECTIONS'), 'maximum_selections', $maximum_selections, true));
     return $fields;
 }
 /**
  * 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));
 }
Beispiel #6
0
/**
 * Outputs a Comcode tag helper dialog.
 */
function comcode_helper_script()
{
    require_lang('comcode');
    $type = get_param('type', 'step1');
    list($tag_list, $custom_tag_list) = _get_details_comcode_tags();
    require_code('comcode_text');
    global $DANGEROUS_TAGS, $TEXTUAL_TAGS;
    if ($type == 'step1') {
        $title = get_page_title('COMCODE_TAG');
        $keep = symbol_tempcode('KEEP');
        $comcode_groups = '';
        $groups = _get_group_tags();
        $non_wysiwyg_tags = _get_non_wysiwyg_tags();
        $in_wysiwyg = get_param_integer('in_wysiwyg', 0) == 1;
        foreach ($groups as $groupname => $grouptags) {
            sort($grouptags);
            $comcode_types = '';
            foreach ($grouptags as $tag) {
                $custom = array_key_exists($tag, $custom_tag_list);
                if ($in_wysiwyg && !$custom && !in_array($tag, $non_wysiwyg_tags)) {
                    continue;
                }
                if (array_key_exists($tag, $DANGEROUS_TAGS) && !has_specific_permission(get_member(), 'comcode_dangerous')) {
                    continue;
                }
                if ($custom) {
                    $description = make_string_tempcode(escape_html(is_integer($custom_tag_list[$tag]['tag_description']) ? get_translated_text($custom_tag_list[$tag]['tag_description']) : $custom_tag_list[$tag]['tag_description']));
                } else {
                    $description = do_lang_tempcode('COMCODE_TAG_' . $tag);
                }
                $url = find_script('comcode_helper') . '?type=step2&tag=' . urlencode($tag) . '&field_name=' . get_param('field_name') . $keep->evaluate();
                if (get_param('utheme', '') != '') {
                    $url .= '&utheme=' . get_param('utheme');
                }
                $link_caption = escape_html($tag);
                $usage = '';
                $comcode_types .= static_evaluate_tempcode(do_template('BLOCK_HELPER_BLOCK_CHOICE', array('USAGE' => $usage, 'DESCRIPTION' => $description, 'URL' => $url, 'LINK_CAPTION' => $link_caption)));
            }
            if ($comcode_types != '') {
                $comcode_groups .= static_evaluate_tempcode(do_template('BLOCK_HELPER_BLOCK_GROUP', array('IMG' => NULL, 'TITLE' => do_lang_tempcode('COMCODE_GROUP_' . $groupname), 'LINKS' => $comcode_types)));
            }
        }
        $content = do_template('BLOCK_HELPER_START', array('_GUID' => 'd2d6837cdd8b19d80ea95ab9f5d09c9a', 'GET' => true, 'TITLE' => $title, 'LINKS' => $comcode_groups));
    } elseif ($type == 'step2') {
        require_code('form_templates');
        $actual_tag = get_param('tag');
        if (!isset($tag_list[$actual_tag]) && !isset($custom_tag_list[$actual_tag])) {
            warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
        }
        $tag = $actual_tag;
        if ($tag == 'attachment_safe') {
            $tag = 'attachment';
        }
        $title = get_page_title('_COMCODE_HELPER', true, array($tag));
        $fields = new ocp_tempcode();
        $fields_advanced = new ocp_tempcode();
        $done_tag_contents = false;
        $hidden = new ocp_tempcode();
        $javascript = '';
        $preview = true;
        require_code('comcode_text');
        $defaults = parse_single_comcode_tag(get_param('parse_defaults', '', true), $actual_tag);
        $default_embed = array_key_exists('', $defaults) ? '[semihtml]' . $defaults[''] . '[/semihtml]' : get_param('default', '');
        $embed_required = true;
        if ($tag == 'contents') {
            $embed_required = false;
        }
        if (isset($custom_tag_list[$tag]['tag_description'])) {
            $tag_description = protect_from_escaping($custom_tag_list[$tag]['tag_description']);
        } else {
            $tag_description = protect_from_escaping(do_lang('COMCODE_TAG_' . $tag));
        }
        if (array_key_exists($tag, $tag_list)) {
            $params = $tag_list[$tag];
            if ($tag == 'include') {
                $default_embed = array_key_exists('', $defaults) ? $defaults[''] : get_param('default', '');
                if (strpos($default_embed, ':') === false) {
                    $default_embed = ':' . $default_embed;
                }
                $fields->attach(form_input_page_link(do_lang_tempcode('PAGE'), '', 'tag_contents', $default_embed, true, NULL, 'comcode'));
                $done_tag_contents = true;
            } elseif ($tag == 'concepts') {
                foreach ($params as $param) {
                    $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                    $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), 1));
                }
            } elseif ($tag == 'jumping') {
                foreach ($params as $param) {
                    $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                    $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), 2));
                }
            } elseif ($tag == 'shocker') {
                foreach ($params as $param) {
                    $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                    if ($param == 'left' || $param == 'right') {
                        $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), 2));
                    } else {
                        $fields->attach(form_input_line(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, '', false));
                    }
                }
            } elseif ($tag == 'random') {
                foreach ($params as $param) {
                    $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                    $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), $param != 'X' ? 2 : 0));
                }
            } elseif ($tag == 'sections') {
                foreach ($params as $param) {
                    if ($param == 'default') {
                        $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                        $default = array_key_exists($param, $defaults) ? $defaults[$param] : get_param('default_' . $param, '1');
                        $fields->attach(form_input_integer(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, intval($default), false));
                    } elseif ($param == 'name') {
                        $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                        $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), 2));
                    }
                }
            } elseif ($tag == 'big_tabs') {
                foreach ($params as $param) {
                    if ($param == 'default') {
                        $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                        $default = array_key_exists($param, $defaults) ? $defaults[$param] : get_param('default_' . $param, '1');
                        $fields->attach(form_input_integer(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, intval($default), false));
                    } elseif ($param == 'name') {
                        $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                        $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), 2));
                    } elseif ($param == 'switch_time') {
                        $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                        $default = array_key_exists($param, $defaults) ? $defaults[$param] : get_param('default_' . $param, '6000');
                        $fields->attach(form_input_integer(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, intval($default), false));
                    }
                }
            } elseif ($tag == 'tabs') {
                foreach ($params as $param) {
                    if ($param == 'default') {
                        $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                        $default = array_key_exists($param, $defaults) ? $defaults[$param] : get_param('default_' . $param, '1');
                        $fields->attach(form_input_integer(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, intval($default), false));
                    } elseif ($param == 'name') {
                        $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                        $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), 2));
                    }
                }
            } else {
                if (count($params) > 0) {
                    require_code('form_templates');
                    foreach ($params as $param) {
                        $parameter_name = do_lang('COMCODE_TAG_' . $tag . '_NAME_OF_PARAM_' . $param, NULL, NULL, NULL, NULL, false);
                        if (is_null($parameter_name)) {
                            $parameter_name = ucwords(str_replace('_', ' ', $param));
                        }
                        $descriptiont = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                        $supports_comcode = strpos($descriptiont, do_lang('BLOCK_IND_SUPPORTS_COMCODE')) !== false;
                        $descriptiont = trim(str_replace(do_lang('BLOCK_IND_SUPPORTS_COMCODE'), '', $descriptiont));
                        $is_advanced = strpos($descriptiont, do_lang('BLOCK_IND_ADVANCED')) !== false;
                        $descriptiont = trim(str_replace(do_lang('BLOCK_IND_ADVANCED'), '', $descriptiont));
                        $default = array_key_exists($param, $defaults) ? $defaults[$param] : get_param('default_' . $param, '');
                        if (!array_key_exists($param, $defaults)) {
                            $matches = array();
                            if (preg_match('#' . do_lang('BLOCK_IND_DEFAULT') . ': ["\']([^"]*)["\']#Ui', $descriptiont, $matches) != 0) {
                                $default = $matches[1];
                            }
                        }
                        $descriptiont = preg_replace('#\\s*' . do_lang('BLOCK_IND_DEFAULT') . ': ["\']([^"]*)["\'](?-U)\\.?(?U)#Ui', '', $descriptiont);
                        if ($tag == 'page' && $param == 'param' && substr_count($default, ':') == 1) {
                            $fields->attach(form_input_page_link($parameter_name, protect_from_escaping($descriptiont), $param, $default, true, NULL));
                        } elseif ($tag == 'attachment' && $param == 'thumb_url' && addon_installed('filedump')) {
                            $field = form_input_tree_list(do_lang_tempcode('THUMBNAIL'), do_lang_tempcode('COMCODE_TAG_attachment_PARAM_thumb_url'), 'thumb_url', '', 'choose_filedump_file', array('only_images' => true), false, $default, false);
                            $fields_advanced->attach($field);
                        } else {
                            if (substr($descriptiont, 0, 12) == '0|1 &ndash; ') {
                                $field = form_input_tick($parameter_name, protect_from_escaping(ucfirst(substr($descriptiont, 12))), $param, $default == '1');
                            } elseif (substr($descriptiont, -1) != '.' && strpos($descriptiont, '|') !== false) {
                                $list = new ocp_tempcode();
                                if (substr($descriptiont, 0, 1) != '=') {
                                    $list->attach(form_input_list_entry(''));
                                }
                                foreach (explode('|', $descriptiont) as $item) {
                                    if (strpos($item, '=') !== false) {
                                        list($item, $label) = explode('=', $item, 2);
                                        // Simplify the choices
                                        if ($tag == 'attachment') {
                                            if ($item == 'inline_extract' && get_param_integer('is_archive', NULL) === 0) {
                                                continue;
                                            }
                                            if ($item == 'island_extract' && get_param_integer('is_archive', NULL) === 0) {
                                                continue;
                                            }
                                            if ($item == 'inline' && get_param_integer('is_image', NULL) === 0) {
                                                continue;
                                            }
                                            if ($item == 'island' && get_param_integer('is_image', NULL) === 0) {
                                                continue;
                                            }
                                            if ($item == 'code' && (get_param_integer('is_image', NULL) === 1 || get_param_integer('is_archive', NULL) === 1)) {
                                                continue;
                                            }
                                            if ($item == 'mail' && get_param('default_type', NULL) !== NULL) {
                                                continue;
                                            }
                                        }
                                        $list->attach(form_input_list_entry($item, $item == $default, protect_from_escaping($label)));
                                    } else {
                                        $list->attach(form_input_list_entry($item, $item == $default));
                                    }
                                }
                                $field = form_input_list($parameter_name, '', $param, $list, NULL, false, false);
                            } elseif ($param == 'width' || $param == 'height') {
                                $field = form_input_integer($parameter_name, protect_from_escaping($descriptiont), $param, $default == '' ? NULL : intval($default), false);
                            } else {
                                if ($supports_comcode) {
                                    $field = form_input_line_comcode($parameter_name, protect_from_escaping($descriptiont), $param, $default, false);
                                } else {
                                    $field = form_input_line($parameter_name, protect_from_escaping($descriptiont), $param, $default, false);
                                }
                            }
                            if ($is_advanced) {
                                $fields_advanced->attach($field);
                            } else {
                                $fields->attach($field);
                            }
                        }
                    }
                    if ($tag == 'attachment') {
                        if (get_option('eager_wysiwyg') == '0') {
                            $field = form_input_tick(do_lang_tempcode('COMCODE_TAG_attachment_safe'), do_lang_tempcode('COMCODE_TAG_attachment_safe_DESCRIPTION'), '_safe', $actual_tag == 'attachment_safe' || $actual_tag == 'attachment2');
                            $fields_advanced->attach($field);
                        }
                    }
                }
            }
        } else {
            $_params = $custom_tag_list[$tag];
            $params = explode(',', $_params['tag_parameters']);
            foreach ($params as $param) {
                $description = new ocp_tempcode();
                $fields->attach(form_input_line(preg_replace('#=.*$#', '', ucwords(str_replace('_', ' ', $param))), protect_from_escaping($description), preg_replace('#=.*$#', '', $param), preg_replace('#^.*=#U', '', $param), false));
            }
            $tag_description = new ocp_tempcode();
            $tag_description->attach(is_integer($_params['tag_description']) ? get_translated_text($_params['tag_description']) : $_params['tag_description']);
            $tag_description->attach(paragraph(is_integer($_params['tag_example']) ? get_translated_text($_params['tag_example']) : $_params['tag_example']));
        }
        if ($tag == 'attachment') {
            if (get_option('eager_wysiwyg') == '0') {
                $javascript .= "document.getElementById('type').onchange=function() { document.getElementById('_safe').checked=(this.options[this.selectedIndex].value=='inline'); };";
            }
            if ($default_embed != '' || !addon_installed('filedump')) {
                $hidden->attach(form_input_hidden('tag_contents', $default_embed));
                $tag_description = new ocp_tempcode();
                if (substr($default_embed, 0, 4) == 'new_') {
                    $preview = NULL;
                }
            } else {
                $filedump_url = build_url(array('page' => 'filedump'), get_module_zone('filedump'));
                $fields->attach(form_input_tree_list(do_lang_tempcode('FILE'), do_lang_tempcode('COMCODE_TAG_attachment_EMBED_FILE', escape_html($filedump_url->evaluate())), 'tag_contents', '', 'choose_filedump_file', array('attachment_ready' => true), true, '', false));
            }
        } elseif ($tag == 'sections' || $tag == 'big_tabs' || $tag == 'tabs' || $tag == 'list') {
            $fields->attach(form_input_text_multi(do_lang_tempcode('TAG_CONTENTS'), protect_from_escaping(do_lang('COMCODE_TAG_' . $tag . '_EMBED')), 'tag_contents', explode(',', $default_embed), 2));
        } elseif (array_key_exists($tag, $TEXTUAL_TAGS) || $tag == 'menu') {
            if ($tag == 'menu' && $default_embed == '') {
                $default_embed = '-contracted section
 +expanded section
  page = URL
  page = URL
+expanded section
 page = URL
 page = URL';
            }
            $descriptiont = do_lang('COMCODE_TAG_' . $tag . '_EMBED');
            $descriptiont = trim(str_replace(do_lang('BLOCK_IND_SUPPORTS_COMCODE'), '', $descriptiont));
            $fields->attach(form_input_text_comcode(do_lang_tempcode('TAG_CONTENTS'), protect_from_escaping(do_lang('COMCODE_TAG_' . $tag . '_EMBED')), 'tag_contents', $default_embed, $embed_required, NULL, true));
        } else {
            if (!$done_tag_contents) {
                $descriptiont = do_lang('COMCODE_TAG_' . $tag . '_EMBED', NULL, NULL, NULL, NULL, false);
                if (is_null($descriptiont)) {
                    $descriptiont = '';
                }
                $supports_comcode = strpos($descriptiont, do_lang('BLOCK_IND_SUPPORTS_COMCODE')) !== false;
                $descriptiont = trim(str_replace(do_lang('BLOCK_IND_SUPPORTS_COMCODE'), '', $descriptiont));
                if ($supports_comcode) {
                    $fields->attach(form_input_line_comcode(do_lang_tempcode('TAG_CONTENTS'), protect_from_escaping($descriptiont), 'tag_contents', $default_embed, $embed_required));
                } else {
                    $fields->attach(form_input_line(do_lang_tempcode('TAG_CONTENTS'), protect_from_escaping($descriptiont), 'tag_contents', $default_embed, $embed_required));
                }
            }
        }
        if (!$fields_advanced->is_empty()) {
            $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('ADVANCED'))));
            $fields->attach($fields_advanced);
        }
        $keep = symbol_tempcode('KEEP');
        $post_url = find_script('comcode_helper') . '?type=step3&field_name=' . get_param('field_name') . $keep->evaluate();
        if (get_param('utheme', '') != '') {
            $post_url .= '&utheme=' . get_param('utheme');
        }
        if (get_param('save_to_id', '') != '') {
            $post_url .= '&save_to_id=' . urlencode(get_param('save_to_id'));
            $submit_name = do_lang_tempcode('SAVE');
            // Allow remove option
            $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => false, 'TITLE' => do_lang_tempcode('ACTIONS'), 'HELP' => '')));
            $fields->attach(form_input_tick(do_lang_tempcode('REMOVE'), '', '_delete', false));
        } else {
            $submit_name = do_lang_tempcode('USE');
        }
        $text = $tag_description->is_empty() ? new ocp_tempcode() : do_lang_tempcode('COMCODE_HELPER_2', escape_html($tag), $tag_description);
        $hidden->attach(form_input_hidden('tag', $tag));
        $content = do_template('FORM_SCREEN', array('_GUID' => '270058349d048a8be6570bba97c81fa2', 'TITLE' => $title, 'JAVASCRIPT' => $javascript, 'TARGET' => '_self', 'SKIP_VALIDATION' => true, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name, 'HIDDEN' => $hidden, 'PREVIEW' => $preview, 'THEME' => $GLOBALS['FORUM_DRIVER']->get_theme()));
    } elseif ($type == 'step3') {
        require_javascript('javascript_posting');
        require_javascript('javascript_editing');
        $field_name = get_param('field_name');
        $tag = post_param('tag');
        $title = get_page_title('_COMCODE_HELPER', true, array($tag));
        if (get_option('eager_wysiwyg') == '0') {
            if ($tag == 'attachment' && post_param_integer('_safe', 0) == 1) {
                $tag = 'attachment_safe';
            }
        }
        list($comcode, $bparameters) = _get_preview_environment_comcode($tag);
        if ($tag == 'sections' || $tag == 'big_tabs' || $tag == 'tabs' || $tag == 'list') {
            $comcode_xml = $bparameters;
        } else {
            $comcode_xml = '<' . $tag . $bparameters . '>' . post_param('tag_contents', '') . '</' . $tag . '>';
        }
        $comcode_semihtml = comcode_to_tempcode($comcode, NULL, false, 60, NULL, NULL, true, false, false);
        $content = do_template('BLOCK_HELPER_DONE', array('TITLE' => $title, 'FIELD_NAME' => $field_name, 'BLOCK' => $tag, 'COMCODE_XML' => $comcode_xml, 'COMCODE' => $comcode, 'COMCODE_SEMIHTML' => $comcode_semihtml));
    }
    $content->handle_symbol_preprocessing();
    $echo = do_template('POPUP_HTML_WRAP', array('TITLE' => do_lang_tempcode('COMCODE_HELPER'), 'EXTRA_HEAD' => $GLOBALS['EXTRA_HEAD'], 'EXTRA_FOOT' => $GLOBALS['EXTRA_FOOT'], 'CONTENT' => $content));
    exit($echo->evaluate());
    $echo->handle_symbol_preprocessing();
    $echo->evaluate_echo();
}
Beispiel #7
0
 /**
  * Get a form to edit/send/delete an email.
  *
  * @return tempcode	The result of execution.
  */
 function edit()
 {
     $title = get_page_title('HANDLE_QUEUED_MESSAGE');
     $id = get_param_integer('id');
     $fields = new ocp_tempcode();
     require_code('form_templates');
     $rows = $GLOBALS['SITE_DB']->query_select('logged_mail_messages', array('*'), array('id' => $id));
     if (!array_key_exists(0, $rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $row = $rows[0];
     $from_email = $row['m_from_email'];
     if ($from_email == '') {
         $from_email = get_option('staff_address');
     }
     $from_name = $row['m_from_name'];
     if ($from_name == '') {
         $from_name = get_site_name();
     }
     $to_email = unserialize($row['m_to_email']);
     if (is_string($to_email)) {
         $to_email = array($to_email);
     }
     if (!array_key_exists(0, $to_email)) {
         $to_email[0] = get_option('staff_address');
     }
     $to_name = unserialize($row['m_to_name']);
     if (is_null($to_name) || $to_name == array(NULL) || $to_name == array('')) {
         $to_name = array(get_site_name());
     }
     if (is_string($to_name)) {
         $to_name = array($to_name);
     }
     if (!array_key_exists(0, $to_name)) {
         $to_name[0] = get_site_name();
     }
     $fields->attach(form_input_line_comcode(do_lang_tempcode('SUBJECT'), '', 'subject', $row['m_subject'], true));
     $fields->attach(form_input_email(do_lang_tempcode('FROM_EMAIL'), '', 'from_email', $from_email, false));
     $fields->attach(form_input_line(do_lang_tempcode('FROM_NAME'), '', 'from_name', $from_name, false));
     $fields->attach(form_input_line_multi(do_lang_tempcode('TO_EMAIL'), '', 'to_email_', $to_email, 1));
     $fields->attach(form_input_line_multi(do_lang_tempcode('TO_NAME'), '', 'to_name', $to_name, 1));
     $fields->attach(form_input_text_comcode(do_lang_tempcode('MESSAGE'), '', 'message', $row['m_message'], true));
     $radios = new ocp_tempcode();
     $radios->attach(form_input_radio_entry('action', 'edit', true, do_lang_tempcode('EDIT')));
     $radios->attach(form_input_radio_entry('action', 'send', false, do_lang_tempcode('EDIT_AND_SEND')));
     $radios->attach(form_input_radio_entry('action', 'delete', false, do_lang_tempcode('DELETE')));
     $fields->attach(form_input_radio(do_lang_tempcode('ACTION'), '', 'action', $radios, true));
     $submit_name = do_lang_tempcode('PROCEED');
     $post_url = build_url(array('page' => '_SELF', 'type' => '_edit', 'id' => $id), '_SELF');
     return do_template('FORM_SCREEN', array('SKIP_VALIDATION' => true, 'HIDDEN' => '', 'TITLE' => $title, 'TEXT' => '', 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name));
 }