Index: /extensions/AdditionalPages/trunk/admin/add_page.inc.php
===================================================================
--- /extensions/AdditionalPages/trunk/admin/add_page.inc.php	(revision 16117)
+++ /extensions/AdditionalPages/trunk/admin/add_page.inc.php	(revision 16118)
@@ -19,4 +19,19 @@
     'content'    => '',
   );
+}
+
+// load template
+if (isset($_GET['load_template']))
+{
+  if (file_exists(AP_DISTRIBUED . $_GET['load_template']))
+  {
+    $distribued = load_ap_template($_GET['load_template'], true);
+  }
+  else
+  {
+    $distribued = trigger_event('load_ap_template', array(), $_GET['load_template']);
+  }
+  $edited_page = array_merge($edited_page, $distribued);
+  $template->assign('template_selected', $_GET['load_template']);
 }
 
@@ -198,4 +213,24 @@
 }
 
+// Available templates
+if (!isset($_GET['edit']))
+{
+  $distribued = array();
+  $dh = opendir(AP_DISTRIBUED);
+  if ($dh)
+  {
+    while (($dir = readdir($dh)) !== false)
+    {
+      if ( is_dir(AP_DISTRIBUED.$dir) and $dir!='.' and $dir!='..' )
+      {
+        array_push($distribued, load_ap_template($dir, false));
+      }
+    }
+    closedir($dh);
+  }
+  $distribued = trigger_event('load_ap_templates_list', $distribued); // external plugins can add templates
+  $template->assign('TEMPLATES', $distribued);
+}
+
 // template output
 $template->assign(array(
@@ -212,3 +247,38 @@
 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
 
+
+function load_ap_template($dir, $with_content=true)
+{
+  $path = AP_DISTRIBUED . $dir . '/';
+  
+  // default template
+  $template_conf = array(
+    'name'       => $dir,
+    'title'      => '',
+    'permalink'  => '',
+    'lang'       => 'ALL',
+    'homepage'   => false,
+    'standalone' => false,
+    'level'      => 0,
+    'users'      => array('guest', 'generic', 'normal', 'admin', 'webmaster'),
+    'groups'     => array(),
+    'content'    => '',
+  );
+  
+  // load config
+  if (file_exists($path.'config.php'))
+  {
+    include($path.'config.php');
+  }
+  
+  // load content
+  if ( $with_content and file_exists($path.'content.tpl') )
+  {
+    $template_conf['content'] = file_get_contents($path.'content.tpl');
+  }
+  
+  $template_conf['tpl_id'] = $dir;
+  return $template_conf;
+}
+
 ?>
Index: /extensions/AdditionalPages/trunk/admin/template/add_page.tpl
===================================================================
--- /extensions/AdditionalPages/trunk/admin/template/add_page.tpl	(revision 16117)
+++ /extensions/AdditionalPages/trunk/admin/template/add_page.tpl	(revision 16118)
@@ -7,4 +7,21 @@
         auto_permalink = false;
       });
+  });
+  
+  var content_changed = false;
+  jQuery("#ap_content").change(function() {
+    content_changed = true;
+  });
+  
+  jQuery("#template").change(function() {
+    if ($(this).val() != '-1') {
+{/literal}
+      if (content_changed == false || confirm("{'The content of the page changed, are your sure you wan\'t to quit without saving?'|@translate|escape:javascript}")) {ldelim}
+        window.location.href = "admin.php?page=plugin-AdditionalPages-add_page&load_template="+ $(this).val();
+      } else {ldelim}
+        $(this).val('-1');
+      }
+{literal}
+    }
   });
 });
@@ -28,4 +45,18 @@
   <legend></legend>
 	<ul>
+    {if $TEMPLATES}
+    <li>
+      <span class="property">
+        <label for="template">{'Load a page model'|@translate}</label>
+      </span>
+      <select name="template" id="template">
+        <option value="-1">---------</option>
+        {foreach from=$TEMPLATES item=tpl}
+        <option value="{$tpl.tpl_id}" {if $template_selected==$tpl.tpl_id}selected="selected"{/if}>{$tpl.name}</option>
+        {/foreach}
+      </select>
+    </li>
+    {/if}
+    
     <li>
       <span class="property">
