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

Last change on this file since 19512 was 19446, checked in by mistic100, 11 years ago
  • add regex for phot name, author
  • add dimensions filter
  • rewrite javascript algorithms
  • add auto update on timeout (default 3 days)
  • display photos count on plugin albums list
File size: 2.9 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
[19446]14define('SMART_PATH',     PHPWG_PLUGINS_PATH . 'SmartAlbums/');
[16104]15define('CATEGORY_FILTERS_TABLE', $prefixeTable . 'category_filters');
[19446]16define('SMART_ADMIN',    get_root_url() . 'admin.php?page=plugin-SmartAlbums');
17define('SMART_VERSION',  'auto');
18//define('SMART_DEBUG',    true);
[10871]19
[17716]20
[19446]21add_event_handler('init', 'smart_init');
22add_event_handler('init', 'smart_periodic_update');
[11376]23add_event_handler('invalidate_user_cache', 'smart_make_all_associations');
[16126]24
[17716]25if (defined('IN_ADMIN'))
26{
27  include_once(SMART_PATH.'include/cat_list.php');
28  add_event_handler('loc_begin_cat_list', 'smart_cat_list');
29  add_event_handler('tabsheet_before_select','smart_tab', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); 
30  add_event_handler('get_admin_plugin_menu_links', 'smart_admin_menu');
31  add_event_handler('delete_categories', 'smart_delete_categories');
32}
33
[11376]34include_once(SMART_PATH.'include/functions.inc.php');
35
[17716]36
37/**
38 * update plugin & unserialize conf & load language
39 */
[16126]40function smart_init()
41{
[17716]42  global $conf, $pwg_loaded_plugins;
[16104]43 
[17716]44  if (
[19446]45    SMART_VERSION == 'auto' or
[17716]46    $pwg_loaded_plugins['SmartAlbums']['version'] == 'auto' or
47    version_compare($pwg_loaded_plugins['SmartAlbums']['version'], SMART_VERSION, '<')
48  )
49  {
50    include_once(SMART_PATH . 'include/install.inc.php');
51    smart_albums_install();
52   
[19446]53    if ( $pwg_loaded_plugins['SmartAlbums']['version'] != 'auto' and SMART_VERSION != 'auto' )
[17716]54    {
55      $query = '
56UPDATE '. PLUGINS_TABLE .'
57SET version = "'. SMART_VERSION .'"
58WHERE id = "SmartAlbums"';
59      pwg_query($query);
60     
61      $pwg_loaded_plugins['SmartAlbums']['version'] = SMART_VERSION;
62     
63      if (defined('IN_ADMIN'))
64      {
65        $_SESSION['page_infos'][] = 'Smart Albums updated to version '. SMART_VERSION;
66      }
67    }
68  }
69 
70  if (defined('IN_ADMIN'))
71  {
72    load_language('plugin.lang', SMART_PATH);
73  }
[16104]74  $conf['SmartAlbums'] = unserialize($conf['SmartAlbums']);
[16939]75 
76  if ( script_basename() == 'index' and $conf['SmartAlbums']['smart_is_forbidden'] )
77  {
78    add_event_handler('loc_end_section_init', 'smart_init_page_items');
79    include_once(SMART_PATH.'include/page_items.php');
80  }
[10871]81}
82
[17716]83/**
84 * new tab on album properties page
85 */
[16938]86function smart_tab($sheets, $id)
87{
[17207]88  if ($id != 'album') return $sheets;
89 
90  global $category;
91 
92  if ($category['dir'] == null)
[16938]93  {
94    $sheets['smartalbum'] = array(
95      'caption' => 'SmartAlbum',
96      'url' => SMART_ADMIN.'-album&amp;cat_id='.$_GET['cat_id'],
97      );
98  }
99 
100  return $sheets;
101}
102
[17716]103
104/**
105 * admin plugins menu link
106 */
[16126]107function smart_admin_menu($menu) 
108{
109  array_push($menu, array(
110      'NAME' => 'SmartAlbums',
111      'URL' => SMART_ADMIN,
112    ));
113  return $menu;
114}
115
[10871]116?>
Note: See TracBrowser for help on using the repository browser.