[12401] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: PWG Stuffs |
---|
| 4 | Version: auto |
---|
| 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 | |
---|
| 13 | global $prefixeTable, $conf; |
---|
| 14 | |
---|
| 15 | $conf['Stuffs'] = @unserialize($conf['PWG_Stuffs']); |
---|
| 16 | |
---|
| 17 | define('STUFFS_DIR' , basename(dirname(__FILE__))); |
---|
| 18 | define('STUFFS_PATH' , PHPWG_PLUGINS_PATH . STUFFS_DIR . '/'); |
---|
| 19 | define('STUFFS_TABLE' , $prefixeTable . 'stuffs'); |
---|
| 20 | |
---|
| 21 | // Need upgrade? |
---|
| 22 | if ($conf['Stuffs'] === false) |
---|
| 23 | include('admin/upgrade.inc.php'); |
---|
| 24 | |
---|
| 25 | function stuffs_admin_menu($menu) |
---|
| 26 | { |
---|
| 27 | global $conf; |
---|
| 28 | |
---|
| 29 | array_push($menu, array( |
---|
| 30 | 'NAME' => 'PWG Stuffs', |
---|
| 31 | 'URL' => get_root_url().'admin.php?page=plugin-'.STUFFS_DIR |
---|
| 32 | ) |
---|
| 33 | ); |
---|
| 34 | return $menu; |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | function load_stuffs() |
---|
| 38 | { |
---|
| 39 | global $template, $conf; |
---|
| 40 | |
---|
| 41 | include(STUFFS_PATH . 'class.inc.php'); |
---|
| 42 | include(STUFFS_PATH . 'functions.inc.php'); |
---|
| 43 | |
---|
| 44 | $template->set_template_dir(STUFFS_PATH.'theme/template/'); |
---|
| 45 | $template->set_filename('stuffs', 'stuffs_blocks.tpl'); |
---|
| 46 | $template->assign('SHOW_THUMBNAIL_CAPTION', $conf['show_thumbnail_caption']); |
---|
| 47 | |
---|
| 48 | $stuffs = new stuffs(); |
---|
| 49 | |
---|
| 50 | if (!empty($stuffs->blocks['begin'])) |
---|
| 51 | { |
---|
| 52 | $template->assign('blocks', $stuffs->blocks['begin']); |
---|
| 53 | $template->concat($stuffs->prefixe.'BEFORE', $template->parse('stuffs', true)); |
---|
| 54 | } |
---|
| 55 | if (!empty($stuffs->blocks['end'])) |
---|
| 56 | { |
---|
| 57 | $template->assign('blocks', $stuffs->blocks['end']); |
---|
| 58 | $template->concat($stuffs->prefixe.'AFTER', $template->parse('stuffs', true)); |
---|
| 59 | } |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | function stuffs_section_init() |
---|
| 63 | { |
---|
| 64 | global $tokens, $page; |
---|
| 65 | |
---|
| 66 | switch (script_basename()) |
---|
| 67 | { |
---|
| 68 | case 'picture': |
---|
| 69 | $page['stuffs_section'] = 'on_picture'; |
---|
| 70 | break; |
---|
| 71 | |
---|
| 72 | case 'index': |
---|
[12524] | 73 | $actions = array('delete_comment', 'validate_comment', 'edit_comment', ''); |
---|
| 74 | if (count($tokens) == 1 and in_array($tokens[0], $actions)) |
---|
[12401] | 75 | { |
---|
| 76 | $page['stuffs_section'] = 'on_home'; |
---|
| 77 | break; |
---|
| 78 | } |
---|
| 79 | elseif (isset($page['section']) and $page['section'] == 'categories') |
---|
| 80 | { |
---|
| 81 | $page['stuffs_section'] = isset($page['category']) ? 'on_cats' : 'on_root'; |
---|
| 82 | break; |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | default: return; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | add_event_handler('loc_begin_index', 'load_stuffs'); |
---|
| 89 | add_event_handler('loc_begin_picture', 'load_stuffs'); |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | add_event_handler('get_admin_plugin_menu_links', 'stuffs_admin_menu'); |
---|
| 93 | add_event_handler('loc_end_section_init', 'stuffs_section_init', 60); |
---|
| 94 | |
---|
| 95 | ?> |
---|