1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: NBC ThemeChanger |
---|
4 | Version: auto |
---|
5 | Description: ThemeChanger allow you to associate for each category a specific theme. |
---|
6 | For the unspecified categories, the theme by default is applied. |
---|
7 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=214 |
---|
8 | Author: Datajulien |
---|
9 | Author URI: http://morgane.quoirez.com |
---|
10 | */ |
---|
11 | |
---|
12 | define('NBC_ThemeChanger_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
13 | |
---|
14 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
15 | |
---|
16 | /* Set the administration panel of the plugin */ |
---|
17 | |
---|
18 | |
---|
19 | class 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 | |
---|
36 | function 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 | if ('stripped' == $user['theme']) |
---|
61 | { |
---|
62 | set_config_values(); |
---|
63 | } |
---|
64 | |
---|
65 | } |
---|
66 | } |
---|
67 | |
---|
68 | add_event_handler('get_admin_plugin_menu_links', array(&$obj, 'nbc_ThemeChanger_admin_menu') ); |
---|
69 | add_event_handler('loc_end_section_init', 'change_category_theme'); |
---|
70 | set_plugin_data($plugin['id'], $obj) |
---|
71 | |
---|
72 | ?> |
---|