Changeset 17765


Ignore:
Timestamp:
Sep 5, 2012, 10:38:30 PM (8 years ago)
Author:
rvelices
Message:

feature 2737: improve tag administration screen
show for every tag

  • the number of photos
  • link to public index page
  • link to batch manager edit

add an event for extended description multi language strings (used for autocompletion and shown in the tag admin screen) instead of hard coded in the core [lang=..

Location:
trunk/admin
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/batch_manager.php

    r17289 r17765  
    115115      );
    116116  }
     117 
     118  if (substr_compare($_GET['cat'],'tag-',0,4)==0)
     119  {
     120    $_SESSION['bulk_manager_filter']=array();
     121    $_SESSION['bulk_manager_filter']['tags'] = array(intval(substr($_GET['cat'],4)));
     122    $_SESSION['bulk_manager_filter']['tag_mode'] = 'AND';
     123  }
    117124}
    118125
  • trunk/admin/batch_manager_unit.php

    r16280 r17765  
    181181    );
    182182  $template->assign(array('navbar' => $nav_bar));
    183 
    184   // tags
    185   $all_tags = get_all_tags();
    186183
    187184  $element_ids = array();
  • trunk/admin/include/functions.php

    r17724 r17765  
    12061206    return array('error' => l10n('The name of an album must not be empty'));
    12071207  }
    1208    
     1208
    12091209  $insert = array(
    12101210    'name' => $category_name,
     
    14751475    }
    14761476
    1477     mass_inserts(
    1478       IMAGE_TAG_TABLE,
    1479       array_keys($inserts[0]),
    1480       $inserts
    1481       );
     1477    if (count($inserts))
     1478    {
     1479      mass_inserts(
     1480        IMAGE_TAG_TABLE,
     1481        array_keys($inserts[0]),
     1482        $inserts
     1483        );
     1484    }
    14821485  }
    14831486}
     
    14991502    return false;
    15001503  }
    1501  
     1504
    15021505  // get existing associations
    15031506  $query = '
     
    15101513;';
    15111514  $result = pwg_query($query);
    1512  
     1515
    15131516  $existing = array();
    15141517  while ($row = pwg_db_fetch_assoc($result))
     
    21202123
    21212124  $taglist = array();
     2125  $altlist = array();
    21222126  while ($row = pwg_db_fetch_assoc($result))
    21232127  {
    2124     if (!$only_user_language and preg_match_all('#\[lang=(.*?)\](.*?)\[/lang\]#is', $row['name'], $matches))
    2125     {
    2126       foreach ($matches[2] as $tag_name)
     2128    $raw_name = $row['name'];
     2129    $name = trigger_event('render_tag_name', $raw_name);
     2130
     2131    $taglist[] =  array(
     2132        'name' => $name,
     2133        'id' => '~~'.$row['id'].'~~',
     2134      );
     2135
     2136    if (!$only_user_language)
     2137    {
     2138      $alt_names = trigger_event('get_tag_alt_names', array(), $raw_name);
     2139
     2140      // TEMP 2.4
     2141      if (count($alt_names)==0 and preg_match_all('#\[lang=(.*?)\](.*?)\[/lang\]#is', $row['name'], $matches))
    21272142      {
    2128         array_push(
    2129           $taglist,
    2130           array(
    2131             'name' => trigger_event('render_tag_name', $tag_name),
     2143        foreach ($matches[2] as $alt)
     2144        {
     2145          $alt_names[] = $alt;
     2146        }
     2147      }
     2148
     2149      foreach( array_diff( array_unique($alt_names), array($name) ) as $alt)
     2150      {
     2151        $altlist[] =  array(
     2152            'name' => $alt,
    21322153            'id' => '~~'.$row['id'].'~~',
    2133             )
    21342154          );
    21352155      }
    2136 
    2137       $row['name'] = preg_replace('#\[lang=(.*?)\](.*?)\[/lang\]#is', null, $row['name']);
    2138     }
    2139 
    2140     if (strlen($row['name']) > 0)
    2141     {
    2142       array_push(
    2143         $taglist,
    2144         array(
    2145           'name' => trigger_event('render_tag_name', $row['name']),
    2146           'id' => '~~'.$row['id'].'~~',
    2147           )
    2148         );
    2149     }
    2150   }
    2151 
    2152   $cmp = create_function('$a,$b', 'return strcasecmp($a["name"], $b["name"]);');
    2153   usort($taglist, $cmp);
     2156    }
     2157  }
     2158
     2159  usort($taglist, 'tag_alpha_compare');
     2160  if (count($altlist))
     2161  {
     2162    usort($altlist, 'tag_alpha_compare');
     2163    $taglist = array_merge($taglist, $altlist);
     2164  }
    21542165
    21552166  return $taglist;
  • trunk/admin/tags.php

    r16526 r17765  
    4646;';
    4747  $existing_names = array_from_query($query, 'name');
    48  
     48
    4949
    5050  $current_name_of = array();
     
    5959    $current_name_of[ $row['id'] ] = $row['name'];
    6060  }
    61  
     61
    6262  $updates = array();
    6363  // we must not rename tag with an already existing name
     
    111111;';
    112112  $existing_names = array_from_query($query, 'name');
    113  
     113
    114114
    115115  $current_name_of = array();
     
    124124    $current_name_of[ $row['id'] ] = $row['name'];
    125125  }
    126  
     126
    127127  $updates = array();
    128128  // we must not rename tag with an already existing name
     
    180180            );
    181181        }
    182  
     182
    183183        if (count($inserts) > 0)
    184184        {
     
    227227    $destination_tag_id = $_POST['destination_tag'];
    228228    $tag_ids = explode(',', $_POST['merge_list']);
    229    
     229
    230230    if (is_array($tag_ids) and count($tag_ids) > 1)
    231231    {
     
    243243        $name_of_tag[ $row['id'] ] = trigger_event('render_tag_name', $row['name']);
    244244      }
    245      
     245
    246246      $tag_ids_to_delete = array_diff(
    247247        $tag_ids,
     
    298298        $tags_deleted[] = $name_of_tag[$tag_id];
    299299      }
    300      
     300
    301301      array_push(
    302302        $page['infos'],
     
    326326
    327327  delete_tags($_POST['tags']);
    328  
     328
    329329  array_push(
    330330    $page['infos'],
    331331    l10n_dec(
    332       'The following tag was deleted', 
     332      'The following tag was deleted',
    333333      'The %d following tags were deleted',
    334334      count($tag_names)).' : '.
     
    344344{
    345345  check_pwg_token();
    346  
     346
    347347  delete_orphan_tags();
    348348  $_SESSION['page_infos'] = array(l10n('Orphan tags deleted'));
     
    378378        )
    379379      );
    380    
     380
    381381    array_push(
    382382      $page['infos'],
     
    441441// +-----------------------------------------------------------------------+
    442442
     443
     444// tag counters
     445$query = '
     446SELECT tag_id, COUNT(image_id) AS counter
     447  FROM '.IMAGE_TAG_TABLE.'
     448  GROUP BY tag_id';
     449$tag_counters = simple_hash_from_query($query, 'tag_id', 'counter');
     450
     451// all tags
     452$query = '
     453SELECT *
     454  FROM '.TAGS_TABLE.'
     455;';
     456$result = pwg_query($query);
     457$all_tags = array();
     458while ($tag = pwg_db_fetch_assoc($result))
     459{
     460  $raw_name = $tag['name'];
     461  $tag['name'] = trigger_event('render_tag_name', $raw_name);
     462  $tag['counter'] = intval(@$tag_counters[ $tag['id'] ]);
     463  $tag['U_VIEW'] = make_index_url(array('tags'=>array($tag)));
     464  $tag['U_EDIT'] = 'admin.php?page=batch_manager&cat=tag-'.$tag['id'];
     465
     466  $alt_names = trigger_event('get_tag_alt_names', array(), $raw_name);
     467  $alt_names = array_diff( array_unique($alt_names), array($tag['name']) );
     468  if (count($alt_names))
     469  {
     470    $tag['alt_names'] = implode(', ', $alt_names);
     471  }
     472  $all_tags[] = $tag;
     473}
     474usort($all_tags, 'tag_alpha_compare');
     475
     476
     477
    443478$template->assign(
    444479  array(
    445     'TAG_SELECTION' => get_html_tag_selection(
    446       get_all_tags(),
    447       'tags'
    448       ),
     480    'all_tags' => $all_tags,
    449481    )
    450482  );
     
    461493    $list_name = 'MERGE_TAGS_LIST';
    462494  }
    463  
     495
    464496  $template->assign(
    465497    array(
  • trunk/admin/themes/default/template/tags.tpl

    r16526 r17765  
    4141      <tr>
    4242        <td>{$tag.NAME}</td>
    43         <td><input type="text" name="tag_name-{$tag.ID}" value="{$tag.NAME}" size="30"></td>
     43        <td><input type="text" name="tag_name-{$tag.ID}" value="{$tag.NAME}" size="50"></td>
    4444      </tr>
    4545      {/foreach}
     
    6565      <tr>
    6666        <td>{$tag.NAME}</td>
    67         <td><input type="text" name="tag_name-{$tag.ID}" value="{$tag.NAME}" size="30"></td>
     67        <td><input type="text" name="tag_name-{$tag.ID}" value="{$tag.NAME}" size="50"></td>
    6868      </tr>
    6969      {/foreach}
     
    9696    <label>
    9797      {'New tag'|@translate}
    98       <input type="text" name="add_tag" size="30">
     98      <input type="text" name="add_tag" size="50">
    9999    </label>
    100100   
     
    104104  <fieldset>
    105105    <legend>{'Tag selection'|@translate}</legend>
    106    
    107     {$TAG_SELECTION}
     106{html_style}
     107.showInfo{ldelim}position:static; display:inline-block; text-indent:6px}
     108{/html_style}
     109{footer_script}{literal}
     110jQuery('.showInfo').tipTip({
     111    'delay' : 0,
     112    'fadeIn' : 200,
     113    'fadeOut' : 200,
     114    'maxWidth':'300px',
     115    'keepAlive':true,
     116    'activation':'click'
     117  });
     118{/literal}{/footer_script}
     119<ul class="tagSelection">
     120{foreach from=$all_tags item=tag}
     121        <li>{capture name='showInfo'}<b>{$tag.name}</b><br>{$pwg->l10n_dec('%d photo', '%d photos', $tag.counter)} <a href="{$tag.U_VIEW}">{'View'|@translate}</a> <a href="{$tag.U_EDIT}">{'Edit'|@translate}</a>{if !empty($tag.alt_names)}<br>{$tag.alt_names}{/if}{/capture}
     122                <a class="showInfo" title="{$smarty.capture.showInfo|@htmlspecialchars}">i</a>
     123                <label>
     124                        <input type="checkbox" name="tags[]" value="{$tag.id}"> {$tag.name}
     125                </label>
     126        </li>
     127{/foreach}
     128</ul>
    108129
    109130    <p>
Note: See TracChangeset for help on using the changeset viewer.