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

Last change on this file since 25461 was 21655, checked in by ddtddt, 12 years ago

[extensions] - nbc_ThemeChanger - Plugin URI

File size: 1.9 KB
Line 
1<?php
2/*
3Plugin Name: NBC ThemeChanger
4Version: auto
5Description: ThemeChanger allow you to associate for each category a specific theme.
6        For the unspecified categories, the theme by default is applied.
7Plugin URI: http://piwigo.org/ext/extension_view.php?eid=214
8Author: Datajulien
9Author URI: http://morgane.quoirez.com
10*/
11
12define('NBC_ThemeChanger_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
13
14if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
15
16/* Set the administration panel of the plugin */
17
18
19class ThemeChanger
20// Sets the administration panel of the plugin
21{
22        function nbc_ThemeChanger_admin_menu($menu)
23        {
24          array_push($menu,
25                array(
26                  'NAME' => 'ThemeChanger',
27                  'URL'  => get_root_url().'admin.php?page=plugin-'.basename(NBC_ThemeChanger_PATH)
28                )
29          );
30          return $menu;
31        }
32}
33
34$obj = new ThemeChanger();
35
36function change_category_theme()
37{
38  global $template, $page, $user, $conf;
39
40  $conf_nbc_ThemeChanger = isset($conf['nbc_ThemeChanger']) ? explode(";" , $conf['nbc_ThemeChanger']) : array();
41   
42  $category_theme = array();
43 
44  foreach ($conf_nbc_ThemeChanger as $Theme_Cat)
45  {
46    $element_ThemeChanger = explode("," , $Theme_Cat);
47   
48    if ($element_ThemeChanger[0] <> '' and $element_ThemeChanger[1] <> '')
49      $category_theme[$element_ThemeChanger[0]] = $element_ThemeChanger[1];
50  }
51
52  if (isset($page['category']['id']) and isset($category_theme[$page['category']['id']]))
53  {
54        $Defalut_user_theme = $user['theme'];
55        if (realpath(PHPWG_ROOT_PATH.'themes'.'/'.$category_theme[$page['category']['id']]))
56                $user['theme'] = $category_theme[$page['category']['id']];
57
58        $template = new Template(PHPWG_ROOT_PATH.'themes', $user['theme']);
59  }
60}
61
62add_event_handler('get_admin_plugin_menu_links', array(&$obj, 'nbc_ThemeChanger_admin_menu') );
63add_event_handler('loc_end_section_init', 'change_category_theme');
64set_plugin_data($plugin['id'], $obj)
65
66?>
Note: See TracBrowser for help on using the repository browser.