public function hook_page_alter(&$page) { // Add an extra "Panelizer" action on the content types admin page. if ($_GET['q'] == 'admin/structure/types') { // This only works with some themes. if (!empty($page['content']['system_main']['node_table'])) { // Shortcut. $table =& $page['content']['system_main']['node_table']; // Operations column should always be the last column in header. // Increase its colspan by one to include possible panelizer link. $operationsCol = end($table['#header']); if (!empty($operationsCol['colspan'])) { $operationsColKey = key($table['#header']); $table['#header'][$operationsColKey]['colspan']++; } // Since we can't tell what row a type is for, but we know that they // were generated in this order, go through the original types list. $types = node_type_get_types(); $names = node_type_get_names(); $row_index = 0; foreach ($names as $bundle => $name) { $type = $types[$bundle]; if (node_hook($type->type, 'form')) { $type_url_str = str_replace('_', '-', $type->type); if ($this->is_panelized($bundle) && panelizer_administer_entity_bundle($this, $bundle)) { $table['#rows'][$row_index][] = array('data' => l(t('panelizer'), 'admin/structure/types/manage/' . $type_url_str . '/panelizer')); } else { $table['#rows'][$row_index][] = array('data' => ''); } // Update row index for next pass. $row_index++; } } } } }
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; }
public function hook_page_alter(&$page) { if ($_GET['q'] == 'admin/structure/types' && !empty($page['content']['system_main']['node_table'])) { // shortcut $table =& $page['content']['system_main']['node_table']; // Modify the header. $table['#header'][1]['colspan'] = 5; // Since we can't tell what row a type is for, but we know that they // were generated in this order, go through the original types // list: $types = node_type_get_types(); $names = node_type_get_names(); $row_index = 0; foreach ($names as $bundle => $name) { $type = $types[$bundle]; if (node_hook($type->type, 'form')) { $type_url_str = str_replace('_', '-', $type->type); if ($this->is_panelized($bundle) && panelizer_administer_entity_bundle($this, $bundle)) { $table['#rows'][$row_index][] = array('data' => l(t('panelizer'), 'admin/structure/types/manage/' . $type_url_str . '/panelizer')); } else { $table['#rows'][$row_index][] = array('data' => ''); } // Update row index for next pass: $row_index++; } } } }
/** * 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. module_invoke_all('node_view', $node, false, false); $text = '<h1>' . drupal_specialchars($node->title) . '</h1>' . $node->body; // Fetch extra data normally not visible $extra = module_invoke_all('node_update_index', $node); foreach ($extra as $t) { $text .= $t; } // Update index search_index($node->nid, 'node', $text); } }