/**
  * Delete a node.
  */
 function deleteNode($nid)
 {
     // Implemention taken from node_delete, with some assumptions regarding
     // function_exists removed.
     $node = node_load($nid);
     db_query('DELETE FROM {node} WHERE nid = %d', $node->nid);
     db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid);
     // Call the node-specific callback (if any):
     node_invoke($node, 'delete');
     node_invoke_nodeapi($node, 'delete');
     // Clear the page and block caches.
     cache_clear_all();
 }
function _ttt_node_delete($nid)
{
    // Clear the cache before the load, so if multiple nodes are deleted, the
    // memory will not fill up with nodes (possibly) already removed.
    $node = node_load($nid, NULL, TRUE);
    db_query('DELETE FROM {node} WHERE nid = %d', $node->nid);
    db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid);
    db_query('DELETE FROM {node_access} WHERE nid = %d', $node->nid);
    // Call the node-specific callback (if any):
    node_invoke($node, 'delete');
    node_invoke_nodeapi($node, 'delete');
    // Remove this node from the search index if needed.
    if (function_exists('search_wipe')) {
        search_wipe($node->nid, 'node');
    }
}
Beispiel #3
0
 /**
  * Override node_delete() core Drupal function.
  * Skip user access function during the importing.
  *
  * @param int $nid The nodeID
  */
 protected function node_delete($nid)
 {
     // Clear the cache before the load, so if multiple nodes are deleted, the
     // memory will not fill up with nodes (possibly) already removed.
     $node = node_load($nid, NULL, TRUE);
     db_query('DELETE FROM {node} WHERE nid = %d', $node->nid);
     db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid);
     // Call the node-specific callback (if any):
     node_invoke($node, 'delete');
     node_invoke_nodeapi($node, 'delete');
     // Clear the page and block caches.
     cache_clear_all();
     // Remove this node from the search index if needed.
     if (function_exists('search_wipe')) {
         search_wipe($node->nid, 'node');
     }
     watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title));
     drupal_set_message(t('@type %title has been deleted.', array('@type' => node_get_types('name', $node), '%title' => $node->title)));
 }
Beispiel #4
0
function dewey_render_node_body($nid)
{
    $node = node_load($nid);
    $node->build_mode = DEWEY_BUILD_FULL;
    $node = node_build_content($node, FALSE, TRUE);
    // Set the proper node part, then unset unused $node part so that a bad
    // theme can not open a security hole.
    $content = drupal_render($node->content);
    $node->body = $content;
    unset($node->teaser);
    // Allow modules to modify the fully-built node.
    node_invoke_nodeapi($node, 'alter');
    return $node->body;
}
function phptemplate_views_rss_feed_recent_blog_posts_rss($view, $nodes, $type)
{
    if ($type == 'block') {
        return;
    }
    global $base_url;
    $channel = array('title' => views_get_title($view, 'page'), 'link' => url($view->feed_url ? $view->feed_url : $view->real_url, NULL, NULL, true), 'description' => $view->description);
    $item_length = 'fulltext';
    $namespaces = array('xmlns:dc="http://purl.org/dc/elements/1.1/"');
    // Except for the original being a while and this being a foreach, this is
    // completely cut & pasted from node.module.
    foreach ($nodes as $node) {
        // Load the specified node:
        $item = node_load($node->nid);
        $link = url("node/{$node->nid}", NULL, NULL, 1);
        if ($item_length != 'title') {
            $teaser = $item_length == 'teaser' ? TRUE : FALSE;
            // Filter and prepare node teaser
            if (node_hook($item, 'view')) {
                node_invoke($item, 'view', $teaser, FALSE);
            } else {
                $item = node_prepare($item, $teaser);
            }
            // Allow modules to change $node->teaser before viewing.
            node_invoke_nodeapi($item, 'view', $teaser, FALSE);
        }
        // Allow modules to add additional item fields
        $extra = node_invoke_nodeapi($item, 'rss item');
        $extra = array_merge($extra, array(array('key' => 'pubDate', 'value' => date('r', $item->created)), array('key' => 'dc:creator', 'value' => $item->name), array('key' => 'guid', 'value' => $item->nid . ' at ' . $base_url, 'attributes' => array('isPermaLink' => 'false'))));
        foreach ($extra as $element) {
            if ($element['namespace']) {
                $namespaces = array_merge($namespaces, $element['namespace']);
            }
        }
        // Prepare the item description
        switch ($item_length) {
            case 'fulltext':
                $item_text = $item->body;
                break;
            case 'teaser':
                $item_text = $item->teaser;
                if ($item->readmore) {
                    $item_text .= '<p>' . l(t('read more'), 'node/' . $item->nid, NULL, NULL, NULL, TRUE) . '</p>';
                }
                break;
            case 'title':
                $item_text = '';
                break;
        }
        $items .= format_rss_item($item->title, $link, $item_text, $extra);
    }
    $channel_defaults = array('version' => '2.0', 'title' => variable_get('site_name', 'drupal') . ' - ' . variable_get('site_slogan', ''), 'link' => $base_url, 'description' => variable_get('site_mission', ''), 'language' => $GLOBALS['locale']);
    $channel = array_merge($channel_defaults, $channel);
    $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
    $output .= "<rss version=\"" . $channel["version"] . "\" xml:base=\"" . $base_url . "\" " . implode(' ', $namespaces) . ">\n";
    $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']);
    $output .= "</rss>\n";
    drupal_set_header('Content-Type: text/xml; charset=utf-8');
    print $output;
    module_invoke_all('exit');
    exit;
}
Beispiel #6
0
/**
 * Update Drupal's full-text index for this module.
 *
 * Modules can implement this hook if they want to use the full-text indexing
 * mechanism in Drupal.
 *
 * This hook is called every cron run if search.module is enabled. A module
 * should check which of its items were modified or added since the last
 * run. It is advised that you implement a throttling mechanism which indexes
 * at most 'search_cron_limit' items per run (see example below).
 *
 * You should also be aware that indexing may take too long and be aborted if
 * there is a PHP time limit. That's why you should update your internal
 * bookkeeping multiple times per run, preferably after every item that
 * is indexed.
 *
 * Per item that needs to be indexed, you should call search_index() with
 * its content as a single HTML string. The search indexer will analyse the
 * HTML and use it to assign higher weights to important words (such as
 * titles). It will also check for links that point to nodes, and use them to
 * boost the ranking of the target nodes.
 *
 * @ingroup search
 */
