source: extensions/rotateImage/admin.php @ 20479

Last change on this file since 20479 was 16981, checked in by plg, 12 years ago

Insert a new tab "Rotate" on the photo administration screen (requires Piwigo 2.4.2)

File size: 4.7 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2011 Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24if( !defined("PHPWG_ROOT_PATH") )
25{
26  die ("Hacking attempt!");
27}
28
29include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
30include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
31include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php');
32include_once(dirname(__FILE__).'/functions.inc.php');
33
34// +-----------------------------------------------------------------------+
35// | Check Access and exit when user status is not ok                      |
36// +-----------------------------------------------------------------------+
37
38check_status(ACCESS_ADMINISTRATOR);
39
40// +-----------------------------------------------------------------------+
41// | Basic checks                                                          |
42// +-----------------------------------------------------------------------+
43
44$_GET['image_id'] = $_GET['tab'];
45
46check_input_parameter('image_id', $_GET, false, PATTERN_ID);
47
48$admin_photo_base_url = get_root_url().'admin.php?page=photo-'.$_GET['image_id'];
49
50// +-----------------------------------------------------------------------+
51// | Process form                                                          |
52// +-----------------------------------------------------------------------+
53
54load_language('plugin.lang', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
55 
56if (isset($_POST['rotate']))
57{
58  check_pwg_token();
59
60  $rotate_hd = false;
61  if (isset($_POST['rotate_hd']))
62  {
63    $rotate_hd = true;
64  }
65
66  rotate_image($_GET['image_id'], $rotate_hd, $_POST['angle']);
67
68  array_push(
69    $page['infos'],
70    l10n('The photo was updated')
71    );
72}
73
74// +-----------------------------------------------------------------------+
75// | Tabs                                                                  |
76// +-----------------------------------------------------------------------+
77
78$tabsheet = new tabsheet();
79$tabsheet->set_id('photo');
80$tabsheet->select('rotate');
81$tabsheet->assign();
82
83// +-----------------------------------------------------------------------+
84// |                             template init                             |
85// +-----------------------------------------------------------------------+
86
87$template->set_filenames(
88  array(
89    'plugin_admin_content' => dirname(__FILE__).'/admin.tpl'
90    )
91  );
92
93// retrieving direct information about picture
94$query = '
95SELECT *
96  FROM '.IMAGES_TABLE.'
97  WHERE id = '.$_GET['image_id'].'
98;';
99$row = pwg_db_fetch_assoc(pwg_query($query));
100
101$angles = array(
102  array('value' => 270, 'name' => l10n('90° right')),
103  array('value' =>  90, 'name' => l10n('90° left')),
104  array('value' => 180, 'name' => l10n('180°'))
105);
106
107$template->assign(
108  array(
109    'TN_SRC' => DerivativeImage::thumb_url($row),
110    'TITLE' => render_element_name($row),
111    'angles' => $angles,
112    'angle_selected' => 90,
113    'library' => pwg_image::get_library(),
114    'PWG_TOKEN' => get_pwg_token(),
115    )
116  );
117
118// +-----------------------------------------------------------------------+
119// | sending html code                                                     |
120// +-----------------------------------------------------------------------+
121
122$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
123?>
Note: See TracBrowser for help on using the repository browser.