Index: /extensions/piwishack/admin/index.php
===================================================================
--- /extensions/piwishack/admin/index.php	(revision 23724)
+++ /extensions/piwishack/admin/index.php	(revision 23724)
@@ -0,0 +1,27 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PiwiShack - a Piwigo Plugin                                           |
+// | Copyright (C) 2009 MOREAU Julien - gotcha@piwigo.org                  |
+// +-----------------------------------------------------------------------+
+// | 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/piwishack/admin/piwishack_admin.css
===================================================================
--- /extensions/piwishack/admin/piwishack_admin.css	(revision 23724)
+++ /extensions/piwishack/admin/piwishack_admin.css	(revision 23724)
@@ -0,0 +1,14 @@
+span.pattern {
+	background-color: yellow;
+	padding: 0 5px;
+	margin-left: 2px;
+}
+
+span.propertyleft {
+  font-weight:bold;
+  float:left;
+  width:30%;
+  text-align:right;
+  margin:0;
+  padding:0 0.5em 0 0
+}
Index: /extensions/piwishack/admin/piwishack_admin.php
===================================================================
--- /extensions/piwishack/admin/piwishack_admin.php	(revision 23724)
+++ /extensions/piwishack/admin/piwishack_admin.php	(revision 23724)
@@ -0,0 +1,74 @@
+<?php
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+ 
+//include_once(dirname(__FILE__).'/../initialize.inc.php');
+//URLSHACK_init();
+$me = get_plugin_data('piwishack');
+load_language('plugin.lang', $me->plugin_path);
+ 
+//$me->config['URLShackRight'] = 'BBcode'; 
+if (isset($_POST['submit']))
+{
+  $me->config['URLShackRight'] =            $_POST['URLSHACK_RIGHT'];
+  $me->config['DefaultHtmlBBcode'] =        $_POST['URLSHACK_DEFAULTCODE'];
+  $me->config['WebLinkOpenOnOtherWindow'] = $_POST['URLSHACK_BLANK'];
+  $me->config['ImageNameBeforeCode'] =      $_POST['URLSHACK_IMG_NAME'];
+  
+  $me->config['Display']['Thumbnail'] =         $_POST['URLSHACK_THUMB'];
+  $me->config['Display']['ThumbnailToGallery'] = $_POST['URLSHACK_THUMB_TO_GAL'];
+  $me->config['Display']['ThumbnailToImage'] =   $_POST['URLSHACK_THUMB_TO_IMG'];
+  $me->config['Display']['Image'] =             $_POST['URLSHACK_IMG'];
+  $me->config['Display']['ImageToGallery'] =     $_POST['URLSHACK_IMG_TO_GAL'];
+  $me->config['Display']['NameToImage']  =       $_POST['URLSHACK_URL_IMG'];
+  $me->config['Display']['NameToGallery'] =      $_POST['URLSHACK_URL_GAL'];
+  
+  $me->config['ExtendedDisplay'][0] = stripslashes($_POST['URLSHACK_PERSO1']);
+  $me->config['ExtendedDisplay'][1] = stripslashes($_POST['URLSHACK_PERSO2']);
+  $me->config['ExtendedDisplay'][2] = stripslashes($_POST['URLSHACK_PERSO3']);
+  $me->config['ExtendedDisplay'][3] = stripslashes($_POST['URLSHACK_PERSO4']);
+  $me->config['ExtendedDisplay'][4] = stripslashes($_POST['URLSHACK_PERSO5']); 
+  $me->config['ExtendedDisplay'][5] = stripslashes($_POST['URLSHACK_PERSO6']); 
+  $me->config['ExtendedDisplay'][6] = stripslashes($_POST['URLSHACK_PERSO7']); 
+  $me->config['ExtendedLabel'][0] = stripslashes($_POST['URLSHACK_PLABEL1']);
+  $me->config['ExtendedLabel'][1] = stripslashes($_POST['URLSHACK_PLABEL2']);
+  $me->config['ExtendedLabel'][2] = stripslashes($_POST['URLSHACK_PLABEL3']);
+  $me->config['ExtendedLabel'][3] = stripslashes($_POST['URLSHACK_PLABEL4']);
+  $me->config['ExtendedLabel'][4] = stripslashes($_POST['URLSHACK_PLABEL5']); 
+  $me->config['ExtendedLabel'][5] = stripslashes($_POST['URLSHACK_PLABEL6']); 
+  $me->config['ExtendedLabel'][6] = stripslashes($_POST['URLSHACK_PLABEL7']); 
+  $me->save_config();
+}
+ 
+global $template;
+$template->set_filenames( array('plugin_admin_content' => dirname(__FILE__).'/piwishack_admin.tpl') );
+ 
+$template->assign('URLSHACK_RIGHT',       $me->config['URLShackRight']);
+$template->assign('URLSHACK_DEFAULTCODE', $me->config['DefaultHtmlBBcode']);
+$template->assign('URLSHACK_BLANK',       $me->config['WebLinkOpenOnOtherWindow']);
+$template->assign('URLSHACK_IMG_NAME',    $me->config['ImageNameBeforeCode']);
+  
+$template->assign('URLSHACK_THUMB',        $me->config['Display']['Thumbnail']);
+$template->assign('URLSHACK_THUMB_TO_GAL', $me->config['Display']['ThumbnailToGallery']);
+$template->assign('URLSHACK_THUMB_TO_IMG', $me->config['Display']['ThumbnailToImage']);
+$template->assign('URLSHACK_IMG',          $me->config['Display']['Image']);
+$template->assign('URLSHACK_IMG_TO_GAL',   $me->config['Display']['ImageToGallery']);
+$template->assign('URLSHACK_URL_IMG',      $me->config['Display']['NameToImage']);
+$template->assign('URLSHACK_URL_GAL',      $me->config['Display']['NameToGallery']);
+  
+$template->assign('URLSHACK_PERSO1', $me->config['ExtendedDisplay'][0]);
+$template->assign('URLSHACK_PERSO2', $me->config['ExtendedDisplay'][1]);
+$template->assign('URLSHACK_PERSO3', $me->config['ExtendedDisplay'][2]);
+$template->assign('URLSHACK_PERSO4', $me->config['ExtendedDisplay'][3]);
+$template->assign('URLSHACK_PERSO5', $me->config['ExtendedDisplay'][4]);
+$template->assign('URLSHACK_PERSO6', $me->config['ExtendedDisplay'][5]);
+$template->assign('URLSHACK_PERSO7', $me->config['ExtendedDisplay'][6]);
+$template->assign('URLSHACK_PLABEL1', $me->config['ExtendedLabel'][0]);
+$template->assign('URLSHACK_PLABEL2', $me->config['ExtendedLabel'][1]);
+$template->assign('URLSHACK_PLABEL3', $me->config['ExtendedLabel'][2]);
+$template->assign('URLSHACK_PLABEL4', $me->config['ExtendedLabel'][3]);
+$template->assign('URLSHACK_PLABEL5', $me->config['ExtendedLabel'][4]);
+$template->assign('URLSHACK_PLABEL6', $me->config['ExtendedLabel'][5]);
+$template->assign('URLSHACK_PLABEL7', $me->config['ExtendedLabel'][6]);
+ 
+$template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content');
+?>
Index: /extensions/piwishack/admin/piwishack_admin.tpl
===================================================================
--- /extensions/piwishack/admin/piwishack_admin.tpl	(revision 23724)
+++ /extensions/piwishack/admin/piwishack_admin.tpl	(revision 23724)
@@ -0,0 +1,162 @@
+<link rel="stylesheet" type="text/css" href="{$ROOT_URL}plugins/piwishack/admin/piwishack_admin.css">
+<div class="titrePage">
+  <h2>{'admin_title'|@translate}</h2>
+</div>
+<form method="post" action="{$URLSHACK_F_ACTION}" class="properties">
+<fieldset>
+  <legend>{'admin_fieldset_main'|@translate}</legend>
+	<ul>
+    <li>
+    <span class="propertyleft">
+      <label>{'admin_used_by'|@translate}</label>
+    </span> 
+    <select name="URLSHACK_RIGHT">
+      <option value="admin" {if $URLSHACK_RIGHT == "admin"}selected="selected"{/if}>{'admin_used_by_admin'|@translate}</option>
+	    <option value="member" {if $URLSHACK_RIGHT == "member"}selected="selected"{/if}>{'admin_used_by_members'|@translate}</option>
+	    <option value="all" {if $URLSHACK_RIGHT == "all"}selected="selected"{/if}>{'admin_used_by_all'|@translate}</option>
+	  </select> 
+	  </li>
+    <li>
+    <span class="propertyleft">
+      <label>{'admin_default_sheet'|@translate}</label>
+    </span>
+    <select name="URLSHACK_DEFAULTCODE">
+      <option value="html" {if $URLSHACK_DEFAULTCODE == "html"}selected="selected"{/if}>{'admin_default_sheet_html'|@translate}</option>
+      <option value="bbcode" {if $URLSHACK_DEFAULTCODE == "bbcode"}selected="selected"{/if}>{'admin_default_sheet_bbcode'|@translate}</option>
+      <option value="custom" {if $URLSHACK_DEFAULTCODE == "custom"}selected="selected"{/if}>{'admin_default_sheet_custom'|@translate}</option>
+    </select>
+	  </li>
+    <li>
+    <span class="propertyleft">
+      <label>{'admin_window_open'|@translate}</label>
+    </span>
+	  <select name="URLSHACK_BLANK">
+	    <option value="local" {if $URLSHACK_BLANK != "other"}selected="selected"{/if}>{'admin_window_open_local'|@translate}</option>
+	    <option value="other" {if $URLSHACK_BLANK == "other"}selected="selected"{/if}>{'admin_window_open_other'|@translate}</option>
+	  </select>
+	  </li>
+    <li>
+    <span class="propertyleft">
+      <label>{'admin_img_name'|@translate}</label>
+    </span>
+	  <select name="URLSHACK_IMG_NAME">
+	    <option value="no" {if $URLSHACK_IMG_NAME == "no"}selected="selected"{/if}>{'admin_img_name_never'|@translate}</option>
+	    <option value="list" {if $URLSHACK_IMG_NAME == "list"}selected="selected"{/if}>{'admin_img_name_list'|@translate}</option>
+	    <option value="all" {if $URLSHACK_IMG_NAME == "all"}selected="selected"{/if}>{'admin_img_name_all'|@translate}</option>
+	  </select>
+	  </li>
+  </ul>
+</fieldset>
+<fieldset>
+	<legend>{'admin_fieldset_codes'|@translate}</legend>
+	<ul>
+	  <li>
+	  <span class="propertyleft">
+      <label>{'admin_codes_thumb'|@translate}</label>
+    </span>
+    <input type="text" size="2" name="URLSHACK_THUMB" value="{$URLSHACK_THUMB}" /> BBCode: <span class="pattern">[img]##t[/img]</span> - HTML: <span class="pattern">&lt;img src="##t" /&gt;</span>
+    </li>
+    <li>
+    <span class="propertyleft">
+      <label>{'admin_codes_thumb_to_page'|@translate}</label>
+    </span>
+    <input type="text" size="2" name="URLSHACK_THUMB_TO_GAL" value="{$URLSHACK_THUMB_TO_GAL}" /> BBCode: <span class="pattern">[url=##g][img]##t[/img][/url]</span> - HTML: <span class="pattern">&lt;a src="##g" /&gt&lt;img src="##t" /&gt;&lt;/a&gt;</span>
+    </li>
+    <li>
+    <span class="propertyleft">
+      <label>{'admin_codes_thumb_to_image'|@translate}</label>
+    </span>
+    <input type="text" size="2" name="URLSHACK_THUMB_TO_IMG" value="{$URLSHACK_THUMB_TO_IMG}" /> BBCode: <span class="pattern">[url=##i][img]##t[/img][/url]</span> - HTML: <span class="pattern">&lt;a src="##i" /&gt&lt;img src="##t" /&gt;&lt;/a&gt;</span> 
+    </li>
+    <li>
+    <span class="propertyleft">
+      <label>{'admin_codes_img'|@translate}</label>
+    </span>
+    <input type="text" size="2" name="URLSHACK_IMG" value="{$URLSHACK_IMG}" /> BBCode: <span class="pattern">[img]##i[/img]</span> - HTML: <span class="pattern">&lt;img src="##i" /&gt;</span>
+    </li>
+    <li>
+    <span class="propertyleft">
+      <label>{'admin_codes_img_to_page'|@translate}</label>
+    </span>
+    <input type="text" size="2" name="URLSHACK_IMG_TO_GAL" value="{$URLSHACK_IMG_TO_GAL}" /> BBCode: <span class="pattern">[url=##g][img]##i[/img][/url]</span> - HTML: <span class="pattern">&lt;a src="##g" /&gt&lt;img src="##i" /&gt;&lt;/a&gt;</span>
+    </li>
+    <li>
+    <span class="propertyleft">
+      <label>{'admin_codes_name_to_image'|@translate}</label>
+    </span>
+    <input type="text" size="2" name="URLSHACK_URL_IMG" value="{$URLSHACK_URL_IMG}" /> BBCode: <span class="pattern">[url=##i]##n[/url]</span> - HTML: <span class="pattern">&lt;a href="##i"&gt;##n&lt;/a&gt;</span>
+    </li>
+    <li>
+    <span class="propertyleft">
+      <label>{'admin_codes_name_to_page'|@translate}</label>
+    </span>
+    <input type="text" size="2" name="URLSHACK_URL_GAL" value="{$URLSHACK_URL_GAL}" /> BBCode: <span class="pattern">[url=##g]##n[/url]</span> - HTML: <span class="pattern">&lt;a src="##g" /&gt##n&lt;/a&gt;</span>
+    </li>
+  </ul>
+	<div class="help">{'admin_codes_help'|@translate}</div>
+</fieldset>
+<fieldset>
+	<legend>{'admin_fieldset_custom'|@translate}</legend>
+  <ul>
+    <li>
+	  <span class="propertyleft">
+      <label>{'admin_custom_code'|@translate}1</label>
+    </span>
+    <input type="text" size="65" name="URLSHACK_PERSO1" value='{$URLSHACK_PERSO1}' />
+      <label>{'admin_custom_name'|@translate}</label>
+    <input type="text" size="35" name="URLSHACK_PLABEL1" value='{$URLSHACK_PLABEL1}' />
+    </li>
+    <li>
+    <span class="propertyleft">
+      <label>{'admin_custom_code'|@translate}2</label>
+    </span>
+    <input type="text" size="65" name="URLSHACK_PERSO2" value='{$URLSHACK_PERSO2}' />
+      <label>{'admin_custom_name'|@translate}</label>
+    <input type="text" size="35" name="URLSHACK_PLABEL2" value='{$URLSHACK_PLABEL2}' />
+    </li>
+    <li>
+    <span class="propertyleft">
+      <label>{'admin_custom_code'|@translate}3</label>
+    </span>
+    <input type="text" size="65" name="URLSHACK_PERSO3" value='{$URLSHACK_PERSO3}' />
+      <label>{'admin_custom_name'|@translate}</label>
+    <input type="text" size="35" name="URLSHACK_PLABEL3" value='{$URLSHACK_PLABEL3}' />
+    </li>
+    <li>
+    <span class="propertyleft">
+      <label>{'admin_custom_code'|@translate}4</label>
+    </span>
+    <input type="text" size="65" name="URLSHACK_PERSO4" value='{$URLSHACK_PERSO4}' />
+      <label>{'admin_custom_name'|@translate}</label>
+    <input type="text" size="35" name="URLSHACK_PLABEL4" value='{$URLSHACK_PLABEL4}' />
+    </li>
+    <li>
+    <span class="propertyleft">
+      <label>{'admin_custom_code'|@translate}5</label>
+    </span>
+    <input type="text" size="65" name="URLSHACK_PERSO5" value='{$URLSHACK_PERSO5}' />
+      <label>{'admin_custom_name'|@translate}</label>
+    <input type="text" size="35" name="URLSHACK_PLABEL5" value='{$URLSHACK_PLABEL5}' />
+    </li>
+    <li>
+    <span class="propertyleft">
+      <label>{'admin_custom_code'|@translate}6</label>
+    </span>
+    <input type="text" size="65" name="URLSHACK_PERSO6" value='{$URLSHACK_PERSO6}' />
+      <label>{'admin_custom_name'|@translate}</label>
+    <input type="text" size="35" name="URLSHACK_PLABEL6" value='{$URLSHACK_PLABEL6}' />
+    </li>
+    <li>
+    <span class="propertyleft">
+      <label>{'admin_custom_code'|@translate}7</label>
+    </span>
+    <input type="text" size="65" name="URLSHACK_PERSO7" value='{$URLSHACK_PERSO7}' />
+      <label>{'admin_custom_name'|@translate}</label>
+    <input type="text" size="35" name="URLSHACK_PLABEL7" value='{$URLSHACK_PLABEL7}' />
+    </li>
+  </ul>
+	<div class="help">{'admin_custom_help'|@translate}</div>
+</fieldset>
+ 
+<p><input type="submit" value="{'admin_save'|@translate}" name="submit" /></p>
+</form>
Index: /extensions/piwishack/class.inc.php
===================================================================
--- /extensions/piwishack/class.inc.php	(revision 23724)
+++ /extensions/piwishack/class.inc.php	(revision 23724)
@@ -0,0 +1,617 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PiwiShack - a Piwigo Plugin                                           |
+// | Copyright (C) 2009 MOREAU Julien - gotcha@piwigo.org                  |
+// +-----------------------------------------------------------------------+
+// | 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.                                                                  |
+// +-----------------------------------------------------------------------+
+
+class PiwiShack
+{
+  var $plugin_name, $plugin_path;
+  var $opened, $to_close;
+  var $config;
+  var $list;
+  
+  /**************************************************************************
+   *  function: PiwiShack
+   **************************************************************************
+   *  Rôle:
+   *    Constructeur; charge la config et initialise les handlers 
+   *************************************************************************/
+  function PiwiShack($plugin_name, $plugin_path)
+  {
+    // Args
+    $this->plugin_name = $plugin_name;
+    $this->plugin_path = $plugin_path;
+
+    $this->load_config();
+
+    // handler
+    $this->initialize_event_handler();
+
+  }
+
+  /**************************************************************************
+   *  function: initialize_event_handler
+   **************************************************************************
+   *  Rôle:
+   *    Ajout des handlers nécessaires aux pages index et picture 
+   *    si les droits l'autorisent.    
+   *************************************************************************/
+  function initialize_event_handler()
+  {
+  
+    if ((($this->config['URLShackRight'] == "admin") && (is_admin()))
+     || (($this->config['URLShackRight'] == "member") && (!is_a_guest()))
+     ||  ($this->config['URLShackRight'] == "all"))
+    {
+      if (script_basename() != $this->plugin_name.'_controller')
+      {
+        add_event_handler('loc_end_index', array(&$this, 'handler_index'));
+        add_event_handler('picture_pictures_data', array(&$this, 'handler_picture'));
+      }
+    }
+  }
+
+  /**************************************************************************
+   *  function: loading_lang
+   **************************************************************************
+   *  Rôle:
+   *    Chargement des données de langue 
+   *************************************************************************/
+  function loading_lang()
+  {
+    load_language('plugin.lang', $this->plugin_path);
+  }
+
+  /**************************************************************************
+   *  function: get_link_icon
+   **************************************************************************
+   *  in: 
+   *  out: 
+   *    code de l'action   
+   **************************************************************************
+   *  Rôle:
+   *    Retourne le code de l'action d'ouverture piwishack 
+   *************************************************************************/
+  function get_link_icon($main_link)
+  {
+    global $page;
+
+    if (empty($page['items']))
+    {
+        return;
+    }
+
+    $this->loading_lang();
+    $link_title = l10n('open_window_piwishack');
+    $link_url = '<img id="urlshackicon" title="'.$link_title.'" onclick="urlshack_switch();" src="'.get_root_url().'plugins/piwishack/icon/controller_open.png" class="button" alt="URLShack links popup">';
+
+    return $link_url;
+  }
+
+  /**************************************************************************
+   *  function: handler_index
+   **************************************************************************
+   *  in: 
+   *  out: 
+   *    Code source   
+   **************************************************************************
+   *  Rôle:
+   *    Handler dans le cas des pages d'index : ajoute le code javascript,
+   *     le code html du popup et l'icone d'ouverture piwishack.
+   *************************************************************************/
+  function handler_index()
+  {
+    global $template;
+
+    $link_url = $this->get_link_icon(duplicate_index_url());
+    if (!empty($link_url))
+    {
+      $mystyle = '<link rel="stylesheet" type="text/css" href="' . get_root_url() . 'plugins/piwishack/style.css">';
+      $template->block_html_head(null, $mystyle);
+
+      // get button javascript code and add to page
+      $code = $this->get_js_button_code();
+      $template->concat('PLUGIN_INDEX_CONTENT_AFTER', $code);
+    
+      // Add piwishack button in the list of action icons
+      $template->concat('PLUGIN_INDEX_ACTIONS', '<li>'.$link_url.'</li>');
+    
+      // get popup html code and add to page
+      $popup = $this->get_html_popup_code("index");
+      $template->concat('PLUGIN_INDEX_CONTENT_AFTER', $popup);
+    }
+  }
+
+  /**************************************************************************
+   *  function: handler_picture
+   **************************************************************************
+   *  in: 
+   *  out: 
+   *    Code source   
+   **************************************************************************
+   *  Rôle:
+   *    Handler dans le cas des pages images : ajoute le code javascript,
+   *     le code html du popup et l'icone d'ouverture piwishack.    
+   *************************************************************************/
+  function handler_picture($pictures)
+  {
+    global $template;
+
+    $link_url = $this->get_link_icon(duplicate_index_url());
+    if (!empty($link_url))
+    {
+      $mystyle = '<link rel="stylesheet" type="text/css" href="' . get_root_url() . 'plugins/piwishack/style.css">';
+      $template->block_html_head(null, $mystyle);
+
+      // get button javascript code and add to page
+      $code = $this->get_js_button_code();
+      $template->concat('PLUGIN_PICTURE_AFTER', $code);
+    
+      // Add piwishack button in the list of action icons
+      $template->concat('PLUGIN_PICTURE_ACTIONS', $link_url);
+    
+      // get popup html code and add to page
+      $popup = $this->get_html_popup_code("picture");
+      $template->concat('PLUGIN_PICTURE_AFTER', $popup);
+    }
+    return $pictures;    
+  }
+
+  /**************************************************************************
+   *  function: get_js_button_code
+   **************************************************************************
+   *  in: 
+   *  out: 
+   *    Code source   
+   **************************************************************************
+   *  Rôle:
+   *    Genere le code javascript de la page 
+   *************************************************************************/
+  function get_js_button_code()
+  {
+    $this->loading_lang();
+    $link_open = l10n('open_window_piwishack');
+    $link_close = l10n('close_window_piwishack');
+
+    $icon_open = get_root_url() . 'plugins/piwishack/icon/controller_open.png';
+    $icon_close = get_root_url() . 'plugins/piwishack/icon/controller_close.png'; 
+    $code = '
+<script type="text/javascript">
+  function urlshack_switch() { 
+    if (document.getElementById("urlshackpopup").style.visibility != "visible")
+      urlshack_open();
+    else
+      urlshack_close();
+  }
+  function urlshack_open() { 
+    document.getElementById("urlshackpopup").style.visibility = "visible";
+    document.getElementById("urlshackicon").src = "' . $icon_close . '";
+    document.getElementById("urlshackicon").title = "' . $link_close . '";
+    return false;
+  }    
+  function urlshack_close() {
+    document.getElementById("urlshackpopup").style.visibility = "hidden";
+    document.getElementById("urlshackicon").src = "' . $icon_open . '";
+    document.getElementById("urlshackicon").title = "' . $link_open . '";
+    return false;
+  }
+  function urlshack_html() { 
+    document.getElementById("bbcode").style.display = "none";
+    document.getElementById("custom").style.display = "none";
+    document.getElementById("html").style.display = "block";
+    document.getElementById("tab-bbcode").setAttribute("class", "tab");
+    document.getElementById("tab-custom").setAttribute("class", "tab");
+    document.getElementById("tab-html").setAttribute("class", "tabselected");
+    return false;
+  }    
+  function urlshack_bbcode() { 
+    document.getElementById("html").style.display = "none";
+    document.getElementById("custom").style.display = "none";
+    document.getElementById("bbcode").style.display = "block";
+    document.getElementById("tab-bbcode").setAttribute("class", "tabselected");
+    document.getElementById("tab-custom").setAttribute("class", "tab");
+    document.getElementById("tab-html").setAttribute("class", "tab");
+    return false;
+  }    
+  function urlshack_custom() { 
+    document.getElementById("html").style.display = "none";
+    document.getElementById("bbcode").style.display = "none";
+    document.getElementById("custom").style.display = "block";
+    document.getElementById("tab-bbcode").setAttribute("class", "tab");
+    document.getElementById("tab-custom").setAttribute("class", "tabselected");
+    document.getElementById("tab-html").setAttribute("class", "tab");
+    return false;
+  }    
+   
+</script>
+        ';
+    return $code;
+  }
+
+  /**************************************************************************
+   *  function: get_html_popup_code
+   **************************************************************************
+   *  in: 
+   *    $pagetype (index ou picture)   
+   *  out: 
+   *    Code source   
+   **************************************************************************
+   *  Rôle:
+   *    Genere le code html complet du popup piwishack 
+   *************************************************************************/
+  function get_html_popup_code($pagetype)
+  {
+    $prefix = 0;
+
+    $icon_close = get_root_url() . 'plugins/piwishack/icon/controller_close.png';
+    $icon_open = get_root_url() . 'plugins/piwishack/icon/controller_open.png';
+    $this->get_data();
+    $listdisp = $this->config['Display'];
+    asort($listdisp);
+    $namedisp = array_keys($listdisp); 
+
+    $this->loading_lang();
+
+    $popup  = "<div id='urlshackpopup' class='piwishack' >\n";
+    $popup .= "<div class='header'><img src='" .$icon_open . "'> &nbsp; Piwishack</div>\n";
+    $popup .= "<div class='area'>\n";
+    $popup .= "<h1>" . l10n('Partage_me') . "</h1>\n";
+    $popup .= "<form>\n";
+    $popup .= "<span onclick='urlshack_html();' id='tab-html' class='" . ($this->config['DefaultHtmlBBcode'] == 'html' ? "tabselected" : "tab") . "'>\n";
+    $popup .= l10n('sheet_html') . "</span>\n";
+    $popup .= "<span onclick='urlshack_bbcode();' id='tab-bbcode' class='" . ($this->config['DefaultHtmlBBcode'] == 'bbcode' ? "tabselected" : "tab") . "'>\n";
+    $popup .= l10n('sheet_bbcode') . "</span>\n";
+    $popup .= "<span onclick='urlshack_custom();' id='tab-custom' class='" . ($this->config['DefaultHtmlBBcode'] == 'custom' ? "tabselected" : "tab") . "'>\n";
+    $popup .= l10n('sheet_custom') . "</span>\n";
+    $popup .= "</form>\n";
+
+    // A block is inserted for each format, bbcode and html
+    //  but displayed only for the selected (radio) format
+    foreach (array("html", "bbcode") as $format)
+    {
+      $popup.= "<div id='" . $format . "' class='" . ($this->config['DefaultHtmlBBcode'] == $format ? "sheetselected" : "sheet") . "'>\n";
+      foreach ($namedisp as $i) {
+        if ($listdisp[$i] != 0) {
+          // Compute code length
+          $current_code = $this->get_codes($i, $format, $prefix);
+          $nb_cols = 100;
+          $nb_rows = min(1 + (strlen($current_code) / $nb_cols), 5);
+
+          $popup .= "<form>\n";
+          $popup .= "<h2>". l10n('post_code_' .$i) . " : </h2>";
+          $popup .= '<textarea name="' . $i . '" cols="' . $nb_cols . '" rows="' . $nb_rows .'" onclick="select()">';
+          if (($this->config['ImageNameBeforeCode'] === "all")
+           || (($this->config['ImageNameBeforeCode'] === "list") && ($pagetype === "index")))
+          {
+             $prefix = 1;
+          }
+          $popup .= $current_code;
+          $popup .= '</textarea>';
+          $popup .= "<img src='plugins/piwishack/icon/$i.png' alt='$i' width='200' />";
+          $popup .= "</form>\n";
+        }
+      }
+      $popup .= "</div>\n";
+    }
+
+    $nb = count($this->config['ExtendedDisplay']);
+    $popup .= "<div id='custom' class='" . ($this->config['DefaultHtmlBBcode'] == "custom" ? "sheetselected" : "sheet") . "'>\n";
+    for ($i = 0; $i < $nb; $i++) {
+      if ($this->config['ExtendedDisplay'][$i] != "") {
+        // Compute code length
+        $current_code = $this->get_list_pattern_result($this->config['ExtendedDisplay'][$i]);
+        $nb_cols = 125;
+        $nb_rows = min(1 + (strlen($current_code) / $nb_cols), 5);
+
+        $popup .= "<form>\n";
+        $popup .= "<h2>" . l10n('custom_code') . ($i+1) . " - " . $this->config['ExtendedLabel'][$i] . " </h2>";
+        $popup .= '<textarea class="commentContent" name="ExtendedDisplay' . $i . '" cols="' . $nb_cols . '" rows="' . $nb_rows .'" onclick="select()">';
+        $popup .= $current_code;
+        $popup .= '</textarea>';
+        $popup .= "</form>\n";
+      }
+    }
+    $popup .= "</div>\n";
+ 
+    $popup .= "</div>\n";
+    $popup .= "<div class='footer'>";
+    $popup .= '<button onclick="urlshack_close();"><img src="' .$icon_close . '"><span class="txtbutton">' . l10n('close') . '</span><img src="' .$icon_close . '"></button>';
+    $popup .= "</div>\n";
+    $popup .= "</div>\n";
+    return $popup;
+  }
+
+  /**************************************************************************
+   *  function: get_data
+   **************************************************************************
+   *  in: 
+   *  out: 
+   **************************************************************************
+   *  Rôle:
+   *    Remplit le tableau d'images en fonction du contexte 
+   *************************************************************************/
+  function get_data()
+  {
+    global $page;
+    $this->list = array();
+    $S = '';
+
+    switch (script_basename())
+    {
+      case 'index':
+      {
+        global $pictures;
+        if (isset($pictures))
+        {
+          $this->list = $pictures;
+        }
+        break;
+      }
+      case 'picture':
+      {
+        global $picture;
+        if (isset($picture['current']))
+        {
+          $this->list[] = $picture['current'];
+        }
+        break;
+      }
+    }
+
+    if (empty($this->list) and !empty($page['items']))
+    {
+  	  $rank_of = array_flip($page['items']);
+      $query = '
+	  SELECT *
+      FROM '.IMAGES_TABLE.'
+      WHERE id IN ('.implode(',', $page['items']).')
+	  ;';
+
+      $result = pwg_query($query);
+
+      while ($row = pwg_db_fetch_assoc($result))
+      {
+        $row['rank'] = $rank_of[ $row['id'] ];
+        array_push($this->list, $row);
+      }
+
+      usort($this->list, 'rank_compare');
+    }
+  }
+
+  /**************************************************************************
+   *  function: get_codes
+   **************************************************************************
+   *  in: 
+   *    $type: type du code
+   *    $format: html ou bbcode
+   *    $prefix : indique si le nom doit précéder le code     
+   *  out: 
+   *    Code du type
+   **************************************************************************
+   *  Rôle:
+   *    Retourne le code (pattern) correspondant au type fourni 
+   *    en le faisant précéder éventuellement du nom de l'image 
+   *************************************************************************/
+  function get_codes($type, $format, $prefix)
+  {
+    $pattern = '';
+    
+    $target = $this->config['WebLinkOpenOnOtherWindow'] == "other" ? " target=_blank" : "";
+     
+    if ($type === 'Thumbnail') {
+      if ($format === 'html')   { $pattern = "<img src=\"##t\" />"; }
+      if ($format === 'bbcode') { $pattern = "[img]##t[/img]"; }
+    }
+    else if ($type === 'ThumbnailToImage') {
+      if ($format === 'html')   { $pattern = "<a href=\"##i\"". $target . "><img src=\"##t\" /></a>"; }
+      if ($format === 'bbcode') { $pattern = "[url=##i][img]##t[/img][/url]"; }
+    }
+    else if ($type === 'ThumbnailToGallery') {
+      if ($format === 'html')   { $pattern = "<a href=\"##g\"". $target . "><img src=\"##t\" /></a>"; }
+      if ($format === 'bbcode') { $pattern = "[url=##g][img]##t[/img][/url]"; }
+    }
+    else if ($type === 'Image') {
+      if ($format === 'html')   { $pattern = "<img src=\"##t\" />"; }
+      if ($format === 'bbcode') { $pattern = "[img]##i[/img]"; }
+    }
+    else if ($type === 'ImageToGallery') {
+      if ($format === 'html')   { $pattern = "<a href=\"##g\"". $target . "><img src=\"##i\" /></a>"; }
+      if ($format === 'bbcode') { $pattern = "[url=##g][img]##i[/img][/url]"; }
+    }
+    else if ($type === 'NameToImage') {
+      if ($format === 'html')   { $pattern = "<a href=\"##i\"". $target . ">##n</a>"; }
+      if ($format === 'bbcode') { $pattern = "[url=##i]##n[/url]"; }
+    }
+    else if ($type === 'NameToGallery') {
+      if ($format === 'html')   { $pattern = "<a href=\"##g\"". $target . ">##n</a>"; }
+      if ($format === 'bbcode') { $pattern = "[url=##g]##n[/url]"; }
+    }
+    if ($prefix === 1) {
+      // TO_DO : n'ajouter que si ##n n'est pas déjà dans la chaine ?
+      $pattern = "##n: " . $pattern;
+    }
+    return $this->get_list_pattern_result($pattern);
+  }
+
+  /**************************************************************************
+   *  function: get_list_pattern_result
+   **************************************************************************
+   *  in: 
+   *    $pattern
+   *  out: 
+   *    Le code à afficher
+   **************************************************************************
+   *  Rôle:
+   *    Retourne la chaine à afficher pour le pattern fourni et pour 
+   *       l'ensemble des images du contexte courant 
+   *************************************************************************/
+  function get_list_pattern_result($pattern)
+  {
+    global $page, $lang_info, $conf;
+    // force $conf['derivative_url_style'] to 2 (script) to make sure
+    // exported HTML/BBCode will use i.php?/upload and not _data/i/upload
+    // because you don't know when the cache will be flushed
+    $previous_derivative_url_style = $conf['derivative_url_style'];
+    $conf['derivative_url_style'] = 2;
+    $S = '';
+    if (!empty($this->list))
+    {
+      set_make_full_url();
+      foreach ($this->list as $row)
+      {
+         $S .= $this->get_pattern_result($row, $pattern) . "\n";
+      }
+      unset_make_full_url();
+    }
+    
+    // restore configuration setting
+    $conf['derivative_url_style'] = $previous_derivative_url_style;
+    return $S;
+  }
+
+  /**************************************************************************
+   *  function: get_pattern_result
+   **************************************************************************
+   *  in: 
+   *    $pattern
+   *  out: 
+   *    La chaine expansée
+   **************************************************************************
+   *  Rôle:
+   *    transformer le pattern fourni en résolvant les variables
+   *      ##i : image URL
+   *      ##t : thumbnail URL
+   *      ##g : galerie URL
+   *      ##n : nom de l'image
+   *************************************************************************/
+  function get_pattern_result($row, $pattern)
+  {
+    global $page, $lang_info;
+    include_once(PHPWG_ROOT_PATH.'/include/functions_picture.inc.php');
+
+    // nom image
+    $name = (!empty($row['name']) ? $row['name'] : $row['file']);
+
+    // lien image miniature
+    $tbn = DerivativeImage::thumb_url($row);
+
+    // lien image grand format
+    $img = DerivativeImage::url(IMG_MEDIUM, $row);
+
+    // lien image dans sa galerie
+    $gal = duplicate_picture_url( array( 'image_id' => $row['id'], 'image_file' => $row['file'],));
+
+    $applic = str_replace('##i', $img, $pattern);
+    $applic = str_replace('##t', $tbn, $applic);
+    $applic = str_replace('##g', $gal, $applic);
+    $applic = str_replace('##n', $name, $applic);
+
+    return $applic;
+  }
+    
+  /**************************************************************************
+   *  function: load_config
+   **************************************************************************
+   *  Rôle:
+   *    Chargement de la configuration du plugin
+   *    Definition des valeurs par défaut    
+   *************************************************************************/
+  function load_config()
+  {
+    $x = @file_get_contents( dirname(__FILE__).'/data.dat' );
+    if ($x!==false)
+    {
+      $c = unserialize($x);
+      $this->config = $c;
+    }
+
+    if ( !isset($this->config))
+    {
+      // Default configuration
+      $this->config['URLShackRight'] = 'admin';    // admin, members, all 
+      $this->config['DefaultHtmlBBcode'] = 'bbcode'; // bbcode, html, custom
+      $this->config['WebLinkOpenOnOtherWindow'] = 'local';    // local, other
+      $this->config['ImageNameBeforeCode'] = 'list';    // no, list, all
+      
+      $this->config['Display']['Thumbnail'] = 1;
+      $this->config['Display']['ThumbnailToGallery'] = 2;
+      $this->config['Display']['ThumbnailToImage'] = 3;
+      $this->config['Display']['Image'] = 4;
+      $this->config['Display']['ImageToGallery'] = 5;
+      $this->config['Display']['NameToImage'] = 0;
+      $this->config['Display']['NameToGallery'] = 0;
+      
+      $this->config['ExtendedDisplay'][0] = "Thumbnail in Textile format";
+      $this->config['ExtendedLabel'][0] = "!##t(##n)!";
+
+      $this->config['ExtendedDisplay'][1] = "{{##i|##n}}";
+      $this->config['ExtendedLabel'][1] = "Image in Creole format";
+
+      $this->config['ExtendedDisplay'][2] = '<h6 style="text-align: center;"><a href="##i" target="_blank"><img class="aligncenter" style="width: 100%; height: 100%;" src="##t" alt="##t" /></a></h6>';
+      $this->config['ExtendedLabel'][2] = "Personnalised HTML format example";
+
+      $this->config['ExtendedDisplay'][3] = "##n : ##i";
+      $this->config['ExtendedLabel'][3] = "Image name + image URL";
+
+      $this->config['ExtendedDisplay'][4] = ""; 
+      $this->config['ExtendedLabel'][4] = ""; 
+      $this->config['ExtendedDisplay'][5] = ""; 
+      $this->config['ExtendedLabel'][5] = ""; 
+      $this->config['ExtendedDisplay'][6] = ""; 
+      $this->config['ExtendedLabel'][6] = ""; 
+      $this->save_config();
+    }
+  }
+
+  /**************************************************************************
+   *  function: save_config
+   **************************************************************************
+   *  Rôle:
+   *    Sauvegarde de la configuration du plugin 
+   *************************************************************************/
+  function save_config()
+  {
+    $file = fopen( dirname(__FILE__).'/data.dat', 'w' );
+    fwrite($file, serialize($this->config) );
+    fclose( $file );
+  }
+
+  /**************************************************************************
+   *  function: plugin_admin_menu
+   **************************************************************************
+   *  in: menu 
+   *  out: menu 
+   **************************************************************************
+   *  Rôle:
+   *    Ajout du lien d'administration du plugin
+   *************************************************************************/
+  function plugin_admin_menu($menu)
+  {
+    array_push($menu,
+      array(
+      'NAME' => 'PiwiShack',
+      'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/admin/piwishack_admin.php')
+      )
+    );
+    return $menu;
+  }
+    
+}
+
+?>
Index: /extensions/piwishack/style.css
===================================================================
--- /extensions/piwishack/style.css	(revision 23724)
+++ /extensions/piwishack/style.css	(revision 23724)
@@ -0,0 +1,119 @@
+.piwishack {
+  background-color: #222;
+  position: absolute;
+  visibility: hidden;
+  left: 50px;
+  top: 50px;
+  border: 4px groove orange; /* #ff4020; */
+  padding: 0;
+  margin: 0;
+  color: #ccc;
+  z-index: 999; 
+}
+.piwishack .header, .piwishack .footer {
+  font-size: 140%;
+  font-weight: bold;
+  text-align: right;
+  padding: 5px 10px;
+  margin: 0;
+  background-color: #333;
+  color: #fff;
+}
+
+.piwishack .area {
+  padding: 10px;
+  border-top: 1px solid #444;
+  border-bottom: 1px solid #444;
+}
+
+.piwishack h1 {
+  color:#ccc;
+  font-size:120%;
+  font-weight:bold;
+  text-align: center;
+  margin: 0 0 10px 0;
+  padding: 0;
+  background-image: none;
+  background-color: #222;
+  /* border: 1px solid green; */
+}
+.piwishack h2 {
+  color:#ccc;
+  font-size:100%;
+  font-weight:bold;
+  text-align: left;
+  padding-left: 25px;
+  background-image: none;
+  background-color: #222;
+}
+.piwishack label, .piwishack span {
+  padding-left: 10px;
+}
+
+.piwishack textarea {
+  background-color: #444;
+  color: #ccc;
+}  
+
+.piwishack input[type="radio"] {
+  margin: 0 5px;
+}
+.piwishack button, .piwishack input[type="button"] {
+  font-weight: bold;
+}
+.piwishack .txtbutton {
+  font-size: 140%;
+  vertical-align: bottom;
+  margin: 0 15px;
+  color: #159;
+}
+
+.piwishack .tab, .piwishack .tabselected {
+  font-weight: bold;
+  border-left: 1px solid #888;
+  border-top: 1px solid #888;
+  border-right: 1px solid #888;
+  border-radius: 4px 4px 0 0;
+  border-width: 1px 1px 0 1px;
+  padding: 6px 15px 2px 15px;
+}  
+.piwishack .tab {
+  background-color: #444;
+  color: #888;
+}  
+.piwishack .tabselected {
+  background-color: #222;
+  color: #fff;
+}  
+
+.piwishack img {
+  /* border: 1px solid yellow; */ 
+  vertical-align: top;
+}
+
+.piwishack .sheet, .piwishack .sheetselected { 
+  border: 1px solid #888;
+  padding: 3px 8px;
+  border-radius: 0 4px 4px 4px;
+}
+.piwishack .sheetselected {
+  display: block;
+}
+.piwishack .sheet {
+  display: none;
+}
+
+span.pattern {
+	background-color: yellow;
+	padding: 0 5px;
+	margin-left: 2px;
+}
+
+span.propertyleft {
+  font-weight:bold;
+  float:left;
+  width:30%;
+  text-align:right;
+  margin:0;
+  padding:0 0.5em 0 0
+}
