[27034] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: Fotorama |
---|
[27148] | 4 | Version: 2.6.d |
---|
[27034] | 5 | Description: Fotorama based full-screen slideshow |
---|
| 6 | Author: JanisV |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | global $conf; |
---|
| 10 | |
---|
| 11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 12 | |
---|
| 13 | if (mobile_theme()) return; |
---|
| 14 | |
---|
[27148] | 15 | define('FOTORAMA_ID', basename(dirname(__FILE__))); |
---|
| 16 | define('FOTORAMA_PATH' , PHPWG_PLUGINS_PATH . FOTORAMA_ID . '/'); |
---|
| 17 | define('FOTORAMA_ADMIN', get_root_url() . 'admin.php?page=plugin-' . FOTORAMA_ID); |
---|
[27034] | 18 | |
---|
| 19 | add_event_handler('init', 'Fotorama_init'); |
---|
[27148] | 20 | if (defined('IN_ADMIN')) |
---|
| 21 | { |
---|
| 22 | add_event_handler('get_admin_plugin_menu_links', 'Fotorama_admin_menu'); |
---|
| 23 | } |
---|
[27034] | 24 | |
---|
| 25 | function Fotorama_init() |
---|
| 26 | { |
---|
[27148] | 27 | global $conf; |
---|
[27034] | 28 | |
---|
[27148] | 29 | load_language('plugin.lang', FOTORAMA_PATH); |
---|
| 30 | |
---|
| 31 | $conf['Fotorama'] = unserialize($conf['Fotorama']); |
---|
| 32 | |
---|
[27034] | 33 | add_event_handler('loc_end_picture', 'Fotorama_end_picture'); |
---|
| 34 | add_event_handler('loc_end_page_header', 'Fotorama_end_page_header'); |
---|
| 35 | } |
---|
[27148] | 36 | |
---|
[27034] | 37 | function Fotorama_end_picture() |
---|
| 38 | { |
---|
[27035] | 39 | global $template, $conf, $user, $page; |
---|
[27034] | 40 | |
---|
| 41 | if ($page['slideshow'] and $conf['light_slideshow']) |
---|
| 42 | { |
---|
| 43 | $query = ' |
---|
| 44 | SELECT * |
---|
| 45 | FROM '.IMAGES_TABLE.' |
---|
| 46 | WHERE id IN ('.implode(',', $page['items']).') |
---|
| 47 | ORDER BY FIELD(id, '.implode(',', $page['items']).') |
---|
| 48 | ;'; |
---|
| 49 | |
---|
| 50 | $result = pwg_query($query); |
---|
| 51 | |
---|
| 52 | $current = $template->get_template_vars('current'); |
---|
| 53 | $type = $current['selected_derivative']->get_type(); |
---|
| 54 | $defined = ImageStdParams::get_defined_type_map(); |
---|
| 55 | if (!isset($defined[$type])) |
---|
| 56 | { |
---|
| 57 | $type = pwg_get_session_var('picture_deriv', $conf['derivative_default_size']); |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | $skip = -1; |
---|
| 61 | $big_type = $type; |
---|
| 62 | foreach (ImageStdParams::get_defined_type_map() as $def_type => $params) |
---|
| 63 | { |
---|
| 64 | if ($def_type == $type) |
---|
| 65 | $skip = 2; |
---|
| 66 | if ($skip >= 0) |
---|
| 67 | $big_type = $def_type; |
---|
| 68 | if ($skip == 0) |
---|
| 69 | break; |
---|
| 70 | $skip = $skip - 1; |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | $picture = array(); |
---|
| 74 | while ($row = pwg_db_fetch_assoc($result)) |
---|
| 75 | { |
---|
| 76 | $row['src_image'] = new SrcImage($row); |
---|
| 77 | // $row['derivatives'] = DerivativeImage::get_all($row['src_image']); |
---|
| 78 | $row['derivative'] = DerivativeImage::get_one($type, $row['src_image']); |
---|
| 79 | if ($row['derivative'] == null) |
---|
| 80 | { |
---|
| 81 | $row['derivative'] = $row['src_image']; |
---|
| 82 | } |
---|
| 83 | $row['derivative_big'] = DerivativeImage::get_one($big_type, $row['src_image']); |
---|
| 84 | if ($row['derivative_big'] == null) |
---|
| 85 | { |
---|
| 86 | $row['derivative'] = $row['src_image']; |
---|
| 87 | } |
---|
[27039] | 88 | |
---|
[27034] | 89 | $row['url'] = duplicate_picture_url( |
---|
| 90 | array( |
---|
| 91 | 'image_id' => $row['id'], |
---|
| 92 | 'image_file' => $row['file'], |
---|
| 93 | ), |
---|
| 94 | array( |
---|
| 95 | 'start', |
---|
| 96 | ) |
---|
| 97 | ); |
---|
[27039] | 98 | |
---|
[27034] | 99 | $row['TITLE'] = render_element_name($row); |
---|
| 100 | $row['TITLE_ESC'] = str_replace('"', '"', $row['TITLE']); |
---|
| 101 | $picture[] = $row; |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | $template->assign('item_height', ImageStdParams::get_by_type($type)->max_height()); |
---|
| 105 | $template->assign('items', $picture); |
---|
| 106 | $template->assign('current_rank', $page['current_rank']); |
---|
[27148] | 107 | $template->assign(array('Fotorama' => $conf['Fotorama'])); |
---|
[27034] | 108 | $template->set_filenames( array('slideshow' => realpath(FOTORAMA_PATH.'template/slideshow.tpl'))); |
---|
| 109 | } |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | function Fotorama_end_page_header() |
---|
| 113 | { |
---|
[27035] | 114 | global $template, $conf, $page; |
---|
[27034] | 115 | |
---|
[27035] | 116 | if (isset($page['slideshow']) and $page['slideshow'] and $conf['light_slideshow']) |
---|
| 117 | { |
---|
| 118 | $template->clear_assign('page_refresh'); |
---|
| 119 | $template->clear_assign('first'); |
---|
| 120 | $template->clear_assign('previous'); |
---|
| 121 | $template->clear_assign('next'); |
---|
| 122 | $template->clear_assign('last'); |
---|
| 123 | } |
---|
[27034] | 124 | } |
---|
| 125 | |
---|
[27148] | 126 | function Fotorama_admin_menu($menu) |
---|
| 127 | { |
---|
| 128 | $menu[] = array( |
---|
| 129 | 'NAME' => 'Fotorama', |
---|
| 130 | 'URL' => FOTORAMA_ADMIN, |
---|
| 131 | ); |
---|
| 132 | |
---|
| 133 | return $menu; |
---|
| 134 | } |
---|
| 135 | |
---|
[27034] | 136 | ?> |
---|