Last active
April 12, 2018 08:30
-
-
Save gautiermichelin/c262023cb28eebb9107a1f58fd661ac7 to your computer and use it in GitHub Desktop.
Export in TSV all the screens and the bundles from a CollectiveAccess installation, using a user id (useful for reports)
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"); | |
$vt_user = new ca_users(16); | |
$vt_list_item = new ca_list_items(); | |
print "Table CollectiveAccess | Editeur\tEcran de saisie\tLibellé du champs ou conteneur\tIdentifiant du champs ou conteneur\tType de données\n"; | |
function getScreens($idno) { | |
$result = ""; | |
$ui = new ca_editor_uis($idno); | |
foreach ($ui->getScreens() as $screen_id=>$screen) { | |
$result.= "\t".$screen_id." ".$screen["name"]."\n"; | |
$ui_screen = new ca_editor_ui_screens($screen_id); | |
//var_dump($ui_screen);die(); | |
$bundle_list = $ui_screen->getPlacements(); | |
foreach($bundle_list as $bundle) { | |
$datatype = "Champs intrinsèque"; | |
$idno = $bundle["bundle_name"]; | |
$is_attribute = (strpos($idno, "ca_attribute_") !== false); | |
$idno = str_replace("ca_attribute_","", $idno); | |
if(isset($bundle["settings"]["label"])) { | |
$label = reset($bundle["settings"]["label"]); | |
} else { | |
$label = $bundle["bundle_name"]; | |
if($label == "preferred_labels") { | |
$label = "Titres"; | |
} | |
} | |
if(!$label) { | |
$label = $idno; | |
} | |
if($is_attribute) { | |
$vt_metadata = new ca_metadata_elements(); | |
$metadata_info = $vt_metadata::elementCodesToIDs($idno); | |
$metadata_id = reset(array_values($metadata_info)); | |
$vt_metadata->load($metadata_id); | |
//var_dump($vt_metadata->getSettings()); | |
$datatype_id = $vt_metadata->get('datatype'); | |
$datatype = $vt_metadata->getAttributeNameForTypeCode($datatype_id); | |
} | |
if(in_array($idno, ["ca_objects","ca_collections","ca_entities","ca_places"])) { | |
$datatype = "Relation avec un autre enregistrement"; | |
} | |
$result .= "\t\t$label\t$idno\t$datatype\n"; | |
} | |
} | |
return $result; | |
} | |
$tables = ["57"=>"Objets", "20"=>"Entités", "13"=>"Collection (OA/OP)", "72"=>"Lieu", "89"=>"Emplacements"]; | |
foreach($tables as $table_num=>$table_name) { | |
$ui_list = $vt_user->_getUIListByType($table_num); | |
foreach($ui_list as $key=>$value) { | |
$affichage_name = reset(reset($value)); | |
$ui_idno = reset(array_keys($value)); | |
$vt_list_item->load($key); | |
if($key != "__all__") { | |
print $table_name." | ".$vt_list_item->getLabelForDisplay()." ".$affichage_name."\n"; | |
print getScreens($ui_idno); | |
} else { | |
print $table_name." | "."Pour tous les autres types : ".$affichage_name."\n"; | |
print getScreens($ui_idno); | |
} | |
} | |
print "\n\n"; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment