Index: /extensions/AdditionalPages/additional_page.php
===================================================================
--- /extensions/AdditionalPages/additional_page.php	(revision 9260)
+++ /extensions/AdditionalPages/additional_page.php	(revision 9261)
@@ -3,73 +3,92 @@
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
-global $template, $conf, $user;
+global $template, $user;
+
+$page['section'] = 'additional_page';
+$identifier = $page['is_homepage'] ? $conf['additional_pages']['homepage'] : $tokens[1];
 
 load_language('plugin.lang.php', AP_PATH);
 
-$ap_id = explode('additional_page/' , $_SERVER['REQUEST_URI']);
-$ap_id = explode('&' , $ap_id[1]);
-$ap_conf = explode ("," , $conf['additional_pages']);
+if (function_exists('get_extended_desc'))
+  add_event_handler('AP_render_content', 'get_extended_desc');
 
 // Récupération des données de la page
-$q = 'SELECT title , pos , text
+$query = 'SELECT id, title , content, users, groups, permalink
 FROM ' . ADD_PAGES_TABLE . '
-WHERE id = ' . $ap_id[0] . ';';
-$result = mysql_fetch_assoc(pwg_query($q));
+';
+$query .= is_numeric($identifier) ?
+  'WHERE id = '.$identifier.';' :
+  'WHERE permalink = "'.$identifier.'";';
 
-if (empty($result))
+$row = mysql_fetch_assoc(pwg_query($query));
+
+if (empty($row))
 {
-  page_not_found('This page does not exist', 'index.php?');
+  if ($page['is_homepage']) return;
+  page_not_found('Requested page does not exist');
 }
 
+if (is_numeric($identifier) and !empty($row['permalink']) and !$page['is_homepage'])
+{
+  redirect(make_index_url().'/page/' . $row['permalink']);
+}
+
+$page['additional_page'] = array(
+  'id' => $row['id'],
+  'permalink' => @$row['permalink'],
+  'title' => trigger_event('AP_render_content', $row['title']),
+  'content' => trigger_event('AP_render_content', $row['content']),
+);
+
 // Utilisateurs autorisés
-if (strpos($result['title'] , 'user_id='))
+if (!empty($row['users']))
 {
-  $array = explode('/user_id=' , $result['title']);
-  $result['title'] = $array[0];
-  $authorized_users = explode(',', $array[1]);
-  if (!is_admin() and $ap_conf[7] == 'on' and !in_array($user['status'], $authorized_users))
+  $authorized_users = explode(',', $row['users']);
+  if (!is_admin() and $conf['additional_pages']['user_perm'] and !in_array($user['status'], $authorized_users))
   {
-  	page_not_found('User not allowed', 'index.php?');
+    if ($page['is_homepage']) return;
+  	page_forbidden(l10n('You are not authorized to access the requested page'));
   }
 }
 
 // Groupe autorisé
-if (strpos($result['title'] , 'group_id='))
+if (!empty($row['groups']))
 {
-  $array = explode('/group_id=' , $result['title']);
-  $result['title'] = $array[0];
-  $authorized_groups = $array[1];
-
   $q = 'SELECT *
 FROM ' . USER_GROUP_TABLE . '
-WHERE user_id = ' . $user['id'] . ' AND group_id IN (' . $authorized_groups . ');';
+WHERE user_id = ' . $user['id'] . ' AND group_id IN (' . $row['groups'] . ');';
   $array = mysql_fetch_array(pwg_query($q));
-  if (!is_admin() and $ap_conf[6] == 'on' and empty($array))
+  if (!is_admin() and $conf['additional_pages']['group_perm'] and empty($array))
   {
-  	page_not_found('User not allowed', 'index.php?');
+    if ($page['is_homepage']) return;
+  	page_forbidden(l10n('You are not authorized to access the requested page'));
   }
 }
 
-// Envoi de la page
-// Extended description
-if (function_exists('get_extended_desc'))
-  add_event_handler('AP_render_content', 'get_extended_desc');
+add_event_handler('loc_end_index', 'ap_set_index');
 
