[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 | add_event_handler('loc_begin_page_header', 'set_config_values'); |
---|
| 38 | |
---|
| 39 | function set_config_values() |
---|
| 40 | { |
---|
[12321] | 41 | global $template, $stripped; |
---|
| 42 | $template->assign( 'stripped', $stripped ); |
---|
[9960] | 43 | } |
---|
| 44 | |
---|
[7989] | 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 | |
---|
| 57 | load_language('theme.lang', PHPWG_THEMES_PATH.'stripped/'); |
---|
| 58 | |
---|
| 59 | pwg_set_session_var('show_metadata', true); |
---|
| 60 | |
---|
| 61 | // max number of thumbnails by page |
---|
| 62 | |
---|
| 63 | add_event_handler('loc_begin_index', 'modify_nb_thumbnail_page'); |
---|
| 64 | function modify_nb_thumbnail_page() |
---|
| 65 | { |
---|
[12547] | 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']; |
---|
[7989] | 71 | } |
---|
| 72 | |
---|
[14481] | 73 | // Preload function |
---|
| 74 | |
---|
[12321] | 75 | if (isset($stripped['imagePreload']) && ($user['theme'] == 'stripped')) { |
---|
[12153] | 76 | add_event_handler('loc_end_picture', 'assign_next_images_url'); |
---|
[12321] | 77 | } |
---|
[12153] | 78 | |
---|
[12321] | 79 | function assign_next_images_url() |
---|
| 80 | { |
---|
| 81 | global $page, $template, $conf, $stripped; |
---|
[12153] | 82 | |
---|
[12321] | 83 | $nb_image =$stripped['imagePreloadNb']; |
---|
| 84 | $nb_max = $page['last_rank'] - $page['current_rank']; |
---|
| 85 | $nb_image = min ($nb_image, $nb_max); |
---|
[12153] | 86 | |
---|
[12321] | 87 | if ($nb_image < 1) return; |
---|
[12153] | 88 | |
---|
[12321] | 89 | for ($n = 1; $n <= $nb_image; $n++) { |
---|
| 90 | $pagenext[$n] = $page['items'][ $page['current_rank'] + $n ]; |
---|
| 91 | } |
---|
[12153] | 92 | |
---|
[12321] | 93 | $picturenext = array(); |
---|
| 94 | $idnext = array(); |
---|
[12153] | 95 | |
---|
[12321] | 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 | { |
---|
[12153] | 110 | for ($n = 1; $n <= $nb_image; $n++) { |
---|
[12321] | 111 | if (isset($pagenext[$n]) and $rownext['id'] == $pagenext[$n]) {$in = $n;} |
---|
[12153] | 112 | } |
---|
| 113 | |
---|
[12321] | 114 | $picturenext[$in] = $rownext; |
---|
[12153] | 115 | |
---|
[14690] | 116 | $derivative = new DerivativeImage($stripped['imageSize'], new SrcImage($rownext)); |
---|
| 117 | $picturenext[$in]['image_url'] = $derivative->get_url(); |
---|
[12321] | 118 | } |
---|
[12153] | 119 | |
---|
[12321] | 120 | for ($n = 1; $n <= $nb_image; $n++) { |
---|
| 121 | if (isset($picturenext[$n]['image_url'])) { $image_next[$n] = $picturenext[$n]['image_url']; } |
---|
[12153] | 122 | } |
---|
[12321] | 123 | |
---|
| 124 | $template->assign('U_IMGNEXT', $image_next ); |
---|
[12153] | 125 | |
---|
| 126 | } |
---|
| 127 | |
---|
[7989] | 128 | ?> |
---|