summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-12-08 11:12:26 +0000
committerDries Buytaert <dries@buytaert.net>2001-12-08 11:12:26 +0000
commit67ac175ed53830ceb2a7174c08c5c33f4ab7f662 (patch)
treedfd9cc905b9b7c392e9493c4e0a8ed0b83ac8fef /includes
parent8eb45a6ebaae86f29d96c35dd7b247030fbaec24 (diff)
downloadbrdo-67ac175ed53830ceb2a7174c08c5c33f4ab7f662.tar.gz
brdo-67ac175ed53830ceb2a7174c08c5c33f4ab7f662.tar.bz2
- Working on the filter code: removed the "filter()" statemets from the
node.module; I'll move this to the individual modules as they are the only one's who know what to do best with it. - Merged node.inc and node.module.
Diffstat (limited to 'includes')
-rw-r--r--includes/node.inc243
1 files changed, 0 insertions, 243 deletions
diff --git a/includes/node.inc b/includes/node.inc
deleted file mode 100644
index c23a3a6bd..000000000
--- a/includes/node.inc
+++ /dev/null
@@ -1,243 +0,0 @@
-<?php
-// $Id$
-
-// TODO: still used by themes, yet doesn't return anything at the moment
-function node_index() {
-}
-
-function node_get_comments($nid) {
- $comment = db_fetch_object(db_query("SELECT COUNT(c.lid) AS number FROM node n LEFT JOIN comments c ON n.nid = c.lid WHERE n.nid = '$nid' GROUP BY n.nid"));
- return $comment->number ? $comment->number : 0;
-}
-
-function node_teaser($body) {
-
- $size = 400;
-
- /*
- ** If we have a short body, return the entire body:
- */
-
- if (strlen($body) < $size) {
- return $body;
- }
-
- /*
- ** If we have a long body, try not to split paragraphs:
- */
-
- if ($length = strpos($body, "\n", $size)) {
- return substr($body, 0, $length + 1);
- }
-
- /*
- ** If we have a long body, try not to split sentences:
- */
-
- return substr($body, 0, strpos($body, ". ", $size) + 1);
-
-}
-
-function node_invoke($node, $name, $arg = 0) {
- if (is_array($node)) {
- $function = $node[type] ."_$name";
- }
- else if (is_object($node)) {
- $function = $node->type ."_$name";
- }
- else if (is_string($node)) {
- $function = $node ."_$name";
- }
-
- if (function_exists($function)) {
- return ($arg ? $function($node, $arg) : $function($node));
- }
-}
-
-function node_object($node) {
-
- if (is_array($node)) {
- foreach ($node as $key => $value) {
- $object->$key = $value;
- }
- }
- else {
- $object = $node;
- }
-
- return $object;
-}
-
-function node_array($node) {
-
- if (is_object($node)) {
- foreach ($node as $key => $value) {
- $array[$key] = $value;
- }
- }
- else {
- $array = $node;
- }
-
- return $array;
-}
-
-function node_load($conditions) {
-
- /*
- ** Turn the conditions into a query:
- */
-
- foreach ($conditions as $key => $value) {
- $cond[] = "n.". check_query($key) ." = '". check_query($value) ."'";
- }
-
- /*
- ** Retrieve the node:
- */
-
- $node = db_fetch_object(db_query("SELECT n.*, u.uid, u.name FROM node n LEFT JOIN users u ON u.uid = n.uid WHERE ". implode(" AND ", $cond)));
-
- /*
- ** Unserialize the revisions field:
- */
-
- if ($node->revisions) {
- $node->revisions = unserialize($node->revisions);
- }
-
- /*
- ** Call the node specific callback (if any) and piggy-back the
- ** results to the node or overwrite some values:
- */
-
- if ($extra = module_invoke($node->type, "load", $node)) {
- foreach ($extra as $key => $value) {
- $node->$key = $value;
- }
- }
-
- return $node;
-}
-
-function node_save($node, $filter) {
-
- $fields = array("nid", "uid", "type", "title", "teaser", "body", "revisions", "score", "status", "comment", "promote", "moderate", "created", "changed", "users", "votes");
-
- foreach ($filter as $key => $value) {
- /*
- ** Only save those fields specified by the filter. If the filter
- ** does not specify a default value, use the value of the $node's
- ** corresponding field instead.
- */
-
- if (is_numeric($key)) {
- if (isset($node->$value)) {
- // The above check is mandatory.
- $edit->$value = $node->$value;
- }
- }
- else {
- if (isset($value)) {
- // The above check is mandatory.
- $edit->$key = $value;
- }
- }
- }
-
- $node = $edit;
-
- /*
- ** Serialize the revisions field:
- */
-
- if ($node->revisions) {
- $node->revisions = serialize($node->revisions);
- }
-
- /*
- ** Apply filters to some default node fields:
- */
-
- if (empty($node->nid)) {
-
- /*
- ** Insert a new node:
- */
-
- // set some required fields:
- $node->created = time();
- $node->nid = db_result(db_query("SELECT MAX(nid) + 1 FROM node"));
-
- // prepare the query:
- foreach ($node as $key => $value) {
- if (in_array($key, $fields)) {
- $k[] = check_query($key);
- $v[] = "'". check_query($value) ."'";
- }
- }
-
- // insert the node into the database:
- db_query("INSERT INTO node (". implode(", ", $k) .") VALUES (". implode(", ", $v) .")");
-
- // call the node specific callback (if any):
- module_invoke($node->type, "insert", $node);
- }
- else {
-
- /*
- ** Update an existing node:
- */
-
- // set some required fields:
- $node->changed = time();
-
- // prepare the query:
- foreach ($node as $key => $value) {
- if (in_array($key, $fields)) {
- $q[] = check_query($key) ." = '". check_query($value) ."'";
- }
- }
-
- // update the node in the database:
- db_query("UPDATE node SET ". implode(", ", $q) ." WHERE nid = '$node->nid'");
-
- // call the node specific callback (if any):
- module_invoke($node->type, "update", $node);
-
- }
-
- /*
- ** Return the node ID:
- */
-
- return $node->nid;
-
-}
-
-function node_view($node, $main = 0) {
- global $theme;
-
- if (is_array($node)) {
- $node = node_object($node);
- }
-
- /*
- ** The "view" hook can be implemented to overwrite the default function
- ** to display nodes.
- */
-
- if (module_hook($node->type, "view")) {
- node_invoke($node, "view", $main);
- }
- else {
-
- /*
- ** Default behavior:
- */
-
- $theme->node($node, $main);
- }
-}
-
-?>