* character (asterisk) as a wildcard and the ~ character (tilde) to prevent this context from activating if the listed context is active. Other contexts which use context conditions can not be used to exclude this context from activating.'),
+ 'title' => t('Context (any)'),
+ 'description' => t('Set this context on the basis of other active contexts. Put each context on a separate line. The condition will pass if any of the contexts are active. You can use the * character (asterisk) as a wildcard and the ~ character (tilde) to prevent this context from activating if the listed context is active. Other contexts which use context conditions can not be used to exclude this context from activating.'),
'plugin' => 'context_condition_context',
),
+ 'context_all' => array(
+ 'title' => t('Context (all)'),
+ 'description' => t('Set this context on the basis of other active contexts. Put each context on a separate line. The condition will pass only if all of the contexts are active. You can use the * character (asterisk) as a wildcard and the ~ character (tilde) to prevent this context from activating if the listed context is active. Other contexts which use context conditions can not be used to exclude this context from activating.'),
+ 'plugin' => 'context_condition_context_all',
+ ),
'node' => array(
'title' => t('Node type'),
'description' => t('Set this context when viewing a node page or using the add/edit form of one of these content types.'),
@@ -21,11 +26,21 @@ function _context_context_registry() {
'description' => t('Should this context always be set? If true, this context will be active across your entire site.'),
'plugin' => 'context_condition_sitewide',
),
+ 'default' => array(
+ 'title' => t('Default context'),
+ 'description' => t('This context will be set if no other context is active except sitewide contexts.'),
+ 'plugin' => 'context_condition_default',
+ ),
'path' => array(
'title' => t('Path'),
'description' => t('Set this context when any of the paths above match the page path. Put each path on a separate line. You can use the * character (asterisk) as a wildcard and the ~ character (tilde) to exclude one or more paths. Use <front> for the site front page.'),
'plugin' => 'context_condition_path',
),
+ 'query_string' => array(
+ 'title' => t('Query String'),
+ 'description' => t('Set this context when any of the query strings above match the page query string. Put each query string on a separate line. You can use the "*" character as a wildcard and ~ to exclude one or more query strings.'),
+ 'plugin' => 'context_condition_query_string',
+ ),
'user' => array(
'title' => t('User role'),
'description' => t('Set this context when the current user has one of the selected role(s).'),
@@ -98,6 +113,11 @@ function _context_context_registry() {
'description' => t('Set the breadcrumb trail to the selected menu item.'),
'plugin' => 'context_reaction_breadcrumb',
),
+ 'template_suggestions' => array(
+ 'title' => t('Template suggestions'),
+ 'description' => t('Add template suggestions using context.'),
+ 'plugin' => 'context_reaction_template_suggestions',
+ ),
'theme' => array(
'title' => t('Theme Page'),
'description' => t('Control page theme variables using context.'),
@@ -155,6 +175,14 @@ function _context_context_plugins() {
'parent' => 'context_condition_path',
),
);
+ $plugins['context_condition_context_all'] = array(
+ 'handler' => array(
+ 'path' => drupal_get_path('module', 'context') . '/plugins',
+ 'file' => 'context_condition_context_all.inc',
+ 'class' => 'context_condition_context_all',
+ 'parent' => 'context_condition_path',
+ ),
+ );
$plugins['context_condition_node'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'context') . '/plugins',
@@ -171,6 +199,14 @@ function _context_context_plugins() {
'parent' => 'context_condition',
),
);
+ $plugins['context_condition_default'] = array(
+ 'handler' => array(
+ 'path' => drupal_get_path('module', 'context') . '/plugins',
+ 'file' => 'context_condition_default.inc',
+ 'class' => 'context_condition_default',
+ 'parent' => 'context_condition',
+ ),
+ );
$plugins['context_condition_path'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'context') . '/plugins',
@@ -179,6 +215,14 @@ function _context_context_plugins() {
'parent' => 'context_condition',
),
);
+ $plugins['context_condition_query_string'] = array(
+ 'handler' => array(
+ 'path' => drupal_get_path('module', 'context') .'/plugins',
+ 'file' => 'context_condition_query_string.inc',
+ 'class' => 'context_condition_query_string',
+ 'parent' => 'context_condition_path',
+ ),
+ );
$plugins['context_condition_user'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'context') . '/plugins',
@@ -294,6 +338,14 @@ function _context_context_plugins() {
'parent' => 'context_reaction_menu',
),
);
+ $plugins['context_reaction_template_suggestions'] = array(
+ 'handler' => array(
+ 'path' => drupal_get_path('module', 'context') . '/plugins',
+ 'file' => 'context_reaction_template_suggestions.inc',
+ 'class' => 'context_reaction_template_suggestions',
+ 'parent' => 'context_reaction',
+ ),
+ );
$plugins['context_reaction_menu'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'context') . '/plugins',
diff --git a/sites/all/modules/contrib/admin/context/context_layouts/context_layouts.info b/sites/all/modules/contrib/admin/context/context_layouts/context_layouts.info
index 47c09918..5ddb2cfb 100644
--- a/sites/all/modules/contrib/admin/context/context_layouts/context_layouts.info
+++ b/sites/all/modules/contrib/admin/context/context_layouts/context_layouts.info
@@ -6,9 +6,9 @@ core = 7.x
files[] = plugins/context_layouts_reaction_block.inc
-; Information added by drupal.org packaging script on 2013-07-29
-version = "7.x-3.0-beta7"
+; Information added by Drupal.org packaging script on 2015-01-06
+version = "7.x-3.6"
core = "7.x"
project = "context"
-datestamp = "1375065368"
+datestamp = "1420573188"
diff --git a/sites/all/modules/contrib/admin/context/context_layouts/context_layouts.module b/sites/all/modules/contrib/admin/context/context_layouts/context_layouts.module
index a1fa86eb..06cdff3a 100644
--- a/sites/all/modules/contrib/admin/context/context_layouts/context_layouts.module
+++ b/sites/all/modules/contrib/admin/context/context_layouts/context_layouts.module
@@ -49,7 +49,7 @@ function context_layouts_theme() {
if (!empty($layout['template'])) {
$info["page__context_layouts_{$theme->name}_{$layout['layout']}"] = array(
'template' => $layout['template'],
- 'path' => drupal_get_path('theme', $theme->name),
+ 'path' => $layout['path'],
);
}
}
@@ -107,10 +107,12 @@ function context_layouts_get_layouts($theme = NULL, $reset = FALSE) {
// Merge layout info into a single array.
foreach ($themes as $key => $info) {
+ $path = drupal_get_path('theme', $key);
if (!empty($info['layouts'])) {
foreach ($info['layouts'] as $layout => $layout_info) {
$layout_info['layout'] = str_replace('-', '_', $layout);
$layout_info['theme'] = $key;
+ $layout_info['path'] = $path;
$layouts[$theme][$layout] = $layout_info;
}
}
diff --git a/sites/all/modules/contrib/admin/context/context_ui/context_ui.info b/sites/all/modules/contrib/admin/context/context_ui/context_ui.info
index d89f8b53..00066996 100644
--- a/sites/all/modules/contrib/admin/context/context_ui/context_ui.info
+++ b/sites/all/modules/contrib/admin/context/context_ui/context_ui.info
@@ -8,9 +8,9 @@ configure = admin/structure/context
files[] = context.module
files[] = tests/context_ui.test
-; Information added by drupal.org packaging script on 2013-07-29
-version = "7.x-3.0-beta7"
+; Information added by Drupal.org packaging script on 2015-01-06
+version = "7.x-3.6"
core = "7.x"
project = "context"
-datestamp = "1375065368"
+datestamp = "1420573188"
diff --git a/sites/all/modules/contrib/admin/context/context_ui/context_ui.module b/sites/all/modules/contrib/admin/context/context_ui/context_ui.module
index 239d79f7..2ed2aa68 100644
--- a/sites/all/modules/contrib/admin/context/context_ui/context_ui.module
+++ b/sites/all/modules/contrib/admin/context/context_ui/context_ui.module
@@ -80,6 +80,10 @@ function context_ui_permission() {
'title' => 'Administer contexts',
'description' => 'Associate menus, views, blocks, etc. with different contexts to structure your site.'
);
+ $permissions['context ajax block access'] = array(
+ 'title' => t('Access All Blocks'),
+ 'description' => t('Allows users to access all rendered blocks via an AJAX callback. If you have some blocks that should not be rendered for some users but need those users to be able to use context UI, then implement hook_context_allow_ajax_block_access with the necessary logic.'),
+ );
return $permissions;
}
@@ -383,8 +387,10 @@ function context_ui_menu_contextual_links_alter(&$links, $router_item, $root_pat
* A page call back to activate the context_ui inline editor dialog.
*/
function context_ui_activate() {
- $_SESSION['context_ui_active'] = $_GET['destination'];
- drupal_goto($_GET['destination']);
+ if (isset($_GET['destination']) && !url_is_external($_GET['destination'])) {
+ $_SESSION['context_ui_active'] = $_GET['destination'];
+ drupal_goto($_GET['destination']);
+ }
}
/**
@@ -394,8 +400,10 @@ function context_ui_activate() {
* to navigate to when deactivating context_ui_editor
*/
function context_ui_deactivate() {
- $_SESSION['context_ui_active'] = FALSE;
- drupal_goto($_GET['destination']);
+ if (isset($_GET['destination']) && !url_is_external($_GET['destination'])) {
+ $_SESSION['context_ui_active'] = FALSE;
+ drupal_goto($_GET['destination']);
+ }
}
/**
diff --git a/sites/all/modules/contrib/admin/context/context_ui/export_ui/context_export_ui.class.php b/sites/all/modules/contrib/admin/context/context_ui/export_ui/context_export_ui.class.php
index 881f9ae4..db5cf86d 100644
--- a/sites/all/modules/contrib/admin/context/context_ui/export_ui/context_export_ui.class.php
+++ b/sites/all/modules/contrib/admin/context/context_ui/export_ui/context_export_ui.class.php
@@ -73,6 +73,7 @@ class context_export_ui extends ctools_export_ui {
if (!empty($this->plugin['form']['submit'])) {
$this->plugin['form']['submit']($form, $form_state);
}
+ context_invalidate_cache();
}
/**
diff --git a/sites/all/modules/contrib/admin/context/context_ui/tests/context_ui.test b/sites/all/modules/contrib/admin/context/context_ui/tests/context_ui.test
index 1e8092ce..06c7a5ea 100644
--- a/sites/all/modules/contrib/admin/context/context_ui/tests/context_ui.test
+++ b/sites/all/modules/contrib/admin/context/context_ui/tests/context_ui.test
@@ -24,6 +24,7 @@ class ContextUiTestCase extends DrupalWebTestCase {
$admin_user = $this->drupalCreateUser(array(
'access administration pages',
'administer site configuration',
+ 'administer contexts',
'access content',
'create blog content'
));
diff --git a/sites/all/modules/contrib/admin/context/plugins/context_condition_context.inc b/sites/all/modules/contrib/admin/context/plugins/context_condition_context.inc
index b9140705..aca0e6ae 100644
--- a/sites/all/modules/contrib/admin/context/plugins/context_condition_context.inc
+++ b/sites/all/modules/contrib/admin/context/plugins/context_condition_context.inc
@@ -9,7 +9,8 @@ class context_condition_context extends context_condition_path {
$active_contexts = array_keys(context_active_contexts());
foreach ($this->get_contexts() as $context) {
if (!in_array($context->name, $active_contexts, TRUE) && $values = $this->fetch_from_context($context, 'values')) {
- if ($this->match($active_contexts, $values)) {
+ // Always check against the active contexts.
+ if ($this->match(array_keys(context_active_contexts()), $values)) {
$this->condition_met($context);
}
}
@@ -20,4 +21,45 @@ class context_condition_context extends context_condition_path {
}
}
}
+
+ /**
+ * Retrieve all context conditions.
+ *
+ * This method is slightly adapted to context_condition::get_contexts() in
+ * order to ensure that a context that is used as condition in another context
+ * gets handled before.
+ */
+ function get_contexts($value = NULL) {
+ $map = context_condition_map();
+ $map = isset($map[$this->plugin]) ? $map[$this->plugin] : array();
+
+ $contexts = array();
+
+ // Add the contexts that are needed for conditions in the other contexts
+ // first. Start with the negated ones first, as we can not unset a met
+ // condition afterwards.
+ krsort($map);
+ foreach ($map as $key => $submap) {
+ // Negated context conditions start with a "~".
+ if (substr($key, 0, 1) == "~") {
+ $key = substr($key, 1);
+ }
+ if (!isset($contexts[$key])) {
+ $context = context_load($key);
+ // Check if context exists. This will fail for wildcards.
+ if ($context) {
+ $contexts[$context->name] = $context;
+ }
+ }
+ }
+ foreach ($map as $key => $submap) {
+ foreach ($submap as $name) {
+ if (!isset($contexts[$name])) {
+ $context = context_load($name);
+ $contexts[$context->name] = $context;
+ }
+ }
+ }
+ return $contexts;
+ }
}
diff --git a/sites/all/modules/contrib/admin/context/plugins/context_condition_context_all.inc b/sites/all/modules/contrib/admin/context/plugins/context_condition_context_all.inc
new file mode 100644
index 00000000..faecbb34
--- /dev/null
+++ b/sites/all/modules/contrib/admin/context/plugins/context_condition_context_all.inc
@@ -0,0 +1,29 @@
+condition_used()) {
+ $active_contexts = array_keys(context_active_contexts());
+ foreach ($this->get_contexts() as $context) {
+
+ // Only test contexts that haven't been activated yet,
+ // and have values set.
+ if (!in_array($context->name, $active_contexts, TRUE) && $values = $this->fetch_from_context($context, 'values')) {
+
+ // The condition is met if all contexts are active.
+ if (count(array_intersect($values, $active_contexts)) == count($values)) {
+ $this->condition_met($context);
+ }
+ }
+ }
+
+ // If the list of active contexts has changed, we need to recurse.
+ if ($active_contexts != array_keys(context_active_contexts())) {
+ $this->execute();
+ }
+ }
+ }
+}
diff --git a/sites/all/modules/contrib/admin/context/plugins/context_condition_default.inc b/sites/all/modules/contrib/admin/context/plugins/context_condition_default.inc
new file mode 100644
index 00000000..b463c0a9
--- /dev/null
+++ b/sites/all/modules/contrib/admin/context/plugins/context_condition_default.inc
@@ -0,0 +1,35 @@
+ t('Default context'));
+ }
+
+ function editor_form($context = NULL) {
+ $form = parent::editor_form($context);
+ $form[1]['#title'] = t('Default context');
+ $form['#weight'] = -10;
+ return $form;
+ }
+
+ function execute() {
+ if ($this->condition_used()) {
+ $active_contexts = context_active_contexts();
+
+ foreach ($active_contexts as $name => $context) {
+ foreach (array_keys($context->conditions) as $cond) {
+ if (!in_array($cond, array('default', 'sitewide'))) {
+ return;
+ }
+ }
+ }
+ foreach ($this->get_contexts('context_condition_default') as $context) {
+ $this->condition_met($context, 'context_condition_default');
+ }
+ }
+ }
+}
diff --git a/sites/all/modules/contrib/admin/context/plugins/context_condition_query_string.inc b/sites/all/modules/contrib/admin/context/plugins/context_condition_query_string.inc
new file mode 100644
index 00000000..781d4cbb
--- /dev/null
+++ b/sites/all/modules/contrib/admin/context/plugins/context_condition_query_string.inc
@@ -0,0 +1,28 @@
+condition_used()) {
+ $current_query_string = $_SERVER["QUERY_STRING"];
+ foreach ($this->get_contexts() as $context) {
+ $query_strings = $this->fetch_from_context($context, 'values');
+ if ($this->match($current_query_string, $query_strings, TRUE)) {
+ $this->condition_met($context);
+ }
+ }
+ }
+ }
+}
diff --git a/sites/all/modules/contrib/admin/context/plugins/context_reaction_block.css b/sites/all/modules/contrib/admin/context/plugins/context_reaction_block.css
index 7af243fa..e82a6a66 100644
--- a/sites/all/modules/contrib/admin/context/plugins/context_reaction_block.css
+++ b/sites/all/modules/contrib/admin/context/plugins/context_reaction_block.css
@@ -168,7 +168,6 @@ body.context-editing .draggable:hover a.context-block-remove {
* Block visibility ===================================================
*/
#context-blockform .context-blockform-selector {
- height:20em;
overflow:auto;
}
@@ -179,6 +178,7 @@ body.context-editing .draggable:hover a.context-block-remove {
border:1px solid #ddd;
padding:10px;
width:50%;
+ vertical-align: top;
}
#context-blockform td.blocks .label,
diff --git a/sites/all/modules/contrib/admin/context/plugins/context_reaction_block.inc b/sites/all/modules/contrib/admin/context/plugins/context_reaction_block.inc
index 433e7112..abcafd87 100644
--- a/sites/all/modules/contrib/admin/context/plugins/context_reaction_block.inc
+++ b/sites/all/modules/contrib/admin/context/plugins/context_reaction_block.inc
@@ -42,13 +42,19 @@ class context_reaction_block extends context_reaction {
$group = isset($block->context_group) ? $block->context_group : $block->module;
if (!isset($form['selector'][$group])) {
$form['selector'][$group] = array(
- '#type' => 'checkboxes',
+ '#type' => 'fieldset',
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
'#title' => isset($block->context_group) ? $block->context_group : $modules[$block->module],
+ );
+ $form['selector'][$group]['checkboxes'] = array(
+ '#type' => 'checkboxes',
'#options' => array(),
);
}
- $form['selector'][$group]['#options'][$block->bid] = check_plain($block->info);
+ $form['selector'][$group]['checkboxes']['#options'][$block->bid] = check_plain($block->info);
}
+
ksort($form['selector']);
/**
@@ -58,7 +64,7 @@ class context_reaction_block extends context_reaction {
'#tree' => TRUE,
'#theme' => 'context_block_regions_form',
);
- foreach (system_region_list($theme_key, REGIONS_VISIBLE) as $region => $label) {
+ foreach ($this->system_region_list($theme_key, REGIONS_VISIBLE) as $region => $label) {
$form['blocks'][$region] = array(
'#type' => 'item',
'#title' => $label,
@@ -215,7 +221,7 @@ class context_reaction_block extends context_reaction {
}
// Populate all block regions
- $all_regions = system_region_list($theme);
+ $all_regions = $this->system_region_list($theme);
// Load all region content assigned via blocks.
foreach (array_keys($all_regions) as $region) {
@@ -255,7 +261,7 @@ class context_reaction_block extends context_reaction {
*/
protected function is_enabled_region($region) {
global $theme;
- $regions = array_keys(system_region_list($theme));
+ $regions = array_keys($this->system_region_list($theme));
return in_array($region, $regions, TRUE);
}
@@ -290,7 +296,7 @@ class context_reaction_block extends context_reaction {
return FALSE;
}
// Check that this region is not hidden
- $visible = system_region_list($theme, REGIONS_VISIBLE);
+ $visible = $this->system_region_list($theme, REGIONS_VISIBLE);
return $requirements && $this->is_enabled_region($region) && isset($visible[$region]);
}
@@ -299,15 +305,7 @@ class context_reaction_block extends context_reaction {
*/
protected function editable_block($block) {
if (!empty($block->content)) {
- $block->content = array(
- 'content' => $block->content,
- 'context' => array('#markup' => ""),
- );
- //Contextual links are in the wrong spot in the render array once we've nested them
- if (isset($block->content['content']['#contextual_links'])) {
- $block->content['#contextual_links'] = $block->content['content']['#contextual_links'];
- unset($block->content['content']['#contextual_links']);
- }
+ $block->content['#theme_wrappers'][] = 'context_block_edit_wrap';
}
else {
// the block alter in context.module should ensure that blocks are never
@@ -328,7 +326,7 @@ class context_reaction_block extends context_reaction {
context_isset('context_ui', 'context_ui_editor_present'))
) {
global $theme;
- $regions = system_region_list($theme);
+ $regions = $this->system_region_list($theme);
$name = isset($regions[$region]) ? $regions[$region] : $region;
// The negative weight + sorted will push our region marker to the top of the region
$build['context'] = array(
@@ -388,13 +386,29 @@ class context_reaction_block extends context_reaction {
}
$this->is_editable_check($context_blocks);
- foreach ($context_blocks as $r => $blocks) {
- $context_blocks[$r] = _block_render_blocks($blocks);
+ global $theme;
+ $active_regions = $this->system_region_list($theme);
- // Make blocks editable if allowed.
- if ($this->is_editable_region($r)) {
- foreach ($context_blocks[$r] as $key => $block) {
- $context_blocks[$r][$key] = $this->editable_block($block);
+ // Make context renders regions in the same order as core.
+ $_context_blocks = array();
+ foreach ($active_regions as $r => $name) {
+ if (isset($context_blocks[$r])) {
+ $_context_blocks[$r] = $context_blocks[$r];
+ }
+ }
+ $context_blocks = $_context_blocks;
+ unset($_context_blocks);
+
+ foreach ($context_blocks as $r => $blocks) {
+ //only render blocks in an active region
+ if (array_key_exists($r, $active_regions)) {
+ $context_blocks[$r] = _block_render_blocks($blocks);
+
+ // Make blocks editable if allowed.
+ if ($this->is_editable_region($r)) {
+ foreach ($context_blocks[$r] as $key => $block) {
+ $context_blocks[$r][$key] = $this->editable_block($block);
+ }
}
}
@@ -514,7 +528,12 @@ class context_reaction_block extends context_reaction {
$result = db_select('block')
->fields('block')
->condition('theme', $theme_key)
- ->execute();
+ ->execute()
+ ->fetchAllAssoc('bid');
+
+ drupal_alter('block_list', $result);
+ drupal_alter('context_block_list', $result);
+
foreach ($result as $row) {
if (isset($block_info["{$row->module}-{$row->delta}"])) {
$block_info["{$row->module}-{$row->delta}"] = (object) array_merge((array) $row, (array) $block_info["{$row->module}-{$row->delta}"]);
@@ -576,50 +595,9 @@ class context_reaction_block extends context_reaction {
if (function_exists('json_decode')) {
return json_decode($json, $assoc);
}
- return context_reaction_block::_json_decode($json);
- }
-
- /**
- * From http://www.php.net/manual/en/function.json-decode.php#91216
- * with modifications for consistency with output of json_decode().
- *
- * Original author: walidator.info 2009.
- */
- static function _json_decode($json) {
- $comment = FALSE;
- $out = '$x = ';
- for ($i=0; $i < strlen($json); $i++) {
- if (!$comment) {
- switch ($json[$i]) {
- case '{':
- $out .= ' (object) array(';
- break;
- case '}':
- $out .= ')';
- break;
- case '[':
- $out .= ' array(';
- break;
- case ']':
- $out .= ')';
- break;
- case ':';
- $out .= '=>';
- break;
- default:
- $out .= $json[$i];
- break;
- }
- }
- else {
- $out .= $json[$i];
- }
- if ($json[$i] == '"') {
- $comment = !$comment;
- }
+ else {
+ watchdog('context', 'Please upgrade your PHP version to one that supports json_decode.');
}
- eval($out . ';');
- return $x;
}
/**
@@ -640,7 +618,7 @@ class context_reaction_block extends context_reaction {
list($bid, $context) = explode(',', $param);
list($module, $delta) = explode('-', $bid, 2);
// Check token to make sure user has access to block.
- if (empty($_GET['context_token']) || $_GET['context_token'] != drupal_get_token($bid)) {
+ if (!(user_access('administer contexts') || user_access('context ajax block access') || $this->context_block_ajax_rendering_allowed($bid))) {
echo drupal_json_encode(array('status' => 0));
exit;
}
@@ -670,4 +648,34 @@ class context_reaction_block extends context_reaction {
echo drupal_json_encode(array('status' => 0));
drupal_exit();
}
+
+ /**
+ * Provide caching for system_region_list since it can get called
+ * frequently. Evaluate for removal once https://drupal.org/node/1873450
+ * lands or system_region_list is otherwise cached in core
+ */
+ protected function system_region_list($theme_key, $show = REGIONS_ALL) {
+ static $cache = array();
+ if (!isset($cache[$theme_key])) {
+ $cache[$theme_key] = array();
+ }
+ if (!isset($cache[$theme_key][$show])) {
+ $cache[$theme_key][$show] = system_region_list($theme_key, $show);
+ }
+ return $cache[$theme_key][$show];
+ }
+
+ /**
+ * Allow modules to selectively allow ajax rendering of a specific block
+ */
+ private function context_block_ajax_rendering_allowed($bid) {
+ $allowed = FALSE;
+ foreach (module_invoke_all('context_allow_ajax_block_access', $bid) as $module_allow) {
+ $allowed = $allow || $module_allow;
+ if ($allowed) {
+ break;
+ }
+ }
+ return $allowed;
+ }
}
diff --git a/sites/all/modules/contrib/admin/context/plugins/context_reaction_block.js b/sites/all/modules/contrib/admin/context/plugins/context_reaction_block.js
index b51e2f34..10e25a26 100644
--- a/sites/all/modules/contrib/admin/context/plugins/context_reaction_block.js
+++ b/sites/all/modules/contrib/admin/context/plugins/context_reaction_block.js
@@ -327,11 +327,6 @@ DrupalContextBlockEditor.prototype = {
// Construct query params for our AJAX block request.
var params = Drupal.settings.contextBlockEditor.params;
params.context_block = bid + ',' + context;
- if (!Drupal.settings.contextBlockEditor.block_tokens || !Drupal.settings.contextBlockEditor.block_tokens[bid]) {
- alert(Drupal.t('An error occurred trying to retrieve block content. Please contact a site administer.'));
- return;
- }
- params.context_token = Drupal.settings.contextBlockEditor.block_tokens[bid];
// Replace item with loading block.
//ui.sender.append(ui.item);
@@ -443,7 +438,7 @@ DrupalContextBlockEditor.prototype = {
dropOnEmpty: true,
placeholder: 'draggable-placeholder',
forcePlaceholderSize: true,
- items: '> .block:has(a.context-block.editable)',
+ items: '> *:has(a.context-block.editable)',
handle: 'a.context-block-handle',
start: function(event, ui) { self.scriptFix(event, ui, editor, context); },
stop: function(event, ui) { self.addBlock(event, ui, editor, context); },
diff --git a/sites/all/modules/contrib/admin/context/plugins/context_reaction_breadcrumb.inc b/sites/all/modules/contrib/admin/context/plugins/context_reaction_breadcrumb.inc
index 17efb0a2..66d121cc 100644
--- a/sites/all/modules/contrib/admin/context/plugins/context_reaction_breadcrumb.inc
+++ b/sites/all/modules/contrib/admin/context/plugins/context_reaction_breadcrumb.inc
@@ -5,35 +5,35 @@
*/
class context_reaction_breadcrumb extends context_reaction_menu {
/**
- * Override of execute().
+ * Overrides set_active_trail_from_link to set the breadcrumb instead of the menu path.
*/
- function execute(&$vars = NULL) {
- if ($active_paths = $this->get_active_paths()) {
- $breadcrumb = array(l(t('Home'), 'TRUE (PHP-mode, experts only).');
- $form['settings']['adv_link']['print_html_node_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' => ''));
- }
- }
-
- $form['settings']['adv_link']['print_html_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_html_sys_link_visibility', PRINT_HTML_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']['print_html_sys_link_pages'] = array(
- '#type' => 'textarea',
- '#default_value' => variable_get('print_html_sys_link_pages', PRINT_HTML_SYS_LINK_PAGES_DEFAULT),
- '#rows' => 3,
- '#description' => t('Setting this option will add a printer-friendly version page link on pages created by Drupal or the enabled modules.') . 'TRUE (PHP-mode, experts only).');
- $form['settings']['adv_link']['print_html_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' => ''));
- }
- }
-
- $form['settings']['adv_link']['print_html_book_link'] = array(
- '#type' => 'radios',
- '#title' => t('Link in book hierarchy nodes'),
- '#default_value' => variable_get('print_html_book_link', PRINT_HTML_BOOK_LINK_DEFAULT),
- '#options' => array(t('Book module link not modified'), t('Current page and sub-pages'), t('Current page only')),
- );
-
$form['settings']['print_html_new_window'] = array(
'#type' => 'checkbox',
'#title' => t('Open the printer-friendly version in a new window'),
@@ -326,18 +221,18 @@ function print_html_settings() {
'#description' => t("When the above options are enabled, this option will close the window after its contents are printed."),
);
- $form['settings']['print_display_sys_urllist'] = array(
+ $form['settings']['print_html_display_sys_urllist'] = array(
'#type' => 'checkbox',
'#title' => t('Printer-friendly URLs list in system pages'),
- '#default_value' => variable_get('print_display_sys_urllist', PRINT_TYPE_SYS_URLLIST_DEFAULT),
+ '#default_value' => variable_get('print_html_display_sys_urllist', PRINT_TYPE_SYS_URLLIST_DEFAULT),
'#description' => t('Enabling this option will display a list of printer-friendly destination URLs at the bottom of the page.'),
);
$form['settings']['print_robots_settings'] = array(
- '#type' => 'fieldset',
- '#title' => t('Robots META tags'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
+ '#type' => 'fieldset',
+ '#title' => t('Robots META tags'),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
);
$form['settings']['print_robots_settings']['print_robots_noindex'] = array(
@@ -361,92 +256,22 @@ function print_html_settings() {
'#description' => t('Non-standard tag to instruct search engines to not show a "Cached" link for your printer-friendly pages. Recognized by Googlebot.'),
);
- return system_settings_form($form);
-}
-
-/**
- * Menu callback for the common print module text strings settings form
- *
- * @ingroup forms
- */
-function print_main_strings_settings() {
- drupal_set_message(t("Saving these strings will disable their translation via Drupal's language system. Use the reset button to return them to the original state."), 'warning');
-
- $form['print_main_text'] = array(
+ $form['settings']['link_text'] = array(
'#type' => 'fieldset',
- '#title' => t('Text strings'),
+ '#title' => t('Custom link text'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
);
-
- $form['print_main_text']['print_text_published'] = array(
+ $form['settings']['link_text']['print_html_link_text_enabled'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable custom link text'),
+ '#default_value' => variable_get('print_html_link_text_enabled', PRINT_TYPE_LINK_TEXT_ENABLED_DEFAULT),
+ );
+ $form['settings']['link_text']['print_html_link_text'] = array(
'#type' => 'textfield',
- '#default_value' => variable_get('print_text_published', t('Published on %site_name')),
- );
- $form['print_main_text']['print_text_source_url'] = array(
- '#type' => 'textfield',
- '#default_value' => variable_get('print_text_source_url', t('Source URL')),
- );
- $form['print_main_text']['print_text_retrieved'] = array(
- '#type' => 'textfield',
- '#default_value' => variable_get('print_text_retrieved', t('retrieved on %date')),
- );
- $form['print_main_text']['print_text_links'] = array(
- '#type' => 'textfield',
- '#default_value' => variable_get('print_text_links', t('Links')),
- );
- $form['print_main_text']['reset'] = array(
- '#type' => 'submit',
- '#value' => t('Reset to defaults'),
- '#submit' => array('print_main_strings_settings_delete'),
- );
-
- return system_settings_form($form);
-}
-
-/**
- * Reset button callback for text strings settings form
- *
- * @ingroup forms
- */
-function print_main_strings_settings_delete() {
- variable_del('print_text_published');
- variable_del('print_text_source_url');
- variable_del('print_text_retrieved');
- variable_del('print_text_links');
-}
-
-/**
- * Menu callback for the printer-friendly version text strings settings form
- *
- * @ingroup forms
- */
-function print_html_strings_settings() {
- drupal_set_message(t("Saving these strings will disable their translation via Drupal's language system. Use the reset button to return them to the original state."), 'warning');
-
- $form['print_html_text'] = array(
- '#type' => 'fieldset',
- '#title' => t('Text strings'),
- );
-
- $form['print_html_text']['print_html_link_text'] = array(
- '#type' => 'textfield',
- '#title' => t('Link text'),
- '#default_value' => variable_get('print_html_link_text', t('Printer-friendly version')),
+ '#default_value' => variable_get('print_html_link_text', $link['text']),
'#description' => t('Text used in the link to the printer-friendly version.'),
);
- $form['print_html_text']['reset'] = array(
- '#type' => 'submit',
- '#value' => t('Reset to defaults'),
- '#submit' => array('print_html_strings_settings_delete'),
- );
return system_settings_form($form);
}
-
-/**
- * Reset button callback for text strings settings form
- *
- * @ingroup forms
- */
-function print_html_strings_settings_delete() {
- variable_del('print_html_link_text');
-}
diff --git a/sites/all/modules/contrib/admin/print/print.api.php b/sites/all/modules/contrib/admin/print/print.api.php
new file mode 100644
index 00000000..4cc70389
--- /dev/null
+++ b/sites/all/modules/contrib/admin/print/print.api.php
@@ -0,0 +1,122 @@
+name);
}
@@ -126,7 +119,7 @@ function print_schema() {
'fields' => array(
'path' => array(
'type' => 'varchar',
- 'length' => 128,
+ 'length' => 255,
'not null' => TRUE,
'description' => 'Page path',
),
@@ -166,12 +159,55 @@ function print_update_7000(&$sandbox) {
update_fix_d7_block_deltas($sandbox, $renamed_deltas, array());
}
+/**
+ * Enable the print UI module
+ */
+function print_update_7199(&$sandbox) {
+ module_enable(array('print_ui'), FALSE);
+}
+
+/**
+ * Delete old variables
+ */
+function print_update_7200(&$sandbox) {
+ variable_del('print_settings');
+ variable_del('print_sourceurl_settings');
+ variable_del('print_html_settings');
+ variable_del('print_robot_settings');
+
+ variable_del('print_html_node_link_pages');
+ variable_del('print_html_node_link_visibility');
+
+ variable_del('print_text_links');
+ variable_del('print_text_published');
+ variable_del('print_text_retrieved');
+ variable_del('print_text_source_url');
+
+ $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_display\_%'");
+ foreach ($settings as $variable) {
+ $name = $variable->name;
+
+ variable_set(str_replace('print_', 'print_html_', $name), variable_get($name));
+ variable_del($name);
+ }
+}
+
/**
* Enable block and help area links
*/
-function print_update_7101(&$sandbox) {
+function print_update_7202(&$sandbox) {
$link_pos = variable_get('print_html_link_pos', drupal_json_decode('{ "link": "link", "block": "block", "help": "help" }'));
$link_pos['block'] = 'block';
$link_pos['help'] = 'help';
variable_set('print_html_link_pos', $link_pos);
}
+
+/**
+ * Increase size of the path field in the print_page_counter table
+ */
+function print_update_7203(&$sandbox) {
+ db_drop_primary_key('print_page_counter');
+ db_change_field('print_page_counter', 'path', 'path',
+ array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'description' => 'Page path'),
+ array('primary key' => array('path')));
+}
diff --git a/sites/all/modules/contrib/admin/print/print.module b/sites/all/modules/contrib/admin/print/print.module
index 23b9bcf2..1a56c9fa 100644
--- a/sites/all/modules/contrib/admin/print/print.module
+++ b/sites/all/modules/contrib/admin/print/print.module
@@ -1,31 +1,5 @@
'html',
+ 'text' => t('Printer-friendly version'),
+ 'description' => t('Display a printer-friendly version of this page.'),
+ 'path' => 'print',
+ 'class' => 'print-page',
+ 'icon' => 'print_icon.png',
+ 'module' => 'print',
+ );
+}
+
+/**
+ * Implements hook_print_new_window_alter().
+ */
+function print_print_new_window_alter(&$new_window, $format) {
+ $new_window = variable_get('print_html_new_window', PRINT_HTML_NEW_WINDOW_DEFAULT);
+}
/**
* Implements hook_permission().
@@ -92,10 +72,6 @@ function print_permission() {
'title' => t('Administer the module'),
'description' => t('Perform maintenance tasks for the print module.'),
),
- 'node-specific print configuration' => array(
- 'title' => t('Node-specific configuration'),
- 'description' => t('Enable access to the per-node settings.'),
- ),
'access print' => array(
'title' => t('Access the printer-friendly page'),
'description' => t('View the printer-friendly pages and the links to them in the original pages.'),
@@ -108,12 +84,30 @@ function print_permission() {
*/
function print_theme() {
return array(
- 'print_format_link' => array(
- 'variables' => array(),
- ),
'print' => array(
- 'variables' => array('print' => array(), 'type' => PRINT_HTML_FORMAT, 'node' => NULL),
+ 'variables' => array('node' => NULL, 'query' => NULL, 'format' => '', 'expand_css' => FALSE, 'message' => ''),
'template' => 'print',
+ 'file' => 'print.pages.inc',
+ ),
+ 'print_published' => array(
+ 'variables' => array(),
+ 'file' => 'print.pages.inc',
+ ),
+ 'print_breadcrumb' => array(
+ 'variables' => array('node' => NULL),
+ 'file' => 'print.pages.inc',
+ ),
+ 'print_footer' => array(
+ 'variables' => array(),
+ 'file' => 'print.pages.inc',
+ ),
+ 'print_sourceurl' => array(
+ 'variables' => array('url' => '', 'node' => NULL, 'cid' => NULL),
+ 'file' => 'print.pages.inc',
+ ),
+ 'print_url_list' => array(
+ 'variables' => array(),
+ 'file' => 'print.pages.inc',
),
);
}
@@ -122,7 +116,7 @@ function print_theme() {
* Implements hook_preprocess_HOOK().
*/
function print_preprocess_node(&$variables) {
- if (($variables['elements']['#view_mode'] == 'print') && isset($variables['elements']['#print_format'])) {
+ if (($variables['elements']['#view_mode'] == PRINT_VIEW_MODE) && isset($variables['elements']['#print_format'])) {
$type = $variables['elements']['#node']->type;
$format = $variables['elements']['#print_format'];
$nid = $variables['elements']['#node']->nid;
@@ -134,61 +128,21 @@ function print_preprocess_node(&$variables) {
}
}
-/**
- * Implements hook_preprocess_HOOK().
- */
-function print_preprocess_print(&$variables) {
- static $hooks = NULL;
- if (!isset($hooks)) {
- drupal_theme_initialize();
- $hooks = theme_get_registry();
- }
-
- $variables['page']['#show_messages'] = FALSE;
-
- // Stolen from theme() so that ALL preprocess functions are called
- $hook = 'page';
- $info = $hooks[$hook];
- if (isset($info['preprocess functions']) || isset($info['process functions'])) {
- foreach (array('preprocess functions', 'process functions') as $phase) {
- if (!empty($info[$phase])) {
- foreach ($info[$phase] as $processor_function) {
- if (function_exists($processor_function)) {
- // We don't want a poorly behaved process function changing $hook.
- $hook_clone = $hook;
- $processor_function($variables, $hook_clone);
- }
- }
- }
- }
- }
-
- $format = $variables['type'];
- $type = (isset($variables['node']->type)) ? $variables['node']->type : '';
- $nid = (isset($variables['node']->nid)) ? $variables['node']->nid : '';
-
- $variables['theme_hook_suggestions'] = array();
- $variables['theme_hook_suggestions'][] = "print__node__{$type}";
- $variables['theme_hook_suggestions'][] = "print__node__{$type}__{$nid}";
- $variables['theme_hook_suggestions'][] = "print__{$format}";
- $variables['theme_hook_suggestions'][] = "print__{$format}__node__{$type}";
- $variables['theme_hook_suggestions'][] = "print__{$format}__node__{$type}__{$nid}";
-}
-
/**
* Implements hook_menu().
*/
function print_menu() {
+ $link = print_print_link();
$items = array();
- $items[PRINT_PATH] = array(
+ $items[$link['path']] = array(
'title' => 'Printer-friendly',
'page callback' => 'print_controller_html',
'access arguments' => array('access print'),
'type' => MENU_CALLBACK,
'file' => 'print.pages.inc',
);
- $items[PRINT_PATH . '/' . PRINT_PATH] = array(
+ $items[$link['path'] . '/' . $link['path']] = array(
'access callback' => FALSE,
);
$items['admin/config/user-interface/print'] = array(
@@ -204,21 +158,6 @@ function print_menu() {
'weight' => 1,
'type' => MENU_DEFAULT_LOCAL_TASK,
);
- $items['admin/config/user-interface/print/html/options'] = array(
- 'title' => 'Options',
- 'weight' => 1,
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- );
- $items['admin/config/user-interface/print/html/strings'] = array(
- 'title' => 'Text strings',
- 'description' => 'Override the user-facing strings used in the printer-friendly version.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('print_html_strings_settings'),
- 'access arguments' => array('administer print'),
- 'weight' => 2,
- 'type' => MENU_LOCAL_TASK,
- 'file' => 'print.admin.inc',
- );
$items['admin/config/user-interface/print/common'] = array(
'title' => 'Settings',
'description' => 'Settings for the common functionalities for all the print sub-modules.',
@@ -229,123 +168,58 @@ function print_menu() {
'type' => MENU_LOCAL_TASK,
'file' => 'print.admin.inc',
);
- $items['admin/config/user-interface/print/common/options'] = array(
- 'title' => 'Options',
- 'weight' => 1,
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- );
- $items['admin/config/user-interface/print/common/strings'] = array(
- 'title' => 'Text strings',
- 'description' => 'Override the user-facing strings used by the print module.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('print_main_strings_settings'),
- 'access arguments' => array('administer print'),
- 'weight' => 2,
- 'type' => MENU_LOCAL_TASK,
- 'file' => 'print.admin.inc',
- );
return $items;
}
+/**
+ * Implements hook_variable_info().
+ */
+function print_variable_info($options) {
+ $link = print_print_link();
+
+ $variable['print_html_link_text'] = array(
+ 'title' => t('Printer-friendly version'),
+ 'description' => t('Text used in the link to the printer-friendly version.'),
+ 'type' => 'string',
+ 'default' => t($link['text']),
+ );
+
+ return $variable;
+}
+
/**
* Implements hook_block_info().
*/
function print_block_info() {
- $block['print-links']['info'] = t('Printer, email and PDF versions');
- $block['print-links']['cache'] = DRUPAL_CACHE_PER_PAGE;
- $block['print-top']['info'] = t('Most printed');
- $block['print-top']['cache'] = DRUPAL_CACHE_GLOBAL;
- return $block;
+ $block['print-top']['info'] = t('Most printed');
+ $block['print-top']['cache'] = DRUPAL_CACHE_GLOBAL;
+ return $block;
}
/**
* Implements hook_block_view().
*/
function print_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 (array('html' => 'print', 'mail' => 'print_mail', 'pdf' => 'print_pdf') as $format => $module) {
- $link_pos = variable_get('print_' . $format . '_link_pos', drupal_json_decode(PRINT_HTML_LINK_POS_DEFAULT));
-
- if (!(empty($link_pos['block']))) {
- $func = $module . '_insert_link';
-
- if (function_exists($func)) {
- $links = $func(NULL, $node);
- if (!empty($links)) {
- $block['content'] .= $links;
- }
- }
- }
- }
- break;
case 'print-top':
$block['subject'] = t('Most printed');
$result = db_query_range("SELECT path FROM {print_page_counter} LEFT JOIN {node} n ON path = CONCAT('node/', n.nid) WHERE status <> 0 OR status IS NULL ORDER BY totalcount DESC", 0, 3)
->fetchAll();
if (count($result)) {
- $block['content'] = '' . t('Printer-friendly version') . '
', - ); - - $form['print']['print_display'] = array( - '#type' => 'checkbox', - '#title' => t('Show link'), - ); - $form['print']['print_display_comment'] = array( - '#type' => 'checkbox', - '#title' => t('Show link in individual comments'), - ); - $form['print']['print_display_urllist'] = array( - '#type' => 'checkbox', - '#title' => t('Show Printer-friendly URLs list'), - ); - - if ($form_id == 'node_type_form') { - $form['print']['print_display']['#default_value'] = variable_get('print_display_' . $form['#node_type']->type, PRINT_TYPE_SHOW_LINK_DEFAULT); - $form['print']['print_display_comment']['#default_value'] = variable_get('print_display_comment_' . $form['#node_type']->type, PRINT_TYPE_COMMENT_LINK_DEFAULT); - $form['print']['print_display_urllist']['#default_value'] = variable_get('print_display_urllist_' . $form['#node_type']->type, PRINT_TYPE_URLLIST_DEFAULT); - } - else { - $node = $form['#node']; - $form['print']['print_display']['#default_value'] = isset($node->print_display) ? $node->print_display : variable_get('print_display_' . $node->type, PRINT_TYPE_SHOW_LINK_DEFAULT); - $form['print']['print_display_comment']['#default_value'] = isset($node->print_display_comment) ? $node->print_display_comment : variable_get('print_display_comment_' . $node->type, PRINT_TYPE_COMMENT_LINK_DEFAULT); - $form['print']['print_display_urllist']['#default_value'] = isset($node->print_display_urllist) ? $node->print_display_urllist : variable_get('print_display_urllist_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT); - } - } -} - /** * Implements hook_entity_info_alter(). */ function print_entity_info_alter(&$info) { // Add the 'Print' view mode for nodes. $info['node']['view modes'] += array( - 'print' => array( + PRINT_VIEW_MODE => array( 'label' => t('Print'), - 'custom settings' => TRUE, + 'custom settings' => FALSE, ), ); + // Add the 'Print' view mode for field_collections + if (module_exists('field_collection')) { + $info['field_collection_item']['view modes'] += array( + PRINT_VIEW_MODE => array( + 'label' => t('Print'), + 'custom settings' => FALSE, + ), + ); + } } /** * Auxiliary function to discover a given page's title * - * @param $path + * @param string $path * path of the page being identified - * @return + * + * @return string * string with the page's title */ function _print_get_title($path) { @@ -578,338 +295,47 @@ function _print_get_title($path) { } } -/** - * Modify the print_node_conf_table - * - * Update the print_node_conf table to reflect the given attributes. - * If updating to the default values, delete the record. - * - * @param $nid - * value of the nid field (primary key) - * @param $link - * value of the link field (0 or 1) - * @param $comments - * value of the comments field (0 or 1) - * @param $url_list - * value of the url_list field (0 or 1) - */ -function _print_node_conf_modify($nid, $link, $comments, $url_list) { - db_merge('print_node_conf') - ->key(array('nid' => $nid)) - ->fields(array( - 'link' => $link, - 'comments' => $comments, - 'url_list' => $url_list, - )) - ->execute(); -} - -/** - * Auxiliary function to fill the Printer-friendly link attributes - * - * @param $title - * 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 - */ -function print_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; -} - -/** - * Auxiliary function to set the link text and html flag - * - * @param $type - * type of link: 0 or 1 for a text-only link, 2 for icon-only and 3 for - * both text and icon - * @param $text - * text to be displayed on the link to the printer-friendly page - * @param $img - * path to the icon file - * @return - * array with the link text and html flag - */ -function _print_format_link_aux($type = 0, $text = '', $img = '') { - if ($type >= 2) { - $html = TRUE; - switch ($type) { - case 2: - $text = theme('image', array('path' => $img, 'alt' => $text, 'title' => $text, 'attributes' => array('class' => array('print-icon')))); - break; - case 3: - $text = theme('image', array('path' => $img, 'alt' => $text, 'title' => $text, 'attributes' => array('class' => array('print-icon', 'print-icon-margin')))) . $text; - break; - } - } - else { - $html = FALSE; - } - - return array('text' => $text, - 'html' => $html, - ); -} - -/** - * Format the Printer-friendly link - * - * @return - * array of formatted attributes - * @ingroup themeable - */ -function theme_print_format_link() { - $print_html_link_class = variable_get('print_html_link_class', PRINT_HTML_LINK_CLASS_DEFAULT); - $print_html_new_window = variable_get('print_html_new_window', PRINT_HTML_NEW_WINDOW_DEFAULT); - $print_html_show_link = variable_get('print_html_show_link', PRINT_HTML_SHOW_LINK_DEFAULT); - $print_html_link_text = filter_xss(variable_get('print_html_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 = strip_tags($print_html_link_class); - $new_window = $print_html_new_window; - $format = _print_format_link_aux($print_html_show_link, $print_html_link_text, $img); - - return array('text' => $format['text'], - 'html' => $format['html'], - 'attributes' => print_fill_attributes($title, $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 $path - * path of the original page (optional). If not specified, the current URL - * is used - * @param $node - * an optional node object, to be used in defining the path, if used, the - * path argument is irrelevant - * @return - * string with the HTML link to the printer-friendly page + * @param string $path + * path to be used in the link. If not specified, the current URL is used. + * @param object $node + * node object, to be used in checking node access. If the path argument is + * not provided, the path used will be node/nid. + * @param string $location + * where in the page where the link is being inserted ('link', 'corner', + * 'block', 'help'). + * + * @return string + * HTML link to the printer-friendly page + * + * @ingroup print_api */ -function print_insert_link($path = NULL, $node = NULL) { - if ($node !== NULL) { - $nid = $node->nid; - $path = 'node/' . $nid; - $allowed_type = print_link_allowed(array('node' => $node)); - } - else { - if ($path === NULL) { - $nid = preg_replace('!^node/([\d]+)!', '$1', $_GET['q']); - $path = $_GET['q']; - } - else { - $nid = NULL; - } - $allowed_type = print_link_allowed(array('path' => $path)); - } - - if ($allowed_type) { - if ($nid !== NULL) { - if ($allowed_type === PRINT_ALLOW_BOOK_LINK) { - $path = 'book/export/html/' . $nid; - } - else { - if (variable_get('print_html_link_use_alias', PRINT_HTML_LINK_USE_ALIAS_DEFAULT) && ($alias = drupal_lookup_path('alias', $path))) { - $path = $alias; - } - else { - $path = $nid; - } - } - $path = PRINT_PATH . '/' . $path; - $query = print_query_string_encode($_GET, array('q')); - } - else { - $query = NULL; - } - drupal_add_css(drupal_get_path('module', 'print') . '/css/printlinks.css'); - $format = theme('print_format_link'); - return '' . l($format['text'], $path, array('attributes' => $format['attributes'], 'query' => $query, 'absolute' => TRUE, 'html' => $format['html'])) . ''; +function print_insert_link($path = NULL, $node = NULL, $location = '') { + if (function_exists('print_ui_insert_link')) { + return print_ui_insert_link(print_print_link(), array('path' => $path, 'node' => $node, 'location' => $location)); } else { return FALSE; } } -/** - * Check if the provided page is enabled according to the visibility settings - * - * @param $visibility - * current visibility settings: - * 0 for show on every page except the listed pages - * 1 for show on only the listed pages - * @param $pages - * list of pages - * @return - * TRUE if it is enabled, FALSE otherwise - */ -function _print_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; - } -} - /** * Check if the link to the PF version is allowed depending on the settings * - * @param $args + * @param array $args * array containing the possible parameters: - * teaser, node, type, path - * @return - * FALSE if not allowed - * PRINT_ALLOW_NORMAL_LINK if a normal link is allowed - * PRINT_ALLOW_BOOK_LINK if a link is allowed in a book node + * view_mode, node, type, path + * + * @return bool + * FALSE if not allowed, TRUE otherwise */ function print_link_allowed($args) { - $view_mode = isset($args['view_mode']) ? $args['view_mode'] : ''; - if ((($view_mode == 'teaser') && !variable_get('print_html_link_teaser', PRINT_HTML_LINK_TEASER_DEFAULT)) - || !in_array($view_mode, array('full', 'teaser', '')) || !user_access('access print')) { - // If the teaser link is disabled or the user is not allowed - 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 - $print_html_node_link_visibility = variable_get('print_html_node_link_visibility', PRINT_HTML_NODE_LINK_VISIBILITY_DEFAULT); - $print_html_node_link_pages = variable_get('print_html_node_link_pages', PRINT_HTML_NODE_LINK_PAGES_DEFAULT); - - if (!_print_page_match($print_html_node_link_visibility, "node/" . $node->nid, $print_html_node_link_pages)) { - // Page not in visibility list - return FALSE; - } - elseif (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[$node->nid])) { - $res[$node->nid] = db_query("SELECT comments FROM {print_node_conf} WHERE nid = :nid", array(':nid' => $node->nid))->fetchField(); - } - $print_display_comment = ($res && ($res[$node->nid] !== FALSE)) ? $res[$node->nid] : variable_get('print_display_comment_' . $node_type, PRINT_TYPE_COMMENT_LINK_DEFAULT); - if ($print_display_comment) { - return PRINT_ALLOW_NORMAL_LINK; - } - } - else { - // Node link - if (isset($node->print_display) && !$node->print_display) { - // Link for this node is disabled - return FALSE; - } - elseif (isset($node->book)) { - // Node is a book; - $print_html_book_link = variable_get('print_html_book_link', PRINT_HTML_BOOK_LINK_DEFAULT); - switch ($print_html_book_link) { - case 1: - if (user_access('access printer-friendly version')) { - return PRINT_ALLOW_BOOK_LINK; - } - break; - case 2: - return PRINT_ALLOW_NORMAL_LINK; - } - } - else { - return PRINT_ALLOW_NORMAL_LINK; - } - } - } - else { - // 'System' page - $print_html_sys_link_visibility = variable_get('print_html_sys_link_visibility', PRINT_HTML_SYS_LINK_VISIBILITY_DEFAULT); - $print_html_sys_link_pages = variable_get('print_html_sys_link_pages', PRINT_HTML_SYS_LINK_PAGES_DEFAULT); - - return _print_page_match($print_html_sys_link_visibility, $_GET['q'], $print_html_sys_link_pages); - } - return FALSE; -} - -/** - * 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 $query - * The array to be processed e.g. $_GET - * @param $exclude - * The array filled with keys to be excluded. - * @return - * urlencoded string which can be appended to/as the URL query string - */ -function print_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_query_string_encode($value, $exclude, $key); - } - else { - $params[$key] = $value; - } - } - - return empty($params) ? NULL : $params; + return (user_access('access print')); } /** @@ -922,43 +348,6 @@ function print_contextual_links_view_alter(&$element, $items) { } } -/** - * Callback function for the preg_replace_callback replacing spaces with %20 - * - * Replace spaces in URLs with %20 - * - * @param array $matches - * array with the matched tag patterns, usually" . t('Links') . "
$url_list
$links:
$pfp_links
' . t("No EPUB generation tool found! Please download a supported PHP EPUB generation tool. Check this module's INSTALL.txt for more details.") . '
', + ); + } + + return system_settings_form($form); +} + +/** + * Form validation handler for print_epub_settings(). + * + * @see print_epub_settings() + * @ingroup forms + */ +function _print_epub_settings_validate($form, &$form_state) { + if (empty($form_state['values']['print_epub_epub_tool'])) { + form_set_error('print_epub_epub_tool', t("No EPUB tool selected")); + } +} diff --git a/sites/all/modules/contrib/admin/print/print_epub/print_epub.api.php b/sites/all/modules/contrib/admin/print/print_epub/print_epub.api.php new file mode 100644 index 00000000..437e68b6 --- /dev/null +++ b/sites/all/modules/contrib/admin/print/print_epub/print_epub.api.php @@ -0,0 +1,96 @@ +writeHTML($html); + if ($filename) { + $epub->Output($filename); + return TRUE; + } + else { + return $epub->Output(); + } +} + +/** + * Alters the list of available EPUB libraries. + * + * During the configuration of the EPUB library to be used, the module needs + * to discover and display the available libraries. This function should use + * the internal _print_scan_libs() function which will scan both the module + * and the libraries directory in search of the unique file pattern that can + * be used to identify the library location. + * + * @param array $epub_tools + * An associative array using as key the format 'module|path', and as value + * a string describing the discovered library, where: + * - module: the machine name of the module that handles this library. + * - path: the path where the library is installed, relative to DRUPAL_ROOT. + * If the recommended path is used, it begins with sites/all/libraries. + * As a recommendation, the value should contain in parantheses the path + * where the library was found, to allow the user to distinguish between + * multiple install paths of the same library version. + * + * @ingroup print_hooks + */ +function hook_print_epub_available_libs_alter(&$epub_tools) { + module_load_include('inc', 'print', 'includes/print'); + $tools = _print_scan_libs('foo', '!^foo.php$!'); + + foreach ($tools as $tool) { + $epub_tools['print_epub_foo|' . $tool] = 'foo (' . dirname($tool) . ')'; + } +} + +/** + * Alters the EPUB filename. + * + * Changes the value of the EPUB filename variable, just before it is used to + * create the file. When altering the variable, do not suffix it with the + * '.epub' extension, as the module will do that automatically. + * + * @param string $epub_filename + * current value of the epub_filename variable, after processing tokens and + * any transliteration steps. + * @param string $path + * original alias/system path of the page being converted to EPUB. + * + * @ingroup print_hooks + */ +function hook_print_epub_filename_alter(&$epub_filename, &$path) { + $epub_filename = 'foo'; +} + +/** + * @} End of "addtogroup hooks". + */ diff --git a/sites/all/modules/contrib/admin/print/print_epub/print_epub.drush.inc b/sites/all/modules/contrib/admin/print/print_epub/print_epub.drush.inc new file mode 100644 index 00000000..583783d9 --- /dev/null +++ b/sites/all/modules/contrib/admin/print/print_epub/print_epub.drush.inc @@ -0,0 +1,65 @@ + 'Download and extract a EPUB library.', + 'arguments' => array( + 'library' => dt('The EPUB library to download. Available choices: !libs.', array('!libs' => implode(', ', array_keys($epub_libs)))), + ), + 'options' => array( + 'path' => dt('A path to the download folder. If omitted Drush will use the default location (@path).', array('@path' => 'sites/all/libraries')), + ), + 'aliases' => array('epubdl'), + 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT, // No site or config needed. + ); + + return $items; +} + +/** + * Implements of drush_hook_COMMAND_validate(). + */ +function drush_print_epub_download_validate($library = NULL) { + if (is_null($library)) { + $epub_libs = array(); + drush_command_invoke_all_ref('drush_epub_libs_alter', $epub_libs); + + drush_set_error('DRUSH_EPUBDL_MISSING_ARG', dt("Usage: drush !cmdTRUE (PHP-mode, experts only).');
- $form['settings']['adv_link']['print_mail_node_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' => ''));
- }
- }
-
- $form['settings']['adv_link']['print_mail_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_mail_sys_link_visibility', PRINT_MAIL_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']['print_mail_sys_link_pages'] = array(
- '#type' => 'textarea',
- '#default_value' => variable_get('print_mail_sys_link_pages', PRINT_MAIL_SYS_LINK_PAGES_DEFAULT),
- '#rows' => 3,
- '#description' => t('Setting this option will add a send by email link on pages created by Drupal or the enabled modules.') . 'TRUE (PHP-mode, experts only).');
- $form['settings']['adv_link']['print_mail_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' => ''));
- }
- }
-
- $form['settings']['adv_link']['print_mail_book_link'] = array(
- '#type' => 'radios',
- '#title' => t('Link in book hierarchy nodes'),
- '#default_value' => variable_get('print_mail_book_link', PRINT_MAIL_BOOK_LINK_DEFAULT),
- '#options' => array(t('No link'), t('Current page and sub-pages'), t('Current page only')),
- );
-
$form['settings']['print_mail_hourly_threshold'] = array(
'#type' => 'select',
'#title' => t('Hourly threshold'),
@@ -153,6 +48,13 @@ function print_mail_settings() {
'#description' => t("If selected, the default choice will be to send only the node's teaser instead of the full content."),
);
+ $form['settings']['print_mail_user_recipients'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable user list recipients'),
+ '#default_value' => variable_get('print_mail_user_recipients', PRINT_MAIL_USER_RECIPIENTS_DEFAULT),
+ '#description' => t("If selected, a user list will be included as possible email recipients."),
+ );
+
$form['settings']['print_mail_teaser_choice'] = array(
'#type' => 'checkbox',
'#title' => t('Enable teaser/full mode choice'),
@@ -188,78 +90,22 @@ function print_mail_settings() {
'#description' => t('Enabling this option will display a list of printer-friendly destination URLs at the bottom of the page.'),
);
- return system_settings_form($form);
-}
-
-/**
- * Menu callback for the send by email module text strings settings form.
- *
- * @ingroup forms
- */
-function print_mail_strings_settings() {
- drupal_set_message(t("Saving these strings will disable their translation via Drupal's language system. Use the reset button to return them to the original state."), 'warning', FALSE);
-
- $form['print_mail_text'] = array(
+ $form['settings']['link_text'] = array(
'#type' => 'fieldset',
- '#title' => t('Text strings'),
+ '#title' => t('Custom link text'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
);
-
- $form['print_mail_text']['print_mail_link_text'] = array(
+ $form['settings']['link_text']['print_mail_link_text_enabled'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable custom link text'),
+ '#default_value' => variable_get('print_mail_link_text_enabled', PRINT_TYPE_LINK_TEXT_ENABLED_DEFAULT),
+ );
+ $form['settings']['link_text']['print_mail_link_text'] = array(
'#type' => 'textfield',
- '#title' => t('Link text'),
- '#default_value' => variable_get('print_mail_link_text', t('Send by email')),
- '#description' => t('Text used in the link to the send by-email form.'),
- );
-
- $form['print_mail_text']['print_mail_text_title'] = array(
- '#type' => 'textfield',
- '#title' => t('Form page title'),
- '#default_value' => variable_get('print_mail_text_title', t('Send page by email')),
- '#description' => t("Text used as the page title of the mail submission form. Requires a menu rebuild to apply."),
- );
- $form['print_mail_text']['print_mail_text_subject'] = array(
- '#type' => 'textfield',
- '#title' => t('Message subject'),
- '#default_value' => variable_get('print_mail_text_subject', t('!user has sent you a message from !site')),
- '#description' => t("email subject line. The sender's name will appear in place of !user in the subject. The web site name will be inserted in place of !site. The page title replaces !title."),
- );
- $form['print_mail_text']['print_mail_text_message'] = array(
- '#type' => 'textarea',
- '#title' => t('Message preamble'),
- '#default_value' => variable_get('print_mail_text_message', t('Message from sender')),
- '#description' => t('email message preamble. The sender will be able to add their own message after this.'),
- );
- $form['print_mail_text']['print_mail_text_content'] = array(
- '#type' => 'textarea',
- '#title' => t('Message content'),
- '#default_value' => variable_get('print_mail_text_content', ''),
- '#description' => t('Set the default contents of the message.'),
- );
- $form['print_mail_text']['print_mail_text_confirmation'] = array(
- '#type' => 'textfield',
- '#title' => t('Thank you message'),
- '#default_value' => variable_get('print_mail_text_confirmation', t('Thank you for spreading the word about !site.')),
- '#description' => t('This message will be displayed after the user successfully submits the form.'),
- );
- $form['print_mail_text']['reset'] = array(
- '#type' => 'submit',
- '#value' => t('Reset to defaults'),
- '#submit' => array('print_mail_strings_settings_delete'),
+ '#default_value' => variable_get('print_mail_link_text', $link['text']),
+ '#description' => t('Text used in the link to the send by email form.'),
);
return system_settings_form($form);
}
-
-/**
- * Reset button callback for text strings settings form
- *
- * @ingroup forms
- */
-function print_mail_strings_settings_delete() {
- variable_del('print_mail_link_text');
- variable_del('print_mail_text_title');
- variable_del('print_mail_text_subject');
- variable_del('print_mail_text_message');
- variable_del('print_mail_text_content');
- variable_del('print_mail_text_confirmation');
-}
diff --git a/sites/all/modules/contrib/admin/print/print_mail/print_mail.inc b/sites/all/modules/contrib/admin/print/print_mail/print_mail.inc
index 43785a9c..b673346e 100644
--- a/sites/all/modules/contrib/admin/print/print_mail/print_mail.inc
+++ b/sites/all/modules/contrib/admin/print/print_mail/print_mail.inc
@@ -10,19 +10,15 @@
* @ingroup print
*/
-require_once(DRUPAL_ROOT . '/' . drupal_get_path('module', 'print') . '/print.pages.inc');
-
// Include MIME library
@include_once('Mail/mime.php');
/**
- * Menu callback for the send by email form.
+ * Form constructor for the send by email form.
*
* @ingroup forms
*/
function print_mail_form($form, &$form_state) {
- global $user;
-
// Remove the printmail/ prefix
$path_arr = explode('/', $_GET['q']);
unset($path_arr[0]);
@@ -30,13 +26,14 @@ function print_mail_form($form, &$form_state) {
if (empty($path)) {
// If no path was provided, let's try to generate a page for the referer
global $base_url;
+ $link = print_mail_print_link();
$ref = $_SERVER['HTTP_REFERER'];
$path = preg_replace("!^$base_url/!", '', $ref);
if (($path === $ref) || empty($path)) {
$path = variable_get('site_frontpage', 'node');
}
- drupal_goto(PRINTMAIL_PATH . '/' . $path);
+ drupal_goto($link['path'] . '/' . $path);
}
elseif (ctype_digit($path_arr[1])) {
if (drupal_lookup_path('source', $path)) {
@@ -56,6 +53,19 @@ function print_mail_form($form, &$form_state) {
$query = $_GET;
unset($query['q']);
+ return print_mail_form_for_path($form, $form_state, $path, $query);
+}
+
+/**
+ * Build email form for the page provided in the path argument.
+ *
+ * @ingroup forms
+ */
+function print_mail_form_for_path($form, &$form_state, $path, $query = NULL, $user = NULL) {
+ if ($user === NULL) {
+ global $user;
+ }
+
$print_mail_hourly_threshold = variable_get('print_mail_hourly_threshold', PRINT_MAIL_HOURLY_THRESHOLD);
if ((!user_access('send unlimited emails')) && (!flood_is_allowed('print_mail', $print_mail_hourly_threshold))) {
@@ -68,11 +78,26 @@ function print_mail_form($form, &$form_state) {
$print_mail_teaser_default = variable_get('print_mail_teaser_default', PRINT_MAIL_TEASER_DEFAULT_DEFAULT);
$print_mail_teaser_choice = variable_get('print_mail_teaser_choice', PRINT_MAIL_TEASER_CHOICE_DEFAULT);
+ $print_mail_user_recipients_default = variable_get('print_mail_user_recipients', PRINT_MAIL_USER_RECIPIENTS_DEFAULT);
$form = array();
$cid = isset($_GET['comment']) ? (int)$_GET['comment'] : NULL;
$title = _print_get_title($path);
+ if ($print_mail_user_recipients_default) {
+ $options = array();
+ if (module_exists('realname')) {
+ $sql = "SELECT u.mail, r.realname AS name from {users} u LEFT JOIN {realname} r ON u.uid = r.uid WHERE u.uid <> :uid ORDER BY name ASC";
+ }
+ else {
+ $sql = "SELECT mail, name from {users} WHERE uid <> :uid ORDER BY name ASC";
+ }
+ $recipients = db_query($sql, array(':uid' => drupal_anonymous_user()->uid));
+ foreach ($recipients as $recipient) {
+ $options[$recipient->mail] = $recipient->name;
+ }
+ }
+
if (count($form_state['input']) == 0) {
$nodepath = drupal_get_normal_path($path);
db_merge('print_mail_page_counter')
@@ -101,14 +126,26 @@ function print_mail_form($form, &$form_state) {
'#title' => t('Your name'),
'#size' => 62,
);
- $form['txt_to_addrs'] = array(
+ $form['txt_to'] = array(
+ '#tree' => TRUE,
+ );
+ $form['txt_to']['addrs'] = array(
'#type' => 'textarea',
'#title' => t('Send to'),
'#rows' => 3,
'#resizable' => FALSE,
'#description' => t('Enter multiple addresses separated by commas and/or different lines.'),
- '#required' => TRUE,
+ '#required' => !$print_mail_user_recipients_default,
);
+ if ($print_mail_user_recipients_default) {
+ $form['txt_to']['users'] = array(
+ '#type' => 'select',
+ '#title' => t('Send to users'),
+ '#multiple' => TRUE,
+ '#size' => 10,
+ '#options' => $options,
+ );
+ }
$form['fld_subject'] = array(
'#type' => 'textfield',
'#title' => t('Subject'),
@@ -116,8 +153,8 @@ function print_mail_form($form, &$form_state) {
'#required' => TRUE,
);
if (!empty($title)) {
- // To prevent useless translation strings, try to translate only node titles
- if (drupal_substr($path, 0, 5) == 'node/') {
+ // To prevent useless translation strings, try to translate only non-node titles
+ if (drupal_substr($path, 0, 5) != 'node/') {
$title = t($title);
}
@@ -150,10 +187,6 @@ function print_mail_form($form, &$form_state) {
'#type' => 'submit',
'#value' => t('Send email'),
);
- $form['btn_clear'] = array(
- '#type' => 'markup',
- '#markup' => '',
- );
$form['btn_cancel'] = array(
'#name' => 'cancel',
'#type' => 'submit',
@@ -171,33 +204,37 @@ function print_mail_form($form, &$form_state) {
$user_name = t('Someone');
}
$site_name = variable_get('site_name', t('an interesting site'));
- $print_mail_text_subject = filter_xss(variable_get('print_mail_text_subject', t('!user has sent you a message from !site')));
- $form['fld_subject']['#default_value'] = t($print_mail_text_subject, array('!user' => $user_name, '!site' => $site_name, '!title' => $title));
- $print_mail_text_content = filter_xss(variable_get('print_mail_text_content', ''));
- $form['txt_message']['#default_value'] = t($print_mail_text_content);
+ $form['fld_subject']['#default_value'] = t('!user has sent you a message from !site', array('!user' => $user_name, '!site' => $site_name, '!title' => $title));
+ $form['txt_message']['#default_value'] = t('');
return $form;
}
/**
- * Theme function for the send by-email form submission.
+ * Returns HTML for the send by-email form.
*
* Adds a class to the form labels. This class is used to place the label on
* the left of the input fields.
*
+ * @param array $form
+ * Form array
+ *
+ * @see print_mail_form()
* @ingroup forms
+ * @ingroup themeable
+ * @ingroup print_themeable
*/
function theme_print_mail_form($variables) {
$form = $variables['form'];
- drupal_add_css(drupal_get_path('module', 'print') . '/css/printlinks.css');
+ drupal_add_css(drupal_get_path('module', 'print_mail') . '/css/print_mail.theme.css');
$content = '';
foreach (element_children($form) as $key) {
$tmp = drupal_render($form[$key]);
switch ($key) {
case 'fld_from_addr':
case 'fld_from_name':
- case 'txt_to_addrs':
+ case 'txt_to':
case 'fld_subject':
case 'fld_title':
$tmp = str_replace('' . t('Send by email') . '
', - ); - - $form['print']['print_mail_display'] = array( - '#type' => 'checkbox', - '#title' => t('Show link'), - ); - $form['print']['print_mail_display_comment'] = array( - '#type' => 'checkbox', - '#title' => t('Show link in individual comments'), - ); - $form['print']['print_mail_display_urllist'] = array( - '#type' => 'checkbox', - '#title' => t('Show Printer-friendly URLs list'), - ); - - if ($form_id == 'node_type_form') { - $form['print']['print_mail_display']['#default_value'] = variable_get('print_mail_display_' . $form['#node_type']->type, PRINT_TYPE_SHOW_LINK_DEFAULT); - $form['print']['print_mail_display_comment']['#default_value'] = variable_get('print_mail_display_comment_' . $form['#node_type']->type, PRINT_TYPE_COMMENT_LINK_DEFAULT); - $form['print']['print_mail_display_urllist']['#default_value'] = variable_get('print_mail_display_urllist_' . $form['#node_type']->type, PRINT_TYPE_URLLIST_DEFAULT); - } - else { - $node = $form['#node']; - $form['print']['print_mail_display']['#default_value'] = isset($node->print_mail_display) ? $node->print_mail_display : variable_get('print_mail_display_' . $node->type, PRINT_TYPE_SHOW_LINK_DEFAULT); - $form['print']['print_mail_display_comment']['#default_value'] = isset($node->print_mail_display_comment) ? $node->print_mail_display_comment : variable_get('print_mail_display_comment_' . $node->type, PRINT_TYPE_COMMENT_LINK_DEFAULT); - $form['print']['print_mail_display_urllist']['#default_value'] = isset($node->print_mail_display_urllist) ? $node->print_mail_display_urllist : variable_get('print_mail_display_urllist_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT); - } - } -} - /** * Implements hook_cron_queue_info(). */ @@ -348,6 +190,19 @@ function print_mail_cron_queue_info() { return $queues; } +/** + * Worker callback for print_mail_cron_queue_info() + * + * @param array $data + * An associative array containing: + * - module: A module name to invoke hook_mail() on. + * - key: A key to identify the e-mail sent. + * - to: The e-mail address or addresses where the message will be sent to. + * - language: Language object to use to compose the e-mail. + * - params: Optional parameters to build the e-mail. + * - from: Sets From to this value, if given. + * These are the input arguments of the drupal_mail() function. + */ function print_mail_send($data) { drupal_mail($data['module'], $data['key'], $data['to'], $data['language'], $data['params'], $data['from']); } @@ -369,8 +224,8 @@ function print_mail_mail($key, &$message, $params) { break; case 'sendlink': // Generate plain-text and html versions of message with link - $sendlink_plain = $params['message'] . '\n\n' . $params['link']; - $sendlink_html = $params['message'] . 'TRUE (PHP-mode, experts only).');
- $form['settings']['adv_link']['print_pdf_node_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' => ''));
- }
- }
-
- $form['settings']['adv_link']['print_pdf_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_pdf_sys_link_visibility', PRINT_PDF_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']['print_pdf_sys_link_pages'] = array(
- '#type' => 'textarea',
- '#default_value' => variable_get('print_pdf_sys_link_pages', PRINT_PDF_SYS_LINK_PAGES_DEFAULT),
- '#rows' => 3,
- '#description' => t('Setting this option will add a PDF version page link on pages created by Drupal or the enabled modules.') . 'TRUE (PHP-mode, experts only).');
- $form['settings']['adv_link']['print_pdf_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' => ''));
- }
- }
-
- $form['settings']['adv_link']['print_pdf_book_link'] = array(
- '#type' => 'radios',
- '#title' => t('Link in book hierarchy nodes'),
- '#default_value' => variable_get('print_pdf_book_link', PRINT_PDF_BOOK_LINK_DEFAULT),
- '#options' => array(t('No link'), t('Current page and sub-pages'), t('Current page only')),
- );
-
$form['settings']['print_pdf_content_disposition'] = array(
'#type' => 'radios',
'#title' => t('Open PDF in'),
@@ -153,21 +49,7 @@ function print_pdf_settings() {
$form['settings']['print_pdf_paper_size'] = array(
'#type' => 'select',
'#title' => t('Paper size'),
- '#options' => array('4A0' => '4A0', '2A0' => '2A0', 'A0' => 'A0',
- 'A1' => 'A1', 'A2' => 'A2', 'A3' => 'A3', 'A4' => 'A4',
- 'A5' => 'A5', 'A6' => 'A6', 'A7' => 'A7', 'A8' => 'A8',
- 'A9' => 'A9', 'A10' => 'A10', 'B0' => 'B0', 'B1' => 'B1',
- 'B2' => 'B2', 'B3' => 'B3', 'B4' => 'B4', 'B5' => 'B5',
- 'B6' => 'B6', 'B7' => 'B7', 'B8' => 'B8', 'B9' => 'B9',
- 'B10' => 'B10', 'C0' => 'C0', 'C1' => 'C1', 'C2' => 'C2',
- 'C3' => 'C3', 'C4' => 'C4', 'C5' => 'C5', 'C6' => 'C6',
- 'C7' => 'C7', 'C8' => 'C8', 'C9' => 'C9', 'C10' => 'C10',
- 'RA0' => 'RA0', 'RA1' => 'RA1', 'RA2' => 'RA2',
- 'RA3' => 'RA3', 'RA4' => 'RA4', 'SRA0' => 'SRA0',
- 'SRA1' => 'SRA1', 'SRA2' => 'SRA2', 'SRA3' => 'SRA3',
- 'SRA4' => 'SRA4', 'LETTER' => 'Letter', 'LEGAL' => 'Legal',
- 'EXECUTIVE' => 'Executive', 'FOLIO' => 'Folio',
- ),
+ '#options' => _print_pdf_paper_sizes(),
'#default_value' => variable_get('print_pdf_paper_size', PRINT_PDF_PAPER_SIZE_DEFAULT),
'#description' => t('Choose the paper size of the generated PDF.'),
);
@@ -179,6 +61,35 @@ function print_pdf_settings() {
'#default_value' => variable_get('print_pdf_page_orientation', PRINT_PDF_PAGE_ORIENTATION_DEFAULT),
'#description' => t('Choose the page orientation of the generated PDF.'),
);
+
+ $form['settings']['print_pdf_cache_enabled'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable caching of generated PDFs'),
+ '#default_value' => variable_get('print_pdf_cache_enabled', PRINT_PDF_CACHE_ENABLED_DEFAULT),
+ );
+
+ $form['settings']['print_pdf_cache_lifetime'] = array(
+ '#type' => 'select',
+ '#title' => t('Cache Lifetime'),
+ '#options' => array(
+ '0' => 'None',
+ '10800' => '3 hours',
+ '21600' => '6 hours',
+ '43200' => '12 hours',
+ '64800' => '18 hours',
+ '86400' => '24 hours',
+ '129600' => '36 hours',
+ '172800' => '2 days',
+ '259200' => '3 days',
+ '345600' => '4 days',
+ '432000' => '5 days',
+ '518400' => '6 days',
+ '604800' => '7 days',
+ ),
+ '#default_value' => variable_get('print_pdf_cache_lifetime', PRINT_PDF_CACHE_LIFETIME_DEFAULT),
+ '#description' => t('The lifetime of cached PDFs. A cached PDF is only removed when a node is updated, deleted, or cron is run and the last access is older than this value.'),
+ );
+
$form['settings']['print_pdf_images_via_file'] = array(
'#type' => 'checkbox',
'#title' => t('Access images via local file access'),
@@ -191,50 +102,13 @@ function print_pdf_settings() {
'#default_value' => variable_get('print_pdf_autoconfig', PRINT_PDF_AUTOCONFIG_DEFAULT),
'#description' => t('If you disable this option, the pdf tool settings must be configured manually. For TCDPF, edit the tcpdf/config/tcpdf_config.php file. For dompdf, edit the dompdf/dompdf_config.inc.php file.'),
);
- $form['settings']['print_pdf_font_family'] = array(
- '#type' => 'textfield',
- '#title' => t('Font family'),
- '#default_value' => variable_get('print_pdf_font_family', PRINT_PDF_FONT_FAMILY_DEFAULT),
- '#size' => 60,
- '#maxlength' => 250,
- '#description' => t('(TCPDF only) Set the font family to be used. Examples: %examples.', array('%examples' => 'helvetica, times, courier, dejavusans, dejavuserif, freesans, freeserif, freemono')) . '' . t("No PDF generation tool found! Please dowload a supported PHP PDF generation tool. Check this module's INSTALL.txt for more details.") . '
', + '#markup' => '' . t("No PDF generation tool found! Please download a supported PHP PDF generation tool. Check this module's INSTALL.txt for more details.") . '
', ); } @@ -268,78 +161,13 @@ function print_pdf_settings() { } /** - * Validate print_pdf_settings form. + * Form validation handler for print_pdf_settings(). + * + * @see print_pdf_settings() + * @ingroup forms */ function _print_pdf_settings_validate($form, &$form_state) { if (empty($form_state['values']['print_pdf_pdf_tool'])) { form_set_error('print_pdf_pdf_tool', t("No PDF tool selected")); } - if ($form_state['values']['print_pdf_font_size'] < 1) { - form_set_error('print_pdf_font_size', t("Font size must be at least 1.")); - } -} - -/** - * Auxiliary function to locate suitable PDF generation tools - * - * @return - * array of filenames with the include-able PHP file of the located tools - */ -function _print_pdf_tools() { - $pattern = '!^(?:dompdf_config.inc.php|tcpdf.php|wkhtmltopdf.*)$!'; - $tools = array_keys(file_scan_directory(drupal_get_path('module', 'print'), $pattern)); - $tools = array_merge($tools, array_keys(file_scan_directory(PRINT_PDF_LIB_PATH, $pattern))); - if (module_exists('libraries')) { - $tools = array_merge($tools, array_keys(file_scan_directory(libraries_get_path('dompdf'), '/^dompdf_config.inc.php$/'))); - $tools = array_merge($tools, array_keys(file_scan_directory(libraries_get_path('tcpdf'), '/^tcpdf.php$/'))); - $tools = array_merge($tools, array_keys(file_scan_directory(libraries_get_path('wkhtmltopdf'), '/^wkhtmltopdf/'))); - } - - - $num_tools = count($tools); - - if ($num_tools == 0) { - variable_set('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT); - return -1; - } - else { - return array_combine($tools, $tools); - } -} - -/** - * Menu callback for the PDF version module text strings settings form. - * - * @ingroup forms - */ -function print_pdf_strings_settings() { - drupal_set_message(t("Saving these strings will disable their translation via Drupal's language system. Use the reset button to return them to the original state."), 'warning'); - - $form['print_pdf_text'] = array( - '#type' => 'fieldset', - '#title' => t('Text strings'), - ); - - $form['print_pdf_text']['print_pdf_link_text'] = array( - '#type' => 'textfield', - '#title' => t('Link text'), - '#default_value' => variable_get('print_pdf_link_text', t('PDF version')), - '#description' => t('Text used in the link to the PDF version.'), - ); - $form['print_pdf_text']['reset'] = array( - '#type' => 'submit', - '#value' => t('Reset to defaults'), - '#submit' => array('print_pdf_strings_settings_delete'), - ); - - return system_settings_form($form); -} - -/** - * Reset button callback for text strings settings form - * - * @ingroup forms - */ -function print_pdf_strings_settings_delete() { - variable_del('print_pdf_link_text'); } diff --git a/sites/all/modules/contrib/admin/print/print_pdf/print_pdf.api.php b/sites/all/modules/contrib/admin/print/print_pdf/print_pdf.api.php new file mode 100644 index 00000000..f6c34bde --- /dev/null +++ b/sites/all/modules/contrib/admin/print/print_pdf/print_pdf.api.php @@ -0,0 +1,144 @@ + 'foopdf', + 'min_version' => '1.0', + 'url' => 'http://www.pdf.tool/download', + 'expand_css' => FALSE, + 'public_dirs' => array( + 'fonts', + 'cache', + 'tmp', + ), + 'tool_dirs' => array( + 'xyz', + ), + ); +} + +/** + * Find out the version of the PDF library + * + * @param string $pdf_tool + * Filename of the tool to be analysed. + * + * @return string + * version number of the library + */ +function hook_pdf_tool_version() { + require_once(DRUPAL_ROOT . '/' . $pdf_tool); + + return '1.0'; +} + +/** + * Generate a PDF version of the provided HTML. + * + * @param string $html + * HTML content of the PDF + * @param array $meta + * Meta information to be used in the PDF + * - url: original URL + * - name: author's name + * - title: Page title + * - node: node object + * @param string $paper_size + * (optional) Paper size of the generated PDF + * @param string $page_orientation + * (optional) Page orientation of the generated PDF + * + * @return + * generated PDF page, or NULL in case of error + * + * @see print_pdf_controller_html() + * @ingroup print_hooks + */ +function hook_print_pdf_generate($html, $meta, $paper_size = NULL, $page_orientation = NULL) { + $pdf = new PDF(); + $pdf->writeHTML($html); + + return $pdf->Output(); +} + +/** + * Alters the list of available PDF libraries. + * + * During the configuration of the PDF library to be used, the module needs + * to discover and display the available libraries. This function should use + * the internal _print_scan_libs() function which will scan both the module + * and the libraries directory in search of the unique file pattern that can + * be used to identify the library location. + * + * @param array $pdf_tools + * An associative array using as key the format 'module|path', and as value + * a string describing the discovered library, where: + * - module: the machine name of the module that handles this library. + * - path: the path where the library is installed, relative to DRUPAL_ROOT. + * If the recommended path is used, it begins with sites/all/libraries. + * As a recommendation, the value should contain in parantheses the path + * where the library was found, to allow the user to distinguish between + * multiple install paths of the same library version. + * + * @ingroup print_hooks + */ +function hook_print_pdf_available_libs_alter(&$pdf_tools) { + module_load_include('inc', 'print', 'includes/print'); + $tools = _print_scan_libs('foo', '!^foo.php$!'); + + foreach ($tools as $tool) { + $pdf_tools['print_pdf_foo|' . $tool] = 'foo (' . dirname($tool) . ')'; + } +} + +/** + * Alters the PDF filename. + * + * Changes the value of the PDF filename variable, just before it is used to + * create the file. When altering the variable, do not suffix it with the + * '.pdf' extension, as the module will do that automatically. + * + * @param string $pdf_filename + * current value of the pdf_filename variable, after processing tokens and + * any transliteration steps. + * @param string $path + * original alias/system path of the page being converted to PDF. + * + * @ingroup print_hooks + */ +function hook_print_pdf_filename_alter(&$pdf_filename, &$path) { + $pdf_filename = 'foo'; +} + +/** + * @} End of "addtogroup hooks". + */ diff --git a/sites/all/modules/contrib/admin/print/print_pdf/print_pdf.drush.inc b/sites/all/modules/contrib/admin/print/print_pdf/print_pdf.drush.inc index 4ebe9968..c46ea22a 100644 --- a/sites/all/modules/contrib/admin/print/print_pdf/print_pdf.drush.inc +++ b/sites/all/modules/contrib/admin/print/print_pdf/print_pdf.drush.inc @@ -5,32 +5,19 @@ * drush integration for print_pdf module PDF libraries download. */ -/** - * The PDF project download URL - */ - -// TCPDF is in sourceforge, and nicely provides a link to the latest version -define('TCPDF_DOWNLOAD_URI', 'http://sourceforge.net/projects/tcpdf/files/latest'); - -// URI to the the latest dompdf version.. Hardcoded version unfortunately -define('DOMPDF_DOWNLOAD_URI', 'http://dompdf.googlecode.com/files/dompdf_0-6-0_beta3.tar.gz'); - -// wkhtmltopdf is a binary, requiring a different download for each platform -define('WKHTMLTOPDF_AMD64_DOWNLOAD_URI', 'http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2'); -define('WKHTMLTOPDF_I386_DOWNLOAD_URI', 'http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1-static-i386.tar.bz2'); -define('WKHTMLTOPDF_WIN_DOWNLOAD_URI', 'http://wkhtmltopdf.googlecode.com/files/wkhtmltox-0.11.0_rc1-installer.exe'); -define('WKHTMLTOPDF_OSX_DOWNLOAD_URI', 'http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-OSX-0.10.0_rc2-static.tar.bz2'); - /** * Implements hook_drush_command(). */ function print_pdf_drush_command() { $items = array(); + $pdf_libs = array(); + drush_command_invoke_all_ref('drush_pdf_libs_alter', $pdf_libs); + $items['print-pdf-download'] = array( - 'description' => 'Download a PDF library.', + 'description' => 'Download and extract a PDF library.', 'arguments' => array( - 'library' => dt('The PDF library to download. Either tcpdf, dompdf or wkhtmltopdf.'), + 'library' => dt('The PDF library to download. Available choices: !libs.', array('!libs' => implode(', ', array_keys($pdf_libs)))), ), 'options' => array( 'path' => dt('A path to the download folder. If omitted Drush will use the default location (@path).', array('@path' => 'sites/all/libraries')), @@ -42,177 +29,37 @@ function print_pdf_drush_command() { return $items; } +/** + * Implements of drush_hook_COMMAND_validate(). + */ +function drush_print_pdf_download_validate($library = NULL) { + if (is_null($library)) { + $pdf_libs = array(); + drush_command_invoke_all_ref('drush_pdf_libs_alter', $pdf_libs); + + drush_set_error('DRUSH_PDFDL_MISSING_ARG', dt("Usage: drush !cmd' . t('PDF version') . '
', + $link = print_pdf_print_link(); + + $size = 'print_' . $link['format'] . '_size'; + $orientation = 'print_' . $link['format'] . '_orientation'; + + $form['print']['print_' . $link['format']][$size] = array( + '#type' => 'select', + '#title' => t('Paper size'), + '#options' => _print_pdf_paper_sizes(TRUE), + '#description' => t('Choose the paper size of the generated PDF.'), ); - $form['print']['print_pdf_display'] = array( - '#type' => 'checkbox', - '#title' => t('Show link'), - ); - $form['print']['print_pdf_display_comment'] = array( - '#type' => 'checkbox', - '#title' => t('Show link in individual comments'), - ); - $form['print']['print_pdf_display_urllist'] = array( - '#type' => 'checkbox', - '#title' => t('Show Printer-friendly URLs list'), + $form['print']['print_' . $link['format']][$orientation] = array( + '#type' => 'select', + '#title' => t('Page orientation'), + '#options' => array('' => 'Unchanged', 'portrait' => t('Portrait'), 'landscape' => t('Landscape')), + '#description' => t('Choose the page orientation of the generated PDF.'), ); if ($form_id == 'node_type_form') { - $form['print']['print_pdf_display']['#default_value'] = variable_get('print_pdf_display_' . $form['#node_type']->type, PRINT_TYPE_SHOW_LINK_DEFAULT); - $form['print']['print_pdf_display_comment']['#default_value'] = variable_get('print_pdf_display_comment_' . $form['#node_type']->type, PRINT_TYPE_COMMENT_LINK_DEFAULT); - $form['print']['print_pdf_display_urllist']['#default_value'] = variable_get('print_pdf_display_urllist_' . $form['#node_type']->type, PRINT_TYPE_URLLIST_DEFAULT); + $form['print']['print_' . $link['format']][$size]['#default_value'] = variable_get($size . '_' . $form['#node_type']->type); + $form['print']['print_' . $link['format']][$orientation]['#default_value'] = variable_get($orientation . '_' . $form['#node_type']->type); } else { $node = $form['#node']; - $form['print']['print_pdf_display']['#default_value'] = isset($node->print_pdf_display) ? $node->print_pdf_display : variable_get('print_pdf_display_' . $node->type, PRINT_TYPE_SHOW_LINK_DEFAULT); - $form['print']['print_pdf_display_comment']['#default_value'] = isset($node->print_pdf_display_comment) ? $node->print_pdf_display_comment : variable_get('print_pdf_display_comment_' . $node->type, PRINT_TYPE_COMMENT_LINK_DEFAULT); - $form['print']['print_pdf_display_urllist']['#default_value'] = isset($node->print_pdf_display_urllist) ? $node->print_pdf_display_urllist : variable_get('print_pdf_display_urllist_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT); + $form['print']['print_' . $link['format']][$size]['#default_value'] = isset($node->{$size}) ? $node->{$size} : variable_get($size . '_' . $node->type); + $form['print']['print_' . $link['format']][$orientation]['#default_value'] = isset($node->{$orientation}) ? $node->{$orientation} : variable_get($orientation . '_' . $node->type); } } } -/** - * Update the print_pdf_node_conf table to reflect the given attributes - * - * If updating to the default values, delete the record. - * - * @param $nid - * value of the nid field (primary key) - * @param $link - * value of the link field (0 or 1) - * @param $comments - * value of the comments field (0 or 1) - * @param $url_list - * value of the url_list field (0 or 1) - */ -function _print_pdf_node_conf_modify($nid, $link, $comments, $url_list) { - db_merge('print_pdf_node_conf') - ->key(array('nid' => $nid)) - ->fields(array( - 'link' => $link, - 'comments' => $comments, - 'url_list' => $url_list, - )) - ->execute(); -} - -/** - * Format the PDF version link - * - * @return - * array of formatted attributes - * @ingroup themeable - */ -function theme_print_pdf_format_link() { - $print_pdf_link_class = variable_get('print_pdf_link_class', PRINT_PDF_LINK_CLASS_DEFAULT); - $print_pdf_content_disposition = variable_get('print_pdf_content_disposition', PRINT_PDF_CONTENT_DISPOSITION_DEFAULT); - $print_pdf_show_link = variable_get('print_pdf_show_link', PRINT_PDF_SHOW_LINK_DEFAULT); - $print_pdf_link_text = filter_xss(variable_get('print_pdf_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 = strip_tags($print_pdf_link_class); - $new_window = ($print_pdf_content_disposition == 1); - $format = _print_format_link_aux($print_pdf_show_link, $print_pdf_link_text, $img); - - return array('text' => $format['text'], - 'html' => $format['html'], - 'attributes' => print_fill_attributes($title, $class, $new_window), - ); -} - /** * Auxiliary function to display a formatted PDF version link * * Function made available so that developers may call this function from * their defined pages/blocks. * - * @param $path - * path of the original page (optional). If not specified, the current URL - * is used - * @param $node - * an optional node object, to be used in defining the path, if used, the - * path argument is irrelevant - * @return + * @param string $path + * path to be used in the link. If not specified, the current URL is used. + * @param object $node + * node object, to be used in checking node access. If the path argument is + * not provided, the path used will be node/nid. + * @param string $location + * where in the page where the link is being inserted ('link', 'corner', + * 'block', 'help'). + * + * @return bool * string with the HTML link to the printer-friendly page + * + * @ingroup print_api */ -function print_pdf_insert_link($path = NULL, $node = NULL) { - if ($node !== NULL) { - $nid = $node->nid; - $path = 'node/' . $nid; - $allowed_type = print_pdf_link_allowed(array('node' => $node)); - } - else { - if ($path === NULL) { - $nid = preg_replace('!^node/([\d]+)!', '$1', $_GET['q']); - $path = $_GET['q']; - } - else { - $nid = NULL; - } - $allowed_type = print_pdf_link_allowed(array('path' => $path)); - } - - if ($allowed_type) { - if ($nid !== NULL) { - if ($allowed_type === PRINT_ALLOW_BOOK_LINK) { - $path = 'book/export/html/' . $nid; - } - else { - if (variable_get('print_pdf_link_use_alias', PRINT_PDF_LINK_USE_ALIAS_DEFAULT) && ($alias = drupal_lookup_path('alias', $path))) { - $path = $alias; - } - else { - $path = $nid; - } - } - $path = PRINTPDF_PATH . '/' . $path; - $query = print_query_string_encode($_GET, array('q')); - } - else { - $query = NULL; - } - drupal_add_css(drupal_get_path('module', 'print') . '/css/printlinks.css'); - $format = theme('print_pdf_format_link'); - return '' . l($format['text'], $path, array('attributes' => $format['attributes'], 'query' => $query, 'absolute' => TRUE, 'html' => $format['html'])) . ''; +function print_pdf_insert_link($path = NULL, $node = NULL, $location = '') { + if (function_exists('print_ui_insert_link')) { + return print_ui_insert_link(print_pdf_print_link(), array('path' => $path, 'node' => $node, 'location' => $location)); } else { return FALSE; @@ -581,135 +402,153 @@ function print_pdf_insert_link($path = NULL, $node = NULL) { /** * Check if the link to the PDF version is allowed depending on the settings * - * @param $args + * @param array $args * array containing the possible parameters: - * teaser, node, type, path - * @return - * FALSE if not allowed - * PRINT_ALLOW_NORMAL_LINK if a normal link is allowed - * PRINT_ALLOW_BOOK_LINK if a link is allowed in a book node + * view_mode, node, type, path + * + * @return bool + * FALSE if not allowed, TRUE otherwise */ function print_pdf_link_allowed($args) { - $view_mode = isset($args['view_mode']) ? $args['view_mode'] : ''; $print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT); - if ((($view_mode == 'teaser') && !variable_get('print_pdf_link_teaser', PRINT_PDF_LINK_TEASER_DEFAULT)) - || !in_array($view_mode, array('full', 'teaser', '')) || !user_access('access PDF version') || (empty($print_pdf_pdf_tool))) { - // If the teaser link is disabled or the user is not allowed - 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 = FALSE; - $node = $args['node']; - if (isset($node->type)) { - $node_type = $node->type; - } - // Node - $print_pdf_node_link_visibility = variable_get('print_pdf_node_link_visibility', PRINT_PDF_NODE_LINK_VISIBILITY_DEFAULT); - $print_pdf_node_link_pages = variable_get('print_pdf_node_link_pages', PRINT_PDF_NODE_LINK_PAGES_DEFAULT); - - if (!_print_page_match($print_pdf_node_link_visibility, "node/" . $node->nid, $print_pdf_node_link_pages)) { - // Page not in visibility list - return FALSE; - } - elseif (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[$node->nid])) { - $res[$node->nid] = db_query("SELECT comments FROM {print_pdf_node_conf} WHERE nid = :nid", array(':nid' => $node->nid))->fetchField(); - } - $print_display_comment = ($res && ($res[$node->nid] !== FALSE)) ? $res[$node->nid] : variable_get('print_pdf_display_comment_' . $node_type, PRINT_TYPE_COMMENT_LINK_DEFAULT); - if ($print_display_comment) { - return PRINT_ALLOW_NORMAL_LINK; - } - } - else { - // Node link - if (isset($node->print_pdf_display) && !$node->print_pdf_display) { - // Link for this node is disabled - return FALSE; - } - elseif (isset($node->book)) { - // Node is a book; - $print_pdf_book_link = variable_get('print_pdf_book_link', PRINT_PDF_BOOK_LINK_DEFAULT); - switch ($print_pdf_book_link) { - case 1: - if (user_access('access printer-friendly version')) { - return PRINT_ALLOW_BOOK_LINK; - } - break; - case 2: - return PRINT_ALLOW_NORMAL_LINK; - } - } - else { - return PRINT_ALLOW_NORMAL_LINK; - } - } - } - else { - // 'System' page - $print_pdf_sys_link_visibility = variable_get('print_pdf_sys_link_visibility', PRINT_PDF_SYS_LINK_VISIBILITY_DEFAULT); - $print_pdf_sys_link_pages = variable_get('print_pdf_sys_link_pages', PRINT_PDF_SYS_LINK_PAGES_DEFAULT); - - return _print_page_match($print_pdf_sys_link_visibility, $_GET['q'], $print_pdf_sys_link_pages); - } - return FALSE; + return (user_access('access PDF version') && (!empty($print_pdf_pdf_tool))); } /** - * Find out the version of the TCPDF library + * Implements hook_cron(). */ -function _print_pdf_tcpdf_version() { - $print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT); - if (variable_get('print_pdf_autoconfig', PRINT_PDF_AUTOCONFIG_DEFAULT)) { - // prevent TCPDF default configs - define('K_TCPDF_EXTERNAL_CONFIG', TRUE); - } - require_once(DRUPAL_ROOT . '/' . $print_pdf_pdf_tool); +function print_pdf_cron() { + print_pdf_cache_clean(); +} - // Hide warnings, as some TCPDF constants may still be undefined - @$pdf = new TCPDF(); +/** + * Removes pdf files for nodes/paths if they are older than the lifetime. + */ +function print_pdf_cache_clean() { + $lifetime = variable_get('print_pdf_cache_lifetime', PRINT_PDF_CACHE_LIFETIME_DEFAULT); - if (method_exists($pdf, 'getTCPDFVersion')) { - return $pdf->getTCPDFVersion(); - } - elseif (defined('PDF_PRODUCER')) { - sscanf(PDF_PRODUCER, "TCPDF %s", $version); + if ($lifetime > 0) { + $files = file_scan_directory(print_pdf_cache_dir(), '!\d+\.pdf$!'); + foreach ($files as $file) { + // For all files in the cache directory, see when they were last accessed + $result = db_query("SELECT timestamp FROM {print_pdf_page_counter} WHERE path = :path", array(':path' => 'node/' . $file->name)) + ->fetchField(); - return $version; - } - else { - return 'unknown'; + // Keep the file only if the last access was within the cache max life value + if (($result === FALSE) || ($result + $lifetime < REQUEST_TIME)) { + print_pdf_cache_delete($file->name); + } + } } } /** - * Find out the version of the wkhtmltopdf library + * Returns the cache directory. + * + * @return string + * The scheme://path of the cache directory */ -function _print_pdf_wkhtmltopdf_version() { - $print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT); - $descriptor = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')); +function print_pdf_cache_dir() { + $scheme = 'private'; + if (!file_stream_wrapper_valid_scheme($scheme)) { + $scheme = 'temporary'; + } + return $scheme . '://print_pdf/cache'; +} - $cmd = '"' . realpath($print_pdf_pdf_tool) . '" --version'; - $process = proc_open($cmd, $descriptor, $pipes, NULL, NULL); - if (is_resource($process)) { - $content = stream_get_contents($pipes[1]); - $out = preg_match('!.*?(\d+\.\d+\.\d+).*$!m', $content, $matches); - fclose($pipes[0]); - fclose($pipes[1]); - fclose($pipes[2]); - $retval = proc_close($process); +/** + * Deletes one or more files from the PDF cache directory. + * + * @param int nid + * The node ID of the page for which the cached PDF should be deleted. + * If not provided, the entire cache directory will be deleted. + */ +function print_pdf_cache_delete($nid = NULL) { + $directory = print_pdf_cache_dir(); + + if ($nid) { + $filename = $directory . '/' . $nid . '.pdf'; + if (is_file($filename)) { + file_unmanaged_delete($filename); + } + } + else { + // If no nid is provided, flush the entire cache. + if (is_dir($directory)) { + file_unmanaged_delete_recursive($directory); + } + } +} + +/** + * Displays the PDF as inline or a downloadable file. + * + * @param string $pdf + * PDF content string + * @param string $filename + * Filename of the generated PDF + * + * @return string + * The disposed PDF file + */ +function print_pdf_dispose_content($pdf, $filename) { + if (headers_sent()) { + exit('Unable to stream pdf: headers already sent'); + } + header('Cache-Control: private'); + header('Content-Type: application/pdf'); + + $content_disposition = variable_get('print_pdf_content_disposition', PRINT_PDF_CONTENT_DISPOSITION_DEFAULT); + $attachment = ($content_disposition == 2) ? 'attachment' : 'inline'; + + header("Content-Disposition: $attachment; filename=\"$filename\""); + + echo $pdf; + flush(); + + return TRUE; +} + +/** + * Generate a PDF version of the provided HTML. + * + * @param string $html + * HTML content of the PDF + * @param array $meta + * Meta information to be used in the PDF + * - url: original URL + * - name: author's name + * - title: Page title + * - node: node object + * @param string $filename + * (optional) Filename of the generated PDF + * @param string $paper_size + * (optional) Paper size of the generated PDF + * @param string $page_orientation + * (optional) Page orientation of the generated PDF + * + * @return + * generated PDF page, or NULL in case of error + * + * @see print_pdf_controller() + * + * @ingroup print_api + */ +function print_pdf_generate_html($html, $meta, $filename = NULL, $paper_size = NULL, $page_orientation = NULL) { + $pdf_tool = explode('|', variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT)); + + module_load_include('inc', $pdf_tool[0], $pdf_tool[0] . '.pages'); + + $function = $pdf_tool[0] . '_print_pdf_generate'; + if (function_exists($function)) { + $pdf = $function($html, $meta, $paper_size, $page_orientation); + } + if ($filename) { + return print_pdf_dispose_content($pdf, $filename); } - return ($matches[1]); + return $pdf; } /** @@ -721,3 +560,34 @@ function print_pdf_views_api() { 'path' => drupal_get_path('module', 'print_pdf'), ); } + +/** + * Lists all possible paper sizes + * + * @return + * array of strings with the available paper sizes + */ +function _print_pdf_paper_sizes($include_default = FALSE) { + $ret = array(); + + $ret = ($include_default) ? array('' => 'Unchanged') : array(); + + $ret += array( + '4A0' => '4A0', '2A0' => '2A0', 'A0' => 'A0', + 'A1' => 'A1', 'A2' => 'A2', 'A3' => 'A3', 'A4' => 'A4', + 'A5' => 'A5', 'A6' => 'A6', 'A7' => 'A7', 'A8' => 'A8', + 'A9' => 'A9', 'A10' => 'A10', 'B0' => 'B0', 'B1' => 'B1', + 'B2' => 'B2', 'B3' => 'B3', 'B4' => 'B4', 'B5' => 'B5', + 'B6' => 'B6', 'B7' => 'B7', 'B8' => 'B8', 'B9' => 'B9', + 'B10' => 'B10', 'C0' => 'C0', 'C1' => 'C1', 'C2' => 'C2', + 'C3' => 'C3', 'C4' => 'C4', 'C5' => 'C5', 'C6' => 'C6', + 'C7' => 'C7', 'C8' => 'C8', 'C9' => 'C9', 'C10' => 'C10', + 'RA0' => 'RA0', 'RA1' => 'RA1', 'RA2' => 'RA2', + 'RA3' => 'RA3', 'RA4' => 'RA4', 'SRA0' => 'SRA0', + 'SRA1' => 'SRA1', 'SRA2' => 'SRA2', 'SRA3' => 'SRA3', + 'SRA4' => 'SRA4', 'LETTER' => 'Letter', 'LEGAL' => 'Legal', + 'EXECUTIVE' => 'Executive', 'FOLIO' => 'Folio', + ); + + return $ret; +} diff --git a/sites/all/modules/contrib/admin/print/print_pdf/print_pdf.pages.inc b/sites/all/modules/contrib/admin/print/print_pdf/print_pdf.pages.inc index 50103ec7..be867d01 100644 --- a/sites/all/modules/contrib/admin/print/print_pdf/print_pdf.pages.inc +++ b/sites/all/modules/contrib/admin/print/print_pdf/print_pdf.pages.inc @@ -44,12 +44,12 @@ function print_pdf_controller() { $pdf_filename = variable_get('print_pdf_filename', PRINT_PDF_FILENAME_DEFAULT); if (!empty($pdf_filename) && !empty($node)) { - $pdf_filename = token_replace($pdf_filename, array('node' => $node)); + $pdf_filename = token_replace($pdf_filename, array('node' => $node), array('clear' => TRUE)); } else { - $pdf_filename = token_replace($pdf_filename, array('site')); - if (empty($pdf_filename) || count(token_scan($pdf_filename))) { - // If there are still tokens, use a fallback solution + $pdf_filename = token_replace($pdf_filename, array('site'), array('clear' => TRUE)); + if (empty($pdf_filename)) { + // If empty, use a fallback solution $pdf_filename = str_replace('/', '_', $path); } } @@ -70,7 +70,7 @@ function print_pdf_controller() { exit; } - $nodepath = (isset($node->path) && is_string($node->path)) ? drupal_get_normal_path($node->path) : 'node/' . $path; + $nodepath = (isset($node->nid)) ? 'node/' . $node->nid : drupal_get_normal_path($path); db_merge('print_pdf_page_counter') ->key(array('path' => $nodepath)) ->fields(array( @@ -83,548 +83,98 @@ function print_pdf_controller() { drupal_exit(); } -function print_pdf_generate_path($path, $query = NULL, $cid = NULL, $pdf_filename = NULL) { +/** + * Gennerate a PDF for a given Drupal path. + * + * @param string $path + * path of the page to convert to PDF + * @param array $query + * (optional) array of key/value pairs as used in the url() function for the + * query + * @param int $cid + * (optional) comment ID of the comment to render. + * @param string $pdf_filename + * (optional) filename of the generated PDF + * @param string $view_mode + * (optional) view mode to be used when rendering the content + * + * @return + * generated PDF page, or NULL in case of error + * + * @see print_pdf_controller() + */ +function print_pdf_generate_path($path, $query = NULL, $cid = NULL, $pdf_filename = NULL, $view_mode = PRINT_VIEW_MODE) { global $base_url; - $print = print_controller($path, $query, $cid, PRINT_PDF_FORMAT); - if ($print === FALSE) { - return; - } + $link = print_pdf_print_link(); + $node = print_controller($path, $link['format'], $cid, $view_mode); + if ($node) { + // Call the current tool's hook_pdf_tool_info(), to see if we need to expand CSS + $pdf_tool = explode('|', variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT)); + $cache_enabled = variable_get('print_pdf_cache_enabled', PRINT_PDF_CACHE_ENABLED_DEFAULT); - // Img elements must be set to absolute - $pattern = '!<(img\s[^>]*?)>!is'; - $print['content'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['content']); - $print['logo'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['logo']); - $print['footer_message'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['footer_message']); + $function = $pdf_tool[0] . '_pdf_tool_info'; + if (function_exists($function)) { + $info = $function(); + } + $expand = isset($info['expand_css']) ? $info['expand_css'] : FALSE; - // Send to printer option causes problems with PDF - $print['sendtoprinter'] = ''; + $html = theme('print', array('node' => $node, 'query' => $query, $expand, 'format' => $link['format'])); - $node = $print['node']; - $html = theme('print', array('print' => $print, 'type' => PRINT_PDF_FORMAT, 'node' => $node)); + // Img elements must be set to absolute + $pattern = '!<(img\s[^>]*?)>!is'; + $html = preg_replace_callback($pattern, '_print_rewrite_urls', $html); - // Convert the a href elements, to make sure no relative links remain - $pattern = '!<(a\s[^>]*?)>!is'; - $html = preg_replace_callback($pattern, '_print_rewrite_urls', $html); - // And make anchor links relative again, to permit in-PDF navigation - $html = preg_replace("!${base_url}/" . PRINTPDF_PATH . '/.*?#!', '#', $html); + // Convert the a href elements, to make sure no relative links remain + $pattern = '!<(a\s[^>]*?)>!is'; + $html = preg_replace_callback($pattern, '_print_rewrite_urls', $html); + // And make anchor links relative again, to permit in-PDF navigation + $html = preg_replace("!${base_url}/" . $link['path'] . '/.*?#!', '#', $html); - return print_pdf_generate_html($print, $html, $pdf_filename); -} + $meta = array( + 'node' => $node, + 'url' => url(drupal_get_path_alias(empty($node->nid) ? $node->path : "node/$node->nid"), array('absolute' => TRUE)), + ); + if (isset($node->name)) $meta['name'] = $node->name; + if (isset($node->title)) $meta['title'] = $node->title; -function print_pdf_generate_html($print, $html, $filename = NULL) { - $print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT); + $paper_size = isset($node->print_pdf_size) ? $node->print_pdf_size : NULL; + $page_orientation = isset($node->print_pdf_orientation) ? $node->print_pdf_orientation : NULL; - if (basename($print_pdf_pdf_tool) == 'dompdf_config.inc.php') { - return _print_pdf_dompdf($print, $html, $filename); - } - elseif (basename($print_pdf_pdf_tool) == 'tcpdf.php') { - return _print_pdf_tcpdf($print, $html, $filename); - } - elseif (drupal_substr(basename($print_pdf_pdf_tool, '.exe'), 0, 11) == 'wkhtmltopdf') { - return _print_pdf_wkhtmltopdf($print, $html, $filename); - } - elseif ($filename) { - return drupal_not_found(); - } - return NULL; -} - -/** - * Convert image paths to the file:// protocol - * - * In some Drupal setups, the use of the 'private' filesystem or Apache's - * configuration prevent access to the images of the page. This function - * tries to circumnvent those problems by accessing files in the local - * filesystem. - * - * @param $html - * contents of the post-processed template already with the node data - * @see print_pdf_controller() - */ -function _print_pdf_file_access_images($html) { - global $base_url, $language; - $print_pdf_images_via_file = variable_get('print_pdf_images_via_file', PRINT_PDF_IMAGES_VIA_FILE_DEFAULT); - - $lang = (function_exists('language_negotiation_get_any') && language_negotiation_get_any('locale-url')) ? $language->language : ''; - - // Always convert private to local paths - $pattern = "!(TRUE (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' => ''));
+ }
+ }
+
+ $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;
+}
diff --git a/sites/all/modules/contrib/admin/print/print_ui/print_ui.api.php b/sites/all/modules/contrib/admin/print/print_ui/print_ui.api.php
new file mode 100644
index 00000000..75a6d753
--- /dev/null
+++ b/sites/all/modules/contrib/admin/print/print_ui/print_ui.api.php
@@ -0,0 +1,101 @@
+ '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".
+ */
diff --git a/sites/all/modules/contrib/admin/print/print_ui/print_ui.info b/sites/all/modules/contrib/admin/print/print_ui/print_ui.info
new file mode 100644
index 00000000..77944aeb
--- /dev/null
+++ b/sites/all/modules/contrib/admin/print/print_ui/print_ui.info
@@ -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"
+
diff --git a/sites/all/modules/contrib/admin/print/print_ui/print_ui.install b/sites/all/modules/contrib/admin/print/print_ui/print_ui.install
new file mode 100644
index 00000000..54c1aecc
--- /dev/null
+++ b/sites/all/modules/contrib/admin/print/print_ui/print_ui.install
@@ -0,0 +1,22 @@
+fields(array(
+ 'weight' => 1,
+ ))
+ ->condition('type', 'module')
+ ->condition('name', 'print_ui')
+ ->execute();
+}
diff --git a/sites/all/modules/contrib/admin/print/print_ui/print_ui.module b/sites/all/modules/contrib/admin/print/print_ui/print_ui.module
new file mode 100644
index 00000000..3affdb3c
--- /dev/null
+++ b/sites/all/modules/contrib/admin/print/print_ui/print_ui.module
@@ -0,0 +1,770 @@
+ 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 "$links";
+ }
+ }
+ }
+}
+
+/**
+ * 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' => '',
+ '#markup' => $corner_markup,
+ '#suffix' => '',
+ '#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 '' . l($format['text'], $path, array('attributes' => $format['attributes'], 'query' => $query, 'absolute' => TRUE, 'html' => $format['html'])) . '';
+ }
+ 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;
+}
diff --git a/sites/all/modules/contrib/admin/print/tests/print_basic.test b/sites/all/modules/contrib/admin/print/tests/print_basic.test
index 795cca51..03068384 100644
--- a/sites/all/modules/contrib/admin/print/tests/print_basic.test
+++ b/sites/all/modules/contrib/admin/print/tests/print_basic.test
@@ -53,7 +53,7 @@ class PrintBasicTest extends DrupalWebTestCase {
global $base_url, $base_root, $_print_urls;
// Must require it, since this function gets called via Drupal's dynamic loading
- require_once(DRUPAL_ROOT . '/' . drupal_get_path('module', 'print') . '/print.pages.inc');
+ module_load_include('inc', 'print', 'print.pages');
variable_set('print_urls_anchors', 1);
diff --git a/sites/all/modules/contrib/admin/rules_link/rules_link.admin.inc b/sites/all/modules/contrib/admin/rules_link/rules_link.admin.inc
index 2a09f2f4..a1112eda 100644
--- a/sites/all/modules/contrib/admin/rules_link/rules_link.admin.inc
+++ b/sites/all/modules/contrib/admin/rules_link/rules_link.admin.inc
@@ -411,7 +411,7 @@ function rules_link_form_submit(&$form, &$form_state) {
/**
* Form function for the rules link components.
*/
-function rules_link_component_form($form, $form_state, $entity_type, $rules_link) {
+function rules_link_component_form($form, &$form_state, $entity_type, $rules_link) {
$form = array();
$form_state['rules_link'] = $rules_link;
@@ -428,10 +428,16 @@ function rules_link_component_form($form, $form_state, $entity_type, $rules_link
unset($form['condition_set']['negate']);
$form['condition_set']['#tree'] = TRUE;
-
$rule_set = rules_link_load_rules_set($rules_link);
$rule_set->form($form['rule_set'], $form_state, array('show settings' => TRUE));
+ // Correct the state setup - default ruleset form doesn't expect this structure
+ $form['rule_set']['settings']['access']['permissions']['#states'] = array(
+ 'visible' => array(
+ ':input[name="rule_set[settings][access][access_exposed]"]' => array('checked' => TRUE),
+ ),
+ );
+
$form['rule_set']['elements']['#caption'] = '';
$form['rule_set']['#tree'] = TRUE;
@@ -492,6 +498,14 @@ function rules_link_component_form_submit(&$form, &$form_state) {
$form_state['rules_link_rules_set']->save(rules_link_get_rules_set_name($form_state['rules_link']), 'rules_link');
}
+ // Save the permission matrix if access is exposed
+ if (isset($form_state['values']['rule_set']['settings']['access']) && !empty($form_state['values']['rule_set']['settings']['access']['access_exposed'])) {
+ // Save the permission matrix.
+ foreach ($form_state['values']['rule_set']['settings']['access']['permissions']['matrix']['checkboxes'] as $rid => $value) {
+ user_role_change_permissions($rid, $value);
+ }
+ }
+
// If an additional variable was added, then disable 'show link in entity'.
if (count($rules_set_vars) > 1) {
$form_state['rules_link']->settings['entity_link'] = FALSE;
diff --git a/sites/all/modules/contrib/admin/rules_link/rules_link.info b/sites/all/modules/contrib/admin/rules_link/rules_link.info
index f5be5775..c9c9803f 100644
--- a/sites/all/modules/contrib/admin/rules_link/rules_link.info
+++ b/sites/all/modules/contrib/admin/rules_link/rules_link.info
@@ -8,9 +8,9 @@ files[] = rules_link.views.inc
files[] = rules_link.admin.inc
files[] = rules_link.test
-; Information added by drupal.org packaging script on 2013-10-01
-version = "7.x-1.0-beta5+0-dev"
+; Information added by Drupal.org packaging script on 2014-08-27
+version = "7.x-1.1"
core = "7.x"
project = "rules_link"
-datestamp = "1380626278"
+datestamp = "1409148229"
diff --git a/sites/all/modules/contrib/admin/rules_link/rules_link.module b/sites/all/modules/contrib/admin/rules_link/rules_link.module
index 87596a76..ca631f5c 100644
--- a/sites/all/modules/contrib/admin/rules_link/rules_link.module
+++ b/sites/all/modules/contrib/admin/rules_link/rules_link.module
@@ -282,14 +282,14 @@ function rules_link_rules_link_delete($link) {
function rules_link_get_token($content_id) {
// Anonymous users get a less secure token, since it must be the same for all
// anonymous users on the entire site to work with page caching.
- return ($GLOBALS['user']->uid) ? drupal_get_token($content_id) : md5(drupal_get_private_key() . $content_id);
+ return ($GLOBALS['user']->uid) ? drupal_get_token($content_id) : drupal_hmac_base64($content_id, drupal_get_private_key() . drupal_get_hash_salt());
}
/**
* Checks if the given token is correct.
*/
function rules_link_check_token($token, $content_id) {
- return rules_link_get_token($content_id) == $token;
+ return rules_link_get_token($content_id) === $token;
}
function rules_link_get_paramters($rules_link) {
@@ -351,7 +351,7 @@ function rules_link_trigger_form($form, &$form_state, $rules_link, $entity_id) {
'#type' => 'hidden',
'#value' => $entity_id,
);
- return confirm_form($form, $rules_link->getSettingTranslation('confirm_question'), '', $rules_link->getSettingTranslation('confirm_description'));
+ return confirm_form($form, filter_xss_admin($rules_link->getSettingTranslation('confirm_question')), '', filter_xss_admin($rules_link->getSettingTranslation('confirm_description')));
}
/**
@@ -470,7 +470,6 @@ function template_preprocess_rules_link(&$variables) {
}
$variables['href'] = check_plain(url($variables['href'], $variables['options']));
- $variables['title'] = check_plain($variables['title']);
$variables['attr'] = drupal_attributes($variables['attr']);
}
diff --git a/sites/all/modules/contrib/admin/rules_link/rules_link_i18n.info b/sites/all/modules/contrib/admin/rules_link/rules_link_i18n.info
index d57f8050..ef1f937d 100644
--- a/sites/all/modules/contrib/admin/rules_link/rules_link_i18n.info
+++ b/sites/all/modules/contrib/admin/rules_link/rules_link_i18n.info
@@ -5,9 +5,9 @@ dependencies[] = i18n_string
package = Multilingual - Internationalization
core = 7.x
-; Information added by drupal.org packaging script on 2013-10-01
-version = "7.x-1.0-beta5+0-dev"
+; Information added by Drupal.org packaging script on 2014-08-27
+version = "7.x-1.1"
core = "7.x"
project = "rules_link"
-datestamp = "1380626278"
+datestamp = "1409148229"
diff --git a/sites/all/modules/contrib/dev/ctools/API.txt b/sites/all/modules/contrib/dev/ctools/API.txt
index e0441d62..b698b798 100644
--- a/sites/all/modules/contrib/dev/ctools/API.txt
+++ b/sites/all/modules/contrib/dev/ctools/API.txt
@@ -3,6 +3,9 @@ Current API Version: 2.0.8
Please note that the API version is an internal number and does not match release numbers. It is entirely possible that releases will not increase the API version number, and increasing this number too often would burden contrib module maintainers who need to keep up with API changes.
This file contains a log of changes to the API.
+API Version 2.0.9
+Changed import permissions to use the new 'use ctools import' permission.
+
API Version 2.0.8
Introduce ctools_class_add().
Introduce ctools_class_remove().
diff --git a/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.info b/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.info
index d27ea9ab..fd355450 100644
--- a/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.info
+++ b/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.info
@@ -3,10 +3,12 @@ description = Performs bulk exporting of data objects known about by Chaos tools
core = 7.x
dependencies[] = ctools
package = Chaos tool suite
+version = CTOOLS_MODULE_VERSION
-; Information added by drupal.org packaging script on 2013-04-03
-version = "7.x-1.3"
+
+; Information added by Drupal.org packaging script on 2015-03-18
+version = "7.x-1.7"
core = "7.x"
project = "ctools"
-datestamp = "1365013512"
+datestamp = "1426696183"
diff --git a/sites/all/modules/contrib/dev/ctools/css/modal.css b/sites/all/modules/contrib/dev/ctools/css/modal.css
index d9f44e26..def374be 100644
--- a/sites/all/modules/contrib/dev/ctools/css/modal.css
+++ b/sites/all/modules/contrib/dev/ctools/css/modal.css
@@ -89,6 +89,10 @@ div.ctools-modal-content .form-checkboxes {
clear: left;
}
+div.ctools-modal-content .vertical-tabs-panes > fieldset {
+ clear: none;
+}
+
div.ctools-modal-content .resizable-textarea {
width: auto;
margin-left: 15em;
diff --git a/sites/all/modules/contrib/dev/ctools/ctools.info b/sites/all/modules/contrib/dev/ctools/ctools.info
index 8a7b0b60..3283454b 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools.info
+++ b/sites/all/modules/contrib/dev/ctools/ctools.info
@@ -2,13 +2,16 @@ name = Chaos tools
description = A library of helpful tools by Merlin of Chaos.
core = 7.x
package = Chaos tool suite
+version = CTOOLS_MODULE_VERSION
files[] = includes/context.inc
+files[] = includes/css-cache.inc
files[] = includes/math-expr.inc
files[] = includes/stylizer.inc
+files[] = tests/css_cache.test
-; Information added by drupal.org packaging script on 2013-04-03
-version = "7.x-1.3"
+; Information added by Drupal.org packaging script on 2015-03-18
+version = "7.x-1.7"
core = "7.x"
project = "ctools"
-datestamp = "1365013512"
+datestamp = "1426696183"
diff --git a/sites/all/modules/contrib/dev/ctools/ctools.install b/sites/all/modules/contrib/dev/ctools/ctools.install
index 1f961f15..e96c7432 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools.install
+++ b/sites/all/modules/contrib/dev/ctools/ctools.install
@@ -37,10 +37,22 @@ function ctools_requirements($phase) {
}
/**
- * Implements hook_schemea
+ * Implements hook_schema().
*/
function ctools_schema() {
- return ctools_schema_2();
+ return ctools_schema_3();
+}
+
+/**
+ * Version 3 of the CTools schema.
+ */
+function ctools_schema_3() {
+ $schema = ctools_schema_2();
+
+ // update the 'obj' field to be 128 bytes long:
+ $schema['ctools_object_cache']['fields']['obj']['length'] = 128;
+
+ return $schema;
}
/**
@@ -141,6 +153,21 @@ function ctools_schema_1() {
return $schema;
}
+/**
+ * Implements hook_install().
+ */
+function ctools_install() {
+ // Activate our custom cache handler for the CSS cache.
+ variable_set('cache_class_cache_ctools_css', 'CToolsCssCache');
+}
+
+/**
+ * Implements hook_uninstall().
+ */
+function ctools_uninstall() {
+ variable_del('cache_class_cache_ctools_css');
+}
+
/**
* Enlarge the ctools_object_cache.name column to prevent truncation and weird
* errors.
@@ -217,3 +244,22 @@ function ctools_update_6008() {
)
);
}
+
+/**
+ * Enable the custom CSS cache handler.
+ */
+function ctools_update_7000() {
+ variable_set('cache_class_cache_ctools_css', 'CToolsCssCache');
+}
+
+/**
+ * Increase the length of the ctools_object_cache.obj column.
+ */
+function ctools_update_7001() {
+ db_change_field('ctools_object_cache', 'obj', 'obj', array(
+ 'type' => 'varchar',
+ 'length' => '128',
+ 'not null' => TRUE,
+ 'description' => 'The type of the object this cache is attached to; this essentially represents the owner so that several sub-systems can use this cache.',
+ ));
+}
diff --git a/sites/all/modules/contrib/dev/ctools/ctools.module b/sites/all/modules/contrib/dev/ctools/ctools.module
index f014e74d..3e8cc88f 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools.module
+++ b/sites/all/modules/contrib/dev/ctools/ctools.module
@@ -9,7 +9,21 @@
* must be implemented in the module file.
*/
-define('CTOOLS_API_VERSION', '2.0.7');
+define('CTOOLS_API_VERSION', '2.0.8');
+
+/**
+ * The current working ctools version.
+ *
+ * In a release, it should be 7.x-1.x, which should match what drush make will
+ * create. In a dev format, it should be 7.x-1.(x+1)-dev, which will allow
+ * modules depending on new features in ctools to depend on ctools > 7.x-1.x.
+ *
+ * To define a specific version of CTools as a dependency for another module,
+ * simply include a dependency line in that module's info file, e.g.:
+ * ; Requires CTools v7.x-1.4 or newer.
+ * dependencies[] = ctools (>=1.4)
+ */
+define('CTOOLS_MODULE_VERSION', '7.x-1.7');
/**
* Test the CTools API version.
@@ -298,7 +312,7 @@ function ctools_break_phrase($str) {
/**
* Set a token/value pair to be replaced later in the request, specifically in
- * ctools_preprocess_page().
+ * ctools_page_token_processing().
*
* @param $token
* The token to be replaced later, during page rendering. This should
@@ -367,6 +381,59 @@ function ctools_set_no_blocks($blocks = FALSE) {
$status = $blocks;
}
+/**
+ * Wrapper function to create UUIDs via ctools, falls back on UUID module
+ * if it is enabled. This code is a copy of uuid.inc from the uuid module.
+ * @see http://php.net/uniqid#65879
+ */
+
+function ctools_uuid_generate() {
+ if (!module_exists('uuid')) {
+ ctools_include('uuid');
+
+ $callback = drupal_static(__FUNCTION__);
+
+ if (empty($callback)) {
+ if (function_exists('uuid_create') && !function_exists('uuid_make')) {
+ $callback = '_ctools_uuid_generate_pecl';
+ }
+ elseif (function_exists('com_create_guid')) {
+ $callback = '_ctools_uuid_generate_com';
+ }
+ else {
+ $callback = '_ctools_uuid_generate_php';
+ }
+ }
+ return $callback();
+ }
+ else {
+ return uuid_generate();
+ }
+}
+
+/**
+ * Check that a string appears to be in the format of a UUID.
+ * @see http://drupal.org/project/uuid
+ *
+ * @param $uuid
+ * The string to test.
+ *
+ * @return
+ * TRUE if the string is well formed.
+ */
+function ctools_uuid_is_valid($uuid = '') {
+ if (empty($uuid)) {
+ return FALSE;
+ }
+ if (function_exists('uuid_is_valid') || module_exists('uuid')) {
+ return uuid_is_valid($uuid);
+ }
+ else {
+ ctools_include('uuid');
+ return uuid_is_valid($uuid);
+ }
+}
+
/**
* Add an array of classes to the body.
*
@@ -483,6 +550,19 @@ function ctools_menu() {
return $items;
}
+/**
+ * Implements hook_permission().
+ */
+function ctools_permission() {
+ return array(
+ 'use ctools import' => array(
+ 'title' => t('Use CTools importer'),
+ 'description' => t('The import functionality allows users to execute arbitrary PHP code, so extreme caution must be taken.'),
+ 'restrict access' => TRUE,
+ ),
+ );
+}
+
/**
* Implementation of hook_cron. Clean up old caches.
*/
@@ -493,19 +573,12 @@ function ctools_cron() {
}
/**
- * Ensure the CTools CSS cache is flushed whenever hook_flush_caches is invoked.
+ * Implements hook_flush_caches().
*/
function ctools_flush_caches() {
- // Do not actually flush caches if running on cron. Drupal uses this hook
- // in an inconsistent fashion and it does not necessarily mean to *flush*
- // caches when running from cron. Instead it's just getting a list of cache
- // tables and may not do any flushing.
- if (!empty($GLOBALS['locks']['cron'])) {
- return;
- }
-
- ctools_include('css');
- ctools_css_flush_caches();
+ // Only return the CSS cache bin if it has been activated, to avoid
+ // drupal_flush_all_caches() from trying to truncate a non-existing table.
+ return variable_get('cache_class_cache_ctools_css', FALSE) ? array('cache_ctools_css') : array();
}
/**
@@ -585,7 +658,26 @@ function ctools_preprocess_node(&$vars) {
}
}
+
+/**
+ * Implements hook_page_alter().
+ *
+ * Last ditch attempt to remove sidebar regions if the "no blocks"
+ * functionality has been activated.
+ *
+ * @see ctools_block_list_alter().
+ */
function ctools_page_alter(&$page) {
+ $check = drupal_static('ctools_set_no_blocks', TRUE);
+ if (!$check) {
+ foreach ($page as $region_id => $region) {
+ // @todo -- possibly we can set configuration for this so that users can
+ // specify which blocks will not get rendered.
+ if (strpos($region_id, 'sidebar') !== FALSE) {
+ unset($page[$region_id]);
+ }
+ }
+ }
$page['#post_render'][] = 'ctools_page_token_processing';
}
@@ -601,15 +693,15 @@ function ctools_page_token_processing($children, $elements) {
list($type, $argument) = $key;
switch ($type) {
case 'variable':
- $tokens[$token] = isset($variables[$argument]) ? $variables[$argument] : '';
+ $tokens[$token] = isset($elements[$argument]) ? $elements[$argument] : '';
break;
case 'callback':
if (is_string($argument) && function_exists($argument)) {
- $tokens[$token] = $argument($variables);
+ $tokens[$token] = $argument($elements);
}
if (is_array($argument) && function_exists($argument[0])) {
$function = array_shift($argument);
- $argument = array_merge(array(&$variables), $argument);
+ $argument = array_merge(array(&$elements), $argument);
$tokens[$token] = call_user_func_array($function, $argument);
}
break;
@@ -733,6 +825,15 @@ function ctools_js_load($js) {
return 0;
}
+/**
+ * Provides the default value for %ctools_js.
+ *
+ * This allows drupal_valid_path() to work with %ctools_js.
+ */
+function ctools_js_to_arg($arg) {
+ return empty($arg) || $arg == '%' ? 'nojs' : $arg;
+}
+
/**
* Menu _load hook.
*
@@ -852,11 +953,25 @@ function ctools_block_list_alter(&$blocks) {
}
/**
- * Implement hook_modules_enabled to clear static caches for detecting new plugins
+ * Implements hook_modules_enabled().
+ *
+ * Clear caches for detecting new plugins.
*/
function ctools_modules_enabled($modules) {
ctools_include('plugins');
ctools_get_plugins_reset();
+ cache_clear_all('ctools_plugin_files:', 'cache', TRUE);
+}
+
+/**
+ * Implements hook_modules_disabled().
+ *
+ * Clear caches for removing disabled plugins.
+ */
+function ctools_modules_disabled($modules) {
+ ctools_include('plugins');
+ ctools_get_plugins_reset();
+ cache_clear_all('ctools_plugin_files:', 'cache', TRUE);
}
/**
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.info b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.info
index 10192538..d7ec175d 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.info
+++ b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.info
@@ -2,11 +2,12 @@ name = Custom rulesets
description = Create custom, exportable, reusable access rulesets for applications like Panels.
core = 7.x
package = Chaos tool suite
+version = CTOOLS_MODULE_VERSION
dependencies[] = ctools
-; Information added by drupal.org packaging script on 2013-04-03
-version = "7.x-1.3"
+; Information added by Drupal.org packaging script on 2015-03-18
+version = "7.x-1.7"
core = "7.x"
project = "ctools"
-datestamp = "1365013512"
+datestamp = "1426696183"
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.info b/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.info
index 03ccb341..bc1a213d 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.info
+++ b/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.info
@@ -1,12 +1,13 @@
name = Chaos Tools (CTools) AJAX Example
description = Shows how to use the power of Chaos AJAX.
package = Chaos tool suite
+version = CTOOLS_MODULE_VERSION
dependencies[] = ctools
core = 7.x
-; Information added by drupal.org packaging script on 2013-04-03
-version = "7.x-1.3"
+; Information added by Drupal.org packaging script on 2015-03-18
+version = "7.x-1.7"
core = "7.x"
project = "ctools"
-datestamp = "1365013512"
+datestamp = "1426696183"
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.info b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.info
index d9c45673..2b2d04bb 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.info
+++ b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.info
@@ -2,11 +2,12 @@ name = Custom content panes
description = Create custom, exportable, reusable content panes for applications like Panels.
core = 7.x
package = Chaos tool suite
+version = CTOOLS_MODULE_VERSION
dependencies[] = ctools
-; Information added by drupal.org packaging script on 2013-04-03
-version = "7.x-1.3"
+; Information added by Drupal.org packaging script on 2015-03-18
+version = "7.x-1.7"
core = "7.x"
project = "ctools"
-datestamp = "1365013512"
+datestamp = "1426696183"
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.module b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.module
index a2e8ee24..3e316a91 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.module
+++ b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.module
@@ -36,6 +36,26 @@ function ctools_custom_content_ctools_plugin_directory($module, $plugin) {
}
}
+/**
+ * Implements hook_get_pane_links_alter().
+ */
+function ctools_custom_content_get_pane_links_alter(&$links, $pane, $content_type) {
+ if ($pane->type == 'custom') {
+ if(!isset($pane->configuration['name'])) {
+ $name_of_pane = $pane->subtype;
+ }
+ else {
+ $name_of_pane = $pane->configuration['name'];
+ }
+
+ $links['top']['edit_custom_content'] = array(
+ 'title' => t('Edit custom content pane'),
+ 'href' => url('admin/structure/ctools-content/list/' . $name_of_pane . '/edit', array('absolute' => TRUE)),
+ 'attributes' => array('target' => array('_blank')),
+ );
+ }
+}
+
/**
* Create callback for creating a new CTools custom content type.
*
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.info b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.info
index e4fa5343..f9158762 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.info
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.info
@@ -1,15 +1,16 @@
name = Chaos Tools (CTools) Plugin Example
description = Shows how an external module can provide ctools plugins (for Panels, etc.).
package = Chaos tool suite
+version = CTOOLS_MODULE_VERSION
dependencies[] = ctools
dependencies[] = panels
dependencies[] = page_manager
dependencies[] = advanced_help
core = 7.x
-; Information added by drupal.org packaging script on 2013-04-03
-version = "7.x-1.3"
+; Information added by Drupal.org packaging script on 2015-03-18
+version = "7.x-1.7"
core = "7.x"
project = "ctools"
-datestamp = "1365013512"
+datestamp = "1426696183"
diff --git a/sites/all/modules/contrib/dev/ctools/help/context-content.html b/sites/all/modules/contrib/dev/ctools/help/context-content.html
index 8af5df43..c1c6a356 100644
--- a/sites/all/modules/contrib/dev/ctools/help/context-content.html
+++ b/sites/all/modules/contrib/dev/ctools/help/context-content.html
@@ -116,6 +116,10 @@ The first form will always have required configuration added to it. These forms