Index: path.module =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.module,v retrieving revision 1.115 diff -u -r1.115 path.module --- path.module 30 Apr 2007 17:03:26 -0000 1.115 +++ path.module 5 May 2007 02:34:02 -0000 @@ -67,6 +67,13 @@ 'access arguments' => array('administer url aliases'), 'type' => MENU_LOCAL_TASK, ); + $items['admin/build/path/search'] = array( + 'title' => 'Search aliases', + 'description' => 'Search aliases by keyword.', + 'page callback' => 'path_admin_search', + 'access arguments' => array('administer url aliases'), + 'type' => MENU_LOCAL_TASK, + ); return $items; } @@ -314,13 +321,20 @@ /** * Return a listing of all defined URL aliases. + * When search key argument passed, perform a standard search on the given key, + * and return the listing of matching URL aliases. */ -function path_overview() { +function path_overview($search_key = '') { // Enable language column if locale is enabled or if we have any alias with language $count = db_result(db_query("SELECT COUNT(*) FROM {url_alias} WHERE language != ''")); $multilanguage = (module_exists('locale') || $count); - $sql = 'SELECT * FROM {url_alias}'; + if ($search_key) { + $sql = "SELECT * FROM {url_alias} WHERE dst LIKE '". $search_key ."'"; + } + else { + $sql = 'SELECT * FROM {url_alias}'; + } $header = array( array('data' => t('Alias'), 'field' => 'dst', 'sort' => 'asc'), array('data' => t('System'), 'field' => 'src'), @@ -346,7 +360,8 @@ } if (empty($rows)) { - $rows[] = array(array('data' => t('No URL aliases available.'), 'colspan' => ($multilanguage ? 5 : 4))); + $empty_message = $search_key ? t('No URL aliases found.') : t('No URL aliases available.') ; + $rows[] = array(array('data' => $empty_message, 'colspan' => ($multilanguage ? 5 : 4))); } $output = theme('table', $header, $rows); @@ -386,3 +401,61 @@ drupal_set_message(t('The alias has been saved.')); return 'admin/build/path'; } + +/** + * Menu callback; presents a form to search URL aliases. + */ +function path_admin_search() { + $keys = path_admin_search_get_keys(); + $output = drupal_get_form('path_admin_search_form', $keys); + if (trim($keys)) { + $output .= path_overview($keys); + } + + return $output; +} + +/** + * Return a form to search URL aliases. + */ +function path_admin_search_form($keys = '') { + $form = array( + '#action' => url('admin/build/path/search'), + '#attributes' => array('class' => 'search-form'), + ); + $form['basic'] = array('#type' => 'item', '#title' => t('Enter your keywords'), '#description' => t('Enter a keyword for the alias which you wish to search. Use % and _ as query wildcards, and \ as the escape character.')); + $form['basic']['inline'] = array('#prefix' => '