source: extensions/nbc_ThemeChanger/main.inc.php @ 6553

Last change on this file since 6553 was 6553, checked in by datajulien, 14 years ago

Portage plugin vers piwigo 2.1.0

File size: 2.2 KB
Line 
1<?php
2/*
3Plugin Name: NBC ThemeChanger
4Version: 2.1.0.a
5Description: Permet d'associer à chaque catégorie virtuel ou physique un thème spécifique.
6        ThemeChanger vous permet de spécifier pour chaque catégorie un thème différent.
7        Pour les catégories non spécifiées, le thème par défaut s'applique.
8        ThemeChanger allow you to associate for each category a specific theme.
9        For the unspecified categories, the theme by default is applied.
10        ThemeChanger permette di precisare per ogni categoria un tema diverso.
11        Per le categorie non precisato, il tema da difetto è applicato.
12Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=214
13Author: Datajulien
14Author URI: http://morgane.quoirez.com
15*/
16
17define('NBC_ThemeChanger_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
18
19//if (!defined(NBC_ThemeChanger_PATH)) die('Hacking attempt - ThemeChanger main.inc.php - NBC_ThemeChanger_PATH!');
20
21/* Set the administration panel of the plugin */
22
23class ThemeChanger
24// Sets the administration panel of the plugin
25{
26        function nbc_ThemeChanger_admin_menu($menu)
27        {
28          array_push($menu,
29                array(
30                  'NAME' => 'ThemeChanger',
31                  'URL'  => get_admin_plugin_menu_link(NBC_ThemeChanger_PATH.'admin/nbc_ThemeChanger_admin.php')
32                )
33          );
34          return $menu;
35        }
36}
37
38$obj = new ThemeChanger();
39
40function change_category_theme()
41{
42  global $template, $page, $user, $conf;
43
44  $conf_nbc_ThemeChanger = isset($conf['nbc_ThemeChanger']) ? explode(";" , $conf['nbc_ThemeChanger']) : array();
45   
46  $category_theme = array();
47 
48  foreach ($conf_nbc_ThemeChanger as $Theme_Cat)
49  {
50    $element_ThemeChanger = explode("," , $Theme_Cat);
51   
52    if ($element_ThemeChanger[0] <> '' and $element_ThemeChanger[1] <> '')
53      $category_theme[$element_ThemeChanger[0]] = $element_ThemeChanger[1];
54  }
55
56  if (isset($page['category']['id']) and isset($category_theme[$page['category']['id']]))
57  {
58    $user['theme'] = $category_theme[$page['category']['id']];
59        $template = new Template(PHPWG_ROOT_PATH.'themes', $user['theme'] );
60  }
61}
62
63add_event_handler('get_admin_plugin_menu_links', array(&$obj, 'nbc_ThemeChanger_admin_menu') );
64add_event_handler('loc_end_section_init', 'change_category_theme');
65set_plugin_data($plugin['id'], $obj)
66
67?>
Note: See TracBrowser for help on using the repository browser.