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