source: extensions/SmartAlbums/main.inc.php @ 19183

Last change on this file since 19183 was 17821, checked in by mistic100, 12 years ago

Warning undefined function get_tag_ids() on quick count button

File size: 2.8 KB
RevLine 
[10871]1<?php
2/*
3Plugin Name: SmartAlbums
4Version: auto
[10980]5Description: Easily create dynamic albums with tags, date and other criteria
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=544
[10871]7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12global $prefixeTable;
13
[17716]14define('SMART_PATH',    PHPWG_PLUGINS_PATH . 'SmartAlbums/');
[16104]15define('CATEGORY_FILTERS_TABLE', $prefixeTable . 'category_filters');
[17716]16define('SMART_ADMIN',   get_root_url() . 'admin.php?page=plugin-SmartAlbums');
[17821]17define('SMART_VERSION', '2.0.4');
[10871]18
[17716]19
[11376]20add_event_handler('invalidate_user_cache', 'smart_make_all_associations');
[16939]21add_event_handler('init', 'smart_init');
[16126]22
[17716]23if (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]32include_once(SMART_PATH.'include/functions.inc.php');
33
[17716]34
35/**
36 * update plugin & unserialize conf & load language
37 */
[16126]38function 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 = '
53UPDATE '. PLUGINS_TABLE .'
54SET version = "'. SMART_VERSION .'"
55WHERE 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]83function 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&amp;cat_id='.$_GET['cat_id'],
94      );
95  }
96 
97  return $sheets;
98}
99
[17716]100
101/**
102 * admin plugins menu link
103 */
[16126]104function 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?>
Note: See TracBrowser for help on using the repository browser.