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

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

use conf_update_param instead of custom insert query

File size: 4.1 KB
RevLine 
[7989]1<?php
2/*
3Theme Name: stripped
[12961]4Version: Auto
[7989]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
[12547]11global $conf, $user, $stripped;
[9987]12
13// Need upgrade?
14if (!isset($conf['stripped']))
15  include(PHPWG_THEMES_PATH.'stripped/admin/upgrade.inc.php');
16
[30457]17$conf['stripped'] = safe_unserialize($conf['stripped']);
18
19$stripped = array_merge($conf['stripped'], (array)$stripped );
[12321]20
[12547]21// Need upgrade from v1.x?
22if (!isset($stripped['themeStyle'])) {
23        include(PHPWG_THEMES_PATH.'stripped/admin/upgrade.inc.php');
[30457]24        $stripped = array_merge($conf['stripped'], (array)$stripped );
[12547]25}
26
[12960]27// Need upgrade from v2.x?
28if (!isset($stripped['paramVersion'])) {
29        include(PHPWG_THEMES_PATH.'stripped/admin/upgrade.inc.php');
[30457]30        $stripped = array_merge($conf['stripped'], (array)$stripped );
[12960]31}
32
[17961]33// Need upgrade from v2.1 or v2.2?
34if ((isset($stripped['paramVersion'])) && ($stripped['paramVersion'] != '2.3')) {
[14687]35        include(PHPWG_THEMES_PATH.'stripped/admin/upgrade.inc.php');
[30457]36        $stripped = array_merge($conf['stripped'], (array)$stripped );
[14687]37}
38
[9960]39
[23538]40add_event_handler('init', 'set_config_values');
[9960]41function set_config_values()
42{
[23538]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                         ));
[9960]52}
53       
[7989]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',
[21216]61  'img_dir'      => 'themes/stripped/images',
[7989]62  'admin_icon_dir' => 'themes/default/icon/admin',
63  'mime_icon_dir' => 'themes/default/icon/mimetypes/',
64  'local_head' => 'local_head.tpl',
[29391]65  'colorscheme' => 'white' == $stripped['themeStyle'] ? 'clear' : 'dark',
[7989]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{
[12547]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'];
[7989]82}
83
[14481]84// Preload function
85
[12321]86if (isset($stripped['imagePreload']) && ($user['theme'] == 'stripped')) {
[12153]87        add_event_handler('loc_end_picture', 'assign_next_images_url');
[12321]88}
[12153]89
[12321]90function assign_next_images_url()
91{
92        global $page, $template, $conf, $stripped;
[12153]93
[12321]94        $nb_image =$stripped['imagePreloadNb'];
95        $nb_max = $page['last_rank'] - $page['current_rank'];
96        $nb_image = min ($nb_image, $nb_max);
[12153]97
[12321]98        if ($nb_image < 1) return;
[12153]99
[12321]100        for ($n = 1; $n <= $nb_image; $n++) {
101                $pagenext[$n] = $page['items'][ $page['current_rank'] + $n ];
102        }
[12153]103
[12321]104        $picturenext = array();
105        $idnext = array();
[12153]106
[12321]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        {
[12153]121                for ($n = 1; $n <= $nb_image; $n++) {
[12321]122                        if (isset($pagenext[$n]) and $rownext['id'] == $pagenext[$n]) {$in = $n;}
[12153]123                }
124
[12321]125                $picturenext[$in] = $rownext;
[12153]126
[14690]127                $derivative = new DerivativeImage($stripped['imageSize'], new SrcImage($rownext));
128                $picturenext[$in]['image_url'] = $derivative->get_url();
[12321]129        }
[12153]130
[12321]131        for ($n = 1; $n <= $nb_image; $n++) {
132                if (isset($picturenext[$n]['image_url'])) { $image_next[$n] = $picturenext[$n]['image_url']; }
[12153]133        }
[12321]134 
135  $template->assign('U_IMGNEXT', $image_next );
[12153]136
137}
138
[7989]139?>
Note: See TracBrowser for help on using the repository browser.