/** * The UI to edit a template. * * @return tempcode The UI */ function _edit_templates() { $theme = get_param('theme'); //if ((get_file_base()!=get_custom_file_base()) && ($theme=='default')) warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT')); $title = get_page_title('EDIT_TEMPLATES'); $GLOBALS['HELPER_PANEL_TEXT'] = comcode_lang_string('DOC_MARKUP'); $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_themes'; // Searching for something, which will provide links that loop back to the proper version of this page $search = get_param('search', '', true); if ($search != '') { $filesarray = $this->get_template_files_array($theme); $results = new ocp_tempcode(); foreach ($filesarray as $file) { $full_path = (strpos($file, '/default/templates/') !== false ? get_file_base() : get_custom_file_base()) . '/themes/' . $file; $contents = file_get_contents($full_path, FILE_TEXT); if (strpos(strtolower($contents), strtolower($search)) !== false || strpos(strtolower($file), strtolower($search)) !== false) { $_url = build_url(array('page' => '_SELF', 'type' => '_edit_templates', 'theme' => $theme, 'f0file' => $file), '_SELF'); $results->attach(do_template('INDEX_SCREEN_ENTRY', array('_GUID' => 'ed744a45728f3d7c1082a3dda893f352', 'URL' => $_url, 'NAME' => $file))); } } return do_template('INDEX_SCREEN', array('_GUID' => '286a7ae3add44f935a9a2018dde3ccaf', 'TITLE' => $title, 'PRE' => do_lang_tempcode('_RESULTS'), 'POST' => '', 'CONTENT' => $results)); } require_javascript('javascript_editing'); $post_url = build_url(array('page' => '_SELF', 'type' => '__edit_templates'), '_SELF'); $preview_url = get_param('preview_url', ''); // We support multi-list for getting here, so f0file can be an array, in which case we change that if (array_key_exists('f0file', $_GET)) { if (is_array($_GET['f0file'])) { foreach ($_GET['f0file'] as $i => $f) { $_GET['f' . strval($i) . 'file'] = $f; } } } $template_editors = new ocp_tempcode(); $templates = array(); $files_seen = array(); if (get_option('editarea') == '1') { $GLOBALS['EXTRA_HEAD']->attach(make_string_tempcode(' <script language="javascript" type="text/javascript" src="' . get_base_url() . '/data/editarea/edit_area_full.js"></script> ')); } $count = 0; $first_id = ''; foreach (array_keys($_GET) as $_i) { $matches = array(); if (preg_match('#f(\\d+)file#', $_i, $matches) != 0) { $i = $matches[1]; } else { continue; } // The file we're editing $file = filter_naughty(get_param('f' . $i . 'file', '')); if ($file == '') { $file = filter_naughty(get_param('f' . $i . 'file2', '')); } if ($file == '') { continue; } if (substr($file, -4) != '.tpl' && substr($file, -4) != '.css') { $file .= '.tpl'; } if (get_param('preview_url', '') == '') { if (substr($file, -4) != '.tpl' && substr($file, -4) != '.css') { $file .= '.tpl'; } require_code('lorem'); $all_previews = find_all_previews__by_template(); if (array_key_exists(basename($file), $all_previews)) { $_preview_url = build_url(array('page' => '_SELF', 'type' => 'view', 'id' => basename($file), 'hook' => $all_previews[basename($file)][0], 'function' => $all_previews[basename($file)][1], 'arg' => '', 'keep_theme' => $theme, 'keep_wide_high' => 1), '_SELF'); $preview_url = $_preview_url->evaluate(); } } if (in_array($file, $files_seen)) { continue; } $files_seen[] = $file; if (!is_null($GLOBALS['CURRENT_SHARE_USER']) && strpos($file, 'BANNER_TYPED') !== false) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } if ($file[0] == '!') { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD')); } $syntax = 'html'; if (substr($file, -4) == '.css') { $syntax = 'css'; } elseif (substr($file, 0, 11) == 'JAVASCRIPT_') { $syntax = 'js'; } if (get_option('editarea') == '1') { $GLOBALS['EXTRA_HEAD']->attach(' <script type="text/javascript">// <![CDATA[ editAreaLoader.init({ id : "f' . $i . '_new" ,syntax: "' . $syntax . '" ,start_highlight: true ,language: "' . (file_exists(get_file_base() . '/data/editarea/langs/' . strtolower(user_lang())) ? strtolower(user_lang()) : 'en') . '" ,allow_resize: true ,toolbar: "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, reset_highlight, word_wrap" }); //]]></script> '); } if ($file == 'HEADER.tpl') { $a = build_url(array('page' => '_SELF', 'type' => '_edit_templates', 'theme' => $theme, 'f0file' => 'FOOTER'), '_SELF'); $b = build_url(array('page' => '_SELF', 'type' => '_edit_templates', 'theme' => $theme, 'f0file' => 'STYLED_HTML_WRAP'), '_SELF'); $c = build_url(array('page' => '_SELF', 'type' => '_edit_templates', 'theme' => $theme, 'f0file' => 'BASIC_HTML_WRAP'), '_SELF'); $d = build_url(array('page' => '_SELF', 'type' => '_edit_templates', 'theme' => $theme, 'f0file' => 'POPUP_HTML_WRAP'), '_SELF'); $e = build_url(array('page' => '_SELF', 'type' => '_edit_templates', 'theme' => $theme, 'f0file' => 'MAIL'), '_SELF'); attach_message(do_lang_tempcode('HEADER_EDIT_ALSO', escape_html($a->evaluate()), escape_html($b->evaluate()), array(escape_html($c->evaluate()), escape_html($d->evaluate()), escape_html($e->evaluate()))), 'inform'); } // Support searching if (strpos($file, '/') === false) { $codename = $file; if (substr($file, -4) == '.css') { $file = $theme . '/css_custom/' . $codename; if (!file_exists(get_custom_file_base() . '/themes/' . $file)) { $file = 'default/css_custom/' . $codename; } if (!file_exists(get_custom_file_base() . '/themes/' . $file)) { $file = 'default/css/' . $codename; } } else { $file = $theme . '/templates_custom/' . $codename; if (!file_exists(get_custom_file_base() . '/themes/' . $file)) { $file = $theme . '/templates/' . $codename; } if (!file_exists(get_custom_file_base() . '/themes/' . $file)) { $file = 'default/templates_custom/' . $codename; } if (!file_exists(get_custom_file_base() . '/themes/' . $file)) { $file = 'default/templates/' . $codename; } } } else { $codename = basename($file); } // The file we're LOADING from for edit (maybe $file, maybe some old versions being restored) $restore_from = filter_naughty(get_param('restore_from', $file)); if (file_exists(get_file_base() . '/themes/' . $restore_from)) { $path = get_file_base() . '/themes/' . $restore_from; $contents = file_get_contents($path, FILE_TEXT); $last_path = $path; } elseif (file_exists(get_custom_file_base() . '/themes/' . $restore_from)) { $path = get_custom_file_base() . '/themes/' . $restore_from; $contents = file_get_contents($path, FILE_TEXT); $last_path = $path; } else { $contents = ''; $last_path = NULL; } // Revision history $filesarray = $this->get_template_files_array($theme, basename($file), true); rsort($filesarray); $j = 0; $revision_history = new ocp_tempcode(); $max = intval(get_option('number_revisions_show')); foreach ($filesarray as $time) { // Find who did the revision $editor = $GLOBALS['SITE_DB']->query_value_null_ok('adminlogs', 'the_user', array('date_and_time' => $time, 'the_type' => 'EDIT_TEMPLATES', 'param_a' => $file)); if (is_null($editor)) { $editor = do_lang('UNKNOWN'); } else { $editor = $GLOBALS['FORUM_DRIVER']->get_username($editor); if (is_null($editor)) { $editor = do_lang('UNKNOWN'); } } $date = is_null($time) ? do_lang('UNKNOWN') : get_timezoned_date($time); $url = get_custom_base_url() . '/themes/' . str_replace('templates/', 'templates_custom/', $file) . '.' . strval($time); $old_file = get_custom_file_base() . '/themes/' . str_replace('templates/', 'templates_custom/', $file) . '.' . strval($time); if (!file_exists($old_file)) { $url = get_custom_base_url() . '/themes/' . str_replace('default/', $theme . '/', str_replace('templates/', 'templates_custom/', $file)) . '.' . strval($time); $old_file = get_custom_file_base() . '/themes/' . str_replace('default/', $theme . '/', str_replace('templates/', 'templates_custom/', $file)) . '.' . strval($time); } if (!file_exists($old_file)) { $url = get_custom_base_url() . '/themes/' . str_replace($theme . '/', 'default/', str_replace('templates/', 'templates_custom/', $file)) . '.' . strval($time); $old_file = get_custom_file_base() . '/themes/' . str_replace($theme . '/', 'default/', str_replace('templates/', 'templates_custom/', $file)) . '.' . strval($time); } $size = filesize($old_file); $restore_url = build_url(array('page' => '_SELF', 'type' => '_edit_templates', 'theme' => $theme, 'f0file' => basename($file), 'restore_from' => substr($old_file, strlen(get_custom_file_base() . '/themes/'))), '_SELF'); require_code('diff'); if (function_exists('diff_simple')) { $rendered_diff = is_null($last_path) ? '' : diff_simple($old_file, $last_path); $last_path = $old_file; $revision_history->attach(do_template('REVISION_HISTORY_LINE', array('_GUID' => 'f0cb02bfa3692ed431b69b8d9dc0b2f8', 'RENDERED_DIFF' => $rendered_diff, 'REFERENCE_POINT_EXACT' => true, 'EDITOR' => $editor, 'DATE' => $date, 'DATE_RAW' => strval($time), 'RESTORE_URL' => $restore_url, 'URL' => $url, 'SIZE' => clean_file_size($size)))); $j++; } if ($j == $max) { break; } } $orig_version = str_replace('/templates_custom/', '/templates/', $file); $orig_version = str_replace('/css_custom/', '/css/', $orig_version); if (!file_exists(get_file_base() . '/themes/' . $orig_version)) { $orig_version = 'default' . substr($orig_version, strpos($orig_version, '/')); } if ((strpos($file, '/templates_custom/') !== false || strpos($file, '/css_custom/') !== false) && file_exists(get_file_base() . '/themes/' . $orig_version)) { $restore_url = build_url(array('page' => '_SELF', 'type' => '_edit_templates', 'theme' => $theme, 'f0file' => basename($file), 'restore_from' => $orig_version), '_SELF'); $url = get_base_url() . '/themes/' . $orig_version; $size = filesize(get_custom_file_base() . '/themes/' . $file); require_code('diff'); if (function_exists('diff_simple')) { $rendered_diff = diff_simple(get_file_base() . '/themes/' . $orig_version, $last_path); $revision_history->attach(do_template('REVISION_HISTORY_LINE', array('_GUID' => '7ba03fe98a20330fc64ad742d2fb74fa', 'RENDERED_DIFF' => $rendered_diff, 'REFERENCE_POINT_EXACT' => true, 'RESTORE_URL' => $restore_url, 'URL' => $url, 'SIZE' => clean_file_size($size)))); $j++; } } if ($j != 0 && get_param('restore_from', '') == '') { $revision_history = do_template('REVISION_HISTORY_WRAP', array('_GUID' => '435e050dd2f38187d757e792ceb2f2f5', 'CONTENT' => $revision_history)); } elseif ($j != 0) { $revision_history = do_template('REVISION_RESTORE'); } $_file = substr($file, strrpos($file, '/') + 1); if (substr($_file, -4) == '.css') { $old_contents = @file_get_contents(get_file_base() . '/themes/default/css/' . $_file); } else { $old_contents = @file_get_contents(get_file_base() . '/themes/default/templates/' . $_file, FILE_TEXT); } if ($old_contents === false) { $old_contents = ''; } $matches = array(); $cnt = preg_match_all('#\\{([\\w_]*)\\}#', $old_contents, $matches); $parameters = new ocp_tempcode(); $p_done = array(); for ($j = 0; $j < $cnt; $j++) { if (array_key_exists($matches[1][$j], $p_done)) { continue; } $p_done[$matches[1][$j]] = 1; $parameters->attach(form_input_list_entry($matches[1][$j] . '__0', false, $matches[1][$j])); } $parameters = do_template('TEMPLATE_EDIT_SCREEN_DROPDOWN', array('_GUID' => '50f31c49c99b864c1719fb51ed426274', 'ID' => $i, 'PARAMETERS' => $parameters, 'NAME' => 'ppparameter', 'LANG' => do_lang_tempcode('INSERT_PARAMETER'))); $_directives = array(array('BOX', '1'), array('WHILE', '1'), array('IF_NON_EMPTY', '1'), array('IF_EMPTY', '1'), array('IF', '1'), array('IF_ADJACENT', '1'), array('SHIFT_ENCODE', '1'), array('LOOP', '1')); $directives = $this->generate_from($_directives, 'DIRECTIVE', $i); $_programmatic_symbols = array(array('RAND', '0'), array('SET_RAND', '0+'), array('CYCLE', '1+'), array('INIT', '1'), array('SET', '2'), array('GET', '1'), array('INC', '1'), array('DEC', '1'), array('SHIFT_DECODE', '1')); $programmatic_symbols = $this->generate_from($_programmatic_symbols, 'PROGRAMMATIC_SYMBOL', $i); $_abstraction_symbols = array(array('IMG', '1'), array('PAGE_LINK', '1'), array('MAILTO', '0'), array('BLOCK', '2'), array('THUMBNAIL', '2'), array('LOAD_PAGE', '1'), array('LOAD_PANEL', '1')); $abstraction_symbols = $this->generate_from($_abstraction_symbols, 'ABSTRACTION_SYMBOL', $i); $_symbols = array(array('THEME', '0'), array('LANG', '0'), array('BASE_URL', '0'), array('MOBILE', '0'), array('SITE_NAME', '0'), array('STAFF_ADDRESS', '0'), array('USER', '0'), array('DATE_AND_TIME', '0'), array('DATE', '0'), array('TIME', '0'), array('USERNAME', '0-1'), array('IS_STAFF', '0'), array('MATCH_KEY_MATCH', '1')); $symbols = $this->generate_from($_symbols, 'SYMBOL', $i); $_arithmetical_symbols = array(array('MAX', '2'), array('MIN', '2'), array('REM', '2'), array('DIV', '2'), array('SUBTRACT', '2'), array('ADD', '2'), array('ROUND', '2'), array('MULT', '2')); $arithmetical_symbols = $this->generate_from($_arithmetical_symbols, 'ARITHMETICAL_SYMBOL', $i); $_formatting_symbols = array(array('WCASE', '1'), array('LCASE', '1'), array('UCASE', '1'), array('REPLACE', '3'), array('AT', '2'), array('SUBSTR', '3'), array('LENGTH', '1'), array('WORDWRAP', '2'), array('TRUNCATE_LEFT', '2'), array('TRUNCATE_SPREAD', '2')); $formatting_symbols = $this->generate_from($_formatting_symbols, 'FORMATTING_SYMBOL', $i); $_logical_symbols = array(array('NOT', '1'), array('OR', '2'), array('AND', '2'), array('EQ', '2'), array('NEQ', '2'), array('LT', '2'), array('GT', '2')); $logical_symbols = $this->generate_from($_logical_symbols, 'LOGICAL_SYMBOL', $i); $guid = get_param('f' . $i . 'guid', '?'); if ($guid == '?') { $guid = ''; } $guids = array(); $file_bits = explode('/', $file); $clean_file = str_replace('.tpl', '', $file_bits[count($file_bits) - 1]); $_guids = @unserialize(@file_get_contents(get_file_base() . '/data/guids.dat', FILE_TEXT)); if ($_guids !== false && array_key_exists($clean_file, $_guids)) { foreach ($_guids[$clean_file] as $_guid) { $guids[] = array('FILENAME' => $_guid[0], 'LINE' => integer_format($_guid[1]), 'THIS_GUID' => $_guid[2]); } } $templates[] = array('I' => $i, 'FILE' => $file); $display = $count == 0 ? 'block' : 'none'; if ($count == 0) { $first_id = $i; } $template_editors->attach(do_template('TEMPLATE_EDIT_SCREEN_EDITOR', array('PREVIEW_URL' => $preview_url, 'CODENAME' => str_replace('.tpl', '', $codename), 'I' => $i, 'DISPLAY' => $display, 'GUIDS' => $guids, 'GUID' => $guid, 'ARITHMETICAL_SYMBOLS' => $arithmetical_symbols, 'FORMATTING_SYMBOLS' => $formatting_symbols, 'LOGICAL_SYMBOLS' => $logical_symbols, 'ABSTRACTION_SYMBOLS' => $abstraction_symbols, 'PARAMETERS' => $parameters, 'DIRECTIVES' => $directives, 'PROGRAMMATIC_SYMBOLS' => $programmatic_symbols, 'SYMBOLS' => $symbols, 'FILE' => $file, 'FILE_SAVE_TARGET' => str_replace('default/', $theme . '/', $file), 'OLD_CONTENTS' => $old_contents, 'CONTENTS' => $contents, 'REVISION_HISTORY' => $revision_history))); $count++; } if ($count == 1) { $GLOBALS['SEO_TITLE'] = $files_seen[0]; } if ($template_editors->is_empty()) { warn_exit(do_lang_tempcode('NO_TEMPLATES_SELECTED')); } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_THEMES')), array('_SELF:_SELF:edit_templates:theme=' . $theme, do_lang_tempcode('CHOOSE')))); return do_template('TEMPLATE_EDIT_SCREEN', array('_GUID' => 'cbcd6d18c2456f94f72624e1a39a36a5', 'MULTIPLE' => $count > 1, 'FIRST_ID' => $first_id, 'THEME' => $theme, 'TEMPLATES' => $templates, 'TITLE' => $title, 'URL' => $post_url, 'TEMPLATE_EDITORS' => $template_editors)); }
/** * 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)); }