1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based picture gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2010 Piwigo Team http://piwigo.org | |
---|
6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | This program is free software; you can redistribute it and/or modify | |
---|
10 | // | it under the terms of the GNU General Public License as published by | |
---|
11 | // | the Free Software Foundation | |
---|
12 | // | | |
---|
13 | // | This program is distributed in the hope that it will be useful, but | |
---|
14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
16 | // | General Public License for more details. | |
---|
17 | // | | |
---|
18 | // | You should have received a copy of the GNU General Public License | |
---|
19 | // | along with this program; if not, write to the Free Software | |
---|
20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
21 | // | USA. | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | |
---|
24 | /* Ajouter le lien au menu de l'admin */ |
---|
25 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
26 | Class ThemeCreator |
---|
27 | { |
---|
28 | var $theme_config; |
---|
29 | function ThemeCreator() |
---|
30 | { |
---|
31 | $this->theme_config = array(); |
---|
32 | } |
---|
33 | function get_config_file_dir() |
---|
34 | { |
---|
35 | global $conf; |
---|
36 | return $conf['local_data_dir'].'/plugins/'; |
---|
37 | } |
---|
38 | function get_config_file_name() |
---|
39 | { |
---|
40 | return basename(dirname(__FILE__)).'.dat'; |
---|
41 | } |
---|
42 | function reload() |
---|
43 | { |
---|
44 | $x = @file_get_contents( $this->get_config_file_dir().$this->get_config_file_name() ); |
---|
45 | if ($x!==false) |
---|
46 | { |
---|
47 | $y = unserialize($x); |
---|
48 | $this->theme_config = $y; |
---|
49 | } |
---|
50 | } |
---|
51 | function save_theme_config() |
---|
52 | { |
---|
53 | $dir = $this->get_config_file_dir(); |
---|
54 | @mkdir($dir); |
---|
55 | $file = fopen( $dir.$this->get_config_file_name(), 'w' ); |
---|
56 | fwrite($file, serialize($this->theme_config) ); |
---|
57 | fclose( $file ); |
---|
58 | } |
---|
59 | function plugin_admin_menu($menu) |
---|
60 | { |
---|
61 | array_push($menu, |
---|
62 | array( |
---|
63 | 'NAME' => 'Swift Theme Creator', |
---|
64 | 'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/theme_creator.php') |
---|
65 | ) |
---|
66 | ); |
---|
67 | return $menu; |
---|
68 | } |
---|
69 | /** |
---|
70 | * returns available template/theme |
---|
71 | */ |
---|
72 | function get_pwg_templates() |
---|
73 | { |
---|
74 | $templates = array(); |
---|
75 | $template_dir = PHPWG_ROOT_PATH.'template'; |
---|
76 | foreach (get_dirs($template_dir) as $template) |
---|
77 | { |
---|
78 | array_push($templates, $template); |
---|
79 | } |
---|
80 | return $templates; |
---|
81 | } |
---|
82 | } |
---|
83 | $swift_theme_creator = new ThemeCreator(); |
---|
84 | $swift_theme_creator->reload(); |
---|
85 | add_event_handler('get_admin_plugin_menu_links', |
---|
86 | array(&$swift_theme_creator, 'plugin_admin_menu') ); |
---|
87 | set_plugin_data($plugin['id'], $swift_theme_creator); |
---|
88 | ?> |
---|