From 171479fcfa4ddd85c7a1d9564ca286a5c91a418f Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 10 Feb 2001 14:36:49 +0000 Subject: [PATCH] - a 2nd batch of various updates --- CHANGELOG | 28 ++++++++++++++ CREDITS | 16 ++++++++ account.php | 68 +++++++++----------------------- includes/search.inc | 30 ++++++++++++++ includes/theme.inc | 2 +- modules/account.module | 4 +- modules/comment.module | 4 +- modules/comment/comment.module | 4 +- modules/diary.module | 4 +- modules/story.module | 4 +- modules/story/story.module | 4 +- search.php | 71 ++++++++-------------------------- 12 files changed, 122 insertions(+), 117 deletions(-) create mode 100644 CHANGELOG create mode 100644 CREDITS create mode 100644 includes/search.inc diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 00000000000..b1fe08ff7a5 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,28 @@ +drupal 1.xx, xx/xx/2001 +----------------------- +- rewrote the comment/discussion code: + * comment navigation should be less confusing now additional/alternative + display and order methods have been added. + * modules can be extended with a "comment system" as they can embed the + existing comment code without having to write duplicate code. +- added section manager: + * story sections can be maintained from the administration pages. + * makes the open submission more adaptive in that you can set individual + post, dump and expiration thresholds for each section according to the + story type and urgency level: some section do not really "expire" and + stay interesting and active as time passes by, whereas news-related + stories are only considered "hot" over a short period of time. +- multiple vhosts + multiple directories: + * you can setup multiple drupal sites on top of the same physical source + tree either by using vhosts or sub-directories +- added "user ratings" similar to SlashCode's karma or Scoop's mojo. +- added search infractructure: + * better search page + search functionality in administration pages. +- various updates: + * improved cron-module + * improved module-module + * revised documentation + +drupal 1.00, 15/01/2001 +----------------------- +- initial release \ No newline at end of file diff --git a/CREDITS b/CREDITS new file mode 100644 index 00000000000..be4a9dabd75 --- /dev/null +++ b/CREDITS @@ -0,0 +1,16 @@ +Listed in order of "appearance": + +Dries Buytaert + - project architect + +Jeroen Bensch + - themes and images + +Steven Wittens + - themes and images + +Kjartan Mannes + - hosting, hardware, bandwidth + +Michael O'Henly + - documentation revisions diff --git a/account.php b/account.php index 2528c17f270..5d2d81b654c 100644 --- a/account.php +++ b/account.php @@ -222,7 +222,7 @@ function account_content_edit() { $output .= "\n"; $theme->header(); - $theme->box("Edit site content", $output); + $theme->box("Edit your content", $output); $theme->footer(); } else { @@ -255,17 +255,16 @@ function account_user($uname) { if ($user->id && $user->userid == $uname) { $output .= "\n"; - $output .= " \n"; - $output .= " \n"; + $output .= " \n"; $output .= " \n"; - $output .= " \n"; + $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= "
User ID:$user->userid
Name:". format_data($user->name) ."
Username:$user->userid
E-mail:". format_email($user->fake_email) ."
URL:". format_url($user->url) ."
Homepage:". format_url($user->url) ."
Bio:". format_data($user->bio) ."
Signature:". format_data($user->signature) ."
\n"; // Display account information: $theme->header(); - $theme->box("View user settings", $output); + $theme->box("Personal information", $output); $theme->footer(); } elseif ($uname && $account = account_get_user($uname)) { @@ -426,8 +425,6 @@ function account_password($min_length=6) { function account_track_comments() { global $theme, $user; - $msg = "

This page might be helpful in case you want to keep track of your recent comments in any of the current discussions. You are presented an overview of your comments in each of the stories you participated in along with the number of replies each comment got.\n

\n"; - $sresult = db_query("SELECT s.id, s.subject, COUNT(s.id) as count FROM comments c LEFT JOIN stories s ON c.lid = s.id WHERE c.author = $user->id GROUP BY s.id DESC LIMIT 5"); while ($story = db_fetch_object($sresult)) { @@ -441,7 +438,7 @@ function account_track_comments() { $output .= " \n"; } - $output = ($output) ? "$msg $output" : "$info

You have not posted any comments recently.
\n"; + $output = ($output) ? "$output" : "$info
You have not posted any comments recently.
\n"; $theme->header(); $theme->box("Track your comments", $output); @@ -451,8 +448,6 @@ function account_track_comments() { function account_track_stories() { global $theme, $user; - $msg = "

This page might be helpful in case you want to keep track of the stories you contributed. You are presented an overview of your stories along with the number of replies each story got.\n

