Index: /extensions/typetags/admin.php
===================================================================
--- /extensions/typetags/admin.php	(revision 15148)
+++ /extensions/typetags/admin.php	(revision 15149)
@@ -26,5 +26,5 @@
 // +-----------------------------------------------------------------------+
 
-if (isset($_POST['edittypetag']) and (empty($_POST['typetag_name']) or empty($_POST['typetag_color'])))
+if ( isset($_POST['edittypetag']) and (empty($_POST['typetag_name']) or empty($_POST['typetag_color'])) )
 {
   $edited_typetag = array(
@@ -33,51 +33,40 @@
     'color' => $_POST['typetag_color'],
   );
-  $page['errors'][] = l10n('typetag_error');
+  
+  array_push($page['errors'],  l10n('typetag_error'));
 }
 else if (isset($_POST['edittypetag']))
 {
-  $typetag = mysql_escape_string($_POST['edited_typetag']);
-  $typetag_name = mysql_escape_string($_POST['typetag_name']);
-  $typetag_color = mysql_escape_string($_POST['typetag_color']);
-
-  $all_typetags = pwg_query("
-    SELECT 
-      id, 
-      name, 
-      color
-    FROM  `". typetags_TABLE ."`;
-  ");
-  
-  while ($row = mysql_fetch_array($all_typetags))
-  {
-    $existing_names[] = $row['name'];
-    if ($typetag == $row['id'])
-    {
-      $current_name = $row['name'];
-      $current_color = $row['color'];
-    }
-  }
-
   // we must not rename typetag with an already existing name
-  if ($typetag_name != $current_name AND in_array($typetag_name, $existing_names))
+  $query = '
+SELECT id
+  FROM '.typetags_TABLE.'
+  WHERE
+    name = "'.$_POST['typetag_name'].'"
+    AND id != '.$_POST['edited_typetag'].'
+;';
+
+  if ( pwg_db_num_rows(pwg_query($query)) )
   {
     $edited_typetag = array(
-      'id' => $typetag,
-      'name' => $typetag_name,
-      'color' => $typetag_color,
+      'id' => $_POST['edited_typetag'],
+      'name' => $_POST['typetag_name'],
+      'color' => $_POST['typetag_color'],
     );
     
-    $page['errors'][] = l10n('typetag_already_exists');
+    array_push($page['errors'], l10n('typetag_already_exists'));
   }
   else
   {
-    pwg_query("
-      UPDATE `". typetags_TABLE ."` SET 
-        `name` = '". $typetag_name ."',
-        `color` = '". $typetag_color ."'
-      WHERE `id` = ". $typetag .";
-    ");
-    
-    $page['infos'][] = l10n('typetag_saved');
+    $query = '
+UPDATE '.typetags_TABLE.'
+  SET 
+    name = "'.$_POST['typetag_name'].'",
+    color = "'.$_POST['typetag_color'].'"
+  WHERE id = '.$_POST['edited_typetag'].'
+;';
+    pwg_query($query);
+    
+    array_push($page['infos'], l10n('typetag_saved'));
   }
 }
@@ -89,29 +78,30 @@
 if (isset($_GET['deletetypetag']))
 {
-  $query = "
-    SELECT name
-    FROM `". typetags_TABLE ."`
-    WHERE id = ". $_GET['deletetypetag'] .";
-  ";
-  $typetag_name = array_from_query($query, 'name');
-  
-  if (count($typetag_name) != 0)
-  {
-    pwg_query("
-      UPDATE `". TAGS_TABLE ."`
-      SET id_typetags = NULL
-      WHERE id_typetags = ". $_GET['deletetypetag'] .";
-    ");
-
-    pwg_query("
-      DELETE FROM `". typetags_TABLE ."`
-      WHERE id = ". $_GET['deletetypetag'] .";
-    ");
-
-    $page['infos'][] = l10n('typetag_suppr').' : '.$typetag_name[0];
+  $query = '
+SELECT id
+  FROM '.typetags_TABLE.'
+  WHERE id = '.$_GET['deletetypetag'].'
+;';
+  
+  if ( pwg_db_num_rows(pwg_query($query)) )
+  {
+    $query = '
+UPDATE '.TAGS_TABLE.'
+  SET id_typetags = NULL
+  WHERE id_typetags = '.$_GET['deletetypetag'].'
+;';
+    pwg_query($query);
+    
+    $query = '
+DELETE FROM '.typetags_TABLE.'
+  WHERE id = '.$_GET['deletetypetag'].'
+;';
+    pwg_query($query);
+    
+    array_push($page['infos'], l10n('typetag_suppr'));
   }
   else
   {
-    $page['errors'][] = l10n('typetag_unknown').' : '.$_GET['deletetypetag'];
+    array_push($page['errors'], l10n('typetag_unknown'));
   }
 }
@@ -121,12 +111,12 @@
 // +-----------------------------------------------------------------------+
 
-if (isset($_POST['addtypetag']) and (empty($_POST['typetag_name']) or empty($_POST['typetag_color'])))
+if ( isset($_POST['addtypetag']) and (empty($_POST['typetag_name']) or empty($_POST['typetag_color'])) )
 {
   $template->assign('typetag', array(
-    'NAME' => isset($_POST['typetag_name']) ? $_POST['typetag_name'] : '',
-    'COLOR' => isset($_POST['typetag_color']) ? $_POST['typetag_color'] : '',
+    'NAME' => $_POST['typetag_name'],
+    'COLOR' => $_POST['typetag_color'],
   ));
   
-  $page['errors'][] = l10n('typetag_error');
+  array_push($page['errors'], l10n('typetag_error'));
 }
 else if (isset($_POST['addtypetag']))
@@ -136,34 +126,34 @@
 
   // does the tag already exists?
-  $query = "
-    SELECT id
-    FROM `". typetags_TABLE ."`
-    WHERE name = '". $typetag_name ."';
-  ";
-  $existing_tags = array_from_query($query, 'id');
-
-  if (count($existing_tags) == 0)
-  {
-    pwg_query("
-      INSERT INTO `". typetags_TABLE ."`(
-        `name`,
-        `color`
-      )
-      VALUES(
-        '". $typetag_name ."',
-        '". $typetag_color ."'
-      );
-    ");
-
-    $page['infos'][] = l10n('typetag_saved');
+  $query = '
+SELECT id
+  FROM '.typetags_TABLE.'
+  WHERE name = "'.$_POST['typetag_name'].'"
+';
+
+  if ( pwg_db_num_rows(pwg_query($query)) )
+  {
+    $template->assign('typetag', array(
+      'NAME' => $_POST['typetag_name'],
+      'COLOR' => $_POST['typetag_color'],
+    ));
+    
+    array_push($page['errors'], l10n('typetag_already_exists'));
   }
   else
   {
-    $template->assign('typetag', array(
-      'NAME' => $typetag_name,
-      'COLOR' => $typetag_color,
-    ));
-    
-    $page['errors'][] = l10n('typetag_already_exists');
+    $query = '
+INSERT INTO '.typetags_TABLE.'(
+    name,
+    color
+  )
+  VALUES(
+    "'.$_POST['typetag_name'].'",
+    "'.$_POST['typetag_color'].'"
+  )
+;';
+    pwg_query($query);
+
+    array_push($page['infos'], l10n('typetag_saved'));
   }
 }
@@ -175,34 +165,52 @@
 if (isset($_POST['delete_all_assoc'])) 
 {
-  pwg_query("UPDATE `". TAGS_TABLE ."` SET id_typetags = NULL;");
-  $page['infos'][] = l10n('All associations have been removed');
-
+  pwg_query('UPDATE '.TAGS_TABLE.' SET id_typetags = NULL;');
+  array_push($page['infos'], l10n('All associations have been removed'));
 } 
 else if (isset($_POST['associations'])) 
 {
-    // beautify the parameters array
-    $string = preg_replace('#[;]$#', '', $_POST['associations']);
-    $associations = array();
-    $a = explode(';', $string);
-    
-    foreach ($a as $s) 
-    {
-       $v = explode(':', $s);
-       $associations[ltrim($v[0],'t-')] = ltrim($v[1],'tt-');
-    }
-
-    // save associations
-    foreach ($associations AS $tag => $typetag) 
-    {
-      pwg_query("
-        UPDATE `". TAGS_TABLE ."`
-        SET id_typetags = ". $typetag ."
-        WHERE id = ". $tag .";
-      ");
-    }
-    
-    $page['infos'][] = l10n('typetags_associated');
-}
-
+  // beautify the parameters array
+  $string = preg_replace('#[;]$#', null, $_POST['associations']);
+  $associations = array();
+  $a = explode(';', $string);
+  
+  foreach ($a as $s) 
+  {
+    $v = explode(':', $s);
+    $associations[ltrim($v[0],'t-')] = ltrim($v[1],'tt-');
+  }
+
+  // save associations
+  $updates = array();
+  foreach ($associations as $tag => $typetag) 
+  {
+    array_push($updates, array(
+      'id' => $tag,
+      'id_typetags' => $typetag,
+      ));
+  }
+  
+  mass_updates(
+    TAGS_TABLE, 
+    array('primary' => array('id'), 'update' => array('id_typetags')),
+    $updates
+    );
+  
+  array_push($page['infos'], l10n('typetags_associated'));
+}
+
+// +-----------------------------------------------------------------------+
+// |                          Configuration                                |
+// +-----------------------------------------------------------------------+
+if (isset($_POST['save_config']))
+{
+  $conf['TypeTags'] = array(
+    'show_all' => $_POST['show_all'] == 'true',
+    );
+    
+  conf_update_param('TypeTags', serialize($conf['TypeTags']));
+}
+
+$template->assign('SHOW_ALL', $conf['TypeTags']['show_all']);
 
 // +-----------------------------------------------------------------------+
@@ -212,25 +220,25 @@
 $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin/typetags_admin.tpl'));
 
-// Récupère tous les tags
-$all_tags = pwg_query("
-  SELECT 
-    t.id as tagid,
-    t.name as tagname, 
-    tt.id as typetagid,
-    tt.name as typetagname
-  FROM `". TAGS_TABLE ."` as t 
-  LEFT JOIN `". typetags_TABLE ."` as tt
-  ON  t.id_typetags = tt.id
-  ORDER BY t.name ASC;
-");
-
-while ($row = pwg_db_fetch_assoc($all_tags)) {
-  if ($row['typetagname'] == null) $row['typetagid'] = 'NULL';
-  $row['tagname'] = trigger_event('render_tag_name', $row['tagname']);
+// get all tags
+$query = '
+SELECT 
+    id as tagid,
+    name as tagname, 
+    id_typetags as typetagid
+  FROM '.TAGS_TABLE.'
+  ORDER BY name ASC
+;';
+$all_tags = pwg_query($query);
+
+while ($row = pwg_db_fetch_assoc($all_tags))
+{
+  if (!$row['typetagid']) $row['typetagid'] = 'NULL';
+  $row['tagname'] = strip_tags(trigger_event('render_tag_name', $row['tagname']));
   $template->append('typetags_association', $row);
 }
 
-// Récupère tous les typetags
-$all_typetags = pwg_query("SELECT * FROM `". typetags_TABLE ."` ORDER BY `name`;");
+// get all typetags
+$query = 'SELECT * FROM '.typetags_TABLE.' ORDER BY name;';
+$all_typetags = pwg_query($query);
 
 while ($row = mysql_fetch_assoc($all_typetags))
@@ -243,6 +251,7 @@
 }
 
-// formualire d'édition
-if (isset($_GET['edittypetag'])) {
+// edit form
+if (isset($_GET['edittypetag']))
+{
   $edited_typetag['id'] = $_GET['edittypetag'];
 }
@@ -251,14 +260,14 @@
 {
   $template->assign('edited_typetag', $edited_typetag['id']);
-
-  $tag = pwg_query("
-    SELECT 
-      id,
-      name,
-      color
-    FROM `". typetags_TABLE ."`
-    WHERE id = ".$edited_typetag['id'].";
-  ");
-  $row = pwg_db_fetch_assoc($tag);
+  
+$query = '
+SELECT 
+    id,
+    name,
+    color
+  FROM '.typetags_TABLE.'
+  WHERE id = '.$edited_typetag['id'].'
+;';
+  $row = pwg_db_fetch_assoc(pwg_query($query));
 
   $template->assign('typetag', array(
Index: /extensions/typetags/admin/typetags_admin.tpl
===================================================================
--- /extensions/typetags/admin/typetags_admin.tpl	(revision 15148)
+++ /extensions/typetags/admin/typetags_admin.tpl	(revision 15149)
@@ -5,65 +5,67 @@
 {combine_css path=$ROOT_URL|@cat:"plugins/typetags/admin/typetags_style.css"}
 
-{footer_script}
-{literal}
-  $(document).ready(function(){
-    // colorpicker
-    $('#colorpicker').farbtastic('#hexval');
-
-    // déplace chaque élément dans la bonne case
-    jQuery('ul#tt-NULL li').each(function() {
-      var $target = jQuery('ul#' + jQuery(this).attr('title'));
-      jQuery(this).appendTo($target).css('float', 'left');
+{footer_script}{literal}
+// set all containers the same size
+function equilibrate() {
+  var h=0;
+  jQuery("#associations ul")
+    .css('height', 'auto')
+    .each(function() { 
+      h = Math.max(h, jQuery(this).height());
+    })
+    .promise().done(function() { 
+      jQuery("#associations ul").css({'height': h+'px'});
     });
     
-    // initialise les déplacement
-    jQuery("li").draggable({
-      revert: "invalid",
-      helper: "clone",
-      cursor: "move"
+  //jQuery("#tt-NULL").css('height', 'auto');
+}
+
+// generate tag:typetag couples before submit the form
+function save_datas(form) {
+  var out = '';
+  
+  jQuery(".tt-container").each(function() {
+    var section = jQuery(this).attr('id');
+    jQuery("> li", this).each(function() { 
+      out += jQuery(this).attr('id') + ':' + section + ';';
     });
+  });
+  
+  jQuery('#assoc-input').val(out);
+  submit(form);
+}
 
-    // initialise le dépôt
-    jQuery('.tt-container').droppable({
-      accept: "li",
-      hoverClass: "active",
-      drop: function(event, ui) {
-        var $gallery = this;
-        ui.draggable.fadeOut(function() {
-          jQuery(this).appendTo($gallery).fadeIn();
-          equilibrate(); // on rééquilibre les colonnes à chaque déplacement
-        });      
-      }
-    });
-    
-    // équilibrage des colonnes
-    equilibrate();
-  });
-      
-  function equilibrate() {
-    jQuery("#associations").each(function(){
-      var h=0;
-      jQuery("> ul", this).css('height', 'auto')
-        .each(function(){ h=Math.max(h,jQuery(this).height()); })
-        .css({'height': h+'px'});
-    });
+// colorpicker
+jQuery('#colorpicker').farbtastic('#hexval');
+
+// move each tag in it's typetag container
+jQuery('ul#tt-NULL li').each(function() {
+  var $target = jQuery('ul#' + jQuery(this).attr('data'));
+  jQuery(this).appendTo($target).css('float', 'left');
+  if ($($target).attr('id') == 'tt-NULL') jQuery(this).css({'display':'inline-block','float':'none'});
+});
+equilibrate();
+
+// init drag
+jQuery("li").draggable({
+  revert: "invalid",
+  helper: "clone",
+  cursor: "move"
+});
+
+// init drop
+jQuery('.tt-container').droppable({
+  accept: "li",
+  hoverClass: "active",
+  drop: function(event, ui) {
+    var $gallery = this;
+    ui.draggable.fadeOut(function() {
+      jQuery(this).appendTo($gallery).css('float', 'left').css('display','').fadeIn();
+      if ($($gallery).attr('id') == 'tt-NULL') jQuery(this).css({'display':'inline-block','float':'none'});
+      equilibrate();
+    });      
   }
-  
-  // génération des couples tag:typetag avant de valider le formulaire
-  function save_datas(form) {
-    var out = '';
-    
-    jQuery(".tt-container").each(function(){
-      var section = jQuery(this).attr('id');
-      jQuery("> li", this).each(function(){ 
-        out += jQuery(this).attr('id') + ':' + section + ';';
-      });
-    });
-    
-    jQuery('#assoc-input').val(out);
-    submit(form);
-  }
-{/literal}
-{/footer_script}
+});
+{/literal}{/footer_script}
 
 <div class="titrePage">
@@ -72,18 +74,28 @@
 
 <form action="{$typetags_ADMIN}" method="post" name="form">
+<fieldset>
+  <legend>{'Configuration'|@translate}</legend>
+  <b>{'Display colored tags'|@translate}</b>
+  <label><input type="radio" name="show_all" value="false" {if not $SHOW_ALL}checked="checked"{/if}> {'Only on tags page'|@translate}</label>
+  <label><input type="radio" name="show_all" value="true" {if $SHOW_ALL}checked="checked"{/if}> {'Everywhere'|@translate}</label>
+  <p><input class="submit" type="submit" name="save_config" value="{'Submit'|@translate}"></p> 
+</fieldset>
+</form>
+ 
+<form action="{$typetags_ADMIN}" method="post" name="form">
   <fieldset>
   {if isset($edited_typetag)}
     <legend>{'Edit typetag'|@translate}</legend>
-    <input type="hidden" name="edited_typetag" value="{$edited_typetag}" />
     <div class="edit-container">
       <div id="colorpicker" style="float:right;"></div>
       <p><b>{'Edited TypeTag'|@translate} : <input type="text" readonly="readonly" size="18" style="background-color:{$typetag.OLD_COLOR};color:{$typetag.COLOR_TEXT};" value="{$typetag.OLD_NAME}"></b></p>
       <p>&nbsp;</p>
-      <p>{'New name'|@translate} : <input type="text" size="18" name="typetag_name" value="{$typetag.NAME}"/></p>
-      <p>{'New color'|@translate} : <input type="text" id="hexval" name="typetag_color" size="7" maxlength="7" value="{$typetag.COLOR}"/></p>
+      <p>{'New name'|@translate} : <input type="text" size="18" name="typetag_name" value="{$typetag.NAME}"></p>
+      <p>{'New color'|@translate} : <input type="text" id="hexval" name="typetag_color" size="7" maxlength="7" value="{$typetag.COLOR}"></p>
       <p>&nbsp;</p>
       <p>
-        <input class="submit" type="submit" name="edittypetag" value="{'Modify'|@translate}"/>
-        <input class="submit" type="submit" name="cancel" value="{'Reset'|@translate}"/>
+        <input type="hidden" name="edited_typetag" value="{$edited_typetag}">
+        <input class="submit" type="submit" name="edittypetag" value="{'Modify'|@translate}">
+        <input class="submit" type="submit" name="cancel" value="{'Reset'|@translate}">
       </p>
     </div>
@@ -93,9 +105,9 @@
       <div id="colorpicker" style="float:right;"></div>
       <p>&nbsp;</p>
-      <p>{'New TypeTag'|@translate} : <input type="text" size="18" name="typetag_name" value="{if isset($typetag.NAME)}{$typetag.NAME}{/if}"/></p>
-      <p>{'Color TypeTag'|@translate} : <input type="text" id="hexval" name="typetag_color" size="7" maxlength="7" value="{if isset($typetag.COLOR)}{$typetag.COLOR}{else}#444444{/if}"/></p>
+      <p>{'New TypeTag'|@translate} : <input type="text" size="18" name="typetag_name" value="{if isset($typetag.NAME)}{$typetag.NAME}{/if}"></p>
+      <p>{'Color TypeTag'|@translate} : <input type="text" id="hexval" name="typetag_color" size="7" maxlength="7" value="{if isset($typetag.COLOR)}{$typetag.COLOR}{else}#444444{/if}"></p>
       <p>&nbsp;</p>
       <p>
-        <input class="submit" type="submit" name="addtypetag" value="{'Create a Typetag'|@translate}"/>
+        <input class="submit" type="submit" name="addtypetag" value="{'Create a Typetag'|@translate}">
       </p>
     </div>
@@ -104,28 +116,13 @@
 </form>
 
-  {if !empty($typetags_selection)}
+{if !empty($typetags_selection)}
+<form action="{$typetags_ADMIN}" method="post" name="form" onsubmit="save_datas(this);">
   <fieldset>
-    <legend>{'TypeTag selection'|@translate}</legend>
-    <ul class="tagSelection">
-      {foreach from=$typetags_selection item=typetag}
-      <li>
-        <input type="text" readonly="readonly" style="background-color:{$typetag.color};color:{$typetag.color_text};margin:5px 0;" value="{$typetag.name}">
-        <a href="{$typetag.u_edit}" title="{'edit'|@translate}"><img src="{$themeconf.icon_dir}/edit.png" class="button" alt="{'edit'|@translate}"/></a>
-        <a href="{$typetag.u_delete}" title="{'delete'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');"><img src="{$themeconf.admin_icon_dir}/plug_delete.png" class="button" alt="{'delete'|@translate}"/></a>
-      </li>
-      {/foreach}
-    </ul>
-  </fieldset>
-  {/if}
-
-<form action="{$typetags_ADMIN}" method="post" name="form" onsubmit="save_datas(this);">
-  {if !empty($typetags_association) and !empty($typetags_selection)}
-  <fieldset>
-    <legend>{'TypeTag association'|@translate}</legend>
+    <legend>{'Edit and associate TypeTags'|@translate}</legend>
     
     <ul id="tt-NULL" class="tt-container NULL">
-      <h5>Non associés</h5>
+      <h5>{'Not associated'|@translate}</h5>
       {foreach from=$typetags_association item=tag}
-      <li id="t-{$tag.tagid}" title="tt-{$tag.typetagid}">
+      <li id="t-{$tag.tagid}" data="tt-{$tag.typetagid}">
         {$tag.tagname}
       </li>
@@ -136,4 +133,8 @@
     {foreach from=$typetags_selection item=typetag}
       <ul id="tt-{$typetag.id}" class="tt-container" style="box-shadow:inset 0 0 5px {$typetag.color};">
+        <span class="buttons">
+          <a href="{$typetag.u_edit}" title="{'edit'|@translate}"><img src="{$themeconf.icon_dir}/edit.png" class="button" alt="{'edit'|@translate}"></a>
+          <a href="{$typetag.u_delete}" title="{'delete'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');"><img src="{$themeconf.icon_dir}/delete.png" class="button" alt="{'delete'|@translate}"></a>
+        </span>
         <h5 style="background-color:{$typetag.color};color:{$typetag.color_text};">{$typetag.name}</h5>
       </ul>
@@ -141,10 +142,11 @@
     </div>
     
-    <p style="clear:both;">
-      <input type="hidden" name="associations" id="assoc-input"/>
-      <input class="submit" type="submit" name="associate" value="{'Validate'|@translate}"/>
-      <input class="submit" type="submit" name="delete_all_assoc" value="{'Delete all associations'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');"/>
+    <div style="clear:both;"></div>
+    <p style="margin-top:20px;">
+      <input type="hidden" name="associations" id="assoc-input">
+      <input class="submit" type="submit" name="associate" value="{'Validate'|@translate}">
+      <input class="submit" type="submit" name="delete_all_assoc" value="{'Delete all associations'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');">
     </p>
   </fieldset>
-  {/if}
 </form>
+{/if}
Index: /extensions/typetags/admin/typetags_style.css
===================================================================
--- /extensions/typetags/admin/typetags_style.css	(revision 15148)
+++ /extensions/typetags/admin/typetags_style.css	(revision 15149)
@@ -13,6 +13,6 @@
 .tt-container {
   float:left;
-  width:150px;
-  min-height:50px;
+  width:250px;
+  min-height:40px;
   height:auto;
   margin:5px !important;
@@ -25,6 +25,7 @@
   display:inline;
   float:none;
-  padding:2px 8px;
-  margin:5px;
+  padding:2px 5px;
+  margin:3px;
+  font-size:0.85em;
   background-color:#ddd;
   box-shadow:1px 1px 0px #fff;
@@ -37,5 +38,5 @@
 }
 .tt-container h5 {
-  margin:0 -5px;
+  margin:0 -5px 5px -5px;
   border-radius:5px 5px 0 0;
   padding:2px 0;
@@ -50,5 +51,6 @@
 
 .tt-container.NULL {
-  width:98%;
+  float:none;
+  width:auto;
   box-shadow:inset 0 0 5px #bbb;
   padding-bottom:10px;
@@ -58,2 +60,8 @@
   font-weight:bold;
 }
+
+.buttons {
+  float:right;
+  margin-left:-37px;
+  margin-top:2px;
+}
Index: /extensions/typetags/language/cs_CZ/plugin.lang.php
===================================================================
--- /extensions/typetags/language/cs_CZ/plugin.lang.php	(revision 15148)
+++ /extensions/typetags/language/cs_CZ/plugin.lang.php	(revision 15149)
@@ -32,6 +32,4 @@
 $lang['Edited TypeTag'] = 'TypeTag změněn';
 $lang['New TypeTag'] = 'Název TypeTagu';
-$lang['TypeTag association'] = 'Přiřadit - zrušit přiřazení TypeTagů';
-$lang['TypeTag selection'] = 'Změnit - smazat TypeTag';
 $lang['typetag_already_exists'] = 'Tento TypeTag už existuje';
 $lang['typetag_saved'] = 'TypeTag uložen';
Index: /extensions/typetags/language/de_DE/plugin.lang.php
===================================================================
--- /extensions/typetags/language/de_DE/plugin.lang.php	(revision 15148)
+++ /extensions/typetags/language/de_DE/plugin.lang.php	(revision 15149)
@@ -4,6 +4,4 @@
 $lang['Create a Typetag'] = 'Einen TypeTag erstellen';
 $lang['Edit typetag'] = 'TypeTag bearbeiten';
-$lang['TypeTag selection'] = 'TypeTags bearbeiten - löschen';
-$lang['TypeTag association'] = 'TypeTags assoziieren - dissoziieren';
 
 /* fields */
Index: /extensions/typetags/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/typetags/language/en_UK/plugin.lang.php	(revision 15148)
+++ /extensions/typetags/language/en_UK/plugin.lang.php	(revision 15149)
@@ -4,6 +4,5 @@
 $lang['Create a Typetag'] = 'Create a TypeTag';
 $lang['Edit typetag'] = 'Edit TypeTag';
-$lang['TypeTag selection'] = 'Edit - Delete TypeTags';
-$lang['TypeTag association'] = 'Associate - Dissociate TypeTags';
+$lang['Edit and associate TypeTags'] = 'Edit and associate TypeTags';
 
 /* fields */
@@ -13,4 +12,8 @@
 $lang['New name'] = 'New name';
 $lang['Color TypeTag'] = 'TypeTag color';
+$lang['Not associated'] = 'Not associated';
+$lang['Display colored tags'] = 'Display colored tags';
+$lang['Only on tags page'] = 'Only on tags page';
+$lang['Everywhere'] = 'Everywhere';
 
 /* buttons */
Index: /extensions/typetags/language/es_ES/plugin.lang.php
===================================================================
--- /extensions/typetags/language/es_ES/plugin.lang.php	(revision 15148)
+++ /extensions/typetags/language/es_ES/plugin.lang.php	(revision 15149)
@@ -4,6 +4,4 @@
 $lang['Create a Typetag'] = 'Crear TypeTag';
 $lang['Edit typetag'] = 'Editar TypeTag';
-$lang['TypeTag selection'] = 'Editar - Suprimir TypeTags';
-$lang['TypeTag association'] = 'Asociar - Disociar TypeTags';
 
 /* fields */
Index: /extensions/typetags/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/typetags/language/fr_FR/plugin.lang.php	(revision 15148)
+++ /extensions/typetags/language/fr_FR/plugin.lang.php	(revision 15149)
@@ -4,6 +4,5 @@
 $lang['Create a Typetag'] = 'Créer un TypeTag';
 $lang['Edit typetag'] = 'Editer le TypeTag';
-$lang['TypeTag selection'] = 'Editer - Supprimer des TypeTags';
-$lang['TypeTag association'] = 'Associer - Dissocier des TypeTags';
+$lang['Edit and associate TypeTags'] = 'Editer et associer les TypeTags';
 
 /* fields */
@@ -13,4 +12,8 @@
 $lang['New name'] = 'Nouveau nom';
 $lang['Color TypeTag'] = 'Couleur du TypeTag';
+$lang['Not associated'] = 'Non associés';
+$lang['Display colored tags'] = 'Afficher les tags colorés';
+$lang['Only on tags page'] = 'Seulement sur la page des tags';
+$lang['Everywhere'] = 'Partout';
 
 /* buttons */
Index: /extensions/typetags/language/it_IT/plugin.lang.php
===================================================================
--- /extensions/typetags/language/it_IT/plugin.lang.php	(revision 15148)
+++ /extensions/typetags/language/it_IT/plugin.lang.php	(revision 15149)
@@ -4,6 +4,4 @@
 $lang['Create a Typetag'] = 'Creare un TypeTag';
 $lang['Edit typetag'] = 'Modificare i TypeTag';
-$lang['TypeTag selection'] = 'Modificare - Cancellare i TypeTags';
-$lang['TypeTag association'] = 'Associare - Dissociare i TypeTags';
 
 /* fields */
Index: /extensions/typetags/language/lv_LV/plugin.lang.php
===================================================================
--- /extensions/typetags/language/lv_LV/plugin.lang.php	(revision 15148)
+++ /extensions/typetags/language/lv_LV/plugin.lang.php	(revision 15149)
@@ -4,6 +4,4 @@
 $lang['Create a Typetag'] = 'Izveidot TypeTag';
 $lang['Edit typetag'] = 'Rediģēt TypeTag';
-$lang['TypeTag selection'] = 'Rediģēt - Dzēst TypeTags';
-$lang['TypeTag association'] = 'Sasaistīt - Atsaistīt TypeTags';
 
 /* fields */
Index: /extensions/typetags/language/nl_NL/plugin.lang.php
===================================================================
--- /extensions/typetags/language/nl_NL/plugin.lang.php	(revision 15148)
+++ /extensions/typetags/language/nl_NL/plugin.lang.php	(revision 15149)
@@ -31,6 +31,4 @@
 $lang['New color'] = 'Nieuwe kleur';
 $lang['New name'] = 'Nieuwe naam';
-$lang['TypeTag association'] = 'Toekennen - Verwijderen van TypeTags';
-$lang['TypeTag selection'] = 'Wijzig - Verwijder TypeTags';
 $lang['typetag_already_exists'] = 'Deze TypeTag bestaat al';
 $lang['typetag_error'] = 'Je moet alle velden invullen (naam en kleur)';
Index: /extensions/typetags/language/no_NO/plugin.lang.php
===================================================================
--- /extensions/typetags/language/no_NO/plugin.lang.php	(revision 15148)
+++ /extensions/typetags/language/no_NO/plugin.lang.php	(revision 15149)
@@ -4,6 +4,4 @@
 $lang['Create a Typetag'] = 'Lag en TypeTag';
 $lang['Edit typetag'] = 'Rediger TypeTag';
-$lang['TypeTag selection'] = 'Rediger - Slett TypeTags';
-$lang['TypeTag association'] = 'Assosier - Dissossier TypeTags';
 
 /* fields */
Index: /extensions/typetags/language/pl_PL/plugin.lang.php
===================================================================
--- /extensions/typetags/language/pl_PL/plugin.lang.php	(revision 15148)
+++ /extensions/typetags/language/pl_PL/plugin.lang.php	(revision 15149)
@@ -31,6 +31,4 @@
 $lang['New name'] = 'Nowa nazwa';
 $lang['New TypeTag'] = 'Nazwa TypeTag';
-$lang['TypeTag association'] = 'Powiązania - usuń powiązania TypeTag';
-$lang['TypeTag selection'] = 'Edycja - Usuwanie TypeTag';
 $lang['typetags_associated'] = 'Powiązano TypeTag';
 $lang['typetag_already_exists'] = 'Ten TypeTag już istnieje';
Index: /extensions/typetags/language/ru_RU/plugin.lang.php
===================================================================
--- /extensions/typetags/language/ru_RU/plugin.lang.php	(revision 15148)
+++ /extensions/typetags/language/ru_RU/plugin.lang.php	(revision 15149)
@@ -31,6 +31,4 @@
 $lang['New color'] = 'Новый цвет';
 $lang['New name'] = 'Новое название';
-$lang['TypeTag association'] = 'Связать - отделить типы тегов';
-$lang['TypeTag selection'] = 'Редактировать - Удалить типы тегов';
 $lang['typetag_already_exists'] = 'Этот тип тегов уже есть';
 $lang['typetag_error'] = 'Нужно заполнить все поля (название и цвет)';
Index: /extensions/typetags/language/sk_SK/plugin.lang.php
===================================================================
--- /extensions/typetags/language/sk_SK/plugin.lang.php	(revision 15148)
+++ /extensions/typetags/language/sk_SK/plugin.lang.php	(revision 15149)
@@ -4,6 +4,4 @@
 $lang['Create a Typetag'] = 'Vytvoriť kľúčové slovo';
 $lang['Edit typetag'] = 'Upraviť kľúčového slová';
-$lang['TypeTag selection'] = 'Upraviť - vymazať kľúčového slová';
-$lang['TypeTag association'] = 'Spojené - Rozdelené kľúčového slová';
 
 /* fields */
Index: /extensions/typetags/language/uk_UA/plugin.lang.php
===================================================================
--- /extensions/typetags/language/uk_UA/plugin.lang.php	(revision 15148)
+++ /extensions/typetags/language/uk_UA/plugin.lang.php	(revision 15149)
@@ -31,6 +31,4 @@
 $lang['New name'] = 'Нове ім\'я';
 $lang['New TypeTag'] = 'Ім\'я TypeTag';
-$lang['TypeTag association'] = 'Асоціювати - Дисоціювати TypeTags';
-$lang['TypeTag selection'] = 'Редагування - Видалити TypeTags';
 $lang['typetags_associated'] = 'TypeTags, пов\'язані';
 $lang['typetag_already_exists'] = 'Це TypeTag вже існує';
Index: /extensions/typetags/main.inc.php
===================================================================
--- /extensions/typetags/main.inc.php	(revision 15148)
+++ /extensions/typetags/main.inc.php	(revision 15149)
@@ -10,10 +10,33 @@
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
-global $prefixeTable ;
+global $prefixeTable, $conf;
 
-define('typetags_DIR' , basename(dirname(__FILE__)));
-define('typetags_PATH' , PHPWG_PLUGINS_PATH . typetags_DIR . '/');
+define('typetags_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
 define('typetags_TABLE' , $prefixeTable . 'typetags');
-define('typetags_ADMIN', get_root_url().'admin.php?page=plugin-' . typetags_DIR);
+define('typetags_ADMIN', get_root_url().'admin.php?page=plugin-' . basename(dirname(__FILE__)));
+
+
+include(typetags_PATH . 'typetags.php');
+$conf['TypeTags'] = unserialize($conf['TypeTags']);
+
+// tags on picture page
+/*if (script_basename() == 'picture')
+{
+  add_event_handler('loc_end_picture', 'typetags_picture');
+}*/
+
+// tags everywhere
+if ($conf['TypeTags']['show_all'])
+{
+  add_event_handler('render_tag_name', 'typetags_render', 0);
+}
+// tags on tags page
+else if (script_basename() == 'tags')
+{
+  add_event_handler('loc_begin_page_header', 'typetags_tags');
+}
+
+
+add_event_handler('get_admin_plugin_menu_links', 'typetags_admin_menu');
 
 function typetags_admin_menu($menu)
@@ -26,15 +49,3 @@
 }
 
-function typetags()
-{
-  include(typetags_PATH . 'typetags.php');
-}
-
-if (script_basename() == 'tags')
-{
-  add_event_handler('loc_begin_page_header', 'typetags', 60);
-}
-
-add_event_handler('get_admin_plugin_menu_links', 'typetags_admin_menu');
-
 ?>
Index: /extensions/typetags/maintain.inc.php
===================================================================
--- /extensions/typetags/maintain.inc.php	(revision 15148)
+++ /extensions/typetags/maintain.inc.php	(revision 15149)
@@ -10,5 +10,5 @@
   if (!in_array('id_typetags', $result))
   {
-    pwg_query('ALTER TABLE '.TAGS_TABLE.' ADD COLUMN `id_typetags` SMALLINT(5)');
+    pwg_query('ALTER TABLE '.TAGS_TABLE.' ADD COLUMN `id_typetags` SMALLINT(5);');
   }
 
@@ -16,10 +16,25 @@
   if (!mysql_fetch_row($result))
   {
-    $q = 'CREATE TABLE '. $prefixeTable .'typetags(
-      id smallint(5) unsigned NOT NULL auto_increment,
-      name VARCHAR(255) NOT NULL,
-      color VARCHAR(255) NOT NULL,
-      PRIMARY KEY  (id));';
-    pwg_query($q);
+    $query = '
+CREATE TABLE `'. $prefixeTable .'typetags` (
+  `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
+  `name` varchar(255) NOT NULL,
+  `color` varchar(255) NOT NULL,
+  PRIMARY KEY (`id`)
+) DEFAULT CHARSET=utf8
+;';
+    pwg_query($query);
+  }
+  
+  conf_update_param('TypeTags', serialize(array('show_all'=>true)));
+}
+
+function plugin_activate()
+{
+  global $conf;
+  
+  if (!isset($conf['TypeTags']))
+  {
+    conf_update_param('TypeTags', serialize(array('show_all'=>true)));
   }
 }
@@ -29,9 +44,7 @@
   global $prefixeTable;
 
-  $q = ' ALTER TABLE '.TAGS_TABLE.' DROP COLUMN `id_typetags`';
-  pwg_query( $q );
-
-  $q = ' DROP TABLE '. $prefixeTable .'typetags;';
-  pwg_query($q);
+  pwg_query('ALTER TABLE '.TAGS_TABLE.' DROP COLUMN `id_typetags`');
+  pwg_query('DROP TABLE '. $prefixeTable .'typetags;');
+  pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param = "TypeTags" LIMIT 1;');
 }
 
Index: /extensions/typetags/typetags.php
===================================================================
--- /extensions/typetags/typetags.php	(revision 15148)
+++ /extensions/typetags/typetags.php	(revision 15149)
@@ -1,73 +1,141 @@
 <?php
 
-global $page, $template;
+/**
+ * triggered by 'render_tag_name'
+ */
+function typetags_render($tag)
+{
+  global $pwg_loaded_plugins;
+  
+  $query = '
+SELECT color
+  FROM '.typetags_TABLE.' AS tt
+    INNER JOIN '.TAGS_TABLE.' AS t
+      ON t.id_typetags = tt.id
+  WHERE t.name = "'.mysql_real_escape_string($tag).'"
+;';;
+  list($color) = pwg_db_fetch_row(pwg_query($query));
+  
+  if ($color === null) 
+  {
+    return $tag;
+  }
+  elseif (isset($pwg_loaded_plugins['ExtendedDescription']))
+  {
+    return "[lang=all]<span style='color:".$color.";'>[/lang]".$tag."[lang=all]</span>[/lang]";
+  }
+  else
+  {
+    return "<span style='color:".$color.";'>".$tag."</span>";
+  }
+}
 
-$query = '
-SELECT  t.id , tt.color
-FROM ' . typetags_TABLE . ' AS tt
-INNER JOIN ' . TAGS_TABLE . ' AS t
-ON  t.id_typetags = tt.id
-WHERE  t.id_typetags IS NOT NULL ;';
-
-$result = pwg_query($query);
-$tagsColor = array();
-while ($row = mysql_fetch_assoc($result))
+/**
+ * colors tags on picture page
+ */
+/*function typetags_picture()
 {
-  $tagsColor[$row['id']] = $row['color'];
-}
-$display = $template->get_template_vars('display_mode');
-
-if ($display == 'letters')
-{
-  $letters = $template->get_template_vars('letters');
-  if (empty($letters)) return;
-  $template->clear_assign('letters');
-
-  foreach ($letters as $k1 => $letter)
-  {
-    foreach ($letter['tags'] as $k2 => $tag)
-    {
-      if (isset($tagsColor[$tag['id']]))
-      {
-        $letters[$k1]['tags'][$k2]['URL'] .= '" style="color:' . $tagsColor[$tag['id']];
-      }
-    }
-  }
-  $template->assign('letters', $letters);
-}
-elseif ($display == 'cloud')
-{
-  $tags = $template->get_template_vars('tags');
+  global $template;
+    
+  $tags = $template->get_template_vars('related_tags');
   if (empty($tags)) return;
-  $template->clear_assign('tags');
+  
+  $query = '
+SELECT
+    t.id ,
+    tt.color
+  FROM '.typetags_TABLE.' AS tt
+    INNER JOIN '.TAGS_TABLE.' AS t
+      ON t.id_typetags = tt.id
+  WHERE t.id_typetags IS NOT NULL
+;';
+  $tagsColor = simple_hash_from_query($query, 'id', 'color');
+  if (empty($tagsColor)) return;
 
   foreach ($tags as $key => $tag)
   {
-    if (isset($tagsColor[$tag['id']]))
+    if (isset($tagsColor[ $tag['id'] ]))
     {
-      $tags[$key]['URL'] .= '" style="color:' . $tagsColor[$tag['id']];
+      $tags[$key]['URL'].= '" style="color:'.$tagsColor[ $tag['id'] ].';';
     }
   }
-  $template->assign('tags', $tags);
-}
-elseif ($display == 'cumulus')
+  
+  $template->clear_assign('related_tags');
+  $template->assign('related_tags', $tags);
+}*/
+
+/**
+ * colors tags on tags page
+ */
+function typetags_tags()
 {
-  $tags = $template->get_template_vars('tags');
-  if (empty($tags)) return;
-  $template->clear_assign('tags');
+  global $template;
 
-  foreach ($tags as $key => $tag)
+  $query = '
+SELECT
+    t.id ,
+    tt.color
+  FROM '.typetags_TABLE.' AS tt
+    INNER JOIN '.TAGS_TABLE.' AS t
+      ON t.id_typetags = tt.id
+  WHERE t.id_typetags IS NOT NULL
+;';
+  $tagsColor = simple_hash_from_query($query, 'id', 'color');
+  if (empty($tagsColor)) return;
+
+  $display = $template->get_template_vars('display_mode');
+  if ($display == 'letters')
   {
-    if (isset($tagsColor[$tag['id']]))
+    $letters = $template->get_template_vars('letters');
+    if (empty($letters)) return;
+
+    foreach ($letters as $k1 => $letter)
     {
-      $tagsColor[$tag['id']] = str_replace('#', '0x', $tagsColor[$tag['id']]);
-      $tags[$key]['URL'] .= '\' color=\'' . $tagsColor[$tag['id']] . '\' hicolor=\'' . $tagsColor[$tag['id']];
+      foreach ($letter['tags'] as $k2 => $tag)
+      {
+        if (isset($tagsColor[ $tag['id'] ]))
+        {
+          $letters[$k1]['tags'][$k2]['URL'].= '" style="color:'.$tagsColor[ $tag['id'] ].';';
+        }
+      }
     }
+    
+    $template->clear_assign('letters');
+    $template->assign('letters', $letters);
   }
-  $template->assign('tags', $tags);
+  elseif ($display == 'cloud')
+  {
+    $tags = $template->get_template_vars('tags');
+    if (empty($tags)) return;
+
+    foreach ($tags as $key => $tag)
+    {
+      if (isset($tagsColor[ $tag['id'] ]))
+      {
+        $tags[$key]['URL'].= '" style="color:'.$tagsColor[ $tag['id'] ].';';
+      }
+    }
+    
+    $template->clear_assign('tags');
+    $template->assign('tags', $tags);
+  }
+  elseif ($display == 'cumulus')
+  {
+    $tags = $template->get_template_vars('tags');
+    if (empty($tags)) return;
+
+    foreach ($tags as $key => $tag)
+    {
+      if (isset($tagsColor[ $tag['id'] ]))
+      {
+        $tagsColor[ $tag['id'] ] = str_replace('#', '0x', $tagsColor[ $tag['id'] ]);
+        $tags[$key]['URL'].= '\' color=\''.$tagsColor[ $tag['id'] ].'\' hicolor=\''.$tagsColor[ $tag['id'] ];
+      }
+    }
+    
+    $template->clear_assign('tags');
+    $template->assign('tags', $tags);
+  }
 }
 
-// Suppression des liens soulignés
-$template->block_html_head('', '<style type="text/css">#fullTagCloud a, .tagLetter a { border: none; }</style>', $smarty, $repeat);
-
 ?>
