1 | <?php |
---|
2 | /* |
---|
3 | Theme Name: hr_glass_xl |
---|
4 | Version: auto |
---|
5 | Description: A theme with an horizontal menu and a simple modern design |
---|
6 | Theme URI: http://fr.piwigo.org/ext/extension_view.php?eid=502 |
---|
7 | Author: flop25 |
---|
8 | Author URI: http://www.planete-flop.fr |
---|
9 | */ |
---|
10 | $themeconf = array( |
---|
11 | 'name' => 'hr_glass_xl', |
---|
12 | 'parent' => 'default', |
---|
13 | 'icon_dir' => 'themes/hr_glass_xl/icon', |
---|
14 | 'mime_icon_dir' => 'themes/hr_glass_xl/icon/mimetypes/', |
---|
15 | 'local_head' => 'local_head.tpl', |
---|
16 | 'activable' => true, |
---|
17 | ); |
---|
18 | //// [update check] |
---|
19 | if (!isset($conf['hr_glass_xl'])) |
---|
20 | { |
---|
21 | $config = array( |
---|
22 | 'home' => true, |
---|
23 | 'categories' => true, |
---|
24 | 'picture' => false, |
---|
25 | 'other' => true, |
---|
26 | ); |
---|
27 | |
---|
28 | $query = ' |
---|
29 | INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
30 | VALUES ("hr_glass_xl" , "'.pwg_db_real_escape_string(serialize($config)).'" , "hr_glass_xl parameters");'; |
---|
31 | |
---|
32 | pwg_query($query); |
---|
33 | load_conf_from_db(); |
---|
34 | } |
---|
35 | if (isset($conf['derivatives'])) { |
---|
36 | $new = @unserialize($conf['derivatives']); |
---|
37 | if(!isset($new['d']['Optimal'])) |
---|
38 | { |
---|
39 | $new['d']['Optimal']=ImageStdParams::get_custom(900,9999); |
---|
40 | $query = ' |
---|
41 | UPDATE '.CONFIG_TABLE.' |
---|
42 | SET value="'.addslashes(serialize($new)).'" |
---|
43 | WHERE param = "derivatives" |
---|
44 | LIMIT 1'; |
---|
45 | pwg_query($query); |
---|
46 | load_conf_from_db(); |
---|
47 | } |
---|
48 | }//// [/update check] |
---|
49 | |
---|
50 | |
---|
51 | |
---|
52 | // thx to P@t |
---|
53 | add_event_handler('loc_begin_page_header', 'set_hr_glass_xl_header'); |
---|
54 | |
---|
55 | function set_hr_glass_xl_header() |
---|
56 | { |
---|
57 | global $page, $conf, $template; |
---|
58 | |
---|
59 | $config = unserialize($conf['hr_glass_xl']); |
---|
60 | |
---|
61 | if (isset($page['body_id']) and $page['body_id'] == 'theCategoryPage') |
---|
62 | { |
---|
63 | $header = isset($page['category']) ? $config['categories'] : $config['home']; |
---|
64 | } |
---|
65 | elseif (isset($page['body_id']) and $page['body_id'] == 'thePicturePage') |
---|
66 | { |
---|
67 | $header = $config['picture']; |
---|
68 | } |
---|
69 | else |
---|
70 | { |
---|
71 | $header = $config['other']; |
---|
72 | } |
---|
73 | |
---|
74 | $template->assign('display_hr_glass_xl_banner', $header); |
---|
75 | } |
---|
76 | |
---|
77 | // function load_pattern |
---|
78 | // include the right ***.pattern.php |
---|
79 | // not compatible 2.2and<2.2 |
---|
80 | |
---|
81 | function load_pattern() |
---|
82 | { |
---|
83 | global $pattern; |
---|
84 | $pwgversion=str_replace('.','',PHPWG_VERSION); |
---|
85 | $pwgversion_array=explode('.', PHPWG_VERSION); |
---|
86 | if (file_exists($pwgversion.'pattern.php')) |
---|
87 | { |
---|
88 | include($pwgversion.'.pattern.php'); |
---|
89 | return true; |
---|
90 | } |
---|
91 | elseif (file_exists(PHPWG_ROOT_PATH.'themes/hr_glass_xl/'.$pwgversion_array[0].$pwgversion_array[1].'x.pattern.php')) |
---|
92 | { |
---|
93 | include(PHPWG_ROOT_PATH.'themes/hr_glass_xl/'.$pwgversion_array[0].$pwgversion_array[1].'x.pattern.php'); |
---|
94 | return true; |
---|
95 | } |
---|
96 | else |
---|
97 | { |
---|
98 | $list_pattern_path=array(); |
---|
99 | $dir=PHPWG_ROOT_PATH.'themes/hr_glass_xl'; |
---|
100 | $dh = opendir($dir); |
---|
101 | while (($file = readdir ($dh)) !== false ) { |
---|
102 | if ($file !== '.' && $file !== '..') { |
---|
103 | $path =$dir.'/'.$file; |
---|
104 | if (!is_dir ($path)) { |
---|
105 | if(strpos($file,'pattern.php')!==false) { //On ne prend que les .pattern.php |
---|
106 | $list_pattern_path[]=$file; |
---|
107 | } |
---|
108 | } |
---|
109 | } |
---|
110 | } |
---|
111 | closedir($dh); |
---|
112 | $f=0; |
---|
113 | for($i = 10; $i >=0; $i--) |
---|
114 | { |
---|
115 | if (in_array($pwgversion_array[0].$i.'.pattern.php',$list_pattern_path)) |
---|
116 | { |
---|
117 | include($pwgversion_array[0].$i.'.pattern.php'); |
---|
118 | return true; |
---|
119 | $f=1; |
---|
120 | break; |
---|
121 | } |
---|
122 | } |
---|
123 | if ($f=0) |
---|
124 | { |
---|
125 | return false; |
---|
126 | } |
---|
127 | } |
---|
128 | |
---|
129 | } |
---|
130 | if(!load_pattern()) |
---|
131 | { |
---|
132 | global $page; |
---|
133 | $page['errors'][]='Theme not compatible'; |
---|
134 | } |
---|
135 | |
---|
136 | /************************************ picture.tpl ************************************/ |
---|
137 | //add_event_handler('render_element_content', 'hr_glass_xl_picture', EVENT_HANDLER_PRIORITY_NEUTRAL, 20 ); |
---|
138 | function hr_glass_xl_picture($content, $element_info) |
---|
139 | { |
---|
140 | global $template; |
---|
141 | $template->set_prefilter('default_content', 'hr_glass_xl_prefilter_picture'); |
---|
142 | return $content; |
---|
143 | } |
---|
144 | function hr_glass_xl_prefilter_picture($content, &$smarty) |
---|
145 | { |
---|
146 | global $pattern; |
---|
147 | $r=$pattern['hr_glass_xl_prefilter_picture']['R']; |
---|
148 | $ps=$pattern['hr_glass_xl_prefilter_picture']['S']; |
---|
149 | foreach($r as $i => $pr) |
---|
150 | { |
---|
151 | $content = str_replace($ps[$i], $pr, $content); |
---|
152 | } |
---|
153 | |
---|
154 | $content ='{define_derivative name=\'der_hr_glass_xl\' width=730 height=9999 crop=false} |
---|
155 | {assign var=der value=$pwg->derivative($der_hr_glass_xl, $current.src_image)} |
---|
156 | '.$content; |
---|
157 | return $content; |
---|
158 | } |
---|
159 | |
---|
160 | |
---|
161 | ?> |
---|