source: trunk/admin/picture_coi.php @ 13038

Revision 13038, 3.6 KB checked in by rvelices, 8 years ago (diff)

multisize - added the coi (still to affine the admin ui + language)
multisize - derivatives can be revuild from a larger derviative instead of the original

Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2012 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
29// +-----------------------------------------------------------------------+
30// | Check Access and exit when user status is not ok                      |
31// +-----------------------------------------------------------------------+
32check_status(ACCESS_ADMINISTRATOR);
33
34check_input_parameter('image_id', $_GET, false, PATTERN_ID);
35
36if (isset($_POST['submit']))
37{
38  $query = 'UPDATE '.IMAGES_TABLE;
39  if (strlen($_POST['l'])==0)
40  {
41    $query .= ' SET coi=NULL';
42  }
43  else
44  {
45    $coi = fraction_to_char($_POST['l'])
46      .fraction_to_char($_POST['t'])
47      .fraction_to_char($_POST['r'])
48      .fraction_to_char($_POST['b']);
49    $query .= ' SET coi=\''.$coi.'\'';
50  }
51  $query .= ' WHERE id='.$_GET['image_id'];
52  pwg_query($query);
53}
54
55$query = 'SELECT * FROM '.IMAGES_TABLE.' WHERE id='.$_GET['image_id'];
56$row = pwg_db_fetch_assoc( pwg_query($query) );
57
58if (isset($_POST['submit']))
59{
60  delete_element_derivatives($row);
61}
62
63$tpl_var = array(
64  'ALT' => $row['file'],
65  'U_IMG' => DerivativeImage::url(IMG_LARGE, $row),
66  'U_EDIT' => get_root_url().'admin.php?page=picture_modify&amp;image_id='.$_GET['image_id'],
67  );
68
69if (!empty($row['coi']))
70{
71  $tpl_var['coi'] = array(
72    'l'=> char_to_fraction($row['coi'][0]),
73    't'=> char_to_fraction($row['coi'][1]),
74    'r'=> char_to_fraction($row['coi'][2]),
75    'b'=> char_to_fraction($row['coi'][3]),
76  );
77}
78
79if (isset($_POST['submit']))
80{
81  $uid = '&b='.time();
82  $conf['question_mark_in_urls'] = $conf['php_extension_in_urls'] = true;
83  $conf['derivative_url_style']=2; //script
84  $tpl_var['U_SQUARE'] = DerivativeImage::url(IMG_SQUARE, $row).$uid;
85  $tpl_var['U_THUMB'] = DerivativeImage::url(IMG_THUMB, $row).$uid;
86}
87else
88{
89  $tpl_var['U_SQUARE'] = DerivativeImage::url(IMG_SQUARE, $row);
90  $tpl_var['U_THUMB'] = DerivativeImage::url(IMG_THUMB, $row);
91}
92
93$template->assign($tpl_var);
94$template->set_filename('picture_coi', 'picture_coi.tpl');
95
96$template->assign_var_from_handle('ADMIN_CONTENT', 'picture_coi');
97?>
Note: See TracBrowser for help on using the repository browser.