From b903edacea47fa1a2cbdbd8aa1e00d71de74bd5f Mon Sep 17 00:00:00 2001 From: saxmatt Date: Wed, 22 Sep 2004 06:33:54 +0000 Subject: [PATCH] Some file editor improvements. New: Recently edited and editor sidebar. git-svn-id: http://svn.automattic.com/wordpress/trunk@1703 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/menu.php | 4 +- wp-admin/templates.php | 115 +++++++++++++++++++++++--------------- wp-admin/theme-editor.php | 1 - wp-admin/wp-admin.css | 22 ++++++++ 4 files changed, 95 insertions(+), 47 deletions(-) diff --git a/wp-admin/menu.php b/wp-admin/menu.php index b98cede7a..8c543f367 100644 --- a/wp-admin/menu.php +++ b/wp-admin/menu.php @@ -14,8 +14,7 @@ $menu[25] = array(__('Users'), 3, 'users.php'); $menu[30] = array(__('Options'), 6, 'options-general.php'); $menu[35] = array(__('Plugins'), 8, 'plugins.php'); $menu[40] = array(__('Presentation'), 8, 'themes.php'); -$menu[45] = array(__('Templates'), 4, 'templates.php'); -$menu[50] = array(__('Upload'), get_settings('fileupload_minlevel'), 'upload.php'); +$menu[45] = array(__('Upload'), get_settings('fileupload_minlevel'), 'upload.php'); ksort($menu); // So other files can plugin $submenu['edit.php'][5] = array(__('Posts'), 1, 'edit.php'); @@ -42,6 +41,7 @@ $submenu['options-general.php'][30] = array(__('Miscellaneous'), 5, 'options-mis $submenu['themes.php'][5] = array(__('Themes'), 5, 'themes.php'); $submenu['themes.php'][10] = array(__('Theme Editor'), 5, 'theme-editor.php'); +$submenu['themes.php'][15] = array(__('Other Files'), 5, 'templates.php'); $self = preg_replace('|.*/wp-admin/|i', '', $_SERVER['PHP_SELF']); if (!isset($parent_file)) $parent_file = ''; diff --git a/wp-admin/templates.php b/wp-admin/templates.php index 6e6ab37ad..e1af76ae6 100644 --- a/wp-admin/templates.php +++ b/wp-admin/templates.php @@ -1,7 +1,8 @@ $v) { @@ -57,7 +58,7 @@ switch($action) { case 'update': $standalone = 1; - require_once("admin-header.php"); + require_once('./admin-header.php'); if ($user_level < 5) { die(__('

You have do not have sufficient permissions to edit templates for this blog.

')); @@ -82,18 +83,26 @@ break; default: - require_once('admin-header.php'); -update_option('recently_edited', array(1, 2, 3) ); + require_once('./admin-header.php'); if ($user_level <= 5) { die(__('

You have do not have sufficient permissions to edit templates for this blog.

')); } if ('' == $file) { - if ('' != get_settings('blogfilename')) { - $file = get_settings('blogfilename'); + $file = 'index.php'; + } else { + $oldfiles = (array) get_option('recently_edited'); + if ($oldfiles) { + $oldfiles = array_reverse($oldfiles); + $oldfiles[] = $file; + $oldfiles = array_reverse($oldfiles); + $oldfiles = array_unique($oldfiles); + if ( 5 < count($oldfiles) ) + array_pop($oldfiles); } else { - $file = 'index.php'; + $oldfiles[] = $file; } + update_option('recently_edited', $oldfiles); } $home = get_settings('home'); @@ -102,7 +111,7 @@ update_option('recently_edited', array(1, 2, 3) ); '.htaccess' == $file)) { $home_root = parse_url($home); $home_root = $home_root['path']; - $root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["PATH_TRANSLATED"]); + $root = str_replace($_SERVER['PHP_SELF'], '', $_SERVER['PATH_TRANSLATED']); $home_root = $root . $home_root; $real_file = $home_root . '/' . $file; } else { @@ -112,15 +121,11 @@ update_option('recently_edited', array(1, 2, 3) ); if (!is_file($real_file)) $error = 1; - - if ((substr($file,0,2) == 'wp') and (substr($file,-4,4) == '.php') and ($file != 'wp.php')) - $warning = __(' — this is a WordPress file, be careful when editing it!'); if (!$error) { $f = fopen($real_file, 'r'); $content = fread($f, filesize($real_file)); $content = htmlspecialchars($content); -// $content = str_replace(" @@ -128,38 +133,28 @@ update_option('recently_edited', array(1, 2, 3) );

- " . sprintf(__('Editing %s'), $file) . " $warning

"; - - if (!$error) { - ?> -
- - - -

- "; - } else { - echo ""; - } - ?> -

-
-

' . __('Oops, no such file exists! Double check the name and try again, merci.') . '

'; - } - ?> - -
-

writable by the server, e.g. CHMOD 666.') ?>

-
- - -
-

+' . sprintf(__('Editing %s'), $file) . ''; +} else { + echo '

' . sprintf(__('Browsing %s'), $file) . '

'; +} +?> +
+ +

+'; +foreach ($recents as $recent) : + $display = preg_replace('|.*/(.*)$|', '$1', $recent); + echo "
  • $display"; +endforeach; +echo ''; +endif; +?> +

    • @@ -168,6 +163,38 @@ update_option('recently_edited', array(1, 2, 3) );
    +
  • + +
    +
    + + +
    + +

    +"; +?> +

    + +

    + +
    +

    ' . __('Oops, no such file exists! Double check the name and try again, merci.') . '

    '; + } + ?> + +
    +

    Other Files

    + +

    writable by the server, e.g. CHMOD 666.') ?>

    +
    + + +
    + You have do not have sufficient permissions to edit themes for this blog.

    ')); } diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css index c14060aba..bd959cbc3 100644 --- a/wp-admin/wp-admin.css +++ b/wp-admin/wp-admin.css @@ -352,6 +352,28 @@ textarea, input, select { clear: both; } +#template div { + margin-right: 190px; +} + +#templateside { + width: 170px; + float: right; +} +#templateside h3 { + margin: 0; +} +#templateside ol, #templateside ul { + list-style: none; + margin: .5em; + padding: 0; +} +#template textarea { + font-family: 'Courier New', Courier, monopace; + font-size: small; + width: 99%; +} + #postcustom { border: 1px solid #aaa; padding: .5em;