\n"; - $result = db_query("SELECT s.id, s.subject, s.timestamp, s.section, COUNT(c.cid) as count FROM stories s LEFT JOIN comments c ON c.lid = s.id WHERE s.status = 2 AND s.author = $user->id GROUP BY s.id DESC"); while ($story = db_fetch_object($result)) { @@ -465,54 +460,29 @@ function account_track_stories() { } $theme->header(); - $theme->box("Track your stories", ($output ? "$msg $output" : "$msg You have not posted any stories.\n")); + $theme->box("Track your stories", ($output ? "$output" : "You have not posted any stories.\n")); $theme->footer(); } function account_track_site() { global $theme, $user, $site_name; - $result1 = db_query("SELECT c.cid, c.pid, c.lid, c.subject, u.userid, s.subject AS story FROM comments c LEFT JOIN users u ON u.id = c.author LEFT JOIN stories s ON s.id = c.lid WHERE s.status = 2 ORDER BY cid DESC LIMIT 10"); + $period = 259200; // 3 days - while ($comment = db_fetch_object($result1)) { - $block1 .= "\n"; - $block1 .= " \n"; - $block1 .= " \n"; - $block1 .= " \n"; - $block1 .= "
Comment:lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."
Author:". format_username($comment->userid) ."
Story:lid\">". check_output($comment->story) ."
\n"; - $block1 .= "