function hook_update_index()
{
    $last = variable_get('node_cron_last', 0);
    $limit = (int) variable_get('search_cron_limit', 100);
    $result = db_query_range('SELECT n.nid, c.last_comment_timestamp FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE n.status = 1 AND n.moderate = 0 AND (n.created > %d OR n.changed > %d OR c.last_comment_timestamp > %d) ORDER BY GREATEST(n.created, n.changed, c.last_comment_timestamp) ASC', $last, $last, $last, 0, $limit);
    while ($node = db_fetch_object($result)) {
        $last_comment = $node->last_comment_timestamp;
        $node = node_load(array('nid' => $node->nid));
        // We update this variable per node in case cron times out, or if the node
        // cannot be indexed (PHP nodes which call drupal_goto, for example).
        // In rare cases this can mean a node is only partially indexed, but the
        // chances of this happening are very small.
        variable_set('node_cron_last', max($last_comment, $node->changed, $node->created));
        // Get node output (filtered and with module-specific fields).
        if (node_hook($node, 'view')) {
            node_invoke($node, 'view', false, false);
        } else {
            $node = node_prepare($node, false);
        }
        // Allow modules to change $node->body before viewing.
        node_invoke_nodeapi($node, 'view', false, false);
        $text = '<h1>' . drupal_specialchars($node->title) . '</h1>' . $node->body;
        // Fetch extra data normally not visible
        $extra = node_invoke_nodeapi($node, 'update_index');
        foreach ($extra as $t) {
            $text .= $t;
        }
        // Update index
        search_index($node->nid, 'node', $text);
    }
}
if ($links) {
    $node->links = module_invoke_all('link', 'node', $node, $teaser);
    drupal_alter('link', $node->links, $node);
}
// Set the proper node part, then unset unused $node part so that a bad
// theme can not open a security hole.
$content = drupal_render($node->content);
if ($teaser) {
    $node->teaser = $content;
    unset($node->body);
} else {
    $node->body = $content;
    unset($node->teaser);
}
// Allow modules to modify the fully-built node.
node_invoke_nodeapi($node, 'alter', $teaser, $page);
?>
	<div class="rev-news__title">
			<a href="<?php 
print url('node/' . $node->nid);
?>
"><?php 
print $node->title;
?>
</a>
	</div>
	<div class="rev-news__date"><?php 
print date('d-m-Y', $node->created);
?>
</div>