Changeset 15149


Ignore:
Timestamp:
May 20, 2012, 12:38:07 PM (12 years ago)
Author:
mistic100
Message:
  • display typetags everywhere (not only tags page)
  • little redesign of admin page + code cleaning
Location:
extensions/typetags
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • extensions/typetags/admin.php

    r12483 r15149  
    2626// +-----------------------------------------------------------------------+
    2727
    28 if (isset($_POST['edittypetag']) and (empty($_POST['typetag_name']) or empty($_POST['typetag_color'])))
     28if ( isset($_POST['edittypetag']) and (empty($_POST['typetag_name']) or empty($_POST['typetag_color'])) )
    2929{
    3030  $edited_typetag = array(
     
    3333    'color' => $_POST['typetag_color'],
    3434  );
    35   $page['errors'][] = l10n('typetag_error');
     35 
     36  array_push($page['errors'],  l10n('typetag_error'));
    3637}
    3738else if (isset($_POST['edittypetag']))
    3839{
    39   $typetag = mysql_escape_string($_POST['edited_typetag']);
    40   $typetag_name = mysql_escape_string($_POST['typetag_name']);
    41   $typetag_color = mysql_escape_string($_POST['typetag_color']);
    42 
    43   $all_typetags = pwg_query("
    44     SELECT
    45       id,
    46       name,
    47       color
    48     FROM  `". typetags_TABLE ."`;
    49   ");
    50  
    51   while ($row = mysql_fetch_array($all_typetags))
    52   {
    53     $existing_names[] = $row['name'];
    54     if ($typetag == $row['id'])
    55     {
    56       $current_name = $row['name'];
    57       $current_color = $row['color'];
    58     }
    59   }
    60 
    6140  // we must not rename typetag with an already existing name
    62   if ($typetag_name != $current_name AND in_array($typetag_name, $existing_names))
     41  $query = '
     42SELECT id
     43  FROM '.typetags_TABLE.'
     44  WHERE
     45    name = "'.$_POST['typetag_name'].'"
     46    AND id != '.$_POST['edited_typetag'].'
     47;';
     48
     49  if ( pwg_db_num_rows(pwg_query($query)) )
    6350  {
    6451    $edited_typetag = array(
    65       'id' => $typetag,
    66       'name' => $typetag_name,
    67       'color' => $typetag_color,
     52      'id' => $_POST['edited_typetag'],
     53      'name' => $_POST['typetag_name'],
     54      'color' => $_POST['typetag_color'],
    6855    );
    6956   
    70     $page['errors'][] = l10n('typetag_already_exists');
     57    array_push($page['errors'], l10n('typetag_already_exists'));
    7158  }
    7259  else
    7360  {
    74     pwg_query("
    75       UPDATE `". typetags_TABLE ."` SET
    76         `name` = '". $typetag_name ."',
    77         `color` = '". $typetag_color ."'
    78       WHERE `id` = ". $typetag .";
    79     ");
    80    
    81     $page['infos'][] = l10n('typetag_saved');
     61    $query = '
     62UPDATE '.typetags_TABLE.'
     63  SET
     64    name = "'.$_POST['typetag_name'].'",
     65    color = "'.$_POST['typetag_color'].'"
     66  WHERE id = '.$_POST['edited_typetag'].'
     67;';
     68    pwg_query($query);
     69   
     70    array_push($page['infos'], l10n('typetag_saved'));
    8271  }
    8372}
     
    8978if (isset($_GET['deletetypetag']))
    9079{
    91   $query = "
    92     SELECT name
    93     FROM `". typetags_TABLE ."`
    94     WHERE id = ". $_GET['deletetypetag'] .";
    95   ";
    96   $typetag_name = array_from_query($query, 'name');
    97  
    98   if (count($typetag_name) != 0)
    99   {
    100     pwg_query("
    101       UPDATE `". TAGS_TABLE ."`
    102       SET id_typetags = NULL
    103       WHERE id_typetags = ". $_GET['deletetypetag'] .";
    104     ");
    105 
    106     pwg_query("
    107       DELETE FROM `". typetags_TABLE ."`
    108       WHERE id = ". $_GET['deletetypetag'] .";
    109     ");
    110 
    111     $page['infos'][] = l10n('typetag_suppr').' : '.$typetag_name[0];
     80  $query = '
     81SELECT id
     82  FROM '.typetags_TABLE.'
     83  WHERE id = '.$_GET['deletetypetag'].'
     84;';
     85 
     86  if ( pwg_db_num_rows(pwg_query($query)) )
     87  {
     88    $query = '
     89UPDATE '.TAGS_TABLE.'
     90  SET id_typetags = NULL
     91  WHERE id_typetags = '.$_GET['deletetypetag'].'
     92;';
     93    pwg_query($query);
     94   
     95    $query = '
     96DELETE FROM '.typetags_TABLE.'
     97  WHERE id = '.$_GET['deletetypetag'].'
     98;';
     99    pwg_query($query);
     100   
     101    array_push($page['infos'], l10n('typetag_suppr'));
    112102  }
    113103  else
    114104  {
    115     $page['errors'][] = l10n('typetag_unknown').' : '.$_GET['deletetypetag'];
     105    array_push($page['errors'], l10n('typetag_unknown'));
    116106  }
    117107}
     
    121111// +-----------------------------------------------------------------------+
    122112
    123 if (isset($_POST['addtypetag']) and (empty($_POST['typetag_name']) or empty($_POST['typetag_color'])))
     113if ( isset($_POST['addtypetag']) and (empty($_POST['typetag_name']) or empty($_POST['typetag_color'])) )
    124114{
    125115  $template->assign('typetag', array(
    126     'NAME' => isset($_POST['typetag_name']) ? $_POST['typetag_name'] : '',
    127     'COLOR' => isset($_POST['typetag_color']) ? $_POST['typetag_color'] : '',
     116    'NAME' => $_POST['typetag_name'],
     117    'COLOR' => $_POST['typetag_color'],
    128118  ));
    129119 
    130   $page['errors'][] = l10n('typetag_error');
     120  array_push($page['errors'], l10n('typetag_error'));
    131121}
    132122else if (isset($_POST['addtypetag']))
     
    136126
    137127  // does the tag already exists?
    138   $query = "
    139     SELECT id
    140     FROM `". typetags_TABLE ."`
    141     WHERE name = '". $typetag_name ."';
    142   ";
    143   $existing_tags = array_from_query($query, 'id');
    144 
    145   if (count($existing_tags) == 0)
    146   {
    147     pwg_query("
    148       INSERT INTO `". typetags_TABLE ."`(
    149         `name`,
    150         `color`
    151       )
    152       VALUES(
    153         '". $typetag_name ."',
    154         '". $typetag_color ."'
    155       );
    156     ");
    157 
    158     $page['infos'][] = l10n('typetag_saved');
     128  $query = '
     129SELECT id
     130  FROM '.typetags_TABLE.'
     131  WHERE name = "'.$_POST['typetag_name'].'"
     132';
     133
     134  if ( pwg_db_num_rows(pwg_query($query)) )
     135  {
     136    $template->assign('typetag', array(
     137      'NAME' => $_POST['typetag_name'],
     138      'COLOR' => $_POST['typetag_color'],
     139    ));
     140   
     141    array_push($page['errors'], l10n('typetag_already_exists'));
    159142  }
    160143  else
    161144  {
    162     $template->assign('typetag', array(
    163       'NAME' => $typetag_name,
    164       'COLOR' => $typetag_color,
    165     ));
    166    
    167     $page['errors'][] = l10n('typetag_already_exists');
     145    $query = '
     146INSERT INTO '.typetags_TABLE.'(
     147    name,
     148    color
     149  )
     150  VALUES(
     151    "'.$_POST['typetag_name'].'",
     152    "'.$_POST['typetag_color'].'"
     153  )
     154;';
     155    pwg_query($query);
     156
     157    array_push($page['infos'], l10n('typetag_saved'));
    168158  }
    169159}
     
    175165if (isset($_POST['delete_all_assoc']))
    176166{
    177   pwg_query("UPDATE `". TAGS_TABLE ."` SET id_typetags = NULL;");
    178   $page['infos'][] = l10n('All associations have been removed');
    179 
     167  pwg_query('UPDATE '.TAGS_TABLE.' SET id_typetags = NULL;');
     168  array_push($page['infos'], l10n('All associations have been removed'));
    180169}
    181170else if (isset($_POST['associations']))
    182171{
    183     // beautify the parameters array
    184     $string = preg_replace('#[;]$#', '', $_POST['associations']);
    185     $associations = array();
    186     $a = explode(';', $string);
    187    
    188     foreach ($a as $s)
    189     {
    190        $v = explode(':', $s);
    191        $associations[ltrim($v[0],'t-')] = ltrim($v[1],'tt-');
    192     }
    193 
    194     // save associations
    195     foreach ($associations AS $tag => $typetag)
    196     {
    197       pwg_query("
    198         UPDATE `". TAGS_TABLE ."`
    199         SET id_typetags = ". $typetag ."
    200         WHERE id = ". $tag .";
    201       ");
    202     }
    203    
    204     $page['infos'][] = l10n('typetags_associated');
    205 }
    206 
     172  // beautify the parameters array
     173  $string = preg_replace('#[;]$#', null, $_POST['associations']);
     174  $associations = array();
     175  $a = explode(';', $string);
     176 
     177  foreach ($a as $s)
     178  {
     179    $v = explode(':', $s);
     180    $associations[ltrim($v[0],'t-')] = ltrim($v[1],'tt-');
     181  }
     182
     183  // save associations
     184  $updates = array();
     185  foreach ($associations as $tag => $typetag)
     186  {
     187    array_push($updates, array(
     188      'id' => $tag,
     189      'id_typetags' => $typetag,
     190      ));
     191  }
     192 
     193  mass_updates(
     194    TAGS_TABLE,
     195    array('primary' => array('id'), 'update' => array('id_typetags')),
     196    $updates
     197    );
     198 
     199  array_push($page['infos'], l10n('typetags_associated'));
     200}
     201
     202// +-----------------------------------------------------------------------+
     203// |                          Configuration                                |
     204// +-----------------------------------------------------------------------+
     205if (isset($_POST['save_config']))
     206{
     207  $conf['TypeTags'] = array(
     208    'show_all' => $_POST['show_all'] == 'true',
     209    );
     210   
     211  conf_update_param('TypeTags', serialize($conf['TypeTags']));
     212}
     213
     214$template->assign('SHOW_ALL', $conf['TypeTags']['show_all']);
    207215
    208216// +-----------------------------------------------------------------------+
     
    212220$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin/typetags_admin.tpl'));
    213221
    214 // Récupère tous les tags
    215 $all_tags = pwg_query("
    216   SELECT
    217     t.id as tagid,
    218     t.name as tagname,
    219     tt.id as typetagid,
    220     tt.name as typetagname
    221   FROM `". TAGS_TABLE ."` as t
    222   LEFT JOIN `". typetags_TABLE ."` as tt
    223   ON  t.id_typetags = tt.id
    224   ORDER BY t.name ASC;
    225 ");
    226 
    227 while ($row = pwg_db_fetch_assoc($all_tags)) {
    228   if ($row['typetagname'] == null) $row['typetagid'] = 'NULL';
    229   $row['tagname'] = trigger_event('render_tag_name', $row['tagname']);
     222// get all tags
     223$query = '
     224SELECT
     225    id as tagid,
     226    name as tagname,
     227    id_typetags as typetagid
     228  FROM '.TAGS_TABLE.'
     229  ORDER BY name ASC
     230;';
     231$all_tags = pwg_query($query);
     232
     233while ($row = pwg_db_fetch_assoc($all_tags))
     234{
     235  if (!$row['typetagid']) $row['typetagid'] = 'NULL';
     236  $row['tagname'] = strip_tags(trigger_event('render_tag_name', $row['tagname']));
    230237  $template->append('typetags_association', $row);
    231238}
    232239
    233 // Récupère tous les typetags
    234 $all_typetags = pwg_query("SELECT * FROM `". typetags_TABLE ."` ORDER BY `name`;");
     240// get all typetags
     241$query = 'SELECT * FROM '.typetags_TABLE.' ORDER BY name;';
     242$all_typetags = pwg_query($query);
    235243
    236244while ($row = mysql_fetch_assoc($all_typetags))
     
    243251}
    244252
    245 // formualire d'édition
    246 if (isset($_GET['edittypetag'])) {
     253// edit form
     254if (isset($_GET['edittypetag']))
     255{
    247256  $edited_typetag['id'] = $_GET['edittypetag'];
    248257}
     
    251260{
    252261  $template->assign('edited_typetag', $edited_typetag['id']);
    253 
    254   $tag = pwg_query("
    255     SELECT
    256       id,
    257       name,
    258       color
    259     FROM `". typetags_TABLE ."`
    260     WHERE id = ".$edited_typetag['id'].";
    261   ");
    262   $row = pwg_db_fetch_assoc($tag);
     262 
     263$query = '
     264SELECT
     265    id,
     266    name,
     267    color
     268  FROM '.typetags_TABLE.'
     269  WHERE id = '.$edited_typetag['id'].'
     270;';
     271  $row = pwg_db_fetch_assoc(pwg_query($query));
    263272
    264273  $template->assign('typetag', array(
  • extensions/typetags/admin/typetags_admin.tpl

    r10987 r15149  
    55{combine_css path=$ROOT_URL|@cat:"plugins/typetags/admin/typetags_style.css"}
    66
    7 {footer_script}
    8 {literal}
    9   $(document).ready(function(){
    10     // colorpicker
    11     $('#colorpicker').farbtastic('#hexval');
    12 
    13     // déplace chaque élément dans la bonne case
    14     jQuery('ul#tt-NULL li').each(function() {
    15       var $target = jQuery('ul#' + jQuery(this).attr('title'));
    16       jQuery(this).appendTo($target).css('float', 'left');
     7{footer_script}{literal}
     8// set all containers the same size
     9function equilibrate() {
     10  var h=0;
     11  jQuery("#associations ul")
     12    .css('height', 'auto')
     13    .each(function() {
     14      h = Math.max(h, jQuery(this).height());
     15    })
     16    .promise().done(function() {
     17      jQuery("#associations ul").css({'height': h+'px'});
    1718    });
    1819   
    19     // initialise les déplacement
    20     jQuery("li").draggable({
    21       revert: "invalid",
    22       helper: "clone",
    23       cursor: "move"
     20  //jQuery("#tt-NULL").css('height', 'auto');
     21}
     22
     23// generate tag:typetag couples before submit the form
     24function save_datas(form) {
     25  var out = '';
     26 
     27  jQuery(".tt-container").each(function() {
     28    var section = jQuery(this).attr('id');
     29    jQuery("> li", this).each(function() {
     30      out += jQuery(this).attr('id') + ':' + section + ';';
    2431    });
     32  });
     33 
     34  jQuery('#assoc-input').val(out);
     35  submit(form);
     36}
    2537
    26     // initialise le dépôt
    27     jQuery('.tt-container').droppable({
    28       accept: "li",
    29       hoverClass: "active",
    30       drop: function(event, ui) {
    31         var $gallery = this;
    32         ui.draggable.fadeOut(function() {
    33           jQuery(this).appendTo($gallery).fadeIn();
    34           equilibrate(); // on rééquilibre les colonnes à chaque déplacement
    35         });     
    36       }
    37     });
    38    
    39     // équilibrage des colonnes
    40     equilibrate();
    41   });
    42      
    43   function equilibrate() {
    44     jQuery("#associations").each(function(){
    45       var h=0;
    46       jQuery("> ul", this).css('height', 'auto')
    47         .each(function(){ h=Math.max(h,jQuery(this).height()); })
    48         .css({'height': h+'px'});
    49     });
     38// colorpicker
     39jQuery('#colorpicker').farbtastic('#hexval');
     40
     41// move each tag in it's typetag container
     42jQuery('ul#tt-NULL li').each(function() {
     43  var $target = jQuery('ul#' + jQuery(this).attr('data'));
     44  jQuery(this).appendTo($target).css('float', 'left');
     45  if ($($target).attr('id') == 'tt-NULL') jQuery(this).css({'display':'inline-block','float':'none'});
     46});
     47equilibrate();
     48
     49// init drag
     50jQuery("li").draggable({
     51  revert: "invalid",
     52  helper: "clone",
     53  cursor: "move"
     54});
     55
     56// init drop
     57jQuery('.tt-container').droppable({
     58  accept: "li",
     59  hoverClass: "active",
     60  drop: function(event, ui) {
     61    var $gallery = this;
     62    ui.draggable.fadeOut(function() {
     63      jQuery(this).appendTo($gallery).css('float', 'left').css('display','').fadeIn();
     64      if ($($gallery).attr('id') == 'tt-NULL') jQuery(this).css({'display':'inline-block','float':'none'});
     65      equilibrate();
     66    });     
    5067  }
    51  
    52   // génération des couples tag:typetag avant de valider le formulaire
    53   function save_datas(form) {
    54     var out = '';
    55    
    56     jQuery(".tt-container").each(function(){
    57       var section = jQuery(this).attr('id');
    58       jQuery("> li", this).each(function(){
    59         out += jQuery(this).attr('id') + ':' + section + ';';
    60       });
    61     });
    62    
    63     jQuery('#assoc-input').val(out);
    64     submit(form);
    65   }
    66 {/literal}
    67 {/footer_script}
     68});
     69{/literal}{/footer_script}
    6870
    6971<div class="titrePage">
     
    7274
    7375<form action="{$typetags_ADMIN}" method="post" name="form">
     76<fieldset>
     77  <legend>{'Configuration'|@translate}</legend>
     78  <b>{'Display colored tags'|@translate}</b>
     79  <label><input type="radio" name="show_all" value="false" {if not $SHOW_ALL}checked="checked"{/if}> {'Only on tags page'|@translate}</label>
     80  <label><input type="radio" name="show_all" value="true" {if $SHOW_ALL}checked="checked"{/if}> {'Everywhere'|@translate}</label>
     81  <p><input class="submit" type="submit" name="save_config" value="{'Submit'|@translate}"></p>
     82</fieldset>
     83</form>
     84 
     85<form action="{$typetags_ADMIN}" method="post" name="form">
    7486  <fieldset>
    7587  {if isset($edited_typetag)}
    7688    <legend>{'Edit typetag'|@translate}</legend>
    77     <input type="hidden" name="edited_typetag" value="{$edited_typetag}" />
    7889    <div class="edit-container">
    7990      <div id="colorpicker" style="float:right;"></div>
    8091      <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>
    8192      <p>&nbsp;</p>
    82       <p>{'New name'|@translate} : <input type="text" size="18" name="typetag_name" value="{$typetag.NAME}"/></p>
    83       <p>{'New color'|@translate} : <input type="text" id="hexval" name="typetag_color" size="7" maxlength="7" value="{$typetag.COLOR}"/></p>
     93      <p>{'New name'|@translate} : <input type="text" size="18" name="typetag_name" value="{$typetag.NAME}"></p>
     94      <p>{'New color'|@translate} : <input type="text" id="hexval" name="typetag_color" size="7" maxlength="7" value="{$typetag.COLOR}"></p>
    8495      <p>&nbsp;</p>
    8596      <p>
    86         <input class="submit" type="submit" name="edittypetag" value="{'Modify'|@translate}"/>
    87         <input class="submit" type="submit" name="cancel" value="{'Reset'|@translate}"/>
     97        <input type="hidden" name="edited_typetag" value="{$edited_typetag}">
     98        <input class="submit" type="submit" name="edittypetag" value="{'Modify'|@translate}">
     99        <input class="submit" type="submit" name="cancel" value="{'Reset'|@translate}">
    88100      </p>
    89101    </div>
     
    93105      <div id="colorpicker" style="float:right;"></div>
    94106      <p>&nbsp;</p>
    95       <p>{'New TypeTag'|@translate} : <input type="text" size="18" name="typetag_name" value="{if isset($typetag.NAME)}{$typetag.NAME}{/if}"/></p>
    96       <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>
     107      <p>{'New TypeTag'|@translate} : <input type="text" size="18" name="typetag_name" value="{if isset($typetag.NAME)}{$typetag.NAME}{/if}"></p>
     108      <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>
    97109      <p>&nbsp;</p>
    98110      <p>
    99         <input class="submit" type="submit" name="addtypetag" value="{'Create a Typetag'|@translate}"/>
     111        <input class="submit" type="submit" name="addtypetag" value="{'Create a Typetag'|@translate}">
    100112      </p>
    101113    </div>
     
    104116</form>
    105117
    106   {if !empty($typetags_selection)}
     118{if !empty($typetags_selection)}
     119<form action="{$typetags_ADMIN}" method="post" name="form" onsubmit="save_datas(this);">
    107120  <fieldset>
    108     <legend>{'TypeTag selection'|@translate}</legend>
    109     <ul class="tagSelection">
    110       {foreach from=$typetags_selection item=typetag}
    111       <li>
    112         <input type="text" readonly="readonly" style="background-color:{$typetag.color};color:{$typetag.color_text};margin:5px 0;" value="{$typetag.name}">
    113         <a href="{$typetag.u_edit}" title="{'edit'|@translate}"><img src="{$themeconf.icon_dir}/edit.png" class="button" alt="{'edit'|@translate}"/></a>
    114         <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>
    115       </li>
    116       {/foreach}
    117     </ul>
    118   </fieldset>
    119   {/if}
    120 
    121 <form action="{$typetags_ADMIN}" method="post" name="form" onsubmit="save_datas(this);">
    122   {if !empty($typetags_association) and !empty($typetags_selection)}
    123   <fieldset>
    124     <legend>{'TypeTag association'|@translate}</legend>
     121    <legend>{'Edit and associate TypeTags'|@translate}</legend>
    125122   
    126123    <ul id="tt-NULL" class="tt-container NULL">
    127       <h5>Non associés</h5>
     124      <h5>{'Not associated'|@translate}</h5>
    128125      {foreach from=$typetags_association item=tag}
    129       <li id="t-{$tag.tagid}" title="tt-{$tag.typetagid}">
     126      <li id="t-{$tag.tagid}" data="tt-{$tag.typetagid}">
    130127        {$tag.tagname}
    131128      </li>
     
    136133    {foreach from=$typetags_selection item=typetag}
    137134      <ul id="tt-{$typetag.id}" class="tt-container" style="box-shadow:inset 0 0 5px {$typetag.color};">
     135        <span class="buttons">
     136          <a href="{$typetag.u_edit}" title="{'edit'|@translate}"><img src="{$themeconf.icon_dir}/edit.png" class="button" alt="{'edit'|@translate}"></a>
     137          <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>
     138        </span>
    138139        <h5 style="background-color:{$typetag.color};color:{$typetag.color_text};">{$typetag.name}</h5>
    139140      </ul>
     
    141142    </div>
    142143   
    143     <p style="clear:both;">
    144       <input type="hidden" name="associations" id="assoc-input"/>
    145       <input class="submit" type="submit" name="associate" value="{'Validate'|@translate}"/>
    146       <input class="submit" type="submit" name="delete_all_assoc" value="{'Delete all associations'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');"/>
     144    <div style="clear:both;"></div>
     145    <p style="margin-top:20px;">
     146      <input type="hidden" name="associations" id="assoc-input">
     147      <input class="submit" type="submit" name="associate" value="{'Validate'|@translate}">
     148      <input class="submit" type="submit" name="delete_all_assoc" value="{'Delete all associations'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');">
    147149    </p>
    148150  </fieldset>
    149   {/if}
    150151</form>
     152{/if}
  • extensions/typetags/admin/typetags_style.css

    r10987 r15149  
    1313.tt-container {
    1414  float:left;
    15   width:150px;
    16   min-height:50px;
     15  width:250px;
     16  min-height:40px;
    1717  height:auto;
    1818  margin:5px !important;
     
    2525  display:inline;
    2626  float:none;
    27   padding:2px 8px;
    28   margin:5px;
     27  padding:2px 5px;
     28  margin:3px;
     29  font-size:0.85em;
    2930  background-color:#ddd;
    3031  box-shadow:1px 1px 0px #fff;
     
    3738}
    3839.tt-container h5 {
    39   margin:0 -5px;
     40  margin:0 -5px 5px -5px;
    4041  border-radius:5px 5px 0 0;
    4142  padding:2px 0;
     
    5051
    5152.tt-container.NULL {
    52   width:98%;
     53  float:none;
     54  width:auto;
    5355  box-shadow:inset 0 0 5px #bbb;
    5456  padding-bottom:10px;
     
    5860  font-weight:bold;
    5961}
     62
     63.buttons {
     64  float:right;
     65  margin-left:-37px;
     66  margin-top:2px;
     67}
  • extensions/typetags/language/cs_CZ/plugin.lang.php

    r14334 r15149  
    3232$lang['Edited TypeTag'] = 'TypeTag změněn';
    3333$lang['New TypeTag'] = 'Název TypeTagu';
    34 $lang['TypeTag association'] = 'Přiřadit - zrušit přiřazení TypeTagů';
    35 $lang['TypeTag selection'] = 'Změnit - smazat TypeTag';
    3634$lang['typetag_already_exists'] = 'Tento TypeTag už existuje';
    3735$lang['typetag_saved'] = 'TypeTag uložen';
  • extensions/typetags/language/de_DE/plugin.lang.php

    r9863 r15149  
    44$lang['Create a Typetag'] = 'Einen TypeTag erstellen';
    55$lang['Edit typetag'] = 'TypeTag bearbeiten';
    6 $lang['TypeTag selection'] = 'TypeTags bearbeiten - löschen';
    7 $lang['TypeTag association'] = 'TypeTags assoziieren - dissoziieren';
    86
    97/* fields */
  • extensions/typetags/language/en_UK/plugin.lang.php

    r9863 r15149  
    44$lang['Create a Typetag'] = 'Create a TypeTag';
    55$lang['Edit typetag'] = 'Edit TypeTag';
    6 $lang['TypeTag selection'] = 'Edit - Delete TypeTags';
    7 $lang['TypeTag association'] = 'Associate - Dissociate TypeTags';
     6$lang['Edit and associate TypeTags'] = 'Edit and associate TypeTags';
    87
    98/* fields */
     
    1312$lang['New name'] = 'New name';
    1413$lang['Color TypeTag'] = 'TypeTag color';
     14$lang['Not associated'] = 'Not associated';
     15$lang['Display colored tags'] = 'Display colored tags';
     16$lang['Only on tags page'] = 'Only on tags page';
     17$lang['Everywhere'] = 'Everywhere';
    1518
    1619/* buttons */
  • extensions/typetags/language/es_ES/plugin.lang.php

    r9863 r15149  
    44$lang['Create a Typetag'] = 'Crear TypeTag';
    55$lang['Edit typetag'] = 'Editar TypeTag';
    6 $lang['TypeTag selection'] = 'Editar - Suprimir TypeTags';
    7 $lang['TypeTag association'] = 'Asociar - Disociar TypeTags';
    86
    97/* fields */
  • extensions/typetags/language/fr_FR/plugin.lang.php

    r9863 r15149  
    44$lang['Create a Typetag'] = 'Créer un TypeTag';
    55$lang['Edit typetag'] = 'Editer le TypeTag';
    6 $lang['TypeTag selection'] = 'Editer - Supprimer des TypeTags';
    7 $lang['TypeTag association'] = 'Associer - Dissocier des TypeTags';
     6$lang['Edit and associate TypeTags'] = 'Editer et associer les TypeTags';
    87
    98/* fields */
     
    1312$lang['New name'] = 'Nouveau nom';
    1413$lang['Color TypeTag'] = 'Couleur du TypeTag';
     14$lang['Not associated'] = 'Non associés';
     15$lang['Display colored tags'] = 'Afficher les tags colorés';
     16$lang['Only on tags page'] = 'Seulement sur la page des tags';
     17$lang['Everywhere'] = 'Partout';
    1518
    1619/* buttons */
  • extensions/typetags/language/it_IT/plugin.lang.php

    r13946 r15149  
    44$lang['Create a Typetag'] = 'Creare un TypeTag';
    55$lang['Edit typetag'] = 'Modificare i TypeTag';
    6 $lang['TypeTag selection'] = 'Modificare - Cancellare i TypeTags';
    7 $lang['TypeTag association'] = 'Associare - Dissociare i TypeTags';
    86
    97/* fields */
  • extensions/typetags/language/lv_LV/plugin.lang.php

    r9863 r15149  
    44$lang['Create a Typetag'] = 'Izveidot TypeTag';
    55$lang['Edit typetag'] = 'Rediģēt TypeTag';
    6 $lang['TypeTag selection'] = 'Rediģēt - Dzēst TypeTags';
    7 $lang['TypeTag association'] = 'Sasaistīt - Atsaistīt TypeTags';
    86
    97/* fields */
  • extensions/typetags/language/nl_NL/plugin.lang.php

    r14812 r15149  
    3131$lang['New color'] = 'Nieuwe kleur';
    3232$lang['New name'] = 'Nieuwe naam';
    33 $lang['TypeTag association'] = 'Toekennen - Verwijderen van TypeTags';
    34 $lang['TypeTag selection'] = 'Wijzig - Verwijder TypeTags';
    3533$lang['typetag_already_exists'] = 'Deze TypeTag bestaat al';
    3634$lang['typetag_error'] = 'Je moet alle velden invullen (naam en kleur)';
  • extensions/typetags/language/no_NO/plugin.lang.php

    r9863 r15149  
    44$lang['Create a Typetag'] = 'Lag en TypeTag';
    55$lang['Edit typetag'] = 'Rediger TypeTag';
    6 $lang['TypeTag selection'] = 'Rediger - Slett TypeTags';
    7 $lang['TypeTag association'] = 'Assosier - Dissossier TypeTags';
    86
    97/* fields */
  • extensions/typetags/language/pl_PL/plugin.lang.php

    r13780 r15149  
    3131$lang['New name'] = 'Nowa nazwa';
    3232$lang['New TypeTag'] = 'Nazwa TypeTag';
    33 $lang['TypeTag association'] = 'Powiązania - usuń powiązania TypeTag';
    34 $lang['TypeTag selection'] = 'Edycja - Usuwanie TypeTag';
    3533$lang['typetags_associated'] = 'Powiązano TypeTag';
    3634$lang['typetag_already_exists'] = 'Ten TypeTag już istnieje';
  • extensions/typetags/language/ru_RU/plugin.lang.php

    r14439 r15149  
    3131$lang['New color'] = 'Новый цвет';
    3232$lang['New name'] = 'Новое название';
    33 $lang['TypeTag association'] = 'Связать - отделить типы тегов';
    34 $lang['TypeTag selection'] = 'Редактировать - Удалить типы тегов';
    3533$lang['typetag_already_exists'] = 'Этот тип тегов уже есть';
    3634$lang['typetag_error'] = 'Нужно заполнить все поля (название и цвет)';
  • extensions/typetags/language/sk_SK/plugin.lang.php

    r13934 r15149  
    44$lang['Create a Typetag'] = 'Vytvoriť kľúčové slovo';
    55$lang['Edit typetag'] = 'Upraviť kľúčového slová';
    6 $lang['TypeTag selection'] = 'Upraviť - vymazať kľúčového slová';
    7 $lang['TypeTag association'] = 'Spojené - Rozdelené kľúčového slová';
    86
    97/* fields */
  • extensions/typetags/language/uk_UA/plugin.lang.php

    r13794 r15149  
    3131$lang['New name'] = 'Нове ім\'я';
    3232$lang['New TypeTag'] = 'Ім\'я TypeTag';
    33 $lang['TypeTag association'] = 'Асоціювати - Дисоціювати TypeTags';
    34 $lang['TypeTag selection'] = 'Редагування - Видалити TypeTags';
    3533$lang['typetags_associated'] = 'TypeTags, пов\'язані';
    3634$lang['typetag_already_exists'] = 'Це TypeTag вже існує';
  • extensions/typetags/main.inc.php

    r10987 r15149  
    1010if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    1111
    12 global $prefixeTable ;
     12global $prefixeTable, $conf;
    1313
    14 define('typetags_DIR' , basename(dirname(__FILE__)));
    15 define('typetags_PATH' , PHPWG_PLUGINS_PATH . typetags_DIR . '/');
     14define('typetags_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
    1615define('typetags_TABLE' , $prefixeTable . 'typetags');
    17 define('typetags_ADMIN', get_root_url().'admin.php?page=plugin-' . typetags_DIR);
     16define('typetags_ADMIN', get_root_url().'admin.php?page=plugin-' . basename(dirname(__FILE__)));
     17
     18
     19include(typetags_PATH . 'typetags.php');
     20$conf['TypeTags'] = unserialize($conf['TypeTags']);
     21
     22// tags on picture page
     23/*if (script_basename() == 'picture')
     24{
     25  add_event_handler('loc_end_picture', 'typetags_picture');
     26}*/
     27
     28// tags everywhere
     29if ($conf['TypeTags']['show_all'])
     30{
     31  add_event_handler('render_tag_name', 'typetags_render', 0);
     32}
     33// tags on tags page
     34else if (script_basename() == 'tags')
     35{
     36  add_event_handler('loc_begin_page_header', 'typetags_tags');
     37}
     38
     39
     40add_event_handler('get_admin_plugin_menu_links', 'typetags_admin_menu');
    1841
    1942function typetags_admin_menu($menu)
     
    2649}
    2750
    28 function typetags()
    29 {
    30   include(typetags_PATH . 'typetags.php');
    31 }
    32 
    33 if (script_basename() == 'tags')
    34 {
    35   add_event_handler('loc_begin_page_header', 'typetags', 60);
    36 }
    37 
    38 add_event_handler('get_admin_plugin_menu_links', 'typetags_admin_menu');
    39 
    4051?>
  • extensions/typetags/maintain.inc.php

    r10987 r15149  
    1010  if (!in_array('id_typetags', $result))
    1111  {
    12     pwg_query('ALTER TABLE '.TAGS_TABLE.' ADD COLUMN `id_typetags` SMALLINT(5)');
     12    pwg_query('ALTER TABLE '.TAGS_TABLE.' ADD COLUMN `id_typetags` SMALLINT(5);');
    1313  }
    1414
     
    1616  if (!mysql_fetch_row($result))
    1717  {
    18     $q = 'CREATE TABLE '. $prefixeTable .'typetags(
    19       id smallint(5) unsigned NOT NULL auto_increment,
    20       name VARCHAR(255) NOT NULL,
    21       color VARCHAR(255) NOT NULL,
    22       PRIMARY KEY  (id));';
    23     pwg_query($q);
     18    $query = '
     19CREATE TABLE `'. $prefixeTable .'typetags` (
     20  `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
     21  `name` varchar(255) NOT NULL,
     22  `color` varchar(255) NOT NULL,
     23  PRIMARY KEY (`id`)
     24) DEFAULT CHARSET=utf8
     25;';
     26    pwg_query($query);
     27  }
     28 
     29  conf_update_param('TypeTags', serialize(array('show_all'=>true)));
     30}
     31
     32function plugin_activate()
     33{
     34  global $conf;
     35 
     36  if (!isset($conf['TypeTags']))
     37  {
     38    conf_update_param('TypeTags', serialize(array('show_all'=>true)));
    2439  }
    2540}
     
    2944  global $prefixeTable;
    3045
    31   $q = ' ALTER TABLE '.TAGS_TABLE.' DROP COLUMN `id_typetags`';
    32   pwg_query( $q );
    33 
    34   $q = ' DROP TABLE '. $prefixeTable .'typetags;';
    35   pwg_query($q);
     46  pwg_query('ALTER TABLE '.TAGS_TABLE.' DROP COLUMN `id_typetags`');
     47  pwg_query('DROP TABLE '. $prefixeTable .'typetags;');
     48  pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param = "TypeTags" LIMIT 1;');
    3649}
    3750
  • extensions/typetags/typetags.php

    r3609 r15149  
    11<?php
    22
    3 global $page, $template;
     3/**
     4 * triggered by 'render_tag_name'
     5 */
     6function typetags_render($tag)
     7{
     8  global $pwg_loaded_plugins;
     9 
     10  $query = '
     11SELECT color
     12  FROM '.typetags_TABLE.' AS tt
     13    INNER JOIN '.TAGS_TABLE.' AS t
     14      ON t.id_typetags = tt.id
     15  WHERE t.name = "'.mysql_real_escape_string($tag).'"
     16;';;
     17  list($color) = pwg_db_fetch_row(pwg_query($query));
     18 
     19  if ($color === null)
     20  {
     21    return $tag;
     22  }
     23  elseif (isset($pwg_loaded_plugins['ExtendedDescription']))
     24  {
     25    return "[lang=all]<span style='color:".$color.";'>[/lang]".$tag."[lang=all]</span>[/lang]";
     26  }
     27  else
     28  {
     29    return "<span style='color:".$color.";'>".$tag."</span>";
     30  }
     31}
    432
    5 $query = '
    6 SELECT  t.id , tt.color
    7 FROM ' . typetags_TABLE . ' AS tt
    8 INNER JOIN ' . TAGS_TABLE . ' AS t
    9 ON  t.id_typetags = tt.id
    10 WHERE  t.id_typetags IS NOT NULL ;';
    11 
    12 $result = pwg_query($query);
    13 $tagsColor = array();
    14 while ($row = mysql_fetch_assoc($result))
     33/**
     34 * colors tags on picture page
     35 */
     36/*function typetags_picture()
    1537{
    16   $tagsColor[$row['id']] = $row['color'];
    17 }
    18 $display = $template->get_template_vars('display_mode');
    19 
    20 if ($display == 'letters')
    21 {
    22   $letters = $template->get_template_vars('letters');
    23   if (empty($letters)) return;
    24   $template->clear_assign('letters');
    25 
    26   foreach ($letters as $k1 => $letter)
    27   {
    28     foreach ($letter['tags'] as $k2 => $tag)
    29     {
    30       if (isset($tagsColor[$tag['id']]))
    31       {
    32         $letters[$k1]['tags'][$k2]['URL'] .= '" style="color:' . $tagsColor[$tag['id']];
    33       }
    34     }
    35   }
    36   $template->assign('letters', $letters);
    37 }
    38 elseif ($display == 'cloud')
    39 {
    40   $tags = $template->get_template_vars('tags');
     38  global $template;
     39   
     40  $tags = $template->get_template_vars('related_tags');
    4141  if (empty($tags)) return;
    42   $template->clear_assign('tags');
     42 
     43  $query = '
     44SELECT
     45    t.id ,
     46    tt.color
     47  FROM '.typetags_TABLE.' AS tt
     48    INNER JOIN '.TAGS_TABLE.' AS t
     49      ON t.id_typetags = tt.id
     50  WHERE t.id_typetags IS NOT NULL
     51;';
     52  $tagsColor = simple_hash_from_query($query, 'id', 'color');
     53  if (empty($tagsColor)) return;
    4354
    4455  foreach ($tags as $key => $tag)
    4556  {
    46     if (isset($tagsColor[$tag['id']]))
     57    if (isset($tagsColor[ $tag['id'] ]))
    4758    {
    48       $tags[$key]['URL'] .= '" style="color:' . $tagsColor[$tag['id']];
     59      $tags[$key]['URL'].= '" style="color:'.$tagsColor[ $tag['id'] ].';';
    4960    }
    5061  }
    51   $template->assign('tags', $tags);
    52 }
    53 elseif ($display == 'cumulus')
     62 
     63  $template->clear_assign('related_tags');
     64  $template->assign('related_tags', $tags);
     65}*/
     66
     67/**
     68 * colors tags on tags page
     69 */
     70function typetags_tags()
    5471{
    55   $tags = $template->get_template_vars('tags');
    56   if (empty($tags)) return;
    57   $template->clear_assign('tags');
     72  global $template;
    5873
    59   foreach ($tags as $key => $tag)
     74  $query = '
     75SELECT
     76    t.id ,
     77    tt.color
     78  FROM '.typetags_TABLE.' AS tt
     79    INNER JOIN '.TAGS_TABLE.' AS t
     80      ON t.id_typetags = tt.id
     81  WHERE t.id_typetags IS NOT NULL
     82;';
     83  $tagsColor = simple_hash_from_query($query, 'id', 'color');
     84  if (empty($tagsColor)) return;
     85
     86  $display = $template->get_template_vars('display_mode');
     87  if ($display == 'letters')
    6088  {
    61     if (isset($tagsColor[$tag['id']]))
     89    $letters = $template->get_template_vars('letters');
     90    if (empty($letters)) return;
     91
     92    foreach ($letters as $k1 => $letter)
    6293    {
    63       $tagsColor[$tag['id']] = str_replace('#', '0x', $tagsColor[$tag['id']]);
    64       $tags[$key]['URL'] .= '\' color=\'' . $tagsColor[$tag['id']] . '\' hicolor=\'' . $tagsColor[$tag['id']];
     94      foreach ($letter['tags'] as $k2 => $tag)
     95      {
     96        if (isset($tagsColor[ $tag['id'] ]))
     97        {
     98          $letters[$k1]['tags'][$k2]['URL'].= '" style="color:'.$tagsColor[ $tag['id'] ].';';
     99        }
     100      }
    65101    }
     102   
     103    $template->clear_assign('letters');
     104    $template->assign('letters', $letters);
    66105  }
    67   $template->assign('tags', $tags);
     106  elseif ($display == 'cloud')
     107  {
     108    $tags = $template->get_template_vars('tags');
     109    if (empty($tags)) return;
     110
     111    foreach ($tags as $key => $tag)
     112    {
     113      if (isset($tagsColor[ $tag['id'] ]))
     114      {
     115        $tags[$key]['URL'].= '" style="color:'.$tagsColor[ $tag['id'] ].';';
     116      }
     117    }
     118   
     119    $template->clear_assign('tags');
     120    $template->assign('tags', $tags);
     121  }
     122  elseif ($display == 'cumulus')
     123  {
     124    $tags = $template->get_template_vars('tags');
     125    if (empty($tags)) return;
     126
     127    foreach ($tags as $key => $tag)
     128    {
     129      if (isset($tagsColor[ $tag['id'] ]))
     130      {
     131        $tagsColor[ $tag['id'] ] = str_replace('#', '0x', $tagsColor[ $tag['id'] ]);
     132        $tags[$key]['URL'].= '\' color=\''.$tagsColor[ $tag['id'] ].'\' hicolor=\''.$tagsColor[ $tag['id'] ];
     133      }
     134    }
     135   
     136    $template->clear_assign('tags');
     137    $template->assign('tags', $tags);
     138  }
    68139}
    69140
    70 // Suppression des liens soulignés
    71 $template->block_html_head('', '<style type="text/css">#fullTagCloud a, .tagLetter a { border: none; }</style>', $smarty, $repeat);
    72 
    73141?>
Note: See TracChangeset for help on using the changeset viewer.