Changeset 1058 for trunk/admin


Ignore:
Timestamp:
Feb 28, 2006, 2:13:16 AM (18 years ago)
Author:
rvelices
Message:

remake of Remote sites and synchronize: final integration and old code cleanup

fix: xml getAttribute always decodes html entities and added encodeAttribute
function

Location:
trunk/admin
Files:
2 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_modify.php

    r1004 r1058  
    33// | PhpWebGallery - a PHP based picture gallery                           |
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    5 // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
     5// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
    66// +-----------------------------------------------------------------------+
    77// | branch        : BSF (Best So Far)
     
    259259                                       '',
    260260                                       get_complete_dir($category['id']))));
    261   $template->assign_block_vars('upload' ,array());
    262261}
    263262else
     
    301300}
    302301
    303 if (is_numeric($category['site_id']) and $category['site_id'] != 1)
     302$category['cat_dir'] = get_complete_dir($_GET['cat_id']);
     303if (is_numeric($category['site_id']) and url_is_remote($category['cat_dir']) )
    304304{
    305305  $query = '
     
    312312}
    313313
     314if (!$category['is_virtual'] and !url_is_remote($category['cat_dir']) )
     315{
     316  $template->assign_block_vars('upload' ,array());
     317}
     318
    314319//----------------------------------------------------------- sending html code
    315320$template->assign_var_from_handle('ADMIN_CONTENT', 'categories');
  • trunk/admin/site_manager.php

    • Property svn:eol-style set to native
    r1033 r1058  
    6464  else
    6565  {
    66     array_push($page['errors'], l10n('remote_site_file_not_found'));
     66    array_push($page['errors'], l10n('site_err_remote_file_not_found'));
    6767  }
    6868}
     
    100100  {
    101101    array_push($page['errors'],
    102       l10n('remote_site_already_exists').' ['.$url.']');
     102      l10n('site_already_exists').' ['.$url.']');
    103103  }
    104104  if (count($page['errors']) == 0)
     
    115115        {
    116116          array_push($page['errors'],
    117                      l10n('remote_site_error').' : '.$first_line);
     117                     l10n('site_err').' : '.$first_line);
    118118        }
    119119      }
    120120      else
    121121      {
    122         array_push($page['errors'], l10n('remote_site_file_not_found') );
     122        array_push($page['errors'], l10n('site_err_remote_file_not_found') );
    123123      }
    124124    }
     
    143143    pwg_query($query);
    144144    array_push($page['infos'],
    145                $url.' '.l10n('remote_site_created'));
     145               $url.' '.l10n('site_created'));
    146146  }
    147147}
     
    189189      delete_site($page['site']);
    190190      array_push($page['infos'],
    191                  $galleries_url.' '.l10n('remote_site_deleted'));
     191                 $galleries_url.' '.l10n('site_deleted'));
    192192      break;
    193193    }
     
    197197$template->assign_vars( array(
    198198  'F_ACTION' => PHPWG_ROOT_PATH.'admin.php'
    199                 .get_query_string_diff( array('action','site') ) 
     199                .get_query_string_diff( array('action','site') )
    200200  ) );
    201  
     201
    202202// +-----------------------------------------------------------------------+
    203203// |                           remote sites list                           |
     
    227227  $update_url.= '?page=site_update';
    228228  $update_url.= '&site='.$row['id'];
    229 
    230229  $template->assign_block_vars(
    231230    'sites.site',
    232231    array(
    233232      'NAME' => $row['galleries_url'],
    234       'TYPE' => l10n( $is_remote ? 'Remote' : 'Local' ),
     233      'TYPE' => l10n( $is_remote ? 'site_remote' : 'site_local' ),
    235234      'CATEGORIES' => $row['nb_categories'],
    236235      'IMAGES' => isset($row['nb_images']) ? $row['nb_images'] : 0,
    237       'U_UPDATE' => $update_url
     236      'U_SYNCHRONIZE' => $update_url
    238237     )
    239238   );
    240 
    241239   if ($is_remote)
    242240   {
  • trunk/admin/site_reader_local.php

    • Property svn:eol-style set to native
    r1029 r1058  
    4747  if (!is_dir($this->site_url))
    4848  {
    49     array_push($errors, array('path' => $this->site_url, 'type' => 'PWG-ERROR-NODIR'));
     49    array_push($errors, array('path' => $this->site_url, 'type' => 'PWG-ERROR-NO-FS'));
    5050    return false;
    5151  }
     
    6161
    6262/**
    63  * Returns an array with all file system files according to $conf['file_ext'] 
     63 * Returns an array with all file system files according to $conf['file_ext']
    6464 * and $conf['picture_ext']
    6565 * @param string $path recurse in this directory
     
    131131}
    132132
    133 // returns the name of the attributes that are supported for 
     133// returns the name of the attributes that are supported for
    134134// update/synchronization according to configuration
    135135function get_update_attributes()
    136136{
    137137  global $conf;
    138   $update_fields = array( 'has_high', 'representative_ext', 
     138  $update_fields = array( 'has_high', 'representative_ext',
    139139      'filesize', 'width', 'height' );
    140140  if ($conf['use_exif'])
     
    166166    return null;
    167167  }
    168  
     168
    169169  $data = array();
    170  
     170
    171171  $filename = basename($file);
    172172  $data['has_high'] = $this->get_has_high( dirname($file), $filename );
    173   $data['representative_ext'] = $this->get_representative_ext( dirname($file), 
     173  $data['representative_ext'] = $this->get_representative_ext( dirname($file),
    174174                                        get_filename_wo_extension($filename) );
    175  
     175
    176176  $data['filesize'] = floor(filesize($file)/1024);
    177177  if ($image_size = @getimagesize($file))
  • trunk/admin/site_reader_remote.php

    • Property svn:eol-style set to native
    r1046 r1058  
    7272  else
    7373  {
    74     array_push($errors, array('path' => $listing_file, 'type' => 'PWG-ERROR-NO-FS'));
     74    array_push($errors, array('path' => $listing_file, 'type' => 'PWG-ERROR-NOLISTING'));
    7575    return false;
    7676  }
     
    9595
    9696/**
    97  * Returns a hash with all elements (images and files) inside the full $path 
     97 * Returns a hash with all elements (images and files) inside the full $path
    9898 * according to listing.xml
    9999 * @param string $path recurse in this directory only
     
    110110      foreach ( $files as $file)
    111111      {
    112         $data = $this->get_element_attributes($file, 
     112        $data = $this->get_element_attributes($file,
    113113                                              $this->insert_attributes);
    114114        $elements[$file] = $data;
     
    120120}
    121121
    122 // returns the name of the attributes that are supported for 
     122// returns the name of the attributes that are supported for
    123123// update/synchronization according to listing.xml
    124124function get_update_attributes()
     
    130130function get_element_update_attributes($file)
    131131{
    132     return $this->get_element_attributes($file, 
     132    return $this->get_element_attributes($file,
    133133                                         $this->update_attributes);
    134134}
     
    138138 * Returns a hash of image/file attributes
    139139 * @param string $file fully qualified file name
    140  * @param array $attributes specifies which attributes to retrieve 
     140 * @param array $attributes specifies which attributes to retrieve
    141141 *  returned
    142142*/
     
    144144{
    145145  $xml_element = $this->site_files[$file];
    146   if ( ! isset($xml_element) ) 
     146  if ( ! isset($xml_element) )
    147147  {
    148148    return null;
     
    153153    if (getAttribute($xml_element, $att) != '')
    154154    {
    155       $val = html_entity_decode( getAttribute($xml_element, $att) );
     155      $val = getAttribute($xml_element, $att);
    156156      $data[$att] = addslashes($val);
    157157    }
  • trunk/admin/site_update.php

    • Property svn:eol-style set to native
    r1033 r1058  
    5151
    5252$error_labels = array(
    53   'PWG-UPDATE-1' => array( l10n('update_wrong_dirname_short'), 
     53  'PWG-UPDATE-1' => array( l10n('update_wrong_dirname_short'),
    5454                           l10n('update_wrong_dirname_info') ),
    5555  'PWG-UPDATE-2' => array( l10n('update_missing_tn_short'),
    56                            l10n('update_missing_tn_info') 
     56                           l10n('update_missing_tn_info')
    5757                           . implode(',', $conf['picture_ext']) ),
    58   'PWG-ERROR-NO-FS' => array( l10n('Does not exist'),
     58  'PWG-ERROR-NO-FS' => array( l10n('update_missing_file_or_dir'),
    5959                             l10n('update_missing_file_or_dir_info')),
    60   'PWG-ERROR-VERSION' => array( l10n('Invalid PhpWebGalley version'),
    61                              l10n('update_pwg_version_differs_info')),
    62   'PWG-ERROR-NOLISTING' => array( l10n('remote_site_listing_not_found'),
    63                              l10n('remote_site_listing_not_found_info'))
     60  'PWG-ERROR-VERSION' => array( l10n('update_err_pwg_version_differs'),
     61                             l10n('update_err_pwg_version_differs_info')),
     62  'PWG-ERROR-NOLISTING' => array( l10n('update_err_remote_listing_not_found'),
     63                             l10n('update_err_remote_listing_not_found_info'))
    6464                      );
    6565$errors = array();
     
    409409        $insert{'date_available'} = CURRENT_DATE;
    410410        $insert{'tn_ext'} = $fs[$path]['tn_ext'];
    411         $insert{'has_high'} = $fs[$path]['has_high'];
     411        if ( isset($fs[$path]['has_high']) )
     412        {
     413          $insert{'has_high'} = $fs[$path]['has_high'];
     414        }
     415        else
     416        {
     417          $insert{'has_high'} = null;
     418        }
    412419        $insert{'path'} = $path;
    413420
     
    431438      $insert{'date_available'} = CURRENT_DATE;
    432439      $insert{'has_high'} = $fs[$path]['has_high'];
     440      if ( isset($fs[$path]['has_high']) )
     441      {
     442        $insert{'has_high'} = $fs[$path]['has_high'];
     443      }
     444      else
     445      {
     446        $insert{'has_high'} = null;
     447      }
    433448      $insert{'path'} = $path;
    434449
     
    525540      foreach ($fields['update'] as $field)
    526541      {
    527         $data[$field] = getAttribute($row['infos'], $field);
     542        $data[$field] = addslashes( getAttribute($row['infos'], $field) );
    528543      }
    529544
     
    582597// |                          synchronize metadata                         |
    583598// +-----------------------------------------------------------------------+
    584 if (isset($_POST['submit']) and preg_match('/^metadata/', $_POST['sync']) 
     599if (isset($_POST['submit']) and preg_match('/^metadata/', $_POST['sync'])
    585600         and !$general_failure)
    586601{
     
    643658    mass_updates(IMAGES_TABLE, $fields, $datas);
    644659  }
    645  
     660
    646661  echo '<!-- metadata update : ';
    647662  echo get_elapsed_time($start, get_moment());
     
    672687if ($site_is_remote and !isset($_POST['submit']) )
    673688{
    674   $used_metadata.= ' + ' . l10n('Aditionnal remote attributes');
     689  $used_metadata.= ' + ...';
    675690}
    676691
Note: See TracChangeset for help on using the changeset viewer.