[3893] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: NBC ThemeChanger |
---|
[21654] | 4 | Version: auto |
---|
[10272] | 5 | Description: ThemeChanger allow you to associate for each category a specific theme. |
---|
[3893] | 6 | For the unspecified categories, the theme by default is applied. |
---|
[21655] | 7 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=214 |
---|
[6552] | 8 | Author: Datajulien |
---|
| 9 | Author URI: http://morgane.quoirez.com |
---|
[3893] | 10 | */ |
---|
| 11 | |
---|
| 12 | define('NBC_ThemeChanger_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
| 13 | |
---|
[6573] | 14 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
[3893] | 15 | |
---|
| 16 | /* Set the administration panel of the plugin */ |
---|
| 17 | |
---|
[6573] | 18 | |
---|
[3893] | 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', |
---|
[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 | |
---|
| 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 | |
---|
[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']); |
---|
[27640] | 59 | |
---|
| 60 | if ('stripped' == $user['theme']) |
---|
| 61 | { |
---|
| 62 | set_config_values(); |
---|
[3893] | 63 | } |
---|
[27640] | 64 | |
---|
| 65 | } |
---|
[3893] | 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 | ?> |
---|