diff options
author | plegall <plg@piwigo.org> | 2006-03-04 23:31:46 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2006-03-04 23:31:46 +0000 |
commit | c08fa6f67ef5b149fdeb3bcc57045e629df8fff4 (patch) | |
tree | 8a0eeb15f6a4989b6691584c9cf5123361be4f1c /admin/site_reader_remote.php | |
parent | c4874071babe878fcdcda10da1cc34ba5ded6aae (diff) |
new feature: source/destination links between categories. Will we keep this
feature? Code is complicated and very few people will understand how it
works...
modification: #images.storage_category_id replaced by
#image_category.is_storage
improvement: many code refactoring to improve readibility
improvement: virtual category creation code was moved to a dedicated
function in order to be called from admin/cat_list.php and
admin/cat_modify.php (create a new destination category)
git-svn-id: http://piwigo.org/svn/trunk@1064 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/site_reader_remote.php')
-rw-r--r-- | admin/site_reader_remote.php | 68 |
1 files changed, 49 insertions, 19 deletions
diff --git a/admin/site_reader_remote.php b/admin/site_reader_remote.php index 3bcd367d3..1810b955b 100644 --- a/admin/site_reader_remote.php +++ b/admin/site_reader_remote.php @@ -39,8 +39,12 @@ var $update_attributes; function RemoteSiteReader($url) { $this->site_url = $url; - $this->insert_attributes = array('tn_ext', 'representative_ext', 'has_high'); - $this->update_attributes = array( 'representative_ext', 'has_high', 'filesize', 'width', 'height' ); + $this->insert_attributes = array( + 'tn_ext', 'representative_ext', 'has_high' + ); + $this->update_attributes = array( + 'representative_ext', 'has_high', 'filesize', 'width', 'height' + ); } /** @@ -51,6 +55,7 @@ function RemoteSiteReader($url) function open() { global $errors; + $listing_file = $this->site_url.'/listing.xml'; if (@fopen($listing_file, 'r')) { @@ -58,20 +63,38 @@ function open() $this->site_files = array(); $xml_content = getXmlCode($listing_file); $info_xml_element = getChild($xml_content, 'informations'); - if ( getAttribute($info_xml_element , 'phpwg_version') != PHPWG_VERSION ) + if (getAttribute($info_xml_element , 'phpwg_version') != PHPWG_VERSION) { - array_push($errors, array('path' => $listing_file, 'type' => 'PWG-ERROR-VERSION')); + array_push( + $errors, + array( + 'path' => $listing_file, + 'type' => 'PWG-ERROR-VERSION' + ) + ); + return false; } - $meta_attributes = explode ( ',', - getAttribute($info_xml_element , 'metadata') ); - $this->update_attributes = array_merge( $this->update_attributes, $meta_attributes ); + + $this->update_attributes = array_merge( + $this->update_attributes, + explode(',', getAttribute($info_xml_element, 'metadata')) + ); + $this->build_structure($xml_content, '', 0); + return true; } else { - array_push($errors, array('path' => $listing_file, 'type' => 'PWG-ERROR-NOLISTING')); + array_push( + $errors, + array( + 'path' => $listing_file, + 'type' => 'PWG-ERROR-NOLISTING' + ) + ); + return false; } } @@ -83,8 +106,8 @@ function get_full_directories($basedir) foreach ( array_keys($this->site_dirs) as $dir) { $full_dir = $this->site_url . $dir; - if ( $full_dir!=$basedir - and strpos($full_dir, $basedir)===0 + if ($full_dir != $basedir + and strpos($full_dir, $basedir) === 0 ) { array_push($dirs, $full_dir); @@ -105,12 +128,14 @@ function get_elements($path) foreach ( $this->site_dirs as $dir=>$files) { $full_dir = $this->site_url . $dir; - if ( strpos($full_dir, $path)===0 ) + if (strpos($full_dir, $path) === 0) { - foreach ( $files as $file) + foreach ($files as $file) { - $data = $this->get_element_attributes($file, - $this->insert_attributes); + $data = $this->get_element_attributes( + $file, + $this->insert_attributes + ); $elements[$file] = $data; } } @@ -129,8 +154,10 @@ function get_update_attributes() // returns a hash of attributes (metadata+filesize+width,...) for file function get_element_update_attributes($file) { - return $this->get_element_attributes($file, - $this->update_attributes); + return $this->get_element_attributes( + $file, + $this->update_attributes + ); } //-------------------------------------------------- private functions -------- @@ -143,7 +170,7 @@ function get_element_update_attributes($file) function get_element_attributes($file, $attributes) { $xml_element = $this->site_files[$file]; - if ( ! isset($xml_element) ) + if (!isset($xml_element)) { return null; } @@ -177,12 +204,15 @@ function build_structure($xml_content, $basedir, $level) if ($basedir != '') { - $xml_elements = getChildren( getChild($xml_content, 'root'), 'element' ); + $xml_elements = getChildren( + getChild($xml_content, 'root'), + 'element' + ); foreach ($xml_elements as $xml_element) { $path = getAttribute($xml_element, 'path'); $this->site_files[$path] = $xml_element; - array_push( $this->site_dirs[$basedir], $path); + array_push($this->site_dirs[$basedir], $path); } } } |