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 | add_event_handler('loc_end_index_category_thumbnails', 'MY'); |
---|
40 | add_event_handler('loc_end_index_thumbnails', 'MY'); |
---|
41 | function MY($tpl_thumbnails_var) |
---|
42 | { |
---|
43 | global $template, $conf; |
---|
44 | $config = unserialize( $conf['stripped_black_bloc'] ); |
---|
45 | $new_tplvar=array(); |
---|
46 | foreach ($tpl_thumbnails_var as $tplvar) |
---|
47 | { |
---|
48 | list($width, $height, $type, $attr) = getimagesize( $tplvar['TN_SRC'] ); |
---|
49 | $tplvar['TN_WIDTH']=$width; |
---|
50 | $tplvar['TN_HEIGHT']=$height; |
---|
51 | if (isset($config['thumbnail'])) |
---|
52 | { |
---|
53 | switch ($config['thumbnail']) |
---|
54 | { |
---|
55 | case 'generated': |
---|
56 | if (isset($tplvar['FILE_WIDTH'])) |
---|
57 | { |
---|
58 | $tplvar['TN_SRC']=PHPWG_THEMES_PATH."stripped_black_bloc/library/timthumb.php?src=".$tplvar['FILE_PATH']."&w=".$config['thumbnail_width']; |
---|
59 | } |
---|
60 | else |
---|
61 | { |
---|
62 | $tplvar['TN_SRC']=PHPWG_THEMES_PATH."stripped_black_bloc/library/timthumb.php?src=".$tplvar['TN_SRC']."&w=".$config['thumbnail_width']; |
---|
63 | } |
---|
64 | $tplvar['TN_HEIGHT']=floor($tplvar['TN_HEIGHT']*($config['thumbnail_width']/$tplvar['TN_WIDTH'])); |
---|
65 | $tplvar['TN_WIDTH']=$config['thumbnail_width']; |
---|
66 | break; |
---|
67 | case 'auto': |
---|
68 | if($tplvar['TN_WIDTH']<=$config['thumbnail_width']) |
---|
69 | { |
---|
70 | if (isset($tplvar['FILE_WIDTH'])) |
---|
71 | { |
---|
72 | $tplvar['TN_SRC']=PHPWG_THEMES_PATH."stripped_black_bloc/library/timthumb.php?src=".$tplvar['FILE_PATH']."&w=".$config['thumbnail_width']; |
---|
73 | } |
---|
74 | else |
---|
75 | { |
---|
76 | $tplvar['TN_SRC']=PHPWG_THEMES_PATH."stripped_black_bloc/library/timthumb.php?src=".$tplvar['TN_SRC']."&w=".$config['thumbnail_width']; |
---|
77 | } |
---|
78 | $tplvar['TN_HEIGHT']=floor($tplvar['TN_HEIGHT']*($config['thumbnail_width']/$tplvar['TN_WIDTH'])); |
---|
79 | $tplvar['TN_WIDTH']=$config['thumbnail_width']; |
---|
80 | } |
---|
81 | break; |
---|
82 | case 'piwigo':break; |
---|
83 | } |
---|
84 | } |
---|
85 | $new_tplvar[]=$tplvar; |
---|
86 | } |
---|
87 | return $new_tplvar; |
---|
88 | } |
---|
89 | add_event_handler('init', 'MY_init'); |
---|
90 | function MY_init() |
---|
91 | { |
---|
92 | remove_event_handler('loc_begin_index', 'modify_nb_thumbnail_page'); |
---|
93 | } |
---|
94 | |
---|
95 | /************************************ index.tpl ************************************/ |
---|
96 | add_event_handler('loc_end_index', 'stripped_black_bloc_index'); |
---|
97 | function stripped_black_bloc_index() |
---|
98 | { |
---|
99 | global $template; |
---|
100 | $template->set_prefilter('index', 'stripped_black_bloc_prefilter_index'); |
---|
101 | } |
---|
102 | function stripped_black_bloc_prefilter_index($content, &$smarty) |
---|
103 | { |
---|
104 | $search = '#Menu</span>#'; |
---|
105 | $replacement = "{'Show/hide menu'|@translate}</span>"; |
---|
106 | $content = preg_replace($search, $replacement, $content); |
---|
107 | $search = '#<div id="subcontent">#'; |
---|
108 | $replacement = ""; |
---|
109 | $content = preg_replace($search, $replacement, $content); |
---|
110 | $search = '#\{if \!empty\(\$CONTENT_DESCRIPTION\) \}#'; |
---|
111 | $replacement = ' <div id="subcontent"> |
---|
112 | |
---|
113 | {if !empty($CONTENT_DESCRIPTION) }'; |
---|
114 | $content = preg_replace($search, $replacement, $content); |
---|
115 | $search = '#\{if \!empty\(\$navbar\) \}[\s]*\{include file=\'navigation_bar\.tpl\'\|@get_extent:\'navbar\'\}[\s]*\{/if\}#'; |
---|
116 | $replacement = ''; |
---|
117 | $content = preg_replace($search, $replacement, $content); |
---|
118 | |
---|
119 | $search = '#<\!-- subContent -->#'; |
---|
120 | $replacement = '<!-- subContent --> |
---|
121 | {if !empty($navbar) } |
---|
122 | {include file=\'navigation_bar.tpl\'|@get_extent:\'navbar\'} |
---|
123 | {/if}'; |
---|
124 | return preg_replace($search, $replacement, $content); |
---|
125 | } |
---|
126 | |
---|
127 | ?> |
---|