[3609] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: PWG Stuffs |
---|
[9369] | 4 | Version: auto |
---|
[3609] | 5 | Description: Insert modules on your gallery |
---|
| 6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=190 |
---|
| 7 | Author: P@t |
---|
| 8 | Author URI: http://www.gauchon.com |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 12 | |
---|
[9383] | 13 | global $prefixeTable, $conf; |
---|
[3609] | 14 | |
---|
[9449] | 15 | $conf['Stuffs'] = @unserialize($conf['PWG_Stuffs']); |
---|
| 16 | |
---|
[3609] | 17 | define('STUFFS_DIR' , basename(dirname(__FILE__))); |
---|
| 18 | define('STUFFS_PATH' , PHPWG_PLUGINS_PATH . STUFFS_DIR . '/'); |
---|
| 19 | define('STUFFS_TABLE' , $prefixeTable . 'stuffs'); |
---|
| 20 | |
---|
[9369] | 21 | // Need upgrade? |
---|
[9383] | 22 | if ($conf['Stuffs'] === false) |
---|
[9369] | 23 | include('admin/upgrade.inc.php'); |
---|
| 24 | |
---|
[3609] | 25 | function stuffs_admin_menu($menu) |
---|
| 26 | { |
---|
[9449] | 27 | global $conf; |
---|
| 28 | |
---|
[9383] | 29 | array_push($menu, array( |
---|
| 30 | 'NAME' => 'PWG Stuffs', |
---|
| 31 | 'URL' => get_admin_plugin_menu_link(STUFFS_PATH . 'admin/admin.php') |
---|
| 32 | ) |
---|
| 33 | ); |
---|
| 34 | return $menu; |
---|
[3609] | 35 | } |
---|
| 36 | |
---|
[9383] | 37 | function load_stuffs() |
---|
[3609] | 38 | { |
---|
[9383] | 39 | global $template; |
---|
[3609] | 40 | |
---|
[9410] | 41 | include(STUFFS_PATH . 'class.inc.php'); |
---|
| 42 | include(STUFFS_PATH . 'functions.inc.php'); |
---|
[9383] | 43 | |
---|
| 44 | $template->set_template_dir(STUFFS_PATH.'theme/template/'); |
---|
| 45 | $template->set_filename('stuffs', 'stuffs_blocks.tpl'); |
---|
| 46 | |
---|
| 47 | $stuffs = new stuffs(); |
---|
| 48 | |
---|
| 49 | if (!empty($stuffs->blocks['begin'])) |
---|
[3609] | 50 | { |
---|
[9383] | 51 | $template->assign('blocks', $stuffs->blocks['begin']); |
---|
[9410] | 52 | $template->concat($stuffs->prefixe.'BEFORE', $template->parse('stuffs', true)); |
---|
[9369] | 53 | } |
---|
[9383] | 54 | if (!empty($stuffs->blocks['end'])) |
---|
| 55 | { |
---|
| 56 | $template->assign('blocks', $stuffs->blocks['end']); |
---|
[9410] | 57 | $template->concat($stuffs->prefixe.'AFTER', $template->parse('stuffs', true)); |
---|
[9383] | 58 | } |
---|
[3609] | 59 | } |
---|
| 60 | |
---|
[9383] | 61 | function stuffs_section_init() |
---|
[3609] | 62 | { |
---|
[9383] | 63 | global $tokens, $page; |
---|
[3609] | 64 | |
---|
[9383] | 65 | switch (script_basename()) |
---|
| 66 | { |
---|
| 67 | case 'picture': |
---|
| 68 | $page['stuffs_section'] = 'on_picture'; |
---|
| 69 | break; |
---|
[3609] | 70 | |
---|
[9383] | 71 | case 'index': |
---|
| 72 | if (count($tokens) == 1 and empty($tokens[0])) |
---|
| 73 | { |
---|
| 74 | $page['stuffs_section'] = 'on_home'; |
---|
| 75 | break; |
---|
| 76 | } |
---|
| 77 | elseif (isset($page['section']) and $page['section'] == 'categories') |
---|
| 78 | { |
---|
| 79 | $page['stuffs_section'] = isset($page['category']) ? 'on_cats' : 'on_root'; |
---|
| 80 | break; |
---|
| 81 | } |
---|
[7402] | 82 | |
---|
[9383] | 83 | default: return; |
---|
[7402] | 84 | } |
---|
[9383] | 85 | |
---|
| 86 | add_event_handler('loc_begin_page_header', 'load_stuffs'); |
---|
[7402] | 87 | } |
---|
[9383] | 88 | |
---|
| 89 | add_event_handler('get_admin_plugin_menu_links', 'stuffs_admin_menu'); |
---|
| 90 | add_event_handler('loc_end_section_init', 'stuffs_section_init', 60); |
---|
| 91 | |
---|
[7402] | 92 | ?> |
---|