Index: trunk/plugins/LocalFilesEditor/admin.php
===================================================================
--- trunk/plugins/LocalFilesEditor/admin.php	(revision 10312)
+++ trunk/plugins/LocalFilesEditor/admin.php	(revision 10348)
@@ -24,5 +24,5 @@
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
-include_once(LOCALEDIT_PATH.'functions.inc.php');
+include_once(LOCALEDIT_PATH.'include/functions.inc.php');
 load_language('plugin.lang', LOCALEDIT_PATH);
 $my_base_url = get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__));
@@ -55,219 +55,5 @@
 $tabsheet->assign();
 
-
-// +-----------------------------------------------------------------------+
-// |                            Variables init
-// +-----------------------------------------------------------------------+
-$edited_file = isset($_POST['edited_file']) ? $_POST['edited_file'] : '';
-$content_file = '';
-$new_file['localconf'] = "<?php\n\n/* ".l10n('locfiledit_newfile')." */\n\n\n\n\n?>";
-$new_file['css'] = "/* " . l10n('locfiledit_newfile') . " */\n\n";
-$new_file['tpl'] = "{* " . l10n('locfiledit_newfile') . " *}\n\n";
-$new_file['lang'] = $new_file['localconf'];
-$new_file['plug'] = "<?php\n/*
-Plugin Name: " . l10n('locfiledit_onglet_plug') . "
-Version: 1.0
-Description: " . l10n('locfiledit_onglet_plug') . "
-Plugin URI: http://piwigo.org
-Author:
-Author URI:
-*/\n\n\n\n\n?>";
-$newfile_page = isset($_GET['newfile']) ? true : false;
-
-// Edit selected file for CSS, template and language
-if ((isset($_POST['edit'])) and !is_numeric($_POST['file_to_edit']))
-{
-  $edited_file = $_POST['file_to_edit'];
-  $content_file = file_exists($edited_file) ? 
-    file_get_contents($edited_file) : $new_file[$page['tab']];
-}
-
-// Edit new tpl file
-if (isset($_POST['create_tpl']))
-{
-  $filename = $_POST['tpl_name'];
-  if (empty($filename))
-  {
-    array_push($page['errors'], l10n('locfiledit_empty_filename'));
-  }
-  if (get_extension($filename) != 'tpl')
-  {
-    $filename .= '.tpl';
-  }
-  if (!preg_match('/^[a-zA-Z0-9-_.]+$/', $filename))
-  {
-    array_push($page['errors'], l10n('locfiledit_filename_error'));
-  }
-  if (is_numeric($_POST['tpl_model']) and $_POST['tpl_model'] != '0')
-  {
-    array_push($page['errors'], l10n('locfiledit_model_error'));
-  }
-  if (file_exists($_POST['tpl_parent'] . '/' . $filename))
-  {
-    array_push($page['errors'], l10n('locfiledit_file_already_exists'));
-  }
-  if (!empty($page['errors']))
-  {
-    $newfile_page = true;
-  }
-  else
-  {
-    $edited_file = $_POST['tpl_parent'] . '/' . $filename;
-    $content_file = ($_POST['tpl_model'] == '0') ? $new_file['tpl'] : file_get_contents($_POST['tpl_model']);
-  }
-}
-
-// +-----------------------------------------------------------------------+
-// |                            Process tabsheet
-// +-----------------------------------------------------------------------+
-switch ($page['tab'])
-{
-  case 'localconf':
-    $edited_file = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . "config/config.inc.php";
-    $content_file = file_exists($edited_file) ?
-      file_get_contents($edited_file) : $new_file['localconf'];
-	
-    $template->assign('show_default' , array(
-        array('SHOW_DEFAULT' => LOCALEDIT_PATH
-                . 'show_default.php?file=include/config_default.inc.php',
-              'FILE' => 'config_default.inc.php')));
-    $codemirror_mode = 'application/x-httpd-php';
-    break;
-
-  case 'css':
-    $selected = 0; 
-    $options[] = l10n('locfiledit_choose_file');
-    $options[] = '----------------------';
-    $value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . "css/rules.css";
-    $options[$value] = 'local / css / rules.css';
-    if ($edited_file == $value) $selected = $value;
-    $options[] = '----------------------';
-	
-    foreach (get_dirs($conf['themes_dir']) as $theme_id)
-    {
-      $value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . 'css/'.$theme_id.'-rules.css';
-      $options[$value] = 'local / css / '.$theme_id.'-rules.css';
-      if ($edited_file == $value) $selected = $value;
-    }
-    $template->assign('css_lang_tpl', array(
-        'OPTIONS' => $options,
-        'SELECTED' => $selected));
-    $codemirror_mode = 'text/css';
-    break;
-
-  case 'tpl':
-    // New file form creation
-    if ($newfile_page)
-    {
-      $filename = isset($_POST['tpl_name']) ? $_POST['tpl_name'] : '';
-      $selected['model'] = isset($_POST['tpl_model']) ? $_POST['tpl_model'] : '0';
-      $selected['parent'] = isset($_POST['tpl_parent']) ? $_POST['tpl_parent'] : PHPWG_ROOT_PATH . 'template-extension';
-
-      // Parent directories list
-      $options['parent'] = array(PHPWG_ROOT_PATH . 'template-extension' => 'template-extension');
-      $options['parent'] = array_merge($options['parent'], get_rec_dirs(PHPWG_ROOT_PATH . 'template-extension'));
-
-      $options['model'][] = l10n('locfiledit_empty_page');
-      $options['model'][] = '----------------------';
-      $i = 0;
-      foreach (get_extents() as $pwg_template)
-      {
-        $value = PHPWG_ROOT_PATH . 'template-extension/' . $pwg_template;
-        $options['model'][$value] =  'template-extension / ' . str_replace('/', ' / ', $pwg_template);
-        $i++;
-      }
-      foreach (get_dirs($conf['themes_dir']) as $theme_id)
-      {
-        if ($i)
-        {
-          $options['model'][] = '----------------------';
-          $i = 0;
-        }
-        $dir = $conf['themes_dir'] . '/' . $theme_id . '/template/';
-        if (is_dir($dir) and $content = opendir($dir))
-        {
-          while ($node = readdir($content))
-          {
-            if (is_file($dir.$node) and get_extension($node) == 'tpl')
-            {
-              $value = $dir . $node;
-              $options['model'][$value] = $theme_id . ' / ' . $node;
-              $i++;
-            }
-          }
-        }
-      }
-      if (end($options['model']) == '----------------------')
-      {
-        array_pop($options['model']);
-      }
-      // Assign variables to template
-      $template->assign('create_tpl', array(
-        'NEW_FILE_NAME' => $filename,
-        'MODEL_OPTIONS' => $options['model'],
-        'MODEL_SELECTED' => $selected['model'],
-        'PARENT_OPTIONS' => $options['parent'],
-        'PARENT_SELECTED' => $selected['parent']));
-      break;
-    }
-    // List existing template extensions
-    $selected = 0; 
-    $options[] = l10n('locfiledit_choose_file');
-    $options[] = '----------------------';
-    foreach (get_extents() as $pwg_template)
-    {
-      $value = './template-extension/' . $pwg_template;
-      $options[$value] =  str_replace('/', ' / ', $pwg_template);
-      if ($edited_file == $value) $selected = $value;
-    }
-    if ($selected == 0 and !empty($edited_file))
-    {
-      $options[$edited_file] =  str_replace(array('./template-extension/', '/'), array('', ' / '), $edited_file);
-      $selected = $edited_file;
-    }
-    $template->assign('css_lang_tpl', array(
-      'OPTIONS' => $options,
-      'SELECTED' => $selected,
-      'NEW_FILE_URL' => $my_base_url.'-tpl&amp;newfile',
-      'NEW_FILE_CLASS' => empty($edited_file) ? '' : 'top_right'));
-
-    $codemirror_mode = 'text/html';
-    break;
-
-  case 'lang':
-    $selected = 0; 
-    $options[] = l10n('locfiledit_choose_file');
-    $options[] = '----------------------';
-    foreach (get_languages() as $language_code => $language_name)
-    {
-      $value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'language/'.$language_code.'.lang.php';
-      if ($edited_file == $value)
-      {
-        $selected = $value;
-        $template->assign('show_default', array(
-          array('SHOW_DEFAULT' => LOCALEDIT_PATH
-                  . 'show_default.php?file='
-                  . 'language/'.$language_code.'/common.lang.php',
-                'FILE' => 'common.lang.php'),
-          array('SHOW_DEFAULT' => LOCALEDIT_PATH
-                  . 'show_default.php?file='
-                  . 'language/'.$language_code.'/admin.lang.php',
-                'FILE' => 'admin.lang.php')));
-      }
-      $options[$value] = $language_name;
-    }
-    $template->assign('css_lang_tpl', array(
-        'OPTIONS' => $options,
-        'SELECTED' => $selected));
-    $codemirror_mode = 'application/x-httpd-php';
-    break;
-    
-  case 'plug':
-    $edited_file = PHPWG_PLUGINS_PATH . "PersonalPlugin/main.inc.php";
-    $content_file = file_exists($edited_file) ?
-      file_get_contents($edited_file) : $new_file['plug'];
-    $codemirror_mode = 'application/x-httpd-php';
-    break;
-}
+include_once(LOCALEDIT_PATH.'include/'.$page['tab'].'.inc.php');
 
 // +-----------------------------------------------------------------------+
