security updates
have to check views and entityreference for custom patches
This commit is contained in:
@@ -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().
|
||||
|
@@ -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"
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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"
|
||||
|
||||
|
@@ -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.',
|
||||
));
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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"
|
||||
|
||||
|
@@ -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"
|
||||
|
||||
|
@@ -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"
|
||||
|
||||
|
@@ -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.
|
||||
*
|
||||
|
@@ -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"
|
||||
|
||||
|
@@ -116,6 +116,10 @@ The first form will always have required configuration added to it. These forms
|
||||
<dt>required context [Optional]</dt>
|
||||
|
||||
<dd>Either a ctools_context_required or ctools_context_optional or array of contexts for this content. If omitted, no contexts are used.</dd>
|
||||
|
||||
<dt>create content access [Optional]</dt>
|
||||
|
||||
<dd>An optional callback to determine if a user can access this subtype. The callback will receive two arguments, the type and subtype.</dd>
|
||||
</dl>
|
||||
|
||||
<h2>Rendered content</h2>
|
||||
|
@@ -156,6 +156,9 @@ function mymodule_schema() {
|
||||
<dt>to hook code callback</dt>
|
||||
<dd>Function used to generate an export for the bulk export process. This is only necessary if the export is more complicated than simply listing the fields. Defaults to $module . '_' . $table . '_to_hook_code'.</dt>
|
||||
|
||||
<dt>boolean</dt>
|
||||
<dd>Explicitly indicate if a table field contains a boolean or not. The Schema API does not model the
|
||||
difference between a tinyint and a boolean type. Boolean values are stored in tinyint fields. This may cause mismatch errors when exporting a non-boolean value from a tinyint field. Add this to a tinyint field if it contains boolean data and can be exported. Defaults to TRUE.
|
||||
|
||||
<dt>create callback</dt>
|
||||
<dd>CRUD callback to use to create a new exportable item in memory. If not provided, the default function will be used. The single argument is a boolean used to determine if defaults should be set on the object. This object will not be written to the database by this callback.</dd>
|
||||
|
@@ -24,6 +24,17 @@ The following information can be specified for each plugin type:
|
||||
<dt>cache table</dt>
|
||||
<dd><em>Defaults to:</em> <strong>'cache'</strong></dd>
|
||||
<dd>If 'cache' is TRUE, then this value specifies the cache table where the cached plugin information will be stored.</dd>
|
||||
<dt>classes</dt>
|
||||
<dd><em>Defaults to:</em> <strong>array()</strong></dd>
|
||||
<dd>An array of <em>class identifiers</em>(i.e. plugin array keys) which a plugin of this type uses to provide classes to the CTools autoloader. For example, if <strong>classes</strong> is set to array('class'), then CTools will search each <strong>$plugin['class']</strong> for a class to autoload. Depending of the plugin structure, a <em>class identifier</em> may be either:</dd>
|
||||
<dl>
|
||||
<dt>- a file name:</dt>
|
||||
<dd>the file which holds the class with the name structure as: <em>[filename].[class].php</em></dd>
|
||||
<dd>in this case the class name can be different than the <em>class identifier</em></dd>
|
||||
<dt>- the class name:</dt>
|
||||
<dd>if the class is in the same file as the $plugin</dd>
|
||||
<dd>the plugin <em>.inc</em> file can have a different name than the <em>class identifier</em></dd>
|
||||
</dl>
|
||||
<dt>defaults</dt>
|
||||
<dd><em>Defaults to:</em> <strong>array()</strong></dd>
|
||||
<dd>An array of defaults that should be added to each plugin; this can be used to ensure that every plugin has the basic data necessary. These defaults will not ovewrite data supplied by the plugin. This could also be a function name, in which case the callback will be used to provide defaults. NOTE, however, that the callback-based approach is deprecated as it is redundant with the 'process' callback, and as such will be removed in later versions. Consequently, you should only use the array form for maximum cross-version compatibility.</dd>
|
||||
|
@@ -49,6 +49,34 @@ function ctools_ajax_text_button($text, $dest, $alt, $class = '', $type = 'use-a
|
||||
return l($text, $dest, array('html' => TRUE, 'attributes' => array('class' => array($type, $class), 'title' => $alt)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an icon and related text as a link. This will automatically apply an AJAX class
|
||||
* to the link and add the appropriate javascript to make this happen.
|
||||
*
|
||||
* Note: 'html' => true so be sure any text is vetted! Chances are these kinds of buttons will
|
||||
* not use user input so this is a very minor concern.
|
||||
*
|
||||
* @param $text
|
||||
* The text that will be displayed as the link.
|
||||
* @param $image
|
||||
* The icon image to include in the link.
|
||||
* @param $dest
|
||||
* The destination of the link.
|
||||
* @param $alt
|
||||
* The title text of the link.
|
||||
* @param $class
|
||||
* Any class to apply to the link. @todo this should be a options array.
|
||||
* @param $type
|
||||
* A type to use, in case a different behavior should be attached. Defaults
|
||||
* to ctools-use-ajax.
|
||||
*/
|
||||
function ctools_ajax_icon_text_button($text, $image, $dest, $alt, $class = '', $type = 'use-ajax') {
|
||||
drupal_add_library('system', 'drupal.ajax');
|
||||
$rendered_image = theme('image', array('path' => $image));
|
||||
$link_content = $rendered_image . "<span>" . $text . "</span>";
|
||||
return l($link_content, $dest, array('html' => TRUE, 'attributes' => array('class' => array($type, $class), 'title' => $alt)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a single property to a value, on all matched elements.
|
||||
*
|
||||
|
@@ -244,6 +244,7 @@ function ctools_content_prepare_subtype(&$subtype, $plugin) {
|
||||
* The content as rendered by the plugin. This content should be an array
|
||||
* with the following possible keys:
|
||||
* - title: The safe to render title of the content.
|
||||
* - title_heading: The title heading.
|
||||
* - content: The safe to render HTML content.
|
||||
* - links: An array of links associated with the content suitable for
|
||||
* theme('links').
|
||||
@@ -299,6 +300,7 @@ function ctools_content_render($type, $subtype, $conf, $keywords = array(), $arg
|
||||
$keywords['%title'] = empty($content->title) ? '' : $content->title;
|
||||
$content->original_title = $keywords['%title'];
|
||||
$content->title = $conf['override_title_text'];
|
||||
$content->title_heading = isset($conf['override_title_heading']) ? $conf['override_title_heading'] : 'h2';
|
||||
}
|
||||
|
||||
if (!empty($content->title)) {
|
||||
@@ -504,8 +506,26 @@ function ctools_content_configure_form_defaults($form, &$form_state) {
|
||||
'#size' => 35,
|
||||
'#id' => 'override-title-textfield',
|
||||
'#dependency' => array('override-title-checkbox' => array(1)),
|
||||
'#dependency_type' => 'disable',
|
||||
'#dependency_type' => 'hidden',
|
||||
);
|
||||
$form['override_title_heading'] = array(
|
||||
'#type' => 'select',
|
||||
'#default_value' => isset($conf['override_title_heading']) ? $conf['override_title_heading'] : 'h2',
|
||||
'#options' => array(
|
||||
'h1' => t('h1'),
|
||||
'h2' => t('h2'),
|
||||
'h3' => t('h3'),
|
||||
'h4' => t('h4'),
|
||||
'h5' => t('h5'),
|
||||
'h6' => t('h6'),
|
||||
'div' => t('div'),
|
||||
'span' => t('span'),
|
||||
),
|
||||
'#id' => 'override-title-heading',
|
||||
'#dependency' => array('override-title-checkbox' => array(1)),
|
||||
'#dependency_type' => 'hidden',
|
||||
);
|
||||
|
||||
$form['aligner_stop'] = array(
|
||||
'#markup' => '</div>',
|
||||
);
|
||||
@@ -536,6 +556,7 @@ function ctools_content_configure_form_defaults_submit(&$form, &$form_state) {
|
||||
if (isset($form_state['values']['override_title'])) {
|
||||
$form_state['conf']['override_title'] = $form_state['values']['override_title'];
|
||||
$form_state['conf']['override_title_text'] = $form_state['values']['override_title_text'];
|
||||
$form_state['conf']['override_title_heading'] = $form_state['values']['override_title_heading'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -687,6 +708,11 @@ function ctools_content_get_available_types($contexts = NULL, $has_content = FAL
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the content type provides an access callback.
|
||||
if (isset($subtype['create content access']) && function_exists($subtype['create content access']) && !$subtype['create content access']($plugin, $subtype)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If we made it through all the tests, then we can use this content.
|
||||
$available[$id][$subtype_id] = $subtype;
|
||||
}
|
||||
|
@@ -23,68 +23,157 @@ function ctools_content_menu(&$items) {
|
||||
/**
|
||||
* Helper function for autocompletion of entity titles.
|
||||
*/
|
||||
function ctools_content_autocomplete_entity($type, $string = '') {
|
||||
$entity = entity_get_info($type);
|
||||
function ctools_content_autocomplete_entity($entity_type, $string = '') {
|
||||
if ($string != '') {
|
||||
// @todo verify the query logic here, it's untested.
|
||||
// Set up the query
|
||||
$query = db_select($entity['base table'], 'b');
|
||||
if ($entity['entity keys']['label']) {
|
||||
$query->fields('b', array($entity['entity keys']['id'], $entity['entity keys']['label']))->range(0, 10);
|
||||
}
|
||||
else {
|
||||
$query->fields('b', array($entity['entity keys']['id']))->range(0, 10);
|
||||
$entity_info = entity_get_info($entity_type);
|
||||
|
||||
if (!module_exists('entity')) {
|
||||
module_load_include('inc', 'ctools', 'includes/entity-access');
|
||||
_ctools_entity_access($entity_info, $entity_type);
|
||||
}
|
||||
|
||||
// We must query all ids, because if every one of the 10 don't have access
|
||||
// the user may never be able to autocomplete a node title.
|
||||
$preg_matches = array();
|
||||
$matches = array();
|
||||
$match = preg_match('/\[id: (\d+)\]/', $string, $preg_matches);
|
||||
if (!$match) {
|
||||
$match = preg_match('/^id: (\d+)/', $string, $preg_matches);
|
||||
}
|
||||
// If an ID match was found, use that ID rather than the whole string.
|
||||
if ($match) {
|
||||
$query->condition('b.' . $entity['entity keys']['id'], $preg_matches[1]);
|
||||
}
|
||||
elseif ($entity['entity keys']['label']) {
|
||||
$query->condition('b.' . $entity['entity keys']['label'], '%' . db_like($string) . '%', 'LIKE');
|
||||
}
|
||||
|
||||
$matches = array();
|
||||
if ($type == 'node') {
|
||||
if (!user_access('bypass node access')) {
|
||||
// If the user is able to view their own unpublished nodes, allow them
|
||||
// to see these in addition to published nodes.
|
||||
if (user_access('view own unpublished content')) {
|
||||
$query->condition(db_or()
|
||||
->condition('b.status', NODE_PUBLISHED)
|
||||
->condition('b.uid', $GLOBALS['user']->uid)
|
||||
);
|
||||
}
|
||||
else {
|
||||
// If not, restrict the query to published nodes.
|
||||
$query->condition('b.status', NODE_PUBLISHED);
|
||||
}
|
||||
}
|
||||
|
||||
$query->addTag('node_access');
|
||||
$query->join('users', 'u', 'b.uid = u.uid');
|
||||
$query->addField('u', 'name', 'name');
|
||||
|
||||
foreach ($query->execute() as $nodeish) {
|
||||
$name = empty($nodeish->name) ? variable_get('anonymous', t('Anonymous')) : check_plain($nodeish->name);
|
||||
$matches[$nodeish->title . " [id: $nodeish->nid]"] = '<span class="autocomplete_title">' . check_plain($nodeish->title) . '</span> <span class="autocomplete_user">(' . t('by @user', array('@user' => $name)) . ')</span>';
|
||||
}
|
||||
$entity_id = $preg_matches[1];
|
||||
$results = _ctools_getReferencableEntities($entity_type, $entity_info, $entity_id, '=', 1);
|
||||
}
|
||||
else {
|
||||
foreach ($query->execute() as $item) {
|
||||
$id = $item->{$entity['entity keys']['id']};
|
||||
if ($entity['entity keys']['label']) {
|
||||
$matches[$item->{$entity['entity keys']['label']} . " [id: $id]"] = '<span class="autocomplete_title">' . check_plain($item->{$entity['entity keys']['label']}) . '</span>';
|
||||
}
|
||||
else {
|
||||
$matches["[id: $id]"] = '<span class="autocomplete_title">' . check_plain($item->{$entity['entity keys']['id']}) . '</span>';
|
||||
}
|
||||
// We cannot find results if the entity doesn't have a label to search.
|
||||
if (!isset($entity_info['entity keys']['label'])) {
|
||||
drupal_json_output(array("[id: NULL]" => '<span class="autocomplete_title">' . t('Entity Type !entity_type does not support autocomplete search.', array('!entity_type' => $entity_type)) . '</span>'));
|
||||
return;
|
||||
}
|
||||
$results = _ctools_getReferencableEntities($entity_type, $entity_info, $string, 'LIKE', 10);
|
||||
}
|
||||
foreach ($results as $entity_id => $result) {
|
||||
$matches[$result['label'] . " [id: $entity_id]"] = '<span class="autocomplete_title">' . check_plain($result['label']) . '</span>';
|
||||
$matches[$result['label'] . " [id: $entity_id]"] .= isset($result['bundle']) ? ' <span class="autocomplete_bundle">(' . check_plain($result['bundle']) . ')</span>' : '';
|
||||
}
|
||||
|
||||
drupal_json_output($matches);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Use well known/tested entity reference code to build our search query
|
||||
* From EntityReference_SelectionHandler_Generic class
|
||||
*/
|
||||
function _ctools_buildQuery($entity_type, $entity_info, $match = NULL, $match_operator = 'CONTAINS') {
|
||||
$base_table = $entity_info['base table'];
|
||||
$label_key = $entity_info['entity keys']['label'];
|
||||
$query = db_select($base_table)
|
||||
->fields($base_table, array($entity_info['entity keys']['id']));
|
||||
|
||||
if (isset($match)) {
|
||||
if (isset($label_key)) {
|
||||
$query->condition($base_table . '.' . $label_key, '%' . $match . '%', $match_operator);
|
||||
}
|
||||
// This should never happen, but double check just in case.
|
||||
else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
// Add a generic entity access tag to the query.
|
||||
$query->addTag('ctools');
|
||||
|
||||
// We have to perform two checks. First check is a query alter (with tags)
|
||||
// in an attempt to only return results that have access. However, this is
|
||||
// not full-proof since entities many not implement hook_access query tag.
|
||||
// This is why we have a second check after entity load, before we display
|
||||
// the label of an entity.
|
||||
if ($entity_type == 'comment') {
|
||||
// Adding the 'comment_access' tag is sadly insufficient for comments: core
|
||||
// requires us to also know about the concept of 'published' and
|
||||
// 'unpublished'.
|
||||
if (!user_access('administer comments')) {
|
||||
$query->condition('comment.status', COMMENT_PUBLISHED);
|
||||
}
|
||||
|
||||
// Join to a node if the user does not have node access bypass permissions
|
||||
// to obey node published permissions
|
||||
if (!user_access('bypass node access')) {
|
||||
$node_alias = $query->innerJoin('node', 'n', '%alias.nid = comment.nid');
|
||||
$query->condition($node_alias . '.status', NODE_PUBLISHED);
|
||||
}
|
||||
$query->addTag('node_access');
|
||||
}
|
||||
else {
|
||||
$query->addTag($entity_type . '_access');
|
||||
}
|
||||
|
||||
// Add the sort option.
|
||||
if (isset($label_key)) {
|
||||
$query->orderBy($base_table . '.' . $label_key, 'ASC');
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Private function to get referencable entities. Based on code from the
|
||||
* Entity Reference module.
|
||||
*/
|
||||
function _ctools_getReferencableEntities($entity_type, $entity_info, $match = NULL, $match_operator = 'LIKE', $limit = 0) {
|
||||
global $user;
|
||||
$account = $user;
|
||||
$options = array();
|
||||
// We're an entity ID, return the id
|
||||
if (is_numeric($match) && $match_operator == '=') {
|
||||
if ($entity = array_shift(entity_load($entity_type, array($match)))) {
|
||||
if (isset($entity_info['access callback']) && function_exists($entity_info['access callback'])) {
|
||||
if ($entity_info['access callback']('view', $entity, $account, $entity_type)) {
|
||||
$label = entity_label($entity_type, $entity);
|
||||
return array(
|
||||
$match => array(
|
||||
'label' => !empty($label) ? $label : $entity->{$entity_info['entity keys']['id']},
|
||||
'bundle' => !empty($entity_info['entity keys']['bundle']) ? check_plain($entity->{$entity_info['entity keys']['bundle']}) : NULL,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
// If you don't have access, or an access callback or a valid entity, just
|
||||
// Return back the Entity ID.
|
||||
return array(
|
||||
$match => array(
|
||||
'label' => $match,
|
||||
'bundle' => NULL,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// We have matches, build a query to fetch the result.
|
||||
if ($query = _ctools_buildQuery($entity_type, $entity_info, $match, $match_operator)) {
|
||||
if ($limit > 0) {
|
||||
$query->range(0, $limit);
|
||||
}
|
||||
|
||||
$results = $query->execute();
|
||||
|
||||
if (!empty($results)) {
|
||||
foreach ($results as $record) {
|
||||
$entities = entity_load($entity_type, array($record->{$entity_info['entity keys']['id']}));
|
||||
$entity = array_shift($entities);
|
||||
if (isset($entity_info['access callback']) && function_exists($entity_info['access callback'])) {
|
||||
if ($entity_info['access callback']('view', $entity, $account, $entity_type)) {
|
||||
$label = entity_label($entity_type, $entity);
|
||||
$options[$record->{$entity_info['entity keys']['id']}] = array(
|
||||
'label' => !empty($label) ? $label : $entity->{$entity_info['entity keys']['id']},
|
||||
'bundle' => !empty($entity_info['entity keys']['bundle']) ? check_plain($entity->{$entity_info['entity keys']['bundle']}) : NULL,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
@@ -376,11 +376,11 @@ function ctools_context_ajax_item_add($mechanism = NULL, $type = NULL, $cache_ke
|
||||
'path' => "ctools/context/ajax/add/$mechanism/$type/$cache_key/$name/%step",
|
||||
'show cancel' => TRUE,
|
||||
'default form' => 'ctools_edit_context_form_defaults',
|
||||
'auto caching' => TRUE,
|
||||
'auto cache' => TRUE,
|
||||
'cache mechanism' => $mechanism,
|
||||
'cache key' => $cache_key,
|
||||
// This is stating what the cache will be referred to in $form_state
|
||||
'cache storage' => 'object',
|
||||
'cache location' => 'object',
|
||||
);
|
||||
|
||||
if ($type == 'requiredcontext') {
|
||||
@@ -416,12 +416,20 @@ function ctools_context_ajax_item_add($mechanism = NULL, $type = NULL, $cache_ke
|
||||
ctools_cache_operation($mechanism, $cache_key, 'finalize', $object);
|
||||
|
||||
// Very irritating way to update the form for our contexts.
|
||||
$arg_form_state = array('values' => array());
|
||||
$arg_form_state = form_state_defaults() + array(
|
||||
'values' => array(),
|
||||
'process_input' => FALSE,
|
||||
'complete form' => array(),
|
||||
);
|
||||
|
||||
$rel_form_state = $arg_form_state;
|
||||
|
||||
$arg_form = array(
|
||||
'#post' => array(),
|
||||
'#programmed' => FALSE,
|
||||
'#tree' => FALSE,
|
||||
'#parents' => array(),
|
||||
'#array_parents' => array(),
|
||||
);
|
||||
|
||||
// Build a chunk of the form to merge into the displayed form
|
||||
@@ -446,6 +454,8 @@ function ctools_context_ajax_item_add($mechanism = NULL, $type = NULL, $cache_ke
|
||||
'#post' => array(),
|
||||
'#programmed' => FALSE,
|
||||
'#tree' => FALSE,
|
||||
'#parents' => array(),
|
||||
'#array_parents' => array(),
|
||||
);
|
||||
|
||||
$rel_form['relationship'] = array(
|
||||
@@ -460,7 +470,7 @@ function ctools_context_ajax_item_add($mechanism = NULL, $type = NULL, $cache_ke
|
||||
$output = array();
|
||||
if (!empty($available_relationships)) {
|
||||
ctools_context_add_item_table_buttons('relationship', $mechanism, $rel_form, $available_relationships);
|
||||
$rel_form = form_builder('dummy_form_id', $rel_form, $arg_form_state);
|
||||
$rel_form = form_builder('dummy_form_id', $rel_form, $rel_form_state);
|
||||
$output[] = ajax_command_replace('div#ctools-relationships-table div.buttons', drupal_render($rel_form));
|
||||
}
|
||||
|
||||
@@ -551,11 +561,11 @@ function ctools_context_ajax_item_edit($mechanism = NULL, $type = NULL, $cache_k
|
||||
'path' => "ctools/context/ajax/configure/$mechanism/$type/$cache_key/$position/%step",
|
||||
'show cancel' => TRUE,
|
||||
'default form' => 'ctools_edit_context_form_defaults',
|
||||
'auto caching' => TRUE,
|
||||
'auto cache' => TRUE,
|
||||
'cache mechanism' => $mechanism,
|
||||
'cache key' => $cache_key,
|
||||
// This is stating what the cache will be referred to in $form_state
|
||||
'cache storage' => 'object',
|
||||
'cache location' => 'object',
|
||||
);
|
||||
|
||||
if ($type == 'requiredcontext') {
|
||||
@@ -582,8 +592,16 @@ function ctools_context_ajax_item_edit($mechanism = NULL, $type = NULL, $cache_k
|
||||
$output = array();
|
||||
$output[] = ctools_modal_command_dismiss();
|
||||
|
||||
$arg_form_state = form_state_defaults() + array(
|
||||
'values' => array(),
|
||||
'process_input' => FALSE,
|
||||
'complete form' => array(),
|
||||
);
|
||||
|
||||
$arg_form = array(
|
||||
'#post' => array(),
|
||||
'#parents' => array(),
|
||||
'#array_parents' => array(),
|
||||
'#programmed' => FALSE,
|
||||
'#tree' => FALSE,
|
||||
);
|
||||
|
@@ -161,7 +161,7 @@ function ctools_context_handler_render_handler($task, $subtask, $handler, $conte
|
||||
'query' => $info['query'],
|
||||
'fragment' => $info['fragment'],
|
||||
);
|
||||
return drupal_goto($info['destination'], $options, $info['response code']);
|
||||
drupal_goto($info['destination'], $options, $info['response code']);
|
||||
// @todo -- should other response codes be supported here?
|
||||
}
|
||||
}
|
||||
|
@@ -169,7 +169,12 @@ class ctools_context_required {
|
||||
|
||||
function select($contexts, $context) {
|
||||
if (!is_array($contexts)) {
|
||||
$contexts = array($contexts);
|
||||
if (is_object($contexts) && $contexts instanceof ctools_context) {
|
||||
$contexts = array($contexts->id => $contexts);
|
||||
}
|
||||
else {
|
||||
$contexts = array($contexts);
|
||||
}
|
||||
}
|
||||
|
||||
// If we had requested a $context but that $context doesn't exist
|
||||
@@ -328,13 +333,15 @@ function _ctools_context_selector($contexts, $required, $default, $num = 0) {
|
||||
$title = $num ? t('Context %count', array('%count' => $num)) : t('Context');
|
||||
}
|
||||
|
||||
return array(
|
||||
$form = array(
|
||||
'#type' => 'select',
|
||||
'#options' => $options,
|
||||
'#title' => $title,
|
||||
'#default_value' => $default,
|
||||
);
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1400,8 +1407,7 @@ function ctools_get_relevant_access_plugins($contexts) {
|
||||
* Create a context for the logged in user.
|
||||
*/
|
||||
function ctools_access_get_loggedin_context() {
|
||||
global $user;
|
||||
$context = ctools_context_create('entity:user', $user);
|
||||
$context = ctools_context_create('entity:user', array('type' => 'current'), TRUE);
|
||||
$context->identifier = t('Logged in user');
|
||||
$context->keyword = 'viewer';
|
||||
$context->id = 0;
|
||||
@@ -1588,7 +1594,9 @@ function ctools_access_add_restrictions($settings, $contexts) {
|
||||
$required_context = isset($plugin['required context']) ? $plugin['required context'] : array();
|
||||
$context = isset($test['context']) ? $test['context'] : array();
|
||||
$contexts = ctools_context_select($contexts, $required_context, $context);
|
||||
$function($test['settings'], $contexts);
|
||||
if ($contexts !== FALSE) {
|
||||
$function($test['settings'], $contexts);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
52
sites/all/modules/contrib/dev/ctools/includes/css-cache.inc
Normal file
52
sites/all/modules/contrib/dev/ctools/includes/css-cache.inc
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Custom cache implementation for the CTools CSS cache.
|
||||
*/
|
||||
|
||||
class CToolsCssCache implements DrupalCacheInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function clear($cid = NULL, $wildcard = FALSE) {
|
||||
// Only clear the caches if the wildcard is set, this ensures that the cache
|
||||
// is only cleared when the full caches are cleared manually (eg by invoking
|
||||
// drupal_flush_all_caches()), and not on a cron run.
|
||||
// @see drupal_flush_all_caches()
|
||||
// @see system_cron()
|
||||
if ($wildcard) {
|
||||
ctools_include('css');
|
||||
ctools_css_flush_caches();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($cid) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getMultiple(&$cids) {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isEmpty() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set($cid, $data, $expire = CACHE_PERMANENT) {
|
||||
}
|
||||
|
||||
}
|
@@ -77,9 +77,9 @@ function ctools_css_store($id, $css, $filter = TRUE) {
|
||||
|
||||
$filename = ctools_css_cache($css, $filter);
|
||||
|
||||
db_insert('ctools_css_cache')
|
||||
db_merge('ctools_css_cache')
|
||||
->key(array('cid' => $id))
|
||||
->fields(array(
|
||||
'cid' => $id,
|
||||
'filename' => $filename,
|
||||
'css' => $css,
|
||||
'filter' => intval($filter),
|
||||
|
150
sites/all/modules/contrib/dev/ctools/includes/entity-access.inc
Normal file
150
sites/all/modules/contrib/dev/ctools/includes/entity-access.inc
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides various callbacks for the whole core module integration.
|
||||
* This is a copy of Entity API's functionality for use when Entity API isn't
|
||||
* Enabled, and only works on view functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Core hack to include entity api-esque 'access callback' functions to core
|
||||
* entities without needing to rely on entity api.
|
||||
* Exception: We don't touch file entity. You must have entity API enabled to
|
||||
* view files.
|
||||
*/
|
||||
function _ctools_entity_access(&$entity_info, $entity_type) {
|
||||
// If the access callback is already set, don't change anything.
|
||||
if (isset($entity_info['access callback'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch ($entity_type) {
|
||||
case 'node':
|
||||
// Sad panda, we don't use Entity API, lets manually add access callbacks.
|
||||
$entity_info['access callback'] = 'ctools_metadata_no_hook_node_access';
|
||||
break;
|
||||
case 'user':
|
||||
$entity_info['access callback'] = 'ctools_metadata_user_access';
|
||||
break;
|
||||
case 'comment':
|
||||
if (module_exists('comment')) {
|
||||
$entity_info['access callback'] = 'ctools_metadata_comment_access';
|
||||
}
|
||||
break;
|
||||
case 'taxonomy_term':
|
||||
if (module_exists('taxonomy')) {
|
||||
$entity_info['access callback'] = 'ctools_metadata_taxonomy_access';
|
||||
}
|
||||
break;
|
||||
case 'taxonomy_vocabulary':
|
||||
if (module_exists('taxonomy')) {
|
||||
$entity_info['access callback'] = 'ctools_metadata_taxonomy_access';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Access callback for the node entity.
|
||||
*
|
||||
* This function does not implement hook_node_access(), thus it may not be
|
||||
* called ctools_metadata_node_access().
|
||||
*
|
||||
* @see entity_access()
|
||||
*
|
||||
* @param $op
|
||||
* The operation being performed. One of 'view', 'update', 'create' or
|
||||
* 'delete'.
|
||||
* @param $node
|
||||
* A node to check access for. Must be a node object. Must have nid,
|
||||
* except in the case of 'create' operations.
|
||||
* @param $account
|
||||
* The user to check for. Leave it to NULL to check for the global user.
|
||||
*
|
||||
* @throws EntityMalformedException
|
||||
*
|
||||
* @return boolean
|
||||
* TRUE if access is allowed, FALSE otherwise.
|
||||
*/
|
||||
function ctools_metadata_no_hook_node_access($op, $node = NULL, $account = NULL) {
|
||||
// First deal with the case where a $node is provided.
|
||||
if (isset($node)) {
|
||||
// If a non-default revision is given, incorporate revision access.
|
||||
$default_revision = node_load($node->nid);
|
||||
if ($node->vid !== $default_revision->vid) {
|
||||
return _node_revision_access($node, $op, $account);
|
||||
}
|
||||
else {
|
||||
return node_access($op, $node, $account);
|
||||
}
|
||||
}
|
||||
// No node is provided. Check for access to all nodes.
|
||||
if (user_access('bypass node access', $account)) {
|
||||
return TRUE;
|
||||
}
|
||||
if (!user_access('access content', $account)) {
|
||||
return FALSE;
|
||||
}
|
||||
if ($op == 'view' && node_access_view_all_nodes($account)) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access callback for the user entity.
|
||||
*/
|
||||
function ctools_metadata_user_access($op, $entity = NULL, $account = NULL, $entity_type) {
|
||||
$account = isset($account) ? $account : $GLOBALS['user'];
|
||||
// Grant access to the users own user account and to the anonymous one.
|
||||
if (isset($entity) && $op != 'delete' && (($entity->uid == $account->uid && $entity->uid) || (!$entity->uid && $op == 'view'))) {
|
||||
return TRUE;
|
||||
}
|
||||
if (user_access('administer users', $account) || user_access('access user profiles', $account) && $op == 'view' && $entity->status) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access callback for the comment entity.
|
||||
*/
|
||||
function ctools_metadata_comment_access($op, $entity = NULL, $account = NULL) {
|
||||
// When determining access to a comment, if comment has an associated node,
|
||||
// the user must be able to view the node in order to access the comment.
|
||||
if (isset($entity->nid)) {
|
||||
if (!node_access('view', node_load($entity->nid), $account)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// Comment administrators are allowed to perform all operations on all
|
||||
// comments.
|
||||
if (user_access('administer comments', $account)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Unpublished comments can never be accessed by non-admins.
|
||||
if (isset($entity->status) && $entity->status == COMMENT_NOT_PUBLISHED) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (user_access('access comments', $account) && $op == 'view') {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access callback for the taxonomy entities.
|
||||
*/
|
||||
function ctools_metadata_taxonomy_access($op, $entity = NULL, $account = NULL, $entity_type) {
|
||||
if ($entity_type == 'taxonomy_vocabulary') {
|
||||
return user_access('administer taxonomy', $account);
|
||||
}
|
||||
if (user_access('administer taxonomy', $account) || user_access('access content', $account) && $op == 'view') {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
@@ -945,7 +945,13 @@ function ctools_export_object($table, $object, $indent = '', $identifier = NULL,
|
||||
else {
|
||||
$value = $object->$field;
|
||||
if ($info['type'] == 'int') {
|
||||
$value = (isset($info['size']) && $info['size'] == 'tiny') ? (bool) $value : (int) $value;
|
||||
if (isset($info['size']) && $info['size'] == 'tiny') {
|
||||
$info['boolean'] = (!isset($info['boolean'])) ? $schema['export']['boolean'] : $info['boolean'];
|
||||
$value = ($info['boolean']) ? (bool) $value : (int) $value;
|
||||
}
|
||||
else {
|
||||
$value = (int) $value;
|
||||
}
|
||||
}
|
||||
|
||||
$output .= $indent . '$' . $identifier . '->' . $field . ' = ' . ctools_var_export($value, $indent) . ";\n";
|
||||
@@ -967,7 +973,12 @@ function ctools_export_object($table, $object, $indent = '', $identifier = NULL,
|
||||
* that it's easily available.
|
||||
*/
|
||||
function ctools_export_get_schema($table) {
|
||||
$cache = &drupal_static(__FUNCTION__);
|
||||
static $drupal_static_fast;
|
||||
if (!isset($drupal_static_fast)) {
|
||||
$drupal_static_fast['cache'] = &drupal_static(__FUNCTION__);
|
||||
}
|
||||
$cache = &$drupal_static_fast['cache'];
|
||||
|
||||
if (empty($cache[$table])) {
|
||||
$schema = drupal_get_schema($table);
|
||||
|
||||
@@ -1003,6 +1014,7 @@ function ctools_export_get_schema($table) {
|
||||
'cache defaults' => FALSE,
|
||||
'default cache bin' => 'cache',
|
||||
'export type string' => 'type',
|
||||
'boolean' => TRUE,
|
||||
);
|
||||
|
||||
// If the export definition doesn't have the "primary key" then the CRUD
|
||||
|
@@ -79,6 +79,19 @@ function ctools_fields_get_field_formatter_settings_form($field, $formatter_type
|
||||
$instance = ctools_fields_fake_field_instance($field['field_name'], $view_mode, $formatter_type, $conf['formatter_settings']);
|
||||
$settings_form = $function($field, $instance, $view_mode, $form, $form_state);
|
||||
if ($settings_form) {
|
||||
// Allow other modules to alter the formatter settings form.
|
||||
$context = array(
|
||||
'module' => $formatter['module'],
|
||||
'formatter' => $formatter,
|
||||
'field' => $field,
|
||||
'instance' => $instance,
|
||||
'view_mode' => $view_mode,
|
||||
'form' => $form,
|
||||
'form_state' => $form_state,
|
||||
);
|
||||
drupal_alter('field_formatter_settings_form', $settings_form, $context);
|
||||
|
||||
$settings_form['#tree'] = TRUE;
|
||||
$form['ctools_field_list']['#value'][] = $field;
|
||||
$form += $settings_form;
|
||||
}
|
||||
|
@@ -187,18 +187,32 @@ function ctools_modal_text_button($text, $dest, $alt, $class = '') {
|
||||
/**
|
||||
* Wrap a form so that we can use it properly with AJAX. Essentially if the
|
||||
* form wishes to render, it automatically does that, otherwise it returns
|
||||
* so we can see submission results.
|
||||
* the render array so we can see submission results.
|
||||
|
||||
* @param array $form
|
||||
* An associative array containing the structure of the form.
|
||||
* @param array $form_state
|
||||
* An associative array containing the current state of the form.
|
||||
* If the 'reset_html_ids' key is set to TRUE, it will prevent HTML IDs in
|
||||
* forms from being incremented.
|
||||
*
|
||||
* @return
|
||||
* @return mixed
|
||||
* The output of the form, if it was rendered. If $form_state['ajax']
|
||||
* is set, this will use ctools_modal_form_render so it will be
|
||||
* a $command object suitable for ajax_render already.
|
||||
*
|
||||
* The return will be NULL if the form was successfully submitted unless
|
||||
* you specifically set re_render = TRUE. If ajax is set the
|
||||
* form will never be redirected.
|
||||
* If the form was not rendered, the raw render array will be returned.
|
||||
*
|
||||
* If ajax is set the form will never be redirected.
|
||||
*/
|
||||
function ctools_modal_form_wrapper($form_id, &$form_state) {
|
||||
// Since this will run again on form rebuild while still in the modal, prevent
|
||||
// form IDs from being incremented.
|
||||
// @todo https://drupal.org/node/1305882
|
||||
if (!empty($form_state['reset_html_ids']) && !empty($_POST['ajax_html_ids'])) {
|
||||
unset($_POST['ajax_html_ids']);
|
||||
}
|
||||
|
||||
// This won't override settings already in.
|
||||
$form_state += array(
|
||||
're_render' => FALSE,
|
||||
@@ -206,7 +220,7 @@ function ctools_modal_form_wrapper($form_id, &$form_state) {
|
||||
);
|
||||
|
||||
$output = drupal_build_form($form_id, $form_state);
|
||||
if (!empty($form_state['ajax']) && (!$form_state['executed'] || $form_state['rebuild'])) {
|
||||
if (!empty($form_state['ajax']) && (!$form_state['executed'] || $form_state['rebuild'])) {
|
||||
return ctools_modal_form_render($form_state, $output);
|
||||
}
|
||||
|
||||
|
@@ -214,7 +214,12 @@ function ctools_plugin_api_get_hook($owner, $api) {
|
||||
function ctools_get_plugins($module, $type, $id = NULL) {
|
||||
// Store local caches of plugins and plugin info so we don't have to do full
|
||||
// lookups everytime.
|
||||
$plugins = &drupal_static('ctools_plugins', array());
|
||||
static $drupal_static_fast;
|
||||
if (!isset($drupal_static_fast)) {
|
||||
$drupal_static_fast['plugins'] = &drupal_static('ctools_plugins', array());
|
||||
}
|
||||
$plugins = &$drupal_static_fast['plugins'];
|
||||
|
||||
$info = ctools_plugin_get_plugin_type_info();
|
||||
|
||||
// Bail out noisily if an invalid module/type combination is requested.
|
||||
@@ -343,8 +348,13 @@ function ctools_get_plugins($module, $type, $id = NULL) {
|
||||
* name and each inner array keyed on plugin type name.
|
||||
*/
|
||||
function ctools_plugin_get_plugin_type_info($flush = FALSE) {
|
||||
$info_loaded = &drupal_static('ctools_plugin_type_info_loaded', FALSE);
|
||||
$all_type_info = &drupal_static('ctools_plugin_type_info', array());
|
||||
static $drupal_static_fast;
|
||||
if (!isset($drupal_static_fast)) {
|
||||
$drupal_static_fast['info_loaded'] = &drupal_static('ctools_plugin_type_info_loaded', FALSE);
|
||||
$drupal_static_fast['all_type_info'] = &drupal_static('ctools_plugin_type_info', array());
|
||||
}
|
||||
$info_loaded = &$drupal_static_fast['info_loaded'];
|
||||
$all_type_info = &$drupal_static_fast['all_type_info'];
|
||||
|
||||
// Only trigger info loading once.
|
||||
if ($info_loaded && !$flush) {
|
||||
@@ -418,25 +428,15 @@ function ctools_plugin_load_includes($info, $filename = NULL) {
|
||||
// store static of plugin arrays for reference because they can't be reincluded.
|
||||
static $plugin_arrays = array();
|
||||
|
||||
// If we're being asked for all plugins of a type, skip any caching
|
||||
// we may have done because this is an admin task and it's ok to
|
||||
// spend the extra time.
|
||||
if (!isset($filename)) {
|
||||
$all_files[$info['module']][$info['type']] = NULL;
|
||||
}
|
||||
|
||||
if (!isset($all_files[$info['module']][$info['type']])) {
|
||||
// If a filename was set, we will try to load our list of files from
|
||||
// cache. This is considered normal operation and we try to reduce
|
||||
// the time spent finding files.
|
||||
if (isset($filename)) {
|
||||
$cache = cache_get("ctools_plugin_files:$info[module]:$info[type]");
|
||||
if ($cache) {
|
||||
$all_files[$info['module']][$info['type']] = $cache->data;
|
||||
}
|
||||
$cache = cache_get("ctools_plugin_files:$info[module]:$info[type]");
|
||||
if ($cache) {
|
||||
$all_files[$info['module']][$info['type']] = $cache->data;
|
||||
}
|
||||
|
||||
if (!isset($all_files[$info['module']][$info['type']])) {
|
||||
// Do not attempt any file scan even if the cached entry was empty.
|
||||
// A NULL entry here would mean the plugin just does not exists, and we
|
||||
// cannot afford to run file scan on production sites normal run.
|
||||
elseif (!isset($all_files[$info['module']][$info['type']])) {
|
||||
$all_files[$info['module']][$info['type']] = array();
|
||||
// Load all our plugins.
|
||||
$directories = ctools_plugin_get_directories($info);
|
||||
@@ -678,7 +678,7 @@ function ctools_plugin_process($info, $module, $identifier, $path, $file = NULL,
|
||||
if (!function_exists($function)) {
|
||||
return NULL;
|
||||
}
|
||||
$result = $function();
|
||||
$result = $function($info);
|
||||
if (!isset($result) || !is_array($result)) {
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -29,16 +29,3 @@ function ctools_passthrough($module, $type, &$items) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_theme_registry_alter()
|
||||
*/
|
||||
function ctools_theme_registry_alter(&$registry) {
|
||||
// Move this one last last last so it can catch changes made by modules and themes.
|
||||
$key = array_search('ctools_preprocess_page', $registry['page']['preprocess functions']);
|
||||
if ($key) {
|
||||
unset($registry['page']['preprocess functions'][$key]);
|
||||
}
|
||||
$registry['page']['preprocess functions'][] = 'ctools_preprocess_page';
|
||||
}
|
||||
|
||||
|
67
sites/all/modules/contrib/dev/ctools/includes/uuid.inc
Normal file
67
sites/all/modules/contrib/dev/ctools/includes/uuid.inc
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Enables ctools generated modules to use UUIDs without the UUID module enabled.
|
||||
* Per the ctools.module, this file only gets included if UUID doesn't exist.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pattern for detecting a valid UUID.
|
||||
*/
|
||||
define('UUID_PATTERN', '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}');
|
||||
|
||||
/**
|
||||
* Generates a UUID using the Windows internal GUID generator.
|
||||
*
|
||||
* @see http://php.net/com_create_guid
|
||||
*/
|
||||
function _ctools_uuid_generate_com() {
|
||||
// Remove {} wrapper and make lower case to keep result consistent.
|
||||
return drupal_strtolower(trim(com_create_guid(), '{}'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an universally unique identifier using the PECL extension.
|
||||
*/
|
||||
function _ctools_uuid_generate_pecl() {
|
||||
return uuid_create(UUID_TYPE_DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a UUID v4 using PHP code.
|
||||
*
|
||||
* Based on code from @see http://php.net/uniqid#65879 , but corrected.
|
||||
*/
|
||||
function _ctools_uuid_generate_php() {
|
||||
// The field names refer to RFC 4122 section 4.1.2.
|
||||
return sprintf('%04x%04x-%04x-4%03x-%04x-%04x%04x%04x',
|
||||
// 32 bits for "time_low".
|
||||
mt_rand(0, 65535), mt_rand(0, 65535),
|
||||
// 16 bits for "time_mid".
|
||||
mt_rand(0, 65535),
|
||||
// 12 bits after the 0100 of (version) 4 for "time_hi_and_version".
|
||||
mt_rand(0, 4095),
|
||||
bindec(substr_replace(sprintf('%016b', mt_rand(0, 65535)), '10', 0, 2)),
|
||||
// 8 bits, the last two of which (positions 6 and 7) are 01, for "clk_seq_hi_res"
|
||||
// (hence, the 2nd hex digit after the 3rd hyphen can only be 1, 5, 9 or d)
|
||||
// 8 bits for "clk_seq_low" 48 bits for "node".
|
||||
mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535)
|
||||
);
|
||||
}
|
||||
|
||||
// This is wrapped in an if block to avoid conflicts with PECL's uuid_is_valid().
|
||||
/**
|
||||
* Check that a string appears to be in the format of a UUID.
|
||||
*
|
||||
* @param $uuid
|
||||
* The string to test.
|
||||
*
|
||||
* @return
|
||||
* TRUE if the string is well formed.
|
||||
*/
|
||||
if (!function_exists('uuid_is_valid')) {
|
||||
function uuid_is_valid($uuid) {
|
||||
return preg_match('/^' . UUID_PATTERN . '$/', $uuid);
|
||||
}
|
||||
}
|
@@ -274,7 +274,7 @@ function ctools_wizard_wrapper($form, &$form_state) {
|
||||
if (!empty($form_info['show trail'])) {
|
||||
ctools_add_css('wizard');
|
||||
$form['ctools_trail'] = array(
|
||||
'#markup' => theme(array('ctools_wizard_trail__' . $form_info['id'], 'ctools_wizard_trail'), array('trail' => $trail)),
|
||||
'#markup' => theme(array('ctools_wizard_trail__' . $form_info['id'], 'ctools_wizard_trail'), array('trail' => $trail, 'form_info' => $form_info)),
|
||||
'#weight' => -1000,
|
||||
);
|
||||
}
|
||||
|
@@ -7,19 +7,16 @@
|
||||
|
||||
function ctools_wizard_theme(&$theme) {
|
||||
$theme['ctools_wizard_trail'] = array(
|
||||
'variables' => array('trail' => NULL),
|
||||
'variables' => array('trail' => NULL, 'form_info' => NULL, 'divider' => ' » '),
|
||||
'file' => 'includes/wizard.theme.inc',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Themable display of the 'breadcrumb' trail to show the order of the
|
||||
* forms.
|
||||
* Themable display of the 'breadcrumb' trail to show the order of the forms.
|
||||
*/
|
||||
function theme_ctools_wizard_trail($vars) {
|
||||
$trail = $vars['trail'];
|
||||
if (!empty($trail)) {
|
||||
return '<div class="wizard-trail">' . implode(' » ', $trail) . '</div>';
|
||||
if (!empty($vars['trail'])) {
|
||||
return '<div class="wizard-trail">' . implode($vars['divider'], $vars['trail']) . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -212,6 +212,7 @@
|
||||
content.slideToggle(100, afterToggle);
|
||||
}
|
||||
|
||||
$container.toggleClass('ctools-collapsed');
|
||||
toggle.toggleClass('ctools-toggle-collapsed');
|
||||
|
||||
// If we're supposed to remember the state of this class, do so.
|
||||
|
@@ -40,7 +40,7 @@
|
||||
Drupal.CTools.dependent.autoAttach = function() {
|
||||
// Clear active bindings and triggers.
|
||||
for (i in Drupal.CTools.dependent.activeTriggers) {
|
||||
$(Drupal.CTools.dependent.activeTriggers[i]).unbind('change');
|
||||
$(Drupal.CTools.dependent.activeTriggers[i]).unbind('change.ctools-dependent');
|
||||
}
|
||||
Drupal.CTools.dependent.activeTriggers = [];
|
||||
Drupal.CTools.dependent.activeBindings = {};
|
||||
@@ -194,7 +194,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
$(trigger_id).change(function() {
|
||||
$(trigger_id).bind('change.ctools-dependent', function() {
|
||||
// Trigger the internal change function
|
||||
// the attr('id') is used because closures are more confusing
|
||||
changeTrigger(trigger_id, bind_id);
|
||||
@@ -215,7 +215,7 @@
|
||||
// is a sort of hacked one that's faster but much less flexible.
|
||||
$("select.ctools-master-dependent")
|
||||
.once('ctools-dependent')
|
||||
.change(function() {
|
||||
.bind('change.ctools-dependent', function() {
|
||||
var val = $(this).val();
|
||||
if (val == 'all') {
|
||||
$('.ctools-dependent-all').show(0);
|
||||
@@ -225,7 +225,7 @@
|
||||
$('.ctools-dependent-' + val).show(0);
|
||||
}
|
||||
})
|
||||
.trigger('change');
|
||||
.trigger('change.ctools-dependent');
|
||||
}
|
||||
}
|
||||
})(jQuery);
|
||||
|
@@ -99,6 +99,11 @@
|
||||
$('span.modal-title', Drupal.CTools.Modal.modal).html(Drupal.CTools.Modal.currentSettings.loadingText);
|
||||
Drupal.CTools.Modal.modalContent(Drupal.CTools.Modal.modal, settings.modalOptions, settings.animation, settings.animationSpeed);
|
||||
$('#modalContent .modal-content').html(Drupal.theme(settings.throbberTheme));
|
||||
|
||||
// Position autocomplete results based on the scroll position of the modal.
|
||||
$('#modalContent .modal-content').delegate('input.form-autocomplete', 'keyup', function() {
|
||||
$('#autocomplete').css('top', $(this).position().top + $(this).outerHeight() + $(this).offsetParent().filter('#modal-content').scrollTop());
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -222,7 +227,11 @@
|
||||
// AJAX submits specified in this manner automatically submit to the
|
||||
// normal form action.
|
||||
element_settings.url = Drupal.CTools.Modal.findURL(this);
|
||||
if (element_settings.url == '') {
|
||||
element_settings.url = $(this).closest('form').attr('action');
|
||||
}
|
||||
element_settings.event = 'click';
|
||||
element_settings.setClick = true;
|
||||
|
||||
var base = $this.attr('id');
|
||||
Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
|
||||
@@ -249,6 +258,10 @@
|
||||
$('input[type=submit], button', this).click(function(event) {
|
||||
Drupal.ajax[base].element = this;
|
||||
this.form.clk = this;
|
||||
// Stop autocomplete from submitting.
|
||||
if (Drupal.autocompleteSubmit && !Drupal.autocompleteSubmit()) {
|
||||
return false;
|
||||
}
|
||||
// An empty event means we were triggered via .click() and
|
||||
// in jquery 1.4 this won't trigger a submit.
|
||||
if (event.bubbles == undefined) {
|
||||
@@ -282,7 +295,10 @@
|
||||
// content. This is helpful for allowing users to see error messages at the
|
||||
// top of a form, etc.
|
||||
$('#modal-content').html(response.output).scrollTop(0);
|
||||
Drupal.attachBehaviors();
|
||||
|
||||
// Attach behaviors within a modal dialog.
|
||||
var settings = response.settings || ajax.settings || Drupal.settings;
|
||||
Drupal.attachBehaviors('#modalContent', settings);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -363,9 +379,9 @@
|
||||
css.filter = 'alpha(opacity=' + (100 * css.opacity) + ')';
|
||||
content.hide();
|
||||
|
||||
// if we already ahve a modalContent, remove it
|
||||
if ( $('#modalBackdrop')) $('#modalBackdrop').remove();
|
||||
if ( $('#modalContent')) $('#modalContent').remove();
|
||||
// If we already have modalContent, remove it.
|
||||
if ($('#modalBackdrop').length) $('#modalBackdrop').remove();
|
||||
if ($('#modalContent').length) $('#modalContent').remove();
|
||||
|
||||
// position code lifted from http://www.quirksmode.org/viewport/compatibility.html
|
||||
if (self.pageYOffset) { // all except Explorer
|
||||
@@ -405,12 +421,17 @@
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if( $(target).filter('*:visible').parents('#modalContent').size()) {
|
||||
// allow the event only if target is a visible child node of #modalContent
|
||||
|
||||
if ($(target).is('#modalContent, body') || $(target).filter('*:visible').parents('#modalContent').length) {
|
||||
// Allow the event only if target is a visible child node
|
||||
// of #modalContent.
|
||||
return true;
|
||||
}
|
||||
if ( $('#modalContent')) $('#modalContent').get(0).focus();
|
||||
return false;
|
||||
else {
|
||||
$('#modalContent').focus();
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
};
|
||||
$('body').bind( 'focus', modalEventHandler );
|
||||
$('body').bind( 'keypress', modalEventHandler );
|
||||
@@ -461,6 +482,16 @@
|
||||
|
||||
// Move and resize the modalBackdrop and modalContent on resize of the window
|
||||
modalContentResize = function(){
|
||||
|
||||
// position code lifted from http://www.quirksmode.org/viewport/compatibility.html
|
||||
if (self.pageYOffset) { // all except Explorer
|
||||
var wt = self.pageYOffset;
|
||||
} else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
|
||||
var wt = document.documentElement.scrollTop;
|
||||
} else if (document.body) { // all other Explorers
|
||||
var wt = document.body.scrollTop;
|
||||
}
|
||||
|
||||
// Get our heights
|
||||
var docHeight = $(document).height();
|
||||
var docWidth = $(document).width();
|
||||
@@ -470,7 +501,7 @@
|
||||
|
||||
// Get where we should move content to
|
||||
var modalContent = $('#modalContent');
|
||||
var mdcTop = ( winHeight / 2 ) - ( modalContent.outerHeight() / 2);
|
||||
var mdcTop = wt + ( winHeight / 2 ) - ( modalContent.outerHeight() / 2);
|
||||
var mdcLeft = ( winWidth / 2 ) - ( modalContent.outerWidth() / 2);
|
||||
|
||||
// Apply the changes
|
||||
|
@@ -14,7 +14,7 @@
|
||||
function page_manager_list_page($js = NULL) {
|
||||
// Prevent this page from showing up when random other links fail.
|
||||
if ($js && $js != 'ajax' && $js != 'nojs') {
|
||||
return drupal_not_found();
|
||||
return MENU_NOT_FOUND;
|
||||
}
|
||||
|
||||
// TRUE if 'ajax', FALSE if otherwise.
|
||||
@@ -62,7 +62,7 @@ function page_manager_list_page($js = NULL) {
|
||||
if (isset($input['op']) && $input['op'] == t('Reset')) {
|
||||
unset($_SESSION['page_manager']['#admin']);
|
||||
if (!$js) {
|
||||
return drupal_goto($_GET['q']);
|
||||
drupal_goto($_GET['q']);
|
||||
}
|
||||
// clear everything but form id, form build id and form token:
|
||||
$keys = array_keys($input);
|
||||
@@ -95,6 +95,7 @@ function page_manager_list_page($js = NULL) {
|
||||
|
||||
$header = array(
|
||||
array('data' => t('Type'), 'class' => array('page-manager-page-type')),
|
||||
array('data' => t('Module'), 'class' => array('page-manager-page-module')),
|
||||
array('data' => t('Name'), 'class' => array('page-manager-page-name')),
|
||||
array('data' => t('Title'), 'class' => array('page-manager-page-title')),
|
||||
array('data' => t('Path'), 'class' => array('page-manager-page-path')),
|
||||
@@ -175,9 +176,18 @@ function page_manager_get_pages($tasks, &$pages, $task_id = NULL) {
|
||||
$row = array('data' => array(), 'class' => $class, 'title' => strip_tags($task['admin description']));
|
||||
|
||||
$type = isset($task['admin type']) ? $task['admin type'] : t('System');
|
||||
if (isset($task['module'])) {
|
||||
$module = $task['module'];
|
||||
}
|
||||
elseif (isset($task['subtask']->export_module)) {
|
||||
$module = $task['subtask']->export_module;
|
||||
}
|
||||
else {
|
||||
$module = '';
|
||||
}
|
||||
$pages['types'][$type] = $type;
|
||||
$row['data']['type'] = array('data' => $type, 'class' => array('page-manager-page-type'));
|
||||
|
||||
$row['data']['module'] = array('data' => $module, 'class' => array('page-manager-page-module'));
|
||||
$row['data']['name'] = array('data' => $task_name, 'class' => array('page-manager-page-name'));
|
||||
$row['data']['title'] = array('data' => $task['admin title'], 'class' => array('page-manager-page-title'));
|
||||
$row['data']['path'] = array('data' => $visible_path, 'class' => array('page-manager-page-path'));
|
||||
@@ -401,7 +411,7 @@ function page_manager_list_pages_form_submit(&$form, &$form_state) {
|
||||
* Render the edit page for a a page, custom or system.
|
||||
*/
|
||||
function page_manager_edit_page($page) {
|
||||
drupal_set_title($page->subtask['admin title']);
|
||||
drupal_set_title($page->subtask['admin title'], PASS_THROUGH);
|
||||
// Provide and process the save page form before anything else.
|
||||
$form_state = array('page' => &$page);
|
||||
$built_form = drupal_build_form('page_manager_save_page_form', $form_state);
|
||||
@@ -464,7 +474,7 @@ function page_manager_edit_page_operation() {
|
||||
return;
|
||||
}
|
||||
|
||||
drupal_set_title($page->subtask['admin title']);
|
||||
drupal_set_title($page->subtask['admin title'], PASS_THROUGH);
|
||||
return $output;
|
||||
}
|
||||
|
||||
@@ -577,8 +587,8 @@ function page_manager_get_operations($page, $operations = NULL) {
|
||||
),
|
||||
);
|
||||
|
||||
// Restrict variant import to users who can already execute arbitrary PHP
|
||||
if (user_access('use PHP for settings')) {
|
||||
// Restrict variant import due to security implications.
|
||||
if (user_access('use ctools import')) {
|
||||
$result['actions']['children']['import'] = array(
|
||||
'title' => t('Import variant'),
|
||||
'description' => t('Add a new variant to this page from code exported from another page.'),
|
||||
@@ -930,7 +940,7 @@ function _page_manager_get_operation_content($js, &$page, $active, $operation, $
|
||||
$output = drupal_render($built_form);
|
||||
$title = empty($form_state['title']) ? $operation['title'] : $form_state['title'];
|
||||
$titles[] = $title;
|
||||
$title = implode(' » ', array_filter($titles));
|
||||
$title = implode(' » ', array_filter($titles));
|
||||
|
||||
// If there are messages for the form, render them.
|
||||
if ($messages = theme('status_messages')) {
|
||||
@@ -1308,6 +1318,7 @@ function page_manager_handler_add_submit(&$form, &$form_state) {
|
||||
else {
|
||||
$handler->conf['title'] = $plugin['title'];
|
||||
}
|
||||
$handler->conf['name'] = $form_state['values']['name'];
|
||||
$cache->new_handler = $handler;
|
||||
|
||||
// Figure out which forms to present them with
|
||||
@@ -1398,6 +1409,21 @@ function page_manager_handler_add_form($form, $form_state, $features = array())
|
||||
'#title' => t('Title'),
|
||||
'#description' => t('Administrative title of this variant. If you leave blank it will be automatically assigned.'),
|
||||
);
|
||||
|
||||
$form['name'] = array(
|
||||
'#type' => 'machine_name',
|
||||
'#title' => t('Machine name'),
|
||||
'#required' => FALSE,
|
||||
'#description' => t("A unique machine-readable name for this variant. It must only contain lowercase letters, numbers, and underscores. This name will be used when exporting the variant. If left empty the variant's name will be used instead."),
|
||||
'#size' => 32,
|
||||
'#maxlength' => 32,
|
||||
'#machine_name' => array(
|
||||
'exists' => 'page_manager_handler_check_machine_name',
|
||||
'source' => array('title'),
|
||||
),
|
||||
'#field_prefix' => '<span dir="ltr">' . $form_state['task_name'] . '__',
|
||||
'#field_suffix' => '</span>‎',
|
||||
);
|
||||
}
|
||||
|
||||
$form['handler'] = array(
|
||||
@@ -1436,6 +1462,15 @@ function page_manager_handler_add_form($form, $form_state, $features = array())
|
||||
return $form;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if handler's machine-name is unique
|
||||
*/
|
||||
function page_manager_handler_check_machine_name($name, $element, $form_state) {
|
||||
$name = $form_state['task_name'] . '__' . $name;
|
||||
|
||||
return count(ctools_export_load_object('page_manager_handlers', 'names', array($name)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rearrange the order of variants.
|
||||
*/
|
||||
@@ -1446,15 +1481,16 @@ function page_manager_handler_import($form, &$form_state) {
|
||||
'#description' => t('Enter the name of the new variant.'),
|
||||
);
|
||||
|
||||
if (user_access('use PHP for settings')) {
|
||||
if (user_access('use ctools import')) {
|
||||
$form['object'] = array(
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Paste variant code here'),
|
||||
'#rows' => 15,
|
||||
);
|
||||
}
|
||||
// Users ordinarily can't get here without the PHP block visibility perm.
|
||||
// In case they somehow do, though, disable the form widget for extra safety.
|
||||
// Users ordinarily can't get here without the 'import' permission, due to
|
||||
// security implications. In case they somehow do, though, disable the form
|
||||
// widget for extra safety.
|
||||
else {
|
||||
$form['shoveoff'] = array(
|
||||
'#markup' => '<div>' . t('You do not have sufficient permissions to perform this action.') . '</div>',
|
||||
@@ -1468,7 +1504,7 @@ function page_manager_handler_import($form, &$form_state) {
|
||||
* Make sure that an import actually provides a handler.
|
||||
*/
|
||||
function page_manager_handler_import_validate($form, &$form_state) {
|
||||
if (!user_access('use PHP for settings')) {
|
||||
if (!user_access('use ctools import')) {
|
||||
form_error($form['shoveoff'], t('You account permissions do not permit you to import.'));
|
||||
return;
|
||||
}
|
||||
|
@@ -3,10 +3,11 @@ description = Provides a UI and API to manage pages within the site.
|
||||
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"
|
||||
|
||||
|
@@ -213,6 +213,30 @@ function page_manager_menu_alter(&$items) {
|
||||
}
|
||||
}
|
||||
|
||||
// Override the core node revisions display to use the configured Page
|
||||
// display handler.
|
||||
if (!variable_get('page_manager_node_view_disabled', TRUE) && isset($items['node/%node/revisions/%/view'])) {
|
||||
// Abstract the basic settings.
|
||||
$item = array(
|
||||
// Handle the page arguments.
|
||||
'load arguments' => array(3),
|
||||
'page arguments' => array(1, TRUE),
|
||||
|
||||
// Replace the normal node_show call with Page Manager's node view.
|
||||
'page callback' => 'page_manager_node_view_page',
|
||||
|
||||
// Provide the correct path to the Page Manager file.
|
||||
'file' => 'node_view.inc',
|
||||
'file path' => drupal_get_path('module', 'page_manager') . '/plugins/tasks',
|
||||
);
|
||||
// Re-build the menu item using the normal values from node.module.
|
||||
$items['node/%node/revisions/%/view'] = array(
|
||||
'title' => 'Revisions',
|
||||
'access callback' => '_node_revision_access',
|
||||
'access arguments' => array(1),
|
||||
) + $item;
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
@@ -416,16 +440,17 @@ function page_manager_cache_load($task_name) {
|
||||
*/
|
||||
function page_manager_handler_get_name($task_name, $handlers, $handler) {
|
||||
$base = str_replace('-', '_', $task_name);
|
||||
// Generate a unique name. Unlike most named objects, we don't let people choose
|
||||
// names for task handlers because they mostly don't make sense.
|
||||
$base .= '_' . $handler->handler;
|
||||
// Optional machine name.
|
||||
if (!empty($handler->conf['name'])) {
|
||||
$name = $base . '__' . $handler->conf['name'];
|
||||
}
|
||||
|
||||
// Once we have a base, check to see if it is used. If it is, start counting up.
|
||||
$name = $base;
|
||||
$count = 1;
|
||||
// If taken
|
||||
while (isset($handlers[$name])) {
|
||||
$name = $base . '_' . ++$count;
|
||||
// If no machine name was provided, generate a unique name.
|
||||
else {
|
||||
$base .= '__' . $handler->handler;
|
||||
|
||||
// Use the ctools uuid generator to generate a unique id.
|
||||
$name = $base . '_' . ctools_uuid_generate();
|
||||
}
|
||||
|
||||
return $name;
|
||||
|
70
sites/all/modules/contrib/dev/ctools/page_manager/plugins/cache/page_manager_context.inc
vendored
Normal file
70
sites/all/modules/contrib/dev/ctools/page_manager/plugins/cache/page_manager_context.inc
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* A page_manager cache indirection mechanism that just attaches context
|
||||
* caching to the larger page cache.
|
||||
*/
|
||||
|
||||
$plugin = array(
|
||||
// cache plugins are the rare plugin types that have no real UI but
|
||||
// we're providing a title just in case.
|
||||
'title' => t('Page manager context'),
|
||||
'cache get' => 'page_manager_cache_page_manager_context_cache_get',
|
||||
'cache set' => 'page_manager_cache_page_manager_context_cache_set',
|
||||
'cache finalize' => 'page_manager_cache_page_manager_context_cache_finalize',
|
||||
|
||||
// We don't support a clear because the general uses of clear have no effect
|
||||
// on us.
|
||||
);
|
||||
|
||||
function page_manager_cache_page_manager_context_cache_get($data, $key) {
|
||||
$page = page_manager_get_page_cache($data);
|
||||
if ($page) {
|
||||
if (!empty($page->context_cache[$key])) {
|
||||
return $page->context_cache[$key];
|
||||
}
|
||||
else {
|
||||
ctools_include('context-task-handler');
|
||||
if ($key == 'temp') {
|
||||
$handler = $page->new_handler;
|
||||
}
|
||||
else {
|
||||
$handler = $page->handlers[$key];
|
||||
}
|
||||
return ctools_context_handler_get_task_object($page->task, $page->subtask, $handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function page_manager_cache_page_manager_context_cache_set($data, $key, $object) {
|
||||
$page = page_manager_get_page_cache($data);
|
||||
if ($page) {
|
||||
$page->context_cache[$key] = $object;
|
||||
return page_manager_set_page_cache($page);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy temporary data from the page manager cache
|
||||
*/
|
||||
function page_manager_cache_page_manager_context_cache_finalize($data, $key, $object) {
|
||||
// Statically cached so there shouldn't be any worries. It's an object so
|
||||
// referencing ensures that we'll get the right one.
|
||||
$page = page_manager_get_page_cache($data);
|
||||
if ($page) {
|
||||
if ($key == 'temp') {
|
||||
$handler = $page->new_handler;
|
||||
}
|
||||
else {
|
||||
$handler = $page->handlers[$key];
|
||||
}
|
||||
$handler->conf['contexts'] = $object->contexts;
|
||||
$handler->conf['relationships'] = $object->relationships;
|
||||
|
||||
if (isset($page->context_cache[$key])) {
|
||||
unset($page->context_cache[$key]);
|
||||
}
|
||||
return page_manager_set_page_cache($page);
|
||||
}
|
||||
}
|
@@ -216,6 +216,9 @@ function page_manager_http_response_title($handler, $task, $subtask) {
|
||||
* General settings for the panel
|
||||
*/
|
||||
function page_manager_http_response_edit_settings($form, &$form_state) {
|
||||
ctools_include('page_manager.admin', 'page_manager', '');
|
||||
ctools_include('export', 'ctools');
|
||||
|
||||
$conf = $form_state['handler']->conf;
|
||||
$form['title'] = array(
|
||||
'#type' => 'textfield',
|
||||
@@ -224,6 +227,23 @@ function page_manager_http_response_edit_settings($form, &$form_state) {
|
||||
'#description' => t('Administrative title of this variant.'),
|
||||
);
|
||||
|
||||
$name = isset($conf['name']) ? $conf['name'] : FALSE;
|
||||
$form['name'] = array(
|
||||
'#type' => 'machine_name',
|
||||
'#title' => t('Machine name'),
|
||||
'#required' => FALSE,
|
||||
'#default_value' => $name,
|
||||
'#description' => t("A unique machine-readable name for this variant. It must only contain lowercase letters, numbers, and underscores. This name will be used when exporting the variant. If left empty the variant's name will be used instead."),
|
||||
'#size' => 32,
|
||||
'#maxlength' => 32,
|
||||
'#machine_name' => array(
|
||||
'exists' => 'page_manager_handler_check_machine_name',
|
||||
'source' => array('title'),
|
||||
),
|
||||
'#field_prefix' => '<span dir="ltr">' . $form_state['task_name'] . '__',
|
||||
'#field_suffix' => '</span>‎',
|
||||
);
|
||||
|
||||
$form['code'] = array(
|
||||
'#title' => t('Response code'),
|
||||
'#type' => 'select',
|
||||
@@ -244,7 +264,33 @@ function page_manager_http_response_edit_settings($form, &$form_state) {
|
||||
}
|
||||
|
||||
function page_manager_http_response_edit_settings_submit($form, &$form_state) {
|
||||
$machine_name = $form_state['handler']->name;
|
||||
$name = $form_state['task_name'] . '__' . $form_state['values']['name'];
|
||||
|
||||
// If new name doesn't equal machine name, we need to update and redirect.
|
||||
if ($machine_name !== $name) {
|
||||
$form_state['handler']->name = $name;
|
||||
// If there's a trail, we need to replace it for redirection.
|
||||
if (isset($form_state['trail'])) {
|
||||
$form_state['new trail'] = $form_state['trail'];
|
||||
$delta = array_search($machine_name, $form_state['new trail']);
|
||||
$form_state['new trail'][$delta] = $name;
|
||||
}
|
||||
// If handler id is set, replace it.
|
||||
if ($form_state['handler_id']) {
|
||||
$form_state['handler_id'] = $name;
|
||||
}
|
||||
// If we're defining a new custom handler, move page handler to new name.
|
||||
if (isset($form_state['page']->handlers[$machine_name]) && isset($form_state['page']->handler_info[$machine_name])) {
|
||||
$form_state['page']->handlers[$name] = $form_state['page']->handlers[$machine_name];
|
||||
unset($form_state['page']->handlers[$machine_name]);
|
||||
$form_state['page']->handler_info[$name] = $form_state['page']->handler_info[$machine_name];
|
||||
unset($form_state['page']->handler_info[$machine_name]);
|
||||
}
|
||||
}
|
||||
|
||||
$form_state['handler']->conf['title'] = $form_state['values']['title'];
|
||||
$form_state['handler']->conf['name'] = $form_state['values']['name'];
|
||||
$form_state['handler']->conf['code'] = $form_state['values']['code'];
|
||||
$form_state['handler']->conf['destination'] = $form_state['values']['destination'];
|
||||
}
|
||||
|
@@ -67,7 +67,7 @@ function page_manager_comment_reply_page($node, $pid = NULL){
|
||||
}
|
||||
|
||||
$output = ctools_context_handler_render($task, '', $contexts, array($node, $pid));
|
||||
if ($output != FALSE) {
|
||||
if ($output !== FALSE) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
@@ -126,7 +126,7 @@ function page_manager_node_add($type) {
|
||||
'language' => LANGUAGE_NONE,
|
||||
);
|
||||
|
||||
drupal_set_title(t('Create @name', array('@name' => $types[$type]->name)));
|
||||
drupal_set_title(t('Create @name', array('@name' => $types[$type]->name)), PASS_THROUGH);
|
||||
return page_manager_node_edit($node);
|
||||
}
|
||||
|
||||
|
@@ -78,6 +78,10 @@ function page_manager_node_view_menu_alter(&$items, $task) {
|
||||
* node view, which is node_page_view().
|
||||
*/
|
||||
function page_manager_node_view_page($node) {
|
||||
// Prep the node to be displayed so all of the regular hooks are triggered.
|
||||
// Also save the output for later, in case it is needed.
|
||||
$default_output = node_page_view($node);
|
||||
|
||||
// Load my task plugin
|
||||
$task = page_manager_get_task('node_view');
|
||||
|
||||
@@ -85,32 +89,26 @@ function page_manager_node_view_page($node) {
|
||||
ctools_include('context');
|
||||
ctools_include('context-task-handler');
|
||||
|
||||
// We need to mimic Drupal's behavior of setting the node title here.
|
||||
drupal_set_title($node->title);
|
||||
$uri = entity_uri('node', $node);
|
||||
// Set the node path as the canonical URL to prevent duplicate content.
|
||||
drupal_add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], $uri['options'])), TRUE);
|
||||
// Set the non-aliased path as a default shortlink.
|
||||
drupal_add_html_head_link(array('rel' => 'shortlink', 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE)))), TRUE);
|
||||
// Load all contexts.
|
||||
$contexts = ctools_context_handler_get_task_contexts($task, '', array($node));
|
||||
|
||||
// Build the full output using the configured CTools plugin.
|
||||
$output = ctools_context_handler_render($task, '', $contexts, array($node->nid));
|
||||
if ($output != FALSE) {
|
||||
if ($output !== FALSE) {
|
||||
node_tag_new($node);
|
||||
return $output;
|
||||
}
|
||||
|
||||
$function = 'node_page_view';
|
||||
// Try loading an override plugin.
|
||||
foreach (module_implements('page_manager_override') as $module) {
|
||||
$call = $module . '_page_manager_override';
|
||||
if (($rc = $call('node_view')) && function_exists($rc)) {
|
||||
$function = $rc;
|
||||
break;
|
||||
return $rc($node);
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, fall back.
|
||||
return $function($node);
|
||||
// Otherwise, fall back to the default output generated by node_page_view().
|
||||
return $default_output;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -38,7 +38,7 @@ function page_manager_page_menu(&$items, $task) {
|
||||
) + $base;
|
||||
if ($access_callback == 'user_access') {
|
||||
$items['admin/structure/pages/import']['access callback'] = 'ctools_access_multiperm';
|
||||
$items['admin/structure/pages/import']['access arguments'][] = 'use PHP for settings';
|
||||
$items['admin/structure/pages/import']['access arguments'][] = 'use ctools import';
|
||||
}
|
||||
|
||||
// AJAX callbacks for argument modal.
|
||||
@@ -237,7 +237,7 @@ function page_manager_page_add_subtask($task_name = NULL, $step = NULL) {
|
||||
if ($task_name) {
|
||||
$page = page_manager_get_page_cache($task_name);
|
||||
if (empty($page)) {
|
||||
return drupal_not_found();
|
||||
return MENU_NOT_FOUND;
|
||||
}
|
||||
|
||||
$form_info['path'] = "admin/structure/pages/add/$task_name/%step";
|
||||
@@ -443,7 +443,7 @@ function page_manager_page_form_basic($form, &$form_state) {
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => !empty($page->make_frontpage),
|
||||
'#title' => t('Make this your site home page.'),
|
||||
'#description' => t('To set this panel as your home page you must create a unique path name with no % placeholders in the path. The site home page is currently set to %homepage on the !siteinfo configuration form.', array('!siteinfo' => l(t('Site Information'), 'admin/settings/site-information'), '%homepage' => '/' . $frontpage)),
|
||||
'#description' => t('To set this panel as your home page you must create a unique path name with no % placeholders in the path. The site home page is currently set to %homepage on the !siteinfo configuration form.', array('!siteinfo' => l(t('Site Information'), 'admin/config/system/site-information'), '%homepage' => '/' . $frontpage)),
|
||||
);
|
||||
$form['admin_paths'] = array(
|
||||
'#type' => 'checkbox',
|
||||
@@ -769,12 +769,12 @@ function page_manager_page_form_menu($form, &$form_state) {
|
||||
);
|
||||
}
|
||||
$form['menu']['parent']['weight'] = array(
|
||||
'#title' => t('Tab weight'),
|
||||
'#title' => t('Parent weight'),
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $menu['parent']['weight'],
|
||||
'#size' => 5,
|
||||
'#description' => t('If the parent menu item is a tab, enter the weight of the tab. The lower the number, the more to the left it will be.'),
|
||||
'#dependency' => array('radio:menu[type]' => array('default tab'), 'radio:menu[parent][type]' => array('tab')),
|
||||
'#description' => t('Enter the weight of the parent item. The lower the number, the more to the left it will be.'),
|
||||
'#dependency' => array('radio:menu[type]' => array('default tab'), 'radio:menu[parent][type]' => array('tab', 'normal')),
|
||||
'#dependency_count' => 2,
|
||||
);
|
||||
|
||||
|
@@ -321,7 +321,7 @@ function page_manager_page_execute($subtask_id) {
|
||||
ctools_include('context-task-handler');
|
||||
$output = ctools_context_handler_render($task, $subtask, $contexts, $args);
|
||||
if ($output === FALSE) {
|
||||
return drupal_not_found();
|
||||
return MENU_NOT_FOUND;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
@@ -138,7 +138,7 @@ function page_manager_term_view_page($term, $depth = NULL) {
|
||||
$contexts = ctools_context_handler_get_task_contexts($task, '', array($term, $depth));
|
||||
|
||||
if (empty($contexts)) {
|
||||
return drupal_not_found();
|
||||
return MENU_NOT_FOUND;
|
||||
}
|
||||
|
||||
// Build the full output using the configured CTools plugin.
|
||||
@@ -151,7 +151,7 @@ function page_manager_term_view_page($term, $depth = NULL) {
|
||||
foreach (module_implements('page_manager_override') as $module) {
|
||||
$call = $module . '_page_manager_override';
|
||||
if (($rc = $call('term_view')) && function_exists($rc)) {
|
||||
return $rc($node);
|
||||
return $rc($term, $depth);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -97,8 +97,8 @@ function page_manager_user_edit_page($account, $category = 'account') {
|
||||
$output = ctools_context_handler_render($task, '', $contexts, array($account->uid));
|
||||
if (is_array($output)) {
|
||||
$output = drupal_render($output);
|
||||
}
|
||||
if ($output != FALSE) {
|
||||
}
|
||||
if ($output !== FALSE) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ function page_manager_user_edit_page($account, $category = 'account') {
|
||||
//call drupal_build_form.
|
||||
$form_state = array();
|
||||
$form_id = 'user_profile_form';
|
||||
$args = array($account);
|
||||
$args = array($account, $category);
|
||||
$form_state['build_info']['args'] = $args;
|
||||
form_load_include($form_state, 'inc', 'user', 'user.pages');
|
||||
$output = drupal_build_form($form_id, $form_state);
|
||||
|
@@ -81,7 +81,7 @@ function page_manager_user_view_page($account) {
|
||||
user_build_content($account);
|
||||
|
||||
$output = ctools_context_handler_render($task, '', $contexts, array($account->uid));
|
||||
if ($output != FALSE) {
|
||||
if ($output !== FALSE) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
94
sites/all/modules/contrib/dev/ctools/plugins/access/book.inc
Normal file
94
sites/all/modules/contrib/dev/ctools/plugins/access/book.inc
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Plugin to provide access control based on whether a node belongs to a book.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
*/
|
||||
if (module_exists('book')) {
|
||||
$plugin = array(
|
||||
'title' => t("Book: node is in a book"),
|
||||
'description' => t('Control access based upon a node belonging to a book.'),
|
||||
'callback' => 'ctools_book_node_ctools_access_check',
|
||||
'default' => array('book' => array()),
|
||||
'settings form' => 'ctools_book_node_ctools_access_settings',
|
||||
'settings form submit' => 'ctools_book_node_ctools_access_settings_submit',
|
||||
'summary' => 'ctools_book_node_ctools_access_summary',
|
||||
'required context' => new ctools_context_required(t('Node'), 'node'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings form for the 'by book_node' access plugin.
|
||||
*/
|
||||
function ctools_book_node_ctools_access_settings($form, &$form_state, $conf) {
|
||||
$options = array(
|
||||
'any' => t('In any book'),
|
||||
);
|
||||
$books = book_get_books();
|
||||
foreach ($books as $bid => $book) {
|
||||
$options[$bid] = $book['title'];
|
||||
}
|
||||
$form['settings']['book'] = array(
|
||||
'#title' => t('Book'),
|
||||
'#type' => 'checkboxes',
|
||||
'#options' => $options,
|
||||
'#description' => t('Pass only if the node belongs to one of the selected books'),
|
||||
'#default_value' => $conf['book'],
|
||||
'#required' => TRUE,
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for access.
|
||||
*/
|
||||
function ctools_book_node_ctools_access_check($conf, $context) {
|
||||
// As far as I know there should always be a context at this point, but this
|
||||
// is safe.
|
||||
if (empty($context) || empty($context->data) || empty($context->data->book)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ($conf['book']['any']) {
|
||||
return !empty($context->data->book);
|
||||
}
|
||||
|
||||
foreach ($conf['book'] as $bid => $value) {
|
||||
if ($bid == 'any') {
|
||||
continue;
|
||||
}
|
||||
if ($value && ($bid == $context->data->book['bid'])) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a summary description based upon the checked node_languages.
|
||||
*/
|
||||
function ctools_book_node_ctools_access_summary($conf, $context) {
|
||||
if ($conf['book']['any']) {
|
||||
return t('@identifier belongs to a book', array('@identifier' => $context->identifier));
|
||||
}
|
||||
|
||||
$books = array();
|
||||
foreach ($conf['book'] as $bid => $value) {
|
||||
if ($value) {
|
||||
$node = node_load($bid);
|
||||
$books[] = $node->title;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($books) == 1) {
|
||||
return t('@identifier belongs to the book "@book"', array('@book' => $books[0], '@identifier' => $context->identifier));
|
||||
}
|
||||
|
||||
return t('@identifier belongs in multiple books', array('@identifier' => $context->identifier));
|
||||
}
|
@@ -16,8 +16,8 @@ $plugin = array(
|
||||
'get child' => 'ctools_entity_field_value_ctools_access_get_child',
|
||||
'get children' => 'ctools_entity_field_value_ctools_access_get_children',
|
||||
);
|
||||
function ctools_entity_field_value_ctools_access_get_child($plugin, $parent, $child) {
|
||||
|
||||
function ctools_entity_field_value_ctools_access_get_child($plugin, $parent, $child) {
|
||||
$plugins = &drupal_static(__FUNCTION__, array());
|
||||
if (empty($plugins[$parent . ':' . $child])) {
|
||||
list($entity_type, $bundle_type, $field_name) = explode(':', $child);
|
||||
@@ -48,7 +48,6 @@ function ctools_entity_field_value_ctools_access_get_children($plugin, $parent)
|
||||
}
|
||||
|
||||
function _ctools_entity_field_value_ctools_access_get_child($plugin, $parent, $entity_type, $bundle_type, $field_name, $entity = NULL, $bundle = NULL, $field = NULL) {
|
||||
|
||||
// check that the entity, bundle and field arrays have a value.
|
||||
// If not, load theme using machine names.
|
||||
if (empty($entity)) {
|
||||
@@ -86,12 +85,34 @@ function ctools_entity_field_value_ctools_access_settings($form, &$form_state, $
|
||||
$instance = $instances[$field_name];
|
||||
$field = field_info_field_by_id($instance['field_id']);
|
||||
foreach ($field['columns'] as $column => $attributes) {
|
||||
$columns[] = _field_sql_storage_columnname($field_name, $column);
|
||||
$columns[$column] = _field_sql_storage_columnname($field_name, $column);
|
||||
}
|
||||
ctools_include('fields');
|
||||
$entity = (object)array(
|
||||
$entity_info['entity keys']['bundle'] => $bundle_type,
|
||||
);
|
||||
|
||||
foreach ($columns as $column => $sql_column) {
|
||||
if (isset($conf[$sql_column])) {
|
||||
if (is_array($conf[$sql_column])) {
|
||||
foreach ($conf[$sql_column] as $delta => $conf_value) {
|
||||
if (is_numeric($delta)) {
|
||||
if (is_array($conf_value)) {
|
||||
$entity->{$field_name}[LANGUAGE_NONE][$delta][$column] = $conf_value[$column];
|
||||
}
|
||||
else {
|
||||
$entity->{$field_name}[LANGUAGE_NONE][$delta][$column] = $conf_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$entity->{$field_name}[LANGUAGE_NONE][0][$column] = $conf[$sql_column];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$form['#parents'] = array('settings');
|
||||
$langcode = field_valid_language(NULL);
|
||||
$form['settings'] += (array) ctools_field_invoke_field($instance, 'form', $entity_type, $entity, $form, $form_state, array('default' => TRUE, 'language' => $langcode));
|
||||
// weight is really not important once this is populated and will only interfere with the form layout.
|
||||
@@ -99,26 +120,9 @@ function ctools_entity_field_value_ctools_access_settings($form, &$form_state, $
|
||||
unset($form['settings'][$element]['#weight']);
|
||||
}
|
||||
|
||||
// Need more logic here to handle compound fields.
|
||||
foreach ($columns as $column) {
|
||||
if (isset($conf[$column]) && is_array($conf[$column])) {
|
||||
foreach ($conf[$column] as $delta => $conf_value) {
|
||||
if (is_numeric($delta) && is_array($conf_value)) {
|
||||
$form['settings'][$field_name][LANGUAGE_NONE][$delta]['value']['#default_value'] = $conf_value['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$form['settings'][$field_name][LANGUAGE_NONE]['#default_value'] = $conf[$column];
|
||||
}
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compress the entity bundles allowed to the minimum.
|
||||
*/
|
||||
function ctools_entity_field_value_ctools_access_settings_submit($form, &$form_state) {
|
||||
$plugin = $form_state['plugin'];
|
||||
list($parent, $entity_type, $bundle_type, $field_name) = explode(':', $plugin['name']);
|
||||
@@ -128,17 +132,82 @@ function ctools_entity_field_value_ctools_access_settings_submit($form, &$form_s
|
||||
$instance = $instances[$field_name];
|
||||
$field = field_info_field_by_id($instance['field_id']);
|
||||
foreach ($field['columns'] as $column => $attributes) {
|
||||
$columns[] = _field_sql_storage_columnname($field_name, $column);
|
||||
$columns[$column] = _field_sql_storage_columnname($field_name, $column);
|
||||
}
|
||||
$items = _ctools_entity_field_value_get_proper_form_items($field, $form_state['values']['settings'][$field_name][$langcode], array_keys($columns));
|
||||
foreach ($columns as $column => $sql_column) {
|
||||
$column_items = _ctools_entity_field_value_filter_items_by_column($items, $column);
|
||||
$form_state['values']['settings'][$sql_column] = $column_items;
|
||||
}
|
||||
$form_state['values']['settings'][$field_name][$langcode] = $items;
|
||||
}
|
||||
|
||||
function _ctools_entity_field_value_get_proper_form_items($field, $form_items, $columns) {
|
||||
$items = array();
|
||||
|
||||
if (!is_array($form_items)) { // Single value item.
|
||||
foreach ($columns as $column) {
|
||||
$items[0][$column] = $form_items;
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
foreach ($form_items as $delta => $value) {
|
||||
$item = array();
|
||||
if (is_numeric($delta)) { // Array of field values.
|
||||
if (!is_array($value)) { // Single value in array.
|
||||
foreach ($columns as $column) {
|
||||
$item[$column] = $value;
|
||||
}
|
||||
}
|
||||
else { // Value has colums.
|
||||
foreach ($columns as $column) {
|
||||
$item[$column] = isset($value[$column]) ? $value[$column] : '';
|
||||
}
|
||||
}
|
||||
}
|
||||
$items[] = $item;
|
||||
}
|
||||
|
||||
// Check if $form_items is an array of columns.
|
||||
$item = array();
|
||||
$has_columns = FALSE;
|
||||
foreach ($columns as $column) {
|
||||
$form_state['values']['settings'][$column] = $form_state['input']['settings'][$field_name][$langcode];
|
||||
if (isset($form_items[$column])) {
|
||||
$has_columns = TRUE;
|
||||
$item[$column] = $form_items[$column];
|
||||
}
|
||||
else {
|
||||
$item[$column] = '';
|
||||
}
|
||||
}
|
||||
if ($has_columns) {
|
||||
$items[] = $item;
|
||||
}
|
||||
|
||||
// Remove empty values.
|
||||
$items = _field_filter_items($field, $items);
|
||||
return $items;
|
||||
}
|
||||
|
||||
function _ctools_entity_field_value_filter_items_by_column($items, $column) {
|
||||
$column_items = array();
|
||||
foreach ($items as $delta => $values) {
|
||||
$column_items[$delta] = isset($values[$column]) ? $values[$column] : '';
|
||||
}
|
||||
return $column_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for access.
|
||||
*/
|
||||
function ctools_entity_field_value_ctools_access_check($conf, $context, $plugin) {
|
||||
if ((!is_object($context)) || (empty($context->data))) {
|
||||
// If the context doesn't exist -- for example, a newly added entity
|
||||
// reference is used as a pane visibility criteria -- we deny access.
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
list($parent, $entity_type, $bundle_type, $field_name) = explode(':', $plugin['name']);
|
||||
|
||||
if ($field_items = field_get_items($entity_type, $context->data, $field_name)) {
|
||||
@@ -160,16 +229,27 @@ function ctools_entity_field_value_ctools_access_check($conf, $context, $plugin)
|
||||
|
||||
// Check field value.
|
||||
foreach ($field_items as $field_value) {
|
||||
foreach ($field_value as $field_column => $value) {
|
||||
// Iterate through config values.
|
||||
foreach ($conf_value_array as $conf_value) {
|
||||
// Iterate through config values.
|
||||
foreach ($conf_value_array as $conf_value) {
|
||||
$match = FALSE;
|
||||
foreach ($field_value as $field_column => $value) {
|
||||
// Check access only for stored in config column values.
|
||||
if (isset($conf_value[$field_column]) && $value == $conf_value[$field_column]) {
|
||||
return TRUE;
|
||||
if (isset($conf_value[$field_column])) {
|
||||
if ($value == $conf_value[$field_column]) {
|
||||
$match = TRUE;
|
||||
}
|
||||
else {
|
||||
$match = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($match) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +258,7 @@ function ctools_entity_field_value_ctools_access_check($conf, $context, $plugin)
|
||||
|
||||
function _ctools_entity_field_value_ctools_access_get_conf_field_values($values, $langcode = LANGUAGE_NONE) {
|
||||
if (!is_array($values) || !isset($values[$langcode])) {
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
$conf_values = array();
|
||||
|
||||
@@ -201,41 +281,130 @@ function ctools_entity_field_value_ctools_access_summary($conf, $context, $plugi
|
||||
$entity = (object)array(
|
||||
$entity_info['entity keys']['bundle'] => $bundle_type,
|
||||
);
|
||||
$string = '';
|
||||
$keys = array();
|
||||
$values = array();
|
||||
$value_keys = array();
|
||||
$keyed_elements = array();
|
||||
foreach ($field['columns'] as $column => $attributes) {
|
||||
$conf_key = _field_sql_storage_columnname($field_name, $column);
|
||||
if (count($field['columns']) > 1) {
|
||||
// Add some sort of handling for compound fields
|
||||
}
|
||||
else {
|
||||
if (isset($conf[$conf_key])) {
|
||||
$entity->{$field_name}[LANGUAGE_NONE][] = array($column => $conf[$conf_key]);
|
||||
$keyed_elements["@{$column}_value"] = array();
|
||||
|
||||
if (isset($conf[$conf_key])) {
|
||||
if (is_array($conf[$conf_key])) {
|
||||
$i = 0;
|
||||
foreach ($conf[$conf_key] as $conf_value) {
|
||||
if (!is_array($conf_value)) {
|
||||
$entity->{$field_name}[LANGUAGE_NONE][$i][$column] = $conf_value;
|
||||
$keyed_elements["@{$column}_value"][$i] = array('#markup' => $conf_value);
|
||||
}
|
||||
elseif (isset($conf_value[$column])) {
|
||||
$entity->{$field_name}[LANGUAGE_NONE][$i][$column] = $conf_value[$column];
|
||||
$keyed_elements["@{$column}_value"][$i] = array('#markup' => $conf_value[$column]);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$entity->{$field_name}[LANGUAGE_NONE][0][$column] = $conf[$conf_key];
|
||||
$keyed_elements["@{$column}_value"][0] = array('#markup' => $conf[$conf_key]);
|
||||
}
|
||||
}
|
||||
$string .= " @{$column} equals @{$column}_value";
|
||||
$keys['@' . $column] = $column;
|
||||
$values["@{$column}_value"] = $conf[$conf_key];
|
||||
}
|
||||
$view_mode = 'full';
|
||||
$null = NULL;
|
||||
$options = array('language' => LANGUAGE_NONE);
|
||||
ctools_include('fields');
|
||||
$display = field_get_display($instance, $view_mode, $entity);
|
||||
if (isset($display['module'])) {
|
||||
$display['type'] = 'list_default';
|
||||
$function = $display['module'] . '_field_formatter_view';
|
||||
$items = isset($entity->{$field_name}[LANGUAGE_NONE]) ? $entity->{$field_name}[LANGUAGE_NONE] : array();
|
||||
if (function_exists($function)) {
|
||||
$elements = $function($entity_type, $entity, $field, $instance, LANGUAGE_NONE, $items, $display);
|
||||
}
|
||||
$value_keys = array_keys($values);
|
||||
foreach ($value_keys as $key => $value) {
|
||||
$values[$value] = isset($elements[$key]['#markup']) ? $elements[$key]['#markup'] : '';
|
||||
}
|
||||
}
|
||||
$values = array_merge($keys, $values);
|
||||
return t($string, $values);
|
||||
}
|
||||
|
||||
$keys['@' . $column] = $column;
|
||||
$value_keys[] = "@{$column}_value";
|
||||
}
|
||||
$elements = array();
|
||||
$items = isset($entity->{$field_name}[LANGUAGE_NONE]) ? $entity->{$field_name}[LANGUAGE_NONE] : array();
|
||||
$view_mode = 'full';
|
||||
ctools_include('fields');
|
||||
$display = field_get_display($instance, $view_mode, $entity);
|
||||
if (!isset($display['module'])) {
|
||||
$display['module'] = $field['module'];
|
||||
}
|
||||
if (isset($display['module'])) {
|
||||
// Choose simple formatter for well known cases.
|
||||
switch ($display['module']) {
|
||||
case 'text':
|
||||
$display['type'] = 'text_default';
|
||||
break;
|
||||
|
||||
case 'list':
|
||||
$display['type'] = 'list_default';
|
||||
if ($field['type'] == 'list_boolean') {
|
||||
$allowed_values = list_allowed_values($field, $instance, $entity_type, $entity);
|
||||
foreach ($items as $item) {
|
||||
if (isset($allowed_values[$item['value']])) {
|
||||
if ($allowed_values[$item['value']] == '') {
|
||||
$display['type'] = 'list_key';
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$display['type'] = 'list_key';
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'taxonomy':
|
||||
$display['type'] = 'taxonomy_term_reference_plain';
|
||||
break;
|
||||
|
||||
case 'entityreference':
|
||||
$display['type'] = 'entityreference_label';
|
||||
break;
|
||||
|
||||
default :
|
||||
// Use field instance formatter setting.
|
||||
break;
|
||||
}
|
||||
|
||||
$function = $display['module'] . '_field_formatter_view';
|
||||
if (function_exists($function)) {
|
||||
$entity_group = array(0 => $entity);
|
||||
$item_group = array(0 => $items);
|
||||
$instance_group = array(0 => $instance);
|
||||
field_default_prepare_view($entity_type, $entity_group, $field, $instance_group, LANGUAGE_NONE, $item_group, $display);
|
||||
$elements = $function($entity_type, $entity, $field, $instance, LANGUAGE_NONE, $item_group[0], $display);
|
||||
}
|
||||
}
|
||||
if (count($elements) > 0) {
|
||||
foreach ($field['columns'] as $column => $attributes) {
|
||||
if (count($field['columns']) == 1) {
|
||||
$keyed_elements["@{$column}_value"] = $elements;
|
||||
}
|
||||
}
|
||||
}
|
||||
$values = array();
|
||||
foreach ($value_keys as $key) {
|
||||
$output = array();
|
||||
$elements = $keyed_elements[$key];
|
||||
if (is_array($elements)) {
|
||||
foreach ($elements as $element_key => $element) {
|
||||
if (is_numeric($element_key)) {
|
||||
$value_str= strip_tags(drupal_render($element));
|
||||
if (strlen($value_str) > 0) {
|
||||
$output[] = $value_str;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$value_str = strip_tags(drupal_render($elements));
|
||||
if (strlen($value_str) > 0) {
|
||||
$output[] = $value_str;
|
||||
}
|
||||
}
|
||||
$value = implode(', ', $output);
|
||||
if ($value !== '') {
|
||||
$values[$key] = implode(', ', $output);
|
||||
}
|
||||
}
|
||||
$string = '';
|
||||
$value_count = count($values);
|
||||
foreach ($keys as $key_name => $column) {
|
||||
if (isset($values[$key_name . '_value'])) {
|
||||
$string .= ($value_count > 1) ? " @{$column} = @{$column}_value" : "@{$column}_value";
|
||||
}
|
||||
}
|
||||
return t('@field is set to "!value"', array('@field' => $instance['label'], '!value' => format_string($string, array_merge($keys, $values))));
|
||||
}
|
||||
|
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Plugin to provide access control based upon node comment status.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
*/
|
||||
$plugin = array(
|
||||
'title' => t("Node: comments are open"),
|
||||
'description' => t('Control access by the nodes comment status.'),
|
||||
'callback' => 'ctools_node_comment_ctools_access_check',
|
||||
'summary' => 'ctools_node_comment_ctools_access_summary',
|
||||
'required context' => new ctools_context_required(t('Node'), 'node'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Checks for access.
|
||||
*/
|
||||
function ctools_node_comment_ctools_access_check($conf, $context) {
|
||||
return (!empty($context->data) && $context->data->comment == 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a summary description based upon the checked node_status.
|
||||
*/
|
||||
function ctools_node_comment_ctools_access_summary($conf, $context) {
|
||||
return t('Returns true if the nodes comment status is "open".');
|
||||
}
|
@@ -59,7 +59,7 @@ function ctools_string_length_ctools_access_check($conf, $context) {
|
||||
return $length < $conf['length'];
|
||||
case '<=':
|
||||
return $length <= $conf['length'];
|
||||
case '==':
|
||||
case '=':
|
||||
return $length == $conf['length'];
|
||||
case '!=':
|
||||
return $length != $conf['length'];
|
||||
@@ -68,6 +68,8 @@ function ctools_string_length_ctools_access_check($conf, $context) {
|
||||
case '>=':
|
||||
return $length >= $conf['length'];
|
||||
}
|
||||
// Invalid Operator sent, return FALSE.
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -17,7 +17,11 @@ $plugin = array(
|
||||
'settings form' => 'ctools_term_vocabulary_ctools_access_settings',
|
||||
'settings form submit' => 'ctools_term_vocabulary_ctools_access_settings_submit',
|
||||
'summary' => 'ctools_term_vocabulary_ctools_access_summary',
|
||||
'required context' => new ctools_context_required(t('Vocabulary'), array('taxonomy_term', 'terms', 'taxonomy_vocabulary')),
|
||||
'required context' => new ctools_context_required(t('Vocabulary'), array(
|
||||
'taxonomy_term',
|
||||
'terms',
|
||||
'taxonomy_vocabulary'
|
||||
)),
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -27,15 +31,17 @@ function ctools_term_vocabulary_ctools_access_settings($form, &$form_state, $con
|
||||
$options = array();
|
||||
$vocabularies = taxonomy_get_vocabularies();
|
||||
foreach ($vocabularies as $voc) {
|
||||
$options[$voc->vid] = check_plain($voc->name);
|
||||
$options[$voc->machine_name] = check_plain($voc->name);
|
||||
}
|
||||
|
||||
$form['settings']['vids'] = array(
|
||||
_ctools_term_vocabulary_ctools_access_map_vids($conf);
|
||||
|
||||
$form['settings']['machine_name'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Vocabularies'),
|
||||
'#options' => $options,
|
||||
'#description' => t('Only the checked vocabularies will be valid.'),
|
||||
'#default_value' => $conf['vids'],
|
||||
'#default_value' => $conf['machine_name'],
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
@@ -44,7 +50,7 @@ function ctools_term_vocabulary_ctools_access_settings($form, &$form_state, $con
|
||||
* Compress the term_vocabularys allowed to the minimum.
|
||||
*/
|
||||
function ctools_term_vocabulary_ctools_access_settings_submit($form, &$form_state) {
|
||||
$form_state['values']['settings']['vids'] = array_filter($form_state['values']['settings']['vids']);
|
||||
$form_state['values']['settings']['machine_name'] = array_filter($form_state['values']['settings']['machine_name']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,11 +59,13 @@ function ctools_term_vocabulary_ctools_access_settings_submit($form, &$form_stat
|
||||
function ctools_term_vocabulary_ctools_access_check($conf, $context) {
|
||||
// As far as I know there should always be a context at this point, but this
|
||||
// is safe.
|
||||
if (empty($context) || empty($context->data) || empty($context->data->vid)) {
|
||||
if (empty($context) || empty($context->data) || empty($context->data->vocabulary_machine_name)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (array_filter($conf['vids']) && empty($conf['vids'][$context->data->vid])) {
|
||||
_ctools_term_vocabulary_ctools_access_map_vids($conf);
|
||||
|
||||
if (array_filter($conf['machine_name']) && empty($conf['machine_name'][$context->data->vocabulary_machine_name])) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -73,15 +81,47 @@ function ctools_term_vocabulary_ctools_access_summary($conf, $context) {
|
||||
}
|
||||
$vocabularies = taxonomy_get_vocabularies();
|
||||
|
||||
_ctools_term_vocabulary_ctools_access_map_vids($conf);
|
||||
|
||||
$names = array();
|
||||
foreach (array_filter($conf['vids']) as $vid) {
|
||||
$names[] = check_plain($vocabularies[$vid]->name);
|
||||
if (!empty($conf['machine_name'])) {
|
||||
foreach (array_filter($conf['machine_name']) as $machine_name) {
|
||||
foreach ($vocabularies as $vocabulary) {
|
||||
if ($vocabulary->machine_name === $machine_name) {
|
||||
$names[] = check_plain($vocabulary->name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($names)) {
|
||||
return t('@identifier is any vocabulary', array('@identifier' => $context->identifier));
|
||||
}
|
||||
|
||||
return format_plural(count($names), '@identifier vocabulary is "@vids"', '@identifier vocabulary is one of "@vids"', array('@vids' => implode(', ', $names), '@identifier' => $context->identifier));
|
||||
return format_plural(count($names), '@identifier vocabulary is "@machine_names"', '@identifier vocabulary is one of "@machine_names"', array(
|
||||
'@machine_names' => implode(', ', $names),
|
||||
'@identifier' => $context->identifier
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to map the vids from old features to the new machine_name.
|
||||
*
|
||||
* Add the machine_name key to $conf if the vids key exist.
|
||||
*
|
||||
* @param array $conf
|
||||
* The configuration of this plugin.
|
||||
*/
|
||||
function _ctools_term_vocabulary_ctools_access_map_vids(&$conf) {
|
||||
if (!empty($conf['vids'])) {
|
||||
$conf['machine_name'] = array();
|
||||
$vocabularies = taxonomy_get_vocabularies();
|
||||
foreach ($conf['vids'] as $vid) {
|
||||
$machine_name = $vocabularies[$vid]->machine_name;
|
||||
$conf['machine_name'][$machine_name] = $vocabularies[$vid]->machine_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Plugin to provide an argument handler for all entity ids
|
||||
* Plugin to provide an argument handler for all entity ids.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -16,6 +16,10 @@ $plugin = array(
|
||||
'context' => 'ctools_argument_entity_id_context',
|
||||
'get child' => 'ctools_argument_entity_id_get_child',
|
||||
'get children' => 'ctools_argument_entity_id_get_children',
|
||||
'default' => array(
|
||||
'entity_id' => '',
|
||||
),
|
||||
'placeholder form' => 'ctools_argument_entity_id_ctools_argument_placeholder',
|
||||
);
|
||||
|
||||
function ctools_argument_entity_id_get_child($plugin, $parent, $child) {
|
||||
@@ -37,6 +41,7 @@ function ctools_argument_entity_id_get_children($original_plugin, $parent) {
|
||||
$plugins[$plugin_id] = $plugin;
|
||||
}
|
||||
drupal_alter('ctools_entity_contexts', $plugins);
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
@@ -56,15 +61,87 @@ function ctools_argument_entity_id_context($arg = NULL, $conf = NULL, $empty = F
|
||||
return ctools_context_create('entity:' . $entity_type, $arg);
|
||||
}
|
||||
|
||||
// Trim spaces and other garbage.
|
||||
$arg = trim($arg);
|
||||
|
||||
if (!is_numeric($arg)) {
|
||||
$preg_matches = array();
|
||||
$match = preg_match('/\[id: (\d+)\]/', $arg, $preg_matches);
|
||||
if (!$match) {
|
||||
$match = preg_match('/^id: (\d+)/', $arg, $preg_matches);
|
||||
}
|
||||
|
||||
if ($match) {
|
||||
$id = $preg_matches[1];
|
||||
}
|
||||
if (isset($id) && is_numeric($id)) {
|
||||
return ctools_context_create('entity:' . $entity_type, $id);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$entity = entity_load($entity_type, array($arg));
|
||||
if (!$entity) {
|
||||
$entities = entity_load($entity_type, array($arg));
|
||||
if (empty($entities)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return ctools_context_create('entity:' . $entity_type, $entity[$arg]);
|
||||
return ctools_context_create('entity:' . $entity_type, reset($entities));
|
||||
}
|
||||
|
||||
function ctools_argument_entity_id_settings_form(&$form, &$form_state, $conf) {
|
||||
$plugin = &$form_state['plugin'];
|
||||
|
||||
$form['settings']['entity'] = array(
|
||||
'#title' => t('Enter the title or ID of a @entity entity', array('@entity' => $plugin['keyword'])),
|
||||
'#type' => 'textfield',
|
||||
'#maxlength' => 512,
|
||||
'#autocomplete_path' => 'ctools/autocomplete/' . $plugin['keyword'],
|
||||
'#weight' => -10,
|
||||
);
|
||||
|
||||
if (!empty($conf['entity_id'])) {
|
||||
$info = entity_load($plugin['keyword'], array($conf['entity_id']));
|
||||
$info = $info[$conf['entity_id']];
|
||||
if ($info) {
|
||||
$entity = entity_get_info($plugin['keyword']);
|
||||
$uri = entity_uri($plugin['keyword'], $info);
|
||||
if (is_array($uri) && $entity['entity keys']['label']) {
|
||||
$link = l(t("'%title' [%type id %id]", array('%title' => $info->{$entity['entity keys']['label']}, '%type' => $plugin['keyword'], '%id' => $conf['entity_id'])), $uri['path'], array('attributes' => array('target' => '_blank', 'title' => t('Open in new window')), 'html' => TRUE));
|
||||
}
|
||||
elseif (is_array($uri)) {
|
||||
$link = l(t("[%type id %id]", array('%type' => $plugin['keyword'], '%id' => $conf['entity_id'])), $uri['path'], array('attributes' => array('target' => '_blank', 'title' => t('Open in new window')), 'html' => TRUE));
|
||||
}
|
||||
elseif ($entity['entity keys']['label']) {
|
||||
$link = l(t("'%title' [%type id %id]", array('%title' => $info->{$entity['entity keys']['label']}, '%type' => $plugin['keyword'], '%id' => $conf['entity_id'])), file_create_url($uri), array('attributes' => array('target' => '_blank', 'title' => t('Open in new window')), 'html' => TRUE));
|
||||
}
|
||||
else {
|
||||
$link = t("[%type id %id]", array('%type' => $plugin['keyword'], '%id' => $conf['entity_id']));
|
||||
}
|
||||
$form['settings']['entity']['#description'] = t('Currently set to !link', array('!link' => $link));
|
||||
}
|
||||
}
|
||||
|
||||
$form['settings']['entity_id'] = array(
|
||||
'#type' => 'value',
|
||||
'#value' => isset($conf['entity_id']) ? $conf['entity_id'] : '',
|
||||
);
|
||||
|
||||
$form['settings']['entity_type'] = array(
|
||||
'#type' => 'value',
|
||||
'#value' => $plugin['keyword'],
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function ctools_argument_entity_id_ctools_argument_placeholder($conf) {
|
||||
$conf = array(
|
||||
'#title' => t('Enter the title or ID of a @entity entity', array('@entity' => $conf['keyword'])),
|
||||
'#type' => 'textfield',
|
||||
'#maxlength' => 512,
|
||||
'#autocomplete_path' => 'ctools/autocomplete/' . $conf['keyword'],
|
||||
'#weight' => -10,
|
||||
);
|
||||
|
||||
return $conf;
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ function ctools_argument_rid_context($arg = NULL, $conf = NULL, $empty = FALSE)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$nid = db_query('SELECT nid FROM {node_revisions} WHERE vid = :vid', array(':vid' => $arg))->fetchField();
|
||||
$nid = db_query('SELECT nid FROM {node_revision} WHERE vid = :vid', array(':vid' => $arg))->fetchField();
|
||||
$node = node_load($nid, $arg);
|
||||
if (!$node) {
|
||||
return FALSE;
|
||||
|
39
sites/all/modules/contrib/dev/ctools/plugins/cache/export_ui.inc
vendored
Normal file
39
sites/all/modules/contrib/dev/ctools/plugins/cache/export_ui.inc
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* A caching mechanism for use with subsystems that use the export ui.
|
||||
*/
|
||||
|
||||
$plugin = array(
|
||||
// cache plugins are the rare plugin types that have no real UI but
|
||||
// we're providing a title just in case.
|
||||
'title' => t('Export UI wizard cache'),
|
||||
'cache get' => 'ctools_cache_export_ui_cache_get',
|
||||
'cache set' => 'ctools_cache_export_ui_cache_set',
|
||||
// Some operations use a 'finalize' but that really just means set
|
||||
// for us, since we're not using temporary storage for subsystems.
|
||||
'cache finalize' => 'ctools_cache_export_ui_cache_set',
|
||||
);
|
||||
|
||||
function ctools_cache_export_ui_cache_get($plugin_name, $key) {
|
||||
ctools_include('export-ui');
|
||||
$plugin = ctools_get_export_ui($plugin_name);
|
||||
$handler = ctools_export_ui_get_handler($plugin);
|
||||
if ($handler) {
|
||||
$item = $handler->edit_cache_get($key);
|
||||
if (!$item) {
|
||||
$item = ctools_export_crud_load($handler->plugin['schema'], $key);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
|
||||
function ctools_cache_export_ui_cache_set($plugin_name, $key, $item) {
|
||||
ctools_include('export-ui');
|
||||
$plugin = ctools_get_export_ui($plugin_name);
|
||||
$handler = ctools_export_ui_get_handler($plugin);
|
||||
if ($handler) {
|
||||
return $handler->edit_cache_set_key($item, $key);
|
||||
}
|
||||
}
|
51
sites/all/modules/contrib/dev/ctools/plugins/cache/simple.inc
vendored
Normal file
51
sites/all/modules/contrib/dev/ctools/plugins/cache/simple.inc
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* A simple cache indirection mechanism that just uses the basic object cache.
|
||||
*/
|
||||
|
||||
$plugin = array(
|
||||
// cache plugins are the rare plugin types that have no real UI but
|
||||
// we're providing a title just in case.
|
||||
'title' => t('Simple'),
|
||||
'cache get' => 'ctools_cache_simple_cache_get',
|
||||
'cache set' => 'ctools_cache_simple_cache_set',
|
||||
'cache clear' => 'ctools_cache_simple_cache_clear',
|
||||
);
|
||||
|
||||
function ctools_cache_simple_cache_get($data, $key) {
|
||||
ctools_include('object-cache');
|
||||
|
||||
// Ensure that if there is somehow no data, we at least don't stomp on other
|
||||
// people's caches.
|
||||
if (empty($data)) {
|
||||
$data = 'simple_cache_plugin';
|
||||
}
|
||||
|
||||
return ctools_object_cache_get($data, $key);
|
||||
}
|
||||
|
||||
function ctools_cache_simple_cache_set($data, $key, $object) {
|
||||
ctools_include('object-cache');
|
||||
|
||||
// Ensure that if there is somehow no data, we at least don't stomp on other
|
||||
// people's caches.
|
||||
if (empty($data)) {
|
||||
$data = 'simple_cache_plugin';
|
||||
}
|
||||
|
||||
return ctools_object_cache_set($data, $key, $object);
|
||||
}
|
||||
|
||||
function ctools_cache_simple_cache_clear($data, $key) {
|
||||
ctools_include('object-cache');
|
||||
|
||||
// Ensure that if there is somehow no data, we at least don't stomp on other
|
||||
// people's caches.
|
||||
if (empty($data)) {
|
||||
$data = 'simple_cache_plugin';
|
||||
}
|
||||
|
||||
return ctools_object_cache_clear($data, $key);
|
||||
}
|
@@ -40,6 +40,11 @@ function ctools_block_content_type_content_type($subtype_id) {
|
||||
* of the form "$module . '_ctools_block_info'".
|
||||
*/
|
||||
function ctools_block_content_type_content_types() {
|
||||
$types = &drupal_static(__FUNCTION__);
|
||||
if (isset($types)) {
|
||||
return $types;
|
||||
}
|
||||
|
||||
$types = array();
|
||||
foreach (module_implements('block_info') as $module) {
|
||||
$module_blocks = module_invoke($module, 'block_info');
|
||||
@@ -143,27 +148,32 @@ function ctools_block_content_type_render($subtype, $conf) {
|
||||
$block = module_invoke($module, 'block_view', $delta);
|
||||
|
||||
if (!empty($info)) {
|
||||
// Valid PHP function names cannot contain hyphens.
|
||||
$block_delta = str_replace('-', '_', $delta);
|
||||
|
||||
// Allow modules to modify the block before it is viewed, via either
|
||||
// hook_block_view_alter() or hook_block_view_MODULE_DELTA_alter().
|
||||
drupal_alter(array('block_view', "block_view_{$module}_{$delta}"), $block, $info);
|
||||
drupal_alter(array('block_view', "block_view_{$module}_{$block_delta}"), $block, $info);
|
||||
}
|
||||
$block = (object) $block;
|
||||
|
||||
if (empty($block)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$block = (object) $block;
|
||||
$block->module = $module;
|
||||
$block->delta = $delta;
|
||||
|
||||
if ($module == 'block' && !empty($info) && isset($info->title)) {
|
||||
$block->title = $info->title;
|
||||
}
|
||||
else if (isset($block->subject)) {
|
||||
$block->title = $block->subject;
|
||||
}
|
||||
else {
|
||||
$block->title = NULL;
|
||||
if (!isset($block->title)) {
|
||||
if ($module == 'block' && !empty($info) && isset($info->title)) {
|
||||
$block->title = $info->title;
|
||||
}
|
||||
else if (isset($block->subject)) {
|
||||
$block->title = $block->subject;
|
||||
}
|
||||
else {
|
||||
$block->title = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (module_exists('block') && user_access('administer blocks')) {
|
||||
@@ -286,13 +296,18 @@ function ctools_block_content_type_admin_info($subtype, $conf) {
|
||||
list($module, $delta) = _ctools_block_get_module_delta($subtype, $conf);
|
||||
$block = (object) module_invoke($module, 'block_view', $delta);
|
||||
|
||||
// Sanitize the block because <script> tags can hose javascript up:
|
||||
if (!empty($block->content)) {
|
||||
$block->content = filter_xss_admin($block->content);
|
||||
}
|
||||
if (!empty($block)) {
|
||||
// Sanitize the block because <script> tags can hose javascript up:
|
||||
if (!empty($block->content)) {
|
||||
$block->content = filter_xss_admin(render($block->content));
|
||||
}
|
||||
|
||||
if (!empty($block) && !empty($block->subject)) {
|
||||
$block->title = $block->subject;
|
||||
if (!empty($block->subject)) {
|
||||
$block->title = $block->subject;
|
||||
}
|
||||
elseif (empty($block->title)) {
|
||||
$block->title = t('No title');
|
||||
}
|
||||
return $block;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
*/
|
||||
$plugin = array(
|
||||
'single' => TRUE,
|
||||
'title' => t('Comment links'),
|
||||
'icon' => 'icon_comment.png',
|
||||
'description' => t('Comment links of the referenced comment.'),
|
||||
'required context' => new ctools_context_required(t('Comment'), 'entity:comment'),
|
||||
'category' => t('Comment'),
|
||||
'defaults' => array(
|
||||
'override_title' => FALSE,
|
||||
'override_title_text' => '',
|
||||
'build_mode' => '',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Output function for the comment links.
|
||||
*/
|
||||
function ctools_comment_links_content_type_render($subtype, $conf, $panel_args, $context) {
|
||||
if (!empty($context) && empty($context->data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$comment = isset($context->data) ? clone($context->data) : NULL;
|
||||
$block = new stdClass();
|
||||
$block->module = 'comment';
|
||||
$block->delta = $comment->cid;
|
||||
|
||||
if (empty($comment)) {
|
||||
$block->delta = 'placeholder';
|
||||
$block->subject = t('Comment subject.');
|
||||
$block->content = t('Comment links go here.');
|
||||
}
|
||||
else {
|
||||
$node = node_load($comment->nid);
|
||||
$block->subject = $comment->subject;
|
||||
comment_build_content($comment, $node, $conf['build_mode']);
|
||||
$block->content = $comment->content['links'];
|
||||
}
|
||||
return $block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an edit form for the custom type.
|
||||
*/
|
||||
function ctools_comment_links_content_type_edit_form($form, &$form_state) {
|
||||
$conf = $form_state['conf'];
|
||||
|
||||
$entity = entity_get_info('comment');
|
||||
$build_mode_options = array();
|
||||
foreach ($entity['view modes'] as $mode => $option) {
|
||||
$build_mode_options[$mode] = $option['label'];
|
||||
}
|
||||
|
||||
$form['build_mode'] = array(
|
||||
'#title' => t('Build mode'),
|
||||
'#type' => 'select',
|
||||
'#description' => t('Select a build mode for this comment.'),
|
||||
'#options' => $build_mode_options,
|
||||
'#default_value' => $conf['build_mode'],
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function ctools_comment_links_content_type_edit_form_submit($form, &$form_state) {
|
||||
// Copy everything from our defaults.
|
||||
foreach (array_keys($form_state['plugin']['defaults']) as $key) {
|
||||
$form_state['conf'][$key] = $form_state['values'][$key];
|
||||
}
|
||||
}
|
||||
|
||||
function ctools_comment_links_content_type_admin_title($subtype, $conf, $context) {
|
||||
return t('"@s" links', array('@s' => $context->identifier));
|
||||
}
|
@@ -25,7 +25,7 @@ if (module_exists('comment')) {
|
||||
|
||||
function ctools_comment_reply_form_content_type_render($subtype, $conf, $panel_args, $context) {
|
||||
|
||||
$comment = ($context[1]->identifier == 'No context') ? NULL : clone($context[1]->data);
|
||||
$comment = ($context[1]->identifier == t('No context')) ? NULL : clone($context[1]->data);
|
||||
$block = new stdClass();
|
||||
$block->module = 'comments';
|
||||
if ($comment) $block->delta = $comment->cid;
|
||||
|
@@ -45,6 +45,11 @@ function ctools_custom_content_type_content_type($subtype_id) {
|
||||
* Return all custom content types available.
|
||||
*/
|
||||
function ctools_custom_content_type_content_types() {
|
||||
$types = &drupal_static(__FUNCTION__);
|
||||
if (isset($types)) {
|
||||
return $types;
|
||||
}
|
||||
|
||||
ctools_include('export');
|
||||
$types = array();
|
||||
$types['custom'] = _ctools_default_content_type_content_type();
|
||||
|
@@ -38,27 +38,33 @@ function ctools_entity_field_content_type_content_types() {
|
||||
$context_types = array();
|
||||
$entities = entity_get_info();
|
||||
|
||||
$description = t('Field on the referenced entity.');
|
||||
$styles = t('Formatter Styles');
|
||||
$categories = array();
|
||||
foreach ($entities as $entity_type => $entity) {
|
||||
$category = t(ucfirst($entity_type));
|
||||
$categories[$entity_type] = $category;
|
||||
foreach ($entity['bundles'] as $type => $bundle) {
|
||||
foreach (field_info_instances($entity_type, $type) as $field_name => $field) {
|
||||
if (!isset($types[$entity_type . ':' . $field_name])) {
|
||||
$label = t($field['label']);
|
||||
$types[$entity_type . ':' . $field_name] = array(
|
||||
'category' => t(ucfirst($entity_type)),
|
||||
'category' => $category,
|
||||
'icon' => 'icon_field.png',
|
||||
'title' => t('Field: @widget_label (@field_name)', array(
|
||||
'@widget_label' => t($field['label']),
|
||||
'@widget_label' => $label,
|
||||
'@field_name' => $field_name,
|
||||
)),
|
||||
'description' => t('Field on the referenced entity.'),
|
||||
'description' => $description,
|
||||
'edit form' => array(
|
||||
'ctools_entity_field_content_type_formatter_options' => array(
|
||||
'default' => TRUE,
|
||||
'title' => t('Formatter options for: @widget_label (@field_name)', array(
|
||||
'@widget_label' => t($field['label']),
|
||||
'@widget_label' => $label,
|
||||
'@field_name' => $field_name,
|
||||
)),
|
||||
),
|
||||
'ctools_entity_field_content_type_formatter_styles' => t('Formatter Styles'),
|
||||
'ctools_entity_field_content_type_formatter_styles' => $styles,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -70,7 +76,7 @@ function ctools_entity_field_content_type_content_types() {
|
||||
// Create the required context for each field related to the bundle types.
|
||||
foreach ($types as $key => $field_content_type) {
|
||||
list($entity_type, $field_name) = explode(':', $key, 2);
|
||||
$types[$key]['required context'] = new ctools_context_required(t(ucfirst($entity_type)), $entity_type, array(
|
||||
$types[$key]['required context'] = new ctools_context_required($categories[$entity_type], $entity_type, array(
|
||||
'type' => array_keys($context_types[$key]['types']),
|
||||
));
|
||||
unset($context_types[$key]['types']);
|
||||
@@ -112,6 +118,8 @@ function ctools_entity_field_content_type_render($subtype, $conf, $panel_args, $
|
||||
$field_settings = array(
|
||||
'label' => $label,
|
||||
'type' => $conf['formatter'],
|
||||
// Pass all entity field panes settings to field display settings.
|
||||
'pane_settings' => $conf,
|
||||
);
|
||||
|
||||
// Get the field output, and the title.
|
||||
@@ -121,33 +129,19 @@ function ctools_entity_field_content_type_render($subtype, $conf, $panel_args, $
|
||||
|
||||
$all_values = field_get_items($entity_type, $entity, $field_name, $language);
|
||||
if (!is_array($all_values)) {
|
||||
$all_values = array();
|
||||
// Do not render if the field is empty.
|
||||
return;
|
||||
}
|
||||
|
||||
// Reverse values.
|
||||
if (isset($conf['delta_reversed']) && $conf['delta_reversed']) {
|
||||
$all_values = array_reverse($all_values);
|
||||
$all_values = array_reverse($all_values, TRUE);
|
||||
}
|
||||
|
||||
if (isset($conf['delta_limit'])) {
|
||||
$delta_limit = $conf['delta_limit'];
|
||||
$offset = intval($conf['delta_offset']);
|
||||
$total = count($all_values);
|
||||
|
||||
if ($delta_limit == 0) {
|
||||
$delta_limit = $total - $offset;
|
||||
}
|
||||
|
||||
$new_values = array();
|
||||
for ($i = 0; $i < $delta_limit; $i++) {
|
||||
$new_delta = $offset + $i;
|
||||
|
||||
if (isset($all_values[$new_delta])) {
|
||||
$new_values[] = $all_values[$new_delta];
|
||||
}
|
||||
}
|
||||
|
||||
$all_values = $new_values;
|
||||
$limit = !empty($conf['delta_limit']) ? $conf['delta_limit'] : NULL;
|
||||
$all_values = array_slice($all_values, $offset, $limit, TRUE);
|
||||
}
|
||||
|
||||
$clone = clone $entity;
|
||||
@@ -257,10 +251,21 @@ function ctools_entity_field_content_type_formatter_styles_submit($form, &$form_
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the administrative title for a type.
|
||||
*/
|
||||
* Returns the administrative title for a type.
|
||||
*/
|
||||
function ctools_entity_field_content_type_admin_title($subtype, $conf, $context) {
|
||||
list($bundle, $field_name) = explode(':', $subtype);
|
||||
ctools_include('fields');
|
||||
return t('"@s" @field', array('@s' => $context->identifier, '@field' => ctools_field_label($field_name)));
|
||||
if (is_object($context) && isset($context->identifier)) {
|
||||
$identifier = $context->identifier;
|
||||
}
|
||||
else {
|
||||
$type = 'ctools_entity_field_content_type_admin_title';
|
||||
$message = t('Context is missing for field: @name', array('@name' => $subtype));
|
||||
$variables = array($subtype, $conf, $context);
|
||||
watchdog($type, $message, $variables, $severity = WATCHDOG_NOTICE);
|
||||
$identifier = t('Unknown');
|
||||
}
|
||||
|
||||
return t('"@s" @field', array('@s' => $identifier, '@field' => ctools_field_label($field_name)));
|
||||
}
|
||||
|
@@ -25,6 +25,11 @@ function ctools_entity_field_extra_content_type_content_type($subtype) {
|
||||
*/
|
||||
function ctools_entity_field_extra_content_type_content_types() {
|
||||
// This will hold all the individual field content types.
|
||||
$types = &drupal_static(__FUNCTION__);
|
||||
if (isset($types)) {
|
||||
return $types;
|
||||
}
|
||||
|
||||
$types = array();
|
||||
$context_types = array();
|
||||
$entities = entity_get_info();
|
||||
@@ -97,13 +102,20 @@ function ctools_entity_field_extra_content_type_render($subtype, $conf, $panel_a
|
||||
$entity = clone $context->data;
|
||||
list($entity_type, $field_name) = explode(':', $subtype, 2);
|
||||
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
|
||||
|
||||
// Invoke the view-hook to get the extra field.
|
||||
$entity->content = array();
|
||||
$langcode = $GLOBALS['language_content']->language;
|
||||
|
||||
module_invoke_all($entity_type . '_view', $entity, $conf['view_mode'], $langcode);
|
||||
module_invoke_all('entity_view', $entity, $entity_type, $conf['view_mode'], $langcode);
|
||||
$function = $entity_type . '_view';
|
||||
if (in_array($entity_type, array('node', 'taxonomy_term', 'user')) && function_exists($function)) {
|
||||
// Call known ENTITY_view() to get the extra field.
|
||||
$entity->content = $function($entity, $conf['view_mode'], $langcode);
|
||||
}
|
||||
else {
|
||||
// Invoke the view-hook to get the extra field.
|
||||
$entity->content = array();
|
||||
|
||||
module_invoke_all($entity_type . '_view', $entity, $conf['view_mode'], $langcode);
|
||||
module_invoke_all('entity_view', $entity, $entity_type, $conf['view_mode'], $langcode);
|
||||
}
|
||||
|
||||
if (isset($entity->content[$field_name])) {
|
||||
// Build the content type block.
|
||||
|
@@ -30,6 +30,11 @@ function ctools_entity_form_field_content_type_content_type($subtype) {
|
||||
*/
|
||||
function ctools_entity_form_field_content_type_content_types() {
|
||||
// This will hold all the individual field content types.
|
||||
$types = &drupal_static(__FUNCTION__);
|
||||
if (isset($types)) {
|
||||
return $types;
|
||||
}
|
||||
|
||||
$types = array();
|
||||
$content_types = array();
|
||||
$entities = entity_get_info();
|
||||
|
@@ -11,7 +11,7 @@
|
||||
* by the system that includes this file.
|
||||
*/
|
||||
$plugin = array(
|
||||
'title' => t('Node'),
|
||||
'title' => t('Existing node'),
|
||||
'single' => TRUE,
|
||||
'defaults' => array(
|
||||
'nid' => '',
|
||||
@@ -20,7 +20,6 @@ $plugin = array(
|
||||
'identifier' => '',
|
||||
'build_mode' => 'teaser',
|
||||
),
|
||||
'title' => t('Existing node'),
|
||||
'icon' => 'icon_node.png',
|
||||
'description' => t('Add a node from your site as content.'),
|
||||
'category' => t('Custom'),
|
||||
|
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
if (module_exists('comment')) {
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
*/
|
||||
$plugin = array(
|
||||
'single' => TRUE,
|
||||
'title' => t('Comments and comment form.'),
|
||||
'icon' => 'icon_node.png',
|
||||
'description' => t('The comments and comment form for the referenced node.'),
|
||||
'required context' => new ctools_context_required(t('Node'), 'node'),
|
||||
'category' => t('Node'),
|
||||
'defaults' => array(
|
||||
'mode' => variable_get('comment_default_mode', COMMENT_MODE_THREADED),
|
||||
'comments_per_page' => variable_get('comment_default_per_page', '50'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the node comments.
|
||||
*/
|
||||
function ctools_node_comment_wrapper_content_type_render($subtype, $conf, $panel_args, $context) {
|
||||
$node = isset($context->data) ? clone($context->data) : NULL;
|
||||
$block = new stdClass();
|
||||
$block->module = 'comments';
|
||||
$block->delta = $node->nid;
|
||||
|
||||
$renderable = array(
|
||||
'#theme' => 'comment_wrapper__node_' . $node->type,
|
||||
'#node' => $node,
|
||||
'comments' => array(),
|
||||
'comment_form' => array(),
|
||||
);
|
||||
|
||||
// Add in the comments.
|
||||
if (($node->comment_count && user_access('access comments')) || user_access('administer comments')) {
|
||||
$mode = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED);
|
||||
$comments_per_page = variable_get('comment_default_per_page_' . $node->type, 50);
|
||||
if ($cids = comment_get_thread($node, $mode, $comments_per_page)) {
|
||||
$comments = comment_load_multiple($cids);
|
||||
comment_prepare_thread($comments);
|
||||
$build = comment_view_multiple($comments, $node);
|
||||
$build['pager']['#theme'] = 'pager';
|
||||
$renderable['comments'] = $build;
|
||||
}
|
||||
}
|
||||
|
||||
// Stuff in the comment form.
|
||||
if ($node->comment == COMMENT_NODE_OPEN) {
|
||||
if (user_access('post comments')) {
|
||||
$comment = new stdClass();
|
||||
$comment->nid = $node->nid;
|
||||
$comment->pid = NULL;
|
||||
$form_state = array(
|
||||
'ctools comment alter' => TRUE,
|
||||
'node' => $node,
|
||||
'build_info' => array(
|
||||
'args' => array(
|
||||
$comment,
|
||||
),
|
||||
),
|
||||
);
|
||||
$renderable['comment_form'] = drupal_build_form('comment_node_' . $node->type . '_form', $form_state);
|
||||
}
|
||||
else if (!empty($conf['anon_links'])) {
|
||||
$renderable['comment_form'] = theme('comment_post_forbidden', array('node' => $node));
|
||||
}
|
||||
}
|
||||
|
||||
$block->content = drupal_render($renderable);
|
||||
|
||||
return $block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an edit form for the comment wrapper.
|
||||
*/
|
||||
function ctools_node_comment_wrapper_content_type_edit_form($form, &$form_state) {
|
||||
$conf = $form_state['conf'];
|
||||
$form['mode'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Mode'),
|
||||
'#default_value' => $conf['mode'],
|
||||
'#options' => _comment_get_modes(),
|
||||
'#weight' => 1,
|
||||
);
|
||||
foreach (_comment_per_page() as $i) {
|
||||
$options[$i] = t('!a comments per page', array('!a' => $i));
|
||||
}
|
||||
$form['comments_per_page'] = array('#type' => 'select',
|
||||
'#title' => t('Pager'),
|
||||
'#default_value' => $conf['comments_per_page'],
|
||||
'#options' => $options,
|
||||
'#weight' => 3,
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit handler for the comment wrapper settings form.
|
||||
*/
|
||||
function ctools_node_comment_wrapper_content_type_edit_form_submit($form, &$form_state) {
|
||||
// Copy everything from our defaults.
|
||||
foreach (array_keys($form_state['plugin']['defaults']) as $key) {
|
||||
$form_state['conf'][$key] = $form_state['values'][$key];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the administrative title.
|
||||
*/
|
||||
function ctools_node_comment_wrapper_content_type_admin_title($subtype, $conf, $context) {
|
||||
return t('Comments and comment form');
|
||||
}
|
@@ -20,7 +20,7 @@ $plugin = array(
|
||||
* Render the custom content type.
|
||||
*/
|
||||
function ctools_node_updated_content_type_render($subtype, $conf, $panel_args, $context) {
|
||||
if (empty($context) || empty($context->data)) {
|
||||
if (empty($context) || empty($context->data) || empty($context->data->nid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -7,18 +7,48 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
* Plugins are described by creating a $plugin array which will be used by the
|
||||
* system that includes this file.
|
||||
*/
|
||||
$plugin = array(
|
||||
'title' => t('Site name'),
|
||||
'single' => TRUE,
|
||||
'icon' => 'icon_page.png',
|
||||
'description' => t('The name of the site.'),
|
||||
'description' => t('The name of the site, optionally links to the front page.'),
|
||||
'category' => t('Page elements'),
|
||||
'render last' => TRUE,
|
||||
'defaults' => array(
|
||||
'linked' => FALSE,
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Settings form for the Site Name pane.
|
||||
*/
|
||||
function ctools_page_site_name_content_type_edit_form($form, &$form_state) {
|
||||
$conf = $form_state['conf'];
|
||||
|
||||
$form['linked'] = array(
|
||||
'#title' => t('Linked'),
|
||||
'#description' => t('Link the site name to the home page.'),
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => isset($conf['linked']) ? $conf['linked'] : FALSE,
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* The submit form stores the data in $conf.
|
||||
*/
|
||||
function ctools_page_site_name_content_type_edit_form_submit($form, &$form_state) {
|
||||
foreach (array_keys($form_state['plugin']['defaults']) as $key) {
|
||||
if (isset($form_state['values'][$key])) {
|
||||
$form_state['conf'][$key] = $form_state['values'][$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Output function for the 'page_site_name' content type.
|
||||
*
|
||||
@@ -26,7 +56,13 @@ $plugin = array(
|
||||
*/
|
||||
function ctools_page_site_name_content_type_render($subtype, $conf, $panel_args) {
|
||||
$block = new stdClass();
|
||||
|
||||
$block->content = filter_xss_admin(variable_get('site_name', 'Drupal'));
|
||||
|
||||
// Optionally link the site name to the homepage.
|
||||
if (!empty($conf['linked'])) {
|
||||
$block->content = l($block->content, '<front>');
|
||||
}
|
||||
|
||||
return $block;
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ $plugin = array(
|
||||
'title' => t('Site slogan'),
|
||||
'single' => TRUE,
|
||||
'icon' => 'icon_page.png',
|
||||
'description' => t('Add the slogan trail as content.'),
|
||||
'description' => t("Add the site's slogan as content."),
|
||||
'category' => t('Page elements'),
|
||||
'render last' => TRUE,
|
||||
);
|
||||
@@ -26,7 +26,7 @@ $plugin = array(
|
||||
*/
|
||||
function ctools_page_slogan_content_type_render($subtype, $conf, $panel_args) {
|
||||
$block = new stdClass();
|
||||
$block->content = (theme_get_setting('toggle_slogan') ? filter_xss_admin(variable_get('site_slogan', '')) : '');
|
||||
$block->content = filter_xss_admin(variable_get('site_slogan', ''));
|
||||
|
||||
return $block;
|
||||
}
|
||||
|
@@ -11,7 +11,13 @@ $plugin = array(
|
||||
'description' => t('Terms related to an existing term; may be child, siblings or top level.'),
|
||||
'required context' => new ctools_context_required(t('Term'), array('term', 'taxonomy_term')),
|
||||
'category' => t('Taxonomy term'),
|
||||
'defaults' => array('title' => '', 'type' => 'child', 'list_type' => 'ul', 'path' => 'taxonomy/term'),
|
||||
'defaults' => array(
|
||||
'title' => '',
|
||||
'type' => 'child',
|
||||
'include_current_term' => FALSE,
|
||||
'list_type' => 'ul',
|
||||
'path' => 'taxonomy/term',
|
||||
),
|
||||
);
|
||||
|
||||
function ctools_term_list_content_type_render($subtype, $conf, $panel_args, $context) {
|
||||
@@ -40,6 +46,9 @@ function ctools_term_list_content_type_render($subtype, $conf, $panel_args, $con
|
||||
|
||||
case 'child':
|
||||
default:
|
||||
if (!empty($conf['include_current_term'])) {
|
||||
$terms[] = $term;
|
||||
}
|
||||
$terms = taxonomy_get_children($term->tid);
|
||||
break;
|
||||
|
||||
@@ -49,6 +58,9 @@ function ctools_term_list_content_type_render($subtype, $conf, $panel_args, $con
|
||||
|
||||
case 'parent':
|
||||
$terms = taxonomy_get_parents($term->tid);
|
||||
if (!empty($conf['include_current_term'])) {
|
||||
$terms[] = $term;
|
||||
}
|
||||
$block->title = count($terms) == 1 ? t('Parent term') : t('Parent terms');
|
||||
break;
|
||||
|
||||
@@ -116,6 +128,20 @@ function ctools_term_list_content_type_edit_form($form, &$form_state) {
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$form['include_current_term'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Include the current term in the list'),
|
||||
'#default_value' => !empty($conf['include_current_term']),
|
||||
'#prefix' => '<div class="clearfix no-float">',
|
||||
'#suffix' => '</div>',
|
||||
'#states' => array(
|
||||
'invisible' => array(
|
||||
':input[name="type"], unique1' => array('!value' => 'child'),
|
||||
':input[name="type"], unique2' => array('!value' => 'parent'),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$form['list_type'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('List type'),
|
||||
|
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
*/
|
||||
$plugin = array(
|
||||
'single' => TRUE,
|
||||
'title' => t('Term name'),
|
||||
'icon' => 'icon_term.png',
|
||||
'description' => t('The name of this taxonomy term.'),
|
||||
'required context' => new ctools_context_required(t('Term'), array('term', 'taxonomy_term')),
|
||||
'category' => t('Taxonomy term'),
|
||||
'defaults' => array(
|
||||
'link' => TRUE,
|
||||
'markup' => 'none',
|
||||
'id' => '',
|
||||
'class' => '',
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Render the custom content type.
|
||||
*/
|
||||
function ctools_term_name_content_type_render($subtype, $conf, $panel_args, $context) {
|
||||
if (empty($context) || empty($context->data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get a shortcut to the term.
|
||||
$term = $context->data;
|
||||
|
||||
// Load the vocabulary.
|
||||
$vocab = taxonomy_vocabulary_load($term->vid);
|
||||
|
||||
// Generate the title
|
||||
$content = !empty($conf['link']) ? l($term->name, 'taxonomy/term/' . $term->tid) : check_plain($term->name);
|
||||
|
||||
// Build any surrounding markup if so configured
|
||||
if (isset($conf['markup']) && $conf['markup'] != 'none') {
|
||||
$markup = '<' . $conf['markup'];
|
||||
if (!empty($conf['id'])) {
|
||||
$markup .= ' id="' . $conf['id'] . '"';
|
||||
}
|
||||
if (!empty($conf['class'])) {
|
||||
$markup .= ' class="' . $conf['class'] . '"';
|
||||
}
|
||||
$markup .= '>' . $content . '</' . $conf['markup'] . '>' . "\n";
|
||||
$content = $markup;
|
||||
}
|
||||
|
||||
// Build the content type block.
|
||||
$block = new stdClass();
|
||||
$block->module = 'term_name';
|
||||
$block->title = t('Name');
|
||||
$block->content = $content;
|
||||
$block->delta = $term->tid;
|
||||
|
||||
return $block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an edit form for custom type settings.
|
||||
*/
|
||||
function ctools_term_name_content_type_edit_form($form, &$form_state) {
|
||||
$conf = $form_state['conf'];
|
||||
|
||||
$form['markup'] = array(
|
||||
'#title' => t('Title tag'),
|
||||
'#type' => 'select',
|
||||
'#options' => array(
|
||||
'none' => t('- No tag -'),
|
||||
'h1' => t('h1'),
|
||||
'h2' => t('h2'),
|
||||
'h3' => t('h3'),
|
||||
'h4' => t('h4'),
|
||||
'h5' => t('h5'),
|
||||
'h6' => t('h6'),
|
||||
'div' => t('div'),
|
||||
),
|
||||
'#default_value' => $conf['markup'],
|
||||
);
|
||||
|
||||
$form['id'] = array(
|
||||
'#title' => t('CSS id to use'),
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $conf['id'],
|
||||
);
|
||||
|
||||
$form['class'] = array(
|
||||
'#title' => t('CSS class to use'),
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $conf['class'],
|
||||
);
|
||||
|
||||
$form['link'] = array(
|
||||
'#title' => t('Link to term'),
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => $conf['link'],
|
||||
'#description' => t('Check here to make the name link to the term page.'),
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit handler for the custom type settings form.
|
||||
*/
|
||||
function ctools_term_name_content_type_edit_form_submit($form, &$form_state) {
|
||||
// Copy everything from our defaults.
|
||||
foreach (array_keys($form_state['plugin']['defaults']) as $key) {
|
||||
$form_state['conf'][$key] = $form_state['values'][$key];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the administrative title for a type.
|
||||
*/
|
||||
function ctools_term_name_content_type_admin_title($subtype, $conf, $context) {
|
||||
return t('"@s" name', array('@s' => $context->identifier));
|
||||
}
|
@@ -33,19 +33,26 @@ function ctools_token_content_type_content_type($subtype) {
|
||||
*/
|
||||
function ctools_token_content_type_content_types() {
|
||||
// This will hold all the properties.
|
||||
$types = &drupal_static(__FUNCTION__);
|
||||
if (isset($types)) {
|
||||
return $types;
|
||||
}
|
||||
|
||||
$types = array();
|
||||
$info = token_info();
|
||||
|
||||
foreach ($info['tokens'] as $entity_type => $tokens) {
|
||||
$category = t('@entity (tokens)', array('@entity' => ucfirst($entity_type)));
|
||||
$context = new ctools_context_required(t(ucfirst($entity_type)), $entity_type);
|
||||
foreach ($tokens as $name => $token) {
|
||||
if (!empty($token['name'])) {
|
||||
$token += array('description' => '');
|
||||
$types[$entity_type . ':' . $name] = array(
|
||||
'category' => t('@entity (tokens)', array('@entity' => ucfirst($entity_type))),
|
||||
'category' => $category,
|
||||
'icon' => 'icon_token.png',
|
||||
'title' => $token['name'],
|
||||
'description' => $token['description'],
|
||||
'required context' => new ctools_context_required(t(ucfirst($entity_type)), $entity_type),
|
||||
'required context' => $context,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
if (module_exists('profile') && !is_null(profile_user_categories())) {
|
||||
if (module_exists('profile') && !(defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update') && !is_null(profile_user_categories())) {
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
|
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
*/
|
||||
$plugin = array(
|
||||
'single' => TRUE,
|
||||
'title' => t('User links'),
|
||||
'icon' => 'icon_user.png',
|
||||
'description' => t('User links of the referenced user.'),
|
||||
'required context' => new ctools_context_required(t('User'), 'user'),
|
||||
'category' => t('User'),
|
||||
'defaults' => array(
|
||||
'override_title' => FALSE,
|
||||
'override_title_text' => '',
|
||||
'build_mode' => '',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Output function for the user links.
|
||||
*/
|
||||
function ctools_user_links_content_type_render($subtype, $conf, $panel_args, $context) {
|
||||
if (!empty($context) && empty($context->data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$account = clone $context->data;
|
||||
$block = new stdClass();
|
||||
$block->module = 'user';
|
||||
$block->delta = $account->uid;
|
||||
|
||||
if (empty($account)) {
|
||||
$block->delta = 'placeholder';
|
||||
$block->subject = t('User name.');
|
||||
$block->content = t('User links go here.');
|
||||
}
|
||||
else {
|
||||
$block->subject = $account->name;
|
||||
user_build_content($account, $conf['build_mode']);
|
||||
if (!empty($account->content['links'])) {
|
||||
$block->content = $account->content['links'];
|
||||
}
|
||||
else {
|
||||
$block->content = '';
|
||||
}
|
||||
}
|
||||
return $block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an edit form for the custom type.
|
||||
*/
|
||||
function ctools_user_links_content_type_edit_form($form, &$form_state) {
|
||||
$conf = $form_state['conf'];
|
||||
|
||||
$entity = entity_get_info('user');
|
||||
$build_mode_options = array();
|
||||
foreach ($entity['view modes'] as $mode => $option) {
|
||||
$build_mode_options[$mode] = $option['label'];
|
||||
}
|
||||
|
||||
$form['build_mode'] = array(
|
||||
'#title' => t('Build mode'),
|
||||
'#type' => 'select',
|
||||
'#description' => t('Select a build mode for this user.'),
|
||||
'#options' => $build_mode_options,
|
||||
'#default_value' => $conf['build_mode'],
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function ctools_user_links_content_type_edit_form_submit($form, &$form_state) {
|
||||
// Copy everything from our defaults.
|
||||
foreach (array_keys($form_state['plugin']['defaults']) as $key) {
|
||||
$form_state['conf'][$key] = $form_state['values'][$key];
|
||||
}
|
||||
}
|
||||
|
||||
function ctools_user_links_content_type_admin_title($subtype, $conf, $context) {
|
||||
return t('"@s" links', array('@s' => $context->identifier));
|
||||
}
|
@@ -14,12 +14,15 @@ $plugin = array(
|
||||
'title' => t('String'),
|
||||
'description' => t('A context that is just a string.'),
|
||||
'context' => 'ctools_context_create_string',
|
||||
'edit form' => 'ctools_context_string_settings_form',
|
||||
'defaults' => '',
|
||||
'keyword' => 'string',
|
||||
'no ui' => FALSE,
|
||||
'context name' => 'string',
|
||||
'convert list' => array(
|
||||
'raw' => t('Raw string'),
|
||||
'html_safe' => t('HTML-safe string'),
|
||||
'uppercase_words_html_safe' => t('Uppercase words HTML-safe string'),
|
||||
),
|
||||
'convert' => 'ctools_context_string_convert',
|
||||
'placeholder form' => array(
|
||||
@@ -44,7 +47,8 @@ function ctools_context_create_string($empty, $data = NULL, $conf = FALSE) {
|
||||
}
|
||||
|
||||
if ($data !== FALSE ) {
|
||||
$context->data = $data;
|
||||
// Support the array storage from the settings form but also handle direct input from arguments.
|
||||
$context->data = is_array($data) ? $data['string'] : $data;
|
||||
$context->title = ($conf) ? check_plain($data['identifier']) : check_plain($data);
|
||||
return $context;
|
||||
}
|
||||
@@ -59,6 +63,28 @@ function ctools_context_string_convert($context, $type) {
|
||||
return $context->data;
|
||||
case 'html_safe':
|
||||
return check_plain($context->data);
|
||||
case 'uppercase_words_html_safe':
|
||||
return ucwords(str_replace('-', ' ', check_plain($context->data)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* String settings form.
|
||||
*/
|
||||
function ctools_context_string_settings_form($form, &$form_state) {
|
||||
$conf = &$form_state['conf'];
|
||||
|
||||
$form['string'] = array(
|
||||
'#title' => t('Enter the string'),
|
||||
'#type' => 'textfield',
|
||||
'#maxlength' => 512,
|
||||
'#weight' => -10,
|
||||
'#default_value' => $conf['string'],
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function ctools_context_string_settings_form_submit($form, &$form_state) {
|
||||
$form_state['conf']['string'] = $form_state['values']['string'];
|
||||
}
|
||||
|
@@ -51,8 +51,9 @@ function ctools_context_token_convert_list() {
|
||||
function ctools_context_token_convert($context, $token) {
|
||||
$tokens = token_info();
|
||||
list($type, $token) = explode(':', $token, 2);
|
||||
$parts = explode(':', $token, 2);
|
||||
$real_type = isset($tokens['types'][$type]['type']) ? $tokens['types'][$type]['type'] : $type;
|
||||
if (isset($tokens['tokens'][$real_type][$token])) {
|
||||
if (isset($tokens['tokens'][$real_type][$parts[0]])) {
|
||||
$values = token_generate($type, array($token => $token));
|
||||
if (isset($values[$token])) {
|
||||
return $values[$token];
|
||||
|
@@ -88,7 +88,7 @@ function ctools_context_user_settings_form($form, &$form_state) {
|
||||
if (!empty($conf['uid'])) {
|
||||
$info = user_load($conf['uid']);
|
||||
if ($info) {
|
||||
$form['user']['#description'] = t('Currently set to !link', array('!link' => theme('username', $info)));
|
||||
$form['user']['#description'] = t('Currently set to !link', array('!link' => theme('username', array('account' => $info))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -107,7 +107,7 @@ function ctools_context_user_edit_form_settings_form($form, &$form_state) {
|
||||
);
|
||||
|
||||
if (!empty($conf['uid'])) {
|
||||
$info = db_query('SELECT * FROM {user} WHERE uid = :uid', array(':uid' => $conf['uid']))->fetchObject();
|
||||
$info = db_query('SELECT * FROM {users} WHERE uid = :uid', array(':uid' => $conf['uid']))->fetchObject();
|
||||
if ($info) {
|
||||
$link = l(t("'%name' [user id %uid]", array('%name' => $info->name, '%uid' => $info->uid)), "user/$info->uid", array('attributes' => array('target' => '_blank', 'title' => t('Open in new window')), 'html' => TRUE));
|
||||
$form['user']['#description'] = t('Currently set to !link', array('!link' => $link));
|
||||
@@ -154,10 +154,10 @@ function ctools_context_user_edit_form_settings_form_validate($form, &$form_stat
|
||||
$uid = $preg_matches[1];
|
||||
}
|
||||
if (is_numeric($uid)) {
|
||||
$user = db_query('SELECT uid FROM {user} WHEREuid = :uid', array(':uid' => $uid))->fetchObject();
|
||||
$user = db_query('SELECT uid FROM {users} WHERE uid = :uid', array(':uid' => $uid))->fetchObject();
|
||||
}
|
||||
else {
|
||||
$user = db_query('SELECT uid FROM {user} WHERE LOWER(name) = LOWER(:name)', array(':name' => $uid))->fetchObject();
|
||||
$user = db_query('SELECT uid FROM {users} WHERE LOWER(name) = LOWER(:name)', array(':name' => $uid))->fetchObject();
|
||||
}
|
||||
|
||||
form_set_value($form['uid'], $user->uid, $form_state);
|
||||
|
@@ -121,7 +121,7 @@ class ctools_export_ui {
|
||||
|
||||
switch ($op) {
|
||||
case 'import':
|
||||
return user_access('use PHP for settings');
|
||||
return user_access('use ctools import');
|
||||
case 'revert':
|
||||
return ($item->export_type & EXPORT_IN_DATABASE) && ($item->export_type & EXPORT_IN_CODE);
|
||||
case 'delete':
|
||||
@@ -152,7 +152,7 @@ class ctools_export_ui {
|
||||
if (isset($input['op']) && $input['op'] == t('Reset')) {
|
||||
unset($_SESSION['ctools_export_ui'][$this->plugin['name']]);
|
||||
if (!$js) {
|
||||
return drupal_goto($_GET['q']);
|
||||
drupal_goto($_GET['q']);
|
||||
}
|
||||
// clear everything but form id, form build id and form token:
|
||||
$keys = array_keys($input);
|
||||
@@ -639,7 +639,7 @@ class ctools_export_ui {
|
||||
}
|
||||
|
||||
function add_page($js, $input, $step = NULL) {
|
||||
drupal_set_title($this->get_page_title('add'));
|
||||
drupal_set_title($this->get_page_title('add'), PASS_THROUGH);
|
||||
|
||||
// If a step not set, they are trying to create a new item. If a step
|
||||
// is set, they're in the process of creating an item.
|
||||
@@ -665,7 +665,7 @@ class ctools_export_ui {
|
||||
);
|
||||
|
||||
$output = $this->edit_execute_form($form_state);
|
||||
if (!empty($form_state['executed'])) {
|
||||
if (!empty($form_state['executed']) && empty($form_state['rebuild'])) {
|
||||
$this->redirect($form_state['op'], $form_state['item']);
|
||||
}
|
||||
|
||||
@@ -676,7 +676,7 @@ class ctools_export_ui {
|
||||
* Main entry point to edit an item.
|
||||
*/
|
||||
function edit_page($js, $input, $item, $step = NULL) {
|
||||
drupal_set_title($this->get_page_title('edit', $item));
|
||||
drupal_set_title($this->get_page_title('edit', $item), PASS_THROUGH);
|
||||
|
||||
// Check to see if there is a cached item to get if we're using the wizard.
|
||||
if (!empty($this->plugin['use wizard'])) {
|
||||
@@ -701,7 +701,7 @@ class ctools_export_ui {
|
||||
);
|
||||
|
||||
$output = $this->edit_execute_form($form_state);
|
||||
if (!empty($form_state['executed'])) {
|
||||
if (!empty($form_state['executed']) && empty($form_state['rebuild'])) {
|
||||
$this->redirect($form_state['op'], $form_state['item']);
|
||||
}
|
||||
|
||||
@@ -712,7 +712,7 @@ class ctools_export_ui {
|
||||
* Main entry point to clone an item.
|
||||
*/
|
||||
function clone_page($js, $input, $original, $step = NULL) {
|
||||
drupal_set_title($this->get_page_title('clone', $original));
|
||||
drupal_set_title($this->get_page_title('clone', $original), PASS_THROUGH);
|
||||
|
||||
// If a step not set, they are trying to create a new clone. If a step
|
||||
// is set, they're in the process of cloning an item.
|
||||
@@ -749,7 +749,7 @@ class ctools_export_ui {
|
||||
);
|
||||
|
||||
$output = $this->edit_execute_form($form_state);
|
||||
if (!empty($form_state['executed'])) {
|
||||
if (!empty($form_state['executed']) && empty($form_state['rebuild'])) {
|
||||
$this->redirect($form_state['op'], $form_state['item']);
|
||||
}
|
||||
|
||||
@@ -778,7 +778,7 @@ class ctools_export_ui {
|
||||
*/
|
||||
function edit_execute_form_standard(&$form_state) {
|
||||
$output = drupal_build_form('ctools_export_ui_edit_item_form', $form_state);
|
||||
if (!empty($form_state['executed'])) {
|
||||
if (!empty($form_state['executed']) && empty($form_state['rebuild'])) {
|
||||
$this->edit_save_form($form_state);
|
||||
}
|
||||
|
||||
@@ -1218,7 +1218,7 @@ class ctools_export_ui {
|
||||
* Page callback to display export information for an exportable item.
|
||||
*/
|
||||
function export_page($js, $input, $item) {
|
||||
drupal_set_title($this->get_page_title('export', $item));
|
||||
drupal_set_title($this->get_page_title('export', $item), PASS_THROUGH);
|
||||
return drupal_get_form('ctools_export_form', ctools_export_crud_export($this->plugin['schema'], $item), t('Export'));
|
||||
}
|
||||
|
||||
@@ -1226,7 +1226,7 @@ class ctools_export_ui {
|
||||
* Page callback to import information for an exportable item.
|
||||
*/
|
||||
function import_page($js, $input, $step = NULL) {
|
||||
drupal_set_title($this->get_page_title('import'));
|
||||
drupal_set_title($this->get_page_title('import'), PASS_THROUGH);
|
||||
// Import is basically a multi step wizard form, so let's go ahead and
|
||||
// use CTools' wizard.inc for it.
|
||||
|
||||
@@ -1339,7 +1339,7 @@ function _ctools_export_ui_add_form_files($form, &$form_state) {
|
||||
*
|
||||
* This simply loads the object defined in the plugin and hands it off.
|
||||
*/
|
||||
function ctools_export_ui_list_form($form, $form_state) {
|
||||
function ctools_export_ui_list_form($form, &$form_state) {
|
||||
$form_state['object']->list_form($form, $form_state);
|
||||
return $form;
|
||||
}
|
||||
@@ -1441,7 +1441,7 @@ function ctools_export_ui_delete_confirm_form($form, &$form_state) {
|
||||
|
||||
$export_key = $plugin['export']['key'];
|
||||
$question = str_replace('%title', check_plain($item->{$export_key}), $plugin['strings']['confirmation'][$form_state['op']]['question']);
|
||||
$path = empty($_REQUEST['cancel_path']) ? ctools_export_ui_plugin_base_path($plugin) : $_REQUEST['cancel_path'];
|
||||
$path = (!empty($_REQUEST['cancel_path']) && !url_is_external($_REQUEST['cancel_path'])) ? $_REQUEST['cancel_path'] : ctools_export_ui_plugin_base_path($plugin);
|
||||
|
||||
$form = confirm_form($form,
|
||||
$question,
|
||||
|
@@ -42,7 +42,9 @@ function ctools_book_parent_context($context, $conf) {
|
||||
// Load the node.
|
||||
$node = node_load($nid);
|
||||
// Generate the context.
|
||||
return ctools_context_create('node', $node);
|
||||
if (node_access('view', $node)) {
|
||||
return ctools_context_create('node', $node);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@@ -154,6 +154,11 @@ function ctools_entity_from_field_get_children($parent_plugin, $parent) {
|
||||
* Return a new context based on an existing context.
|
||||
*/
|
||||
function ctools_entity_from_field_context($context, $conf) {
|
||||
// Perform access check on current logged in user.
|
||||
global $user;
|
||||
// Clone user object so account can be passed by value to access callback.
|
||||
$account = clone $user;
|
||||
|
||||
$delta = !empty($conf['delta']) ? intval($conf['delta']) : 0;
|
||||
$plugin = $conf['name'];
|
||||
list($plugin, $plugin_name) = explode(':', $plugin);
|
||||
@@ -173,11 +178,20 @@ function ctools_entity_from_field_context($context, $conf) {
|
||||
if (isset($items[$delta])) {
|
||||
ctools_include('fields');
|
||||
$to_entity_info = entity_get_info($to_entity);
|
||||
|
||||
$plugin_info = ctools_get_relationship($conf['name']);
|
||||
$to_entity_id = $items[$delta][$plugin_info['source key']];
|
||||
$loaded_to_entity = entity_load($to_entity, array($to_entity_id));
|
||||
$loaded_to_entity = array_shift($loaded_to_entity);
|
||||
|
||||
// Send it to ctools.
|
||||
return ctools_context_create('entity:' . $to_entity, $to_entity_id);
|
||||
// Pass current user account and entity type to access callback.
|
||||
if (function_exists($to_entity_info['access callback']) && !call_user_func($to_entity_info['access callback'], 'view', $loaded_to_entity, $account, $to_entity)) {
|
||||
return ctools_context_create_empty('entity:' . $to_entity, NULL);
|
||||
}
|
||||
else {
|
||||
// Send it to ctools.
|
||||
return ctools_context_create('entity:' . $to_entity, $to_entity_id);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// In case that delta was empty.
|
||||
|
@@ -35,7 +35,7 @@ function ctools_terms_from_node_context($context, $conf) {
|
||||
$fields = field_info_instances('node', $node->type);
|
||||
foreach ($fields as $name => $info) {
|
||||
$field_info = field_info_field($name);
|
||||
if ($field_info['type'] == 'taxonomy_term_reference' && (empty($conf['vocabulary']) || $conf['vocabulary'][$field_info['settings']['allowed_values'][0]['vocabulary']])) {
|
||||
if ($field_info['type'] == 'taxonomy_term_reference' && (empty($conf['vocabulary']) || !empty($conf['vocabulary'][$field_info['settings']['allowed_values'][0]['vocabulary']]))) {
|
||||
$items = field_get_items('node', $node, $name);
|
||||
if (is_array($items)) {
|
||||
foreach ($items as $item) {
|
||||
|
@@ -2,12 +2,13 @@ name = Stylizer
|
||||
description = Create custom styles for applications such as Panels.
|
||||
core = 7.x
|
||||
package = Chaos tool suite
|
||||
version = CTOOLS_MODULE_VERSION
|
||||
dependencies[] = ctools
|
||||
dependencies[] = color
|
||||
|
||||
; 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"
|
||||
|
||||
|
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Plugin to provide access control based upon a parent term.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
*/
|
||||
$plugin = array(
|
||||
'title' => t("Taxonomy: term depth"),
|
||||
'description' => t('Control access by the depth of a term.'),
|
||||
'callback' => 'term_depth_term_depth_ctools_access_check',
|
||||
'default' => array('vid' => array(), 'depth' => 0),
|
||||
'settings form' => 'term_depth_term_depth_ctools_access_settings',
|
||||
'settings form validation' => 'term_depth_term_depth_ctools_access_settings_validate',
|
||||
'settings form submit' => 'term_depth_term_depth_ctools_access_settings_submit',
|
||||
'summary' => 'term_depth_term_depth_ctools_access_summary',
|
||||
'required context' => new ctools_context_required(t('Term'), array('taxonomy_term', 'terms')),
|
||||
);
|
||||
|
||||
/**
|
||||
* Settings form for the 'term depth' access plugin.
|
||||
*/
|
||||
function term_depth_term_depth_ctools_access_settings($form, &$form_state, $conf) {
|
||||
// If no configuration was saved before, set some defaults.
|
||||
if (empty($conf)) {
|
||||
$conf = array(
|
||||
'vid' => 0,
|
||||
);
|
||||
}
|
||||
if (!isset($conf['vid'])) {
|
||||
$conf['vid'] = 0;
|
||||
}
|
||||
|
||||
// Loop over each of the configured vocabularies.
|
||||
foreach (taxonomy_get_vocabularies() as $vid => $vocabulary) {
|
||||
$options[$vid] = $vocabulary->name;
|
||||
}
|
||||
|
||||
$form['settings']['vid'] = array(
|
||||
'#title' => t('Vocabulary'),
|
||||
'#type' => 'select',
|
||||
'#options' => $options,
|
||||
'#description' => t('Select the vocabulary for this form. If there exists a parent term in that vocabulary, this access check will succeed.'),
|
||||
'#id' => 'ctools-select-vid',
|
||||
'#default_value' => $conf['vid'],
|
||||
'#required' => TRUE,
|
||||
);
|
||||
|
||||
$form['settings']['depth'] = array(
|
||||
'#title' => t('Depth'),
|
||||
'#type' => 'textfield',
|
||||
'#description' => t('Set the required depth of the term. If the term exists at the correct depth, this access check will succeed.'),
|
||||
'#default_value' => $conf['depth'],
|
||||
'#required' => TRUE,
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit function for the access plugins settings.
|
||||
*
|
||||
* We cast all settings to numbers to ensure they can be safely handled.
|
||||
*/
|
||||
function term_depth_term_depth_ctools_access_settings_submit($form, $form_state) {
|
||||
foreach (array('depth', 'vid') as $key) {
|
||||
$form_state['conf'][$key] = (integer) $form_state['values']['settings'][$key];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for access.
|
||||
*/
|
||||
function term_depth_term_depth_ctools_access_check($conf, $context) {
|
||||
// As far as I know there should always be a context at this point, but this
|
||||
// is safe.
|
||||
if (empty($context) || empty($context->data) || empty($context->data->vid) || empty($context->data->tid)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Get the $vid.
|
||||
if (!isset($conf['vid'])) {
|
||||
return FALSE;
|
||||
}
|
||||
$depth = _term_depth($context->data->tid);
|
||||
|
||||
return ($depth == $conf['depth']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a summary description based upon the checked terms.
|
||||
*/
|
||||
function term_depth_term_depth_ctools_access_summary($conf, $context) {
|
||||
$vocab = taxonomy_vocabulary_load($conf['vid']);
|
||||
|
||||
return t('"@term" has parent in vocabulary "@vocab" at @depth', array(
|
||||
'@term' => $context->identifier,
|
||||
'@vocab' => $vocab->name,
|
||||
'@depth' => $conf['depth'],
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the depth of a term.
|
||||
*/
|
||||
function _term_depth($tid) {
|
||||
static $depths = array();
|
||||
|
||||
if (!isset($depths[$tid])) {
|
||||
$parent = db_select('taxonomy_term_hierarchy', 'th')
|
||||
->fields('th', array('parent'))
|
||||
->condition('tid', $tid)
|
||||
->execute()->fetchField();
|
||||
|
||||
if ($parent == 0) {
|
||||
$depths[$tid] = 1;
|
||||
}
|
||||
else {
|
||||
$depths[$tid] = 1 + _term_depth($parent);
|
||||
}
|
||||
}
|
||||
|
||||
return $depths[$tid];
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
name = Term Depth access
|
||||
description = Controls access to context based upon term depth
|
||||
core = 7.x
|
||||
dependencies[] = ctools
|
||||
package = Chaos tool suite
|
||||
version = CTOOLS_MODULE_VERSION
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-03-18
|
||||
version = "7.x-1.7"
|
||||
core = "7.x"
|
||||
project = "ctools"
|
||||
datestamp = "1426696183"
|
||||
|
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
function term_depth_ctools_plugin_directory($owner, $plugin) {
|
||||
if ($owner == 'ctools' && $plugin == 'access') {
|
||||
return 'plugins/' . $plugin;
|
||||
}
|
||||
}
|
48
sites/all/modules/contrib/dev/ctools/tests/css_cache.test
Normal file
48
sites/all/modules/contrib/dev/ctools/tests/css_cache.test
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Tests the custom CSS cache handler.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests the custom CSS cache handler.
|
||||
*/
|
||||
class CtoolsObjectCache extends DrupalWebTestCase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Ctools CSS cache',
|
||||
'description' => 'Tests the custom CSS cache handler.',
|
||||
'group' => 'Chaos Tools Suite',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp('ctools');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the custom CSS cache handler.
|
||||
*
|
||||
* @see https://drupal.org/node/1313368
|
||||
*/
|
||||
public function testCssCache() {
|
||||
// Create a CSS cache entry.
|
||||
$filename = ctools_css_cache('body { color: red; }');
|
||||
|
||||
// Perform a cron run. The CSS cache entry should not be removed.
|
||||
$this->cronRun();
|
||||
$this->assertTrue(file_exists($filename), 'The CSS cache is not cleared after performing a cron run.');
|
||||
|
||||
// Manually clear the caches. The CSS cache entry should be removed.
|
||||
drupal_flush_all_caches();
|
||||
$this->assertFalse(file_exists($filename), 'The CSS cache is cleared after clearing all caches.');
|
||||
}
|
||||
|
||||
}
|
@@ -2,14 +2,15 @@ name = CTools export test
|
||||
description = CTools export test module
|
||||
core = 7.x
|
||||
package = Chaos tool suite
|
||||
version = CTOOLS_MODULE_VERSION
|
||||
dependencies[] = ctools
|
||||
hidden = TRUE
|
||||
|
||||
files[] = ctools_export.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"
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
name = Chaos tools plugins test
|
||||
description = Provides hooks for testing ctools plugins.
|
||||
package = Chaos tool suite
|
||||
version = CTOOLS_MODULE_VERSION
|
||||
core = 7.x
|
||||
dependencies[] = ctools
|
||||
files[] = ctools.plugins.test
|
||||
@@ -11,9 +12,9 @@ files[] = math_expression.test
|
||||
files[] = math_expression_stack.test
|
||||
hidden = TRUE
|
||||
|
||||
; 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"
|
||||
|
||||
|
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* A cached plugin object that tests inheritence including.
|
||||
*/
|
||||
|
||||
class ctoolsCachedPluginArray {}
|
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* A cached plugin object that tests inheritence including.
|
||||
*/
|
||||
|
||||
class ctoolsCachedPluginArray2 extends ctoolsCachedPluginArray {}
|
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Chaos Tools plugin include using a plugin array to declare a plugin.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugin array plugin definition.
|
||||
*/
|
||||
$plugin = array(
|
||||
'function' => 'ctools_plugin_test_plugin_array_cached_test',
|
||||
'handler' => array(
|
||||
'class' => 'ctoolsCachedPluginArray',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Plugin array function plugin.
|
||||
*/
|
||||
function ctools_plugin_test_plugin_array_cached_test() {}
|
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Chaos Tools plugin include using a plugin array to declare a plugin.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugin array plugin definition.
|
||||
*/
|
||||
$plugin = array(
|
||||
'function' => 'ctools_plugin_test_plugin_array2_cached_test',
|
||||
'handler' => array(
|
||||
'class' => 'ctoolsCachedPluginArray2',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Plugin array function plugin.
|
||||
*/
|
||||
function ctools_plugin_test_plugin_array2_cached_test() {}
|
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Chaos Tools plugin include using a plugin array to declare a plugin.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugin array plugin definition.
|
||||
*/
|
||||
$plugin = array(
|
||||
'function' => 'ctools_plugin_test_plugin_array_dne_cached_test',
|
||||
'handler' => array(
|
||||
'class' => 'ctoolsCachedPluginArrayDNE',
|
||||
),
|
||||
);
|
@@ -63,18 +63,6 @@ function views_content_views_content_type_content_types($plugin) {
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a single content type.
|
||||
*/
|
||||
function views_content_views_content_type_content_type($subtype, $plugin) {
|
||||
$view = views_get_view($name);
|
||||
if (empty($view)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return _views_content_views_content_type($view);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the content type info array to give back to ctools for a given display.
|
||||
*/
|
||||
|
@@ -83,7 +83,7 @@ function views_content_views_panes_content_type_content_type($subtype, $plugin)
|
||||
function _views_content_panes_content_type($view, $display) {
|
||||
// Ensure the handler is the right type, as Views will fall back to
|
||||
// the default display if something is broken:
|
||||
if (get_class($display->handler) != 'views_content_plugin_display_panel_pane') {
|
||||
if (!is_a($display->handler, 'views_content_plugin_display_panel_pane')) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ function views_content_views_panes_content_type_render($subtype, $conf, $panel_a
|
||||
$view->set_display($display);
|
||||
views_content_views_panes_add_defaults($conf, $view);
|
||||
|
||||
if (!$view->display_handler->access($GLOBALS['user']) || !$view->display_handler->panel_pane_display) {
|
||||
if (!$view->display_handler->access($GLOBALS['user']) || empty($view->display_handler->panel_pane_display)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -162,6 +162,9 @@ function views_content_views_panes_content_type_render($subtype, $conf, $panel_a
|
||||
$args[] = $contexts[$key]->argument;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$args[] = isset($arguments[$id]['exception']['value']) ? $arguments[$id]['exception']['value'] : 'all';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'fixed':
|
||||
@@ -252,7 +255,7 @@ function views_content_views_panes_content_type_render($subtype, $conf, $panel_a
|
||||
|
||||
if ($conf['use_pager']) {
|
||||
if (!isset($pager['options']['id']) || (isset($conf['pager_id']) && $pager['options']['id'] != $conf['pager_id'])) {
|
||||
$pager['options']['id'] = $conf['pager_id'];
|
||||
$pager['options']['id'] = (int) $conf['pager_id'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,7 +265,7 @@ function views_content_views_panes_content_type_render($subtype, $conf, $panel_a
|
||||
if ($allow['fields_override']) {
|
||||
if ($conf['fields_override']) {
|
||||
$fields = $view->get_items('field');
|
||||
foreach ($fields as $field => $display) {
|
||||
foreach ($fields as $field => $field_display) {
|
||||
$fields[$field]['exclude'] = empty($conf['fields_override'][$field]);
|
||||
}
|
||||
$view->display_handler->set_option('fields', $fields);
|
||||
@@ -271,6 +274,11 @@ function views_content_views_panes_content_type_render($subtype, $conf, $panel_a
|
||||
}
|
||||
|
||||
if ($allow['exposed_form'] && !empty($conf['exposed'])) {
|
||||
foreach ($conf['exposed'] as $filter_name => $filter_value) {
|
||||
if (!is_array($filter_value)) {
|
||||
$conf['exposed'][$filter_name] = ctools_context_keyword_substitute($filter_value, array(), $contexts);
|
||||
}
|
||||
}
|
||||
$view->set_exposed_input($conf['exposed']);
|
||||
}
|
||||
|
||||
@@ -281,6 +289,11 @@ function views_content_views_panes_content_type_render($subtype, $conf, $panel_a
|
||||
return;
|
||||
}
|
||||
|
||||
// Add contextual links to the output.
|
||||
$block = (array) $block;
|
||||
views_add_block_contextual_links($block, $view, $display, 'panel_pane');
|
||||
$block = (object) $block;
|
||||
|
||||
$block->title = $view->get_title();
|
||||
|
||||
if (empty($view->total_rows) || $view->total_rows <= $view->get_items_per_page()) {
|
||||
@@ -310,7 +323,7 @@ function views_content_views_panes_add_defaults(&$conf, $view) {
|
||||
|
||||
$conf += array(
|
||||
'link_to_view' => $view->display_handler->get_option('link_to_view'),
|
||||
'more_link' => $view->display_handler->get_option('more_link'),
|
||||
'more_link' => $view->display_handler->get_option('use_more'),
|
||||
'feed_icons' => FALSE,
|
||||
'use_pager' => $pager['type'] != 'none' && $pager['type'] != 'some',
|
||||
'pager_id' => isset($pager['options']['id']) ? $pager['options']['id'] : 0,
|
||||
@@ -405,7 +418,7 @@ function views_content_views_panes_content_type_edit_form($form, &$form_state) {
|
||||
$form['fields_override'][$field] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $title,
|
||||
'#default_value' => isset($conf['fields_override'][$field]) ? $conf['fields_override'][$field] : TRUE,
|
||||
'#default_value' => isset($conf['fields_override'][$field]) ? $conf['fields_override'][$field] : !$handler->options['exclude'],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -599,7 +612,7 @@ function views_content_views_panes_content_type_admin_info($subtype, $conf, $con
|
||||
$argument_input = $view->display_handler->get_option('argument_input');
|
||||
|
||||
foreach ($conf['arguments'] as $key => $value) {
|
||||
if(!empty($value)){
|
||||
if (!empty($value)){
|
||||
$label = $argument_input[$key]['label'];
|
||||
$info[] = $label . ': ' . $value;
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ $plugin = array(
|
||||
'title' => t('Term from view'),
|
||||
'keyword' => 'term',
|
||||
'description' => t('Extract a term context from a view context of the base type term.'),
|
||||
'required context' => new ctools_context_required(t('View'), 'view', array('base' => 'term_data')),
|
||||
'required context' => new ctools_context_required(t('View'), 'view', array('base' => 'taxonomy_term_data')),
|
||||
'context' => 'views_content_term_from_view_context',
|
||||
'edit form' => 'views_content_term_from_view_settings_form',
|
||||
'edit form validate' => 'views_content_term_from_view_settings_form_validate',
|
||||
@@ -26,7 +26,7 @@ $plugin = array(
|
||||
function views_content_term_from_view_context($context, $conf, $placeholder = FALSE) {
|
||||
// If unset it wants a generic, unfilled context, which is just NULL.
|
||||
if (empty($context->data) || $placeholder) {
|
||||
return ctools_context_create_empty('term', NULL);
|
||||
return ctools_context_create_empty('entity:taxonomy_term', NULL);
|
||||
}
|
||||
$view = views_content_context_get_view($context);
|
||||
// Ensure the view executes, but we don't need its output.
|
||||
@@ -36,11 +36,11 @@ function views_content_term_from_view_context($context, $conf, $placeholder = FA
|
||||
if (isset($view->result[$row])) {
|
||||
$tid = $view->result[$row]->{$view->base_field};
|
||||
if ($tid) {
|
||||
$term = taxonomy_get_term($tid);
|
||||
return ctools_context_create('term', $term);
|
||||
$term = taxonomy_term_load($tid);
|
||||
return ctools_context_create('entity:taxonomy_term', $term);
|
||||
}
|
||||
}
|
||||
return ctools_context_create_empty('term', NULL);
|
||||
return ctools_context_create_empty('entity:taxonomy_term', NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -25,6 +25,7 @@ function views_content_views_plugins() {
|
||||
'use more' => TRUE,
|
||||
'accept attachments' => TRUE,
|
||||
'help topic' => 'display-pane',
|
||||
'contextual links locations' => array('panel_pane'),
|
||||
),
|
||||
'ctools_context' => array(
|
||||
'title' => t('Context'),
|
||||
|
@@ -5,13 +5,14 @@ dependencies[] = ctools
|
||||
dependencies[] = views
|
||||
core = 7.x
|
||||
package = Chaos tool suite
|
||||
version = CTOOLS_MODULE_VERSION
|
||||
files[] = plugins/views/views_content_plugin_display_ctools_context.inc
|
||||
files[] = plugins/views/views_content_plugin_display_panel_pane.inc
|
||||
files[] = plugins/views/views_content_plugin_style_ctools_context.inc
|
||||
|
||||
; 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"
|
||||
|
||||
|
@@ -281,3 +281,17 @@ function _views_content_get_context_from_display($view, $id, $parent, $required
|
||||
'view display id' => $id,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_get_pane_links_alter().
|
||||
*/
|
||||
function views_content_get_pane_links_alter(&$links, $pane, $content_type) {
|
||||
if ($pane->type === 'views_panes') {
|
||||
list($view_name, $display_name) = explode('-', $pane->subtype);
|
||||
$destination = array('destination' => current_path());
|
||||
$links['top'][] = array(
|
||||
'title' => t('Edit view'),
|
||||
'href' => url('admin/structure/views/view/' . $view_name . '/edit/' . $display_name, array('query' => $destination, 'absolute' => TRUE)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user