[7989] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Theme Name: stripped |
---|
[10930] | 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 | |
---|
[9960] | 25 | add_event_handler('loc_begin_page_header', 'set_config_values'); |
---|
| 26 | |
---|
| 27 | function set_config_values() |
---|
| 28 | { |
---|
[12321] | 29 | global $template, $stripped; |
---|
| 30 | $template->assign( 'stripped', $stripped ); |
---|
[9960] | 31 | } |
---|
| 32 | |
---|
[7989] | 33 | $themeconf = array( |
---|
| 34 | 'parent' => 'default', |
---|
| 35 | 'load_parent_css' => false, |
---|
| 36 | 'load_parent_local_head' => false, |
---|
| 37 | 'name' => 'stripped', |
---|
| 38 | 'theme_dir' => 'stripped', |
---|
| 39 | 'icon_dir' => 'themes/stripped/icon', |
---|
| 40 | 'admin_icon_dir' => 'themes/default/icon/admin', |
---|
| 41 | 'mime_icon_dir' => 'themes/default/icon/mimetypes/', |
---|
| 42 | 'local_head' => 'local_head.tpl', |
---|
| 43 | ); |
---|
| 44 | |
---|
| 45 | load_language('theme.lang', PHPWG_THEMES_PATH.'stripped/'); |
---|
| 46 | |
---|
| 47 | pwg_set_session_var('show_metadata', true); |
---|
| 48 | |
---|
| 49 | // max number of thumbnails by page |
---|
| 50 | |
---|
| 51 | add_event_handler('loc_begin_index', 'modify_nb_thumbnail_page'); |
---|
| 52 | function modify_nb_thumbnail_page() |
---|
| 53 | { |
---|
[12547] | 54 | global $user, $page, $stripped; |
---|
| 55 | |
---|
| 56 | if (!isset($stripped['maxThumb'])) { $stripped['maxThumb']=15;} |
---|
| 57 | $user['nb_image_page']=$stripped['maxThumb']; |
---|
| 58 | $page['nb_image_page']=$stripped['maxThumb']; |
---|
[7989] | 59 | } |
---|
| 60 | |
---|
[12321] | 61 | if (isset($stripped['imagePreload']) && ($user['theme'] == 'stripped')) { |
---|
[12153] | 62 | add_event_handler('loc_end_picture', 'assign_next_images_url'); |
---|
[12321] | 63 | } |
---|
[12153] | 64 | |
---|
[12321] | 65 | function assign_next_images_url() |
---|
| 66 | { |
---|
| 67 | global $page, $template, $conf, $stripped; |
---|
[12153] | 68 | |
---|
[12321] | 69 | $nb_image =$stripped['imagePreloadNb']; |
---|
| 70 | $nb_max = $page['last_rank'] - $page['current_rank']; |
---|
| 71 | $nb_image = min ($nb_image, $nb_max); |
---|
[12153] | 72 | |
---|
[12321] | 73 | if ($nb_image < 1) return; |
---|
[12153] | 74 | |
---|
[12321] | 75 | for ($n = 1; $n <= $nb_image; $n++) { |
---|
| 76 | $pagenext[$n] = $page['items'][ $page['current_rank'] + $n ]; |
---|
| 77 | } |
---|
[12153] | 78 | |
---|
[12321] | 79 | $picturenext = array(); |
---|
| 80 | $idnext = array(); |
---|
[12153] | 81 | |
---|
[12321] | 82 | for ($n = 1; $n <= $nb_image; $n++) { |
---|
| 83 | array_push($idnext, $pagenext[$n]); |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | $query = ' |
---|
| 87 | SELECT * |
---|
| 88 | FROM '.IMAGES_TABLE.' |
---|
| 89 | WHERE id IN ('.implode(',', $idnext).') |
---|
| 90 | ;'; |
---|
| 91 | |
---|
| 92 | $result = pwg_query($query); |
---|
| 93 | |
---|
| 94 | while ($rownext = pwg_db_fetch_assoc($result)) |
---|
| 95 | { |
---|
[12153] | 96 | for ($n = 1; $n <= $nb_image; $n++) { |
---|
[12321] | 97 | if (isset($pagenext[$n]) and $rownext['id'] == $pagenext[$n]) {$in = $n;} |
---|
[12153] | 98 | } |
---|
| 99 | |
---|
[12321] | 100 | $picturenext[$in] = $rownext; |
---|
| 101 | $picturenext[$in]['is_picture'] = false; |
---|
[12153] | 102 | |
---|
[12321] | 103 | if (in_array(get_extension($rownext['file']), $conf['picture_ext'])) |
---|
[12153] | 104 | { |
---|
[12321] | 105 | $picturenext[$in]['is_picture'] = true; |
---|
[12153] | 106 | } |
---|
| 107 | |
---|
[12321] | 108 | $picturenext[$in]['image_url'] = get_image_url( $picturenext[$in] ); |
---|
| 109 | } |
---|
[12153] | 110 | |
---|
[12321] | 111 | for ($n = 1; $n <= $nb_image; $n++) { |
---|
| 112 | if (isset($picturenext[$n]['image_url'])) { $image_next[$n] = $picturenext[$n]['image_url']; } |
---|
[12153] | 113 | } |
---|
[12321] | 114 | |
---|
| 115 | $template->assign('U_IMGNEXT', $image_next ); |
---|
[12153] | 116 | |
---|
| 117 | } |
---|
| 118 | |
---|
[12321] | 119 | |
---|
[7989] | 120 | ?> |
---|