Last active
February 26, 2018 08:58
-
-
Save gautiermichelin/27fcf03040c06875ca93c1c6056f6213 to your computer and use it in GitHub Desktop.
test medias for CollectiveAccess
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(__CA_MODELS_DIR__."/ca_objects.php"); | |
require_once(__CA_MODELS_DIR__."/ca_lists.php"); | |
require_once(__CA_MODELS_DIR__."/ca_list_items.php"); | |
$list = new ca_lists("object_types"); | |
// Getting list item id of the first object type defined | |
$first_object_type = reset(array_keys($list->getItemsForList("object_types"))); | |
// Getting list item id of the first object type defined | |
$first_rep_type = reset(array_keys($list->getItemsForList("object_representation_types"))); | |
$obj = new ca_objects(); //Instantiate an empty object | |
$obj->load(array('idno' => "test-media-ideesculture")); | |
$id = $obj->get("ca_objects.object_id"); | |
if($id) { | |
print "Objet test-media-ideesculture déjà présent, suppression.\n"; | |
$obj->setMode(ACCESS_WRITE); | |
$obj->delete(true, array('hard' => true)); | |
} | |
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(__CA_MODELS_DIR__."/ca_objects.php"); | |
require_once(__CA_MODELS_DIR__."/ca_lists.php"); | |
require_once(__CA_MODELS_DIR__."/ca_list_items.php"); | |
$list = new ca_lists("object_types"); | |
// Getting list item id of the first object type defined | |
$first_object_type = reset(array_keys($list->getItemsForList("object_types"))); | |
// Getting list item id of the first object type defined | |
$first_rep_type = reset(array_keys($list->getItemsForList("object_representation_types"))); | |
$obj = new ca_objects(); //Instantiate an empty object | |
$obj->load(array('idno' => "test-media-ideesculture")); | |
$id = $obj->get("ca_objects.object_id"); | |
if($id) { | |
print "Objet test-media-ideesculture déjà présent, suppression.\n"; | |
$obj->setMode(ACCESS_WRITE); | |
$obj->delete(true, array('hard' => true)); | |
} | |
$obj->setMode(ACCESS_WRITE); //Set access mode to WRITE | |
$pn_locale_id='1'; //Set the locale | |
$obj->set(array('access' => 2, 'status' => 3, 'idno' => "test-media-ideesculture",'type_id' => $first_object_type,'locale_id'=>$pn_locale_id));//Define some intrinsic data. | |
$obj->insert();//Insert the object | |
$name = 'test media'; //Label value | |
$pn_locale_id = 2; //Label locale | |
$obj->addLabel(array('name'=>$name),$pn_locale_id,null,true);//Add the label. Only the array containing the name and the locale are mandatory. | |
$obj->addRepresentation(__DIR__."/test.tif", $first_rep_type, 2, 4, 1,1); | |
if($obj->getErrors()) { | |
print "Problème insertion TIFF\n"; | |
//var_dump($obj->getErrors()); | |
$obj->clearErrors(); | |
} | |
//$obj->update(); | |
$obj->addRepresentation(__DIR__."/test.mp4", $first_rep_type, 2, 4, 1,0); | |
if($obj->getErrors()) { | |
print "Problème insertion MP4\n"; | |
//var_dump($obj->getErrors()); | |
$obj->clearErrors(); | |
}//$obj->update(); | |
$obj->addRepresentation(__DIR__."/test.pdf", $first_rep_type, 2, 4, 1,0); | |
if($obj->getErrors()) { | |
print "Problème insertion PDF\n"; | |
//var_dump($obj->getErrors()); | |
$obj->clearErrors(); | |
} //$obj->update(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
git clone https://gist.github.com/gautiermichelin/27fcf03040c06875ca93c1c6056f6213 && cp 27fcf03040c06875ca93c1c6056f6213/*.* providence/ && cp 27fcf03040c06875ca93c1c6056f6213/* providence/ && cd providence