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

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

Added basic customization

File size: 3.5 KB
Line 
1<?php
2/*
3Plugin Name: Fotorama
4Version: 2.6.d
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_ID',       basename(dirname(__FILE__)));
16define('FOTORAMA_PATH' ,    PHPWG_PLUGINS_PATH . FOTORAMA_ID . '/');
17define('FOTORAMA_ADMIN',    get_root_url() . 'admin.php?page=plugin-' . FOTORAMA_ID);
18
19add_event_handler('init', 'Fotorama_init');
20if (defined('IN_ADMIN'))
21{
22  add_event_handler('get_admin_plugin_menu_links', 'Fotorama_admin_menu');
23} 
24
25function Fotorama_init()
26{
27  global $conf;
28 
29  load_language('plugin.lang', FOTORAMA_PATH);
30
31  $conf['Fotorama'] = unserialize($conf['Fotorama']);
32
33  add_event_handler('loc_end_picture', 'Fotorama_end_picture');
34  add_event_handler('loc_end_page_header', 'Fotorama_end_page_header');
35}
36
37function Fotorama_end_picture()
38{
39  global $template, $conf, $user, $page;
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      }
88
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        );
98
99      $row['TITLE'] = render_element_name($row);
100      $row['TITLE_ESC'] = str_replace('"', '&quot;', $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']);
107    $template->assign(array('Fotorama' => $conf['Fotorama']));
108    $template->set_filenames( array('slideshow' => realpath(FOTORAMA_PATH.'template/slideshow.tpl')));
109  }
110}
111
112function Fotorama_end_page_header()
113{
114  global $template, $conf, $page;
115
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  }
124}
125
126function Fotorama_admin_menu($menu)
127{
128  $menu[] = array(
129    'NAME' => 'Fotorama',
130    'URL'  => FOTORAMA_ADMIN,
131  );
132
133  return $menu;
134}
135
136?>
Note: See TracBrowser for help on using the repository browser.