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