\n"; + $sresult = db_query("SELECT s.subject, s.id, COUNT(c.lid) AS count FROM comments c LEFT JOIN stories s ON c.lid = s.id WHERE s.status = 2 AND c.link = 'story' AND ". time() ." - c.timestamp < $period GROUP BY c.lid ORDER BY count DESC LIMIT 10"); + while ($story = db_fetch_object($sresult)) { + $output .= "

  • ". format_plural($story->count, "new comment", "new comments") ." attached to story 'id\">". check_output($story->subject) ."':
  • "; + + $cresult = db_query("SELECT c.subject, c.cid, c.pid, u.userid FROM comments c LEFT JOIN users u ON u.id = c.author WHERE c.lid = $story->id AND c.link = 'story' ORDER BY timestamp DESC LIMIT $story->count"); + $output .= "\n"; } - $block1 = ($block1) ? $block1 : "
    There have not posted any comments recently.
    \n"; - $users_total = db_result(db_query("SELECT COUNT(id) FROM users")); - - $stories_posted = db_result(db_query("SELECT COUNT(id) FROM stories WHERE status = 2")); - $stories_queued = db_result(db_query("SELECT COUNT(id) FROM stories WHERE status = 1")); - $stories_dumped = db_result(db_query("SELECT COUNT(id) FROM stories WHERE status = 0")); - - $result = db_query("SELECT u.userid, COUNT(s.author) AS count FROM stories s LEFT JOIN users u ON s.author = u.id GROUP BY s.author ORDER BY count DESC LIMIT 10"); - while ($poster = db_fetch_object($result)) $stories_posters .= format_username($poster->userid) .", "; - - $comments_total = db_result(db_query("SELECT COUNT(cid) FROM comments")); - $comments_score = db_result(db_query("SELECT TRUNCATE(AVG(score / votes), 2) FROM comments WHERE votes > 0")); - - $result = db_query("SELECT u.userid, COUNT(c.author) AS count FROM comments c LEFT JOIN users u ON c.author = u.id GROUP BY c.author ORDER BY count DESC LIMIT 10"); - while ($poster = db_fetch_object($result)) $comments_posters .= format_username($poster->userid) .", "; - - $diaries_total = db_result(db_query("SELECT COUNT(id) FROM diaries")); - - $result = db_query("SELECT u.userid, COUNT(d.author) AS count FROM diaries d LEFT JOIN users u ON d.author = u.id GROUP BY d.author ORDER BY count DESC LIMIT 10"); - while ($poster = db_fetch_object($result)) $diaries_posters .= format_username($poster->userid) .", "; - - $block2 .= "\n"; - $block2 .= " \n"; - $block2 .= " \n"; - $block2 .= " \n"; - $block2 .= "
    Users:$users_total users
    Stories:$stories_posted posted, $stories_queued queued, $stories_dumped dumped
    [most frequent posters: $stories_posters ...]
    Comments:$comments_total comments with an average score of $comments_score
    [most frequent posters: $comments_posters ...]
    \n"; - - $theme->header(); - $theme->box("Recent comments", $block1); - $theme->box("Site statistics", $block2); + $theme->header(); + $theme->box("Track $site_name", $output); $theme->footer(); } diff --git a/includes/search.inc b/includes/search.inc new file mode 100644 index 00000000000..2fd527a9044 --- /dev/null +++ b/includes/search.inc @@ -0,0 +1,30 @@ +\n"; + $output .= " "; + $output .= " \n"; + $output .= "\n"; + return $output; +} + +function search_data($keys, $type) { + if ($keys && $type) { + $result = module_execute($type, "find", $keys); + foreach ($result as $entry) { + $output .= "

    \n"; + $output .= " $entry[subject]
    "; + $output .= " $site_url$entry[link]". ($entry[user] ? " - ". format_username($entry[user]) : "") ."". ($entry[date] ? " - ". format_date($entry[date], "small") : "") .""; + $output .= "

    \n"; + } + } + + if (!$output) { + $output .= "

    Your search yielded no results:

    • try using fewer words.
    • try using more general keywords.
    • try using different keywords.
    \n"; + } + + return $output; +} + +?> \ No newline at end of file diff --git a/includes/theme.inc b/includes/theme.inc index e54de391c0b..35573ecb8de 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -38,7 +38,7 @@ function theme_account($theme) { $content .= "

    \n"; $content .= "

  • edit your information
  • \n"; $content .= "
  • edit your preferences
  • \n"; - $content .= "
  • edit site content
  • \n"; + $content .= "
  • edit your content
  • \n"; $content .= "

    \n"; if (user_permission($user)) { diff --git a/modules/account.module b/modules/account.module index ca5ddc6db99..d88f262f0f4 100644 --- a/modules/account.module +++ b/modules/account.module @@ -69,8 +69,8 @@ function account_find($keys) { function account_search() { global $keys, $mod; - search_form($keys); - search_data($keys, $mod); + print search_form($keys); + print search_data($keys, $mod); } function account_display($order = "username") { diff --git a/modules/comment.module b/modules/comment.module index f97728e7a3f..4d73e3cafc1 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -15,8 +15,8 @@ function comment_find($keys) { function comment_search() { global $keys, $mod; - search_form($keys); - search_data($keys, $mod); + print search_form($keys); + print search_data($keys, $mod); } function comment_edit($id) { diff --git a/modules/comment/comment.module b/modules/comment/comment.module index f97728e7a3f..4d73e3cafc1 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -15,8 +15,8 @@ function comment_find($keys) { function comment_search() { global $keys, $mod; - search_form($keys); - search_data($keys, $mod); + print search_form($keys); + print search_data($keys, $mod); } function comment_edit($id) { diff --git a/modules/diary.module b/modules/diary.module index 15dac5dcdad..9eeeadae824 100644 --- a/modules/diary.module +++ b/modules/diary.module @@ -24,8 +24,8 @@ function diary_find($keys) { function diary_search() { global $keys, $mod; - search_form($keys); - search_data($keys, $mod); + print search_form($keys); + print search_data($keys, $mod); } function diary_page_overview($num = 20) { diff --git a/modules/story.module b/modules/story.module index 4a199951b42..822f1a7d715 100644 --- a/modules/story.module +++ b/modules/story.module @@ -27,8 +27,8 @@ function story_find($keys) { function story_search() { global $keys, $mod; - search_form($keys); - search_data($keys, $mod); + print search_form($keys); + print search_data($keys, $mod); } function story_help() { diff --git a/modules/story/story.module b/modules/story/story.module index 4a199951b42..822f1a7d715 100644 --- a/modules/story/story.module +++ b/modules/story/story.module @@ -27,8 +27,8 @@ function story_find($keys) { function story_search() { global $keys, $mod; - search_form($keys); - search_data($keys, $mod); + print search_form($keys); + print search_data($keys, $mod); } function story_help() { diff --git a/search.php b/search.php index f18c08e6c31..323d1b3e263 100644 --- a/search.php +++ b/search.php @@ -1,64 +1,25 @@ header(); +include_once "includes/common.inc"; - $terms = check_input($terms); +function find_module($name, $module) { + global $options, $type; + if ($module["find"]) $options .= "\n"; +} - $output .= "\n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= "
    \n"; - $output .= "
    \n"; - $output .= "
    \n"; +module_iterate("find_module"); - // section: - $output .= "\n"; +$search .= "\n"; +$search .= " \n"; +$search .= " \n"; +$search .= " \n"; +$search .= "
    \n"; - // order: - $output .= "\n"; +$output = search_data($keys, $type); - $output .= " \n"; - $output .= "
    \n"; - - // Compose and perform query: - $query = "SELECT s.id, s.subject, u.userid, s.timestamp, COUNT(c.cid) AS comments FROM stories s LEFT JOIN users u ON s.author = u.id LEFT JOIN comments c ON s.id = c.lid WHERE s.status = 2 "; - $query .= ($author) ? "AND u.userid = '$author' " : ""; - $query .= ($terms) ? "AND (s.subject LIKE '%$terms%' OR s.abstract LIKE '%$terms%' OR s.updates LIKE '%$terms%') " : ""; - $query .= ($section) ? "AND s.section = '$section' GROUP BY s.id " : "GROUP BY s.id "; - $query .= ($order == 1) ? "ORDER BY s.timestamp ASC" : "ORDER BY s.timestamp DESC"; - $result = db_query($query); - - // Display search results: - $output .= "
    \n"; - - while ($entry = db_fetch_object($result)) { - $num++; - $output .= "

    $num) id\">". check_output($entry->subject) ." (". format_plural($entry->comments, "comment", comments) .")
    by ". format_username($entry->userid) .", posted on ". format_date($entry->timestamp) .".

    \n"; - } - - if ($num == 0) $output .= "

    Your search did not match any articles in our database:

    • Try using fewer words.
    • Try using more general keywords.
    • Try using different keywords.

    \n"; - else $output .= "

    $num results matched your search query.

    \n"; - - $output .= "
    \n"; - - $theme->box("Search", $output); - $theme->footer(); +$theme->header(); +$theme->box("Search", $search); +$theme->box("Result", $output); +$theme->footer(); ?> \ No newline at end of file