From 68f2112b4d291edef3b8065ee1bf7a5379e72c6f Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 24 Mar 2001 17:04:11 +0000 Subject: - nodified index.php: the index page will only display stories for now but this will/can change in the near future - all other files now thinks in terms of nodes, rather then stories --- includes/common.inc | 1 + includes/theme.inc | 74 ++++++++++++++++++----------------------------------- 2 files changed, 26 insertions(+), 49 deletions(-) (limited to 'includes') diff --git a/includes/common.inc b/includes/common.inc index be788322e..2d24df5a5 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -21,6 +21,7 @@ include_once "includes/locale.inc"; include_once "includes/search.inc"; include_once "includes/theme.inc"; include_once "includes/user.inc"; +include_once "includes/node.inc"; user_init(); $locale = locale_init(); diff --git a/includes/theme.inc b/includes/theme.inc index 09768abd8..cc9909468 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -12,26 +12,22 @@ function theme_init() { return new Theme(); } +function theme_menu($name, $module) { + global $menu; + if ($module["menu"]) $menu = ($menu) ? array_merge($menu, $module["menu"]()) : $module["menu"](); +} + function theme_account($theme) { global $user, $site_name, $links, $menu; if ($user->id) { - function submission_number() { - $result = db_query("SELECT COUNT(id) FROM stories WHERE status = 1"); - return ($result) ? db_result($result, 0) : 0; - } - function menu($name, $module) { - global $menu; - if ($module["menu"]) $menu = ($menu) ? array_merge($menu, $module["menu"]()) : $module["menu"](); - } - - module_iterate("menu"); + module_iterate("theme_menu"); // Display account settings: $content .= "
  • ". t("track your comments") ."
  • \n"; - $content .= "
  • ". t("track your stories") ."
  • \n"; + $content .= "
  • ". t("track your nodes") ."
  • \n"; $content .= "
  • ". strtr(t("track %a"), array("%a" => $site_name)) ."
  • \n"; $content .= "

    \n"; $content .= "

  • ". t("edit your information") ."
  • \n"; @@ -72,11 +68,11 @@ function theme_blocks($region, $theme) { global $id, $PHP_SELF, $user; switch (strrchr($PHP_SELF, "/")) { - case "/story.php": + case "/node.php": if ($region != "left") { - if ($user->id) $story = db_fetch_object(db_query("SELECT * FROM stories WHERE id = '$id'")); - if ($story->status == 1) theme_moderation_results($theme, $story); - else theme_new_headlines($theme); + if ($user->id) $node = db_fetch_object(db_query("SELECT * FROM nodes WHERE nid = '$id'")); + if ($node->status == 1) theme_moderation_results($theme, $node); + // else theme_new_headlines($theme); } break; case "/index.php": @@ -90,59 +86,39 @@ function theme_blocks($region, $theme) { } } -function theme_morelink($theme, $story) { - return ($story->article) ? "[ id\">link\">". t("read more") ." | ". sizeof(explode(" ", $story->article)) ." ". t("words") ." | id\">link\">". format_plural($story->comments, "comment", "comments") ." ]" : "[ id\">link\">". format_plural($story->comments, "comment", "comments") ." ]"; +function theme_morelink($theme, $node) { + return ($node->body) ? "[ nid\">link\">". t("read more") ." | ". sizeof(explode(" ", $node->body)) ." ". t("words") ." | nid\">link\">". format_plural($node->comments, "comment", "comments") ." ]" : "[ nid\">link\">". format_plural($node->comments, "comment", "comments") ." ]"; } -function theme_moderation_results($theme, $story) { +function theme_moderation_results($theme, $node) { global $user; - if ($user->id && $story->id && ($user->id == $story->author || user_get($user, "history", "s$story->id"))) { - $result = db_query("SELECT * FROM users WHERE history LIKE '%s$story->id%'"); + if ($user->id && $node->nid && ($user->id == $node->author || user_get($user, "history", "n$node->nid"))) { + $result = db_query("SELECT * FROM users WHERE history LIKE '%n$node->nid%'"); while ($account = db_fetch_object($result)) { - $output .= format_username($account->userid) ." voted `". user_get($account, "history", "s$story->id") ."'.
    "; + $output .= format_username($account->userid) ." voted '". user_get($account, "history", "n$node->nid") ."'.
    "; } $theme->box(t("Moderation results"), ($output ? $output : t("This story has not been moderated yet."))); } } -function theme_related_links($theme, $story) { - // Parse story for -tags: - $text = stripslashes("$story->abstract $story->updates $story->article"); - while ($text = stristr($text, "") + 4); - $text = stristr($text, ""); - if (!stristr($link, "mailto:")) $content .= "
  • $link
  • "; - } - - // Stories in the same section: - $content .= "
  • ". t("More about") ." section) ."\">$story->section.
  • "; - - $theme->box(t("Related links"), $content); -} - function theme_new_headlines($theme, $num = 10) { - global $user; - - $content = ""; - $result = db_query("SELECT id, subject FROM stories WHERE status = 2 ORDER BY id DESC LIMIT $num"); - while ($story = db_fetch_object($result)) $content .= "
  • id\">". check_output($story->subject) ."
  • \n"; + $result = db_query("SELECT nid, title FROM nodes WHERE status = 2 AND type = 'story' ORDER BY nid DESC LIMIT $num"); + while ($node = db_fetch_object($result)) $content .= "
  • nid\">". check_output($node->title) ."
  • \n"; $theme->box(t("Latest headlines"), $content); } function theme_old_headlines($theme, $num = 10) { global $user; - if ($user->stories) $result = db_query("SELECT id, subject, timestamp FROM stories WHERE status = 2 ORDER BY timestamp DESC LIMIT $user->stories, $num"); - else $result = db_query("SELECT id, subject, timestamp FROM stories WHERE status = 2 ORDER BY timestamp DESC LIMIT $num, $num"); - - while ($story = db_fetch_object($result)) { - if ($time != date("F jS", $story->timestamp)) { - $content .= "

    ". date("l, M jS", $story->timestamp) ."

    \n"; - $time = date("F jS", $story->timestamp); + $result = db_query("SELECT id, subject, timestamp FROM story WHERE status = 2 ORDER BY timestamp DESC LIMIT ". ($user->nodes ? $user->nodes : $num) .", $num"); + while ($node = db_fetch_object($result)) { + if ($time != date("F jS", $node->timestamp)) { + $content .= "

    ". date("l, M jS", $node->timestamp) ."

    \n"; + $time = date("F jS", $node->timestamp); } - $content .= "
  • id\">". check_output($story->subject) ."
  • \n"; + $content .= "
  • nid\">". check_output($node->title) ."
  • \n"; } $theme->box(t("Older headlines"), $content); } -- cgit v1.2.3