Index: /extensions/AdditionalPages/trunk/distribued/index.php
===================================================================
--- /extensions/AdditionalPages/trunk/distribued/index.php	(revision 16118)
+++ /extensions/AdditionalPages/trunk/distribued/index.php	(revision 16118)
@@ -0,0 +1,33 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | 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.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/AdditionalPages/trunk/distribued/standalone_home/config.php
===================================================================
--- /extensions/AdditionalPages/trunk/distribued/standalone_home/config.php	(revision 16118)
+++ /extensions/AdditionalPages/trunk/distribued/standalone_home/config.php	(revision 16118)
@@ -0,0 +1,7 @@
+<?php
+
+$template_conf['name'] = 'Standalone homepage';
+$template_conf['title'] = 'My homepage';
+$template_conf['homepage'] = true;
+
+?>
Index: /extensions/AdditionalPages/trunk/distribued/standalone_home/content.tpl
===================================================================
--- /extensions/AdditionalPages/trunk/distribued/standalone_home/content.tpl	(revision 16118)
+++ /extensions/AdditionalPages/trunk/distribued/standalone_home/content.tpl	(revision 16118)
@@ -0,0 +1,25 @@
+<style type="text/css">
+#menubar {display:none !important;}
+.titrePage {display:none}
+.content {max-width:1120px; margin:0 auto 10px auto !important;}
+.Online {display:none;}
+ 
+.myHomePage_photo {text-align: center; margin:50px 0 20px 0}
+.myHomePage_photo a img {border-width:2px; border-style:solid;}
+.myHomePage_links {letter-spacing:2px; text-align:center; margin-bottom:0; font-weight:bold;}
+.myHomePage_name {margin-top:30px; letter-spacing:2px; text-align:center;}
+</style>
+ 
+<div id="myHomePage">
+  <div class="myHomePage_photo">
+    <a href="index.php?/categories"><img src="[photo 1234 L]"></a>
+  </div>
+ 
+  <div class="myHomePage_links">
+    <a href="index.php?/categories">Albums</a> &#9679; <a href="index.php?/contact">Contact</a>
+  </div>
+ 
+  <div class="myHomePage_name">
+    by Piwigo.com Team &middot; This is a demo gallery
+  </div>
+</div>
Index: /extensions/AdditionalPages/trunk/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/AdditionalPages/trunk/language/en_UK/plugin.lang.php	(revision 16117)
+++ /extensions/AdditionalPages/trunk/language/en_UK/plugin.lang.php	(revision 16118)
@@ -48,3 +48,6 @@
 $lang['ap_language_perm'] = 'by language';
 
+$lang['Load a page model'] = 'Load a page model';
+$lang['The content of the page changed, are your sure you wan\'t to quit without saving?'] = 'The content of the page changed, are your sure you wan\'t to quit without saving?';
+
 ?>
Index: /extensions/AdditionalPages/trunk/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/AdditionalPages/trunk/language/fr_FR/plugin.lang.php	(revision 16117)
+++ /extensions/AdditionalPages/trunk/language/fr_FR/plugin.lang.php	(revision 16118)
@@ -48,3 +48,6 @@
 $lang['ap_language_perm'] = 'par langue';
 
+$lang['Load a page model'] = 'Charger un modèle de page';
+$lang['The content of the page changed, are your sure you wan\'t to quit without saving?'] = 'Le contenu de la page a changé, êtes-vous sûr de vouloir quitter sans sauvegarder ?';
+
 ?>
Index: /extensions/AdditionalPages/trunk/main.inc.php
===================================================================
--- /extensions/AdditionalPages/trunk/main.inc.php	(revision 16117)
+++ /extensions/AdditionalPages/trunk/main.inc.php	(revision 16118)
@@ -16,4 +16,5 @@
 define('AP_PATH' , PHPWG_PLUGINS_PATH . AP_DIR . '/');
 define('ADD_PAGES_TABLE' , $prefixeTable . 'additionalpages');
+define('AP_DISTRIBUED', AP_PATH . 'distribued/');
 
 $conf['AP'] = @unserialize($conf['additional_pages']);
