Index: taxonomy_redirect.module =================================================================== --- taxonomy_redirect.module (revision 2188) +++ taxonomy_redirect.module (revision 2199) @@ -115,11 +115,13 @@ ); // Value for the onclick attribute of the 'load into editor' link. - $onclick = 'document.getElementById(\'edit-path\').value = decodeURIComponent( \''.rawurlencode($redirect->path).'\'); - document.getElementById(\'edit-path-case\').value = \''.$redirect->path_case.'\'; - document.getElementById(\'edit-filter\').value = \''.$redirect->filter.'\'; - document.getElementById(\'edit-separator-replace\').value = decodeURIComponent( \''.rawurlencode($redirect->separator_replace).'\'); - document.getElementById(\'edit-remove-text\').value = decodeURIComponent( \''.rawurlencode($redirect->remove_text).'\'); + $onclick = '$(\'#edit-add-redirect-vocab-select\').val('.$redirect->vid.'); + vocab($(\'#edit-add-redirect-vocab-select\').val()); + $(\'#edit-path\').val(decodeURIComponent( \''.rawurlencode($redirect->path).'\')); + $(\'#edit-path-case\').val(\''.$redirect->path_case.'\'); + $(\'#edit-filter\').val(\''.$redirect->filter.'\'); + $(\'#edit-separator-replace\').val(decodeURIComponent( \''.rawurlencode($redirect->separator_replace).'\')); + $(\'#edit-remove-text\').val(decodeURIComponent( \''.rawurlencode($redirect->remove_text).'\')); return false;'; $form['redirects'][$i]['load'] = array( @@ -217,34 +219,34 @@ '#rows' => 5, ); - $form['add_redirect']['path_case'] = array( - '#id' => 'edit-path-case', - '#type' => 'select', - '#title' => t('Path Case'), - '#description' => t('How to transform the case of the path.'), - '#options' => array( - 'No transform' => 'No transform', - 'Uppercase' => 'Uppercase', - 'Lowercase' => 'Lowercase', - ), - '#default_value' => 'No transform', + $form['add_redirect']['remove_text'] = array( + '#id' => 'edit-remove-text', + '#type' => 'textarea', + '#title' => t('Remove text'), + '#description' => t('A list of text to be removed from the url. Put each piece of text to be removed on a new line. Text can be one or more characters. This may be useful to remove punctuation. This removal will be done before separators are replaced. (case sensitive)'), + '#rows' => 4, ); $form['add_redirect']['separator_replace'] = array( '#id' => 'edit-separator-replace', '#type' => 'textfield', '#title' => t('Separator'), - '#description' => t('Character used to separate words in titles. This will replace any spaces and + characters. Using a space or + character can cause unexpected results. Leave empty if you don\'t want to replace these characters.'), + '#description' => t('Character used to separate words in titles. This will replace any spaces and + characters. Using a space or + character can cause unexpected results. Leave empty if you don\'t want to replace these characters. This happens after the text above is removed.'), '#maxlength' => 1, '#size' => 1, ); - $form['add_redirect']['remove_text'] = array( - '#id' => 'edit-remove-text', - '#type' => 'textarea', - '#title' => t('Remove text'), - '#description' => t('A list of text to be removed from the url. Put each piece of text to be removed on a new line. Text can be one or more characters. This may be useful to remove punctuation. This removal will be done before separators are replaced. (case sensitive)'), - '#rows' => 4, + $form['add_redirect']['path_case'] = array( + '#id' => 'edit-path-case', + '#type' => 'select', + '#title' => t('Path Case'), + '#description' => t('How to transform the case of the path. This happens after the separator character is replaced.'), + '#options' => array( + 'No transform' => 'No transform', + 'Uppercase' => 'Uppercase', + 'Lowercase' => 'Lowercase', + ), + '#default_value' => 'No transform', ); $form['save'] = array( @@ -521,6 +523,8 @@ // Remove the child term from the array array_pop($parents); $parent_path = ''; + $parent_names = ''; + $parent_ids = ''; foreach ($parents as $parent) { $parent_names = $parent_names ? $parent_names.'/'.$parent->name : $parent->name; $parent_ids = $parent_ids ? $parent_ids.'/'.$parent->tid : $parent->tid; @@ -556,6 +560,11 @@ $path = str_replace('//', '/', $path); } + // remove any leading slashes, they will break the url() and l() functions + while (strpos($path, '/') === 0) { + $path = substr($path, 1); + } + return t($path); } Index: taxonomy_redirect.js =================================================================== --- taxonomy_redirect.js (revision 2188) +++ taxonomy_redirect.js (revision 2199) @@ -1,28 +1,28 @@ function vocab(id) { + // no vocabulary was selected if (id == 0) { - divTermSelect = document.getElementById("div_termselect"); - - while (divTermSelect.hasChildNodes()) { - divTermSelect.removeChild(divTermSelect.firstChild); - } + // empty the term selector block + $("#div_termselect").empty(); } + + // a vocabulary was selected else { - termSelect = document.getElementById("term_select_"+id).cloneNode(true); - divTermSelect = document.getElementById("div_termselect"); - termSelect.style.display = "block"; + // grab the selector block + divTermSelect = $("#div_termselect"); - while (divTermSelect.hasChildNodes()) { - divTermSelect.removeChild(divTermSelect.firstChild); - } + // empty the term selector block + divTermSelect.empty(); - divTermSelect.appendChild(termSelect); - legendDiv = divTermSelect.appendChild(document.createElement("div")); - legendDiv.innerHTML = "If you do not select a term, this rule will apply to all terms in this vocabulary."; - divTermSelect.appendChild(legendDiv); + // grab the term selector, clone it and make the clone visible + termSelect = $("#term_select_"+id).clone(true).show(); + + // append the selector & a message + divTermSelect.append(termSelect).append("
If you do not select a term, this rule will apply to all terms in this vocabulary.
"); } } +// function term(id) { - document.getElementById("term_id").value=id; + $("#term_id").val(id); } \ No newline at end of file