source: trunk/admin/site_update.php @ 1029

Last change on this file since 1029 was 1029, checked in by rvelices, 18 years ago
  • remake of Remote sites and Synchronize:
    • synchronization for remote and local sites are done by the same code
    • remote sites can update metadata now (not before) - bug 279
    • fixes bug 82: has_high column
  • improve feature 280: user sort by filename
  • fix path to template mimetypes icons
  • bug 284: session cookie lifetime, deletion on logout and corrected issue

when db upgrades were missing

File size: 24.7 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
5// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2005-12-03 17:03:58 -0500 (Sat, 03 Dec 2005) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 967 $
12// +-----------------------------------------------------------------------+
13// | This program is free software; you can redistribute it and/or modify  |
14// | it under the terms of the GNU General Public License as published by  |
15// | the Free Software Foundation                                          |
16// |                                                                       |
17// | This program is distributed in the hope that it will be useful, but   |
18// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
19// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
20// | General Public License for more details.                              |
21// |                                                                       |
22// | You should have received a copy of the GNU General Public License     |
23// | along with this program; if not, write to the Free Software           |
24// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
25// | USA.                                                                  |
26// +-----------------------------------------------------------------------+
27
28if (!defined('PHPWG_ROOT_PATH'))
29{
30  die ('Hacking attempt!');
31}
32include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
33
34if (! is_numeric($_GET['site']) )
35{
36  die ('site param missing or invalid');
37}
38$site_id = $_GET['site'];
39$query='SELECT galleries_url FROM '.SITES_TABLE.'
40WHERE id='.$site_id.'
41;';
42list($site_url)=mysql_fetch_row(pwg_query($query));
43if (! isset($site_url) )
44{
45  die ("site $site_id does not exist");
46}
47$site_is_remote = url_is_remote($site_url);
48
49list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
50define('CURRENT_DATE', $dbnow);
51
52$error_labels = array(
53  'PWG-UPDATE-1' => array( get_lang('update_wrong_dirname_short'), 
54                           get_lang('update_wrong_dirname_info') ),
55  'PWG-UPDATE-2' => array( get_lang('update_missing_tn_short'),
56                           get_lang('update_missing_tn_info') 
57                           . implode(',', $conf['picture_ext']) ),
58  'PWG-ERROR-NO-FS' => array( get_lang('Does not exist'), 
59                             get_lang('update_missing_file_or_dir_info')),
60  'PWG-ERROR-VERSION' => array( get_lang('Invalid PhpWebGalley version'), 
61                             get_lang('update_pwg_version_differs_info')),
62  'PWG-ERROR-NOLISTING' => array( get_lang('remote_site_listing_not_found'), 
63                             get_lang('remote_site_listing_not_found_info'))
64                      );
65$errors = array();
66$infos = array();
67
68if ($site_is_remote)
69{
70  include_once( PHPWG_ROOT_PATH.'admin/site_reader_remote.php');
71  $site_reader = new RemoteSiteReader($site_url);
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  // shall we simulate only
87  if (isset($_POST['simulate']) and $_POST['simulate'] == 1)
88  {
89    $simulate = true;
90  }
91  else
92  {
93    $simulate = false;
94  }
95}
96
97// +-----------------------------------------------------------------------+
98// |                      directories / categories                         |
99// +-----------------------------------------------------------------------+
100if (isset($_POST['submit'])
101    and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files')
102    and !$general_failure)
103{
104  $counts['new_categories'] = 0;
105  $counts['del_categories'] = 0;
106  $counts['del_elements'] = 0;
107  $counts['new_elements'] = 0;
108
109  $start = get_moment();
110  // which categories to update ?
111  $cat_ids = array();
112
113  $query = '
114SELECT id, uppercats, global_rank, status, visible
115  FROM '.CATEGORIES_TABLE.'
116  WHERE dir IS NOT NULL
117    AND site_id = '.$site_id;
118  if (isset($_POST['cat']) and is_numeric($_POST['cat']))
119  {
120    if (isset($_POST['subcats-included']) and $_POST['subcats-included'] == 1)
121    {
122      $query.= '
123    AND uppercats REGEXP \'(^|,)'.$_POST['cat'].'(,|$)\'
124';
125    }
126    else
127    {
128      $query.= '
129    AND id = '.$_POST['cat'].'
130';
131    }
132  }
133  $query.= '
134;';
135  $result = pwg_query($query);
136
137  $db_categories = array();
138  while ($row = mysql_fetch_array($result))
139  {
140    $db_categories[$row['id']] = $row;
141  }
142
143  // get categort full directories in an array for comparison with file
144  // system directory tree
145  $db_fulldirs = get_fulldirs(array_keys($db_categories));
146
147  // what is the base directory to search file system sub-directories ?
148  if (isset($_POST['cat']) and is_numeric($_POST['cat']))
149  {
150    $basedir = $db_fulldirs[$_POST['cat']];
151  }
152  else
153  {
154    $basedir = preg_replace('#/*$#', '', $site_url);
155  }
156
157  // we need to have fulldirs as keys to make efficient comparison
158  $db_fulldirs = array_flip($db_fulldirs);
159
160  // finding next rank for each id_uppercat. By default, each category id
161  // has 1 for next rank on its sub-categories to create
162  $next_rank['NULL'] = 1;
163
164  $query = '
165SELECT id
166  FROM '.CATEGORIES_TABLE.'
167;';
168  $result = pwg_query($query);
169  while ($row = mysql_fetch_array($result))
170  {
171    $next_rank[$row['id']] = 1;
172  }
173
174  // let's see if some categories already have some sub-categories...
175  $query = '
176SELECT id_uppercat, MAX(rank)+1 AS next_rank
177  FROM '.CATEGORIES_TABLE.'
178  GROUP BY id_uppercat
179;';
180  $result = pwg_query($query);
181  while ($row = mysql_fetch_array($result))
182  {
183    // for the id_uppercat NULL, we write 'NULL' and not the empty string
184    if (!isset($row['id_uppercat']) or $row['id_uppercat'] == '')
185    {
186      $row['id_uppercat'] = 'NULL';
187    }
188    $next_rank[$row['id_uppercat']] = $row['next_rank'];
189  }
190
191  // next category id available
192  $query = '
193SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_id
194  FROM '.CATEGORIES_TABLE.'
195;';
196  list($next_id) = mysql_fetch_array(pwg_query($query));
197
198  // retrieve sub-directories fulldirs from the site reader
199  $fs_fulldirs = $site_reader->get_full_directories($basedir);
200  //print_r( $fs_fulldirs ); echo "<br>";
201
202  // get_full_directories doesn't include the base directory, so if it's a
203  // category directory, we need to include it in our array
204  if (isset($_POST['cat']))
205  {
206    array_push($fs_fulldirs, $basedir);
207  }
208
209  $inserts = array();
210  // new categories are the directories not present yet in the database
211  foreach (array_diff($fs_fulldirs, array_keys($db_fulldirs)) as $fulldir)
212  {
213    $dir = basename($fulldir);
214    if (preg_match('/^[a-zA-Z0-9-_.]+$/', $dir))
215    {
216      $insert = array();
217
218      $insert{'id'} = $next_id++;
219      $insert{'dir'} = $dir;
220      $insert{'name'} = str_replace('_', ' ', $dir);
221      $insert{'site_id'} = $site_id;
222      $insert{'commentable'} = $conf['newcat_default_commentable'];
223      if (! $site_is_remote)
224      {
225        $insert{'uploadable'} = $conf['newcat_default_uploadable'];
226      }
227      else
228      {
229        $insert{'uploadable'} = false;
230      }
231      $insert{'status'} = $conf{'newcat_default_status'};
232      $insert{'visible'} = $conf{'newcat_default_visible'};
233
234      if (isset($db_fulldirs[dirname($fulldir)]))
235      {
236        $parent = $db_fulldirs[dirname($fulldir)];
237
238        $insert{'id_uppercat'} = $parent;
239        $insert{'uppercats'} =
240          $db_categories[$parent]['uppercats'].','.$insert{'id'};
241        $insert{'rank'} = $next_rank[$parent]++;
242        $insert{'global_rank'} =
243          $db_categories[$parent]['global_rank'].'.'.$insert{'rank'};
244        if ('private' == $db_categories[$parent]['status'])
245        {
246          $insert{'status'} = 'private';
247        }
248        if ('false' == $db_categories[$parent]['visible'])
249        {
250          $insert{'visible'} = 'false';
251        }
252      }
253      else
254      {
255        $insert{'uppercats'} = $insert{'id'};
256        $insert{'rank'} = $next_rank['NULL']++;
257        $insert{'global_rank'} = $insert{'rank'};
258      }
259
260      array_push($inserts, $insert);
261      array_push($infos, array('path' => $fulldir,
262                               'info' => get_lang('update_research_added')));
263
264      // add the new category to $db_categories and $db_fulldirs array
265      $db_categories[$insert{'id'}] =
266        array(
267          'id' => $insert{'id'},
268          'status' => $insert{'status'},
269          'visible' => $insert{'visible'},
270          'uppercats' => $insert{'uppercats'},
271          'global_rank' => $insert{'global_rank'}
272          );
273      $db_fulldirs[$fulldir] = $insert{'id'};
274      $next_rank[$insert{'id'}] = 1;
275    }
276    else
277    {
278      array_push($errors, array('path' => $fulldir, 'type' => 'PWG-UPDATE-1'));
279    }
280  }
281
282  if (count($inserts) > 0)
283  {
284    if (!$simulate)
285    {
286      $dbfields = array(
287        'id','dir','name','site_id','id_uppercat','uppercats','commentable',
288        'uploadable','visible','status','rank','global_rank'
289        );
290      mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts);
291    }
292
293    $counts['new_categories'] = count($inserts);
294  }
295
296  // to delete categories
297  $to_delete = array();
298  foreach (array_diff(array_keys($db_fulldirs), $fs_fulldirs) as $fulldir)
299  {
300    array_push($to_delete, $db_fulldirs[$fulldir]);
301    unset($db_fulldirs[$fulldir]);
302    array_push($infos, array('path' => $fulldir,
303                             'info' => get_lang('update_research_deleted')));
304  }
305  if (count($to_delete) > 0)
306  {
307    if (!$simulate)
308    {
309      delete_categories($to_delete);
310    }
311    $counts['del_categories'] = count($to_delete);
312  }
313
314  echo '<!-- scanning dirs : ';
315  echo get_elapsed_time($start, get_moment());
316  echo ' -->'."\n";
317}
318// +-----------------------------------------------------------------------+
319// |                           files / elements                            |
320// +-----------------------------------------------------------------------+
321if (isset($_POST['submit']) and $_POST['sync'] == 'files'
322      and !$general_failure)
323{
324  $start_files = get_moment();
325  $start= $start_files;
326
327  $fs = $site_reader->get_elements($basedir);
328  //print_r($fs); echo "<br>";
329  echo '<!-- get_elements: '.get_elapsed_time($start, get_moment())." -->\n";
330
331  $cat_ids = array_diff(array_keys($db_categories), $to_delete);
332
333  $db_elements = array();
334  $db_unvalidated = array();
335
336  if (count($cat_ids) > 0)
337  {
338    $query = '
339SELECT id, path
340  FROM '.IMAGES_TABLE.'
341  WHERE storage_category_id IN (
342'.wordwrap(implode(', ', $cat_ids), 80, "\n").')
343;';
344    $result = pwg_query($query);
345    while ($row = mysql_fetch_array($result))
346    {
347      $db_elements[$row['id']] = $row['path'];
348    }
349
350    // searching the unvalidated waiting elements (they must not be taken into
351    // account)
352    $query = '
353SELECT file,storage_category_id
354  FROM '.WAITING_TABLE.'
355  WHERE storage_category_id IN (
356'.wordwrap(implode(', ', $cat_ids), 80, "\n").')
357    AND validated = \'false\'
358;';
359    $result = pwg_query($query);
360    while ($row = mysql_fetch_array($result))
361    {
362      array_push(
363        $db_unvalidated,
364        array_search($row['storage_category_id'],
365                     $db_fulldirs).'/'.$row['file']
366        );
367    }
368  }
369
370  // next element id available
371  $query = '
372SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id
373  FROM '.IMAGES_TABLE.'
374;';
375  list($next_element_id) = mysql_fetch_array(pwg_query($query));
376
377  $start = get_moment();
378
379  $inserts = array();
380  $insert_links = array();
381
382  foreach (array_diff(array_keys($fs), $db_elements, $db_unvalidated) as $path)
383  {
384    $insert = array();
385    // storage category must exist
386    $dirname = dirname($path);
387    if (!isset($db_fulldirs[$dirname]))
388    {
389      continue;
390    }
391    $filename = basename($path);
392    if (!preg_match('/^[a-zA-Z0-9-_.]+$/', $filename))
393    {
394      array_push($errors, array('path' => $path, 'type' => 'PWG-UPDATE-1'));
395      continue;
396    }
397
398    // 2 cases : the element is a picture or not. Indeed, for a picture
399    // thumbnail is mandatory and for non picture element, thumbnail and
400    // representative are optionnal
401    if (in_array(get_extension($filename), $conf['picture_ext']))
402    {
403      // if we found a thumnbnail corresponding to our picture...
404      if ( isset($fs[$path]['tn_ext']) )
405      {
406        $insert{'id'} = $next_element_id++;
407        $insert{'file'} = $filename;
408        $insert{'storage_category_id'} = $db_fulldirs[$dirname];
409        $insert{'date_available'} = CURRENT_DATE;
410        $insert{'tn_ext'} = $fs[$path]['tn_ext'];
411        $insert{'has_high'} = $fs[$path]['has_high'];
412        $insert{'path'} = $path;
413
414        array_push($inserts, $insert);
415        array_push($insert_links,
416                   array('image_id' => $insert{'id'},
417                         'category_id' => $insert{'storage_category_id'}));
418        array_push($infos, array('path' => $insert{'path'},
419                                 'info' => get_lang('update_research_added')));
420      }
421      else
422      {
423        array_push($errors, array('path' => $path, 'type' => 'PWG-UPDATE-2'));
424      }
425    }
426    else
427    {
428      $insert{'id'} = $next_element_id++;
429      $insert{'file'} = $filename;
430      $insert{'storage_category_id'} = $db_fulldirs[$dirname];
431      $insert{'date_available'} = CURRENT_DATE;
432      $insert{'has_high'} = $fs[$path]['has_high'];
433      $insert{'path'} = $path;
434
435      if ( isset($fs[$path]['tn_ext']) )
436      {
437        $insert{'tn_ext'} = $fs[$path]['tn_ext'];
438      }
439      if (isset($fs[$path]['representative_ext']))
440      {
441        $insert{'representative_ext'} = $fs[$path]['representative_ext'];
442      }
443
444      array_push($inserts, $insert);
445      array_push($insert_links,
446                 array('image_id' => $insert{'id'},
447                       'category_id' => $insert{'storage_category_id'}));
448      array_push($infos, array('path' => $insert{'path'},
449                               'info' => get_lang('update_research_added')));
450    }
451  }
452
453  if (count($inserts) > 0)
454  {
455    if (!$simulate)
456    {
457      // inserts all new elements
458      $dbfields = array(
459        'id','file','storage_category_id','date_available','tn_ext'
460        ,'representative_ext', 'has_high', 'path'
461        );
462      mass_inserts(IMAGES_TABLE, $dbfields, $inserts);
463
464      // insert all links between new elements and their storage category
465      $dbfields = array('image_id','category_id');
466      mass_inserts(IMAGE_CATEGORY_TABLE, $dbfields, $insert_links);
467    }
468    $counts['new_elements'] = count($inserts);
469  }
470
471  // delete elements that are in database but not in the filesystem
472  $to_delete_elements = array();
473  foreach (array_diff($db_elements, array_keys($fs)) as $path)
474  {
475    array_push($to_delete_elements, array_search($path, $db_elements));
476    array_push($infos, array('path' => $path,
477                             'info' => get_lang('update_research_deleted')));
478  }
479  if (count($to_delete_elements) > 0)
480  {
481    if (!$simulate)
482    {
483      delete_elements($to_delete_elements);
484    }
485    $counts['del_elements'] = count($to_delete_elements);
486  }
487
488  echo '<!-- scanning files : ';
489  echo get_elapsed_time($start_files, get_moment());
490  echo ' -->'."\n";
491
492  // retrieving informations given by uploaders
493  if (!$simulate and count($cat_ids) > 0)
494  {
495    $query = '
496SELECT id,file,storage_category_id,infos
497  FROM '.WAITING_TABLE.'
498  WHERE storage_category_id IN (
499'.wordwrap(implode(', ', $cat_ids), 80, "\n").')
500    AND validated = \'true\'
501;';
502    $result = pwg_query($query);
503
504    $datas = array();
505    $fields =
506      array(
507        'primary' => array('id'),
508        'update'  => array('date_creation', 'author', 'name', 'comment')
509        );
510
511    $waiting_to_delete = array();
512
513    while ($row = mysql_fetch_array($result))
514    {
515      $data = array();
516
517      $query = '
518SELECT id
519  FROM '.IMAGES_TABLE.'
520  WHERE storage_category_id = \''.$row['storage_category_id'].'\'
521    AND file = \''.$row['file'].'\'
522;';
523      list($data['id']) = mysql_fetch_array(pwg_query($query));
524
525      foreach ($fields['update'] as $field)
526      {
527        $data[$field] = getAttribute($row['infos'], $field);
528      }
529
530      array_push($datas, $data);
531      array_push($waiting_to_delete, $row['id']);
532    }
533
534    if (count($datas) > 0)
535    {
536      mass_updates(IMAGES_TABLE, $fields, $datas);
537
538      // delete now useless waiting elements
539      $query = '
540DELETE
541  FROM '.WAITING_TABLE.'
542  WHERE id IN ('.implode(',', $waiting_to_delete).')
543;';
544      pwg_query($query);
545    }
546  }
547}
548
549// +-----------------------------------------------------------------------+
550// |                          synchronize files                            |
551// +-----------------------------------------------------------------------+
552if (isset($_POST['submit'])
553    and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files'))
554{
555  $template->assign_block_vars(
556    'update_result',
557    array(
558      'NB_NEW_CATEGORIES'=>$counts['new_categories'],
559      'NB_DEL_CATEGORIES'=>$counts['del_categories'],
560      'NB_NEW_ELEMENTS'=>$counts['new_elements'],
561      'NB_DEL_ELEMENTS'=>$counts['del_elements'],
562      'NB_ERRORS'=>count($errors),
563      ));
564
565  if (!$simulate)
566  {
567    $start = get_moment();
568    update_category('all');
569    echo '<!-- update_category(all) : ';
570    echo get_elapsed_time($start,get_moment());
571    echo ' -->'."\n";
572    $start = get_moment();
573    ordering();
574    update_global_rank();
575    echo '<!-- ordering categories : ';
576    echo get_elapsed_time($start, get_moment());
577    echo ' -->'."\n";
578  }
579}
580
581// +-----------------------------------------------------------------------+
582// |                          synchronize metadata                         |
583// +-----------------------------------------------------------------------+
584if (isset($_POST['submit']) and preg_match('/^metadata/', $_POST['sync']) 
585         and !$general_failure)
586{
587  // sync only never synchronized files ?
588  if ($_POST['sync'] == 'metadata_new')
589  {
590    $opts['only_new'] = true;
591  }
592  else
593  {
594    $opts['only_new'] = false;
595  }
596  $opts['category_id'] = '';
597  $opts['recursive'] = true;
598
599  if (isset($_POST['cat']))
600  {
601    $opts['category_id'] = $_POST['cat'];
602    // recursive ?
603    if (!isset($_POST['subcats-included']) or $_POST['subcats-included'] != 1)
604    {
605      $opts['recursive'] = false;
606    }
607  }
608  $start = get_moment();
609  $files = get_filelist($opts['category_id'], $site_id,
610                        $opts['recursive'],
611                        $opts['only_new']);
612
613  echo '<!-- get_filelist : ';
614  echo get_elapsed_time($start, get_moment());
615  echo ' -->'."\n";
616
617  $start = get_moment();
618  $datas = array();
619  foreach ( $files as $id=>$file )
620  {
621    $data = $site_reader->get_element_update_attributes($file);
622    if ( is_array($data) )
623    {
624      $data['date_metadata_update'] = CURRENT_DATE;
625      $data['id']=$id;
626      array_push($datas, $data);
627    }
628    else
629    {
630      array_push($errors, array('path' => $file, 'type' => 'PWG-ERROR-NO-FS'));
631    }
632  }
633  $update_fields = $site_reader->get_update_attributes();
634  $update_fields = array_merge($update_fields, 'date_metadata_update');
635  $fields =
636      array(
637        'primary' => array('id'),
638        'update'  => array_unique($update_fields)
639        );
640  //print_r($datas);
641  if (!$simulate and count($datas)>0 )
642  {
643    mass_updates(IMAGES_TABLE, $fields, $datas);
644  }
645 
646  echo '<!-- metadata update : ';
647  echo get_elapsed_time($start, get_moment());
648  echo ' -->'."\n";
649
650  $template->assign_block_vars(
651    'metadata_result',
652    array(
653      'NB_ELEMENTS_DONE' => count($datas),
654      'NB_ELEMENTS_CANDIDATES' => count($files),
655      'NB_ERRORS' => count($errors),
656      ));
657}
658
659// +-----------------------------------------------------------------------+
660// |                        template initialization                        |
661// +-----------------------------------------------------------------------+
662$template->set_filenames(array('update'=>'admin/site_update.tpl'));
663$result_title = '';
664if (isset($simulate) and $simulate)
665{
666  $result_title.= get_lang('update_simulation_title').' ';
667}
668
669// used_metadata string is displayed to inform admin which metadata will be
670// used from files for synchronization
671$used_metadata = implode( ', ', $site_reader->get_update_attributes());
672if ($site_is_remote and !isset($_POST['submit']) )
673{
674  $used_metadata.= ' + ' . get_lang('Aditionnal remote attributes');
675}
676
677$template->assign_vars(
678  array(
679    'SITE_URL'=>$site_url,
680    'U_SITE_MANAGER'=> PHPWG_ROOT_PATH.'admin.php?page=site_manager',
681    'L_RESULT_UPDATE'=>$result_title.get_lang('update_part_research'),
682    'L_RESULT_METADATA'=>$result_title.get_lang('update_result_metadata'),
683    'METADATA_LIST' => $used_metadata
684    ));
685
686$template->assign_vars(
687  array(
688    'U_HELP' => PHPWG_ROOT_PATH.'/popuphelp.php?page=synchronize'
689    )
690  );
691// +-----------------------------------------------------------------------+
692// |                        introduction : choices                         |
693// +-----------------------------------------------------------------------+
694if (!isset($_POST['submit']) or (isset($simulate) and $simulate))
695{
696  $template->assign_block_vars('introduction', array());
697
698  if (isset($simulate) and $simulate)
699  {
700    switch ($_POST['sync'])
701    {
702      case 'dirs' :
703      {
704        $template->assign_vars(
705          array('SYNC_DIRS_CHECKED'=>'checked="checked"'));
706        break;
707      }
708      case 'files' :
709      {
710        $template->assign_vars(
711          array('SYNC_ALL_CHECKED'=>'checked="checked"'));
712        break;
713      }
714      case 'metadata_new' :
715      {
716        $template->assign_vars(
717          array('SYNC_META_NEW_CHECKED'=>'checked="checked"'));
718        break;
719      }
720      case 'metadata_all' :
721      {
722        $template->assign_vars(
723          array('SYNC_META_ALL_CHECKED'=>'checked="checked"'));
724        break;
725      }
726    }
727
728    if (isset($_POST['display_info']) and $_POST['display_info'] == 1)
729    {
730      $template->assign_vars(
731        array('DISPLAY_INFO_CHECKED'=>'checked="checked"'));
732    }
733
734    if (isset($_POST['subcats-included']) and $_POST['subcats-included'] == 1)
735    {
736      $template->assign_vars(
737        array('SUBCATS_INCLUDED_CHECKED'=>'checked="checked"'));
738    }
739
740    if (isset($_POST['cat']) and is_numeric($_POST['cat']))
741    {
742      $cat_selected = array($_POST['cat']);
743    }
744    else
745    {
746      $cat_selected = array();
747    }
748  }
749  else
750  {
751    $template->assign_vars(
752      array('SYNC_DIRS_CHECKED' => 'checked="checked"',
753            'SUBCATS_INCLUDED_CHECKED'=>'checked="checked"'));
754
755    $cat_selected = array();
756  }
757
758  $query = '
759SELECT id,name,uppercats,global_rank
760  FROM '.CATEGORIES_TABLE.'
761  WHERE site_id = '.$site_id.'
762;';
763  display_select_cat_wrapper($query,
764                             $cat_selected,
765                             'introduction.category_option',
766                             false);
767}
768
769if (count($errors) > 0)
770{
771  $template->assign_block_vars('sync_errors', array());
772  foreach ($errors as $error)
773  {
774    $template->assign_block_vars(
775      'sync_errors.error',
776      array(
777        'ELEMENT' => $error['path'],
778        'LABEL' => $error['type'].' ('.$error_labels[$error['type']][0].')'
779        ));
780  }
781
782  foreach ($error_labels as $error_type=>$error_description)
783  {
784    $template->assign_block_vars(
785      'sync_errors.error_caption',
786      array(
787        'TYPE' => $error_type,
788        'LABEL' => $error_description[1]
789        ));
790  }
791
792}
793if (count($infos) > 0
794    and isset($_POST['display_info'])
795    and $_POST['display_info'] == 1)
796{
797  $template->assign_block_vars('sync_infos', array());
798  foreach ($infos as $info)
799  {
800    $template->assign_block_vars(
801      'sync_infos.info',
802      array(
803        'ELEMENT' => $info['path'],
804        'LABEL' => $info['info']
805        ));
806  }
807}
808
809// +-----------------------------------------------------------------------+
810// |                          sending html code                            |
811// +-----------------------------------------------------------------------+
812$template->assign_var_from_handle('ADMIN_CONTENT', 'update');
813?>
Note: See TracBrowser for help on using the repository browser.