Example #1
0
 /**
  * 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]));
 }
Example #2
0
 /**
  * Standard modular render function for profile tabs edit hooks.
  *
  * @param  MEMBER			The ID of the member who is being viewed
  * @param  MEMBER			The ID of the member who is doing the viewing
  * @param  boolean		Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later
  * @return ?array			A tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set)
  */
 function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false)
 {
     $title = do_lang_tempcode('SIGNATURE');
     $order = 40;
     // Actualiser
     $new_signature = post_param('signature', NULL);
     if ($new_signature !== NULL) {
         require_code('ocf_members_action');
         require_code('ocf_members_action2');
         ocf_member_choose_signature($new_signature, $member_id_of);
         require_code('autosave');
         clear_ocp_autosave();
         attach_message(do_lang_tempcode('SUCCESS_SAVE'), 'inform');
     }
     if ($leave_to_ajax_if_possible) {
         return NULL;
     }
     // UI
     $_signature = get_translated_tempcode($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_signature'), $GLOBALS['FORUM_DB']);
     $signature = $_signature->is_empty() ? do_lang_tempcode('NONE_EM') : $_signature;
     $_signature_original = get_translated_text($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_signature'), $GLOBALS['FORUM_DB']);
     $size = ocf_get_member_best_group_property($member_id_of, 'max_sig_length_comcode');
     $javascript = "\n\t\t\tvar form=document.getElementById('signature').form;\n\t\t\tform.old_submit=form.onsubmit;\n\t\t\tform.onsubmit=function()\n\t\t\t\t{\n\t\t\t\t\tvar post=form.elements['signature'];\n\t\t\t\t\tif ((!post.value) && (post[1])) post=post[1];\n\t\t\t\t\tif (post.value.length>" . strval($size) . ")\n\t\t\t\t\t{\n\t\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('SIGNATURE_TOO_BIG')) . "');\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\t\treturn true;\n\t\t\t\t};\n\t\t";
     require_code('form_templates');
     $required = false;
     $has_preview = true;
     require_lang('javascript');
     require_javascript('javascript_posting');
     require_javascript('javascript_editing');
     require_javascript('javascript_ajax');
     require_javascript('javascript_swfupload');
     require_css('swfupload');
     require_lang('comcode');
     $tabindex = get_form_field_tabindex();
     $post_comment = do_lang_tempcode('SIGNATURE');
     list($attachments, $attach_size_field) = get_attachments('signature');
     $hidden_fields = new ocp_tempcode();
     $hidden_fields->attach($attach_size_field);
     $continue_url = get_self_url();
     $comcode_help = build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false));
     $emoticon_chooser = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser();
     $comcode_editor = get_comcode_editor();
     $comcode_editor_small = get_comcode_editor('signature', true);
     $w = has_js() && (browser_matches('wysiwyg') && strpos($_signature_original, '{$,page hint: no_wysiwyg}') === false);
     $class = '';
     global $JAVASCRIPT, $WYSIWYG_ATTACHED;
     if (!$WYSIWYG_ATTACHED) {
         $JAVASCRIPT->attach(do_template('HTML_EDIT'));
     }
     $WYSIWYG_ATTACHED = true;
     @header('Content-type: text/html; charset=' . get_charset());
     if ($w) {
         $class .= ' wysiwyg';
     }
     global $LAX_COMCODE;
     $temp = $LAX_COMCODE;
     $LAX_COMCODE = true;
     $GLOBALS['COMCODE_PARSE_URLS_CHECKED'] = 100;
     // Little hack to stop it checking any URLs
     /*if (is_null($default_parsed)) */
     $default_parsed = comcode_to_tempcode($_signature_original, NULL, false, 60, NULL, NULL, true);
     $LAX_COMCODE = $temp;
     $fields = new ocp_tempcode();
     $fields->attach(do_template('POSTING_FIELD', array('PRETTY_NAME' => do_lang_tempcode('SIGNATURE'), 'DESCRIPTION' => '', 'HIDDEN_FIELDS' => $hidden_fields, 'NAME' => 'signature', 'REQUIRED' => $required, 'TABINDEX_PF' => strval($tabindex), 'COMCODE_EDITOR' => $comcode_editor, 'COMCODE_EDITOR_SMALL' => $comcode_editor_small, 'CLASS' => $class, 'COMCODE_URL' => build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false)), 'EXTRA' => '', 'POST_COMMENT' => $post_comment, 'EMOTICON_CHOOSER' => $emoticon_chooser, 'COMCODE_HELP' => $comcode_help, 'POST' => $_signature_original, 'DEFAULT_PARSED' => $default_parsed, 'CONTINUE_URL' => $continue_url, 'ATTACHMENTS' => $attachments)));
     $text = do_template('OCF_EDIT_SIGNATURE_TAB', array('_GUID' => 'f5f2eb2552c34840c9cf46886422401e', 'SIZE' => integer_format($size), 'SIGNATURE' => $signature, 'TITLE' => $title));
     return array($title, $fields, $text, $javascript, $order);
 }
