source: extensions/PWG_Stuffs/trunk/main.inc.php @ 20016

Last change on this file since 20016 was 20016, checked in by patdenice, 12 years ago

bug:2819
Link problem in menu with smartpocket

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