From 67675b498c9479fac54547270c209bc5cd469a62 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Mon, 24 May 2004 18:37:50 +0000 Subject: - More code improvements by JonBob. --- modules/title.module | 71 +++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 32 deletions(-) (limited to 'modules/title.module') diff --git a/modules/title.module b/modules/title.module index 38bba8e10..35907241a 100644 --- a/modules/title.module +++ b/modules/title.module @@ -1,16 +1,14 @@ $node->nid)); - print theme("page", node_show($node, NULL), $node->title); + $node = node_load(array('nid' => $node->nid)); + print theme('page', node_show($node, NULL), $node->title); } else { - $header = array(t("Type"), t("Title"), t("Author")); + $header = array(t('Type'), t('Title'), t('Author')); while ($node = db_fetch_object($result)) { - $type = ucfirst(module_invoke($node->type, "node", "name")); + $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")); + $rows[] = array(array('data' => $type, 'class' => 'type'), array('data' => $title, 'class' => 'content'), array('data' => $author, 'class' => 'author')); } - $output = "
"; - $output .= theme("table", $header, $rows); - $output .= "
"; + $output = '
'; + $output .= theme('table', $header, $rows); + $output .= '
'; - drupal_set_title(t("Matching Posts")); - print theme("page", $output); + drupal_set_title(t('Matching Posts')); + print theme('page', $output); } } -function title_filter($op, $text = "") { +/** + * Implementation of hook_filter(). + */ +function title_filter($op, $text = '') { switch ($op) { - case "name": - return t("Title filter"); - case "process": + case 'name': + return t('Title filter'); + case 'process': return _title_filter_process($text); - case "settings": + case 'settings': return _title_filter_settings($text); default: return $text; } } -// filter [node title|description] links. '|description' is optional. +/** + * Filter [Node title|Description] links. '|Description' is optional. + */ function _title_filter_process($text) { - $pattern = '\[([^\|\]\n]+)(?>\|?)([^\]\n]*)\]'; // $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. + $pattern = '\[([^\|\]\n]+)(?>\|?)([^\]\n]*)\]'; + // $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); } function _title_filter_settings() { - return form_group(t("Title filter"), t("Wiki-like [node title|text] links are enabled. These shortcuts 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 form_group(t('Title filter'), t('Wiki-like [node title|text] links are enabled. These shortcuts 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.')); } function title_compose_tips() { - 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'.")); + 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".')); } ?> -- cgit v1.2.3