Example #3
0
 /**
  * Get form inputter.
  *
  * @param  string			The field name
  * @param  string			The field description
  * @param  array			The field details
  * @param  ?string		The actual current value of the field (NULL: none)
  * @param  boolean		Whether this is for a new entry
  * @param  boolean		Whether this is the last field in the catalogue
  * @return ?tempcode		The Tempcode for the input field (NULL: skip the field - it's not input)
  */
 function get_field_inputter($_cf_name, $_cf_description, $field, $actual_value, $new, $last = true)
 {
     if (is_null($actual_value)) {
         $actual_value = '';
     }
     // Plug anomaly due to unusual corruption
     require_lang('javascript');
     require_javascript('javascript_posting');
     require_javascript('javascript_editing');
     require_javascript('javascript_ajax');
     require_javascript('javascript_swfupload');
     require_css('swfupload');
     require_lang('comcode');
     $tabindex = get_form_field_tabindex();
     $actual_value = filter_form_field_default($_cf_name, $actual_value);
     list($attachments, $attach_size_field) = get_attachments('field_' . strval($field['id']));
     $hidden_fields = new ocp_tempcode();
     $hidden_fields->attach($attach_size_field);
     $comcode_help = build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false));
     $emoticon_chooser = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser('field_' . strval($field['id']));
     $comcode_editor = get_comcode_editor('field_' . strval($field['id']));
     $comcode_editor_small = get_comcode_editor('field_' . strval($field['id']), true);
     $w = has_js() && (browser_matches('wysiwyg') && strpos($actual_value, '{$,page hint: no_wysiwyg}') === false);
     $class = '';
     global $JAVASCRIPT, $WYSIWYG_ATTACHED;
     if (!$WYSIWYG_ATTACHED) {
         $JAVASCRIPT->attach(do_template('HTML_EDIT'));
     }
     $WYSIWYG_ATTACHED = true;
     @header('Content-type: text/html; charset=' . get_charset());
     if ($w) {
         $class .= ' wysiwyg';
     }
     global $LAX_COMCODE;
     $temp = $LAX_COMCODE;
     $LAX_COMCODE = true;
     $GLOBALS['COMCODE_PARSE_URLS_CHECKED'] = 100;
     // Little hack to stop it checking any URLs
     /*if (is_null($default_parsed)) */
     $default_parsed = comcode_to_tempcode($actual_value, NULL, false, 60, NULL, NULL, true);
     $LAX_COMCODE = $temp;
     $attachments_done = true;
     $ret = do_template('POSTING_FIELD', array('REQUIRED' => $field['cf_required'] == 1, 'DESCRIPTION' => $_cf_description, 'HIDDEN_FIELDS' => $hidden_fields, 'PRETTY_NAME' => $_cf_name, 'NAME' => 'field_' . strval($field['id']), 'TABINDEX_PF' => strval($tabindex), 'COMCODE_EDITOR' => $comcode_editor, 'COMCODE_EDITOR_SMALL' => $comcode_editor_small, 'CLASS' => $class, 'COMCODE_URL' => build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false)), 'EMOTICON_CHOOSER' => $emoticon_chooser, 'COMCODE_HELP' => $comcode_help, 'POST' => $actual_value, 'DEFAULT_PARSED' => $default_parsed, 'ATTACHMENTS' => $attachments));
     if (!$last) {
         $ret->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ADDITIONAL_INFO'))));
     }
     return $ret;
 }
