source: trunk/admin/site_update.php @ 20321

Last change on this file since 20321 was 19703, checked in by plg, 11 years ago

update Piwigo headers to 2013 (the end of the world didn't occur as expected on r12922)

  • Property svn:eol-style set to LF
File size: 23.6 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2013 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');
30
31// +-----------------------------------------------------------------------+
32// | Check Access and exit when user status is not ok                      |
33// +-----------------------------------------------------------------------+
34check_status(ACCESS_ADMINISTRATOR);
35
36if (!is_numeric($_GET['site']))
37{
38  die ('site param missing or invalid');
39}
40$site_id = $_GET['site'];
41
42$query='
43SELECT galleries_url
44  FROM '.SITES_TABLE.'
45  WHERE id = '.$site_id;
46list($site_url) = pwg_db_fetch_row(pwg_query($query));
47if (!isset($site_url))
48{
49  die('site '.$site_id.' does not exist');
50}
51$site_is_remote = url_is_remote($site_url);
52
53list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
54define('CURRENT_DATE', $dbnow);
55
56$error_labels = array(
57  'PWG-UPDATE-1' => array(
58    l10n('wrong filename'),
59    l10n('The name of directories and files must be composed of letters, numbers, "-", "_" or "."')
60    ),
61  'PWG-ERROR-NO-FS' => array(
62    l10n('File/directory read error'),
63    l10n('The file or directory cannot be accessed (either it does not exist or the access is denied)')
64    ),
65  );
66$errors = array();
67$infos = array();
68
69if ($site_is_remote)
70{
71  fatal_error('remote sites not supported');
72}
73else
74{
75  include_once( PHPWG_ROOT_PATH.'admin/site_reader_local.php');
76  $site_reader = new LocalSiteReader($site_url);
77}
78
79$general_failure = true;
80if (isset($_POST['submit']))
81{
82  if ($site_reader->open())
83  {
84    $general_failure = false;
85  }
86
87  // shall we simulate only
88  if (isset($_POST['simulate']) and $_POST['simulate'] == 1)
89  {
90    $simulate = true;
91  }
92  else
93  {
94    $simulate = false;
95  }
96}
97
98// +-----------------------------------------------------------------------+
99// |                      directories / categories                         |
100// +-----------------------------------------------------------------------+
101if (isset($_POST['submit'])
102    and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files'))
103{
104  $counts['new_categories'] = 0;
105  $counts['del_categories'] = 0;
106  $counts['del_elements'] = 0;
107  $counts['new_elements'] = 0;
108  $counts['upd_elements'] = 0;
109}
110
111
112if (isset($_POST['submit'])
113    and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files')
114    and !$general_failure)
115{
116  $start = get_moment();
117  // which categories to update ?
118  $query = '
119SELECT id, uppercats, global_rank, status, visible
120  FROM '.CATEGORIES_TABLE.'
121  WHERE dir IS NOT NULL
122    AND site_id = '.$site_id;
123  if (isset($_POST['cat']) and is_numeric($_POST['cat']))
124  {
125    if (isset($_POST['subcats-included']) and $_POST['subcats-included'] == 1)
126    {
127      $query.= '
128    AND uppercats '.DB_REGEX_OPERATOR.' \'(^|,)'.$_POST['cat'].'(,|$)\'
129';
130    }
131    else
132    {
133      $query.= '
134    AND id = '.$_POST['cat'].'
135';
136    }
137  }
138  $db_categories = hash_from_query($query, 'id');
139
140  // get categort full directories in an array for comparison with file
141  // system directory tree
142  $db_fulldirs = get_fulldirs(array_keys($db_categories));
143
144  // what is the base directory to search file system sub-directories ?
145  if (isset($_POST['cat']) and is_numeric($_POST['cat']))
146  {
147    $basedir = $db_fulldirs[$_POST['cat']];
148  }
149  else
150  {
151    $basedir = preg_replace('#/*$#', '', $site_url);
152  }
153
154  // we need to have fulldirs as keys to make efficient comparison
155  $db_fulldirs = array_flip($db_fulldirs);
156
157  // finding next rank for each id_uppercat. By default, each category id
158  // has 1 for next rank on its sub-categories to create
159  $next_rank['NULL'] = 1;
160
161  $query = '
162SELECT id
163  FROM '.CATEGORIES_TABLE;
164  $result = pwg_query($query);
165  while ($row = pwg_db_fetch_assoc($result))
166  {
167    $next_rank[$row['id']] = 1;
168  }
169
170  // let's see if some categories already have some sub-categories...
171  $query = '
172SELECT id_uppercat, MAX(rank)+1 AS next_rank
173  FROM '.CATEGORIES_TABLE.'
174  GROUP BY id_uppercat';
175  $result = pwg_query($query);
176  while ($row = pwg_db_fetch_assoc($result))
177  {
178    // for the id_uppercat NULL, we write 'NULL' and not the empty string
179    if (!isset($row['id_uppercat']) or $row['id_uppercat'] == '')
180    {
181      $row['id_uppercat'] = 'NULL';
182    }
183    $next_rank[$row['id_uppercat']] = $row['next_rank'];
184  }
185
186  // next category id available
187  $next_id = pwg_db_nextval('id', CATEGORIES_TABLE);
188
189  // retrieve sub-directories fulldirs from the site reader
190  $fs_fulldirs = $site_reader->get_full_directories($basedir);
191
192  // get_full_directories doesn't include the base directory, so if it's a
193  // category directory, we need to include it in our array
194  if (isset($_POST['cat']))
195  {
196    array_push($fs_fulldirs, $basedir);
197  }
198  // If $_POST['subcats-included'] != 1 ("Search in sub-albums" is unchecked)
199  // $db_fulldirs doesn't include any subdirectories and $fs_fulldirs does
200  // So $fs_fulldirs will be limited to the selected basedir
201  // (if that one is in $fs_fulldirs)
202  if (!isset($_POST['subcats-included']) or $_POST['subcats-included'] != 1)
203  {
204    $fs_fulldirs = array_intersect($fs_fulldirs, array_keys($db_fulldirs));
205  }
206  $inserts = array();
207  // new categories are the directories not present yet in the database
208  foreach (array_diff($fs_fulldirs, array_keys($db_fulldirs)) as $fulldir)
209  {
210    $dir = basename($fulldir);
211    if (preg_match($conf['sync_chars_regex'], $dir))
212    {
213      $insert = array(
214        'id'          => $next_id++,
215        'dir'         => $dir,
216        'name'        => str_replace('_', ' ', $dir),
217        'site_id'     => $site_id,
218        'commentable' =>
219          boolean_to_string($conf['newcat_default_commentable']),
220        'status'      => $conf['newcat_default_status'],
221        'visible'     => boolean_to_string($conf['newcat_default_visible']),
222        );
223
224      if (isset($db_fulldirs[dirname($fulldir)]))
225      {
226        $parent = $db_fulldirs[dirname($fulldir)];
227
228        $insert['id_uppercat'] = $parent;
229        $insert['uppercats'] =
230          $db_categories[$parent]['uppercats'].','.$insert['id'];
231        $insert['rank'] = $next_rank[$parent]++;
232        $insert['global_rank'] =
233          $db_categories[$parent]['global_rank'].'.'.$insert['rank'];
234        if ('private' == $db_categories[$parent]['status'])
235        {
236          $insert['status'] = 'private';
237        }
238        if ('false' == $db_categories[$parent]['visible'])
239        {
240          $insert['visible'] = 'false';
241        }
242      }
243      else
244      {
245        $insert['uppercats'] = $insert['id'];
246        $insert{'rank'} = $next_rank['NULL']++;
247        $insert['global_rank'] = $insert['rank'];
248      }
249
250      array_push($inserts, $insert);
251      array_push(
252        $infos,
253        array(
254          'path' => $fulldir,
255          'info' => l10n('added')
256          )
257        );
258
259      // add the new category to $db_categories and $db_fulldirs array
260      $db_categories[$insert{'id'}] =
261        array(
262          'id' => $insert['id'],
263          'status' => $insert['status'],
264          'visible' => $insert['visible'],
265          'uppercats' => $insert['uppercats'],
266          'global_rank' => $insert['global_rank']
267          );
268      $db_fulldirs[$fulldir] = $insert['id'];
269      $next_rank[$insert{'id'}] = 1;
270    }
271    else
272    {
273      array_push(
274        $errors,
275        array(
276          'path' => $fulldir,
277          'type' => 'PWG-UPDATE-1'
278          )
279        );
280    }
281  }
282
283  if (count($inserts) > 0)
284  {
285    if (!$simulate)
286    {
287      $dbfields = array(
288        'id','dir','name','site_id','id_uppercat','uppercats','commentable',
289        'visible','status','rank','global_rank'
290        );
291      mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts);
292
293      // add default permissions to categories
294      $category_ids = array();
295      foreach ($inserts as $category)
296      {
297        $category_ids[] = $category['id'];
298      }
299      add_permission_on_category($category_ids, get_admins());
300    }
301
302    $counts['new_categories'] = count($inserts);
303  }
304
305  // to delete categories
306  $to_delete = array(); $to_delete_derivative_dirs = array();
307  foreach (array_diff(array_keys($db_fulldirs), $fs_fulldirs) as $fulldir)
308  {
309    array_push($to_delete, $db_fulldirs[$fulldir]);
310    unset($db_fulldirs[$fulldir]);
311    array_push($infos, array('path' => $fulldir,
312                             'info' => l10n('deleted')));
313    if (substr_compare($fulldir, '../', 0, 3)==0)
314    {
315      $fulldir = substr($fulldir, 3);
316    }
317    $to_delete_derivative_dirs[] = PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR.$fulldir;
318  }
319  if (count($to_delete) > 0)
320  {
321    if (!$simulate)
322    {
323      delete_categories($to_delete);
324      foreach($to_delete_derivative_dirs as $to_delete_dir)
325      {
326        if (is_dir($to_delete_dir))
327        {
328          clear_derivative_cache_rec($to_delete_dir, '#.+#');
329        }
330      }
331    }
332    $counts['del_categories'] = count($to_delete);
333  }
334
335  $template->append('footer_elements', '<!-- scanning dirs : '
336    . get_elapsed_time($start, get_moment())
337    . ' -->' );
338}
339// +-----------------------------------------------------------------------+
340// |                           files / elements                            |
341// +-----------------------------------------------------------------------+
342if (isset($_POST['submit']) and $_POST['sync'] == 'files'
343      and !$general_failure)
344{
345  $start_files = get_moment();
346  $start= $start_files;
347
348  $fs = $site_reader->get_elements($basedir);
349  $template->append('footer_elements', '<!-- get_elements: '
350    . get_elapsed_time($start, get_moment())
351    . ' -->' );
352
353  $cat_ids = array_diff(array_keys($db_categories), $to_delete);
354
355  $db_elements = array();
356
357  if (count($cat_ids) > 0)
358  {
359    $query = '
360SELECT id, path
361  FROM '.IMAGES_TABLE.'
362  WHERE storage_category_id IN ('
363      .wordwrap(
364        implode(', ', $cat_ids),
365        160,
366        "\n"
367        ).')';
368    $db_elements = simple_hash_from_query($query, 'id', 'path');
369  }
370
371  // next element id available
372  $next_element_id = pwg_db_nextval('id', IMAGES_TABLE);
373
374  $start = get_moment();
375
376  $inserts = array();
377  $insert_links = array();
378
379  foreach (array_diff(array_keys($fs), $db_elements) as $path)
380  {
381    $insert = array();
382    // storage category must exist
383    $dirname = dirname($path);
384    if (!isset($db_fulldirs[$dirname]))
385    {
386      continue;
387    }
388    $filename = basename($path);
389    if (!preg_match($conf['sync_chars_regex'], $filename))
390    {
391      array_push(
392        $errors,
393        array(
394          'path' => $path,
395          'type' => 'PWG-UPDATE-1'
396          )
397        );
398
399      continue;
400    }
401
402    $insert = array(
403      'id'             => $next_element_id++,
404      'file'           => $filename,
405      'name'           => get_name_from_file($filename),
406      'date_available' => CURRENT_DATE,
407      'path'           => $path,
408      'representative_ext'  => $fs[$path]['representative_ext'],
409      'storage_category_id' => $db_fulldirs[$dirname],
410      'added_by'       => $user['id'],
411      );
412
413    if ( $_POST['privacy_level']!=0 )
414    {
415      $insert['level'] = $_POST['privacy_level'];
416    }
417
418    array_push(
419      $inserts,
420      $insert
421      );
422
423    array_push(
424      $insert_links,
425      array(
426        'image_id'    => $insert['id'],
427        'category_id' => $insert['storage_category_id'],
428        )
429      );
430
431    array_push(
432      $infos,
433      array(
434        'path' => $insert['path'],
435        'info' => l10n('added')
436        )
437      );
438
439    $caddiables[] = $insert['id'];
440  }
441
442  if (count($inserts) > 0)
443  {
444    if (!$simulate)
445    {
446      // inserts all new elements
447      mass_inserts(
448        IMAGES_TABLE,
449        array_keys($inserts[0]),
450        $inserts
451        );
452
453      // inserts all links between new elements and their storage category
454      mass_inserts(
455        IMAGE_CATEGORY_TABLE,
456        array_keys($insert_links[0]),
457        $insert_links
458        );
459
460      // add new photos to caddie
461      if (isset($_POST['add_to_caddie']) and $_POST['add_to_caddie'] == 1)
462      {
463        fill_caddie($caddiables);
464      }
465    }
466    $counts['new_elements'] = count($inserts);
467  }
468
469  // delete elements that are in database but not in the filesystem
470  $to_delete_elements = array();
471  foreach (array_diff($db_elements, array_keys($fs)) as $path)
472  {
473    array_push($to_delete_elements, array_search($path, $db_elements));
474    array_push($infos, array('path' => $path,
475                             'info' => l10n('deleted')));
476  }
477  if (count($to_delete_elements) > 0)
478  {
479    if (!$simulate)
480    {
481      delete_elements($to_delete_elements);
482    }
483    $counts['del_elements'] = count($to_delete_elements);
484  }
485
486  $template->append('footer_elements', '<!-- scanning files : '
487    . get_elapsed_time($start_files, get_moment())
488    . ' -->' );
489}
490
491// +-----------------------------------------------------------------------+
492// |                          synchronize files                            |
493// +-----------------------------------------------------------------------+
494if (isset($_POST['submit'])
495    and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files')
496    and !$general_failure )
497{
498  if (!$simulate)
499  {
500    $start = get_moment();
501    update_category('all');
502    $template->append('footer_elements', '<!-- update_category(all) : '
503      . get_elapsed_time($start,get_moment())
504      . ' -->' );
505    $start = get_moment();
506    update_global_rank();
507    $template->append('footer_elements', '<!-- ordering categories : '
508      . get_elapsed_time($start, get_moment())
509      . ' -->');
510  }
511
512  if ($_POST['sync'] == 'files')
513  {
514    $start = get_moment();
515    $opts['category_id'] = '';
516    $opts['recursive'] = true;
517    if (isset($_POST['cat']))
518    {
519      $opts['category_id'] = $_POST['cat'];
520      if (!isset($_POST['subcats-included']) or $_POST['subcats-included'] != 1)
521      {
522        $opts['recursive'] = false;
523      }
524    }
525    $files = get_filelist($opts['category_id'], $site_id,
526                          $opts['recursive'],
527                          false);
528    $template->append('footer_elements', '<!-- get_filelist : '
529      . get_elapsed_time($start, get_moment())
530      . ' -->');
531    $start = get_moment();
532
533    $datas = array();
534    foreach ( $files as $id=>$file )
535    {
536      $file = $file['path'];
537      $data = $site_reader->get_element_update_attributes($file);
538      if ( !is_array($data) )
539      {
540        continue;
541      }
542
543      $data['id']=$id;
544      array_push($datas, $data);
545    } // end foreach file
546
547    $counts['upd_elements'] = count($datas);
548    if (!$simulate and count($datas)>0 )
549    {
550      mass_updates(
551        IMAGES_TABLE,
552        // fields
553        array(
554          'primary' => array('id'),
555          'update'  => $site_reader->get_update_attributes(),
556          ),
557        $datas
558        );
559    }
560    $template->append('footer_elements', '<!-- update files : '
561      . get_elapsed_time($start,get_moment())
562      . ' -->');
563  }// end if sync files
564}
565
566// +-----------------------------------------------------------------------+
567// |                          synchronize files                            |
568// +-----------------------------------------------------------------------+
569if (isset($_POST['submit'])
570    and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files'))
571{
572  $template->assign(
573    'update_result',
574    array(
575      'NB_NEW_CATEGORIES'=>$counts['new_categories'],
576      'NB_DEL_CATEGORIES'=>$counts['del_categories'],
577      'NB_NEW_ELEMENTS'=>$counts['new_elements'],
578      'NB_DEL_ELEMENTS'=>$counts['del_elements'],
579      'NB_UPD_ELEMENTS'=>$counts['upd_elements'],
580      'NB_ERRORS'=>count($errors),
581      ));
582}
583
584// +-----------------------------------------------------------------------+
585// |                          synchronize metadata                         |
586// +-----------------------------------------------------------------------+
587if (isset($_POST['submit']) and isset($_POST['sync_meta'])
588         and !$general_failure)
589{
590  // sync only never synchronized files ?
591  $opts['only_new'] = isset($_POST['meta_all']) ? false : true;
592  $opts['category_id'] = '';
593  $opts['recursive'] = true;
594
595  if (isset($_POST['cat']))
596  {
597    $opts['category_id'] = $_POST['cat'];
598    // recursive ?
599    if (!isset($_POST['subcats-included']) or $_POST['subcats-included'] != 1)
600    {
601      $opts['recursive'] = false;
602    }
603  }
604  $start = get_moment();
605  $files = get_filelist($opts['category_id'], $site_id,
606                        $opts['recursive'],
607                        $opts['only_new']);
608
609  $template->append('footer_elements', '<!-- get_filelist : '
610    . get_elapsed_time($start, get_moment())
611    . ' -->');
612
613  $start = get_moment();
614  $datas = array();
615  $tags_of = array();
616
617  foreach ( $files as $id => $element_infos )
618  {
619    $data = $site_reader->get_element_metadata($element_infos);
620
621    if ( is_array($data) )
622    {
623      $data['date_metadata_update'] = CURRENT_DATE;
624      $data['id']=$id;
625      array_push($datas, $data);
626
627      foreach (array('keywords', 'tags') as $key)
628      {
629        if (isset($data[$key]))
630        {
631          if (!isset($tags_of[$id]))
632          {
633            $tags_of[$id] = array();
634          }
635
636          foreach (explode(',', $data[$key]) as $tag_name)
637          {
638            array_push(
639              $tags_of[$id],
640              tag_id_from_tag_name($tag_name)
641              );
642          }
643        }
644      }
645    }
646    else
647    {
648      array_push($errors, array('path' => $element_infos['path'], 'type' => 'PWG-ERROR-NO-FS'));
649    }
650  }
651
652  if (!$simulate)
653  {
654    if (count($datas) > 0)
655    {
656      mass_updates(
657        IMAGES_TABLE,
658        // fields
659        array(
660          'primary' => array('id'),
661          'update'  => array_unique(
662            array_merge(
663              array_diff(
664                $site_reader->get_metadata_attributes(),
665                // keywords and tags fields are managed separately
666                array('keywords', 'tags')
667                ),
668              array('date_metadata_update'))
669            )
670          ),
671        $datas,
672        isset($_POST['meta_empty_overrides']) ? 0 : MASS_UPDATES_SKIP_EMPTY
673        );
674    }
675    set_tags_of($tags_of);
676  }
677
678  $template->append('footer_elements', '<!-- metadata update : '
679    . get_elapsed_time($start, get_moment())
680    . ' -->');
681
682  $template->assign(
683    'metadata_result',
684    array(
685      'NB_ELEMENTS_DONE' => count($datas),
686      'NB_ELEMENTS_CANDIDATES' => count($files),
687      'NB_ERRORS' => count($errors),
688      ));
689}
690
691// +-----------------------------------------------------------------------+
692// |                        template initialization                        |
693// +-----------------------------------------------------------------------+
694$template->set_filenames(array('update'=>'site_update.tpl'));
695$result_title = '';
696if (isset($simulate) and $simulate)
697{
698  $result_title.= '['.l10n('Simulation').'] ';
699}
700
701// used_metadata string is displayed to inform admin which metadata will be
702// used from files for synchronization
703$used_metadata = implode( ', ', $site_reader->get_metadata_attributes());
704if ($site_is_remote and !isset($_POST['submit']) )
705{
706  $used_metadata.= ' + ...';
707}
708
709$template->assign(
710  array(
711    'SITE_URL'=>$site_url,
712    'U_SITE_MANAGER'=> get_root_url().'admin.php?page=site_manager',
713    'L_RESULT_UPDATE'=>$result_title.l10n('Search for new images in the directories'),
714    'L_RESULT_METADATA'=>$result_title.l10n('Metadata synchronization results'),
715    'METADATA_LIST' => $used_metadata,
716    'U_HELP' => get_root_url().'admin/popuphelp.php?page=synchronize',
717    ));
718
719// +-----------------------------------------------------------------------+
720// |                        introduction : choices                         |
721// +-----------------------------------------------------------------------+
722if (isset($_POST['submit']))
723{
724  $tpl_introduction = array(
725      'sync'  => $_POST['sync'],
726      'sync_meta'  => isset($_POST['sync_meta']) ? true : false,
727      'display_info' => isset($_POST['display_info']) and $_POST['display_info']==1,
728      'add_to_caddie' => isset($_POST['add_to_caddie']) and $_POST['add_to_caddie']==1,
729      'subcats_included' => isset($_POST['subcats-included']) and $_POST['subcats-included']==1,
730      'privacy_level_selected' => (int)@$_POST['privacy_level'],
731      'meta_all'  => isset($_POST['meta_all']) ? true : false,
732      'meta_empty_overrides'  => isset($_POST['meta_empty_overrides']) ? true : false,
733    );
734
735  if (isset($_POST['cat']) and is_numeric($_POST['cat']))
736  {
737    $cat_selected = array($_POST['cat']);
738  }
739  else
740  {
741    $cat_selected = array();
742  }
743}
744else
745{
746  $tpl_introduction = array(
747      'sync'  => 'dirs',
748      'sync_meta'  => true,
749      'display_info' => false,
750      'add_to_caddie' => false,
751      'subcats_included' => true,
752      'privacy_level_selected' => 0,
753      'meta_all'  => false,
754      'meta_empty_overrides'  => false,
755    );
756
757  $cat_selected = array();
758
759  if (isset($_GET['cat_id']))
760  {
761    check_input_parameter('cat_id', $_GET, false, PATTERN_ID);
762
763    $cat_selected = array($_GET['cat_id']);
764    $tpl_introduction['sync'] = 'files';
765  }
766}
767
768$tpl_introduction['privacy_level_options'] = get_privacy_level_options();
769
770$template->assign('introduction', $tpl_introduction);
771
772$query = '
773SELECT id,name,uppercats,global_rank
774  FROM '.CATEGORIES_TABLE.'
775  WHERE site_id = '.$site_id;
776display_select_cat_wrapper($query,
777                           $cat_selected,
778                           'category_options',
779                           false);
780
781
782if (count($errors) > 0)
783{
784  foreach ($errors as $error)
785  {
786    $template->append(
787      'sync_errors',
788      array(
789        'ELEMENT' => $error['path'],
790        'LABEL' => $error['type'].' ('.$error_labels[$error['type']][0].')'
791        ));
792  }
793
794  foreach ($error_labels as $error_type=>$error_description)
795  {
796    $template->append(
797      'sync_error_captions',
798      array(
799        'TYPE' => $error_type,
800        'LABEL' => $error_description[1]
801        ));
802  }
803}
804
805if (count($infos) > 0
806    and isset($_POST['display_info'])
807    and $_POST['display_info'] == 1)
808{
809  foreach ($infos as $info)
810  {
811    $template->append(
812      'sync_infos',
813      array(
814        'ELEMENT' => $info['path'],
815        'LABEL' => $info['info']
816        ));
817  }
818}
819
820// +-----------------------------------------------------------------------+
821// |                          sending html code                            |
822// +-----------------------------------------------------------------------+
823$template->assign_var_from_handle('ADMIN_CONTENT', 'update');
824?>
Note: See TracBrowser for help on using the repository browser.