source: extensions/nbc_ThemeChanger/main.inc.php

Last change on this file was 32434, checked in by ddtddt, 3 years ago

[nbc_ThemeChanger] piwigo 11

File size: 2.0 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
10Has Settings: true
11*/
12
13define('NBC_ThemeChanger_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
14
15if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
16
17/* Set the administration panel of the plugin */
18
19
20class ThemeChanger
21// Sets the administration panel of the plugin
22{
23        /*function nbc_ThemeChanger_admin_menu($menu)
24        {
25          array_push($menu,
26                array(
27                  'NAME' => 'ThemeChanger',
28                  'URL'  => get_root_url().'admin.php?page=plugin-'.basename(NBC_ThemeChanger_PATH)
29                )
30          );
31          return $menu;
32        }*/
33}
34
35$obj = new ThemeChanger();
36
37function change_category_theme()
38{
39  global $template, $page, $user, $conf;
40
41  $conf_nbc_ThemeChanger = isset($conf['nbc_ThemeChanger']) ? explode(";" , $conf['nbc_ThemeChanger']) : array();
42   
43  $category_theme = array();
44 
45  foreach ($conf_nbc_ThemeChanger as $Theme_Cat)
46  {
47    $element_ThemeChanger = explode("," , $Theme_Cat);
48   
49    if ($element_ThemeChanger[0] <> '' and $element_ThemeChanger[1] <> '')
50      $category_theme[$element_ThemeChanger[0]] = $element_ThemeChanger[1];
51  }
52
53  if (isset($page['category']['id']) and isset($category_theme[$page['category']['id']]))
54  {
55        $Defalut_user_theme = $user['theme'];
56        if (realpath(PHPWG_ROOT_PATH.'themes'.'/'.$category_theme[$page['category']['id']]))
57                $user['theme'] = $category_theme[$page['category']['id']];
58
59        $template = new Template(PHPWG_ROOT_PATH.'themes', $user['theme']);
60
61  if ('stripped' == $user['theme'])
62  {
63    set_config_values();
64  }
65 
66  }
67}
68
69//add_event_handler('get_admin_plugin_menu_links', array(&$obj, 'nbc_ThemeChanger_admin_menu') );
70add_event_handler('loc_end_section_init', 'change_category_theme');
71set_plugin_data($plugin['id'], $obj)
72
73?>
Note: See TracBrowser for help on using the repository browser.