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

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

[extensions] - nbc_ThemeChanger - Plugin URI

File size: 1.9 KB
RevLine 
[3893]1<?php
2/*
3Plugin Name: NBC ThemeChanger
[21654]4Version: auto
[10272]5Description: ThemeChanger allow you to associate for each category a specific theme.
[3893]6        For the unspecified categories, the theme by default is applied.
[21655]7Plugin URI: http://piwigo.org/ext/extension_view.php?eid=214
[6552]8Author: Datajulien
9Author URI: http://morgane.quoirez.com
[3893]10*/
11
12define('NBC_ThemeChanger_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
13
[6573]14if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
[3893]15
16/* Set the administration panel of the plugin */
17
[6573]18
[3893]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',
[10099]27                  'URL'  => get_root_url().'admin.php?page=plugin-'.basename(NBC_ThemeChanger_PATH)
[3893]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   
[6552]48    if ($element_ThemeChanger[0] <> '' and $element_ThemeChanger[1] <> '')
49      $category_theme[$element_ThemeChanger[0]] = $element_ThemeChanger[1];
[3893]50  }
51
52  if (isset($page['category']['id']) and isset($category_theme[$page['category']['id']]))
53  {
[6648]54        $Defalut_user_theme = $user['theme'];
[6642]55        if (realpath(PHPWG_ROOT_PATH.'themes'.'/'.$category_theme[$page['category']['id']]))
56                $user['theme'] = $category_theme[$page['category']['id']];
[6648]57
[6573]58        $template = new Template(PHPWG_ROOT_PATH.'themes', $user['theme']);
[3893]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.