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

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

Dynamic configuration page

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