Index: /extensions/showcase_subscribe/admin.php
===================================================================
--- /extensions/showcase_subscribe/admin.php	(revision 11668)
+++ /extensions/showcase_subscribe/admin.php	(revision 11668)
@@ -0,0 +1,182 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture 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.                                                                  |
+// +-----------------------------------------------------------------------+
+
+if( !defined("PHPWG_ROOT_PATH") )
+{
+  die ("Hacking attempt!");
+}
+
+include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+
+load_language('plugin.lang', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
+
+define('SHOWCASE_SUBSCRIBE_BASE_URL', get_root_url().'admin.php?page=plugin-showcase_subscribe');
+
+if (!isset($conf['showcase_subscribe_url']))
+{
+  $conf['showcase_subscribe_url'] = 'http://piwigo.org/showcase';
+}
+
+// +-----------------------------------------------------------------------+
+// | Check Access and exit when user status is not ok                      |
+// +-----------------------------------------------------------------------+
+
+check_status(ACCESS_ADMINISTRATOR);
+
+// +-----------------------------------------------------------------------+
+// | process subscription                                                  |
+// +-----------------------------------------------------------------------+
+
+// searching for the date_creation
+$query = '
+SELECT registration_date
+  FROM '.USER_INFOS_TABLE.'
+  WHERE user_id = 1
+;';
+list($date_creation) = pwg_db_fetch_row(pwg_query($query));
+list($year) = explode('-', $date_creation);
+if ($year == 0)
+{
+  $query = '
+SELECT MIN(date_available)
+  FROM '.IMAGES_TABLE.'
+;';
+  list($date_creation) = pwg_db_fetch_row(pwg_query($query));
+}
+
+if (isset($_POST['submit_subscribe']))
+{
+  $url = $conf['showcase_subscribe_url'].'/ws.php';
+  
+  $get_data = array(
+    'format' => 'php',
+    );
+  
+  $post_data = array(
+    'method' => 'pwg.showcase.subscribe',
+    'url' => get_absolute_root_url(),
+    'date_creation' => $date_creation,
+    'name' => $_POST['title'],
+    'comment' => $_POST['description'],
+    'tags' => $_POST['tags'],
+    'author' => $_POST['author'],
+    'email' => $_POST['email'],
+    );
+
+  if (fetchRemote($url, $result, $get_data, $post_data))
+  {
+    $result = @unserialize($result);
+    // echo '<pre>'; print_r($result); echo '</pre>';
+  }
+  else
+  {
+    echo 'fetchRemote has failed<br>';
+  }
+}
+
+// +-----------------------------------------------------------------------+
+// | template init                                                         |
+// +-----------------------------------------------------------------------+
+
+$template->set_filenames(
+  array(
+    'plugin_admin_content' => dirname(__FILE__).'/admin.tpl'
+    )
+  );
+
+// +-----------------------------------------------------------------------+
+// | subscription state                                                    |
+// +-----------------------------------------------------------------------+
+
+$url = $conf['showcase_subscribe_url'].'/ws.php';
+
+$get_data = array(
+  'format' => 'php',
+  );
+  
+$post_data = array(
+  'method' => 'pwg.showcase.exists',
+  'url' => get_absolute_root_url(),
+  );
+
+if (fetchRemote($url, $result, $get_data, $post_data))
+{
+  $exists_result = @unserialize($result);
+  $subscription_status = $exists_result['result']['status'];
+}
+
+if (!isset($subscription_status))
+{
+  $subscription_status = 'connectionFailure';
+
+  array_push(
+    $page['errors'],
+    sprintf(
+      l10n('An error has occured, no connection to %s'),
+      $conf['showcase_subscribe_url']
+      )
+    );
+}
+
+if ('pending' == $subscription_status)
+{
+  array_push(
+    $page['warnings'],
+    l10n('Your subscription is currently pending, if you have provided an email, you will be notified as soon as your gallery is registered')
+    );
+}
+
+if ('registered' == $subscription_status)
+{
+  array_push(
+    $page['warnings'],
+    sprintf(
+      l10n('Your gallery is already registered in Piwigo Showcase, <a href="%s">see it →</a>'),
+      $exists_result['result']['picture_url']
+      )
+    );
+}
+
+
+// +-----------------------------------------------------------------------+
+// | prepare data for template                                             |
+// +-----------------------------------------------------------------------+
+
+$template->assign(
+  array(
+    'CURRENT_STATUS' => $subscription_status,
+    'URL' => get_absolute_root_url(),
+    'DATE_CREATION' => format_date($date_creation),
+    'EMAIL' => get_webmaster_mail_address(),
+    'TITLE' => strip_tags($conf['gallery_title']),
+    'TAGS' => '',
+    'DESCRIPTION' => '',
+    )
+  );
+
+// +-----------------------------------------------------------------------+
+// | sending html code                                                     |
+// +-----------------------------------------------------------------------+
+
+$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
+?>
Index: /extensions/showcase_subscribe/admin.tpl
===================================================================
--- /extensions/showcase_subscribe/admin.tpl	(revision 11668)
+++ /extensions/showcase_subscribe/admin.tpl	(revision 11668)
@@ -0,0 +1,73 @@
+{literal}
+<style>
+form fieldset p {text-align:left;margin:0 0 1.5em 0;line-height:20px;}
+form fieldset input[type="text"] {width:400px}
+form fieldset textarea {width:600px;height:100px}
+.fieldCaption {font-style:italic;font-size:90% }
+.permissionActions {text-align:center;height:20px}
+.permissionActions a:hover {border:none}
+.permissionActions img {margin-bottom:-2px}
+</style>
+{/literal}
+
+
+<div class="titrePage">
+  <h2>Showcase Subscribe</h2>
+</div>
+
+{if $CURRENT_STATUS eq 'unknown'}
+<form method="post" name="subscribeToShowcase" action="{$F_ACTION}" class="properties">
+  <fieldset>
+    <legend>{'Subscribe my gallery to Piwigo Showcase'|@translate}</legend>
+
+    <p style="margin-top:10px">
+      <strong>{'Gallery Address (URL)'|@translate}</strong>
+      <br>
+      {$URL}
+    </p>
+
+    <p>
+      <strong>{'Creation date'|@translate}</strong>
+      <br>
+      {$DATE_CREATION}
+    </p>
+
+    <p>
+      <strong>{'Email address'|@translate}</strong> <span class="fieldCaption">{'(optional)'|@translate}</span>
+      <br>
+      <input type="text" name="email" value="{$EMAIL}">
+      <br><span class="fieldCaption">{'provide it if you want to be notified when your gallery is registered'|@translate}</span>
+    </p>
+
+    <p>
+      <strong>{'Gallery title'|@translate}</strong> <span class="fieldCaption">{'(optional)'|@translate}</span>
+      <br>
+      <input type="text" name="title" value="{$TITLE}">
+    </p>
+
+    <p>
+      <strong>{'Author'|@translate}</strong> <span class="fieldCaption">{'(optional)'|@translate}</span>
+      <br>
+      <input type="text" name="author" value="{$AUTHOR}">
+    </p>
+
+    <p>
+      <strong>{'Tags'|@translate}</strong> <span class="fieldCaption">{'(optional)'|@translate}</span>
+      <br>
+      <input type="text" name="tags" value="{$TAGS}">
+      <br><span class="fieldCaption">{'(example: nature, landscape, portrait)'|@translate}</span>
+    </p>
+
+    <p>
+      <strong>{'Description'|@translate}</strong> <span class="fieldCaption">{'(optional)'|@translate}</span>
+      <br>
+      <textarea name="description">{$DESCRIPTION}</textarea>
+      <br><span class="fieldCaption">{'A good description will improve your visibility in search engines'|@translate}</span>
+    </p>
+
+    <p style="margin:0;">
+      <input class="submit" type="submit" name="submit_subscribe" value="{'Subscribe'|@translate}"/>
+    </p>
+  </fieldset>
+</form>
+{/if}
Index: /extensions/showcase_subscribe/language/en_UK/description.txt
===================================================================
--- /extensions/showcase_subscribe/language/en_UK/description.txt	(revision 11668)
+++ /extensions/showcase_subscribe/language/en_UK/description.txt	(revision 11668)
@@ -0,0 +1,1 @@
+Subscribe to Piwigo Showcase from your own gallery, with just a few clicks
Index: /extensions/showcase_subscribe/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/showcase_subscribe/language/en_UK/plugin.lang.php	(revision 11668)
+++ /extensions/showcase_subscribe/language/en_UK/plugin.lang.php	(revision 11668)
@@ -0,0 +1,11 @@
+<?php
+$lang['Subscribe my gallery to Piwigo Showcase'] = 'Subscribe my gallery to Piwigo Showcase';
+$lang['Gallery Address (URL)'] = 'Gallery Address (URL)';
+$lang['An error has occured, no connection to %s'] = 'An error has occured, no connection to %s';
+$lang['Your subscription is currently pending, if you have provided an email, you will be notified as soon as your gallery is registered'] = 'Your subscription is currently pending, if you have provided an email, you will be notified as soon as your gallery is registered';
+$lang['Your gallery is already registered in Piwigo Showcase, <a href="%s">see it →</a>'] = 'Your gallery is already registered in Piwigo Showcase, <a href="%s">see it →</a>';
+$lang['A good description will improve your visibility in search engines'] = 'A good description will improve your visibility in search engines';
+$lang['provide it if you want to be notified when your gallery is registered'] = 'provide it if you want to be notified when your gallery is registered';
+$lang['(optional)'] = '(optional)';
+$lang['(example: nature, landscape, portrait)'] = '(example: nature, landscape, portrait)';
+?>
Index: /extensions/showcase_subscribe/language/fr_FR/description.txt
===================================================================
--- /extensions/showcase_subscribe/language/fr_FR/description.txt	(revision 11668)
+++ /extensions/showcase_subscribe/language/fr_FR/description.txt	(revision 11668)
@@ -0,0 +1,1 @@
+Inscription à l'annuaire Piwigo depuis votre propre galerie en quelques clics
Index: /extensions/showcase_subscribe/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/showcase_subscribe/language/fr_FR/plugin.lang.php	(revision 11668)
+++ /extensions/showcase_subscribe/language/fr_FR/plugin.lang.php	(revision 11668)
@@ -0,0 +1,11 @@
+<?php
+$lang['Subscribe my gallery to Piwigo Showcase'] = 'Inscrire ma galerie sur l\'annuaire Piwigo';
+$lang['Gallery Address (URL)'] = 'Adresse de la galerie (URL)';
+$lang['An error has occured, no connection to %s'] = 'Une erreur est survenue, pas de connexion sur %s';
+$lang['Your subscription is currently pending, if you have provided an email, you will be notified as soon as your gallery is registered'] = 'Votre inscription est actuellement en attente, si vous avez fourni une adresse email, vous serez averti dès votre galerie sera enregistrée';
+$lang['Your gallery is already registered in Piwigo Showcase, <a href="%s">see it →</a>'] = 'Votre galerie est déjà enregistrée sur l\'annuaire Piwigo, <a href="%s">la voir →</a>';
+$lang['A good description will improve your visibility in search engines'] = 'Une bonne description améliorera votre visibilité dans les moteurs de recherche';
+$lang['provide it if you want to be notified when your gallery is registered'] = 'donnez en un si vous souhaitez être notifié lorsque votre galerie sera enregistrée';
+$lang['(optional)'] = '(optionnel)';
+$lang['(example: nature, landscape, portrait)'] = '(exemple: nature, paysage, portrait)';
+?>
Index: /extensions/showcase_subscribe/main.inc.php
===================================================================
--- /extensions/showcase_subscribe/main.inc.php	(revision 11668)
+++ /extensions/showcase_subscribe/main.inc.php	(revision 11668)
@@ -0,0 +1,30 @@
+<?php
+/*
+Plugin Name: Showcase Subscribe
+Version: auto
+Description: Subscribe to Piwigo Showcase (piwigo.org/showcase)
+Plugin URI: http://piwigo.org/ext/extension_view.php?eid=
+Author: plg
+Author URI: http://piwigo.wordpress.com
+*/
+
+if (!defined('PHPWG_ROOT_PATH'))
+{
+  die('Hacking attempt!');
+}
+
+/* Plugin admin */
+add_event_handler('get_admin_plugin_menu_links', 'showcase_subscribe_menu');
+function showcase_subscribe_menu($menu)
+{
+  array_push(
+    $menu,
+    array(
+      'NAME' => 'Showcase',
+      'URL'  => get_root_url().'admin.php?page=plugin-showcase_subscribe'
+      )
+    );
+
+  return $menu;
+}
+?>
