[10871] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: SmartAlbums |
---|
| 4 | Version: auto |
---|
[10980] | 5 | Description: Easily create dynamic albums with tags, date and other criteria |
---|
| 6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=544 |
---|
[10871] | 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 | |
---|
[17716] | 14 | define('SMART_PATH', PHPWG_PLUGINS_PATH . 'SmartAlbums/'); |
---|
[16104] | 15 | define('CATEGORY_FILTERS_TABLE', $prefixeTable . 'category_filters'); |
---|
[17716] | 16 | define('SMART_ADMIN', get_root_url() . 'admin.php?page=plugin-SmartAlbums'); |
---|
[17821] | 17 | define('SMART_VERSION', '2.0.4'); |
---|
[10871] | 18 | |
---|
[17716] | 19 | |
---|
[11376] | 20 | add_event_handler('invalidate_user_cache', 'smart_make_all_associations'); |
---|
[16939] | 21 | add_event_handler('init', 'smart_init'); |
---|
[16126] | 22 | |
---|
[17716] | 23 | if (defined('IN_ADMIN')) |
---|
| 24 | { |
---|
| 25 | include_once(SMART_PATH.'include/cat_list.php'); |
---|
| 26 | add_event_handler('loc_begin_cat_list', 'smart_cat_list'); |
---|
| 27 | add_event_handler('tabsheet_before_select','smart_tab', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
| 28 | add_event_handler('get_admin_plugin_menu_links', 'smart_admin_menu'); |
---|
| 29 | add_event_handler('delete_categories', 'smart_delete_categories'); |
---|
| 30 | } |
---|
| 31 | |
---|
[11376] | 32 | include_once(SMART_PATH.'include/functions.inc.php'); |
---|
| 33 | |
---|
[17716] | 34 | |
---|
| 35 | /** |
---|
| 36 | * update plugin & unserialize conf & load language |
---|
| 37 | */ |
---|
[16126] | 38 | function smart_init() |
---|
| 39 | { |
---|
[17716] | 40 | global $conf, $pwg_loaded_plugins; |
---|
[16104] | 41 | |
---|
[17716] | 42 | if ( |
---|
| 43 | $pwg_loaded_plugins['SmartAlbums']['version'] == 'auto' or |
---|
| 44 | version_compare($pwg_loaded_plugins['SmartAlbums']['version'], SMART_VERSION, '<') |
---|
| 45 | ) |
---|
| 46 | { |
---|
| 47 | include_once(SMART_PATH . 'include/install.inc.php'); |
---|
| 48 | smart_albums_install(); |
---|
| 49 | |
---|
| 50 | if ($pwg_loaded_plugins['SmartAlbums']['version'] != 'auto') |
---|
| 51 | { |
---|
| 52 | $query = ' |
---|
| 53 | UPDATE '. PLUGINS_TABLE .' |
---|
| 54 | SET version = "'. SMART_VERSION .'" |
---|
| 55 | WHERE id = "SmartAlbums"'; |
---|
| 56 | pwg_query($query); |
---|
| 57 | |
---|
| 58 | $pwg_loaded_plugins['SmartAlbums']['version'] = SMART_VERSION; |
---|
| 59 | |
---|
| 60 | if (defined('IN_ADMIN')) |
---|
| 61 | { |
---|
| 62 | $_SESSION['page_infos'][] = 'Smart Albums updated to version '. SMART_VERSION; |
---|
| 63 | } |
---|
| 64 | } |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | if (defined('IN_ADMIN')) |
---|
| 68 | { |
---|
| 69 | load_language('plugin.lang', SMART_PATH); |
---|
| 70 | } |
---|
[16104] | 71 | $conf['SmartAlbums'] = unserialize($conf['SmartAlbums']); |
---|
[16939] | 72 | |
---|
| 73 | if ( script_basename() == 'index' and $conf['SmartAlbums']['smart_is_forbidden'] ) |
---|
| 74 | { |
---|
| 75 | add_event_handler('loc_end_section_init', 'smart_init_page_items'); |
---|
| 76 | include_once(SMART_PATH.'include/page_items.php'); |
---|
| 77 | } |
---|
[10871] | 78 | } |
---|
| 79 | |
---|
[17716] | 80 | /** |
---|
| 81 | * new tab on album properties page |
---|
| 82 | */ |
---|
[16938] | 83 | function smart_tab($sheets, $id) |
---|
| 84 | { |
---|
[17207] | 85 | if ($id != 'album') return $sheets; |
---|
| 86 | |
---|
| 87 | global $category; |
---|
| 88 | |
---|
| 89 | if ($category['dir'] == null) |
---|
[16938] | 90 | { |
---|
| 91 | $sheets['smartalbum'] = array( |
---|
| 92 | 'caption' => 'SmartAlbum', |
---|
| 93 | 'url' => SMART_ADMIN.'-album&cat_id='.$_GET['cat_id'], |
---|
| 94 | ); |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | return $sheets; |
---|
| 98 | } |
---|
| 99 | |
---|
[17716] | 100 | |
---|
| 101 | /** |
---|
| 102 | * admin plugins menu link |
---|
| 103 | */ |
---|
[16126] | 104 | function smart_admin_menu($menu) |
---|
| 105 | { |
---|
| 106 | array_push($menu, array( |
---|
| 107 | 'NAME' => 'SmartAlbums', |
---|
| 108 | 'URL' => SMART_ADMIN, |
---|
| 109 | )); |
---|
| 110 | return $menu; |
---|
| 111 | } |
---|
| 112 | |
---|
[10871] | 113 | ?> |
---|