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 | add_event_handler('loc_begin_page_header', 'set_config_values'); |
---|
38 | |
---|
39 | function set_config_values() |
---|
40 | { |
---|
41 | global $template, $stripped; |
---|
42 | $template->assign( 'stripped', $stripped ); |
---|
43 | } |
---|
44 | |
---|
45 | $themeconf = array( |
---|
46 | 'parent' => 'default', |
---|
47 | 'load_parent_css' => false, |
---|
48 | 'load_parent_local_head' => false, |
---|
49 | 'name' => 'stripped', |
---|
50 | 'theme_dir' => 'stripped', |
---|
51 | 'icon_dir' => 'themes/stripped/icon', |
---|
52 | 'img_dir' => 'themes/stripped/images', |
---|
53 | 'admin_icon_dir' => 'themes/default/icon/admin', |
---|
54 | 'mime_icon_dir' => 'themes/default/icon/mimetypes/', |
---|
55 | 'local_head' => 'local_head.tpl', |
---|
56 | ); |
---|
57 | |
---|
58 | load_language('theme.lang', PHPWG_THEMES_PATH.'stripped/'); |
---|
59 | |
---|
60 | pwg_set_session_var('show_metadata', true); |
---|
61 | |
---|
62 | // max number of thumbnails by page |
---|
63 | |
---|
64 | add_event_handler('loc_begin_index', 'modify_nb_thumbnail_page'); |
---|
65 | function modify_nb_thumbnail_page() |
---|
66 | { |
---|
67 | global $user, $page, $stripped; |
---|
68 | |
---|
69 | if (!isset($stripped['maxThumb'])) { $stripped['maxThumb']=15;} |
---|
70 | $user['nb_image_page']=$stripped['maxThumb']; |
---|
71 | $page['nb_image_page']=$stripped['maxThumb']; |
---|
72 | } |
---|
73 | |
---|
74 | // Preload function |
---|
75 | |
---|
76 | if (isset($stripped['imagePreload']) && ($user['theme'] == 'stripped')) { |
---|
77 | add_event_handler('loc_end_picture', 'assign_next_images_url'); |
---|
78 | } |
---|
79 | |
---|
80 | function assign_next_images_url() |
---|
81 | { |
---|
82 | global $page, $template, $conf, $stripped; |
---|
83 | |
---|
84 | $nb_image =$stripped['imagePreloadNb']; |
---|
85 | $nb_max = $page['last_rank'] - $page['current_rank']; |
---|
86 | $nb_image = min ($nb_image, $nb_max); |
---|
87 | |
---|
88 | if ($nb_image < 1) return; |
---|
89 | |
---|
90 | for ($n = 1; $n <= $nb_image; $n++) { |
---|
91 | $pagenext[$n] = $page['items'][ $page['current_rank'] + $n ]; |
---|
92 | } |
---|
93 | |
---|
94 | $picturenext = array(); |
---|
95 | $idnext = array(); |
---|
96 | |
---|
97 | for ($n = 1; $n <= $nb_image; $n++) { |
---|
98 | array_push($idnext, $pagenext[$n]); |
---|
99 | } |
---|
100 | |
---|
101 | $query = ' |
---|
102 | SELECT * |
---|
103 | FROM '.IMAGES_TABLE.' |
---|
104 | WHERE id IN ('.implode(',', $idnext).') |
---|
105 | ;'; |
---|
106 | |
---|
107 | $result = pwg_query($query); |
---|
108 | |
---|
109 | while ($rownext = pwg_db_fetch_assoc($result)) |
---|
110 | { |
---|
111 | for ($n = 1; $n <= $nb_image; $n++) { |
---|
112 | if (isset($pagenext[$n]) and $rownext['id'] == $pagenext[$n]) {$in = $n;} |
---|
113 | } |
---|
114 | |
---|
115 | $picturenext[$in] = $rownext; |
---|
116 | |
---|
117 | $derivative = new DerivativeImage($stripped['imageSize'], new SrcImage($rownext)); |
---|
118 | $picturenext[$in]['image_url'] = $derivative->get_url(); |
---|
119 | } |
---|
120 | |
---|
121 | for ($n = 1; $n <= $nb_image; $n++) { |
---|
122 | if (isset($picturenext[$n]['image_url'])) { $image_next[$n] = $picturenext[$n]['image_url']; } |
---|
123 | } |
---|
124 | |
---|
125 | $template->assign('U_IMGNEXT', $image_next ); |
---|
126 | |
---|
127 | } |
---|
128 | |
---|
129 | ?> |
---|