Example #4
0
/**
 * Creates a posting form, with attachment support.
 *
 * @param  mixed			The title of the form submission button
 * @param  LONG_TEXT		The default post to put in.
 * @param  mixed			Where the form is sent (URLPATH or Tempcode).
 * @param  tempcode		A form_input_hidden buildup of hidden fields (additional parameters sent to the target URL).
 * @param  tempcode		A buildup of leading extra fields, in a format compatible with the templates used by this function.
 * @param  ?mixed			The post comment (string or Tempcode). This gives information about how you should post. (NULL: no post comment)
 * @param  string			Extra info to put on the posting form
 * @param  ?tempcode		A buildup of trailing extra fields, in a format compatible with the templates used by this function. (NULL: none)
 * @param  ?tempcode		The parsed Comcode. (NULL: calculate)
 * @param  ?string		Javascript code to include (NULL: none)
 * @param  ?integer		The tab index of the field (NULL: not specified)
 * @param  boolean		Whether this is a required input field
 * @param  boolean		Whether the form supports previewing
 * @return tempcode		The posting form
 */
function get_posting_form($submit_name, $post, $post_url, $hidden_fields, $specialisation, $post_comment = NULL, $extra = '', $specialisation2 = NULL, $default_parsed = NULL, $javascript = NULL, $tabindex = NULL, $required = true, $has_preview = true)
{
    require_lang('javascript');
    require_javascript('javascript_posting');
    require_javascript('javascript_editing');
    require_javascript('javascript_ajax');
    require_javascript('javascript_swfupload');
    require_css('swfupload');
    require_lang('comcode');
    $tabindex = get_form_field_tabindex($tabindex);
    $post = filter_form_field_default(is_object($submit_name) ? $submit_name->evaluate() : $submit_name, $post);
    if (is_null($post_comment)) {
        $post_comment = do_lang_tempcode('POST_COMMENT');
    }
    if (is_null($specialisation2)) {
        $specialisation2 = new ocp_tempcode();
    }
    list($attachments, $attach_size_field) = get_attachments('post');
    $hidden_fields->attach($attach_size_field);
    $continue_url = get_self_url();
    $comcode_help = build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false));
    $emoticon_chooser = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser();
    $comcode_editor = get_comcode_editor();
    $comcode_editor_small = get_comcode_editor('post', true);
    $w = has_js() && browser_matches('wysiwyg') && strpos($post, '{$,page hint: no_wysiwyg}') === false;
    $class = '';
    global $JAVASCRIPT, $WYSIWYG_ATTACHED;
    if (!$WYSIWYG_ATTACHED) {
        $JAVASCRIPT->attach(do_template('HTML_EDIT'));
    }
    $WYSIWYG_ATTACHED = true;
    @header('Content-type: text/html; charset=' . get_charset());
    if ($w) {
        $class .= ' wysiwyg';
    }
    global $LAX_COMCODE;
    $temp = $LAX_COMCODE;
    $LAX_COMCODE = true;
    $GLOBALS['COMCODE_PARSE_URLS_CHECKED'] = 100;
    // Little hack to stop it checking any URLs
    /*if (is_null($default_parsed)) */
    $default_parsed = @comcode_to_tempcode($post, NULL, false, 60, NULL, NULL, true);
    $LAX_COMCODE = $temp;
    return do_template('POSTING_FORM', array('_GUID' => '41259424ca13c437d5bc523ce18980fe', 'REQUIRED' => $required, 'TABINDEX_PF' => strval($tabindex), 'JAVASCRIPT' => $javascript, 'PREVIEW' => $has_preview ? true : NULL, 'COMCODE_EDITOR' => $comcode_editor, 'COMCODE_EDITOR_SMALL' => $comcode_editor_small, 'CLASS' => $class, 'COMCODE_URL' => build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false)), 'EXTRA' => $extra, 'POST_COMMENT' => $post_comment, 'EMOTICON_CHOOSER' => $emoticon_chooser, 'SUBMIT_NAME' => $submit_name, 'HIDDEN_FIELDS' => $hidden_fields, 'COMCODE_HELP' => $comcode_help, 'URL' => $post_url, 'POST' => $post, 'DEFAULT_PARSED' => $default_parsed, 'CONTINUE_URL' => $continue_url, 'ATTACHMENTS' => $attachments, 'SPECIALISATION' => $specialisation, 'SPECIALISATION2' => $specialisation2));
}