How To: Convert from Old-Style Files to New Dataclass

From ARK
Revision as of 09:24, 23 May 2009 by Stuarteve (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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];
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).