1 | <?php |
---|
2 | /* |
---|
3 | Theme Name: OS_default |
---|
4 | Version: auto |
---|
5 | Description: |
---|
6 | Theme URI: http://piwigo.org/ext/extension_view.php?eid=497 |
---|
7 | Author: flop25 |
---|
8 | Author URI: http://www.planete-flop.fr |
---|
9 | */ |
---|
10 | $themeconf = array( |
---|
11 | 'name' => 'OS_default', |
---|
12 | 'parent' => 'default', |
---|
13 | 'icon_dir' => 'themes/OS_default/icon', |
---|
14 | 'mime_icon_dir' => 'themes/OS_default/icon/mimetypes/', |
---|
15 | 'local_head' => 'local_head.tpl', |
---|
16 | 'activable' => false, |
---|
17 | 'add_menu_on_public_pages' => true, # activation |
---|
18 | 'Exclude' => array('theNBMPage','thePicturePage','thePopuphelpPage',), # Excluded pages |
---|
19 | ); |
---|
20 | |
---|
21 | |
---|
22 | |
---|
23 | add_event_handler('loc_begin_picture', 'pwg_v'); |
---|
24 | function pwg_v() { |
---|
25 | global $template; |
---|
26 | $template->assign( |
---|
27 | array( |
---|
28 | 'PHPWG_VERSION' => PHPWG_VERSION, |
---|
29 | )); |
---|
30 | } |
---|
31 | /*********************************menu on every pages ************************************/ |
---|
32 | // thx to Vdigital and his plugin spreadmenus |
---|
33 | if ( !function_exists( 'add_menu_on_public_pages' ) ) { |
---|
34 | if ( defined('IN_ADMIN') and IN_ADMIN ) return false; |
---|
35 | add_event_handler('loc_after_page_header', 'add_menu_on_public_pages', 20); |
---|
36 | |
---|
37 | function add_menu_on_public_pages() { |
---|
38 | if ( function_exists( 'initialize_menu') ) return false; # The current page has already the menu |
---|
39 | if ( !get_themeconf('add_menu_on_public_pages') ) return false; # The current page has already the menu |
---|
40 | global $template, $page, $conf; |
---|
41 | if ( isset($page['body_id']) and in_array($page['body_id'], get_themeconf('Exclude')) ) return false; |
---|
42 | |
---|
43 | $template->set_filenames(array( |
---|
44 | 'add_menu_on_public_pages' => dirname(__FILE__) . '/template/add_menu_on_public_pages.tpl', |
---|
45 | )); |
---|
46 | include_once(PHPWG_ROOT_PATH.'include/menubar.inc.php'); |
---|
47 | $template->parse('add_menu_on_public_pages'); |
---|
48 | |
---|
49 | if (is_admin()) |
---|
50 | { |
---|
51 | $template->assign( |
---|
52 | 'U_ADMIN', get_root_url().'admin.php?page=picture_modify' |
---|
53 | .'&cat_id='.(isset($page['category']) ? $page['category']['id'] : '') |
---|
54 | .( isset($page['image_id']) ? '&image_id='.$page['image_id'] : '') |
---|
55 | ); |
---|
56 | } |
---|
57 | |
---|
58 | } |
---|
59 | } |
---|
60 | |
---|
61 | |
---|
62 | // function load_pattern |
---|
63 | // include the right ***.pattern.php |
---|
64 | // not compatible 2.2and<2.2 |
---|
65 | |
---|
66 | function load_pattern() |
---|
67 | { |
---|
68 | global $pattern; |
---|
69 | $pwgversion=str_replace('.','',PHPWG_VERSION); |
---|
70 | $pwgversion_array=explode('.', PHPWG_VERSION); |
---|
71 | if (file_exists($pwgversion.'pattern.php')) |
---|
72 | { |
---|
73 | include($pwgversion.'.pattern.php'); |
---|
74 | return true; |
---|
75 | } |
---|
76 | elseif (file_exists(PHPWG_ROOT_PATH.'themes/OS_default/'.$pwgversion_array[0].$pwgversion_array[1].'x.pattern.php')) |
---|
77 | { |
---|
78 | include(PHPWG_ROOT_PATH.'themes/OS_default/'.$pwgversion_array[0].$pwgversion_array[1].'x.pattern.php'); |
---|
79 | return true; |
---|
80 | } |
---|
81 | else |
---|
82 | { |
---|
83 | $list_pattern_path=array(); |
---|
84 | $dir=PHPWG_ROOT_PATH.'themes/OS_default'; |
---|
85 | $dh = opendir($dir); |
---|
86 | while (($file = readdir ($dh)) !== false ) { |
---|
87 | if ($file !== '.' && $file !== '..') { |
---|
88 | $path =$dir.'/'.$file; |
---|
89 | if (!is_dir ($path)) { |
---|
90 | if(strpos($file,'pattern.php')!==false) { //On ne prend que les .pattern.php |
---|
91 | $list_pattern_path[]=$file; |
---|
92 | } |
---|
93 | } |
---|
94 | } |
---|
95 | } |
---|
96 | closedir($dh); |
---|
97 | $f=0; |
---|
98 | for($i = 10; $i >=0; $i--) |
---|
99 | { |
---|
100 | if (in_array($pwgversion_array[0].$i.'.pattern.php',$list_pattern_path)) |
---|
101 | { |
---|
102 | include($pwgversion_array[0].$i.'.pattern.php'); |
---|
103 | return true; |
---|
104 | $f=1; |
---|
105 | break; |
---|
106 | } |
---|
107 | } |
---|
108 | if ($f=0) |
---|
109 | { |
---|
110 | return false; |
---|
111 | } |
---|
112 | } |
---|
113 | |
---|
114 | } |
---|
115 | if(!load_pattern()) |
---|
116 | { |
---|
117 | global $page; |
---|
118 | $page['errors'][]='Theme not compatible'; |
---|
119 | } |
---|
120 | add_event_handler('loc_end_index', 'OS_default_index'); |
---|
121 | function OS_default_index() |
---|
122 | { |
---|
123 | global $template; |
---|
124 | $template->set_prefilter('index', 'OS_default_prefilter_index'); |
---|
125 | } |
---|
126 | function OS_default_prefilter_index($content, &$smarty) |
---|
127 | { |
---|
128 | global $pattern; |
---|
129 | $r=$pattern['OS_default_prefilter_index']['R']; |
---|
130 | $ps=$pattern['OS_default_prefilter_index']['S']; |
---|
131 | foreach($r as $i => $pr) |
---|
132 | { |
---|
133 | $content = str_replace($ps[$i], $pr, $content); |
---|
134 | } |
---|
135 | return $content; |
---|
136 | } |
---|
137 | |
---|
138 | add_event_handler('loc_begin_picture', 'OS_default_picture'); |
---|
139 | function OS_default_picture() |
---|
140 | { |
---|
141 | global $template; |
---|
142 | $template->set_prefilter('picture', 'OS_default_prefilter_picture'); |
---|
143 | } |
---|
144 | function OS_default_prefilter_picture($content, &$smarty) |
---|
145 | { |
---|
146 | global $pattern; |
---|
147 | $r=$pattern['OS_default_prefilter_picture']['R']; |
---|
148 | $ps=$pattern['OS_default_prefilter_picture']['S']; |
---|
149 | foreach($r as $i => $pr) |
---|
150 | { |
---|
151 | $content = preg_replace($ps[$i], $pr, $content); |
---|
152 | } |
---|
153 | return $content; |
---|
154 | } |
---|
155 | ?> |
---|