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