目錄
by 蘇德宙, 2011-04-30 16:00, 人氣(1327)
function node_page_view($node, $cid = NULL) {
drupal_set_title(check_plain($node->title));
return node_show($node, $cid);
}
drupal_set_title(check_plain($node->title));
return node_show($node, $cid);
}
by 蘇德宙, 2011-04-30 16:04, 人氣(1986)
function node_show($node, $cid, $message = FALSE) {
$output = node_view($node, FALSE, TRUE);
if (function_exists('comment_render') && $node->comment) {
$output .= comment_render($node, $cid);
}
node_tag_new($node->nid); // Update the 'last viewed' timestamp
return $output;
}
}
by 蘇德宙, 2011-04-30 16:08, 人氣(1329)
function node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE) {
$node = node_build_content($node, $teaser, $page);
$content = drupal_render($node->content);
node_invoke_nodeapi($node, 'alter', $teaser, $page);
return theme('node', $node, $teaser, $page);
}
by 蘇德宙, 2011-04-30 16:11, 人氣(1387)
function node_build_content($node, $teaser = FALSE, $page = FALSE) {
if (node_hook($node, 'view')) // node_content_view
$node = node_invoke($node, 'view', $teaser, $page);
else
$node = node_prepare($node, $teaser);
$node = node_prepare($node, $teaser);
node_invoke_nodeapi($node, 'view', $teaser, $page);
return $node;
}
}
by 蘇德宙, 2011-04-30 16:18, 人氣(1336)
function node_hook(&$node, $hook) {
$module = node_get_types('module', $node);
if ($module == 'node') {
$module = 'node_content'; // Avoid function name collisions.
}
return module_hook($module, $hook); // return function_exists($module .'_'. $hook);
}
}
$module = node_get_types('module', $node);
if ($module == 'node') {
$module = 'node_content'; // Avoid function name collisions.
}
return module_hook($module, $hook); // return function_exists($module .'_'. $hook);
}
}
by 蘇德宙, 2011-04-30 16:19, 人氣(1380)
function node_invoke(&$node, $hook, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
if (node_hook($node, $hook)) {
$module = node_get_types('module', $node);
if ($module == 'node') {
$module = 'node_content'; // Avoid function name collisions.
}
$function = $module .'_'. $hook;
return ($function($node, $a2, $a3, $a4));
}
}
if (node_hook($node, $hook)) {
$module = node_get_types('module', $node);
if ($module == 'node') {
$module = 'node_content'; // Avoid function name collisions.
}
$function = $module .'_'. $hook;
return ($function($node, $a2, $a3, $a4));
}
}
by 蘇德宙, 2011-04-30 16:21, 人氣(1371)
function node_invoke_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
$return = array();
foreach (module_implements('nodeapi') as $name) {
$function = $name .'_nodeapi';
$result = $function($node, $op, $a3, $a4);
if (isset($result) && is_array($result)) {
$return = array_merge($return, $result);
}
else if (isset($result)) {
$return[] = $result;
}
}
return $return;
}
$return = array();
foreach (module_implements('nodeapi') as $name) {
$function = $name .'_nodeapi';
$result = $function($node, $op, $a3, $a4);
if (isset($result) && is_array($result)) {
$return = array_merge($return, $result);
}
else if (isset($result)) {
$return[] = $result;
}
}
return $return;
}
function module_implements() {
$list = module_list(FALSE, TRUE, $sort);
foreach ($list as $module) {
if (module_hook($module, $hook)) {
$implementations[$hook][] = $module;
}
}
foreach ($list as $module) {
if (module_hook($module, $hook)) {
$implementations[$hook][] = $module;
}
}
return (array)$implementations[$hook];
}