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