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