Commit fb70cd39 authored by jcnventura's avatar jcnventura

Add path-based visibility options to all modules

Minor code documentation fixes
parent 0d7894a0
This diff is collapsed.
......@@ -112,6 +112,20 @@ function print_html_settings() {
'#description' => t("Enable or disable the printer-friendly page link for each node. Even if the link is disabled, you can still view the print version of a node by going to print/nid where nid is the numeric id of the node."),
);
$form['print_html_settings']['node_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Link visibility'),
'#default_value' => $print_html_settings['node_link_visibility'],
'#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')),
);
$form['print_html_settings']['node_link_pages'] = array(
'#type' => 'textarea',
'#default_value' => $print_html_settings['node_link_pages'],
'#rows' => 3,
'#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
);
$form['print_html_settings']['link_class'] = array(
'#type' => 'textfield',
'#title' => t('Link class'),
......@@ -121,12 +135,19 @@ function print_html_settings() {
'#description' => t('This can be used by themers to change the link style or by jQuery modules to open in a new window (e.g. greybox or thickbox). Multiple classes can be specified, separated by spaces.'),
);
$form['print_html_settings']['show_sys_link'] = array(
$form['print_html_settings']['sys_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Show link in system (non-content) pages'),
'#default_value' => $print_html_settings['sys_link_visibility'],
'#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')),
);
$form['print_html_settings']['sys_link_pages'] = array(
'#type' => 'textarea',
'#title' => t('Show link in the following system (non-content) pages'),
'#default_value' => $print_html_settings['show_sys_link'],
'#default_value' => $print_html_settings['sys_link_pages'],
'#rows' => 3,
'#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
'#description' => t("Setting this option will add a printer-friendly version page link on pages created by Drupal or the enabled modules.") .'<br />'.
t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
);
$form['print_html_settings']['book_link'] = array(
......
......@@ -31,8 +31,11 @@ function print_settings_default() {
*/
function print_html_settings_default() {
return array('show_link' => 1,
'node_link_visibility' => 0,
'node_link_pages' => '',
'link_class' => 'print-page',
'show_sys_link' => '<front>',
'sys_link_visibility' => 1,
'sys_link_pages' => '<front>',
'book_link' => 1,
'new_window' => 0,
'sendtoprinter' => 0,
......@@ -139,6 +142,8 @@ function print_link($type, $node = NULL, $teaser = FALSE) {
// No link is shown for several motives...
if ( !($teaser) && ($node_type != 'book') && (!isset($node->book)) &&
($print_html_settings['show_link']) && user_access('access print') &&
!(($print_html_settings['node_link_visibility']) xor
(drupal_match_path("node/". $node->nid, $print_html_settings['node_link_pages']))) &&
(($type == 'comment' && $print_display_comment) ||
($type == 'node' && $print_display))) {
$links = array();
......@@ -197,8 +202,10 @@ function print_help($path, $arg) {
$print_html_settings = variable_get('print_html_settings', print_html_settings_default());
if (($print_html_settings['show_link']) && (drupal_match_path($path, $print_html_settings['show_sys_link'])) &&
user_access('access print') && (preg_match("/^node\//i", $path) == 0)) {
if (($print_html_settings['show_link']) && user_access('access print') &&
!(($print_html_settings['sys_link_visibility']) xor
(drupal_match_path($path, $print_html_settings['sys_link_pages']))) &&
(preg_match("/^node\//i", $path) == 0)) {
static $output = FALSE;
if ($output === FALSE) {
......@@ -237,6 +244,8 @@ function print_form_alter(&$form, $form_state, $form_id) {
* text to displayed by the link when hovering over it with the mouse
* @param $class
* class attribute to be used in the link
* @param $new_window
* if TRUE opens the target page in a new window
* @return
* array of formatted attributes
*/
......@@ -311,7 +320,7 @@ function theme_print_format_link() {
$text = t('Printer-friendly version');
$img = drupal_get_path('module', 'print') .'/icons/print_icon.gif';
$title = t('Display a printer-friendly version of this page.');
$class = $print_html_settings['link_class'];
$class = strip_tags($print_html_settings['link_class']);
$new_window = $print_html_settings['new_window'];
$format = _print_format_link_aux($print_html_settings['show_link'], $text, $img);
......
......@@ -37,6 +37,8 @@ function print_controller_html() {
* comment ID of the individual comment to be rendered
* @param $teaser
* if set to TRUE, outputs only the node's teaser
* @param $message
* optional sender's message (used by the send e-mail module)
* @return
* array with the fields to be used in the template
* @see _print_generate_node()
......@@ -110,6 +112,8 @@ function _print_robots_meta_generator() {
*
* @param $node
* generated node with a printer-friendly node body
* @param $message
* optional sender's message (used by the send e-mail module)
* @param $cid
* id of current comment being generated (NULL when not generating
* an individual comment)
......@@ -142,11 +146,11 @@ function _print_var_generator($node, $message = NULL, $cid = NULL) {
$css_files[] = strip_tags($print_settings['css']);
}
else {
$css_files[] = drupal_get_path('module', 'print') ."/print.css";
$css_files[] = base_path() . drupal_get_path('module', 'print') ."/print.css";
}
// Add CCK's CSS file to properly display the fields
if (module_exists('content')) {
$css_files[] = drupal_get_path('module', 'content') ."/content.css";
$css_files[] = base_path() . drupal_get_path('module', 'content') ."/content.css";
}
// If we are sending a message via e-mail, the CSS must be embedded
......@@ -162,7 +166,7 @@ function _print_var_generator($node, $message = NULL, $cid = NULL) {
else {
$print["css"] = "";
foreach ($css_files as $value) {
$print["css"] .= "<link type=\"text/css\" rel=\"stylesheet\" media=\"all\" href=\"". base_path() . $value ."\" />\n";
$print["css"] .= "<link type=\"text/css\" rel=\"stylesheet\" media=\"all\" href=\"". $value ."\" />\n";
}
}
......@@ -417,13 +421,11 @@ function _print_get_template($format = NULL, $type = NULL) {
foreach ($filenames as $value) {
// First in the theme directory
$file = drupal_get_path('theme', $GLOBALS['theme_key']) ."/". $value;
var_dump($file);
if (file_exists($file)) {
return $file;
}
// Then in the module directory
$file = drupal_get_path('module', 'print') ."/". $value;
var_dump($file);
if (file_exists($file)) {
return $file;
}
......@@ -439,6 +441,8 @@ function _print_get_template($format = NULL, $type = NULL) {
* comment ID of the individual comment to be rendered
* @param $teaser
* if set to TRUE, outputs only the node's teaser
* @param $message
* optional sender's message (used by the send e-mail module)
* @return
* filled array ready to be used in the template
*/
......@@ -520,6 +524,10 @@ function _print_generate_node($nid, $cid = NULL, $teaser = FALSE, $message = NUL
*
* @param $path
* path of the node to be rendered into a printer-friendly page
* @param $teaser
* if set to TRUE, outputs only the node's teaser
* @param $message
* optional sender's message (used by the send e-mail module)
* @return
* filled array ready to be used in the template
*/
......@@ -567,6 +575,10 @@ function _print_generate_path($path, $teaser = FALSE, $message = NULL) {
*
* @param $nid
* node ID of the node to be rendered into a printer-friendly page
* @param $teaser
* if set to TRUE, outputs only the node's teaser
* @param $message
* optional sender's message (used by the send e-mail module)
* @return
* filled array ready to be used in the template
*/
......
......@@ -30,6 +30,20 @@ function print_mail_settings() {
'#description' => t("Enable or disable the send by e-mail link for each node. Even if the link is disabled, you can still send a node by e-mail by going to printmail/nid where nid is the numeric id of the node."),
);
$form['print_mail_settings']['node_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Link visibility'),
'#default_value' => $print_mail_settings['node_link_visibility'],
'#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')),
);
$form['print_mail_settings']['node_link_pages'] = array(
'#type' => 'textarea',
'#default_value' => $print_mail_settings['node_link_pages'],
'#rows' => 3,
'#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
);
$form['print_mail_settings']['link_class'] = array(
'#type' => 'textfield',
'#title' => t('Link class'),
......@@ -39,12 +53,19 @@ function print_mail_settings() {
'#description' => t('This can be used by themers to change the link style or by jQuery modules to open in a new window (e.g. greybox or thickbox). Multiple classes can be specified, separated by spaces.'),
);
$form['print_mail_settings']['show_sys_link'] = array(
$form['print_mail_settings']['sys_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Show link in system (non-content) pages'),
'#default_value' => $print_mail_settings['sys_link_visibility'],
'#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')),
);
$form['print_mail_settings']['sys_link_pages'] = array(
'#type' => 'textarea',
'#title' => t('Show link in the following system (non-content) pages'),
'#default_value' => $print_mail_settings['show_sys_link'],
'#default_value' => $print_mail_settings['sys_link_pages'],
'#rows' => 3,
'#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
'#description' => t("Setting this option will add a send by-email link on pages created by Drupal or the enabled modules.") .'<br />'.
t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
);
$form['print_mail_settings']['book_link'] = array(
......
......@@ -12,9 +12,12 @@ define("PRINTMAIL_PATH", "printmail");
* Default values of the print_mail_settings variable
*/
function print_mail_settings_default() {
return array('show_link' => 0,
return array('show_link' => 1,
'node_link_visibility' => 0,
'node_link_pages' => '',
'link_class' => 'print-mail',
'show_sys_link' => '<front>',
'sys_link_visibility' => 1,
'sys_link_pages' => '<front>',
'book_link' => 1,
'teaser_default' => 1,
'teaser_choice' => 1,
......@@ -101,6 +104,8 @@ function print_mail_link($type, $node = NULL, $teaser = FALSE) {
// No link is shown for several motives...
elseif (($node_type != 'book') && (!isset($node->book)) &&
($print_mail_settings['show_link']) && user_access('access print') &&
!(($print_mail_settings['node_link_visibility']) xor
(drupal_match_path("node/". $node->nid, $print_mail_settings['node_link_pages']))) &&
(($type == 'comment' && $print_mail_display_comment) ||
($type == 'node' && $print_mail_display))) {
......@@ -129,8 +134,10 @@ function print_mail_link($type, $node = NULL, $teaser = FALSE) {
function print_mail_help($path, $arg) {
$print_mail_settings = variable_get('print_mail_settings', print_mail_settings_default());
if (($print_mail_settings['show_link']) && (drupal_match_path($path, $print_mail_settings['show_sys_link'])) &&
user_access('access print') && (preg_match("/^node\//i", $path) == 0)) {
if (($print_mail_settings['show_link']) && user_access('access print') &&
!(($print_mail_settings['sys_link_visibility']) xor
(drupal_match_path($path, $print_mail_settings['sys_link_pages']))) &&
(preg_match("/^node\//i", $path) == 0)) {
static $output = FALSE;
if ($output === FALSE) {
......@@ -174,7 +181,7 @@ function theme_print_mail_format_link() {
$text = t('Send to friend');
$img = drupal_get_path('module', 'print') .'/icons/mail_icon.gif';
$title = t('Send this page by e-mail.');
$class = $print_mail_settings['link_class'];
$class = strip_tags($print_mail_settings['link_class']);
$new_window = ($print_mail_settings['content_disposition'] == 1);
$format = _print_format_link_aux($print_mail_settings['show_link'], $text, $img);
......
......@@ -43,6 +43,20 @@ function print_pdf_settings() {
'#description' => t("Enable or disable the PDF version link for each node. Even if the link is disabled, you can still view the PDF version of a node by going to printpdf/nid where nid is the numeric id of the node."),
);
$form['print_pdf_settings']['node_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Link visibility'),
'#default_value' => $print_pdf_settings['node_link_visibility'],
'#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')),
);
$form['print_pdf_settings']['node_link_pages'] = array(
'#type' => 'textarea',
'#default_value' => $print_pdf_settings['node_link_pages'],
'#rows' => 3,
'#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
);
$form['print_pdf_settings']['link_class'] = array(
'#type' => 'textfield',
'#title' => t('Link class'),
......@@ -52,12 +66,19 @@ function print_pdf_settings() {
'#description' => t('This can be used by themers to change the link style or by jQuery modules to open in a new window (e.g. greybox or thickbox). Multiple classes can be specified, separated by spaces.'),
);
$form['print_pdf_settings']['show_sys_link'] = array(
$form['print_pdf_settings']['sys_link_visibility'] = array(
'#type' => 'radios',
'#title' => t('Show link in system (non-content) pages'),
'#default_value' => $print_pdf_settings['sys_link_visibility'],
'#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')),
);
$form['print_pdf_settings']['sys_link_pages'] = array(
'#type' => 'textarea',
'#title' => t('Show link in the following system (non-content) pages'),
'#default_value' => $print_pdf_settings['show_sys_link'],
'#default_value' => $print_pdf_settings['sys_link_pages'],
'#rows' => 3,
'#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
'#description' => t("Setting this option will add a PDF version page link on pages created by Drupal or the enabled modules.") .'<br />'.
t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
);
$form['print_pdf_settings']['book_link'] = array(
......
......@@ -12,9 +12,12 @@ define("PRINTPDF_PATH", "printpdf");
* Default values of the print_pdf_settings variable
*/
function print_pdf_settings_default() {
return array('show_link' => 0,
return array('show_link' => 1,
'node_link_visibility' => 0,
'node_link_pages' => '',
'link_class' => 'print-pdf',
'show_sys_link' => '<front>',
'sys_link_visibility' => 1,
'sys_link_pages' => '<front>',
'book_link' => 1,
'pdf_tool' => 0,
'content_disposition' => 2,
......@@ -98,6 +101,8 @@ function print_pdf_link($type, $node = NULL, $teaser = FALSE) {
// No link is shown for several motives...
elseif (($node_type != 'book') && (!isset($node->book)) &&
($print_pdf_settings['show_link']) && user_access('access print') &&
!(($print_pdf_settings['node_link_visibility']) xor
(drupal_match_path("node/". $node->nid, $print_pdf_settings['node_link_pages']))) &&
(($type == 'comment' && $print_pdf_display_comment) ||
($type == 'node' && $print_pdf_display))) {
......@@ -126,8 +131,10 @@ function print_pdf_link($type, $node = NULL, $teaser = FALSE) {
function print_pdf_help($path, $arg) {
$print_pdf_settings = variable_get('print_pdf_settings', print_pdf_settings_default());
if (($print_pdf_settings['show_link']) && (drupal_match_path($path, $print_pdf_settings['show_sys_link'])) &&
user_access('access print') && (preg_match("/^node\//i", $path) == 0)) {
if (($print_pdf_settings['show_link']) && user_access('access print') &&
!(($print_pdf_settings['sys_link_visibility']) xor
(drupal_match_path($path, $print_pdf_settings['sys_link_pages']))) &&
(preg_match("/^node\//i", $path) == 0)) {
static $output = FALSE;
if ($output === FALSE) {
......@@ -171,7 +178,7 @@ function theme_print_pdf_format_link() {
$text = t('PDF version');
$img = drupal_get_path('module', 'print') .'/icons/pdf_icon.gif';
$title = t('Display a PDF version of this page.');
$class = $print_pdf_settings['link_class'];
$class = strip_tags($print_pdf_settings['link_class']);
$new_window = ($print_pdf_settings['content_disposition'] == 1);
$format = _print_format_link_aux($print_pdf_settings['show_link'], $text, $img);
......
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