public function view($node, $teaser = FALSE, $page = FALSE) { $this->addCss(); $node = node_prepare($node, $teaser); $node->content['byline'] = array('#value' => theme('newsarticle_byline', $node), '#weight' => -3); if (!$teaser) { $node->content['url'] = array('#value' => theme('more_link', $node->url, t('Read more about this...')), '#weight' => 2); } return $node; }
public function view($node, $teaser = FALSE, $page = FALSE) { $this->addCss(); $node = node_prepare($node, $teaser); if ($teaser) { $node->content['pubmed_link'] = array('#value' => theme('researchstatement_pubmed_link', $node), '#weight' => -10); } else { $wt = 0; $node->content['main'] = array('#value' => theme('researchstatement_main', $node), '#weight' => $wt++); } return $node; }
public function view($node, $teaser = FALSE, $page = FALSE) { $this->addCss(); $node = node_prepare($node, $teaser); if ($teaser) { // nothing yet } else { // undo the work of node_prepare; body is put in by theme unset($node->content['body']); $wt = 0; $node->content['main'] = array('#value' => theme('gene_main', $node), '#weight' => $wt++); } return $node; }
public function view($node, $teaser = FALSE, $page = FALSE) { $this->addCss(); if (!empty($node->image)) { $node->content['picture'] = array('#value' => theme('image', $node->image), '#weight' => -1); } if ($teaser) { $node = node_prepare($node, $teaser); } else { $node->content['body'] = array('#value' => $node->body, '#weight' => 0); $node->content['toc'] = array('#value' => theme('pubgroup_toc', $node), '#weight' => 1); } return $node; }
public function getNode() { if ($this->node == NULL) { if (arg(0) == 'node' && is_numeric(arg(1))) { $this->node = node_load(arg(1)); } else { $textId = $this->getTextId(); if ($textId) { $this->node = node_load(array('title' => $textId)); if (!$this->node) { $this->node = new stdClass(); $this->node->type = 'question_meta'; $this->node = node_prepare($this->node); } } } } return $this->node; }
/** * Display a node. * * This is a hook used by node modules. It allows a module to define a * custom method of displaying its nodes, usually by displaying extra * information particular to that node type. * * @param $node * The node to be displayed. * @param $teaser * Whether we are to generate a "teaser" or summary of the node, rather than * display the whole thing. * @return * $node. The passed $node parameter should be modified as necessary and * returned so it can be properly presented. Nodes are prepared for display * by assembling a structured array in $node->content, rather than directly * manipulating $node->body and $node->teaser. The format of this array is * the same used by the Forms API. As with FormAPI arrays, the #weight * property can be used to control the relative positions of added elements. * If for some reason you need to change the body or teaser returned by * node_prepare(), you can modify $node->content['body']['#value']. Note * that this will be the un-rendered content. To modify the rendered output, * see hook_node($op = 'alter'). * * For a detailed usage example, see node_example.module. */ function hook_view($node, $teaser = FALSE) { if ((bool) menu_get_object()) { $breadcrumb = array(); $breadcrumb[] = array('path' => 'example', 'title' => t('example')); $breadcrumb[] = array('path' => 'example/' . $node->field1, 'title' => t('%category', array('%category' => $node->field1))); $breadcrumb[] = array('path' => 'node/' . $node->nid); menu_set_location($breadcrumb); } $node = node_prepare($node, $teaser); $node->content['myfield'] = array('#value' => theme('mymodule_myfield', $node->myfield), '#weight' => 1); return $node; }
public function view($node, $teaser = FALSE, $page = FALSE) { $node = node_prepare($node, $teaser); if (module_exists('member')) { $mid = member_get_node_id($node->cuid); if ($mid) { $node->content['contributor_member'] = array('#value' => l(t('View member profile'), 'node/' . $mid), '#weight' => 10); } } return $node; }
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; }
/** * 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); } }
/** * Display a node. * * This is a hook used by node modules. It allows a module to define a * custom method of displaying its nodes, usually by displaying extra * information particular to that node type. * * @param $node * The node to be displayed. * @param $teaser * Whether we are to generate a "teaser" or summary of the node, rather than * display the whole thing. * @param $page * Whether the node is being displayed as a standalone page. If this is * TRUE, the node title should not be displayed, as it will be printed * automatically by the theme system. Also, the module may choose to alter * the default breadcrumb trail in this case. * @return * $node. The passed $node parameter should be modified as necessary and * returned so it can be properly presented. Nodes are prepared for display * by assembling a structured array in $node->content, rather than directly * manipulating $node->body and $node->teaser. The format of this array is * the same used by the Forms API. As with FormAPI arrays, the #weight * property can be used to control the relative positions of added elements. * If for some reason you need to change the body or teaser returned by * node_prepare(), you can modify $node->content['body']['#value']. Note * that this will be the un-rendered content. To modify the rendered output, * see hook_nodeapi($op = 'alter'). * * For a detailed usage example, see node_example.module. */ function hook_view($node, $teaser = FALSE, $page = FALSE) { if ($page) { $breadcrumb = array(); $breadcrumb[] = l(t('Home'), NULL); $breadcrumb[] = l(t('Example'), 'example'); $breadcrumb[] = l($node->field1, 'example/' . $node->field1); drupal_set_breadcrumb($breadcrumb); } $node = node_prepare($node, $teaser); $node->content['myfield'] = array('#value' => theme('mymodule_myfield', $node->myfield), '#weight' => 1); return $node; }
function budgets_quote_view($node, $teaser = FALSE, $page = FALSE) { $node = node_prepare($node, $teaser); $supplier = node_load(array('nid' => $node->supplier_id)); $node->content['refquote'] = array('#value' => '<small>' . theme_refquote($node, $supplier, $teaser) . '</small><hr>', '#weight' => -1); return $node; }
/** guifi_node_view(): outputs the node information **/ function guifi_node_view($node, $teaser = FALSE, $page = FALSE, $block = FALSE) { node_prepare($node); if ($teaser) { return $node; } if ($block) { return $node; } drupal_set_breadcrumb(guifi_node_ariadna($node)); $node->content['data'] = array('#value' => theme_table(NULL, array(array(array('data' => '<small>' . theme_guifi_node_data($node) . '</small>', 'width' => '50%'), array('data' => theme_guifi_node_map($node), 'width' => '50%')))), '#weight' => 1); $node->content['graphs'] = array('#value' => theme_guifi_node_graphs_overview($node), '#weight' => 2); $node->content['devices'] = array('#value' => theme_guifi_node_devices_list($node), '#weight' => 3); $node->content['wdsLinks'] = array('#value' => theme_guifi_node_links_by_type($node->id, 'wds'), '#weight' => 4); $node->content['cableLinks'] = array('#value' => theme_guifi_node_links_by_type($node->id, 'cable'), '#weight' => 5); $node->content['clientLinks'] = array('#value' => theme_guifi_node_links_by_type($node->id, 'ap/client'), '#weight' => 6); return $node; }
public function view($node, $teaser = FALSE, $page = FALSE) { if ($teaser) { $node = node_prepare($node, $teaser); } else { $this->addCss(); $this->addDocTypeJs($node); $this->addDocTypeCss($node); if (!empty($node->pdfpath)) { $href = $node->pubpath . '/' . $node->pdfpath; $node->content['pdflink'] = array('#value' => l(t('Download (PDF)'), $href, array('attributes' => array('class' => 'pubnode-pdflink'))), '#weight' => -1); } $node->content['body'] = array('#value' => $node->body, '#weight' => 0); } /* if ($page) { $node->content['edited_info'] = array( '#value' => '<div id="editedinfo">Edited by...</div>', '#weight' => 10 ); } */ return $node; }
public function view($node, $teaser = FALSE, $page = FALSE) { $this->addCss(); $node = node_prepare($node, $teaser); $node->content['byline'] = array('#value' => theme('interview_byline', $node), '#weight' => -3); if (!$teaser) { $interviewers = array(); $ppts = array(); foreach ($node->participants as $ppt) { $ppt = (object) $ppt; if (isset($ppt->cid)) { $contrib = node_load($ppt->cid); if ($contrib) { if ($ppt->interviewer) { $interviewers[] = theme('contributor_embed', $contrib); } else { $ppts[] = theme('contributor_embed', $contrib); } } } } $node->content['interviewers'] = array('#value' => implode('', $interviewers), '#weight' => 1); $node->content['participants'] = array('#value' => implode('', $ppts), '#weight' => 2); $statements = ''; $ppt_lookup = $this->nonemptyParticipantsArray($node); for ($i = 0; $i < count($node->statements); $i++) { $statements .= theme('interview_statement', $node, $i, $ppt_lookup); } $node->content['statements'] = array('#value' => $statements, '#weight' => 3); } return $node; }
/** * outputs the node information **/ function guifi_service_view($node, $teaser = FALSE, $page = FALSE, $block = FALSE) { node_prepare($node); if ($teaser) { return $node; } if ($block) { return $node; } if ($page) { drupal_set_breadcrumb(guifi_zone_ariadna($node->zone_id, 'node/%d/view/services')); $node->content['body']['#value'] = theme('box', t('Description'), $node->content['body']['#value']); $node->content['body']['#weight'] = 1; $service_data = array('#value' => theme('box', t('service information'), theme_guifi_service_data($node, FALSE)), '#weight' => -0); if ($node->service_type == 'DNS') { $form = drupal_get_form('guifi_domain_create_form', $node); $id = $node->id; $rows = array(); $header = array('<h2>' . t('Domain') . '</h2>', array('data' => t('type'), 'style' => 'text-align: left;'), array('data' => t('Scope'))); $query = db_query("SELECT d.id FROM {guifi_dns_domains} d WHERE sid=%d", $id); while ($d = db_fetch_object($query)) { $domain = guifi_domain_load($d->id); if (guifi_domain_access('update', $domain['id'])) { $edit_domain = l(guifi_img_icon('edit.png'), 'guifi/domain/' . $domain['id'] . '/edit', array('html' => TRUE, 'title' => t('edit domain'), 'attributes' => array('target' => '_blank'))) . '</td><td>' . l(guifi_img_icon('drop.png'), 'guifi/domain/' . $domain['id'] . '/delete', array('html' => TRUE, 'title' => t('delete domain'), 'attributes' => array('target' => '_blank'))); } $rows[] = array('<a href="' . url('guifi/domain/' . $domain[id]) . '">' . $domain['name'] . '</a>', array('data' => $domain['type'], 'style' => 'text-align: left;'), array('data' => $domain['scope']), $edit_domain); } if (count($rows)) { $node->content['data'] = array($service_data, array('#value' => theme('table', $header, $rows) . $form, '#weight' => 1)); } else { $node->content['data'] = array(array('#value' => theme('box', t('service information'), theme_guifi_service_data($node, FALSE)) . $form, '#weight' => -0)); } } else { $node->content['data'] = array(array('#value' => theme('box', t('service information'), theme_guifi_service_data($node, FALSE)) . $form, '#weight' => -0)); } } return $node; }
function budgets_supplier_view($node, $teaser = FALSE, $page = FALSE) { global $user; if (!isset($node->nid)) { $node = node_load(array('nid' => $node->id)); } if ($node->sticky) { $node->sticky = 0; } guifi_log(GUIFILOG_TRACE, 'function budgets_supplier_view(teaser)', $teaser); node_prepare($node, $teaser); if ($teaser) { $body = node_teaser($node->body, TRUE, $node->rated == true ? 600 : 300); $body = strip_tags($body, '<br> '); if ($node->rated) { if (!empty($node->logo)) { $img = '<img class="supplier-logo" src="/' . $node->logo . '" width="150">'; } if (!empty($node->web_url)) { $img = '<a href="' . $node->web_url . '">' . $img . '</a>'; } $body = "<div class=\"supplier-rated\">" . $img . $body . "</div>"; } $node->content['body']['#value'] = $body; } if ($node->rated) { $node->content['body']['#value'] = '<p class="rating" >' . $node->official_rating . '</p>' . $node->content['body']['#value']; } $node->content['header'] = array('#value' => theme_budgets_supplier_header($node, $teaser), '#weight' => -10); if ($page) { drupal_set_breadcrumb(guifi_zone_ariadna($node->zone_id, 'node/%d/view/suppliers')); $body = $node->content['body']['#value']; if (!empty($node->logo)) { $img = '<img class="supplier-logo" src="/' . $node->logo . '" width="200">'; } if (!empty($node->web_url)) { $img = '<a href="' . $node->web_url . '">' . $img . '</a>'; } // Quotes //to-do // Accounting guifi_log(GUIFILOG_TRACE, 'function budgets_supplier_view(accounting)', $node->accounting_urls); if (count($node->accounting_urls) > 1 and !empty($node->accounting_urls[0]['url'])) { // There are accounting urls $rows = array(); foreach ($node->accounting_urls as $value) { guifi_log(GUIFILOG_TRACE, 'function budgets_supplier_view(value)', $value); if (!empty($value['url'])) { $rows[] = array(array('data' => $value['node_id']), array('data' => '<a href="' . $value['url'] . '">' . $value['url'] . '</a>'), array('data' => $value['comment'])); } } $headers = array(array('data' => t('Node')), array('data' => t('Url')), array('data' => t('Comment'))); $body .= '<br><hr><h2>' . t('Accounting') . '</h2>' . theme('table', $headers, $rows); } $node->content['body']['#value'] = $img . ' ' . $body; } $node->content['footer'] = array('#value' => theme_budgets_supplier_footer($node, $teaser), '#weight' => 10); return $node; // format antic $node = node_prepare($node, $teaser); $output = ''; $qquotes = pager_query(sprintf('SELECT id ' . 'FROM {supplier_quote} ' . 'WHERE supplier_id = %d ' . 'ORDER BY title, partno, id', $node->nid), variable_get('default_nodes_main', 10)); $output .= '<h3>' . t('Contact information:') . '<h3 />' . t('Phone') . ':' . $node->phone . t(' Email: ') . $user->uid ? l($node->notification) : l('login to view email contact', 'user/login'); if (!$teaser) { $output .= '<br<br><hr><h2>' . t('Quotes') . '</h2>'; while ($quote = db_fetch_object($qquotes)) { $output .= node_view(node_load(array('nid' => $quote->id)), TRUE, FALSE); } empty($quote) ? $output .= t('No quotes available') : NULL; $node->content['quotes'] = array('#value' => $output . theme('pager', NULL, variable_get('default_nodes_main', 10)), '#weight' => 1); } return $node; }
/** guifi_zone_view(): zone view page **/ function guifi_zone_view($node, $teaser = FALSE, $page = FALSE, $block = FALSE) { node_prepare($node); if ($teaser) { return $node; } if ($block) { return $node; } $node->content['data'] = array('#value' => theme_table(NULL, array(array(array('data' => '<small>' . theme_guifi_zone_data($node, FALSE) . '</small>' . theme_guifi_contacts($node), 'width' => '35%'), array('data' => guifi_zone_simple_map($node), 'width' => '65%'))), array('width' => '100%')), '#weight' => 1); $node->content['graph'] = array('#value' => theme_guifi_zone_stats($node, FALSE), '#weight' => 2); $node->content['nodes'] = array('#value' => theme_guifi_zone_nodes($node, FALSE), '#weight' => 3); return $node; }