source: extensions/Fotorama/main.inc.php @ 27035

Last change on this file since 27035 was 27035, checked in by JanisV, 10 years ago

Fixed clearing data for non-slideshow pages

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