source: extensions/stripped/themeconf.inc.php @ 20351

Last change on this file since 20351 was 17961, checked in by Zaphod, 12 years ago

version 2.3.0

File size: 3.5 KB
Line 
1<?php
2/*
3Theme Name: stripped
4Version: Auto
5Description: stripped Theme
6Theme URI: http://piwigo.org/ext/extension_view.php?eid=471
7Author: Julien Capitaine (Zaphod on Piwigo forums)
8Author URI: http://www.audreyetjulien.fr/galerie
9*/
10
11global $conf, $user, $stripped;
12
13// Need upgrade?
14if (!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?
20if (!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?
26if (!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?
32if ((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
37add_event_handler('loc_begin_page_header', 'set_config_values');
38
39function 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  'admin_icon_dir' => 'themes/default/icon/admin',
53  'mime_icon_dir' => 'themes/default/icon/mimetypes/',
54  'local_head' => 'local_head.tpl',
55);
56
57load_language('theme.lang', PHPWG_THEMES_PATH.'stripped/');
58
59pwg_set_session_var('show_metadata', true);
60
61// max number of thumbnails by page
62
63add_event_handler('loc_begin_index', 'modify_nb_thumbnail_page');
64function modify_nb_thumbnail_page()
65{
66        global $user, $page, $stripped;
67
68        if (!isset($stripped['maxThumb'])) { $stripped['maxThumb']=15;}
69        $user['nb_image_page']=$stripped['maxThumb'];
70        $page['nb_image_page']=$stripped['maxThumb'];
71}
72
73// Preload function
74
75if (isset($stripped['imagePreload']) && ($user['theme'] == 'stripped')) {
76        add_event_handler('loc_end_picture', 'assign_next_images_url');
77}
78
79function assign_next_images_url()
80{
81        global $page, $template, $conf, $stripped;
82
83        $nb_image =$stripped['imagePreloadNb'];
84        $nb_max = $page['last_rank'] - $page['current_rank'];
85        $nb_image = min ($nb_image, $nb_max);
86
87        if ($nb_image < 1) return;
88
89        for ($n = 1; $n <= $nb_image; $n++) {
90                $pagenext[$n] = $page['items'][ $page['current_rank'] + $n ];
91        }
92
93        $picturenext = array();
94        $idnext = array();
95
96        for ($n = 1; $n <= $nb_image; $n++) {
97                array_push($idnext, $pagenext[$n]);
98        }
99
100        $query = '
101        SELECT *
102          FROM '.IMAGES_TABLE.'
103          WHERE id IN ('.implode(',', $idnext).')
104        ;';
105
106        $result = pwg_query($query);
107
108        while ($rownext = pwg_db_fetch_assoc($result))
109        {
110                for ($n = 1; $n <= $nb_image; $n++) {
111                        if (isset($pagenext[$n]) and $rownext['id'] == $pagenext[$n]) {$in = $n;}
112                }
113
114                $picturenext[$in] = $rownext;
115
116                $derivative = new DerivativeImage($stripped['imageSize'], new SrcImage($rownext));
117                $picturenext[$in]['image_url'] = $derivative->get_url();
118        }
119
120        for ($n = 1; $n <= $nb_image; $n++) {
121                if (isset($picturenext[$n]['image_url'])) { $image_next[$n] = $picturenext[$n]['image_url']; }
122        }
123 
124  $template->assign('U_IMGNEXT', $image_next );
125
126}
127
128?>
Note: See TracBrowser for help on using the repository browser.