Changeset 26442 for extensions/SmartAlbums/include/events_admin.inc.php
- Timestamp:
- Jan 4, 2014, 4:13:08 PM (10 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
extensions/SmartAlbums/include/events_admin.inc.php
r24342 r26442 1 1 <?php 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 2 defined('SMART_PATH') or die('Hacking attempt!'); 3 4 /** 5 * new tab on album properties page 6 */ 7 function smart_tab($sheets, $id) 8 { 9 if ($id == 'album') 10 { 11 global $category; 12 13 if ($category['dir'] == null) 14 { 15 $sheets['smartalbum'] = array( 16 'caption' => 'SmartAlbum', 17 'url' => SMART_ADMIN.'-album&cat_id='.$_GET['cat_id'], 18 ); 19 } 20 } 21 22 return $sheets; 23 } 24 25 /** 26 * admin plugins menu link 27 */ 28 function smart_admin_menu($menu) 29 { 30 $menu[] = array( 31 'NAME' => 'SmartAlbums', 32 'URL' => SMART_ADMIN, 33 ); 34 return $menu; 35 } 36 3 37 /** 4 38 * Add a link into categories list to regenerate associations 5 39 */ 6 $smart_count = 0;7 8 40 function smart_cat_list() 9 41 { 10 global $template, $page, $smart_count; 42 global $template, $page; 43 44 if (!isset($smart_count)) 45 { 46 $smart_count = 0; 47 } 11 48 12 49 $self_url = get_root_url().'admin.php?page=cat_list'.(isset($_GET['parent_id']) ? '&parent_id='.$_GET['parent_id'] : null); 13 50 14 51 /* get categories with smart filters */ 15 52 $query = ' 16 SELECT DISTINCT id, name 53 SELECT DISTINCT id, name 17 54 FROM '.CATEGORIES_TABLE.' AS c 18 55 INNER JOIN '.CATEGORY_FILTERS_TABLE.' AS cf 19 56 ON c.id = cf.category_id'; 20 57 if (!isset($_GET['parent_id'])) 21 58 { … … 30 67 $query .= ' 31 68 ;'; 32 33 $smart_cats = hash_from_query($query, 'id'); 34 $smart_count = count($smart_cats); 35 69 70 $smart_cats = query2array($query, 'id'); 71 36 72 if (isset($_GET['smart_generate'])) 37 73 { … … 42 78 { 43 79 $associated_images = smart_make_associations($category['id']); 44 array_push($page['infos'], 45 sprintf(l10n('%d photos associated to album %s'),46 count($associated_images),47 '«'.trigger_event('render_category_name', $category['name'], 'admin_cat_list').'»'48 )80 81 $page['infos'][] = l10n( 82 '%d photos associated to album %s', 83 count($associated_images), 84 '«'.trigger_event('render_category_name', $category['name'], 'admin_cat_list').'»' 49 85 ); 50 86 } … … 53 89 else 54 90 { 55 $associated_images = smart_make_associations($_GET['smart_generate']); 56 array_push($page['infos'], 57 sprintf(l10n('%d photos associated to album %s'),58 count($associated_images),59 '«'.trigger_event('render_category_name', $smart_cats[ $_GET['smart_generate'] ]['name'], 'admin_cat_list').'»'60 )91 $associated_images = smart_make_associations($_GET['smart_generate']); 92 93 $page['infos'][] = l10n( 94 '%d photos associated to album %s', 95 count($associated_images), 96 '«'.trigger_event('render_category_name', $smart_cats[ $_GET['smart_generate'] ]['name'], 'admin_cat_list').'»' 61 97 ); 62 98 } 63 99 64 100 define('SMART_NOT_UPDATE', 1); 65 101 invalidate_user_cache(); 66 102 } 67 103 68 104 // create regenerate link 69 105 $tpl_cat = array(); … … 72 108 $tpl_cat[$cat] = $self_url.'&smart_generate='.$cat; 73 109 } 74 $tpl_cat['all'] = $self_url.'&smart_generate=all'; 75 110 if (count($smart_cats)) 111 { 112 $tpl_cat['all'] = $self_url.'&smart_generate=all'; 113 } 114 76 115 $template->assign(array( 77 116 'SMART_URL' => $tpl_cat, 78 117 'SMART_PATH' => SMART_PATH, 79 118 )); 80 119 81 120 $template->set_prefilter('categories', 'smart_cat_list_prefilter'); 82 121 } 83 122 84 123 85 function smart_cat_list_prefilter($content , &$smarty)124 function smart_cat_list_prefilter($content) 86 125 { 87 global $smart_count;88 89 126 $search[0] = '{if isset($category.U_MANAGE_ELEMENTS) }'; 90 127 $replacement[0] = $search[0].' … … 93 130 {/if}'; 94 131 95 if ($smart_count > 0) 96 { 97 $search[1] = '<a href="#" id="autoOrderOpen">{\'apply automatic sort order\'|@translate}</a>'; 98 $replacement[1] = $search[1].' 99 | <a href="{$SMART_URL.all}">{\'Regenerate photos list of all SmartAlbums\'|@translate}</a>'; 100 } 101 132 $search[1] = '<a href="#" id="autoOrderOpen">{\'apply automatic sort order\'|@translate}</a>'; 133 $replacement[1] = $search[1].' 134 {if isset($SMART_URL.all)}| <a href="{$SMART_URL.all}">{\'Regenerate photos list of all SmartAlbums\'|@translate}</a>{/if}'; 135 102 136 $search[2] = '{$category.NAME}</a></strong>'; 103 137 $replacement[2] = $search[2].' … … 108 142 return str_replace($search, $replacement, $content); 109 143 } 110 111 ?>
Note: See TracChangeset
for help on using the changeset viewer.