From fe4b713b683521d1d29661f3c2d537b8d1febf0d Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 24 Apr 2003 21:56:12 +0000 Subject: [PATCH] - Added title module; this brings back some old functionality. Thanks Moshe and Gerhard. --- modules/search.module | 8 ++-- modules/search/search.module | 8 ++-- modules/title.module | 78 ++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 modules/title.module diff --git a/modules/search.module b/modules/search.module index 4f878e58992..fdbc0d29344 100644 --- a/modules/search.module +++ b/modules/search.module @@ -305,8 +305,8 @@ function search_save($edit) { variable_set("remove_short", $edit["remove_short"]); } -function search_view() { - global $edit, $type, $keys; +function search_view($keys = NULL) { + global $edit, $type; if (user_access("search content")) { // Construct the search form: @@ -357,7 +357,7 @@ function search_view() { } function search_page() { - + global $keys; switch (arg(1)) { case "help": @@ -366,7 +366,7 @@ function search_page() { theme("footer"); break; default: - search_view(); + search_view($keys); } } diff --git a/modules/search/search.module b/modules/search/search.module index 4f878e58992..fdbc0d29344 100644 --- a/modules/search/search.module +++ b/modules/search/search.module @@ -305,8 +305,8 @@ function search_save($edit) { variable_set("remove_short", $edit["remove_short"]); } -function search_view() { - global $edit, $type, $keys; +function search_view($keys = NULL) { + global $edit, $type; if (user_access("search content")) { // Construct the search form: @@ -357,7 +357,7 @@ function search_view() { } function search_page() { - + global $keys; switch (arg(1)) { case "help": @@ -366,7 +366,7 @@ function search_page() { theme("footer"); break; default: - search_view(); + search_view($keys); } } diff --git a/modules/title.module b/modules/title.module new file mode 100644 index 00000000000..686bfd66b3c --- /dev/null +++ b/modules/title.module @@ -0,0 +1,78 @@ +nid, NULL); + theme("footer"); + } + else { + $header = array(t("Type"), t("Title"), t("Author")); + while ($node = db_fetch_object($result)) { + $type = ucfirst(module_invoke($node->type, "node", "name")); + $title = l($node->title, "node/view/$node->nid"); + $author = format_name($node); + $rows[] = array(array("data" => $type, "class" => "type"), array("data" => $title, "class" => "content"), array("data" => $author, "class" => "author")); + } + + $output = "
"; + $output .= table($header, $rows); + $output .= "
"; + + theme("header"); + theme("box", t("Matching Posts"), $output); + theme("footer"); + } + } + else { + theme("header"); + theme("box", t("Access denied"), message_access()); + theme("footer"); + } +} + +// filter [node title|description] links. '|description' is optional. +function title_filter($text) { + if(variable_get("title_filter_link", 0)) { + $pattern = '\[([^\|\]]+)(?>\|?)(.*?)\]'; // $1 == title: matches at least 1 char up to the first '|' or ']' + // $2 == text: matches all after a following '|' (if there is) up to the next ']'. may include '|'s. + $replacement = 'l("$2" ? "$2" : "$1", "title/". urlencode("$1"))'; + return preg_replace("/$pattern/e", $replacement, $text); + } + else { + return $text; + } +} + +function title_conf_filters() { + $output = form_select(t("Enable node link tags"), "title_filter_link", variable_get("title_filter_link", 0), array(t("Disabled"), t("Enabled")), t("Enable Wiki-like [node title|text] links. This will generate a link labeled 'text' to the node with the title 'node title'. If you omit '|text', the label becomes 'node title'. You may use a substring of a node title if desired. When multiple matching titles are found, a list of matching nodes will be displayed. If no matching titles are found, a full-text search is returned.")); + return $output; +} + +function title_compose_tips() { + if (variable_get("title_filter_link", 0)) { + return array(t("You may quickly link to another node using this syntax: [node title|text]. This will generate a link labeled 'text' to the node with the title 'node title'. If you omit '|text', the label becomes 'node title'.")); + } +} + +?>