@@ -335,5 +121,5 @@
 // +-----------------------------------------------------------------------+
 $template->set_filenames(array(
-    'plugin_admin_content' => dirname(__FILE__) . '/admin.tpl'));
+    'plugin_admin_content' => dirname(__FILE__) . '/template/admin.tpl'));
 
 if (!empty($edited_file))
@@ -344,7 +130,10 @@
   }
   $template->assign('zone_edit',
-    array('EDITED_FILE' => $edited_file,
-          'CONTENT_FILE' => htmlspecialchars($content_file),
-          'FILE_NAME' => trim($edited_file, './\\')));
+    array(
+      'EDITED_FILE' => $edited_file,
+      'CONTENT_FILE' => htmlspecialchars($content_file),
+      'FILE_NAME' => trim($edited_file, './\\')
+    )
+  );
   if (file_exists(get_bak_file($edited_file)))
   {
@@ -355,5 +144,4 @@
     $template->assign('restore_infos', true);
   }
-  
 }
 
Index: trunk/plugins/LocalFilesEditor/admin.tpl
===================================================================
--- trunk/plugins/LocalFilesEditor/admin.tpl	(revision 10312)
+++ 	(revision )
@@ -1,96 +1,0 @@
-{combine_script id="codemirror" path="plugins/LocalFilesEditor/codemirror/lib/codemirror.js"}
-{combine_script id="codemirror.xml" require="codemirror" path="plugins/LocalFilesEditor/codemirror/mode/xml/xml.js"}
-{combine_script id="codemirror.javascript" require="codemirror" path="plugins/LocalFilesEditor/codemirror/mode/javascript/javascript.js"}
-{combine_script id="codemirror.css" require="codemirror" path="plugins/LocalFilesEditor/codemirror/mode/css/css.js"}
-{combine_script id="codemirror.clike" require="codemirror" path="plugins/LocalFilesEditor/codemirror/mode/clike/clike.js"}
-{combine_script id="codemirror.htmlmixed" require="codemirror.xml,codemirror.javascript,codemirror.css" path="plugins/LocalFilesEditor/codemirror/mode/htmlmixed/htmlmixed.js"}
-{combine_script id="codemirror.php" require="codemirror.xml,codemirror.javascript,codemirror.css,codemirror.clike" path="plugins/LocalFilesEditor/codemirror/mode/php/php.js"}
-
-{combine_css path="plugins/LocalFilesEditor/codemirror/lib/codemirror.css"}
-{combine_css path="plugins/LocalFilesEditor/codemirror/mode/xml/xml.css"}
-{combine_css path="plugins/LocalFilesEditor/codemirror/mode/javascript/javascript.css"}
-{combine_css path="plugins/LocalFilesEditor/codemirror/mode/css/css.css"}
-{combine_css path="plugins/LocalFilesEditor/codemirror/mode/clike/clike.css"}
-{combine_css path="plugins/LocalFilesEditor/locfiledit.css"}
-
-{footer_script}
-if (document.getElementById("text") != null)
-  var editor = CodeMirror.fromTextArea(document.getElementById("text"), {ldelim}
-    matchBrackets: true,
-    mode: "{$CODEMIRROR_MODE}",
-    tabMode: "shift"
-  });
-{/footer_script}
-
-<div class="titrePage">
-  <h2>LocalFiles Editor</h2>
-</div>
-
-<form method="post" class="properties" action="{$F_ACTION}" ENCTYPE="multipart/form-data" name="form">
-
-<div id="LocalFilesEditor">
-
-<input type="hidden" value="{$zone_edit.EDITED_FILE}" name="edited_file"/>
-
-{if isset ($create_tpl)}
-  <table>
-    <tr>
-      <td style="text-align: right;">{'locfiledit_new_filename'|@translate}</td>
-      <td style="text-align: left;"><input type="text" size="55" maxlength="50" value="{$create_tpl.NEW_FILE_NAME}" name="tpl_name"/></td>
-    </tr>
-    <tr>
-      <td style="text-align: right;">{'locfiledit_parent_directory'|@translate}</td>
-      <td style="text-align: left;">{html_options name=tpl_parent options=$create_tpl.PARENT_OPTIONS selected=$create_tpl.PARENT_SELECTED}</td>
-    </tr>
-    <tr>
-      <td style="text-align: right;">{'locfiledit_model'|@translate}</td>
-      <td style="text-align: left;">{html_options name=tpl_model options=$create_tpl.MODEL_OPTIONS selected=$create_tpl.MODEL_SELECTED}</td>
-    </tr>
-  </table>
-<br><br>
-<input class="submit" type="submit" value="{'Submit'|@translate}" name="create_tpl" />
-{/if}
-
-{if isset ($css_lang_tpl)}
-{html_options name=file_to_edit options=$css_lang_tpl.OPTIONS selected=$css_lang_tpl.SELECTED}
-<input class="submit" type="submit" value="{'locfiledit_edit'|@translate}" name="edit" />
-<br><br>
-  {if isset ($css_lang_tpl.NEW_FILE_URL)}
-  <span class="{$css_lang_tpl.NEW_FILE_CLASS}">
-  <a href="{$css_lang_tpl.NEW_FILE_URL}">{'locfiledit_new_tpl'|@translate}</a>
-  </span>
-  {/if}
-{/if}
-
-<div style="overflow:auto;"> {* top bar buttons *}
-{if !empty($show_default)}
-{foreach from=$show_default item=file name=default_loop}
-<span class="top_right">
-<a href="{$file.SHOW_DEFAULT}" onclick="window.open( this.href, 'local_file', 'location=no,toolbar=no,menubar=no,status=no,resizable=yes,scrollbars=yes,width=800,height=700' ); return false;">{'locfiledit_show_default'|@translate} "{$file.FILE}"</a>
-</span>
-{if !($smarty.foreach.default_loop.last)}<br>{/if}
-{/foreach}
-{/if}
-
-{if isset ($zone_edit)}
-<b>{$zone_edit.FILE_NAME}</b>
-
-</div> {* top bar buttons *}
-
-<textarea rows="30" cols="90" name="text" id="text">{$zone_edit.CONTENT_FILE}</textarea>
-
-<br>
-
-<input class="submit" type="submit" value="{'locfiledit_save_file'|@translate}" name="submit"/>
-{if isset ($restore)}
-<input class="submit" type="submit" value="{'locfiledit_restore'|@translate}" name="restore" onclick="return confirm('{'locfiledit_restore_confirm'|@translate|escape:'javascript'}');"/>
-{/if}
-
-{if isset ($restore_infos)}
-<br><br>
-{'locfiledit_save_bak'|@translate}
-{/if}
-
-{/if}
-</div>
-</form>
Index: trunk/plugins/LocalFilesEditor/functions.inc.php
===================================================================
--- trunk/plugins/LocalFilesEditor/functions.inc.php	(revision 10312)
+++ 	(revision )
@@ -1,114 +1,0 @@
-<?php
-// +-----------------------------------------------------------------------+
-// | Piwigo - a PHP based photo gallery                                    |
-// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2011 Piwigo Team                  http://piwigo.org |
-// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
-// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
-// +-----------------------------------------------------------------------+
-// | This program is free software; you can redistribute it and/or modify  |
-// | it under the terms of the GNU General Public License as published by  |
-// | the Free Software Foundation                                          |
-// |                                                                       |
-// | This program is distributed in the hope that it will be useful, but   |
-// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
-// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
-// | General Public License for more details.                              |
-// |                                                                       |
-// | You should have received a copy of the GNU General Public License     |
-// | along with this program; if not, write to the Free Software           |
-// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
-// | USA.                                                                  |
-// +-----------------------------------------------------------------------+
-
-/**
- * returns $code if php syntax is correct
- * else return false
- *
- * @param string php code
- */
-function eval_syntax($code)
-{
-  $code = str_replace(array('<?php', '?>'), '', $code);
-  if (function_exists('token_get_all'))
-  {
-    $b = 0;
-    foreach (token_get_all($code) as $token)
-    {
-      if ('{' == $token) ++$b;
-      else if ('}' == $token) --$b;
-    }
-    if ($b) return false;
-    else
-    {
-      ob_start();
-      $eval = eval('if(0){' . $code . '}');
-      ob_end_clean();
-      if ($eval === false) return false;
-    }
-  }
-  return '<?php' . $code . '?>';
-}
-
-/**
- * returns true or false if $str is bool
-  * returns $str if $str is integer
- * else "$str"
- *
- * @param string
- */
-function editarea_quote($value)
-{
-  switch (gettype($value))
-  {
-    case "boolean":
-      return $value ? 'true' : 'false';
-    case "integer":
-      return $value;
-    default:
-      return '"'.$value.'"';
-  }
-}
-
-/**
- * returns bak file for restore
- * @param string
- */
-function get_bak_file($file)
-{
-  if (get_extension($file) == 'php')
-  {
-    return substr_replace($file, '.bak', strrpos($file , '.'), 0);
-  }
-  else
-  {
-    return $file . '.bak';
-  }
-}
-
-/**
- * returns dirs and subdirs
- * retun array
- * @param string
- */
-function get_rec_dirs($path='')
-{
-  $options = array();
-  if (is_dir($path))
-  {
-    $fh = opendir($path);
-    while ($file = readdir($fh))
-    {
-      $pathfile = $path . '/' . $file;
-      if ($file != '.' and $file != '..' and $file != '.svn' and is_dir($pathfile))
-      {
-        $options[$pathfile] = str_replace(array('./', '/'), array('', ' / '), $pathfile);
-        $options = array_merge($options, get_rec_dirs($pathfile));
-      }
-    }
-    closedir($fh);
-  }
-  return $options;
-}
-
-?>
Index: trunk/plugins/LocalFilesEditor/include/css.inc.php
===================================================================
--- trunk/plugins/LocalFilesEditor/include/css.inc.php	(revision 10348)
+++ trunk/plugins/LocalFilesEditor/include/css.inc.php	(revision 10348)
@@ -0,0 +1,45 @@
+<?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+$edited_file = isset($_POST['edited_file']) ? $_POST['edited_file'] : '';
+$content_file = '';
+
+if ((isset($_POST['edit'])) and !is_numeric($_POST['file_to_edit']))
+{
+  $edited_file = $_POST['file_to_edit'];
+  if (file_exists($edited_file))
+  {
+    $content_file = file_get_contents($edited_file);
+  }
+  else
+  {
+    $content_file = "/* " . l10n('locfiledit_newfile') . " */\n\n";
+  }
+}
+
+$selected = 0; 
+$options[] = l10n('locfiledit_choose_file');
+$options[] = '----------------------';
+$value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . "css/rules.css";
+$options[$value] = 'local / css / rules.css';
+if ($edited_file == $value) $selected = $value;
+$options[] = '----------------------';
+
+foreach (get_dirs($conf['themes_dir']) as $theme_id)
+{
+  $value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . 'css/'.$theme_id.'-rules.css';
+  $options[$value] = 'local / css / '.$theme_id.'-rules.css';
+  if ($edited_file == $value)
+    $selected = $value;
+}
+
+$template->assign('css_lang_tpl', array(
+  'OPTIONS' => $options,
+  'SELECTED' => $selected
+  )
+);
+
+$codemirror_mode = 'text/css';
+
+?>
Index: trunk/plugins/LocalFilesEditor/include/functions.inc.php
===================================================================
--- trunk/plugins/LocalFilesEditor/include/functions.inc.php	(revision 10348)
+++ trunk/plugins/LocalFilesEditor/include/functions.inc.php	(revision 10348)
@@ -0,0 +1,114 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based photo gallery                                    |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2011 Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+/**
+ * returns $code if php syntax is correct
+ * else return false
+ *
+ * @param string php code
+ */
+function eval_syntax($code)
+{
+  $code = str_replace(array('<?php', '?>'), '', $code);
+  if (function_exists('token_get_all'))
+  {
+    $b = 0;
+    foreach (token_get_all($code) as $token)
+    {
+      if ('{' == $token) ++$b;
+      else if ('}' == $token) --$b;
+    }
+    if ($b) return false;
+    else
+    {
+      ob_start();
+      $eval = eval('if(0){' . $code . '}');
+      ob_end_clean();
+      if ($eval === false) return false;
+    }
+  }
+  return '<?php' . $code . '?>';
+}
+
+/**
+ * returns true or false if $str is bool
+  * returns $str if $str is integer
+ * else "$str"
+ *
+ * @param string
+ */
+function editarea_quote($value)
+{
+  switch (gettype($value))
+  {
+    case "boolean":
+      return $value ? 'true' : 'false';
+    case "integer":
+      return $value;
+    default:
+      return '"'.$value.'"';
+  }
+}
+
+/**
+ * returns bak file for restore
+ * @param string
+ */
+function get_bak_file($file)
+{
+  if (get_extension($file) == 'php')
+  {
+    return substr_replace($file, '.bak', strrpos($file , '.'), 0);
+  }
+  else
+  {
+    return $file . '.bak';
+  }
+}
+
+/**
+ * returns dirs and subdirs
+ * retun array
+ * @param string
+ */
+function get_rec_dirs($path='')
+{
+  $options = array();
+  if (is_dir($path))
+  {
+    $fh = opendir($path);
+    while ($file = readdir($fh))
+    {
+      $pathfile = $path . '/' . $file;
+      if ($file != '.' and $file != '..' and $file != '.svn' and is_dir($pathfile))
+      {
+        $options[$pathfile] = str_replace(array('./', '/'), array('', ' / '), $pathfile);
+        $options = array_merge($options, get_rec_dirs($pathfile));
+      }
+    }
+    closedir($fh);
+  }
+  return $options;
+}
+
+?>
Index: trunk/plugins/LocalFilesEditor/include/lang.inc.php
===================================================================
--- trunk/plugins/LocalFilesEditor/include/lang.inc.php	(revision 10348)
+++ trunk/plugins/LocalFilesEditor/include/lang.inc.php	(revision 10348)
@@ -0,0 +1,53 @@
+<?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+$edited_file = isset($_POST['edited_file']) ? $_POST['edited_file'] : '';
+$content_file = '';
+
+if ((isset($_POST['edit'])) and !is_numeric($_POST['file_to_edit']))
+{
+  $edited_file = $_POST['file_to_edit'];
+  if (file_exists($edited_file))
+  {
+    $content_file = file_get_contents($edited_file);
+  }
+  else
+  {
+    $content_file = "<?php\n\n/* ".l10n('locfiledit_newfile')." */\n\n\n\n\n?>";
+  }
+}
+
+$selected = 0; 
+$options[] = l10n('locfiledit_choose_file');
+$options[] = '----------------------';
+foreach (get_languages() as $language_code => $language_name)
+{
+  $value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'language/'.$language_code.'.lang.php';
+  if ($edited_file == $value)
+  {
+    $selected = $value;
+    $template->assign('show_default', array(
+      array(
+        'URL' => LOCALEDIT_PATH.'show_default.php?file=language/'.$language_code.'/common.lang.php',
+        'FILE' => 'common.lang.php'
+        ),
+      array(
+        'URL' => LOCALEDIT_PATH.'show_default.php?file=language/'.$language_code.'/admin.lang.php',
+        'FILE' => 'admin.lang.php'
+        )
+      )
+    );
+  }
+  $options[$value] = $language_name;
+}
+
+$template->assign('css_lang_tpl', array(
+    'OPTIONS' => $options,
+    'SELECTED' => $selected
+    )
+  );
+
+$codemirror_mode = 'application/x-httpd-php';
+
+?>
Index: trunk/plugins/LocalFilesEditor/include/localconf.inc.php
===================================================================
--- trunk/plugins/LocalFilesEditor/include/localconf.inc.php	(revision 10348)
+++ trunk/plugins/LocalFilesEditor/include/localconf.inc.php	(revision 10348)
@@ -0,0 +1,26 @@
+<?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+$edited_file = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . "config/config.inc.php";
+
+if (file_exists($edited_file))
+{
+  $content_file = file_get_contents($edited_file);
+}
+else
+{
+  $content_file = "<?php\n\n/* ".l10n('locfiledit_newfile')." */\n\n\n\n\n?>";
+}
+
+$template->assign('show_default', array(
+  array(
+    'URL' => LOCALEDIT_PATH.'show_default.php?file=include/config_default.inc.php',
+    'FILE' => 'config_default.inc.php'
+    )
+  )
+);
+
+$codemirror_mode = 'application/x-httpd-php';
+
+?>
Index: trunk/plugins/LocalFilesEditor/include/plug.inc.php
===================================================================
--- trunk/plugins/LocalFilesEditor/include/plug.inc.php	(revision 10348)
+++ trunk/plugins/LocalFilesEditor/include/plug.inc.php	(revision 10348)
@@ -0,0 +1,25 @@
+<?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+$edited_file = PHPWG_PLUGINS_PATH . "PersonalPlugin/main.inc.php";
+
+if (file_exists($edited_file))
+{
+  $content_file = file_get_contents($edited_file);
+}
+else
+{
+  $content_file = "<?php\n/*
+Plugin Name: " . l10n('locfiledit_onglet_plug') . "
+Version: 1.0
+Description: " . l10n('locfiledit_onglet_plug') . "
+Plugin URI: http://piwigo.org
+Author:
+Author URI:
+*/\n\n\n\n\n?>";
+}
+
+$codemirror_mode = 'application/x-httpd-php';
+
+?>
Index: trunk/plugins/LocalFilesEditor/include/tpl.inc.php
===================================================================
--- trunk/plugins/LocalFilesEditor/include/tpl.inc.php	(revision 10348)
+++ trunk/plugins/LocalFilesEditor/include/tpl.inc.php	(revision 10348)
@@ -0,0 +1,140 @@
+<?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+$edited_file = isset($_POST['edited_file']) ? $_POST['edited_file'] : '';
+$content_file = '';
+
+if ((isset($_POST['edit'])) and !is_numeric($_POST['file_to_edit']))
+{
+  $edited_file = $_POST['file_to_edit'];
+  if (file_exists($edited_file))
+  {
+    $content_file = file_get_contents($edited_file);
+  }
+  else
+  {
+    $content_file = "{* " . l10n('locfiledit_newfile') . " *}\n\n";
+  }
+}
+
+$newfile_page = isset($_GET['newfile']);
+
+// Edit new tpl file
+if (isset($_POST['create_tpl']))
+{
+  $filename = $_POST['tpl_name'];
+  if (empty($filename))
+  {
+    array_push($page['errors'], l10n('locfiledit_empty_filename'));
+  }
+  if (get_extension($filename) != 'tpl')
+  {
+    $filename .= '.tpl';
+  }
+  if (!preg_match('/^[a-zA-Z0-9-_.]+$/', $filename))
+  {
+    array_push($page['errors'], l10n('locfiledit_filename_error'));
+  }
+  if (is_numeric($_POST['tpl_model']) and $_POST['tpl_model'] != '0')
+  {
+    array_push($page['errors'], l10n('locfiledit_model_error'));
+  }
+  if (file_exists($_POST['tpl_parent'] . '/' . $filename))
+  {
+    array_push($page['errors'], l10n('locfiledit_file_already_exists'));
+  }
+  if (!empty($page['errors']))
+  {
+    $newfile_page = true;
+  }
+  else
+  {
+    $edited_file = $_POST['tpl_parent'] . '/' . $filename;
+    $content_file = ($_POST['tpl_model'] == '0') ? $new_file['tpl'] : file_get_contents($_POST['tpl_model']);
+  }
+}
+
+if ($newfile_page)
+{
+  $filename = isset($_POST['tpl_name']) ? $_POST['tpl_name'] : '';
+  $selected['model'] = isset($_POST['tpl_model']) ? $_POST['tpl_model'] : '0';
+  $selected['parent'] = isset($_POST['tpl_parent']) ? $_POST['tpl_parent'] : PHPWG_ROOT_PATH . 'template-extension';
+
+  // Parent directories list
+  $options['parent'] = array(PHPWG_ROOT_PATH . 'template-extension' => 'template-extension');
+  $options['parent'] = array_merge($options['parent'], get_rec_dirs(PHPWG_ROOT_PATH . 'template-extension'));
+
+  $options['model'][] = l10n('locfiledit_empty_page');
+  $options['model'][] = '----------------------';
+  $i = 0;
+  foreach (get_extents() as $pwg_template)
+  {
+    $value = PHPWG_ROOT_PATH . 'template-extension/' . $pwg_template;
+    $options['model'][$value] =  'template-extension / ' . str_replace('/', ' / ', $pwg_template);
+    $i++;
+  }
+  foreach (get_dirs($conf['themes_dir']) as $theme_id)
+  {
+    if ($i)
+    {
+      $options['model'][] = '----------------------';
+      $i = 0;
+    }
+    $dir = $conf['themes_dir'] . '/' . $theme_id . '/template/';
+    if (is_dir($dir) and $content = opendir($dir))
+    {
+      while ($node = readdir($content))
+      {
+        if (is_file($dir.$node) and get_extension($node) == 'tpl')
+        {
+          $value = $dir . $node;
+          $options['model'][$value] = $theme_id . ' / ' . $node;
+          $i++;
+        }
+      }
+    }
+  }
+  if (end($options['model']) == '----------------------')
+  {
+    array_pop($options['model']);
+  }
+  // Assign variables to template
+  $template->assign('create_tpl', array(
+    'NEW_FILE_NAME' => $filename,
+    'MODEL_OPTIONS' => $options['model'],
+    'MODEL_SELECTED' => $selected['model'],
+    'PARENT_OPTIONS' => $options['parent'],
+    'PARENT_SELECTED' => $selected['parent']
+    )
+  );
+}
+else
+{
+  // List existing template extensions
+  $selected = 0; 
+  $options[] = l10n('locfiledit_choose_file');
+  $options[] = '----------------------';
+  foreach (get_extents() as $pwg_template)
+  {
+    $value = './template-extension/' . $pwg_template;
+    $options[$value] =  str_replace('/', ' / ', $pwg_template);
+    if ($edited_file == $value) $selected = $value;
+  }
+  if ($selected == 0 and !empty($edited_file))
+  {
+    $options[$edited_file] =  str_replace(array('./template-extension/', '/'), array('', ' / '), $edited_file);
+    $selected = $edited_file;
+  }
+  $template->assign('css_lang_tpl', array(
+    'OPTIONS' => $options,
+    'SELECTED' => $selected,
+    'NEW_FILE_URL' => $my_base_url.'-tpl&amp;newfile',
+    'NEW_FILE_CLASS' => empty($edited_file) ? '' : 'top_right'
+    )
+  );
+}
+
+$codemirror_mode = 'text/html';
+
+?>
Index: trunk/plugins/LocalFilesEditor/locfiledit.css
===================================================================
--- trunk/plugins/LocalFilesEditor/locfiledit.css	(revision 10312)
+++ 	(revision )
@@ -1,34 +1,0 @@
-#LocalFilesEditor {
-  text-align: center;
-  margin: 0 2em;
-}
-
-#LocalFilesEditor .top_right  {
-  float: right;
-  margin-right: 1%;
-}
-
-#LocalFilesEditor B {
-  float: left;
-}
-
-#LocalFilesEditor TEXTAREA {
-  margin: 0.5em 0;
-  width: 99%;
-  height: 500px;
-  float: left;
-}
-
-#LocalFilesEditor TD {
-  padding: 0.5em;
-}
-
-.CodeMirror {
-  background-color: #EEEEEE;
-  font-size: 1.3em;
-  border: 1px solid #999999;
-  margin: 0.5em 0;
-  width: 99%;
-  min-height: 500px;
-  height: auto;
-}
Index: trunk/plugins/LocalFilesEditor/show_default.php
===================================================================
--- trunk/plugins/LocalFilesEditor/show_default.php	(revision 10312)
+++ trunk/plugins/LocalFilesEditor/show_default.php	(revision 10348)
@@ -25,5 +25,5 @@
 define('IN_ADMIN', true);
 include_once(PHPWG_ROOT_PATH . 'include/common.inc.php');
