1 | <?php |
---|
2 | /* |
---|
3 | Theme Name: stripped |
---|
4 | Version: Auto |
---|
5 | Description: stripped Theme |
---|
6 | Theme URI: http://piwigo.org/ext/extension_view.php?eid=471 |
---|
7 | Author: Julien Capitaine (Zaphod on Piwigo forums) |
---|
8 | Author URI: http://www.audreyetjulien.fr/galerie |
---|
9 | */ |
---|
10 | |
---|
11 | global $conf, $user, $stripped; |
---|
12 | |
---|
13 | // Need upgrade? |
---|
14 | if (!isset($conf['stripped'])) |
---|
15 | include(PHPWG_THEMES_PATH.'stripped/admin/upgrade.inc.php'); |
---|
16 | |
---|
17 | $stripped = array_merge( unserialize( $conf['stripped'] ), (array)$stripped ); |
---|
18 | |
---|
19 | // Need upgrade from v1.x? |
---|
20 | if (!isset($stripped['themeStyle'])) { |
---|
21 | include(PHPWG_THEMES_PATH.'stripped/admin/upgrade.inc.php'); |
---|
22 | $stripped = array_merge( unserialize( $conf['stripped'] ), (array)$stripped ); |
---|
23 | } |
---|
24 | |
---|
25 | // Need upgrade from v2.x? |
---|
26 | if (!isset($stripped['paramVersion'])) { |
---|
27 | include(PHPWG_THEMES_PATH.'stripped/admin/upgrade.inc.php'); |
---|
28 | $stripped = array_merge( unserialize( $conf['stripped'] ), (array)$stripped ); |
---|
29 | } |
---|
30 | |
---|
31 | // Need upgrade from v2.1 or v2.2? |
---|
32 | if ((isset($stripped['paramVersion'])) && ($stripped['paramVersion'] != '2.3')) { |
---|
33 | include(PHPWG_THEMES_PATH.'stripped/admin/upgrade.inc.php'); |
---|
34 | $stripped = array_merge( unserialize( $conf['stripped'] ), (array)$stripped ); |
---|
35 | } |
---|
36 | |
---|
37 | |
---|
38 | add_event_handler('init', 'set_config_values'); |
---|
39 | function set_config_values() |
---|
40 | { |
---|
41 | global $template, $pwg_loaded_plugins, $stripped; |
---|
42 | $template->assign(array( |
---|
43 | 'automatic_size_enabled'=> isset($pwg_loaded_plugins['automatic_size']), |
---|
44 | 'HDShadowbox_loaded'=> isset($pwg_loaded_plugins['HDShadowbox']), |
---|
45 | 'GMaps_loaded'=> isset($pwg_loaded_plugins['GMaps']), |
---|
46 | 'ThumbScroller_loaded'=> isset($pwg_loaded_plugins[ 'rv_tscroller' ]), |
---|
47 | 'usertags'=> isset($pwg_loaded_plugins['user_tags']), |
---|
48 | 'stripped'=> $stripped |
---|
49 | )); |
---|
50 | } |
---|
51 | |
---|
52 | $themeconf = array( |
---|
53 | 'parent' => 'default', |
---|
54 | 'load_parent_css' => false, |
---|
55 | 'load_parent_local_head' => false, |
---|
56 | 'name' => 'stripped', |
---|
57 | 'theme_dir' => 'stripped', |
---|
58 | 'icon_dir' => 'themes/stripped/icon', |
---|
59 | 'img_dir' => 'themes/stripped/images', |
---|
60 | 'admin_icon_dir' => 'themes/default/icon/admin', |
---|
61 | 'mime_icon_dir' => 'themes/default/icon/mimetypes/', |
---|
62 | 'local_head' => 'local_head.tpl', |
---|
63 | 'colorscheme' => 'white' == $stripped['themeStyle'] ? 'clear' : 'dark', |
---|
64 | ); |
---|
65 | |
---|
66 | load_language('theme.lang', PHPWG_THEMES_PATH.'stripped/'); |
---|
67 | |
---|
68 | pwg_set_session_var('show_metadata', true); |
---|
69 | |
---|
70 | // max number of thumbnails by page |
---|
71 | |
---|
72 | add_event_handler('loc_begin_index', 'modify_nb_thumbnail_page'); |
---|
73 | function modify_nb_thumbnail_page() |
---|
74 | { |
---|
75 | global $user, $page, $stripped; |
---|
76 | |
---|
77 | if (!isset($stripped['maxThumb'])) { $stripped['maxThumb']=15;} |
---|
78 | $user['nb_image_page']=$stripped['maxThumb']; |
---|
79 | $page['nb_image_page']=$stripped['maxThumb']; |
---|
80 | } |
---|
81 | |
---|
82 | // Preload function |
---|
83 | |
---|
84 | if (isset($stripped['imagePreload']) && ($user['theme'] == 'stripped')) { |
---|
85 | add_event_handler('loc_end_picture', 'assign_next_images_url'); |
---|
86 | } |
---|
87 | |
---|
88 | function assign_next_images_url() |
---|
89 | { |
---|
90 | global $page, $template, $conf, $stripped; |
---|
91 | |
---|
92 | $nb_image =$stripped['imagePreloadNb']; |
---|
93 | $nb_max = $page['last_rank'] - $page['current_rank']; |
---|
94 | $nb_image = min ($nb_image, $nb_max); |
---|
95 | |
---|
96 | if ($nb_image < 1) return; |
---|
97 | |
---|
98 | for ($n = 1; $n <= $nb_image; $n++) { |
---|
99 | $pagenext[$n] = $page['items'][ $page['current_rank'] + $n ]; |
---|
100 | } |
---|
101 | |
---|
102 | $picturenext = array(); |
---|
103 | $idnext = array(); |
---|
104 | |
---|
105 | for ($n = 1; $n <= $nb_image; $n++) { |
---|
106 | array_push($idnext, $pagenext[$n]); |
---|
107 | } |
---|
108 | |
---|
109 | $query = ' |
---|
110 | SELECT * |
---|
111 | FROM '.IMAGES_TABLE.' |
---|
112 | WHERE id IN ('.implode(',', $idnext).') |
---|
113 | ;'; |
---|
114 | |
---|
115 | $result = pwg_query($query); |
---|
116 | |
---|
117 | while ($rownext = pwg_db_fetch_assoc($result)) |
---|
118 | { |
---|
119 | for ($n = 1; $n <= $nb_image; $n++) { |
---|
120 | if (isset($pagenext[$n]) and $rownext['id'] == $pagenext[$n]) {$in = $n;} |
---|
121 | } |
---|
122 | |
---|
123 | $picturenext[$in] = $rownext; |
---|
124 | |
---|
125 | $derivative = new DerivativeImage($stripped['imageSize'], new SrcImage($rownext)); |
---|
126 | $picturenext[$in]['image_url'] = $derivative->get_url(); |
---|
127 | } |
---|
128 | |
---|
129 | for ($n = 1; $n <= $nb_image; $n++) { |
---|
130 | if (isset($picturenext[$n]['image_url'])) { $image_next[$n] = $picturenext[$n]['image_url']; } |
---|
131 | } |
---|
132 | |
---|
133 | $template->assign('U_IMGNEXT', $image_next ); |
---|
134 | |
---|
135 | } |
---|
136 | |
---|
137 | ?> |
---|