Difference between revisions of "How To: Convert from Old-Style Files to New Dataclass"
Line 8: | Line 8: | ||
//get a list of the files to be converted | //get a list of the files to be converted | ||
− | |||
$photo_directory = ''''/srv/www/htdocs/ark/data/site_photos/registered/VM07''''; | $photo_directory = ''''/srv/www/htdocs/ark/data/site_photos/registered/VM07''''; | ||
− | |||
processFiles($photo_directory, ''''VM07'''', ''''sph'''', 1, 'NOW()'); | processFiles($photo_directory, ''''VM07'''', ''''sph'''', 1, 'NOW()'); | ||
− | |||
$list = dirList($photo_directory,'jpg'); | $list = dirList($photo_directory,'jpg'); | ||
− | |||
foreach($list as $value){ | foreach($list as $value){ | ||
− | |||
$exploded_name = explode(''''SPHVM07_'''',$value); | $exploded_name = explode(''''SPHVM07_'''',$value); | ||
$number = (int)$exploded_name[1]; | $number = (int)$exploded_name[1]; | ||
+ | printf("<br />filename: $value itemkey: sph_cd itemvalue: 'VM07_$number<br />"); | ||
+ | |||
+ | Edit this code changing the bits in bold to reflect your environment, module and itemkey. | ||
+ | |||
+ | If you want to do a dry-run comment out the line that starts processFiles() - to see if the renaming will work. | ||
+ | |||
+ | This tool will register them properly with the system and create the relevant thumbnails, etc. | ||
+ | |||
+ | Once you have done this - you need to link the files back to their original module. Open php/tools/batch_link_files.php | ||
− | printf("<br />filename: $ | + | $sql = "SELECT * FROM cor_lut_file WHERE batch = ''''VM07''''"; |
+ | $fres = mysql_query($sql, $db) or die("Func: batch_link_files:<br/>SQL: $sql<br/>Error: " . mysql_error()); | ||
+ | // handle results | ||
+ | if ($frow = mysql_fetch_array($fres)) { | ||
+ | do { | ||
+ | $exploded_name = explode(''''SPHVM07_'''',$frow['filename']); | ||
+ | $number = (int)$exploded_name[1]; | ||
+ | printf("<br />filename: {$frow['filename']} itemkey: '''sph_cd''' itemvalue: ''''VM07_'''$number<br />"); | ||
+ | addFile(''''sph_cd'''', ''''VM07_'''' . $number, $frow['id'] , 1, 'NOW()'); | ||
+ | } while ($frow = mysql_fetch_array($fres)); | ||
+ | } | ||
+ | |||
+ | Again update the bits in bold to reflect your setup. If you want to do a dry-run comment out the addFile() line and see if everything looks ok. | ||
− | + | Once these have been run - you should see that the files are properly linked to their original module (don;t forget you will need to setup a file_field in your mod_settings to display them). | |
[[Category: Usermanual]][[Category: How-Tos]] | [[Category: Usermanual]][[Category: How-Tos]] |
Latest revision as of 09:24, 23 May 2009
You should only use this how-to if you are using pre-v0.6 files (that is files as a module rather than a dataclass).
There are two stages to the update - first you need to register the files with ARK system. Then you need to add those files to cor_tbl_file to link them to the original module.
We have created two tool files to aid in this - however they do need a bit of editing before you can use them.
First php/tools/batch_register_files.php - an extract of the code here:
//get a list of the files to be converted $photo_directory = '/srv/www/htdocs/ark/data/site_photos/registered/VM07'; processFiles($photo_directory, 'VM07', 'sph', 1, 'NOW()'); $list = dirList($photo_directory,'jpg'); foreach($list as $value){ $exploded_name = explode('SPHVM07_',$value); $number = (int)$exploded_name[1]; printf("
filename: $value itemkey: sph_cd itemvalue: 'VM07_$number
");
Edit this code changing the bits in bold to reflect your environment, module and itemkey.
If you want to do a dry-run comment out the line that starts processFiles() - to see if the renaming will work.
This tool will register them properly with the system and create the relevant thumbnails, etc.
Once you have done this - you need to link the files back to their original module. Open php/tools/batch_link_files.php
$sql = "SELECT * FROM cor_lut_file WHERE batch = 'VM07'"; $fres = mysql_query($sql, $db) or die("Func: batch_link_files:
SQL: $sql
Error: " . mysql_error()); // handle results if ($frow = mysql_fetch_array($fres)) { do { $exploded_name = explode('SPHVM07_',$frow['filename']); $number = (int)$exploded_name[1]; printf("
filename: {$frow['filename']} itemkey: sph_cd itemvalue: 'VM07_$number
"); addFile('sph_cd', 'VM07_' . $number, $frow['id'] , 1, 'NOW()'); } while ($frow = mysql_fetch_array($fres)); }
Again update the bits in bold to reflect your setup. If you want to do a dry-run comment out the addFile() line and see if everything looks ok.
Once these have been run - you should see that the files are properly linked to their original module (don;t forget you will need to setup a file_field in your mod_settings to display them).