Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
test medias for CollectiveAccess
<?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));
}
<?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();
This file has been truncated, but you can view the full file.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View raw

(Sorry about that, but we can’t show files that are this big right now.)

@gautiermichelin

This comment has been minimized.

Copy link
Owner Author

commented Feb 26, 2018

git clone https://gist.github.com/gautiermichelin/27fcf03040c06875ca93c1c6056f6213 && cp 27fcf03040c06875ca93c1c6056f6213/*.* providence/ && cp 27fcf03040c06875ca93c1c6056f6213/* providence/ && cd providence

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.