Changeset 17766


Ignore:
Timestamp:
Sep 5, 2012, 10:49:12 PM (12 years ago)
Author:
rvelices
Message:

merge-r17765 from trunk to branch 2.4 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:
branches/2.4/admin
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/2.4/admin/batch_manager.php

    r17290 r17766  
    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
  • branches/2.4/admin/batch_manager_unit.php

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

    r17725 r17766  
    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}
     
    20962099
    20972100  $taglist = array();
     2101  $altlist = array();
    20982102  while ($row = pwg_db_fetch_assoc($result))
    20992103  {
    2100     if (!$only_user_language and preg_match_all('#\[lang=(.*?)\](.*?)\[/lang\]#is', $row['name'], $matches))
    2101     {
    2102       foreach ($matches[2] as $tag_name)
     2104    $raw_name = $row['name'];
     2105    $name = trigger_event('render_tag_name', $raw_name);
     2106
     2107    $taglist[] =  array(
     2108        'name' => $name,
     2109        'id' => '~~'.$row['id'].'~~',
     2110      );
     2111
     2112    if (!$only_user_language)
     2113    {
     2114      $alt_names = trigger_event('get_tag_alt_names', array(), $raw_name);
     2115
     2116      // TEMP 2.4
     2117      if (count($alt_names)==0 and preg_match_all('#\[lang=(.*?)\](.*?)\[/lang\]#is', $row['name'], $matches))
    21032118      {
    2104         array_push(
    2105           $taglist,
    2106           array(
    2107             'name' => trigger_event('render_tag_name', $tag_name),
     2119        foreach ($matches[2] as $alt)
     2120        {
     2121          $alt_names[] = $alt;
     2122        }
     2123      }
     2124
     2125      foreach( array_diff( array_unique($alt_names), array($name) ) as $alt)
     2126      {
     2127        $altlist[] =  array(
     2128            'name' => $alt,
    21082129            'id' => '~~'.$row['id'].'~~',
    2109             )
    21102130          );
    21112131      }
    2112 
    2113       $row['name'] = preg_replace('#\[lang=(.*?)\](.*?)\[/lang\]#is', null, $row['name']);
    2114     }
    2115 
    2116     if (strlen($row['name']) > 0)
    2117     {
    2118       array_push(
    2119         $taglist,
    2120         array(
    2121           'name' => trigger_event('render_tag_name', $row['name']),
    2122           'id' => '~~'.$row['id'].'~~',
    2123           )
    2124         );
    2125     }
    2126   }
    2127 
    2128   $cmp = create_function('$a,$b', 'return strcasecmp($a["name"], $b["name"]);');
    2129   usort($taglist, $cmp);
     2132    }
     2133  }
     2134
     2135  usort($taglist, 'tag_alpha_compare');
     2136  if (count($altlist))
     2137  {
     2138    usort($altlist, 'tag_alpha_compare');
     2139    $taglist = array_merge($taglist, $altlist);
     2140  }
    21302141
    21312142  return $taglist;
  • branches/2.4/admin/tags.php

    r12922 r17766  
    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
     
    118118    $destination_tag_id = $_POST['destination_tag'];
    119119    $tag_ids = explode(',', $_POST['merge_list']);
    120    
     120
    121121    if (is_array($tag_ids) and count($tag_ids) > 1)
    122122    {
     
    134134        $name_of_tag[ $row['id'] ] = trigger_event('render_tag_name', $row['name']);
    135135      }
    136      
     136
    137137      $tag_ids_to_delete = array_diff(
    138138        $tag_ids,
     
    189189        $tags_deleted[] = $name_of_tag[$tag_id];
    190190      }
    191      
     191
    192192      array_push(
    193193        $page['infos'],
     
    217217
    218218  delete_tags($_POST['tags']);
    219  
     219
    220220  array_push(
    221221    $page['infos'],
    222222    l10n_dec(
    223       'The following tag was deleted', 
     223      'The following tag was deleted',
    224224      'The %d following tags were deleted',
    225225      count($tag_names)).' : '.
     
    235235{
    236236  check_pwg_token();
    237  
     237
    238238  delete_orphan_tags();
    239239  $_SESSION['page_infos'] = array(l10n('Orphan tags deleted'));
     
    269269        )
    270270      );
    271    
     271
    272272    array_push(
    273273      $page['infos'],
     
    332332// +-----------------------------------------------------------------------+
    333333
     334
     335// tag counters
     336$query = '
     337SELECT tag_id, COUNT(image_id) AS counter
     338  FROM '.IMAGE_TAG_TABLE.'
     339  GROUP BY tag_id';
     340$tag_counters = simple_hash_from_query($query, 'tag_id', 'counter');
     341
     342// all tags
     343$query = '
     344SELECT *
     345  FROM '.TAGS_TABLE.'
     346;';
     347$result = pwg_query($query);
     348$all_tags = array();
     349while ($tag = pwg_db_fetch_assoc($result))
     350{
     351  $raw_name = $tag['name'];
     352  $tag['name'] = trigger_event('render_tag_name', $raw_name);
     353  $tag['counter'] = intval(@$tag_counters[ $tag['id'] ]);
     354  $tag['U_VIEW'] = make_index_url(array('tags'=>array($tag)));
     355  $tag['U_EDIT'] = 'admin.php?page=batch_manager&cat=tag-'.$tag['id'];
     356
     357  $alt_names = trigger_event('get_tag_alt_names', array(), $raw_name);
     358  $alt_names = array_diff( array_unique($alt_names), array($tag['name']) );
     359  if (count($alt_names))
     360  {
     361    $tag['alt_names'] = implode(', ', $alt_names);
     362  }
     363  $all_tags[] = $tag;
     364}
     365usort($all_tags, 'tag_alpha_compare');
     366
     367
     368
    334369$template->assign(
    335370  array(
    336     'TAG_SELECTION' => get_html_tag_selection(
    337       get_all_tags(),
    338       'tags'
    339       ),
     371    'all_tags' => $all_tags,
    340372    )
    341373  );
     
    348380    $list_name = 'MERGE_TAGS_LIST';
    349381  }
    350  
     382
    351383  $template->assign(
    352384    array(
  • branches/2.4/admin/themes/default/template/tags.tpl

    r12032 r17766  
    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}
     
    7272    <label>
    7373      {'New tag'|@translate}
    74       <input type="text" name="add_tag" size="30">
     74      <input type="text" name="add_tag" size="50">
    7575    </label>
    7676   
     
    8080  <fieldset>
    8181    <legend>{'Tag selection'|@translate}</legend>
    82    
    83     {$TAG_SELECTION}
     82{html_style}
     83.showInfo{ldelim}position:static; display:inline-block; text-indent:6px}
     84{/html_style}
     85{footer_script}{literal}
     86jQuery('.showInfo').tipTip({
     87    'delay' : 0,
     88    'fadeIn' : 200,
     89    'fadeOut' : 200,
     90    'maxWidth':'300px',
     91    'keepAlive':true,
     92    'activation':'click'
     93  });
     94{/literal}{/footer_script}
     95<ul class="tagSelection">
     96{foreach from=$all_tags item=tag}
     97        <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}
     98                <a class="showInfo" title="{$smarty.capture.showInfo|@htmlspecialchars}">i</a>
     99                <label>
     100                        <input type="checkbox" name="tags[]" value="{$tag.id}"> {$tag.name}
     101                </label>
     102        </li>
     103{/foreach}
     104</ul>
    84105
    85106    <p>
Note: See TracChangeset for help on using the changeset viewer.