17 require_once SQ_SYSTEM_ROOT.
'/core/assets/system/tool/tool.inc';
43 $this->
Tool($assetid);
60 $o->openSection(translate(
'tool_rename_thesaurus_term'));
61 $o->openField(translate(
'tool_thesaurus_term'));
62 asset_finder(
'thesaurus_term', 0, Array(
'thesaurus_term'=>
'I'));
63 $err_msg = str_replace(
"'",
"\'", translate(
'tool_thesaurus_term_empty'));
64 $o->addOnSubmit(
"if (document.getElementById('thesaurus_term[assetid]').value == 0) {
69 $o->openField(translate(
'tool_thesaurus_term_old'));
70 text_box(
'thesaurus_term_old');
71 $err_msg = str_replace(
"'",
"\'", translate(
'tool_thesaurus_term_old_empty'));
72 $o->addOnSubmit(
"if (document.getElementById('thesaurus_term_old').value == '') {
78 $o->openField(translate(
'tool_thesaurus_term_root_node'));
79 asset_finder(
'root_node', 0);
81 check_box(
'cascade',
'1', FALSE);
82 label(translate(
'tool_thesaurus_term_cascade'),
'cascade');
84 $o->sectionNote(translate(
'tool_rename_thesaurus_term_note'));
102 $current_term = array_get_index($_REQUEST[
'thesaurus_term'],
'assetid', 0);
103 $old_value = array_get_index($_REQUEST,
'thesaurus_term_old',
'');
104 $root_node = array_get_index($_REQUEST[
'root_node'],
'assetid', 0);
105 $cascade = array_get_index($_REQUEST,
'cascade', 0);
107 if (empty($current_term) || empty($old_value)) {
111 $term = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($current_term,
'', TRUE);
112 if (is_null($term)) {
117 $parts = explode(
':', $term->id);
118 $thesaurus_id = array_get_index($parts, 0, 0);
119 if (empty($thesaurus_id)) {
124 $new_value = $term->attr(
'name');
125 $running_vars = Array(
126 'thesaurusid' => $thesaurus_id,
127 'terms' => Array($old_value => $new_value),
131 if (!empty($root_node)) {
132 $root = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($root_node,
'', TRUE);
133 if (!is_null($root)) {
134 $running_vars[
'assetids'] = Array($root->id);
135 if (!empty($cascade)) {
136 $running_vars[
'cascade'] = TRUE;
142 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
143 $hh->queueHipo(
'hipo_job_rename_thesaurus_term', $running_vars);
144 $url = $hh->runQueuedJobs();
145 if (!empty($url)) $o->setRedirect($url);