source: extensions/PWG_Stuffs/main.inc.php @ 9401

Last change on this file since 9401 was 9383, checked in by patdenice, 13 years ago

Add display option. Optimizations.

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