-$template->assign(array(
-  'TITLE' => trigger_event('AP_render_content', $result['title']),
-  'PLUGIN_INDEX_CONTENT_BEGIN' => trigger_event('AP_render_content', $result['text'])));
-if (isset($ap_conf[2]) and $ap_conf[2] == 'on')
+function ap_set_index()
 {
-  $template->assign('PLUGIN_INDEX_ACTIONS' , '
-    <li><a href="' . make_index_url() . '" title="' . l10n('return to homepage') . '">
-      <img src="' . $template->get_themeconf('icon_dir') . '/home.png" class="button" alt="' . l10n('home') . '"/></a>
-    </li>');
-}
-if (is_admin())
-{
-  $template->assign('U_EDIT', PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . AP_DIR . '%2Fadmin%2Fadd_page.php&amp;edit=' . $ap_id[0]);
+  global $template, $page, $conf;
+
+  $template->assign(array(
+    'TITLE' => $page['additional_page']['title'],
+    'PLUGIN_INDEX_CONTENT_BEGIN' => $page['additional_page']['content'],
+    )
+  );
+
+  if ($conf['additional_pages']['show_home'])
+  {
+    $template->assign('PLUGIN_INDEX_ACTIONS' , '
+      <li><a href="'.make_index_url().'" title="' . l10n('return to homepage') . '">
+        <img src="' . $template->get_themeconf('icon_dir') . '/home.png" class="button" alt="' . l10n('home') . '"/></a>
+      </li>');
+  }
+  if (is_admin())
+  {
+    $template->assign('U_EDIT', PHPWG_ROOT_PATH.'admin.php?page=plugin&amp;section='.AP_DIR.'%2Fadmin%2Fadmin.php&amp;tab=edit_page&amp;edit='.$page['additional_page']['id'].'&amp;redirect=true');
+  }
+  $template->clear_assign(array('U_MODE_POSTED', 'U_MODE_CREATED'));
 }
 
-$template->clear_assign(array('U_MODE_POSTED', 'U_MODE_CREATED'));
-
 ?>
Index: /extensions/AdditionalPages/admin/add_page.inc.php
===================================================================
--- /extensions/AdditionalPages/admin/add_page.inc.php	(revision 9261)
+++ /extensions/AdditionalPages/admin/add_page.inc.php	(revision 9261)
@@ -0,0 +1,12 @@
+<?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+$edited_page = array();
+$edited_page['id'] = 0;
+$edited_page['homepage'] = false;
+$page_title = l10n('ap_create');
+
+include(AP_PATH.'admin/page_form.inc.php');
+
+?>
Index: tensions/AdditionalPages/admin/add_page.php
===================================================================
--- /extensions/AdditionalPages/admin/add_page.php	(revision 9260)
+++ 	(revision )
@@ -1,156 +1,0 @@
-<?php
-
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
-load_language('plugin.lang', AP_PATH);
-$ap_conf = explode(',' , $conf['additional_pages']);
-$edited_page = array();
-$page_title = l10n('ap_create');
-
-if (isset($_GET['saved']) and isset($_GET['edit']))
-{
-	array_push($page['infos'], sprintf(l10n('ap_saved_page') , $_GET['edit']));
-}
-
-// Suppression
-if (isset($_POST['delete']) and isset($_GET['edit']))
-{
-	pwg_query('DELETE FROM ' . ADD_PAGES_TABLE . ' WHERE id = ' . $_GET['edit'] . ';');
-  array_push($page['infos'], l10n('ap_deleted_page'));
-  @unlink(AP_PATH . 'backup/' . $_GET['edit'] . '.txt');
-  return;
-}
-
-// Enregistrement
-if (isset($_POST['save']))
-{
-  $group_access = (!empty($_POST['groups']) ? implode(',', $_POST['groups']) : '');
-  $user_access = (!empty($_POST['users']) ? implode(',', $_POST['users']) : '');
-  if (empty($_POST['name']))
-  {
-    array_push($page['errors'], l10n('ap_no_name'));
-    $edited_page['title'] = '';
-    $edited_page['pos'] = $_POST['pos'];
-    $edited_page['text'] = stripslashes($_POST['ap_content']);
-    $edited_page['group'] = (!empty($_POST['groups']) ? $_POST['groups'] : array());
-    $edited_page['user'] = (!empty($_POST['users']) ? $_POST['users'] :  array());
-  }
-  else
-  {
-    $PageTitle = $_POST['name'];
-    if (!empty($group_access))
-    {
-      $PageTitle .= '/group_id=' . $group_access ;
-    }
-    if ($ap_conf[7] == 'on')
-    {
-      $PageTitle .= '/user_id=' . $user_access ;
-    }
-    if (isset($_GET['edit']))
-    {
-      $next_element_id = $_GET['edit'];
-      pwg_query('DELETE FROM ' . ADD_PAGES_TABLE . ' WHERE id = ' . $_GET['edit'] . ';');
-    }
-    else
-    {
-      $q = 'SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id  FROM ' . ADD_PAGES_TABLE . ' ;';
-      list($next_element_id) = mysql_fetch_array(pwg_query($q));
-    }
-    if ($_POST['pos'] == '') $_POST['pos'] = 'NULL';
-    $q = 'INSERT INTO ' . ADD_PAGES_TABLE . ' ( id , pos , lang , title , text )
-VALUES (' . $next_element_id . ' , ' . $_POST['pos'] . ' , "' . $_POST['lang'] . '" , "' . $PageTitle . '" , "' . $_POST['ap_content'] . '");';
-    pwg_query($q);
-
-    // Enregistrement du fichier de sauvegarde
-    $sav_file = @fopen(AP_PATH . 'backup/' . $next_element_id . '.txt', "w");
-    @fwrite($sav_file, "Title: " . $_POST['name'] . "
-Position: " . $_POST['pos'] . "
-Language: " . $_POST['lang'] . "
-
-" . $_POST['ap_content']);
-    @fclose($sav_file);
-
-    if (isset($ap_conf[4]) and $ap_conf[4] == 'on')
-    {
-      redirect(get_root_url() . 'index.php?/additional_page/' . $next_element_id);
-    }
-    else
-    {
-      redirect(get_root_url() . 'admin.php?page=plugin&section=' . AP_DIR . '%2Fadmin%2Fadd_page.php&saved=1&edit=' . $next_element_id);
-    }
-  }
-}
-
-// Chargement des données
-if (isset($_GET['edit']))
-{
-  $q = 'SELECT id , pos , lang , title , text
-FROM ' . ADD_PAGES_TABLE . '
-WHERE id = ' . $_GET['edit'] . ';';
-  $edited_page = mysql_fetch_assoc(pwg_query($q));
-  $page_title = l10n('ap_modify');
-  // Utilisateurs autorisés
-  if (strpos($edited_page['title'] , '/user_id='))
-  {
-    $array = explode('/user_id=' , $edited_page['title']);
-    $edited_page['title'] = $array[0];
-    $edited_page['user'] = explode(',', $array[1]);
-  }
-  // Groupes autorisés
-  if (strpos($edited_page['title'] , '/group_id='))
-  {
-    $array = explode('/group_id=' , $edited_page['title']);
-    $edited_page['title'] = $array[0];
-    $edited_page['group'] = explode(',', $array[1]);
-  }
-  // Lien de suppression
-  $template->assign('delete', true);
-}
-
-// Selection des langues
-$options['ALL'] = l10n('ap_all_lang');
-$selected = 'ALL';
-foreach (get_languages() as $language_code => $language_name)
-{
-  $options[$language_code] = $language_name;
-  if (isset($edited_page['lang']) and $edited_page['lang'] == $language_code)
-  {
-    $selected = $language_code;
-  }
-}
-$template->assign('lang', array(
-  'OPTIONS' => $options,
-  'SELECTED' => $selected));
-
-// Selection des groupes
-if (isset($ap_conf[6]) and $ap_conf[6] == 'on')
-{
-	include_once(AP_PATH . 'admin/functions_groups.php');
-	$template->assign('GROUPSELECTION', get_html_groups_selection(get_all_groups(), 'groups', (!empty($edited_page['group']) ? $edited_page['group'] : array())));
-}
-
-// Selection des utilisateurs
-if (isset($ap_conf[7]) and $ap_conf[7] == 'on')
-{
-	$selected_users = (isset($edited_page['user']) ? $edited_page['user'] : array('guest', 'generic', 'normal'));
-	$template->assign('user_perm', array(
-    'GUEST' => (in_array('guest', $selected_users) ? 'checked="checked"' : ''),
-		'GENERIC' => (in_array('generic', $selected_users) ? 'checked="checked"' : ''),
-		'NORMAL' => (in_array('normal', $selected_users) ? 'checked="checked"' : '')));
-}
-
-// Chargement des données pour l'édition
-if (!empty($edited_page))
-{
-  $template->assign(array(
-    'NAME' => $edited_page['title'],
-    'POS' => $edited_page['pos'],
-    'CONTENT' => $edited_page['text']));
-}
-
-// Parametrage du template
-$template->assign('AP_TITLE', $page_title);
-
-$template->set_filename('plugin_admin_content', dirname(__FILE__) . '/add_page.tpl');
-$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
-
-?>
Index: tensions/AdditionalPages/admin/add_page.tpl
===================================================================
--- /extensions/AdditionalPages/admin/add_page.tpl	(revision 9260)
+++ 	(revision )
@@ -1,88 +1,0 @@
-{literal}
-<script type="text/javascript">
-function GereChkbox(conteneur, a_faire) {
-var blnEtat=null;
-var Chckbox = document.getElementById(conteneur).firstChild;
-	while (Chckbox!=null) {
-		if (Chckbox.nodeName=="INPUT")
-			if (Chckbox.getAttribute("type")=="checkbox") {
-				blnEtat = (a_faire=='0') ? false : (a_faire=='1') ? true : (document.getElementById(Chckbox.getAttribute("id")).checked) ? false : true;
-				document.getElementById(Chckbox.getAttribute("id")).checked=blnEtat;
-			}
-		Chckbox = Chckbox.nextSibling;
-	}
-}
-</script>
-{/literal}
-{$TINYMCE_SCRIPT}
-
-<div class="titrePage">
-	<h2>{$AP_TITLE}</h2>
-</div>
-<form method="post" action="" class="properties"  ENCTYPE="multipart/form-data">
-	<table>
-		<tr>
-			<td align="right">{'ap_page_name'|@translate} &nbsp;&nbsp;</td>
-			<td><input type="text" size="80" maxlength="255" value="{$NAME}" name="name"/></td>
-		</tr>
-		<tr>
-			<td align="right">{'ap_page_pos'|@translate} &nbsp;&nbsp;</td>
-			<td><input type="text" size="3" maxlength="3" value="{$POS}" name="pos"/>&nbsp; ({'ap_pos0'|@translate})</td>
-		</tr>
-		<tr>
-			<td align="right">{'ap_page_lang'|@translate} &nbsp;&nbsp;</td>
-			<td>
-        {html_options name=lang options=$lang.OPTIONS selected=$lang.SELECTED}
-			</td>
-		</tr>
-
-		{if isset($user_perm)}
-		<tr>
-			<td colspan="2"><hr></td>
-		</tr>
-		<tr>
-			<td align="right">{'ap_authorized_users'|@translate} &nbsp;&nbsp;</td>
-			<td>
-				<div id="users">
-				<input type="checkbox" name="users[]" id="guest" value="guest" {$user_perm.GUEST}><label>&nbsp;{'user_status_guest'|@translate}</label>
-				<input type="checkbox" name="users[]" id="generic" value="generic" {$user_perm.GENERIC}><label>&nbsp;{'user_status_generic'|@translate}</label>
-				<input type="checkbox" name="users[]" id="normal" value="normal" {$user_perm.NORMAL}><label>&nbsp;{'user_status_normal'|@translate}</label>
-				<input type="checkbox" name="users[]" id="admin" value="admin" checked="checked" disabled onclick="return false;"><label>&nbsp;{'user_status_admin'|@translate}</label>
-				</div>
-			</td>
-        </tr>
-    {/if}
-
-		{if !empty($GROUPSELECTION)}
-		<tr>
-			<td colspan="2"><hr></td>
-		</tr>
-		<tr>
-			<td align="right">{'ap_authorized_group'|@translate} &nbsp;&nbsp;</td>
-			<td>{$GROUPSELECTION}</td>
-        </tr>
-        <tr>
-        	<td></td>
-			<td><a href="javascript:GereChkbox('groups','1');">{'ap_select_all'|@translate}</a> / <a href="javascript:GereChkbox('groups','0');">{'ap_unselect_all'|@translate}</a>
-			<i>&nbsp;&nbsp; {'ap_guest'|@translate}</i></td>
-        </tr>
-    {/if}
-</table>
-<table style="width:95%;">
-		<tr>
-			<td colspan="2" align="center"><br>
-				<b>{'ap_page_content'|@translate}</b><br>
-				<textarea name="ap_content" id="ap_content" rows="30" cols="50" style="width:100%;">{$CONTENT}</textarea>
-      </td>
-		</tr>
-
-		<tr>
-		<td colspan="2" align="center"><br>
-		<input class="submit" type="submit" value="{'ap_save'|@translate}" name="save" {$TAG_INPUT_ENABLED}>
-		{if isset($delete)}
-		<input class="submit" type="submit" value="{'ap_delete'|@translate}" name="delete" onclick="return confirm('Are you sure?'|@translate);" {$TAG_INPUT_ENABLED}/>
-		{/if}
-		</tr>
-</table>
-
-</form>
Index: /extensions/AdditionalPages/admin/admin.php
===================================================================
--- /extensions/AdditionalPages/admin/admin.php	(revision 9260)
+++ /extensions/AdditionalPages/admin/admin.php	(revision 9261)
@@ -4,82 +4,26 @@
 load_language('plugin.lang', AP_PATH);
 
-global $conf, $template, $lang;
+global $conf, $template;
 
-$ap_conf = explode ("," , $conf['additional_pages']);
+include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
+$my_base_url = get_admin_plugin_menu_link(__FILE__);
 
-// Enregistrement de la configuration
-if (isset($_POST['submit']))
+if (!isset($_GET['tab']))
+  $page['tab'] = 'manage';
+else
+  $page['tab'] = $_GET['tab'];
+
+include(AP_PATH.'admin/'.$page['tab'].'.inc.php');
+
+$tabsheet = new tabsheet();
+$tabsheet->add('manage', l10n('Manage'), $my_base_url.'&amp;tab=manage');
+$tabsheet->add('add_page', l10n('ap_add_page'), $my_base_url.'&amp;tab=add_page');
+$tabsheet->add('config', l10n('Configuration'), $my_base_url.'&amp;tab=config');
+if ($page['tab'] == 'edit_page')
 {
-	foreach($_POST['menu_lang'] as $language_code => $name)
-  {
-		if ($language_code == 'default') $save_languages[] = $name;
-		elseif (!empty($name)) $save_languages[] = $language_code . ':' . $name;
-	}
-	$languages = implode('/', $save_languages);
-    if (!isset($_POST['show_menu']))
-        $_POST['show_menu'] = 'off';
-    if (!isset($_POST['show_home']))
-        $_POST['show_home'] = 'off';
-    if (!isset($_POST['show_edit']))
-        $_POST['show_edit'] = 'off';
-    if (!isset($_POST['redirect']))
-        $_POST['redirect'] = 'off';
-    if (!isset($_POST['group_perm']))
-        $_POST['group_perm'] = 'off';
-    if (!isset($_POST['user_perm']))
-        $_POST['user_perm'] = 'off';
-    $ap_conf = array($languages,
-        $_POST['show_menu'],
-        $_POST['show_home'],
-        $_POST['show_edit'],
-        $_POST['redirect'],
-        $ap_conf[5], //Ancien emplacement du bbcode
-        $_POST['group_perm'],
-        $_POST['user_perm']);
-    $query = '
-UPDATE ' . CONFIG_TABLE . '
-  SET value="' . implode ("," , $ap_conf) . '"
-  WHERE param="additional_pages"
-  LIMIT 1';
-    pwg_query($query);
-    array_push($page['infos'], l10n('ap_conf_saved'));
+  $tabsheet->add('edit_page', l10n('ap_edit_page'), $my_base_url.'&amp;tab=edit_page');
 }
-
-// Gestion des langues pour le bloc menu
-$languages = explode('/', $ap_conf[0]);
-foreach($languages as $language)
-{
-	$array = explode(':', $language);
-	if (!isset($array[1])) $menu_langs['default'] = $array[0];
-	else $menu_langs[$array[0]] = $array[1];
-}
-
-$template->assign('LANG_DEFAULT_VALUE', $menu_langs['default']);
-foreach (get_languages() as $language_code => $language_name)
-{
-	$template->append('language', array(
-    'LANGUAGE_NAME' => $language_name,
-    'LANGUAGE_CODE' => $language_code,
-    'VALUE' => (isset($menu_langs[$language_code]) ? $menu_langs[$language_code] : '')));
-}
-
-// Parametrage du template
-$template->assign(array(
-  'MENU_NAME' => $ap_conf[0],
-  'SHOW_MENU' => (isset($ap_conf[1]) and $ap_conf[1] == 'on') ? 'checked="checked"' : '',
-  'SHOW_HOME' => (isset($ap_conf[2]) and $ap_conf[2] == 'on') ? 'checked="checked"' : '',
-  'SHOW_EDIT' => (isset($ap_conf[3]) and $ap_conf[3] == 'on') ? 'checked="checked"' : '',
-  'REDIRECT' => (isset($ap_conf[4]) and $ap_conf[4] == 'on') ? 'checked="checked"' : '',
-  'GROUP_PERM' => (isset($ap_conf[6]) and $ap_conf[6] == 'on') ? 'checked="checked"' : '',
-  'USER_PERM' => (isset($ap_conf[7]) and $ap_conf[7] == 'on') ? 'checked="checked"' : ''));
-		
-// Lien de conversion bbcode
-if (isset($ap_conf[5]) and $ap_conf[5] == 'on')
-{
-	$template->assign('convert_bbcode', array('PATH' => get_admin_plugin_menu_link(AP_PATH . 'admin/parse_bbcode.php')));
-}
-
-$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl'));
-$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
+$tabsheet->select($page['tab']);
+$tabsheet->assign();
 
 ?>
Index: tensions/AdditionalPages/admin/admin.tpl
===================================================================
--- /extensions/AdditionalPages/admin/admin.tpl	(revision 9260)
+++ 	(revision )
@@ -1,58 +1,0 @@
-<div class="titrePage">
-	<h2>Additional Pages</h2>
-</div>
-
-<form name="apform" method="post" action="" class="properties"  ENCTYPE="multipart/form-data">
-<fieldset>
-	<legend>{'ap_config'|@translate}</legend>
-	<table>
-		<tr>
-			<td><br>{'ap_menu_name'|@translate} : &nbsp;&nbsp;</td>
-			<td><br>{'Default'|@translate}&nbsp;&nbsp;</td>
-			<td><br><input type="text" size="50" maxlength="255" value="{$LANG_DEFAULT_VALUE}" name="menu_lang[default]"/></td>
-		</tr>
-		{foreach from=$language item=lang}
-		<tr>
-			<td></td>
-			<td>{$lang.LANGUAGE_NAME}&nbsp;&nbsp;</td>
-			<td><input type="text" size="50" maxlength="255" value="{$lang.VALUE}" name="menu_lang[{$lang.LANGUAGE_CODE}]"/></td>
-		</tr>
-		{/foreach}
-		<tr>
-			<td colspan="3"><br><hr><br></td>
-		</tr>
-		<tr>
-			<td colspan="3"><input type="checkbox" name="show_menu" value="on" {$SHOW_MENU}/> {'ap_show_menu'|@translate}</td>
-		</tr>
-		<tr>
-			<td colspan="3"><input type="checkbox" name="show_home" value="on" {$SHOW_HOME}/> {'ap_show_home'|@translate}</td>
-		</tr>
-		<tr>
-			<td colspan="3"><input type="checkbox" name="show_edit" value="on" {$SHOW_EDIT}/> {'ap_show_edit'|@translate}</td>
-		</tr>
-		<tr>
-			<td colspan="3"><input type="checkbox" name="redirect" value="on" {$REDIRECT}/> {'ap_redirect'|@translate}</td>
-		</tr>
-		<tr>
-			<td colspan="3"><br><hr><br></td>
-		</tr>
-		<tr>
-			<td colspan="3">{'ap_perm'|@translate}</td>
-		</tr>
-		<tr>
-			<td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="user_perm" value="on" {$USER_PERM}/> <i>{'ap_user_perm'|@translate}</i></td>
-		</tr>
-		<tr>
-			<td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="group_perm" value="on" {$GROUP_PERM}/> <i>{'ap_group_perm'|@translate}</i></td>
-		</tr>
-
-	</table>
-
-<br>
-</fieldset>
-	<p><input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" {$TAG_INPUT_ENABLED}/></p>
-</form>
-
-{if isset($convert_bbcode)}
-	<p><a href="{$convert_bbcode.PATH}">{'ap_parse_bbcode'|@translate}</a></p>
-{/if}
Index: /extensions/AdditionalPages/admin/config.inc.php
===================================================================
--- /extensions/AdditionalPages/admin/config.inc.php	(revision 9261)
+++ /extensions/AdditionalPages/admin/config.inc.php	(revision 9261)
@@ -0,0 +1,51 @@
+<?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+// Enregistrement de la configuration
+if (isset($_POST['submit']))
+{
+  $params = array('show_menu', 'show_home', 'redirect', 'group_perm', 'user_perm');
+
+  $new_conf = array();
+  foreach ($params as $param)
+  {
+    $new_conf[$param] = isset($_POST[$param]);
+  }
+
+  $new_conf['languages'] = array();
+	foreach($_POST['menu_lang'] as $language_code => $name)
+  {
+		if (!empty($name))
+      $new_conf['languages'][$language_code] = $name;
+	}
+
+    $query = '
+UPDATE ' . CONFIG_TABLE . '
+  SET value="'.addslashes(serialize($new_conf)).'"
+  WHERE param="additional_pages"
+  LIMIT 1';
+    pwg_query($query);
+    array_push($page['infos'], l10n('ap_conf_saved'));
+    $conf['additional_pages'] = $new_conf;
+}
+
+// Gestion des langues pour le bloc menu
+$template->assign('LANG_DEFAULT_VALUE', @$conf['additional_pages']['languages']['default']);
+foreach (get_languages() as $language_code => $language_name)
+{
+	$template->append('language', array(
+    'LANGUAGE_NAME' => $language_name,
+    'LANGUAGE_CODE' => $language_code,
+    'VALUE' => isset($conf['additional_pages']['languages'][$language_code]) ? $conf['additional_pages']['languages'][$language_code] : '',
+    )
+  );
+}
+
+// Parametrage du template
+$template->assign('ap_conf', $conf['additional_pages']);
+
+$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/template/config.tpl'));
+$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
+
+?>
Index: /extensions/AdditionalPages/admin/edit_page.inc.php
===================================================================
--- /extensions/AdditionalPages/admin/edit_page.inc.php	(revision 9261)
+++ /extensions/AdditionalPages/admin/edit_page.inc.php	(revision 9261)
@@ -0,0 +1,36 @@
+<?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+if (!is_numeric($_GET['edit']))
+{
+  die('Wrong identifier');
+}
+
+// Suppression
+if (isset($_REQUEST['delete']) and isset($_GET['edit']))
+{
+	pwg_query('DELETE FROM ' . ADD_PAGES_TABLE . ' WHERE id = ' . $_GET['edit'] . ';');
+  @unlink($conf['local_data_dir'].'/additional_pages_backup/' . $_GET['edit'] . '.txt');
+  if ($conf['additional_pages']['homepage'] == $_GET['edit'])
+  {
+    $conf['additional_pages']['homepage'] = null;
+    pwg_query('UPDATE '.CONFIG_TABLE.' SET value = "'.addslashes(serialize($conf['additional_pages'])).'" WHERE param = "additional_pages";');
+  }
+  redirect($my_base_url.'&page_deleted=');
+}
+
+$q = 'SELECT id , lang , title , content , users , groups , permalink
+FROM ' . ADD_PAGES_TABLE . '
+WHERE id = '.$_GET['edit'].';';
+
+$edited_page = mysql_fetch_assoc(pwg_query($q));
+$page_title = l10n('ap_modify');
+$edited_page['homepage'] = $conf['additional_pages']['homepage'] == $edited_page['id'];
+
+// Lien de suppression
+$template->assign('delete', true);
+
+include(AP_PATH.'admin/page_form.inc.php');
+
+?>
Index: /extensions/AdditionalPages/admin/manage.inc.php
===================================================================
--- /extensions/AdditionalPages/admin/manage.inc.php	(revision 9261)
+++ /extensions/AdditionalPages/admin/manage.inc.php	(revision 9261)
@@ -0,0 +1,59 @@
+<?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+if (isset($_GET['page_saved']))
+{
+  array_push($page['infos'], l10n('ap_saved_page'));
+}
+if (isset($_GET['page_deleted']))
+{
+  array_push($page['infos'], l10n('ap_deleted_page'));
+}
+
+if (isset($_POST['submit']))
+{
+  asort($_POST['position'], SORT_NUMERIC);
+  $pos = 1;
+  foreach($_POST['position'] as $id => $old_pos)
+  {
+    $num = isset($_POST['hide_'.$id]) ? -1 : +1;
+    $query = '
+UPDATE ' . ADD_PAGES_TABLE . '
+  SET pos = '.$num*abs($pos++).'
+  WHERE id = '.$id.'
+LIMIT 1
+;';
+    pwg_query($query);
+  }
+}
+
+$languages = get_languages();
+
+$query = 'SELECT id, pos, lang, title
+FROM '.ADD_PAGES_TABLE.'
+ORDER BY ABS(pos) ASC, id ASC
+;';
+$result = pwg_query($query);
+
+while ($row = pwg_db_fetch_assoc($result))
+{
+  $row['U_PAGE'] = make_index_url().'/page/'.(isset($row['permalink']) ? $row['permalink'] : $row['id']);
+  $row['U_EDIT'] = PHPWG_ROOT_PATH.'admin.php?page=plugin&amp;section='.AP_DIR.'%2Fadmin%2Fadmin.php&amp;tab=edit_page&amp;edit='.$row['id'];
+  $row['U_DELETE'] = PHPWG_ROOT_PATH.'admin.php?page=plugin&amp;section='.AP_DIR.'%2Fadmin%2Fadmin.php&amp;tab=edit_page&amp;edit='.$row['id'].'&amp;delete=';
+
+  $row['language'] = @$languages[$row['lang']];
+
+  $template->append('pages', $row);
+}
+
+$template->assign(array(
+  'F_ACTION', $my_base_url.'&amp;tab=manage',
+  'HOMEPAGE' => $conf['additional_pages']['homepage'],
+  )
+);
+
+$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/template/manage.tpl'));
+$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
+
+?>
Index: /extensions/AdditionalPages/admin/page_form.inc.php
===================================================================
--- /extensions/AdditionalPages/admin/page_form.inc.php	(revision 9261)
+++ /extensions/AdditionalPages/admin/page_form.inc.php	(revision 9261)
@@ -0,0 +1,154 @@
+<?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+// Enregistrement
+if (isset($_POST['save']))
+{
+  if (empty($_POST['title']))
+  {
+    array_push($page['errors'], l10n('ap_no_name'));
+  }
+  if (!empty($_POST['permalink']))
+  {
+    $permalink = $_POST['permalink'];
+    $sanitized_permalink = preg_replace( '#[^a-zA-Z0-9_/-]#', '' ,$permalink);
+    $sanitized_permalink = trim($sanitized_permalink, '/');
+    $sanitized_permalink = str_replace('//', '/', $sanitized_permalink);
+    if ( $sanitized_permalink != $permalink or preg_match( '#^(\d)+(-.*)?$#', $permalink) )
+    {
+      array_push($page['errors'], l10n('The permalink name must be composed of a-z, A-Z, 0-9, "-", "_" or "/". It must not be numeric or start with number followed by "-"'));
+    }
+    $query ='
+SELECT id FROM '.ADD_PAGES_TABLE.'
+WHERE permalink = "'.$permalink.'"
+  AND id <> '.$edited_page['id'].'
+;';
+    $ids = array_from_query($query, 'id');
+    if (!empty($ids))
+    {
+      array_push($page['errors'], sprintf(l10n('Permalink %s is already used by additional page %s'), $permalink, $ids[0]));
+    }
+    $permalink = '"'.$permalink.'"';
+  }
+  else
+  {
+    $permalink = 'NULL';
+  }
+
+  $language = $_POST['lang'] != 'ALL' ? '"'.$_POST['lang'].'"' : 'NULL';
+  $group_access = !empty($_POST['groups']) ? '"'.implode(',', $_POST['groups']).'"' : 'NULL';
+  $user_access = !empty($_POST['users']) ? '"'.implode(',', $_POST['users']).'"' : 'NULL';
+
+  if (empty($page['errors']))
+  {
+    if ($page['tab'] == 'edit_page')
+    {
+      $query = '
+UPDATE '.ADD_PAGES_TABLE.'
+SET lang = '.$language.',
+  title = "'.$_POST['title'].'",
+  content = "'.$_POST['ap_content'].'",
+  users = '.$user_access.',
+  groups = '.$group_access.',
+  permalink = '.$permalink.'
+WHERE id = '.$edited_page['id'] .'
+;';
+      pwg_query($query);
+    }
+    else
+    {
+      $query = '
+INSERT INTO ' . ADD_PAGES_TABLE . ' ( lang , title , content , users , groups , permalink)
+VALUES ('.$language.' , "'.$_POST['title'].'" , "'.$_POST['ap_content'].'" , '.$user_access.' , '.$group_access.' , '.$permalink.');';
+      pwg_query($query);
+      $edited_page['id'] = mysql_insert_id();
+    }
+
+    // Homepage
+    if (isset($_POST['homepage']) xor $conf['additional_pages']['homepage'] == $edited_page['id'])
+    {
+      $conf['additional_pages']['homepage'] = isset($_POST['homepage']) ? $edited_page['id'] : null;
+      pwg_query('UPDATE '.CONFIG_TABLE.' SET value = "'.addslashes(serialize($conf['additional_pages'])).'" WHERE param = "additional_pages";');
+    }
+
+    // Enregistrement du fichier de sauvegarde
+    mkgetdir($conf['local_data_dir'], MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
+    mkgetdir($conf['local_data_dir'].'/additional_pages_backup', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
+    $sav_file = @fopen($conf['local_data_dir'].'/additional_pages_backup/' . $edited_page['id'] . '.txt', "w");
+    @fwrite($sav_file, "Title: ".$_POST['title']."
+Permalink: ".$_POST['permalink']."
+Language: ".$_POST['lang']."
+
+" . $_POST['ap_content']);
+    @fclose($sav_file);
+
+    if (isset($_GET['redirect']))
+    {
+      redirect(make_index_url() . '/page/' . $edited_page['id']);
+    }
+    redirect($my_base_url.'&page_saved=');
+  }
+
+  $edited_page['title'] = stripslashes($_POST['title']);
+  $edited_page['permalink'] = $_POST['permalink'];
+  $edited_page['content'] = stripslashes($_POST['ap_content']);
+  $edited_page['groups'] = !empty($_POST['groups']) ? trim($group_access, '"') : '';
+  $edited_page['users'] = !empty($_POST['users']) ? trim($user_access, '"') :  '';
+  $edited_page['homepage'] = isset($_POST['homepage']);
+}
+
+// Selection des langues
+$options['ALL'] = l10n('ap_all_lang');
+$selected = 'ALL';
+foreach (get_languages() as $language_code => $language_name)
+{
+  $options[$language_code] = $language_name;
+  if (isset($edited_page['lang']) and $edited_page['lang'] == $language_code)
+  {
+    $selected = $language_code;
+  }
+}
+$template->assign('lang', array(
+  'OPTIONS' => $options,
+  'SELECTED' => $selected));
+
+// Selection des groupes
+if ($conf['additional_pages']['group_perm'])
+{
+	include_once(AP_PATH . 'admin/functions_groups.php');
+  $groups = !empty($edited_page['groups']) ? explode(',', $edited_page['groups']) : array();
+	$template->assign('GROUPSELECTION', get_html_groups_selection(get_all_groups(), 'groups', $groups));
+}
+
+// Selection des utilisateurs
+if ($conf['additional_pages']['user_perm'])
+{
+  if (isset($_GET['edit']))
+	  $selected_users = isset($edited_page['users']) ? explode(',', $edited_page['users']) : array();
+  else
+    $selected_users = array('guest', 'generic', 'normal');
+
+	$template->assign('user_perm', array(
+    'GUEST' => (in_array('guest', $selected_users) ? 'checked="checked"' : ''),
+		'GENERIC' => (in_array('generic', $selected_users) ? 'checked="checked"' : ''),
+		'NORMAL' => (in_array('normal', $selected_users) ? 'checked="checked"' : '')));
+}
+
+// Chargement des données pour l'édition
+if ($page['tab'] == 'edit_page')
+{
+  $template->assign(array(
+    'NAME' => $edited_page['title'],
+    'PERMALINK' => $edited_page['permalink'],
+    'HOMEPAGE' => $edited_page['homepage'],
+    'CONTENT' => $edited_page['content']));
+}
+
+// Parametrage du template
+$template->assign('AP_TITLE', $page_title);
+
+$template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/add_page.tpl');
+$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
+
+?>
Index: /extensions/AdditionalPages/admin/template/add_page.tpl
===================================================================
--- /extensions/AdditionalPages/admin/template/add_page.tpl	(revision 9261)
+++ /extensions/AdditionalPages/admin/template/add_page.tpl	(revision 9261)
@@ -0,0 +1,91 @@
+{literal}
+<script type="text/javascript">
+function GereChkbox(conteneur, a_faire) {
+var blnEtat=null;
+var Chckbox = document.getElementById(conteneur).firstChild;
+	while (Chckbox!=null) {
+		if (Chckbox.nodeName=="INPUT")
+			if (Chckbox.getAttribute("type")=="checkbox") {
+				blnEtat = (a_faire=='0') ? false : (a_faire=='1') ? true : (document.getElementById(Chckbox.getAttribute("id")).checked) ? false : true;
+				document.getElementById(Chckbox.getAttribute("id")).checked=blnEtat;
+			}
+		Chckbox = Chckbox.nextSibling;
+	}
+}
+</script>
+{/literal}
+
+<div class="titrePage">
+	<h2>{$AP_TITLE}</h2>
+</div>
+<form method="post" action="" class="properties"  ENCTYPE="multipart/form-data">
+	<table>
+		<tr>
+			<td align="right">{'ap_page_name'|@translate} &nbsp;&nbsp;</td>
+			<td><input type="text" size="60" maxlength="255" value="{if isset($NAME)}{$NAME}{/if}" name="title"/></td>
+		</tr>
+		<tr>
+			<td align="right">{'Permalink'|@translate} &nbsp;&nbsp;</td>
+			<td><input type="text" size="60" value="{if isset($PERMALINK)}{$PERMALINK}{/if}" name="permalink"/></td>
+		</tr>
+		<tr>
+			<td align="right">{'ap_page_lang'|@translate} &nbsp;&nbsp;</td>
+			<td>
+        {html_options name=lang options=$lang.OPTIONS selected=$lang.SELECTED}
+			</td>
+		</tr>
+		<tr>
+			<td align="right">{'ap_set_as_homepage'|@translate} &nbsp;&nbsp;</td>
+			<td><input type="checkbox" name="homepage" {if isset($HOMEPAGE) and $HOMEPAGE}checked="checked"{/if}"/></td>
+		</tr>
+
+		{if isset($user_perm)}
+		<tr>
+			<td colspan="2"><hr></td>
+		</tr>
+		<tr>
+			<td align="right">{'ap_authorized_users'|@translate} &nbsp;&nbsp;</td>
+			<td>
+				<div id="users">
+				<input type="checkbox" name="users[]" id="guest" value="guest" {$user_perm.GUEST}><label>&nbsp;{'user_status_guest'|@translate}</label>
+				<input type="checkbox" name="users[]" id="generic" value="generic" {$user_perm.GENERIC}><label>&nbsp;{'user_status_generic'|@translate}</label>
+				<input type="checkbox" name="users[]" id="normal" value="normal" {$user_perm.NORMAL}><label>&nbsp;{'user_status_normal'|@translate}</label>
+				<input type="checkbox" name="users[]" id="admin" value="admin" checked="checked" disabled onclick="return false;"><label>&nbsp;{'user_status_admin'|@translate}</label>
+				</div>
+			</td>
+        </tr>
+    {/if}
+
+		{if !empty($GROUPSELECTION)}
+		<tr>
+			<td colspan="2"><hr></td>
+		</tr>
+		<tr>
+			<td align="right">{'ap_authorized_group'|@translate} &nbsp;&nbsp;</td>
+			<td>{$GROUPSELECTION}</td>
+        </tr>
+        <tr>
+        	<td></td>
+			<td><a href="javascript:GereChkbox('groups','1');">{'ap_select_all'|@translate}</a> / <a href="javascript:GereChkbox('groups','0');">{'ap_unselect_all'|@translate}</a>
+			<i>&nbsp;&nbsp; {'ap_guest'|@translate}</i></td>
+        </tr>
+    {/if}
+</table>
+<table style="width:95%;">
+		<tr>
+			<td colspan="2" align="center"><br>
+				<b>{'ap_page_content'|@translate}</b><br>
+				<textarea name="ap_content" id="ap_content" rows="30" cols="50" style="width:100%;">{if isset($CONTENT)}{$CONTENT}{/if}</textarea>
+      </td>
+		</tr>
+
+		<tr>
+		<td colspan="2" align="center"><br>
+		<input class="submit" type="submit" value="{'ap_save'|@translate}" name="save">
+		{if isset($delete)}
+		<input class="submit" type="submit" value="{'ap_delete'|@translate}" name="delete" onclick="return confirm('Are you sure?'|@translate);"/>
+		{/if}
+		</tr>
+</table>
+
+</form>
Index: /extensions/AdditionalPages/admin/template/config.tpl
===================================================================
--- /extensions/AdditionalPages/admin/template/config.tpl	(revision 9261)
+++ /extensions/AdditionalPages/admin/template/config.tpl	(revision 9261)
@@ -0,0 +1,55 @@
+<div class="titrePage">
+	<h2>Additional Pages - {'Configuration'|@translate}</h2>
+</div>
+
+<form name="apform" method="post" action="" class="properties"  ENCTYPE="multipart/form-data">
+<fieldset>
+	<legend>{'ap_config'|@translate}</legend>
+	<table>
+		<tr>
+			<td><br>{'ap_menu_name'|@translate} : &nbsp;&nbsp;</td>
+			<td><br>{'Default'|@translate}&nbsp;&nbsp;</td>
+			<td><br><input type="text" size="50" maxlength="255" value="{$LANG_DEFAULT_VALUE}" name="menu_lang[default]"/></td>
+		</tr>
+		{foreach from=$language item=lang}
+		<tr>
+			<td></td>
+			<td>{$lang.LANGUAGE_NAME}&nbsp;&nbsp;</td>
+			<td><input type="text" size="50" maxlength="255" value="{$lang.VALUE}" name="menu_lang[{$lang.LANGUAGE_CODE}]"/></td>
+		</tr>
+		{/foreach}
+		<tr>
+			<td colspan="3"><br><hr><br></td>
+		</tr>
+		<tr>
+			<td colspan="3"><input type="checkbox" name="show_menu" value="on" {if $ap_conf.show_menu}checked="checked"{/if}/> {'ap_show_menu'|@translate}</td>
+		</tr>
+		<tr>
+			<td colspan="3"><input type="checkbox" name="show_home" value="on" {if $ap_conf.show_home}checked="checked"{/if}/> {'ap_show_home'|@translate}</td>
+		</tr>
+		<tr>
+			<td colspan="3"><input type="checkbox" name="redirect" value="on" {if $ap_conf.redirect}checked="checked"{/if}/> {'ap_redirect'|@translate}</td>
+		</tr>
+		<tr>
+			<td colspan="3"><br><hr><br></td>
+		</tr>
+		<tr>
+			<td colspan="3">{'ap_perm'|@translate}</td>
+		</tr>
+		<tr>
+			<td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="user_perm" value="on" {if $ap_conf.user_perm}checked="checked"{/if}/> <i>{'ap_user_perm'|@translate}</i></td>
+		</tr>
+		<tr>
+			<td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="group_perm" value="on" {if $ap_conf.group_perm}checked="checked"{/if}/> <i>{'ap_group_perm'|@translate}</i></td>
+		</tr>
+
+	</table>
+
+<br>
+</fieldset>
+	<p><input class="submit" type="submit" value="{'Submit'|@translate}" name="submit"/></p>
+</form>
+
+{if isset($convert_bbcode)}
+	<p><a href="{$convert_bbcode.PATH}">{'ap_parse_bbcode'|@translate}</a></p>
+{/if}
Index: /extensions/AdditionalPages/admin/template/manage.tpl
===================================================================
--- /extensions/AdditionalPages/admin/template/manage.tpl	(revision 9261)
+++ /extensions/AdditionalPages/admin/template/manage.tpl	(revision 9261)
@@ -0,0 +1,73 @@
+{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"}
+{known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.core.packed.js" }
+{known_script id="jquery.ui.sortable" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.sortable.packed.js" }
+
+{html_head}
+<script type="text/javascript">
+  jQuery().ready(function(){ldelim}
+    jQuery(".menuPos").hide();
+    jQuery(".drag_button").show();
+    jQuery(".menuLi").css("cursor","move");
+    jQuery(".menuUl").sortable({ldelim}
+      axis: "y",
+      opacity: 0.8
+    });
+    jQuery("input[name^='hide_']").click(function() {ldelim}
+      men = this.name.split('hide_');
+      if (this.checked) {ldelim}
+        jQuery("#menu_"+men[1]).addClass('menuLi_hidden');
+      } else {ldelim}
+        jQuery("#menu_"+men[1]).removeClass('menuLi_hidden');
+      }
+    });
+    jQuery("#menuOrdering").submit(function(){ldelim}
+      ar = jQuery('.menuUl').sortable('toArray');
+      for(i=0;i<ar.length;i++) {ldelim}
+        men = ar[i].split('menu_');
+        document.getElementsByName('position[' + men[1] + ']')[0].value = i;
+      }
+    });
+  });
+</script>
+<style type="text/css">#menuOrdering a:hover {ldelim} border:none; }</style>
+{/html_head}
+
+<div class="titrePage">
+	<h2>Additional Pages - {'Manage'|@translate}</h2>
+</div>
+
+<form id="menuOrdering" action="{$F_ACTION}" method="post">
+  <ul class="menuUl">
+    {foreach from=$pages item=page}
+    <li class="menuLi {if $page.pos<0}menuLi_hidden{/if}" id="menu_{$page.id}">
+      <p>
+        <span style="margin:2px 5px;">
+          <a href="{$page.U_DELETE}"><img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/category_delete.png" alt="{'delete'|@translate}" title="{'delete'|@translate}" onClick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');"></a>
+        </span>
+        <span style="margin:2px 5px;">
+          <a href="{$page.U_EDIT}"><img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/category_edit.png" alt="{'edit'|@translate}" title="{'edit'|@translate}"></a>
+        </span>
+
+        <img src="{$themeconf.admin_icon_dir}/cat_move.png" class="button drag_button" style="display:none;" alt="{'Drag to re-order'|@translate}" title="{'Drag to re-order'|@translate}">
+        <strong><a href="{$page.U_PAGE}">{$page.title}</a></strong> {if $page.id == $HOMEPAGE} - {'Home'|@translate}{/if} {if !empty($page.language)}<i>({$page.language})</i>{/if}
+      </p>
+
+      <p class="menuAuthor" style="margin-top:7px;">
+        {'Hide'|@translate} <input type="checkbox" name="hide_{$page.id}" {if $page.pos<0}checked="checked"{/if}>
+      </p>
+
+      <p class="menuPos">
+        <label>
+          {'Position'|@translate} :
+          <input type="text" size="4" name="position[{$page.id}]" maxlength="4" value="{math equation="abs(pos)" pos=$page.pos}">
+        </label>
+      </p>
+    </li>
+    {/foreach}
+  </ul>
+  <p class="menuSubmit">
+    <input type="submit" name="submit" value="{'Submit'|@translate}">
+    <input type="submit" name="reset" value="{'Reset'|@translate}">
+  </p>
+
+</form>
Index: /extensions/AdditionalPages/index_menu.php
===================================================================
--- /extensions/AdditionalPages/index_menu.php	(revision 9260)
+++ /extensions/AdditionalPages/index_menu.php	(revision 9261)
@@ -11,5 +11,5 @@
   if ($menu->get_id() != 'menubar')
     return;
-  $menu->register_block( new RegisteredBlock( 'mbAdditionalPages', 'Additional Pages', 'AP'));
+  $menu->register_block( new RegisteredBlock( 'mbAdditionalPages', 'Additional Pages', 'P@t'));
 }
 
@@ -17,6 +17,4 @@
 {
   global $template, $conf, $user, $lang;
-
-  $ap_conf = explode ("," , $conf['additional_pages']);
 
   $menu = & $menu_ref_arr[0];
@@ -27,28 +25,7 @@
 
     load_language('plugin.lang', AP_PATH);
-    
-    // Gestion des langues pour le nom du menu
-    $languages = explode('/', $ap_conf[0]);
-    foreach($languages as $language)
-    {
-      $array = explode(':', $language);
-      if (!isset($array[1])) $menu_langs['default'] = $array[0];
-      else $menu_langs[$array[0]] = $array[1];
-    }
 
     $data = array();
 
-    if (is_admin())
-    {
-      array_push($data, array(
-        'URL' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . AP_DIR . '%2Fadmin%2Fadd_page.php',
-        'LABEL' => l10n('ap_add_page')));
-      $clauses = '';
-    }
-    else
-    {
-      $clauses = 'WHERE (lang = "' . $user['language'] . '" OR lang = "ALL")';
-    }
-  
     // Recupération des groupes de l'utilisateur
     $q = 'SELECT group_id FROM ' . USER_GROUP_TABLE . ' WHERE user_id = ' . $user['id'] . ';';
@@ -61,8 +38,10 @@
   
     // Récupération des pages
-    $q = 'SELECT id , pos , title
+    $q = 'SELECT id, pos, title, users, groups, permalink
 FROM ' . ADD_PAGES_TABLE . '
-' . $clauses . '
-ORDER BY pos ASC;';
+WHERE (lang = "' . $user['language'] . '" OR lang IS NULL)
+  AND pos > 0
+ORDER BY pos ASC, id ASC
+;';
     $result = pwg_query($q);
 
@@ -71,27 +50,21 @@
       if ($row['pos'] != '0' or is_admin())
       {
-        if (strpos($row['title'] , '/user_id='))
+        $authorized_users = array();
+        $authorized_groups = array();
+        if (!empty($row['users']))
         {
-          $array = explode('/user_id=' , $row['title']);
-          $row['title'] = $array[0];
-          $authorized_users = explode(',', $array[1]);
+          $authorized_users = explode(',', $row['users']);
         }
-        if (strpos($row['title'] , '/group_id='))
+        if (!empty($row['groups']))
         {
-          $array = explode('/group_id=' , $row['title']);
-          $row['title'] = $array[0];
-          $auth = explode(',', $array[1]);
+          $auth = explode(',', $row['groups']);
           $authorized_groups = array_intersect($groups, $auth);
         }
-        if (is_admin() and isset($ap_conf[3]) and $ap_conf[3] == 'on')
-        {
-          $row['title'] .= '</a> --- <a href=' . PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . AP_DIR . '%2Fadmin%2Fadd_page.php&amp;edit=' . $row['id'] . '>[edit]';
-        }
         if (is_admin() or (
-          (isset($ap_conf[6]) and $ap_conf[6] == 'off' or !isset($authorized_groups) or !empty($authorized_groups)) and
-          (isset($ap_conf[7]) and $ap_conf[7] == 'off' or !isset($authorized_users) or in_array($user['status'], $authorized_users))))
+          (!$conf['additional_pages']['group_perm'] or empty($row['groups']) or !empty($authorized_groups)) and
+          (!$conf['additional_pages']['user_perm'] or empty($row['users']) or in_array($user['status'], $authorized_users))))
         {
           array_push($data, array(
-            'URL' => PHPWG_ROOT_PATH . 'index.php?/additional_page/' . $row['id'],
+            'URL' => make_index_url().'/page/'.(isset($row['permalink']) ? $row['permalink'] : $row['id']),
             'LABEL' => $row['title']));
         }
@@ -103,5 +76,9 @@
     if (!empty($data))
     {
-      $block->set_title(isset($menu_langs[$user['language']]) ? $menu_langs[$user['language']] : $menu_langs['default']);
+      $block->set_title(
+        isset($conf['additional_pages']['languages'][$user['language']]) ?
+          $conf['additional_pages']['languages'][$user['language']] :
+          @$conf['additional_pages']['languages']['default']
+        );
       $block->template = 'AdditionalPages_menu.tpl';
       $block->data = $data;
Index: /extensions/AdditionalPages/language/cs_CZ/plugin.lang.php
===================================================================
--- /extensions/AdditionalPages/language/cs_CZ/plugin.lang.php	(revision 9260)
+++ /extensions/AdditionalPages/language/cs_CZ/plugin.lang.php	(revision 9261)
@@ -4,7 +4,7 @@
 
 $lang['ap_create'] = 'Přidat novou stránku';
-$lang['ap_deleted_page'] = 'Stránka byla smazána. (<a href="' .PHPWG_ROOT_PATH . '">zpět domů</a>)';
+$lang['ap_deleted_page'] = 'Stránka byla smazána.';
 $lang['ap_no_name'] = 'Je nutné vyplnit jméno.';
-$lang['ap_saved_page'] = 'Stránka byla uložena (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">zobrazit stránku</a>)';
+$lang['ap_saved_page'] = 'Stránka byla uložena';
 $lang['ap_modify'] = 'Upravit stránku';
 $lang['ap_all_lang'] = 'Všechny';
@@ -39,3 +39,6 @@
 $lang['ap_convert_bbcode_ok'] = 'Převod proběhl v pořádku.';
 
+/*TODO*/$lang['ap_edit_page'] = 'Edit a page';
+/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage';
+
 ?>
Index: /extensions/AdditionalPages/language/de_DE/plugin.lang.php
===================================================================
--- /extensions/AdditionalPages/language/de_DE/plugin.lang.php	(revision 9260)
+++ /extensions/AdditionalPages/language/de_DE/plugin.lang.php	(revision 9261)
@@ -4,7 +4,7 @@
 
 $lang['ap_create'] = 'Neue Seite hinzufügen';
-$lang['ap_deleted_page'] = 'Seite gelöscht (<a href="' .PHPWG_ROOT_PATH . '">zurück zur Startseite</a>)';
+$lang['ap_deleted_page'] = 'Seite gelöscht';
 $lang['ap_no_name'] = 'Es wurde kein Name vergeben.';
-$lang['ap_saved_page'] = 'Seite gespeichert (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">Seite anzeigen</a>)';
+$lang['ap_saved_page'] = 'Seite gespeichert';
 $lang['ap_modify'] = 'Neue Seite bearbeiten';
 $lang['ap_all_lang'] = 'Alle';
@@ -39,3 +39,6 @@
 $lang['ap_convert_bbcode_ok'] = 'Konvertierung abgeschlossen.';
 
+/*TODO*/$lang['ap_edit_page'] = 'Edit a page';
+/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage';
+
 ?>
Index: /extensions/AdditionalPages/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/AdditionalPages/language/en_UK/plugin.lang.php	(revision 9260)
+++ /extensions/AdditionalPages/language/en_UK/plugin.lang.php	(revision 9261)
@@ -4,7 +4,7 @@
 
 $lang['ap_create'] = 'Create new additional page';
-$lang['ap_deleted_page'] = 'Page deleted (<a href="' .PHPWG_ROOT_PATH . '">back to home</a>)';
+$lang['ap_deleted_page'] = 'Page deleted';
 $lang['ap_no_name'] = 'You do not fill name field.';
-$lang['ap_saved_page'] = 'Page saved (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">see the page</a>)';
+$lang['ap_saved_page'] = 'Page saved';
 $lang['ap_modify'] = 'Modify the additional page';
 $lang['ap_all_lang'] = 'All';
@@ -39,3 +39,6 @@
 $lang['ap_convert_bbcode_ok'] = 'Conversion effectuée.';
 
+$lang['ap_edit_page'] = 'Edit a page';
+$lang['ap_set_as_homepage'] = 'Set as Homepage';
+
 ?>
Index: /extensions/AdditionalPages/language/es_ES/plugin.lang.php
===================================================================
--- /extensions/AdditionalPages/language/es_ES/plugin.lang.php	(revision 9260)
+++ /extensions/AdditionalPages/language/es_ES/plugin.lang.php	(revision 9261)
@@ -4,7 +4,7 @@
 
 $lang['ap_create'] = 'Crear una nueva página adiciónal';
-$lang['ap_deleted_page'] = 'Página eliminada (<a href="' .PHPWG_ROOT_PATH . '">volver al inicio</a>)';
+$lang['ap_deleted_page'] = 'Página eliminada';
 $lang['ap_no_name'] = 'Usted no indicó el nombre.';
-$lang['ap_saved_page'] = 'Página registrada (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">Ver la página</a>)';
+$lang['ap_saved_page'] = 'Página registrada';
 $lang['ap_modify'] = 'Modificar la página adiciónal';
 $lang['ap_all_lang'] = 'Todas';
@@ -39,3 +39,6 @@
 $lang['ap_convert_bbcode_ok'] = 'Conversión efectuada.';
 
+/*TODO*/$lang['ap_edit_page'] = 'Edit a page';
+/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage';
+
 ?>
Index: /extensions/AdditionalPages/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/AdditionalPages/language/fr_FR/plugin.lang.php	(revision 9260)
+++ /extensions/AdditionalPages/language/fr_FR/plugin.lang.php	(revision 9261)
@@ -4,7 +4,7 @@
 
 $lang['ap_create'] = 'Créer une nouvelle page additionelle';
-$lang['ap_deleted_page'] = 'Page supprimée (<a href="' .PHPWG_ROOT_PATH . '">retour à l\'accueil</a>)';
+$lang['ap_deleted_page'] = 'Page supprimée';
 $lang['ap_no_name'] = 'Vous n\'avez pas indiqué le nom.';
-$lang['ap_saved_page'] = 'Page enregistrée (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">voir la page</a>)';
+$lang['ap_saved_page'] = 'Page enregistrée';
 $lang['ap_modify'] = 'Modifier la page additionelle';
 $lang['ap_all_lang'] = 'Toutes';
@@ -38,3 +38,7 @@
 $lang['ap_parse_bbcode'] = 'Convertir les pages déjà écrites avec le BBCode';
 $lang['ap_convert_bbcode_ok'] = 'Conversion effectuée.';
+
+$lang['ap_edit_page'] = 'Editer une page';
+$lang['ap_set_as_homepage'] = 'Définir comme page d\'accueil';
+
 ?>
Index: /extensions/AdditionalPages/language/hu_HU/plugin.lang.php
===================================================================
--- /extensions/AdditionalPages/language/hu_HU/plugin.lang.php	(revision 9260)
+++ /extensions/AdditionalPages/language/hu_HU/plugin.lang.php	(revision 9261)
@@ -4,7 +4,7 @@
 
 $lang['ap_create'] = 'További új oldal létrehozása';
-$lang['ap_deleted_page'] = 'Oldal törlése (<a href="' .PHPWG_ROOT_PATH . '">vissza a főoldalra</a>)';
+$lang['ap_deleted_page'] = 'Oldal törlése';
 $lang['ap_no_name'] = 'Nem létező mező.';
-$lang['ap_saved_page'] = 'Oldal mentve (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">oldal megtekintése</a>)';
+$lang['ap_saved_page'] = 'Oldal mentve';
 $lang['ap_modify'] = 'Új oldal módosítása';
 $lang['ap_all_lang'] = 'Összes nyelv';
@@ -39,3 +39,6 @@
 $lang['ap_convert_bbcode_ok'] = 'Konvertálás kész.';
 
+/*TODO*/$lang['ap_edit_page'] = 'Edit a page';
+/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage';
+
 ?>
Index: /extensions/AdditionalPages/language/it_IT/plugin.lang.php
===================================================================
--- /extensions/AdditionalPages/language/it_IT/plugin.lang.php	(revision 9260)
+++ /extensions/AdditionalPages/language/it_IT/plugin.lang.php	(revision 9261)
@@ -4,7 +4,7 @@
 
 $lang['ap_create'] = 'Creare una nuova pagina addizionale';
-$lang['ap_deleted_page'] = 'Pagina soppressa (<a href="' .PHPWG_ROOT_PATH . '">ritorno alla home page</a>)';
+$lang['ap_deleted_page'] = 'Pagina soppressa';
 $lang['ap_no_name'] = 'Dovete indicare un nome.';
-$lang['ap_saved_page'] = 'Pagina registrata (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">visualizzare pagina</a>)';
+$lang['ap_saved_page'] = 'Pagina registrata';
 $lang['ap_modify'] = 'Modificare la pagina addizionale';
 $lang['ap_all_lang'] = 'Tutte';
@@ -38,3 +38,7 @@
 $lang['ap_parse_bbcode'] = 'Convertire le pagini già scritte con BBCode';
 $lang['ap_convert_bbcode_ok'] = 'Conversione effettuata.';
+
+/*TODO*/$lang['ap_edit_page'] = 'Edit a page';
+/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage';
+
 ?>
Index: /extensions/AdditionalPages/language/lv_LV/plugin.lang.php
===================================================================
--- /extensions/AdditionalPages/language/lv_LV/plugin.lang.php	(revision 9260)
+++ /extensions/AdditionalPages/language/lv_LV/plugin.lang.php	(revision 9261)
@@ -4,7 +4,7 @@
 
 $lang['ap_create'] = 'Izveidot jaunu papildus lapu';
-$lang['ap_deleted_page'] = 'Lapa dzēsta (<a href="' .PHPWG_ROOT_PATH . '">atpakaļ uz sākumu</a>)';
+$lang['ap_deleted_page'] = 'Lapa dzēsta';
 $lang['ap_no_name'] = 'Jūs neesat aizpildījis nosaukuma lauku.';
-$lang['ap_saved_page'] = 'Lapa saglabāta (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">skatīt lapu</a>)';
+$lang['ap_saved_page'] = 'Lapa saglabāta';
 $lang['ap_modify'] = 'Veikt izmaiņas papildus lapā';
 $lang['ap_all_lang'] = 'Visas';
@@ -38,3 +38,7 @@
 $lang['ap_parse_bbcode'] = 'Konvertēt BBCode kodā rakstītās lapas';
 $lang['ap_convert_bbcode_ok'] = 'Konvertācija veiksmīga.';
+
+/*TODO*/$lang['ap_edit_page'] = 'Edit a page';
+/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage';
+
 ?>
Index: /extensions/AdditionalPages/language/pl_PL/plugin.lang.php
===================================================================
--- /extensions/AdditionalPages/language/pl_PL/plugin.lang.php	(revision 9260)
+++ /extensions/AdditionalPages/language/pl_PL/plugin.lang.php	(revision 9261)
@@ -4,7 +4,7 @@
 
 $lang['ap_create'] = 'Stwórz nową dodatkową stronę';
-$lang['ap_deleted_page'] = 'Strona usunięta (<a href="' .PHPWG_ROOT_PATH . '">powrót do głównej</a>)';
+$lang['ap_deleted_page'] = 'Strona usunięta';
 $lang['ap_no_name'] = 'Nie wypełniłeś pola nazwy.';
-$lang['ap_saved_page'] = 'Strona zapisana (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">zobacz stronę</a>)';
+$lang['ap_saved_page'] = 'Strona zapisana';
 $lang['ap_modify'] = 'Modyfikuj dodatkową stronę';
 $lang['ap_all_lang'] = 'Wszystkie';
@@ -39,3 +39,6 @@
 $lang['ap_convert_bbcode_ok'] = 'Konwersja aktywna.';
 
+/*TODO*/$lang['ap_edit_page'] = 'Edit a page';
+/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage';
+
 ?>
Index: /extensions/AdditionalPages/language/ru_RU/plugin.lang.php
===================================================================
--- /extensions/AdditionalPages/language/ru_RU/plugin.lang.php	(revision 9260)
+++ /extensions/AdditionalPages/language/ru_RU/plugin.lang.php	(revision 9261)
@@ -4,7 +4,7 @@
 
 $lang['ap_create'] = 'Создать новую дополнительную сраницу';
-$lang['ap_deleted_page'] = 'Страница удалена (<a href="' .PHPWG_ROOT_PATH . '">на главную</a>)';
+$lang['ap_deleted_page'] = 'Страница удалена';
 $lang['ap_no_name'] = 'Введите название страницы';
-$lang['ap_saved_page'] = 'Cтраница сохранена (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">просмотреть страницу</a>)';
+$lang['ap_saved_page'] = 'Cтраница сохранена';
 $lang['ap_modify'] = 'Изменить дополнительную страницу';
 $lang['ap_all_lang'] = 'Все';
@@ -39,3 +39,6 @@
 $lang['ap_convert_bbcode_ok'] = 'Конвертирование выполнено';
 
+/*TODO*/$lang['ap_edit_page'] = 'Edit a page';
+/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage';
+
 ?>
Index: /extensions/AdditionalPages/language/sk_SK/plugin.lang.php
===================================================================
--- /extensions/AdditionalPages/language/sk_SK/plugin.lang.php	(revision 9260)
+++ /extensions/AdditionalPages/language/sk_SK/plugin.lang.php	(revision 9261)
@@ -4,7 +4,7 @@
 
 $lang['ap_create'] = 'Vytvoriť novú prídavnú stránku';
-$lang['ap_deleted_page'] = 'Stránka vymazaná (<a href="' .PHPWG_ROOT_PATH . '">späť na úvodnú stránku</a>)';
+$lang['ap_deleted_page'] = 'Stránka vymazaná';
 $lang['ap_no_name'] = 'Nevyplnili ste názov.';
-$lang['ap_saved_page'] = 'Stránka uložená (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">pozrieť stránku</a>)';
+$lang['ap_saved_page'] = 'Stránka uložená';
 $lang['ap_modify'] = 'Upraviť prídavnú stránku';
 $lang['ap_all_lang'] = 'Všetky';
@@ -38,3 +38,7 @@
 $lang['ap_parse_bbcode'] = 'Konvertovať stránky napísané v BBCode';
 $lang['ap_convert_bbcode_ok'] = 'Konverzia úspešná.';
+
+/*TODO*/$lang['ap_edit_page'] = 'Edit a page';
+/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage';
+
 ?>
Index: /extensions/AdditionalPages/main.inc.php
===================================================================
--- /extensions/AdditionalPages/main.inc.php	(revision 9260)
+++ /extensions/AdditionalPages/main.inc.php	(revision 9261)
@@ -4,5 +4,5 @@
 Version: auto
 Description: Add additional pages in menubar.
-Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=153
+Plugin URI: http://piwigo.org/ext/extension_view.php?eid=153
 Author: P@t
 Author URI: http://www.gauchon.com
@@ -17,4 +17,6 @@
 define('ADD_PAGES_TABLE' , $prefixeTable . 'additionalpages');
 
+$conf['additional_pages'] = unserialize($conf['additional_pages']);
+
 function additional_pages_admin_menu($menu)
 {
@@ -27,25 +29,19 @@
 function section_init_additional_page()
 {
-    global $tokens, $page;
-    if ($tokens[0] == 'additional_page')
-      $page['section'] = 'additional_page';
+  global $tokens, $conf, $page;
+
+  $page['is_homepage'] = (count($tokens) == 1 and empty($tokens[0]));
+
+  if (($tokens[0] == 'page' and !empty($tokens[1])) or ($page['is_homepage'] and !is_null($conf['additional_pages']['homepage'])))
+    include(AP_PATH . 'additional_page.php');
+
+  if ($tokens[0] == 'additional_page' and !empty($tokens[1]))
+    redirect(make_index_url().'/page/'.$tokens[1]);
 }
 
-function index_additional_page()
-{
-    global $page;
-    if (isset($page['section']) and $page['section'] == 'additional_page')
-      include(AP_PATH . 'additional_page.php');
-}
-
-$ap_conf = explode ("," , $conf['additional_pages']);
-if (isset($ap_conf[1]) and $ap_conf[1] == 'on' or is_admin())
-{
-  include(AP_PATH . 'index_menu.php');
-}
+include(AP_PATH . 'index_menu.php');
 
 add_event_handler('get_admin_plugin_menu_links', 'additional_pages_admin_menu');
 add_event_handler('loc_end_section_init', 'section_init_additional_page');
-add_event_handler('loc_end_index', 'index_additional_page');
 
 ?>
Index: /extensions/AdditionalPages/maintain.inc.php
===================================================================
--- /extensions/AdditionalPages/maintain.inc.php	(revision 9260)
+++ /extensions/AdditionalPages/maintain.inc.php	(revision 9261)
@@ -11,8 +11,9 @@
     $query = 'CREATE TABLE ' . $prefixeTable . 'additionalpages (
 id SMALLINT( 5 ) UNSIGNED NOT NULL ,
-pos SMALLINT( 5 ) UNSIGNED default NULL ,
-lang VARCHAR( 255 ) NOT NULL ,
+pos SMALLINT( 5 ) NULL default NULL ,
+lang VARCHAR( 255 ) NULL default NULL ,
 title VARCHAR( 255 ) NOT NULL ,
-text LONGTEXT NOT NULL ,
+content LONGTEXT NOT NULL ,
+permalink VARCHAR( 64 ) NULL DEFAULT NULL ,
 PRIMARY KEY (id) ,
 INDEX (pos) ,
@@ -24,6 +25,15 @@
   if (!isset($conf['additional_pages']))
   {
+    $config = array(
+      'languages' => array('default' => 'Additional Pages'),
+      'show_menu' => true,
+      'show_home' => true,
+      'redirect' => false,
+      'group_perm' => false,
+      'user_perm' => false,
+      'homepage' => null,
+    );
     $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
-VALUES ("additional_pages" , "Additional Pages,on,on,off,off,,off,off" , "Parametres du plugin Additional Pages");';
+VALUES ("additional_pages" , "'.addslashes(serialize($config)).'" , "Additional Pages config configuration");';
     pwg_query($query);
   }
@@ -51,4 +61,9 @@
   {
     upgrade_ap_from_17();
+  }
+  $result = array_from_query($query, 'Field');
+  if (!in_array('permalink', $result))
+  {
+    upgrade_ap_from_21();
   }
 }
@@ -78,3 +93,90 @@
 }
 
+function upgrade_ap_from_21()
+{
+  global $prefixeTable, $conf;
+
+  $query = 'ALTER TABLE ' . $prefixeTable . 'additionalpages
+CHANGE `id` `id` SMALLINT( 5 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
+CHANGE `pos` `pos` SMALLINT( 5 ) NULL DEFAULT NULL ,
+CHANGE `lang` `lang` VARCHAR( 255 ) NULL DEFAULT NULL ,
+CHANGE `text` `content` LONGTEXT NOT NULL ,
+ADD `users` VARCHAR( 255 ) NULL DEFAULT NULL ,
+ADD `groups` VARCHAR( 255 ) NULL DEFAULT NULL ,
+ADD `permalink` VARCHAR( 64 ) NULL DEFAULT NULL;';
+  pwg_query($query);
+
+  $query = '
+SELECT id, pos, title, lang
+FROM '.$prefixeTable.'additionalpages
+ORDER BY pos ASC, id ASC
+;';
+  $result = pwg_query($query);
+  while ($row = mysql_fetch_assoc($result))
+  {
+    $title = $row['title'];
+    $authorized_users = 'NULL';
+    $authorized_groups = 'NULL';
+
+    if (strpos($title , '/user_id='))
+    {
+      $array = explode('/user_id=' , $title);
+      $title = $array[0];
+      $authorized_users = '"'.$array[1].'"';
+    }
+    if (strpos($title , '/group_id='))
+    {
+      $array = explode('/group_id=' , $title);
+      $title = $array[0];
+      $authorized_groups = '"'.$array[1].'"';
+    }
+
+    $position = $row['pos'];
+    if ($row['pos'] === '0')
+      $position = '-1';
+    elseif (empty($row['pos']))
+      $position = '0';
+
+    $language = $row['lang'] != 'ALL' ? '"'.$row['lang'].'"' : 'NULL';
+
+    $query = '
+UPDATE '.$prefixeTable.'additionalpages
+  SET title = "'.addslashes($title).'",
+      pos = '.$position.',
+      lang = '.$language.',
+      users = '.$authorized_users.',
+      groups = '.$authorized_groups.'
+  WHERE id = '.$row['id'].'
+;';
+    pwg_query($query);
+  }
+
+  $old_conf = explode ("," , $conf['additional_pages']);
+
+  $new_conf = array(
+    'show_menu' => @($old_conf[1] == 'on'),
+    'show_home' => @($old_conf[2] == 'on'),
+    'redirect' => @($old_conf[4] == 'on'),
+    'group_perm' => @($old_conf[6] == 'on'),
+    'user_perm' => @($old_conf[7] == 'on'),
+    'homepage' => null,
+    );
+
+  $languages = explode('/', $old_conf[0]);
+  $new_conf['languages'] = array();
+  foreach($languages as $language)
+  {
+    $array = explode(':', $language);
+    if (!isset($array[1])) $new_conf['languages']['default'] = $array[0];
+    else $new_conf['languages'][$array[0]] = $array[1];
+  }
+
+  $query = '
+UPDATE '.CONFIG_TABLE.'
+  SET value = "'.addslashes(serialize($new_conf)).'"
+  WHERE param = "additional_pages"
+;';
+  pwg_query($query);
+}
+
 ?>
