1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: SmartAlbums |
---|
4 | Version: auto |
---|
5 | Description: Easily create dynamic albums with tags, date and other criteria |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=544 |
---|
7 | Author: Mistic |
---|
8 | Author URI: http://www.strangeplanet.fr |
---|
9 | */ |
---|
10 | |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
12 | global $prefixeTable; |
---|
13 | |
---|
14 | define('SMART_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); |
---|
15 | define('CATEGORY_FILTERS_TABLE', $prefixeTable . 'category_filters'); |
---|
16 | define('SMART_ADMIN', get_root_url() . 'admin.php?page=plugin-' . basename(dirname(__FILE__))); |
---|
17 | |
---|
18 | add_event_handler('invalidate_user_cache', 'smart_make_all_associations'); |
---|
19 | |
---|
20 | include_once(SMART_PATH.'include/functions.inc.php'); |
---|
21 | |
---|
22 | if (script_basename() == 'index') |
---|
23 | { |
---|
24 | add_event_handler('loc_end_section_init', 'smart_init_page_items'); |
---|
25 | include_once(SMART_PATH.'include/page_items.php'); |
---|
26 | } |
---|
27 | else if (script_basename() == 'admin') |
---|
28 | { |
---|
29 | add_event_handler('init', 'smart_init'); |
---|
30 | } |
---|
31 | |
---|
32 | function smart_init() |
---|
33 | { |
---|
34 | global $conf; |
---|
35 | |
---|
36 | load_language('plugin.lang', SMART_PATH); |
---|
37 | $conf['SmartAlbums'] = unserialize($conf['SmartAlbums']); |
---|
38 | |
---|
39 | include_once(SMART_PATH.'include/cat_list.php'); |
---|
40 | |
---|
41 | add_event_handler('loc_begin_cat_list', 'smart_cat_list'); |
---|
42 | add_event_handler('loc_begin_admin_page', 'smart_add_admin_album_tab'); |
---|
43 | add_event_handler('get_admin_plugin_menu_links', 'smart_admin_menu'); |
---|
44 | } |
---|
45 | |
---|
46 | function smart_admin_menu($menu) |
---|
47 | { |
---|
48 | array_push($menu, array( |
---|
49 | 'NAME' => 'SmartAlbums', |
---|
50 | 'URL' => SMART_ADMIN, |
---|
51 | )); |
---|
52 | return $menu; |
---|
53 | } |
---|
54 | |
---|
55 | function smart_add_admin_album_tab() |
---|
56 | { |
---|
57 | global $page, $template; |
---|
58 | if ($page['page'] != 'album') return; |
---|
59 | |
---|
60 | $template->assign('SMART_CAT_ID', $_GET['cat_id']); |
---|
61 | $template->set_prefilter('tabsheet', 'smart_add_admin_album_tab_prefilter'); |
---|
62 | } |
---|
63 | function smart_add_admin_album_tab_prefilter($content) |
---|
64 | { |
---|
65 | $search = '{/foreach}'; |
---|
66 | $add = ' |
---|
67 | <li class="{if false}selected_tab{else}normal_tab{/if}"> |
---|
68 | <a href="'.SMART_ADMIN.'-album&cat_id={$SMART_CAT_ID}"><span>SmartAlbum</span></a> |
---|
69 | </li>'; |
---|
70 | return str_replace($search, $search.$add, $content); |
---|
71 | } |
---|
72 | ?> |
---|