summaryrefslogtreecommitdiff
path: root/modules/path/path.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2005-12-05 09:11:33 +0000
committerDries Buytaert <dries@buytaert.net>2005-12-05 09:11:33 +0000
commit28fdb3975e2bc53061277f4fdb1147dc8d3ba128 (patch)
tree06c355049d6e98b30417addd2a0942962e4f18cc /modules/path/path.module
parent3e36be3b24423566e6d9de2c1c8cbea5ca68b295 (diff)
downloadbrdo-28fdb3975e2bc53061277f4fdb1147dc8d3ba128.tar.gz
brdo-28fdb3975e2bc53061277f4fdb1147dc8d3ba128.tar.bz2
- Patch #39778 by chx: obliterate nodeapi op form in favor of the forms API's way of doing things. Tested with help from webchick.
Diffstat (limited to 'modules/path/path.module')
-rw-r--r--modules/path/path.module38
1 files changed, 30 insertions, 8 deletions
diff --git a/modules/path/path.module b/modules/path/path.module
index 6929ba822..5ba006086 100644
--- a/modules/path/path.module
+++ b/modules/path/path.module
@@ -185,14 +185,6 @@ function path_nodeapi(&$node, $op, $arg) {
}
break;
- case 'form':
- $form['path'] = array('#type' => 'fieldset', '#title' => t('URL path settings'), '#collapsible' => TRUE, '#collapsed' => TRUE);
- $form['path']['path'] = array('#type' => 'textfield', '#default_value' => $node->path, '#maxlength' => 250, '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => t('Optionally specify an alternative URL by which this node can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'));
- if ($node->path) {
- $form['path']['pid'] = array('#type' => 'hidden', '#value' => db_result(db_query("SELECT pid FROM {url_alias} WHERE dst = '%s'", $node->path)));
- }
- return $form;
-
case 'load':
$path = "node/$node->nid";
$alias = drupal_get_path_alias($path);
@@ -224,6 +216,36 @@ function path_nodeapi(&$node, $op, $arg) {
}
/**
+ * Implementation of hook_form_alter().
+ */
+function path_form_alter($form_id, &$form) {
+ if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
+ $path = $form['#node']->path;
+ $form['path'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('URL path settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+ $form['path']['path'] = array(
+ '#type' => 'textfield',
+ '#default_value' => $path,
+ '#maxlength' => 250,
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#description' => t('Optionally specify an alternative URL by which this node can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'),
+ );
+ if ($node->path) {
+ $form['path']['pid'] = array(
+ '#type' => 'value',
+ '#value' => db_result(db_query("SELECT pid FROM {url_alias} WHERE dst = '%s'", $path))
+ );
+ }
+ }
+}
+
+
+/**
* Implementation of hook_perm().
*/
function path_perm() {