Created
April 16, 2015 08:47
-
-
Save gautiermichelin/6e8fa124bf5fafd7a9f6 to your computer and use it in GitHub Desktop.
CollectiveAccess : detection & reprocessing of media not treated by queue (either for access permission or format error)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once('setup.php'); | |
require_once('app/models/ca_object_representations.php'); | |
require_once('app/lib/core/Db.php'); | |
$o_data = new Db(); | |
$qr_reps = $o_data->query(" | |
SELECT * | |
FROM ca_object_representations | |
"); | |
$t_rep = new ca_object_representations(); | |
$t_rep->setMode(ACCESS_WRITE); | |
$i=0; | |
$num_being_processed=0; | |
$first=true; | |
// Detection empty | |
// print "./bin/caUtils reprocess-media --ids "; | |
while($qr_reps->nextRow()) { | |
$va_media_info = $qr_reps->getMediaInfo('media'); | |
$i++; | |
$being_processed=null; | |
$representation_id=$qr_reps->get('representation_id'); | |
$representation = new ca_object_representations($representation_id); | |
//if($representation->mediaIsEmpty() == false) print "(".$i.") ".$representation_id." media empty\n"; | |
$representations = $representation->getRepresentations(); | |
$preview170 = $representations[0][tags][preview170]; | |
if ($preview170 == "L'image est en cours de traitement.") { | |
$num_being_processed++; | |
$being_processed=true; | |
}; | |
if ($being_processed) { | |
//if (!$first) print ","; | |
//print $representation_id; | |
$first=false; | |
$t_rep->load($qr_reps->get('representation_id')); | |
$t_rep->set('media', $qr_reps->getMediaPath('media', 'original'), array('original_filename' => $vs_original_filename)); | |
$t_rep->update(); | |
if ($t_rep->numErrors()) { | |
print("Error processing representation media: %1". join('; ', $t_rep->getErrors())."<br/>\n"); | |
} else { | |
print "Media retraité ".$representation_id."<br/>\n"; | |
} | |
$i++; | |
} | |
//if($i==10) exit(); | |
} | |
print "<br/>\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment