security updates
have to check views and entityreference for custom patches
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
.print-link {
|
||||
/* Use these for links above the content */
|
||||
text-align: left;
|
||||
/* Use these for links in a corner of the content */
|
||||
/*
|
||||
float: left;
|
||||
*/
|
||||
}
|
||||
|
||||
.print_html, .print_mail, .print_pdf, .print_epub {
|
||||
margin-left: 0;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.print-syslink {
|
||||
margin-right: 0;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
img.print-icon-margin {
|
||||
padding-left: 4px;
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
.print-link {
|
||||
/* Use these for links above the content */
|
||||
display: block;
|
||||
text-align: right;
|
||||
padding-bottom: 0.5em;
|
||||
/* Use these for links in a corner of the content */
|
||||
/*
|
||||
position: relative;
|
||||
bottom: 0.5em;
|
||||
float: right;
|
||||
*/
|
||||
}
|
||||
|
||||
div#block-print-ui-print-links span {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.print_html, .print_mail, .print_pdf, .print_epub {
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
.print-syslink {
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
img.print-icon {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
img.print-icon-margin {
|
||||
padding-right: 4px;
|
||||
}
|
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the administrative functions of the print UI module.
|
||||
*
|
||||
* This file is included by the print UI module, and includes the
|
||||
* settings form.
|
||||
*
|
||||
* @ingroup print
|
||||
*/
|
||||
|
||||
/**
|
||||
* Form constructor for the send by email module settings form.
|
||||
*
|
||||
* @ingroup forms
|
||||
*/
|
||||
function print_ui_settings() {
|
||||
$form['settings'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Link options'),
|
||||
);
|
||||
|
||||
foreach (module_implements('print_link') as $module) {
|
||||
$function = $module . '_print_link';
|
||||
if (function_exists($function)) {
|
||||
$link = call_user_func_array($function, array());
|
||||
$format = $link['format'];
|
||||
|
||||
$form['settings']['checkboxes']['link_pos']['print_' . $format . '_link_pos'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Link location'),
|
||||
'#default_value' => variable_get('print_' . $format . '_link_pos', drupal_json_decode(PRINT_UI_LINK_POS_DEFAULT)),
|
||||
'#options' => array('link' => t('Links area'), 'corner' => t('Content corner'), 'block' => t('Block'), 'help' => t('Help area')),
|
||||
'#description' => t('Choose the location of the link(s) to the printer-friendly version pages. The Links area is usually below the node content, whereas the Content corner is placed in the upper-right corner of the node content (these apply only in node pages). The Help area is used for system pages. Enabling the block area link will allow links of this format in the provided links module. Unselect all options to disable the link. Even if the link is disabled, you can still go to %path where nid is the numeric id of the node.', array('%path' => $link['path'] . '/nid')),
|
||||
);
|
||||
|
||||
$form['settings']['checkboxes']['link_teaser']['print_' . $format . '_link_teaser'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display link in teaser'),
|
||||
'#default_value' => variable_get('print_' . $format . '_link_teaser', PRINT_UI_LINK_TEASER_DEFAULT),
|
||||
'#description' => t('Enabling this will display the link in teaser mode.'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$form['settings']['adv_link'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Advanced link options'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => FALSE,
|
||||
);
|
||||
|
||||
foreach (module_implements('print_link') as $module) {
|
||||
$function = $module . '_print_link';
|
||||
if (function_exists($function)) {
|
||||
$link = call_user_func_array($function, array());
|
||||
$format = $link['format'];
|
||||
|
||||
$form['settings']['adv_link']['show_link']['print_' . $format . '_show_link'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Link style'),
|
||||
'#default_value' => variable_get('print_' . $format . '_show_link', PRINT_UI_SHOW_LINK_DEFAULT),
|
||||
'#options' => array(1 => t('Text only'), 2 => t('Icon only'), 3 => t('Icon and Text')),
|
||||
'#description' => t('Select the visual style of the link.'),
|
||||
);
|
||||
|
||||
$form['settings']['adv_link']['link_use_alias']['print_' . $format . '_link_use_alias'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Use URL alias instead of node ID'),
|
||||
'#default_value' => variable_get('print_' . $format . '_link_use_alias', PRINT_UI_LINK_USE_ALIAS_DEFAULT),
|
||||
'#description' => t('Enabling this will create the link using the URL alias instead of the node ID.'),
|
||||
);
|
||||
|
||||
$form['settings']['adv_link']['link_class']['print_' . $format . '_link_class'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Link class'),
|
||||
'#default_value' => variable_get('print_' . $format . '_link_class', $link['class']),
|
||||
'#size' => 20,
|
||||
'#maxlength' => 250,
|
||||
'#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['settings']['adv_link']['sys_link_visibility']['print_' . $format . '_sys_link_visibility'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Show link in system (non-content) pages'),
|
||||
'#description' => 'Any page that is not a Drupal node. Usually pages generated by Drupal or a module such as Views or Panels.',
|
||||
'#default_value' => variable_get('print_' . $format . '_sys_link_visibility', PRINT_UI_SYS_LINK_VISIBILITY_DEFAULT),
|
||||
'#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')),
|
||||
);
|
||||
|
||||
$form['settings']['adv_link']['sys_link_pages']['print_' . $format . '_sys_link_pages'] = array(
|
||||
'#type' => 'textarea',
|
||||
'#default_value' => variable_get('print_' . $format . '_sys_link_pages', PRINT_UI_SYS_LINK_PAGES_DEFAULT),
|
||||
'#rows' => 3,
|
||||
'#description' => t('Setting this option will add a 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>')),
|
||||
);
|
||||
|
||||
if (module_exists('php')) {
|
||||
$access = user_access('use PHP for settings');
|
||||
|
||||
if ($form['settings']['adv_link']['sys_link_visibility']['print_' . $format . '_sys_link_visibility']['#default_value'] == 2 && !$access) {
|
||||
$form['settings']['adv_link']['sys_link_visibility']['print_' . $format . '_sys_link_visibility'] = array('#type' => 'value', '#value' => 2);
|
||||
$form['settings']['adv_link']['sys_link_pages']['print_' . $format . '_sys_link_pages'] = array('#type' => 'value', '#value' => $form['settings']['adv_link']['print_' . $format . '_sys_link_pages']['#default_value']);
|
||||
}
|
||||
elseif ($access) {
|
||||
$form['settings']['adv_link']['sys_link_visibility']['print_' . $format . '_sys_link_visibility']['#options'][] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
|
||||
$form['settings']['adv_link']['sys_link_pages']['print_' . $format . '_sys_link_pages']['#description'] .= ' ' . t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '<?php ?>'));
|
||||
}
|
||||
}
|
||||
|
||||
$form['settings']['adv_link']['book_link']['print_' . $format . '_book_link'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Link in book hierarchy nodes'),
|
||||
'#default_value' => variable_get('print_' . $format . '_book_link', PRINT_UI_BOOK_LINK_DEFAULT),
|
||||
'#options' => array(t('No link'), t('Current page and sub-pages'), t('Current page only')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$form['#theme'] = 'print_ui_settings';
|
||||
|
||||
return system_settings_form($form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the link settings page.
|
||||
*
|
||||
* @param array $variables
|
||||
* An associative array containing:
|
||||
* - form: A render element representing the form.
|
||||
*
|
||||
* @ingroup themeable
|
||||
* @ingroup print_themeable
|
||||
*/
|
||||
function theme_print_ui_settings($variables) {
|
||||
$form = $variables['form'];
|
||||
$header = array('');
|
||||
|
||||
foreach (module_implements('print_link') as $module) {
|
||||
$function = $module . '_print_link';
|
||||
if (function_exists($function)) {
|
||||
$link = call_user_func_array($function, array());
|
||||
|
||||
$header[] = array('data' => $link['format'], 'class' => 'checkbox');
|
||||
}
|
||||
}
|
||||
|
||||
foreach (element_children($form['settings']) as $group) {
|
||||
$rows = array();
|
||||
foreach (element_children($form['settings'][$group]) as $elem) {
|
||||
$row = array();
|
||||
|
||||
foreach (module_implements('print_link') as $module) {
|
||||
$function = $module . '_print_link';
|
||||
if (function_exists($function)) {
|
||||
$link = call_user_func_array($function, array());
|
||||
$format = $link['format'];
|
||||
|
||||
$item = $form['settings'][$group][$elem]['print_' . $format . '_' . $elem];
|
||||
|
||||
if (empty($row)) {
|
||||
// Start row, fill title and description
|
||||
$row_desc = array(
|
||||
'#type' => 'item',
|
||||
'#markup' => isset($item['#title']) ? $item['#title'] : '',
|
||||
'#description' => isset($item['#description']) ? $item['#description'] : '',
|
||||
);
|
||||
|
||||
$row[] = array('data' => drupal_render($row_desc), 'class' => array(''));
|
||||
}
|
||||
|
||||
$item['#title_display'] = 'invisible';
|
||||
$item['#description'] = '';
|
||||
|
||||
$class = ($item['#type'] == 'checkbox') ? 'checkbox' : '';
|
||||
|
||||
$row[] = array('data' => drupal_render($item), 'class' => array($class));
|
||||
}
|
||||
}
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
$form['settings'][$group]['#children'] = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'permissions')));
|
||||
}
|
||||
|
||||
$output = drupal_render_children($form);
|
||||
|
||||
return $output;
|
||||
}
|
101
sites/all/modules/contrib/admin/print/print_ui/print_ui.api.php
Normal file
101
sites/all/modules/contrib/admin/print/print_ui/print_ui.api.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Hooks provided by the Print UI module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup hooks
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides the format-specific info to be used by the print_ui module.
|
||||
*
|
||||
* The print_ui module manages all the generic link management of the print
|
||||
* package sub-modules. In order to keep the code as generic as possible, all
|
||||
* the identified information necessary to build the link is provided as an
|
||||
* array, from which each of the print_ui functions can access the necessary
|
||||
* details. The print_ui module will iterate over all modules that implement
|
||||
* this hook and build a link pointing to the indicated path + node id (or url
|
||||
* alias). For convenience, this function should be called directly inside the
|
||||
* hook_menu call for each module, and the returned path value used as the
|
||||
* main entry point of the specific functionality.
|
||||
*
|
||||
* @return array
|
||||
* An associative array containing:
|
||||
* - format: The format identifier, must be unique among all modules.
|
||||
* Examples: 'html', 'mail, 'pdf'.
|
||||
* - text: The default string used in the link text. Overridable by the user
|
||||
* configuration settings in the sub-module page.
|
||||
* - description: The text shown when hovering over the link.
|
||||
* - path: The unique path used to call the main handler.
|
||||
* - class: The default value of the CSS class used in the 'a' tag of the
|
||||
* link. Overridable by the user configuration settings in the sub-module
|
||||
* page.
|
||||
* - icon: the filename of the image used as the link icon.
|
||||
* - module: the name of the module. Used to call common functions or access
|
||||
* tables, as not all module names follow the 'print_format' template (e.g.
|
||||
* print.module and not print_html.module).
|
||||
*
|
||||
* @ingroup print_hooks
|
||||
*/
|
||||
function hook_print_link() {
|
||||
return array(
|
||||
'format' => 'foo',
|
||||
'text' => t('Foo version'),
|
||||
'description' => t('Display the foo version of this page.'),
|
||||
'path' => 'printfoo',
|
||||
'class' => 'print-foo',
|
||||
'icon' => 'foo_icon.png',
|
||||
'module' => 'print_foo',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the link is allowed according to the appropriate sub-module.
|
||||
*
|
||||
* Normally checks if the user holds the required access permission, but can
|
||||
* be used for extra checks, such as the proper module configuration, etc.
|
||||
*
|
||||
* @param array $args
|
||||
* An associative array containing:
|
||||
* - path: path to the non-node page being displayed.
|
||||
* - node: path to the node beign displayed.
|
||||
* - view_mode: current view mode of the node being displayed.
|
||||
* - type: 'node' or 'comment'.
|
||||
*
|
||||
* @return bool
|
||||
* FALSE if not allowed, TRUE otherwise
|
||||
*
|
||||
* @ingroup print_hooks
|
||||
*/
|
||||
function hook_link_allowed($args) {
|
||||
return (user_access('access foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the link is allowed according to the appropriate sub-module.
|
||||
*
|
||||
* Normally checks if the user holds the required access permission, but can
|
||||
* be used for extra checks, such as the proper module configuration, etc.
|
||||
*
|
||||
* @param array $args
|
||||
* An associative array containing:
|
||||
* - path: path to the non-node page being displayed.
|
||||
* - node: path to the node beign displayed.
|
||||
* - view_mode: current view mode of the node being displayed.
|
||||
* - type: 'node' or 'comment'.
|
||||
*
|
||||
* @ingroup print_hooks
|
||||
*/
|
||||
function hook_print_new_window_alter(&$new_window, $format) {
|
||||
if ($format == 'foo') {
|
||||
$new_window = variable_get('print_foo_new_windo', FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup hooks".
|
||||
*/
|
13
sites/all/modules/contrib/admin/print/print_ui/print_ui.info
Normal file
13
sites/all/modules/contrib/admin/print/print_ui/print_ui.info
Normal file
@@ -0,0 +1,13 @@
|
||||
name = "Printer-friendly pages UI"
|
||||
description = "Manages the printer-friendly versions link display conditions. Without this module, those links are not displayed."
|
||||
core = 7.x
|
||||
package = "Printer, email and PDF versions"
|
||||
dependencies[] = print
|
||||
configure = admin/config/user-interface/print/ui
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-04-02
|
||||
version = "7.x-2.0"
|
||||
core = "7.x"
|
||||
project = "print"
|
||||
datestamp = "1396426766"
|
||||
|
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install, update and uninstall functions for the print UI module.
|
||||
*
|
||||
* @ingroup print
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_enable().
|
||||
*/
|
||||
function print_ui_enable() {
|
||||
// Module weight
|
||||
db_update('system')
|
||||
->fields(array(
|
||||
'weight' => 1,
|
||||
))
|
||||
->condition('type', 'module')
|
||||
->condition('name', 'print_ui')
|
||||
->execute();
|
||||
}
|
770
sites/all/modules/contrib/admin/print/print_ui/print_ui.module
Normal file
770
sites/all/modules/contrib/admin/print/print_ui/print_ui.module
Normal file
@@ -0,0 +1,770 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Printer-friendly pages User Interface module.
|
||||
*
|
||||
* This module handles the display of the printer-friendly sub-module links.
|
||||
*
|
||||
* @ingroup print
|
||||
*/
|
||||
|
||||
define('PRINT_UI_LINK_POS_DEFAULT', '{ "link": "link", "block": "block", "help": "help" }');
|
||||
define('PRINT_UI_LINK_TEASER_DEFAULT', 0);
|
||||
define('PRINT_UI_SHOW_LINK_DEFAULT', 1);
|
||||
define('PRINT_UI_SYS_LINK_VISIBILITY_DEFAULT', 1);
|
||||
define('PRINT_UI_SYS_LINK_PAGES_DEFAULT', '');
|
||||
define('PRINT_UI_LINK_USE_ALIAS_DEFAULT', 0);
|
||||
define('PRINT_UI_BOOK_LINK_DEFAULT', 1);
|
||||
|
||||
define('PRINT_UI_ALLOW_NORMAL_LINK', 1);
|
||||
define('PRINT_UI_ALLOW_BOOK_LINK', 2);
|
||||
define('PRINT_UI_TYPE_FIELDS_WEIGHT', 30);
|
||||
|
||||
define('PRINT_UI_TYPE_SHOW_LINK_DEFAULT', 1);
|
||||
define('PRINT_UI_TYPE_COMMENT_LINK_DEFAULT', 0);
|
||||
|
||||
/**
|
||||
* Implements hook_permission().
|
||||
*/
|
||||
function print_ui_permission() {
|
||||
return array(
|
||||
'node-specific print configuration' => array(
|
||||
'title' => t('Node-specific configuration'),
|
||||
'description' => t('Enable access to the per-node settings.'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function print_ui_theme() {
|
||||
return array(
|
||||
'print_ui_format_link' => array(
|
||||
'variables' => array('format' => '', 'location' => ''),
|
||||
),
|
||||
'print_ui_settings' => array(
|
||||
'render element' => 'form',
|
||||
'file' => 'print_ui.admin.inc',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function print_ui_menu() {
|
||||
$items = array();
|
||||
$items['admin/config/user-interface/print/ui'] = array(
|
||||
'title' => 'Links',
|
||||
'description' => 'Configure the print module links.',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('print_ui_settings'),
|
||||
'access arguments' => array('administer print'),
|
||||
'weight' => 9,
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'file' => 'print_ui.admin.inc',
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_block_info().
|
||||
*/
|
||||
function print_ui_block_info() {
|
||||
$block['print-links']['info'] = t('Printer, email and PDF versions');
|
||||
$block['print-links']['cache'] = DRUPAL_CACHE_PER_PAGE;
|
||||
return $block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_block_view().
|
||||
*/
|
||||
function print_ui_block_view($delta = '') {
|
||||
$block = array();
|
||||
|
||||
switch ($delta) {
|
||||
case 'print-links':
|
||||
$nid = preg_replace('!^node/!', '', $_GET['q']);
|
||||
if (ctype_digit($nid)) {
|
||||
$node = node_load($nid);
|
||||
if (!node_access('view', $node)) {
|
||||
// If the user doesn't have access to the node, don't show any links
|
||||
$block['content'] = '';
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$node = NULL;
|
||||
}
|
||||
|
||||
$block['content'] = '';
|
||||
foreach (module_implements('print_link') as $module) {
|
||||
$function = $module . '_print_link';
|
||||
if (function_exists($function)) {
|
||||
$link = call_user_func_array($function, array());
|
||||
|
||||
$link_pos = variable_get('print_' . $link['format'] . '_link_pos', drupal_json_decode(PRINT_UI_LINK_POS_DEFAULT));
|
||||
|
||||
if (!(empty($link_pos['block']))) {
|
||||
$links = print_ui_insert_link($link, array('node' => $node, 'location' => 'block'));
|
||||
if (!empty($links)) {
|
||||
$block['content'] .= $links;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_help().
|
||||
*/
|
||||
function print_ui_help($path, $arg) {
|
||||
$links = '';
|
||||
|
||||
if (($path !== 'node/%') && ($path !== 'node/%/revisions/%/view')) {
|
||||
static $output = FALSE;
|
||||
|
||||
if ($output === FALSE) {
|
||||
$output = TRUE;
|
||||
|
||||
foreach (module_implements('print_link') as $module) {
|
||||
$function = $module . '_print_link';
|
||||
if (function_exists($function)) {
|
||||
$link = call_user_func_array($function, array());
|
||||
|
||||
$link_pos = variable_get('print_' . $link['format'] . '_link_pos', drupal_json_decode(PRINT_UI_LINK_POS_DEFAULT));
|
||||
|
||||
if (!empty($link_pos['help'])) {
|
||||
$links .= print_ui_insert_link($link, array('location' => 'help'));
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($links) {
|
||||
return "<span class='print-syslink'>$links</span>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_node_view_alter().
|
||||
*/
|
||||
function print_ui_node_view_alter(&$build) {
|
||||
if (isset($build['links']['book']['#links']['book_printer'])) {
|
||||
$book_link = variable_get('print_html_book_link', PRINT_UI_BOOK_LINK_DEFAULT);
|
||||
|
||||
if ($book_link) {
|
||||
$link = print_print_link();
|
||||
$link_pos = variable_get('print_html_link_pos', drupal_json_decode(PRINT_UI_LINK_POS_DEFAULT));
|
||||
|
||||
if (!empty($link_pos['link'])) {
|
||||
$format = theme('print_ui_format_link', array('format' => 'html', 'location' => 'link'));
|
||||
|
||||
switch ($book_link) {
|
||||
case 1:
|
||||
$path = $build['links']['book']['#links']['book_printer']['href'];
|
||||
break;
|
||||
case 2:
|
||||
$link_use_alias = variable_get('print_html_link_use_alias', PRINT_UI_LINK_USE_ALIAS_DEFAULT);
|
||||
$path = ($link_use_alias && ($alias = drupal_lookup_path('alias', 'node/' . $build['#node']->nid))) ? $alias : $build['#node']->nid;
|
||||
break;
|
||||
}
|
||||
|
||||
$build['links']['book']['#links']['book_printer'] = array(
|
||||
'href' => $link['path'] . '/' . $path,
|
||||
'title' => $format['text'],
|
||||
'attributes' => $format['attributes'],
|
||||
'html' => $format['html'],
|
||||
);
|
||||
}
|
||||
else {
|
||||
unset($build['links']['book']['#links']['book_printer']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_node_view().
|
||||
*/
|
||||
function print_ui_node_view($node, $view_mode) {
|
||||
$corner_markup = '';
|
||||
|
||||
foreach (module_implements('print_link') as $module) {
|
||||
$function = $module . '_print_link';
|
||||
if (function_exists($function)) {
|
||||
$link = call_user_func_array($function, array());
|
||||
|
||||
$link_pos = variable_get('print_' . $link['format'] . '_link_pos', drupal_json_decode(PRINT_UI_LINK_POS_DEFAULT));
|
||||
$link_use_alias = variable_get('print_' . $link['format'] . '_link_use_alias', PRINT_UI_LINK_USE_ALIAS_DEFAULT);
|
||||
|
||||
if (!preg_match('!^node/[\d]*/revisions/[\d]*/view$!', $_GET['q'])) {
|
||||
// Not a revision, use node->nid to build the path
|
||||
$path = (($link_use_alias) && ($alias = drupal_lookup_path('alias', 'node/' . $node->nid))) ? $alias : $node->nid;
|
||||
}
|
||||
else {
|
||||
// This is a node revision, replace only the node component
|
||||
$path = preg_replace('!^node/!', '', $_GET['q']);
|
||||
}
|
||||
$path = $link['path'] . '/' . $path;
|
||||
|
||||
foreach (array('node', 'comment') as $type) {
|
||||
$allowed_type = print_ui_link_allowed($link, array('type' => $type, 'node' => $node, 'view_mode' => $view_mode));
|
||||
if ($allowed_type) {
|
||||
drupal_add_css(drupal_get_path('module', 'print_ui') . '/css/print_ui.theme.css');
|
||||
$links = array();
|
||||
$format = theme('print_ui_format_link', array('format' => $link['format'], 'location' => 'link'));
|
||||
|
||||
// Show book link
|
||||
if ($allowed_type === PRINT_UI_ALLOW_BOOK_LINK) {
|
||||
$path = $link['path'] . '/book/export/html/' . $node->nid;
|
||||
|
||||
$links['book_' . $link['format']] = array(
|
||||
'href' => $path,
|
||||
'title' => $format['text'],
|
||||
'attributes' => $format['attributes'],
|
||||
'html' => $format['html'],
|
||||
);
|
||||
}
|
||||
elseif ($allowed_type === PRINT_UI_ALLOW_NORMAL_LINK) {
|
||||
$links['print_' . $link['format']] = array(
|
||||
'href' => $path,
|
||||
'title' => $format['text'],
|
||||
'attributes' => $format['attributes'],
|
||||
'html' => $format['html'],
|
||||
'query' => _print_ui_query_string_encode($_GET, array('q')),
|
||||
);
|
||||
}
|
||||
|
||||
$link_content = array(
|
||||
'#theme' => 'links',
|
||||
'#links' => $links,
|
||||
'#attributes' => array('class' => array('links', 'inline')),
|
||||
);
|
||||
|
||||
// If it's a node, and configured to show the link, but it's not the html version of a book then show it
|
||||
if (($type == 'node') && !empty($link_pos['link']) && !(isset($node->book) && ($link['format'] == 'html'))) {
|
||||
$node->content['links']['print_' . $link['format']] = $link_content;
|
||||
}
|
||||
elseif (($type == 'comment') && isset($node->content['comments']['comments'])) {
|
||||
foreach ($node->content['comments']['comments'] as $cid => $comment) {
|
||||
if (is_numeric($cid)) {
|
||||
$link_content['#links']['print_' . $link['format']]['query']['comment'] = $cid;
|
||||
$node->content['comments']['comments'][$cid]['links']['print_' . $link['format']] = $link_content;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($link_pos['corner'])) {
|
||||
$corner_markup .= print_ui_insert_link($link, array('node' => $node, 'path' => $path, 'location' => 'corner'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (($view_mode == 'full') && (!empty($corner_markup))) {
|
||||
// Insert content corner links
|
||||
$node->content['print_links'] = array(
|
||||
'#prefix' => '<span class="print-link">',
|
||||
'#markup' => $corner_markup,
|
||||
'#suffix' => '</span>',
|
||||
'#weight' => -101,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_node_load().
|
||||
*/
|
||||
function print_ui_node_load($nodes, $types) {
|
||||
$ids = array();
|
||||
foreach ($nodes as $node) {
|
||||
$ids[] = $node->nid;
|
||||
}
|
||||
|
||||
foreach (module_implements('print_link') as $module) {
|
||||
$function = $module . '_print_link';
|
||||
if (function_exists($function)) {
|
||||
$link = call_user_func_array($function, array());
|
||||
|
||||
$display = 'print_' . $link['format'] . '_display';
|
||||
$display_comment = 'print_' . $link['format'] . '_display_comment';
|
||||
$display_urllist = 'print_' . $link['format'] . '_display_urllist';
|
||||
|
||||
$result = db_query('SELECT nid, link, comments, url_list FROM {' . $module . '_node_conf} WHERE nid IN (:nids)', array(':nids' => $ids))->fetchAllAssoc('nid');
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
$node->{$display} = isset($result[$node->nid]) ? intval($result[$node->nid]->link) : variable_get($display . '_' . $node->type, PRINT_UI_TYPE_SHOW_LINK_DEFAULT);
|
||||
$node->{$display_comment} = isset($result[$node->nid]) ? intval($result[$node->nid]->comments) : variable_get($display_comment . '_' . $node->type, PRINT_UI_TYPE_COMMENT_LINK_DEFAULT);
|
||||
$node->{$display_urllist} = isset($result[$node->nid]) ? intval($result[$node->nid]->url_list) : variable_get($display_urllist . '_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_node_insert().
|
||||
*/
|
||||
function print_ui_node_insert($node) {
|
||||
return print_ui_node_update($node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_node_update().
|
||||
*/
|
||||
function print_ui_node_update($node) {
|
||||
if (user_access('administer print') || user_access('node-specific print configuration')) {
|
||||
foreach (module_implements('print_link') as $module) {
|
||||
$function = $module . '_print_link';
|
||||
if (function_exists($function)) {
|
||||
$link = call_user_func_array($function, array());
|
||||
|
||||
$display = 'print_' . $link['format'] . '_display';
|
||||
$display_comment = 'print_' . $link['format'] . '_display_comment';
|
||||
$display_urllist = 'print_' . $link['format'] . '_display_urllist';
|
||||
|
||||
if (!isset($node->{$display}) || $node->{$display} === NULL) {
|
||||
$node->{$display} = variable_get($display . '_' . $node->type, PRINT_UI_TYPE_SHOW_LINK_DEFAULT);
|
||||
}
|
||||
if (!isset($node->{$display_comment}) || $node->{$display_comment} === NULL) {
|
||||
$node->{$display_comment} = variable_get($display_comment . '_' . $node->type, PRINT_UI_TYPE_COMMENT_LINK_DEFAULT);
|
||||
}
|
||||
if (!isset($node->{$display_urllist}) || $node->{$display_urllist} === NULL) {
|
||||
$node->{$display_urllist} = variable_get($display_urllist . '_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT);
|
||||
}
|
||||
|
||||
db_merge($module . '_node_conf')
|
||||
->key(array('nid' => $node->nid))
|
||||
->fields(array(
|
||||
'link' => $node->{$display},
|
||||
'comments' => $node->{$display_comment},
|
||||
'url_list' => $node->{$display_urllist},
|
||||
))
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_node_delete().
|
||||
*/
|
||||
function print_ui_node_delete($node) {
|
||||
foreach (module_implements('print_link') as $module) {
|
||||
$function = $module . '_print_link';
|
||||
if (function_exists($function)) {
|
||||
$link = call_user_func_array($function, array());
|
||||
|
||||
db_delete($module . '_node_conf')
|
||||
->condition('nid', $node->nid)
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter().
|
||||
*/
|
||||
function print_ui_form_alter(&$form, &$form_state, $form_id) {
|
||||
// Add the node-type settings option to activate the printer-friendly version link
|
||||
if ((user_access('administer print') || user_access('node-specific print configuration')) &&
|
||||
(($form_id == 'node_type_form') || !empty($form['#node_edit_form']))) {
|
||||
$form['print'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Printer, email and PDF versions'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#weight' => PRINT_UI_TYPE_FIELDS_WEIGHT,
|
||||
'#group' => 'additional_settings',
|
||||
);
|
||||
|
||||
foreach (module_implements('print_link') as $module) {
|
||||
$function = $module . '_print_link';
|
||||
if (function_exists($function)) {
|
||||
$link = call_user_func_array($function, array());
|
||||
|
||||
$form['print']['print_' . $link['format']] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => check_plain($link['text']),
|
||||
'#collapsible' => TRUE,
|
||||
);
|
||||
|
||||
$display = 'print_' . $link['format'] . '_display';
|
||||
$display_comment = 'print_' . $link['format'] . '_display_comment';
|
||||
$display_urllist = 'print_' . $link['format'] . '_display_urllist';
|
||||
|
||||
$form['print']['print_' . $link['format']][$display] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show link'),
|
||||
);
|
||||
$form['print']['print_' . $link['format']][$display_comment] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show link in individual comments'),
|
||||
);
|
||||
$form['print']['print_' . $link['format']][$display_urllist] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show Printer-friendly URLs list'),
|
||||
);
|
||||
|
||||
if ($form_id == 'node_type_form') {
|
||||
$form['print']['print_' . $link['format']][$display]['#default_value'] = variable_get($display . '_' . $form['#node_type']->type, PRINT_UI_TYPE_SHOW_LINK_DEFAULT);
|
||||
$form['print']['print_' . $link['format']][$display_comment]['#default_value'] = variable_get($display_comment . '_' . $form['#node_type']->type, PRINT_UI_TYPE_COMMENT_LINK_DEFAULT);
|
||||
$form['print']['print_' . $link['format']][$display_urllist]['#default_value'] = variable_get($display_urllist . '_' . $form['#node_type']->type, PRINT_TYPE_URLLIST_DEFAULT);
|
||||
}
|
||||
else {
|
||||
$node = $form['#node'];
|
||||
$form['print']['print_' . $link['format']][$display]['#default_value'] = isset($node->{$display}) ? $node->{$display} : variable_get($display . '_' . $node->type, PRINT_UI_TYPE_SHOW_LINK_DEFAULT);
|
||||
$form['print']['print_' . $link['format']][$display_comment]['#default_value'] = isset($node->{$display_comment}) ? $node->{$display_comment} : variable_get($display_comment . '_' . $node->type, PRINT_UI_TYPE_COMMENT_LINK_DEFAULT);
|
||||
$form['print']['print_' . $link['format']][$display_urllist]['#default_value'] = isset($node->{$display_urllist}) ? $node->{$display_urllist} : variable_get($display_urllist . '_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Auxiliary function to fill the Printer-friendly link attributes
|
||||
*
|
||||
* @param string $title
|
||||
* text to displayed by the link when hovering over it with the mouse
|
||||
* @param string $class
|
||||
* class attribute to be used in the link
|
||||
* @param bool $new_window
|
||||
* if TRUE opens the target page in a new window
|
||||
*
|
||||
* @return array
|
||||
* An associative array containing:
|
||||
* - title: text to be used when hovering over the link.
|
||||
* - class: CSS class of the link tag.
|
||||
* - target: used for opening a new window with the non-javascript method
|
||||
* - onclick: open a new window, with the javascript method
|
||||
* - rel: SEO-related attribute indicating that the printer-friendly version
|
||||
* should not be indexed by search engine robots.
|
||||
*/
|
||||
function _print_ui_fill_attributes($title = '', $class = '', $new_window = FALSE) {
|
||||
$print_newwindow = variable_get('print_newwindow', PRINT_NEWWINDOW_DEFAULT);
|
||||
$print_robots_noindex = variable_get('print_robots_noindex', PRINT_ROBOTS_NOINDEX_DEFAULT);
|
||||
|
||||
$attributes = array();
|
||||
$attributes['title'] = $title;
|
||||
if (!empty($class)) {
|
||||
$attributes['class'] = array($class);
|
||||
}
|
||||
|
||||
if ($new_window) {
|
||||
switch ($print_newwindow) {
|
||||
case 0:
|
||||
$attributes['target'] = '_blank';
|
||||
break;
|
||||
case 1:
|
||||
$attributes['onclick'] = 'window.open(this.href); return false';
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!empty($print_robots_noindex)) {
|
||||
$attributes['rel'] = 'nofollow';
|
||||
}
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the Printer-friendly link
|
||||
*
|
||||
* @return array
|
||||
* An associative array containing:
|
||||
* - text: The content of the link
|
||||
* - html: TRUE if the text contains HTML tags, FALSE if it's plain text
|
||||
* - attributes: several attributes of the link tag (title, class, target,
|
||||
* onclick, rel)
|
||||
*
|
||||
* @see _print_ui_fill_attributes()
|
||||
* @ingroup themeable
|
||||
* @ingroup print_themeable
|
||||
*/
|
||||
function theme_print_ui_format_link($vars) {
|
||||
$format = $vars['format'];
|
||||
|
||||
foreach (module_implements('print_link') as $module) {
|
||||
$function = $module . '_print_link';
|
||||
if (function_exists($function)) {
|
||||
$link = call_user_func_array($function, array());
|
||||
|
||||
if ($link['format'] == $format) {
|
||||
$link_class = variable_get('print_' . $link['format'] . '_link_class', $link['class']);
|
||||
|
||||
$new_window = FALSE;
|
||||
$func = $module . '_print_new_window_alter';
|
||||
if (function_exists($func)) {
|
||||
$func($new_window, $link['format']);
|
||||
}
|
||||
|
||||
$show_link = variable_get('print_' . $link['format'] . '_show_link', PRINT_UI_SHOW_LINK_DEFAULT);
|
||||
$link_text = filter_xss(variable_get('print_' . $link['format'] . '_link_text', $link['text']));
|
||||
|
||||
if ($show_link >= 2) {
|
||||
$img = drupal_get_path('module', $module) . '/icons/' . $link['icon'];
|
||||
switch ($show_link) {
|
||||
case 2:
|
||||
$text = theme('image', array('path' => $img, 'width' => '16px', 'height' => '16px', 'alt' => $link_text, 'title' => $link_text, 'attributes' => array('class' => array('print-icon'))));
|
||||
break;
|
||||
case 3:
|
||||
$text = theme('image', array('path' => $img, 'width' => '16px', 'height' => '16px', 'alt' => $link_text, 'title' => $link_text, 'attributes' => array('class' => array('print-icon', 'print-icon-margin')))) . $link_text;
|
||||
break;
|
||||
}
|
||||
$html = TRUE;
|
||||
}
|
||||
else {
|
||||
$text = $link_text;
|
||||
$html = FALSE;
|
||||
}
|
||||
|
||||
return array(
|
||||
'text' => $text,
|
||||
'html' => $html,
|
||||
'attributes' => _print_ui_fill_attributes($link['description'], strip_tags($link_class), $new_window),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Auxiliary function to display a formatted Printer-friendly link
|
||||
*
|
||||
* Function made available so that developers may call this function from
|
||||
* their defined pages/blocks.
|
||||
*
|
||||
* @param array $link
|
||||
* array returned by the hook_print_link() call.
|
||||
* @param array $args
|
||||
* Array of optional arguments:
|
||||
* - node: node object, to be used in checking node access. If the path
|
||||
* argument is not provided, the path used will be node/nid.
|
||||
* - path: path to be used in the link. If not specified, the current URL
|
||||
* is used.
|
||||
* - location: the location in the page where the link is being inserted
|
||||
* ('link', 'corner', 'block', 'help').
|
||||
*
|
||||
* @return string
|
||||
* string with the HTML link to the printer-friendly page
|
||||
*/
|
||||
function print_ui_insert_link($link, $args = array()) {
|
||||
$node = isset($args['node']) ? $args['node'] : NULL;
|
||||
$path = isset($args['path']) ? $args['path'] : NULL;
|
||||
$location = isset($args['location']) ? $args['location'] : '';
|
||||
|
||||
if ($node !== NULL) {
|
||||
$nid = $node->nid;
|
||||
if ($path === NULL) {
|
||||
$path = 'node/' . $nid;
|
||||
}
|
||||
$allowed_type = print_ui_link_allowed($link, array('node' => $node));
|
||||
}
|
||||
else {
|
||||
if ($path === NULL) {
|
||||
$nid = preg_replace('!^node/([\d]+)!', '$1', $_GET['q']);
|
||||
$path = $_GET['q'];
|
||||
}
|
||||
else {
|
||||
$nid = NULL;
|
||||
}
|
||||
$allowed_type = print_ui_link_allowed($link, array('path' => $path));
|
||||
}
|
||||
|
||||
if ($allowed_type) {
|
||||
if ($nid !== NULL) {
|
||||
if ($allowed_type === PRINT_UI_ALLOW_BOOK_LINK) {
|
||||
$path = 'book/export/html/' . $nid;
|
||||
}
|
||||
else {
|
||||
if (variable_get('print_' . $link['format'] . '_link_use_alias', PRINT_UI_LINK_USE_ALIAS_DEFAULT) && ($alias = drupal_lookup_path('alias', $path))) {
|
||||
$path = $alias;
|
||||
}
|
||||
else {
|
||||
$path = $nid;
|
||||
}
|
||||
}
|
||||
$path = $link['path'] . '/' . $path;
|
||||
$query = _print_ui_query_string_encode($_GET, array('q'));
|
||||
}
|
||||
else {
|
||||
$query = NULL;
|
||||
}
|
||||
drupal_add_css(drupal_get_path('module', 'print_ui') . '/css/print_ui.theme.css');
|
||||
$format = theme('print_ui_format_link', array('format' => $link['format'], 'location' => $location));
|
||||
return '<span class="print_' . $link['format'] . '">' . l($format['text'], $path, array('attributes' => $format['attributes'], 'query' => $query, 'absolute' => TRUE, 'html' => $format['html'])) . '</span>';
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the link to the PF version is allowed depending on the settings
|
||||
*
|
||||
* @param array $link
|
||||
* array returned by the hook_print_link() call.
|
||||
* @param array $args
|
||||
* array containing the possible parameters:
|
||||
* view_mode, node, type, path
|
||||
*
|
||||
* @return
|
||||
* FALSE if not allowed
|
||||
* PRINT_UI_ALLOW_NORMAL_LINK if a normal link is allowed
|
||||
* PRINT_UI_ALLOW_BOOK_LINK if a link is allowed in a book node
|
||||
*/
|
||||
function print_ui_link_allowed($link, $args) {
|
||||
if (isset($args['view_mode'])) {
|
||||
$view_mode = $args['view_mode'];
|
||||
if ((($view_mode == 'teaser') && !variable_get('print_' . $link['format'] . '_link_teaser', PRINT_UI_LINK_TEASER_DEFAULT))
|
||||
|| !in_array($view_mode, array('full', 'teaser'))) {
|
||||
// If the teaser link is disabled
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
$link_allowed_func = $link['module'] . '_link_allowed';
|
||||
if (function_exists($link_allowed_func)) {
|
||||
if (!$link_allowed_func($args)) {
|
||||
// If the format-specific function disallows the link
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (!empty($args['path'])) {
|
||||
$nid = preg_replace('!^node/!', '', drupal_get_normal_path($args['path']));
|
||||
if (ctype_digit($nid)) {
|
||||
$args['node'] = node_load($nid);
|
||||
}
|
||||
}
|
||||
if (!empty($args['node'])) {
|
||||
static $node_type = '';
|
||||
|
||||
$node = $args['node'];
|
||||
if (isset($node->type)) {
|
||||
$node_type = $node->type;
|
||||
}
|
||||
// Node
|
||||
if (isset($args['type']) && ($args['type'] == 'comment') && isset($node_type)) {
|
||||
// Link is for a comment, return the configured setting
|
||||
// Cache this statically to avoid duplicate queries for every comment.
|
||||
static $res = array();
|
||||
if (!isset($res[$link['format']][$node->nid])) {
|
||||
$res[$link['format']][$node->nid] = db_query("SELECT comments FROM {" . $link['module'] . "_node_conf} WHERE nid = :nid", array(':nid' => $node->nid))->fetchField();
|
||||
}
|
||||
$display_comment = ($res && ($res[$link['format']][$node->nid] !== FALSE)) ? $res[$link['format']][$node->nid] : variable_get('print_' . $link['format'] . '_display_comment_' . $node_type, PRINT_UI_TYPE_COMMENT_LINK_DEFAULT);
|
||||
if ($display_comment) {
|
||||
return PRINT_UI_ALLOW_NORMAL_LINK;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Node link
|
||||
$display = 'print_' . $link['format'] . '_display';
|
||||
if (isset($node->{$display}) && !$node->{$display}) {
|
||||
// Link for this node is disabled
|
||||
return FALSE;
|
||||
}
|
||||
elseif (isset($node->book)) {
|
||||
// Node is a book;
|
||||
$book_link = variable_get('print_' . $link['format'] . '_book_link', PRINT_UI_BOOK_LINK_DEFAULT);
|
||||
switch ($book_link) {
|
||||
case 1:
|
||||
if (user_access('access printer-friendly version')) {
|
||||
return PRINT_UI_ALLOW_BOOK_LINK;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
return PRINT_UI_ALLOW_NORMAL_LINK;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return PRINT_UI_ALLOW_NORMAL_LINK;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 'System' page
|
||||
$sys_link_visibility = variable_get('print_' . $link['format'] . '_sys_link_visibility', PRINT_UI_SYS_LINK_VISIBILITY_DEFAULT);
|
||||
$sys_link_pages = variable_get('print_' . $link['format'] . '_sys_link_pages', PRINT_UI_SYS_LINK_PAGES_DEFAULT);
|
||||
|
||||
return _print_ui_page_match($sys_link_visibility, $_GET['q'], $sys_link_pages);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the provided page is enabled according to the visibility settings
|
||||
*
|
||||
* @param int $visibility
|
||||
* current visibility settings:
|
||||
* 0 for show on every page except the listed pages
|
||||
* 1 for show on only the listed pages
|
||||
* @param string $path
|
||||
* current path
|
||||
* @param string $pages
|
||||
* list of pages
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if it is enabled, FALSE otherwise
|
||||
*/
|
||||
function _print_ui_page_match($visibility, $path, $pages) {
|
||||
if ($pages) {
|
||||
if ($visibility == 2) {
|
||||
if (module_exists('php')) {
|
||||
return php_eval($pages);
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
$alias = drupal_get_path_alias($path);
|
||||
$page_match = drupal_match_path($path, $pages);
|
||||
if ($alias != $path) {
|
||||
$page_match = $page_match || drupal_match_path($alias, $pages);
|
||||
}
|
||||
|
||||
return !($visibility xor $page_match);
|
||||
}
|
||||
else {
|
||||
return !$visibility;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse an array into a valid urlencoded query string.
|
||||
*
|
||||
* Modified from drupal_query_string_encode to prevent re-encoding of
|
||||
* encoded original. (see #301192)
|
||||
*
|
||||
* @param array $query
|
||||
* The array to be processed e.g. $_GET
|
||||
* @param array $exclude
|
||||
* The array filled with keys to be excluded.
|
||||
* @param string $parent
|
||||
* The be used in recursive calls.
|
||||
*
|
||||
* @return string
|
||||
* urlencoded string which can be appended to/as the URL query string
|
||||
*/
|
||||
function _print_ui_query_string_encode($query, $exclude = array(), $parent = '') {
|
||||
$params = array();
|
||||
foreach ($query as $key => $value) {
|
||||
if (in_array($key, $exclude, TRUE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
$params[$key] = _print_ui_query_string_encode($value, $exclude, $key);
|
||||
}
|
||||
else {
|
||||
$params[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return empty($params) ? NULL : $params;
|
||||
}
|
Reference in New Issue
Block a user