-include_once(LOCALEDIT_PATH.'functions.inc.php');
+include_once(LOCALEDIT_PATH.'include/functions.inc.php');
 load_language('plugin.lang', LOCALEDIT_PATH);
 check_status(ACCESS_ADMINISTRATOR);
@@ -37,5 +37,5 @@
   }
     
-  $template->set_filename('show_default', dirname(__FILE__) . '/show_default.tpl');
+  $template->set_filename('show_default', dirname(__FILE__) . '/template/show_default.tpl');
   
   $file = file_get_contents(PHPWG_ROOT_PATH . $path);
@@ -45,6 +45,4 @@
     'TITLE' => $title,
     'DEFAULT_CONTENT' => $file,
-    'LOCALEDIT_PATH' => LOCALEDIT_PATH,
-    'CODEMIRROR_MODE' => 'application/x-httpd-php'
     )
   );
Index: trunk/plugins/LocalFilesEditor/show_default.tpl
===================================================================
--- trunk/plugins/LocalFilesEditor/show_default.tpl	(revision 10312)
+++ 	(revision )
@@ -1,35 +1,0 @@
-{html_head}
-<style type="text/css">#headbranch, #theHeader, #copyright {ldelim} display: none; }</style>
-{/html_head}
-{combine_script id="jquery"}
-
-{combine_script id="codemirror" path="plugins/LocalFilesEditor/codemirror/lib/codemirror.js"}
-{combine_script id="codemirror.xml" require="codemirror" path="plugins/LocalFilesEditor/codemirror/mode/xml/xml.js"}
-{combine_script id="codemirror.javascript" require="codemirror" path="plugins/LocalFilesEditor/codemirror/mode/javascript/javascript.js"}
-{combine_script id="codemirror.css" require="codemirror" path="plugins/LocalFilesEditor/codemirror/mode/css/css.js"}
-{combine_script id="codemirror.clike" require="codemirror" path="plugins/LocalFilesEditor/codemirror/mode/clike/clike.js"}
-{combine_script id="codemirror.htmlmixed" require="codemirror.xml,codemirror.javascript,codemirror.css" path="plugins/LocalFilesEditor/codemirror/mode/htmlmixed/htmlmixed.js"}
-{combine_script id="codemirror.php" require="codemirror.xml,codemirror.javascript,codemirror.css,codemirror.clike" path="plugins/LocalFilesEditor/codemirror/mode/php/php.js"}
-
-{combine_css path="plugins/LocalFilesEditor/codemirror/lib/codemirror.css"}
-{combine_css path="plugins/LocalFilesEditor/codemirror/mode/xml/xml.css"}
-{combine_css path="plugins/LocalFilesEditor/codemirror/mode/javascript/javascript.css"}
-{combine_css path="plugins/LocalFilesEditor/codemirror/mode/css/css.css"}
-{combine_css path="plugins/LocalFilesEditor/codemirror/mode/clike/clike.css"}
-{combine_css path="plugins/LocalFilesEditor/locfiledit.css"}
-
-{footer_script}
-var editor = CodeMirror.fromTextArea(document.getElementById("text"), {ldelim}
-  matchBrackets: true,
-  readOnly: true,
-  mode: "{$CODEMIRROR_MODE}",
-  tabMode: "shift"
-});
-{/footer_script}
-
-<div id="LocalFilesEditor">
-<div style="overflow:auto;"><b>{$TITLE}</b></div>
-
-<textarea id="text" rows="30" cols="90">{$DEFAULT_CONTENT}</textarea>
-
-</div>
Index: trunk/plugins/LocalFilesEditor/template/admin.tpl
===================================================================
--- trunk/plugins/LocalFilesEditor/template/admin.tpl	(revision 10348)
+++ trunk/plugins/LocalFilesEditor/template/admin.tpl	(revision 10348)
@@ -0,0 +1,97 @@
+{combine_script id="codemirror" path="plugins/LocalFilesEditor/codemirror/lib/codemirror.js"}
+{combine_script id="codemirror.xml" require="codemirror" path="plugins/LocalFilesEditor/codemirror/mode/xml/xml.js"}
+{combine_script id="codemirror.javascript" require="codemirror" path="plugins/LocalFilesEditor/codemirror/mode/javascript/javascript.js"}
+{combine_script id="codemirror.css" require="codemirror" path="plugins/LocalFilesEditor/codemirror/mode/css/css.js"}
+{combine_script id="codemirror.clike" require="codemirror" path="plugins/LocalFilesEditor/codemirror/mode/clike/clike.js"}
+{combine_script id="codemirror.htmlmixed" require="codemirror.xml,codemirror.javascript,codemirror.css" path="plugins/LocalFilesEditor/codemirror/mode/htmlmixed/htmlmixed.js"}
+{combine_script id="codemirror.php" require="codemirror.xml,codemirror.javascript,codemirror.css,codemirror.clike" path="plugins/LocalFilesEditor/codemirror/mode/php/php.js"}
+
+{combine_css path="plugins/LocalFilesEditor/codemirror/lib/codemirror.css"}
+{combine_css path="plugins/LocalFilesEditor/codemirror/mode/xml/xml.css"}
+{combine_css path="plugins/LocalFilesEditor/codemirror/mode/javascript/javascript.css"}
+{combine_css path="plugins/LocalFilesEditor/codemirror/mode/css/css.css"}
+{combine_css path="plugins/LocalFilesEditor/codemirror/mode/clike/clike.css"}
+{combine_css path="plugins/LocalFilesEditor/template/locfiledit.css"}
+
+{footer_script}
+if (document.getElementById("text") != null)
+  var editor = CodeMirror.fromTextArea(document.getElementById("text"), {ldelim}
+    matchBrackets: true,
+    mode: "{$CODEMIRROR_MODE}",
+    tabMode: "shift"
+  });
+{/footer_script}
+
+<div class="titrePage">
+  <h2>LocalFiles Editor</h2>
+</div>
+
+<form method="post" class="properties" action="{$F_ACTION}" ENCTYPE="multipart/form-data" name="form">
+
+<div id="LocalFilesEditor">
+
+<input type="hidden" value="{$zone_edit.EDITED_FILE}" name="edited_file"/>
+
+{if isset ($create_tpl)}
+  <table>
+    <tr>
+      <td style="text-align: right;">{'locfiledit_new_filename'|@translate}</td>
+      <td style="text-align: left;"><input type="text" size="55" maxlength="50" value="{$create_tpl.NEW_FILE_NAME}" name="tpl_name"/></td>
+    </tr>
+    <tr>
+      <td style="text-align: right;">{'locfiledit_parent_directory'|@translate}</td>
+      <td style="text-align: left;">{html_options name=tpl_parent options=$create_tpl.PARENT_OPTIONS selected=$create_tpl.PARENT_SELECTED}</td>
+    </tr>
+    <tr>
+      <td style="text-align: right;">{'locfiledit_model'|@translate}</td>
+      <td style="text-align: left;">{html_options name=tpl_model options=$create_tpl.MODEL_OPTIONS selected=$create_tpl.MODEL_SELECTED}</td>
+    </tr>
+  </table>
+<br><br>
+<input class="submit" type="submit" value="{'Submit'|@translate}" name="create_tpl" />
+{/if}
+
+{if isset ($css_lang_tpl)}
+{html_options name=file_to_edit options=$css_lang_tpl.OPTIONS selected=$css_lang_tpl.SELECTED}
+<input class="submit" type="submit" value="{'locfiledit_edit'|@translate}" name="edit" />
+<br><br>
+  {if isset ($css_lang_tpl.NEW_FILE_URL)}
+  <span class="{$css_lang_tpl.NEW_FILE_CLASS}">
+  <a href="{$css_lang_tpl.NEW_FILE_URL}">{'locfiledit_new_tpl'|@translate}</a>
+  </span>
+  {/if}
+{/if}
+
+{if isset ($zone_edit)}
+<div id="title_bar">
+{/if}
+
+{if !empty($show_default)}
+{foreach from=$show_default item=file name=default_loop}
+<span class="default_file">
+<a href="{$file.URL}" onclick="window.open( this.href, 'local_file', 'location=no,toolbar=no,menubar=no,status=no,resizable=yes,scrollbars=yes,width=800,height=700' ); return false;">{'locfiledit_show_default'|@translate} "{$file.FILE}"</a>
+</span>
+{if !($smarty.foreach.default_loop.last)}<br>{/if}
+{/foreach}
+{/if}
+
+{if isset ($zone_edit)}
+<span class="file_name">{$zone_edit.FILE_NAME}</span>
+</div> {* title_bar *}
+
+<textarea rows="30" cols="90" name="text" id="text">{$zone_edit.CONTENT_FILE}</textarea>
+<br>
+<input class="submit" type="submit" value="{'locfiledit_save_file'|@translate}" name="submit"/>
+
+{if isset ($restore)}
+<input class="submit" type="submit" value="{'locfiledit_restore'|@translate}" name="restore" onclick="return confirm('{'locfiledit_restore_confirm'|@translate|escape:'javascript'}');"/>
+{/if}
+
+{if isset ($restore_infos)}
+<br><br>
+{'locfiledit_save_bak'|@translate}
+{/if}
+
+{/if} {* zone_edit *}
+</div>
+</form>
Index: trunk/plugins/LocalFilesEditor/template/locfiledit.css
===================================================================
--- trunk/plugins/LocalFilesEditor/template/locfiledit.css	(revision 10348)
+++ trunk/plugins/LocalFilesEditor/template/locfiledit.css	(revision 10348)
@@ -0,0 +1,32 @@
+#LocalFilesEditor {
+  text-align: center;
+  margin: 0 2em;
+}
+
+#LocalFilesEditor #title_bar {
+  overflow: auto;
+}
+
+#LocalFilesEditor .file_name {
+  font-weight: bold;
+  float: left;
+}
+
+#LocalFilesEditor .default_file  {
+  float: right;
+}
+
+#LocalFilesEditor TD {
+  padding: 0.5em;
+}
+
+#LocalFilesEditor TEXTAREA, .CodeMirror {
+  background-color: #EEEEEE;
+  font-family: monospace,Arial,sans-serif;
+  font-size: 1.2em;
+  border: 1px solid #999999;
+  margin: 0.5em 0;
+  width: 100%;
+  min-height: 500px;
+  height: auto;
+}
Index: trunk/plugins/LocalFilesEditor/template/show_default.tpl
===================================================================
--- trunk/plugins/LocalFilesEditor/template/show_default.tpl	(revision 10348)
+++ trunk/plugins/LocalFilesEditor/template/show_default.tpl	(revision 10348)
@@ -0,0 +1,37 @@
+{combine_script id="codemirror" path="plugins/LocalFilesEditor/codemirror/lib/codemirror.js"}
+{combine_script id="codemirror.xml" require="codemirror" path="plugins/LocalFilesEditor/codemirror/mode/xml/xml.js"}
+{combine_script id="codemirror.javascript" require="codemirror" path="plugins/LocalFilesEditor/codemirror/mode/javascript/javascript.js"}
+{combine_script id="codemirror.css" require="codemirror" path="plugins/LocalFilesEditor/codemirror/mode/css/css.js"}
+{combine_script id="codemirror.clike" require="codemirror" path="plugins/LocalFilesEditor/codemirror/mode/clike/clike.js"}
+{combine_script id="codemirror.htmlmixed" require="codemirror.xml,codemirror.javascript,codemirror.css" path="plugins/LocalFilesEditor/codemirror/mode/htmlmixed/htmlmixed.js"}
+{combine_script id="codemirror.php" require="codemirror.xml,codemirror.javascript,codemirror.css,codemirror.clike" path="plugins/LocalFilesEditor/codemirror/mode/php/php.js"}
+
+{combine_css path="plugins/LocalFilesEditor/codemirror/lib/codemirror.css"}
+{combine_css path="plugins/LocalFilesEditor/codemirror/mode/xml/xml.css"}
+{combine_css path="plugins/LocalFilesEditor/codemirror/mode/javascript/javascript.css"}
+{combine_css path="plugins/LocalFilesEditor/codemirror/mode/css/css.css"}
+{combine_css path="plugins/LocalFilesEditor/codemirror/mode/clike/clike.css"}
+{combine_css path="plugins/LocalFilesEditor/template/locfiledit.css"}
+
+{footer_script}
+var editor = CodeMirror.fromTextArea(document.getElementById("text"), {ldelim}
+  readOnly: true,
+  mode: "application/x-httpd-php"
+});
+{/footer_script}
+
+{html_head}
+<style type="text/css">
+#headbranch, #theHeader, #copyright {ldelim} display: none; }
+</style>
+{/html_head}
+
+<div id="LocalFilesEditor">
+
+<div id="title_bar">
+  <span class="file_name">{$TITLE}</span>
+</div>
+
+<textarea id="text" rows="30" cols="90" class="show_default_area">{$DEFAULT_CONTENT}</textarea>
+
+</div>
