18 require_once SQ_CORE_PACKAGE_PATH.
'/page/page_edit_fns.inc';
19 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
43 unset($this->static_screens[
'tagging']);
60 $access = $asset->writeAccess(
'attributes');
62 if ($access) file_upload($prefix);
83 $info = get_file_upload_info($prefix);
84 $append = array_get_index($_REQUEST, $prefix.
'_append');
85 if (empty($info))
return TRUE;
88 if (is_uploaded_file($info[
'tmp_name'])) {
94 if (!file_exists($asset->data_path)) {
95 if (!create_directory($asset->data_path)) {
96 trigger_localised_error(
'CORE0261', E_USER_WARNING, $asset->data_path);
102 if (!move_uploaded_file($info[
'tmp_name'], $asset->getXmlFilePath())) {
103 trigger_localised_error(
'CORE0235', E_USER_WARNING, $info[
'tmp_name'], $asset->getXmlFilePath());
108 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
109 $hh->queueHipo(
'hipo_job_import_thesaurus_xml', Array(
'thesaurus_id' => $asset->id,
'append' => $append));
127 echo translate(
'thesaurus_example_xml_file', sq_web_path(
'data').
'/asset_types/thesaurus/files/example.xml');
148 $write_access_allowed = $asset->writeAccess(
'attributes');
150 if (is_readable($asset->getXmlFilePath())) {
151 if (!empty($_REQUEST[$prefix.
'_process_export'])) {
155 echo hidden_field($prefix.
'_process_export',
'0');
156 echo normal_button($prefix.
'_export', translate(
'download_file'),
'this.form.'.$prefix.
'_process_export.value = 1; this.form.submit(); SQ_FORM_SUBMITTED = false; this.form.'.$prefix.
'_process_export.value = 0; return true;');
157 echo
' Generated on '.date (
'r', filectime($asset->getXmlFilePath()));
162 if ($asset->countTerms()==0) {
163 echo translate(
'thesaurus_thesaurus_disabled');
164 }
else if ($write_access_allowed) {
165 echo hidden_field($prefix.
'_process_generate',
'0');
166 echo normal_button($prefix.
'_regenerate', translate(
'thesaurus_generate_file'),
'this.form.'.$prefix.
'_process_generate.value = 1; this.form.submit(); SQ_FORM_SUBMITTED = false; this.form.'.$prefix.
'_process_generate.value = 0; return true;');
167 }
else if ($asset->attr(
'contents_changed')) {
169 echo translate(
'thesaurus_thesaurus_not_generated');
172 return $write_access_allowed;
190 $write_access_allowed = $asset->writeAccess(
'attributes');
191 if (!$write_access_allowed) {
192 return $write_access_allowed;
198 if (!empty($_REQUEST[$prefix.
'_process_generate'])) {
199 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
200 $hh->queueHipo(
'hipo_job_export_thesaurus_xml', Array(
'thesaurus_id' => $asset->id));
203 return $write_access_allowed;
218 $filepath = $asset->getXmlFilePath();
219 $filepath = realpath($filepath);
220 if (is_readable($filepath)) {
221 header(
'Content-Type: application/xml');
223 header(
'Content-Disposition: attachment; filename='.basename($filepath).
';');
224 header(
'Content-Length: '.@filesize($filepath));
247 $write_access_allowed = $asset->writeAccess(
'attributes');
249 if (!$write_access_allowed) {
250 return $write_access_allowed;
253 $relations[NULL] =
'-- SELECT Relation to Rename --';
254 $relations += $asset->getActiveRelations();
255 combo_box($prefix.
'_relation', $relations, FALSE, NULL);
256 label(translate(
'thesaurus_new_relation'),$prefix.
'_new_relation');
257 text_box($prefix.
'_new_relation', NULL, $size=
'30', $max=
'255');
259 return $write_access_allowed;
277 $write_access_allowed = $asset->writeAccess(
'attributes');
278 if (!$write_access_allowed) {
279 return $write_access_allowed;
282 $relation = array_get_index($_REQUEST, $prefix.
'_relation');
283 $new_relation = array_get_index($_REQUEST, $prefix.
'_new_relation');
285 if (!empty($relation)) {
286 $success = $asset->renameRelation($relation, $new_relation);
306 $current_rel = $asset->attr(
'synonym_rel');
307 $relations = $asset->getActiveRelations();
309 if (empty($current_rel)) $current_rel = NULL;
311 if (!$asset->writeAccess(
'attributes')) {
312 $rel = array_get_index($relations, $current_rel);
313 if (is_null($current_rel)) {
314 $rel =
'<em>Nothing Selected</em>';
315 }
else if (empty($rel)) {
316 $rel =
'<em>NULL</em>';
317 }
else if (is_null($rel)) {
318 $rel =
'<em style="color:red">Invalid Relation ID ('.$current_rel.
')</em>';
325 if (!isset($relations[$current_rel]) && !is_null($current_rel)) {
326 echo
'Invalid Relation selected';
330 $selectable_relations[NULL] =
'-- Nothing Selected --';
331 $selectable_relations += $relations;
332 combo_box($prefix.
'_synonym', $selectable_relations, FALSE, $current_rel);
353 $synonym_rel = $asset->attr(
'synonym_rel');
354 if ($asset->writeAccess(
'attributes')) {
355 $selected_rel = array_get_index($_REQUEST, $prefix.
'_synonym');
356 $selected_rel = trim($selected_rel);
357 if (empty($selected_rel)) $selected_rel = NULL;
359 $asset->setAttrValue(
'synonym_rel', $selected_rel);
379 $current_rel = $asset->attr(
'abbreviation_rel');
380 $relations = $asset->getActiveRelations();
382 if (empty($current_rel)) $current_rel = NULL;
384 if (!$asset->writeAccess(
'attributes')) {
385 $rel = array_get_index($relations, $current_rel);
386 if (is_null($current_rel)) {
387 $rel =
'<em>Nothing Selected</em>';
388 }
else if (empty($rel)) {
389 $rel =
'<em>NULL</em>';
390 }
else if (is_null($rel)) {
391 $rel =
'<em style="color:red">Invalid Relation ID ('.$current_rel.
')</em>';
397 if (!isset($relations[$current_rel]) && !is_null($current_rel)) {
398 echo
'Invalid Relation selected';
402 $selectable_relations[NULL] =
'-- Nothing Selected --';
403 $selectable_relations += $relations;
404 combo_box($prefix.
'_abbrev', $selectable_relations, FALSE, $current_rel);
424 if ($asset->writeAccess(
'attributes')) {
425 $selected_rel = array_get_index($_REQUEST, $prefix.
'_abbrev');
426 $selected_rel = trim($selected_rel);
427 if (empty($selected_rel)) $selected_rel = NULL;
429 $asset->setAttrValue(
'abbreviation_rel', $selected_rel);
449 $current_rel = $asset->attr(
'default_rel');
450 $relations = $asset->getActiveRelations();
452 if (empty($current_rel)) $current_rel = NULL;
454 if (!$asset->writeAccess(
'attributes')) {
455 $rel = array_get_index($relations, $current_rel);
456 if (is_null($current_rel)) {
457 $rel =
'<em>Nothing Selected</em>';
458 }
else if (empty($rel)) {
459 $rel =
'<em>NULL</em>';
460 }
else if (is_null($rel)) {
461 $rel =
'<em style="color:red">Invalid Relation ID ('.$current_rel.
')</em>';
468 if (!isset($relations[$current_rel]) && !is_null($current_rel)) {
469 echo
'Invalid Relation selected';
473 $selectable_relations[NULL] =
'-- Nothing Selected --';
474 $selectable_relations += $relations;
475 combo_box($prefix.
'_default', $selectable_relations, FALSE, $current_rel);
495 if ($asset->writeAccess(
'attributes')) {
496 $selected_rel = array_get_index($_REQUEST, $prefix.
'_default');
497 $selected_rel = trim($selected_rel);
498 if (empty($selected_rel)) $selected_rel = NULL;
500 $asset->setAttrValue(
'default_rel', $selected_rel);
520 if ($asset->writeAccess(
'attributes')) {
521 check_box($prefix.
'_add_new_relation_check');
522 text_box($prefix.
'_add_new_relation', NULL, $size=
'30', $max=
'255');
542 if ($asset->writeAccess(
'attributes')) {
543 $new_rel_check = array_get_index($_REQUEST, $prefix.
'_add_new_relation_check');
544 if (is_null($new_rel_check))
return TRUE;
546 $new_relation = array_get_index($_REQUEST, $prefix.
'_add_new_relation');
548 $new_relation = trim($new_relation);
549 $relation = $asset->getRelationIdByName($new_relation);
551 if (is_null($relation)) {
552 $asset->addRelation($new_relation);
573 if ($asset->writeAccess(
'attributes')) {
574 $relations = $asset->getActiveRelations();
575 foreach ($relations as $rel_id => $rel_name) {
576 check_box($prefix.
'_delete_relations['.$rel_id.
']');
577 if (empty($rel_name)) $rel_name =
'<em>NULL</em>';
600 if ($asset->writeAccess(
'attributes')) {
601 $rel_to_delete = array_get_index($_REQUEST, $prefix.
'_delete_relations');
602 if (empty($rel_to_delete))
return TRUE;
604 foreach ($rel_to_delete as $rel_id => $junk) {
605 $asset->deleteRelation($rel_id);
626 $all_relations = $asset->getActiveRelations();
627 $all_reflections = $asset->getReflections();
628 $all_available_relations = array_flip(array_keys($all_relations));
629 $available_relations = $all_available_relations;
631 foreach ($all_reflections as $start => $end) {
632 if (!isset($available_relations[$start]))
continue;
634 $start_name = array_get_index($all_relations, $start);
635 if (is_null($start_name)) {
636 if (!isset($all_available_relations[$start])) {
637 $start_name =
'<em style="color:red">Unknown Relation. Invalid Reflection.</em>';
640 $start_name =
'<em>No Name</em>';
644 $end_name = array_get_index($all_relations, $end);
645 if (is_null($end_name)) {
646 if (!isset($all_available_relations[$end])) {
647 $end_name =
'<em style="color:red">Unknown Relation. Invalid Reflection.</em>';
650 $end_name =
'<em>No Name</em>';
656 }
else if ($start_name == $end_name) {
663 echo
'<td align="right" style="color: '.$colour.
'">';
669 echo
'<td align="left" style="color: '.$colour.
'">';
673 if ($asset->writeAccess(
'attributes')) {
674 check_box($prefix.
'_delete_reflection['.$start.
']');
678 unset($available_relations[$start]);
679 unset($available_relations[$end]);
684 foreach ($all_relations as $id => $name) {
685 if (!isset($available_relations[$id])) {
686 unset($all_relations[$id]);
690 if ($asset->writeAccess(
'attributes') && !empty($all_relations)) {
691 $relations[NULL] =
'-- Select Relation --';
692 $relations += $all_relations;
693 combo_box($prefix.
'_reflect_start', $relations, FALSE);
694 echo
' <- Reflects -> ';
695 combo_box($prefix.
'_reflect_end', $relations, FALSE);
716 $all_reflexions = $asset->getReflections();
717 if ($asset->writeAccess(
'attributes')) {
718 $delete_reflections = array_get_index($_REQUEST, $prefix.
'_delete_reflection', Array());
719 foreach ($delete_reflections as $start_id => $flag) {
720 $asset->deleteReflection($start_id);
723 $start_id = array_get_index($_REQUEST, $prefix.
'_reflect_start');
724 $end_id = array_get_index($_REQUEST, $prefix.
'_reflect_end');
726 if ($start_id !==
'' && $end_id !==
'') {
727 $asset->addReflection($start_id, $end_id);
748 $relations = $asset->getActiveRelations();
749 $all_reflections = $asset->getReflections();
751 foreach ($all_reflections as $rel_id => $reflect_id) {
752 unset ($relations[$rel_id]);
755 if (!empty($relations)) {
756 echo
'<span style="color: red">Configuration of this thesaurus is NOT ANSI/NISO Z39.19-2005 compliant<br />';
757 echo
'Below is a list of relations which have not been paired up<br /></span>';
759 foreach ($relations as $rel_id => $relation_name) {
760 if (empty($relation_name)) {
761 $relation_name =
'<em>NULL</em>';
768 echo
'configuration is ANSI compliant';
789 $current_rel = $asset->attr(
'hierarchy_rel');
790 $relations = $asset->getActiveRelations();
792 if (empty($current_rel)) $current_rel = NULL;
794 if (!$asset->writeAccess(
'attributes')) {
795 $rel = array_get_index($relations, $current_rel);
796 if (is_null($current_rel)) {
797 $rel =
'<em>Nothing Selected</em>';
798 }
else if (empty($rel)) {
799 $rel =
'<em>NULL</em>';
800 }
else if (is_null($rel)) {
801 $rel =
'<em style="color:red">Invalid Relation ID ('.$current_rel.
')</em>';
808 if (!isset($relations[$current_rel]) && !is_null($current_rel)) {
809 echo
'Invalid Relation selected';
813 $selectable_relations[NULL] =
'-- Nothing Selected --';
814 $selectable_relations += $relations;
815 combo_box($prefix.
'_hierarchy_relation', $selectable_relations, FALSE, $current_rel);
835 if ($asset->writeAccess(
'attributes')) {
836 $selected_rel = array_get_index($_REQUEST, $prefix.
'_hierarchy_relation');
837 $selected_rel = trim($selected_rel);
838 if (empty($selected_rel)) $selected_rel = NULL;
840 $asset->setAttrValue(
'hierarchy_rel', $selected_rel);