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

Last change on this file since 31946 was 30457, checked in by plg, 9 years ago

use conf_update_param instead of custom insert query

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