source: trunk/admin/thumbnail.php @ 12748

Last change on this file since 12748 was 10653, checked in by patdenice, 13 years ago

Insert upload form parameters in database during installation.
Remove prepare_upload_configuration function.

  • Property svn:eol-style set to LF
File size: 5.0 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo 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
24include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
25include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
26
27check_status(ACCESS_ADMINISTRATOR);
28
29// +-----------------------------------------------------------------------+
30// |                          Load configuration                           |
31// +-----------------------------------------------------------------------+
32$upload_form_config = get_upload_form_config();
33
34$form_values = array();
35
36foreach ($upload_form_config as $param_shortname => $param)
37{
38  $param_name = 'upload_form_'.$param_shortname;
39  $form_values[$param_shortname] = $conf[$param_name];
40}
41
42// +-----------------------------------------------------------------------+
43// |                   search pictures without thumbnails                  |
44// +-----------------------------------------------------------------------+
45$wo_thumbnails = array();
46
47// what is the directory to search in ?
48$query = '
49SELECT galleries_url FROM '.SITES_TABLE.'
50  WHERE galleries_url NOT LIKE \'http://%\'
51;';
52$result = pwg_query($query);
53while ( $row=pwg_db_fetch_assoc($result) )
54{
55  $basedir = preg_replace('#/*$#', '', $row['galleries_url']);
56  $fs = get_fs($basedir);
57
58  // because isset is one hundred time faster than in_array
59  $fs['thumbnails'] = array_flip($fs['thumbnails']);
60
61  foreach ($fs['elements'] as $path)
62  {
63    // only pictures need thumbnails
64    if (in_array(get_extension($path), $conf['picture_ext']))
65    {
66      $dirname = dirname($path);
67      $filename = basename($path);
68 
69      // only files matching the authorized filename pattern can be considered
70      // as "without thumbnail"
71      if (!preg_match('/^[a-zA-Z0-9-_.]+$/', $filename))
72      {
73        continue;
74      }
75     
76      // searching the element
77      $filename_wo_ext = get_filename_wo_extension($filename);
78      $tn_ext = '';
79      $base_test = $dirname.'/'.$conf['dir_thumbnail'].'/';
80      $base_test.= $conf['prefix_thumbnail'].$filename_wo_ext.'.';
81      foreach ($conf['picture_ext'] as $ext)
82      {
83        if (isset($fs['thumbnails'][$base_test.$ext]))
84        {
85          $tn_ext = $ext;
86          break;
87        }
88      }
89     
90      if (empty($tn_ext))
91      {
92        array_push($wo_thumbnails, $path);
93      }
94    }
95  } // next element
96} // next site id
97
98// +-----------------------------------------------------------------------+
99// |             form & pictures without thumbnails display                |
100// +-----------------------------------------------------------------------+
101$template->set_filenames( array('thumbnail'=>'thumbnail.tpl') );
102
103if (count($wo_thumbnails) > 0)
104{
105  foreach ($wo_thumbnails as $path)
106  {
107    list($width, $height) = getimagesize($path);
108    $size = floor(filesize($path) / 1024).' KB';
109
110    $template->append(
111      'remainings',
112      array(
113        'PATH'=>$path,
114        'FILESIZE_IMG'=>$size,
115        'WIDTH_IMG'=>$width,
116        'HEIGHT_IMG'=>$height,
117      )
118    );
119  }
120}
121
122foreach (array_keys($upload_form_config) as $field)
123{
124  if (is_bool($upload_form_config[$field]['default']))
125  {
126    $form_values[$field] = $form_values[$field] ? 'checked="checked"' : '';
127  }
128}
129
130$template->assign(
131  array(
132    'F_ACTION' => get_root_url().'admin.php?page=thumbnail',
133    'values' => $form_values,
134    'TOTAL_NB_REMAINING' => count($wo_thumbnails),
135    'U_HELP' => get_root_url().'admin/popuphelp.php?page=thumbnail',
136  )
137);
138
139$template->assign_var_from_handle('ADMIN_CONTENT', 'thumbnail');
140?>
Note: See TracBrowser for help on using the repository browser.