1 | <?php |
---|
2 | /* |
---|
3 | Theme Name: Stripped & Columns |
---|
4 | Version: auto |
---|
5 | Description: stripped_black_bloc |
---|
6 | Theme URI: http://piwigo.org/ext/extension_view.php?eid=568 |
---|
7 | Author: flop25 |
---|
8 | Author URI: http://www.planete-flop.fr |
---|
9 | */ |
---|
10 | |
---|
11 | |
---|
12 | |
---|
13 | $themeconf = array( |
---|
14 | 'parent' => 'stripped', |
---|
15 | 'name' => 'stripped_black_bloc', |
---|
16 | 'theme_dir' => 'stripped_black_bloc', |
---|
17 | 'icon_dir' => 'themes/stripped/icon', |
---|
18 | 'admin_icon_dir' => 'themes/default/icon/admin', |
---|
19 | 'mime_icon_dir' => 'themes/default/icon/mimetypes/', |
---|
20 | 'local_head' => 'local_head.tpl', |
---|
21 | ); |
---|
22 | |
---|
23 | load_language('theme.lang', PHPWG_THEMES_PATH.'stripped_black_bloc/'); |
---|
24 | |
---|
25 | // Need upgrade? |
---|
26 | |
---|
27 | include(PHPWG_THEMES_PATH.'stripped_black_bloc/admin/upgrade.inc.php'); |
---|
28 | |
---|
29 | add_event_handler('loc_begin_page_header', 'set_config_values_stripped_black_bloc'); |
---|
30 | |
---|
31 | function set_config_values_stripped_black_bloc() |
---|
32 | { |
---|
33 | global $conf, $template; |
---|
34 | $config = unserialize( $conf['stripped_black_bloc'] ); |
---|
35 | $template->assign( 'stripped_black_bloc', $config ); |
---|
36 | } |
---|
37 | |
---|
38 | /// EVENT |
---|
39 | |
---|
40 | /************************************ thumbnails and category_thumbnails ************************************/ |
---|
41 | add_event_handler('loc_end_index_category_thumbnails', 'stripped_black_bloc'); |
---|
42 | add_event_handler('loc_end_index_thumbnails', 'stripped_black_bloc'); |
---|
43 | function stripped_black_bloc($tpl_thumbnails_var) |
---|
44 | { |
---|
45 | global $template, $conf; |
---|
46 | $config = unserialize( $conf['stripped_black_bloc'] ); |
---|
47 | $new_tplvar=array(); |
---|
48 | $i=1; |
---|
49 | foreach ($tpl_thumbnails_var as $tplvar) |
---|
50 | { |
---|
51 | list($width, $height, $type, $attr) = getimagesize( $tplvar['TN_SRC'] ); |
---|
52 | $tplvar['TN_WIDTH']=$width; |
---|
53 | $tplvar['TN_HEIGHT']=$height; |
---|
54 | if (!isset($tplvar['CAPTION_NB_IMAGES'])) |
---|
55 | { |
---|
56 | $conf_thumbnail_width=($i==$config['starting_to']) ? $config['column_width']+$config['thumbnail_width'] : $config['thumbnail_width']; |
---|
57 | $tplvar['TN_CLASS']=($i==$config['starting_to']) ? "bloc_big" : "bloc"; |
---|
58 | } |
---|
59 | else |
---|
60 | { |
---|
61 | $conf_thumbnail_width=$config['thumbnail_width']; |
---|
62 | } |
---|
63 | if (isset($config['thumbnail'])) |
---|
64 | { |
---|
65 | switch ($config['thumbnail']) |
---|
66 | { |
---|
67 | case 'generated': |
---|
68 | if (isset($tplvar['FILE_WIDTH'])) |
---|
69 | { |
---|
70 | $tplvar['TN_SRC']=PHPWG_THEMES_PATH."stripped_black_bloc/library/phpthumb/phpThumb.php?src=../../../../".$tplvar['FILE_PATH']."&w=".$conf_thumbnail_width; |
---|
71 | } |
---|
72 | else |
---|
73 | { |
---|
74 | $tplvar['TN_SRC']=PHPWG_THEMES_PATH."stripped_black_bloc/library/phpthumb/phpThumb.php?src=../../../../".$tplvar['TN_SRC']."&w=".$conf_thumbnail_width; |
---|
75 | } |
---|
76 | $tplvar['TN_HEIGHT']=floor($tplvar['TN_HEIGHT']*($conf_thumbnail_width/$tplvar['TN_WIDTH'])); |
---|
77 | $tplvar['TN_WIDTH']=$conf_thumbnail_width; |
---|
78 | break; |
---|
79 | case 'auto': |
---|
80 | if($tplvar['TN_WIDTH']<=$conf_thumbnail_width) |
---|
81 | { |
---|
82 | if (isset($tplvar['FILE_WIDTH'])) |
---|
83 | { |
---|
84 | $tplvar['TN_SRC']=PHPWG_THEMES_PATH."stripped_black_bloc/library/phpthumb/phpThumb.php?src=../../../../".$tplvar['FILE_PATH']."&w=".$conf_thumbnail_width; |
---|
85 | } |
---|
86 | else |
---|
87 | { |
---|
88 | $tplvar['TN_SRC']=PHPWG_THEMES_PATH."stripped_black_bloc/library/phpthumb/phpThumb.php?src=../../../../".$tplvar['TN_SRC']."&w=".$conf_thumbnail_width; |
---|
89 | } |
---|
90 | $tplvar['TN_HEIGHT']=floor($tplvar['TN_HEIGHT']*($conf_thumbnail_width/$tplvar['TN_WIDTH'])); |
---|
91 | $tplvar['TN_WIDTH']=$conf_thumbnail_width; |
---|
92 | } |
---|
93 | break; |
---|
94 | case 'piwigo':break; |
---|
95 | } |
---|
96 | } |
---|
97 | $new_tplvar[]=$tplvar; |
---|
98 | if ($i==$config['every_x']) |
---|
99 | { |
---|
100 | $i=1; |
---|
101 | } |
---|
102 | else { |
---|
103 | $i++; |
---|
104 | } |
---|
105 | } |
---|
106 | return $new_tplvar; |
---|
107 | } |
---|
108 | add_event_handler('init', 'stripped_black_bloc_init'); |
---|
109 | function stripped_black_bloc_init() |
---|
110 | { |
---|
111 | remove_event_handler('loc_begin_index', 'modify_nb_thumbnail_page'); |
---|
112 | } |
---|
113 | |
---|
114 | /************************************ index.tpl ************************************/ |
---|
115 | add_event_handler('loc_end_index', 'stripped_black_bloc_index'); |
---|
116 | function stripped_black_bloc_index() |
---|
117 | { |
---|
118 | global $template; |
---|
119 | $template->set_prefilter('index', 'stripped_black_bloc_prefilter_index'); |
---|
120 | } |
---|
121 | function stripped_black_bloc_prefilter_index($content, &$smarty) |
---|
122 | { |
---|
123 | $search = '#Menu</span>#'; |
---|
124 | $replacement = "{'Show/hide menu'|@translate}</span>"; |
---|
125 | $content = preg_replace($search, $replacement, $content); |
---|
126 | $search = '#<div id="subcontent">#'; |
---|
127 | $replacement = ""; |
---|
128 | $content = preg_replace($search, $replacement, $content); |
---|
129 | $search = '#\{if \!empty\(\$CONTENT_DESCRIPTION\) \}#'; |
---|
130 | $replacement = ' <div id="subcontent"> |
---|
131 | |
---|
132 | {if !empty($CONTENT_DESCRIPTION) }'; |
---|
133 | $content = preg_replace($search, $replacement, $content); |
---|
134 | $search = '#\{if \!empty\(\$navbar\) \}[\s]*\{include file=\'navigation_bar\.tpl\'\|@get_extent:\'navbar\'\}[\s]*\{/if\}#'; |
---|
135 | $replacement = ''; |
---|
136 | $content = preg_replace($search, $replacement, $content); |
---|
137 | |
---|
138 | $search = '#<\!-- subContent -->#'; |
---|
139 | $replacement = '<!-- subContent --> |
---|
140 | {if !empty($navbar) } |
---|
141 | {include file=\'navigation_bar.tpl\'|@get_extent:\'navbar\'} |
---|
142 | {/if}'; |
---|
143 | return preg_replace($search, $replacement, $content); |
---|
144 | } |
---|
145 | |
---|
146 | ?> |
---|