Commit 99e463d7 authored by jcnventura's avatar jcnventura

Coder fixes

Update to new hook_block_list and hook_block_view
Moved link code to hook_nodeapi_view and removal of hook_link
parent ff47cf5a
......@@ -35,7 +35,7 @@ function print_main_settings() {
'#title' => t('Printer-friendly URLs list'),
'#default_value' => variable_get('print_urls', PRINT_URLS_DEFAULT),
'#description' => t('If set, a list of the destination URLs for the page links will be displayed at the bottom of the page.') .'<br />'.
t('Note that you can enable/disable the URL list for each content type individually from the !url.', array('!url' => l(t('Content Types page'),'admin/build/types'))),
t('Note that you can enable/disable the URL list for each content type individually from the !url.', array('!url' => l(t('Content Types page'), 'admin/build/types'))),
);
$form['settings']['print_comments'] = array(
......
......@@ -14,7 +14,7 @@ function print_install() {
$t = get_t();
drupal_set_message($t('Printer-friendly Page settings are available under !link',
array( '!link' => l('Administer > Site configuration > Printer-friendly Pages ', 'admin/settings/print' ) )
array( '!link' => l($t('Administer > Site configuration > Printer-friendly Pages'), 'admin/settings/print' ) )
));
}
......
......@@ -121,20 +121,18 @@ function print_menu() {
}
/**
* Implementation of hook_block().
* Implementation of hook_block_list().
*/
function print_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
function print_block_list() {
$block[0]['info'] = t('Printer, e-mail and PDF versions');
$block[1]['info'] = t('Most printed');
return $block;
break;
case 'configure':
return '';
case 'save':
return;
case 'view':
}
/**
* Implementation of hook_block_view().
*/
function print_block_view($delta = 0) {
switch ($delta) {
case 0:
$nid = preg_replace('!^node/!', '', $_GET['q']);
......@@ -169,49 +167,6 @@ function print_block($op = 'list', $delta = 0, $edit = array()) {
break;
}
return $block;
break;
}
}
/**
* Implementation of hook_link().
*/
function print_link($type, $node = NULL, $teaser = FALSE) {
$print_html_link_pos = variable_get('print_html_link_pos', array(PRINT_HTML_LINK_POS_DEFAULT => PRINT_HTML_LINK_POS_DEFAULT));
$print_html_link_use_alias = variable_get('print_html_link_use_alias', PRINT_HTML_LINK_USE_ALIAS_DEFAULT);
$allowed_type = print_link_allowed(array('type' => $type, 'node' => $node, 'teaser' => $teaser));
if (($allowed_type === PRINT_ALLOW_NORMAL_LINK) && !isset($node->book) && !empty($print_html_link_pos['link'])) {
drupal_add_css(drupal_get_path('module', 'print') .'/css/printlinks.css');
$links = array();
$format = theme('print_format_link');
$query_arr = $_GET;
if ($type == 'comment') {
$query_arr['comment'] = $node->cid;
}
$query = print_query_string_encode($query_arr, array('q'));
if (empty($query)) $query = NULL;
if ($print_html_link_use_alias) {
$path = drupal_get_path_alias('node/'. $node->nid);
}
else {
$path = $node->nid;
}
$links['print_html'] = array(
'href' => PRINT_PATH .'/'. $path,
'title' => $format['text'],
'attributes' => $format['attributes'],
'html' => $format['html'],
'query' => $query,
);
return $links;
}
else {
return;
}
}
/**
......@@ -276,11 +231,47 @@ function print_help($path, $arg) {
* Implementation of hook_nodeapi_view().
*/
function print_nodeapi_view(&$node, $teaser, $page) {
// Insert content corner links
if ($teaser === FALSE) {
_print_set_node_fields($node);
}
$print_html_link_pos = variable_get('print_html_link_pos', array(PRINT_HTML_LINK_POS_DEFAULT => PRINT_HTML_LINK_POS_DEFAULT));
$print_html_link_pos = variable_get('print_html_link_pos', array(PRINT_HTML_LINK_POS_DEFAULT => PRINT_HTML_LINK_POS_DEFAULT));
$print_html_link_use_alias = variable_get('print_html_link_use_alias', PRINT_HTML_LINK_USE_ALIAS_DEFAULT);
$allowed_type = print_link_allowed(array('type' => 'node', 'node' => $node, 'teaser' => $teaser));
if (($allowed_type === PRINT_ALLOW_NORMAL_LINK) && !isset($node->book) && !empty($print_html_link_pos['link'])) {
drupal_add_css(drupal_get_path('module', 'print') .'/css/printlinks.css');
$links = array();
$format = theme('print_format_link');
$query_arr = $_GET;
if ('node' == 'comment') {
$query_arr['comment'] = $node->cid;
}
$query = print_query_string_encode($query_arr, array('q'));
if (empty($query)) $query = NULL;
if ($print_html_link_use_alias) {
$path = drupal_get_path_alias('node/'. $node->nid);
}
else {
$path = $node->nid;
}
$links['print_html'] = array(
'href' => PRINT_PATH .'/'. $path,
'title' => $format['text'],
'attributes' => $format['attributes'],
'html' => $format['html'],
'query' => $query,
);
$node->content['links']['print_html'] = array(
'#type' => 'node_links',
'#value' => $links,
);
}
// Insert content corner links
if (($teaser === FALSE) && !empty($print_html_link_pos['corner']) &&
(preg_match('!^print!i', $_GET['q']) == 0)) {
$link = print_insert_link(NULL, $node);
......@@ -750,7 +741,7 @@ function print_query_string_encode($query, $exclude = array(), $parent = '') {
}
/**
* Implementation of hook_content_build_modes()
* Implementation of hook_content_build_modes().
*
* @return
* An array describing the build modes used by the module.
......@@ -784,16 +775,15 @@ function print_query_string_encode($query, $exclude = array(), $parent = '') {
* );
*/
function print_content_build_modes() {
return array(
'print' => array(
'title' => t('Print'),
'build modes' => array(
'print' => array(
'title' => t('Print'),
'views style' => FALSE,
),
),
),
);
return array(
'print' => array(
'title' => t('Print'),
'build modes' => array(
'print' => array(
'title' => t('Print'),
'views style' => FALSE,
),
),
),
);
}
......@@ -328,7 +328,9 @@ function _print_var_generator($node, $message = NULL, $cid = NULL) {
}
if (module_exists('taxonomy')) {
$terms = taxonomy_link('taxonomy terms', $node);
// TODO make this work when taxonomy works again
// $terms = taxonomy_link('taxonomy terms', $node);
$terms = taxonomy_preview_terms($node);
$print['taxonomy'] = theme('links', $terms);
}
......@@ -557,9 +559,9 @@ function _print_generate_node($nid, $cid = NULL, $format = PRINT_HTML_FORMAT, $t
//alert other modules that we are generating a printer-friendly page, so they can choose to show/hide info
// TODO: Remove this in favor of PRINT_BUILD_MODE
$node->printing = TRUE;
$node->build_mode = 'print';
// Turn off Pagination by the Paging module
unset($node->pages);
unset($node->page_count);
......
......@@ -63,19 +63,17 @@ function print_mail_menu() {
}
/**
* Implementation of hook_block().
* Implementation of hook_block_list().
*/
function print_mail_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
function print_mail_block_list() {
$block[0]['info'] = t('Most emailed');
return $block;
break;
case 'configure':
return '';
case 'save':
return;
case 'view':
}
/**
* Implementation of hook_block_view().
*/
function print_mail_block_view($delta = 0) {
switch ($delta) {
case 0:
$block['subject'] = t('Most emailed');
......@@ -91,17 +89,39 @@ function print_mail_block($op = 'list', $delta = 0, $edit = array()) {
break;
}
return $block;
break;
}
/**
* Implementation of hook_help().
*/
function print_mail_help($path, $arg) {
$print_mail_link_pos = variable_get('print_mail_link_pos', array(PRINT_MAIL_LINK_POS_DEFAULT => PRINT_MAIL_LINK_POS_DEFAULT));
if ((preg_match('!^node/!i', $path) == 0) &&
!(empty($print_mail_link_pos['link']) && empty($print_mail_link_pos['corner']))) {
static $output = FALSE;
if ($output === FALSE) {
$output = TRUE;
$link = print_mail_insert_link();
if ($link) {
return "<span class='print-syslink'>$link</span>";
}
}
}
}
/**
* Implementation of hook_link().
* Implementation of hook_nodeapi_view().
*/
function print_mail_link($type, $node = NULL, $teaser = FALSE) {
function print_mail_nodeapi_view(&$node, $teaser, $page) {
if ($teaser === FALSE) {
_print_mail_set_node_fields($node);
}
$print_mail_link_pos = variable_get('print_mail_link_pos', array(PRINT_MAIL_LINK_POS_DEFAULT => PRINT_MAIL_LINK_POS_DEFAULT));
$print_mail_link_use_alias = variable_get('print_mail_link_use_alias', PRINT_MAIL_LINK_USE_ALIAS_DEFAULT);
$allowed_type = print_mail_link_allowed(array('type' => $type, 'node' => $node, 'teaser' => $teaser));
$allowed_type = print_mail_link_allowed(array('type' => 'node', 'node' => $node, 'teaser' => $teaser));
if (($allowed_type) && !empty($print_mail_link_pos['link'])) {
drupal_add_css(drupal_get_path('module', 'print') .'/css/printlinks.css');
$links = array();
......@@ -114,12 +134,10 @@ function print_mail_link($type, $node = NULL, $teaser = FALSE) {
'attributes' => $format['attributes'],
'html' => $format['html'],
);
return $links;
}
elseif ($allowed_type === PRINT_ALLOW_NORMAL_LINK) {
$query_arr = $_GET;
if ($type == 'comment') {
if ('node' == 'comment') {
$query_arr['comment'] = $node->cid;
}
$query = print_query_string_encode($query_arr, array('q'));
......@@ -138,44 +156,15 @@ function print_mail_link($type, $node = NULL, $teaser = FALSE) {
'html' => $format['html'],
'query' => $query,
);
return $links;
}
}
else {
return;
}
}
/**
* Implementation of hook_help().
*/
function print_mail_help($path, $arg) {
$print_mail_link_pos = variable_get('print_mail_link_pos', array(PRINT_MAIL_LINK_POS_DEFAULT => PRINT_MAIL_LINK_POS_DEFAULT));
if ((preg_match('!^node/!i', $path) == 0) &&
!(empty($print_mail_link_pos['link']) && empty($print_mail_link_pos['corner']))) {
static $output = FALSE;
if ($output === FALSE) {
$output = TRUE;
$link = print_mail_insert_link();
if ($link) {
return "<span class='print-syslink'>$link</span>";
}
}
$node->content['links']['print_mail'] = array(
'#type' => 'node_links',
'#value' => $links,
);
}
}
/**
* Implementation of hook_nodeapi_view().
*/
function print_mail_nodeapi_view(&$node, $teaser, $page) {
// Insert content corner links
if ($teaser === FALSE) {
_print_mail_set_node_fields($node);
}
$print_mail_link_pos = variable_get('print_mail_link_pos', array(PRINT_MAIL_LINK_POS_DEFAULT => PRINT_MAIL_LINK_POS_DEFAULT));
if (($teaser === FALSE) && !empty($print_mail_link_pos['corner']) &&
(preg_match('!^print!i', $_GET['q']) == 0)) {
$link = print_mail_insert_link(NULL, $node);
......
......@@ -81,19 +81,17 @@ function print_pdf_menu() {
}
/**
* Implementation of hook_block().
* Implementation of hook_block_list().
*/
function print_pdf_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
function print_pdf_block_list() {
$block[0]['info'] = t('Most PDFd');
return $block;
break;
case 'configure':
return '';
case 'save':
return;
case 'view':
}
/**
* Implementation of hook_block_view().
*/
function print_pdf_block_view($delta = 0) {
switch ($delta) {
case 0:
$block['subject'] = t('Most PDFd');
......@@ -109,8 +107,6 @@ function print_pdf_block($op = 'list', $delta = 0, $edit = array()) {
break;
}
return $block;
break;
}
}
/**
......@@ -137,12 +133,36 @@ function print_pdf_requirements($phase) {
}
/**
* Implementation of hook_link().
* Implementation of hook_help().
*/
function print_pdf_link($type, $node = NULL, $teaser = FALSE) {
function print_pdf_help($path, $arg) {
$print_pdf_link_pos = variable_get('print_pdf_link_pos', array(PRINT_PDF_LINK_POS_DEFAULT => PRINT_PDF_LINK_POS_DEFAULT));
if ((preg_match('!^node/!i', $path) == 0) &&
!(empty($print_pdf_link_pos['link']) && empty($print_pdf_link_pos['corner']))) {
static $output = FALSE;
if ($output === FALSE) {
$output = TRUE;
$link = print_pdf_insert_link();
if ($link) {
return "<span class='print-syslink'>$link</span>";
}
}
}
}
/**
* Implementation of hook_nodeapi_view().
*/
function print_pdf_nodeapi_view(&$node, $teaser, $page) {
if ($teaser === FALSE) {
_print_pdf_set_node_fields($node);
}
$print_pdf_link_pos = variable_get('print_pdf_link_pos', array(PRINT_PDF_LINK_POS_DEFAULT => PRINT_PDF_LINK_POS_DEFAULT));
$print_pdf_link_use_alias = variable_get('print_pdf_link_use_alias', PRINT_PDF_LINK_USE_ALIAS_DEFAULT);
$allowed_type = print_pdf_link_allowed(array('type' => $type, 'node' => $node, 'teaser' => $teaser));
$allowed_type = print_pdf_link_allowed(array('type' => 'node', 'node' => $node, 'teaser' => $teaser));
if (($allowed_type) && !empty($print_pdf_link_pos['link'])) {
drupal_add_css(drupal_get_path('module', 'print') .'/css/printlinks.css');
$links = array();
......@@ -155,12 +175,10 @@ function print_pdf_link($type, $node = NULL, $teaser = FALSE) {
'attributes' => $format['attributes'],
'html' => $format['html'],
);
return $links;
}
elseif ($allowed_type === PRINT_ALLOW_NORMAL_LINK) {
$query_arr = $_GET;
if ($type == 'comment') {
if ('node' == 'comment') {
$query_arr['comment'] = $node->cid;
}
$query = print_query_string_encode($query_arr, array('q'));
......@@ -179,44 +197,14 @@ function print_pdf_link($type, $node = NULL, $teaser = FALSE) {
'html' => $format['html'],
'query' => $query,
);
return $links;
}
}
else {
return;
}
}
/**
* Implementation of hook_help().
*/
function print_pdf_help($path, $arg) {
$print_pdf_link_pos = variable_get('print_pdf_link_pos', array(PRINT_PDF_LINK_POS_DEFAULT => PRINT_PDF_LINK_POS_DEFAULT));
if ((preg_match('!^node/!i', $path) == 0) &&
!(empty($print_pdf_link_pos['link']) && empty($print_pdf_link_pos['corner']))) {
static $output = FALSE;
if ($output === FALSE) {
$output = TRUE;
$link = print_pdf_insert_link();
if ($link) {
return "<span class='print-syslink'>$link</span>";
}
}
$node->content['links']['print_pdf'] = array(
'#type' => 'node_links',
'#value' => $links,
);
}
}
/**
* Implementation of hook_nodeapi_view().
*/
function print_pdf_nodeapi_view(&$node, $teaser, $page) {
// Insert content corner links
if ($teaser === FALSE) {
_print_pdf_set_node_fields($node);
}
$print_pdf_link_pos = variable_get('print_pdf_link_pos', array(PRINT_PDF_LINK_POS_DEFAULT => PRINT_PDF_LINK_POS_DEFAULT));
if (($teaser === FALSE) && !empty($print_pdf_link_pos['corner']) &&
(preg_match('!^print!i', $_GET['q']) == 0)) {
$link = print_pdf_insert_link(NULL, $node);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment