diff options
author | plegall <plg@piwigo.org> | 2006-04-02 22:26:19 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2006-04-02 22:26:19 +0000 |
commit | 42abf4c57664d2596872d437f70b95193f9a5d18 (patch) | |
tree | a1262b8601d5ac5b04b5b2e71af52c453712b9df /admin/site_update.php | |
parent | 68ed2ea617ede199a0e2f15fdd4886095ae600cb (diff) |
improvement: tags replace keywords. Better data model, less
limitations. Each image can be associated to as many tag as needed. Tags can
contain non ASCII characters. Oriented navigation with tags by association.
git-svn-id: http://piwigo.org/svn/trunk@1119 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | admin/site_update.php | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/admin/site_update.php b/admin/site_update.php index b68ce2b28..c7c31106c 100644 --- a/admin/site_update.php +++ b/admin/site_update.php @@ -715,6 +715,7 @@ if (isset($_POST['submit']) and preg_match('/^metadata/', $_POST['sync']) $start = get_moment(); $datas = array(); + $tags_of = array(); foreach ( $files as $id=>$file ) { $data = $site_reader->get_element_update_attributes($file); @@ -723,23 +724,55 @@ if (isset($_POST['submit']) and preg_match('/^metadata/', $_POST['sync']) $data['date_metadata_update'] = CURRENT_DATE; $data['id']=$id; array_push($datas, $data); + + foreach (array('keywords', 'tags') as $key) + { + if (isset($data[$key])) + { + if (!isset($tags_of[$id])) + { + $tags_of[$id] = array(); + } + + foreach (explode(',', $data[$key]) as $tag_name) + { + array_push( + $tags_of[$id], + tag_id_from_tag_name($tag_name) + ); + } + } + } } else { array_push($errors, array('path' => $file, 'type' => 'PWG-ERROR-NO-FS')); } } - $update_fields = $site_reader->get_update_attributes(); - $update_fields = array_merge($update_fields, array('date_metadata_update')); - $fields = - array( - 'primary' => array('id'), - 'update' => array_unique($update_fields) - ); - //print_r($datas); - if (!$simulate and count($datas)>0 ) + + if (!$simulate) { - mass_updates(IMAGES_TABLE, $fields, $datas); + if (count($datas) > 0) + { + mass_updates( + IMAGES_TABLE, + // fields + array( + 'primary' => array('id'), + 'update' => array_unique( + array_merge( + array_diff( + $site_reader->get_update_attributes(), + // keywords and tags fields are managed separately + array('keywords', 'tags') + ), + array('date_metadata_update')) + ) + ), + $datas + ); + } + set_tags_of($tags_of); } echo '<!-- metadata update : '; |