updated etxlink, ctools, colorbox, computed_field

This commit is contained in:
2019-05-13 17:51:14 +02:00
parent 33210e10f2
commit 2ffad14939
309 changed files with 4930 additions and 2655 deletions

View File

@@ -1,4 +1,5 @@
<?php
/**
* @file
* Theme function for wrapping menu local actions.
@@ -30,4 +31,4 @@ function theme_ctools_menu_local_actions_wrapper($variables) {
}
return '<ul class="action-links">' . $links . '</ul>';
}
}

View File

@@ -1,6 +1,10 @@
<?php
// Set this so we can tell that the file has been included at some point.
/**
* @file
* Set this so we can tell that the file has been included at some point.
*/
define('CTOOLS_AJAX_INCLUDED', 1);
/**
@@ -85,17 +89,17 @@ function ctools_ajax_icon_text_button($text, $image, $dest, $alt, $class = '', $
* @param $name
* The name or key: of the data attached to this selector.
* @param $value
* The value of the data.
* The value of the data.
*/
function ctools_ajax_command_attr($selector, $name, $value) {
ctools_add_js('ajax-responder');
return array(
'command' => 'attr',
'selector' => $selector,
'name' => $name,
'value' => $value,
);
}
'command' => 'attr',
'selector' => $selector,
'name' => $name,
'value' => $value,
);
}
/**
* Force a client-side redirect.
@@ -154,4 +158,3 @@ function ctools_ajax_render_error($error = '') {
print ajax_render($commands);
exit;
}

View File

@@ -2,7 +2,6 @@
/**
* @file
*
* Plugins to handle cache-indirection.
*
* Simple plugin management to allow clients to more tightly control where
@@ -52,7 +51,6 @@
* @param string $mechanism
* A string containing the plugin name, and an optional data element to
* send to the plugin separated by two colons.
*
* @param string $key
* The key used to identify the cache.
*
@@ -70,7 +68,6 @@ function ctools_cache_get($mechanism, $key) {
* @param string $mechanism
* A string containing the plugin name, and an optional data element to
* send to the plugin separated by two colons.
*
* @param string $key
* The key used to identify the cache.
*
@@ -88,7 +85,6 @@ function ctools_cache_set($mechanism, $key, $object) {
* @param string $mechanism
* A string containing the plugin name, and an optional data element to
* send to the plugin separated by two colons.
*
* @param string $key
* The key used to identify the cache.
*/
@@ -108,13 +104,10 @@ function ctools_cache_clear($mechanism, $key) {
* @param string $mechanism
* A string containing the plugin name, and an optional data element to
* send to the plugin separated by two colons.
*
* @param string $key
* The key used to identify the cache.
*
* @param string $op
* The operation to call, such as 'break' or 'finalize'.
*
* @param mixed $object
* The cache data being operated on, in case it is necessary. This is
* optional so no references should be used.
@@ -150,7 +143,7 @@ function ctools_cache_operation($mechanism, $key, $op, $object = NULL) {
*/
function ctools_cache_find_plugin($mechanism) {
if (strpos($mechanism, '::') !== FALSE) {
// use explode(2) to ensure that the data can contain double
// Use explode(2) to ensure that the data can contain double
// colons, just in case.
list($name, $data) = explode('::', $mechanism, 2);
}

View File

@@ -1,5 +1,4 @@
<?php
// $Id $
/**
* @file
@@ -21,7 +20,7 @@
/**
* Matches Unicode character classes.
*
* See: http://www.unicode.org/Public/UNIDATA/UCD.html#General_Category_Values
* See: http://www.unicode.org/Public/UNIDATA/UCD.html#General_Category_Values.
*
* The index only contains the following character classes:
* Lu Letter, Uppercase
@@ -129,13 +128,13 @@ function ctools_cleanstring($string, $settings = array()) {
$output = transliteration_get($output);
}
// Reduce to the subset of ASCII96 letters and numbers
// Reduce to the subset of ASCII96 letters and numbers.
if ($settings['reduce ascii']) {
$pattern = '/[^a-zA-Z0-9\/]+/';
$output = preg_replace($pattern, $settings['separator'], $output);
}
// Get rid of words that are on the ignore list
// Get rid of words that are on the ignore list.
if (!empty($settings['ignore words'])) {
$ignore_re = '\b' . preg_replace('/,/', '\b|\b', $settings['ignore words']) . '\b';
@@ -159,14 +158,14 @@ function ctools_cleanstring($string, $settings = array()) {
else {
$seppattern = '\\' . $settings['separator'];
}
// Trim any leading or trailing separators (note the need to
// Trim any leading or trailing separators (note the need to.
$output = preg_replace("/^$seppattern+|$seppattern+$/", '', $output);
// Replace multiple separators with a single one
// Replace multiple separators with a single one.
$output = preg_replace("/$seppattern+/", $settings['separator'], $output);
}
// Enforce the maximum component length
// Enforce the maximum component length.
if (!empty($settings['max length'])) {
$output = ctools_cleanstring_truncate($output, $settings['max length'], $settings['separator']);
}
@@ -188,12 +187,14 @@ function ctools_cleanstring($string, $settings = array()) {
* A string which contains the word boundary such as - or _.
*
* @return
* The string truncated below the maxlength.
* The string truncated below the maxlength.
*/
function ctools_cleanstring_truncate($string, $length, $separator) {
if (drupal_strlen($string) > $length) {
$string = drupal_substr($string, 0, $length + 1); // leave one more character
if ($last_break = strrpos($string, $separator)) { // space exists AND is not on position 0
// Leave one more character.
$string = drupal_substr($string, 0, $length + 1);
// Space exists AND is not on position 0.
if ($last_break = strrpos($string, $separator)) {
$string = substr($string, 0, $last_break);
}
else {

View File

@@ -30,8 +30,8 @@ function ctools_collapsible_theme(&$items) {
* Text to put in the handle/title area of the div.
* @param $content
* Text to put in the content area of the div, this is what will get
* collapsed
* @param $collapsed = FALSE
* collapsed.
* @param $collapsed
* If true, this div will start out collapsed.
*/
function theme_ctools_collapsible($vars) {
@@ -56,8 +56,8 @@ function theme_ctools_collapsible($vars) {
* Text to put in the handle/title area of the div.
* @param $content
* Text to put in the content area of the div, this is what will get
* collapsed
* @param $collapsed = FALSE
* collapsed.
* @param $collapsed
* If true, this div will start out collapsed.
*/
function theme_ctools_collapsible_remembered($vars) {
@@ -76,4 +76,3 @@ function theme_ctools_collapsible_remembered($vars) {
return $output;
}

View File

@@ -86,7 +86,7 @@ function ctools_content_process(&$plugin, $info) {
/**
* Fetch metadata on a specific content_type plugin.
*
* @param $content type
* @param mixed $content
* Name of a panel content type.
*
* @return
@@ -146,7 +146,7 @@ function ctools_content_get_subtypes($type) {
if (is_array($function)) {
$subtypes = $function;
}
else if (function_exists($function)) {
elseif (function_exists($function)) {
// Cast to array to prevent errors from non-array returns.
$subtypes = (array) $function($plugin);
}
@@ -157,7 +157,7 @@ function ctools_content_get_subtypes($type) {
foreach ($subtypes as $id => $subtype) {
// Ensure that the 'subtype_id' value exists.
if (!isset($subtype['subtype_id'])) {
$subtype['subtype_id'] = $id;
$subtypes[$id]['subtype_id'] = $id;
}
// Use exact name since this is a modify by reference.
@@ -207,6 +207,13 @@ function ctools_content_get_subtype($type, $subtype_id) {
}
if ($subtype) {
// Ensure that the 'subtype_id' value exists. This is also done in
// ctools_content_get_subtypes(), but it wouldn't be called if the plugin
// provides the subtype through its own function.
if (!isset($subtype['subtype_id'])) {
$subtype['subtype_id'] = $subtype_id;
}
ctools_content_prepare_subtype($subtype, $plugin);
}
return $subtype;
@@ -300,7 +307,7 @@ function ctools_content_render($type, $subtype, $conf, $keywords = array(), $arg
$content->subtype = $subtype;
}
// Override the title if configured to
// Override the title if configured to.
if (!empty($conf['override_title'])) {
// Give previous title as an available substitution here.
$keywords['%title'] = empty($content->title) ? '' : $content->title;
@@ -310,12 +317,12 @@ function ctools_content_render($type, $subtype, $conf, $keywords = array(), $arg
}
if (!empty($content->title)) {
// Perform substitutions
// Perform substitutions.
if (!empty($keywords) || !empty($context)) {
$content->title = ctools_context_keyword_substitute($content->title, $keywords, $context);
}
// Sterilize the title
// Sterilize the title.
$content->title = filter_xss_admin($content->title);
// If a link is specified, populate.
@@ -326,7 +333,7 @@ function ctools_content_render($type, $subtype, $conf, $keywords = array(), $arg
else {
$url = $content->title_link;
}
// set defaults so we don't bring up notices
// Set defaults so we don't bring up notices.
$url += array('href' => '', 'attributes' => array(), 'query' => array(), 'fragment' => '', 'absolute' => NULL, 'html' => TRUE);
$content->title = l($content->title, $url['href'], $url);
}
@@ -348,7 +355,7 @@ function ctools_content_editable($type, $subtype, $conf) {
}
$function = FALSE;
if (!empty($subtype['check editable'])) {
$function = ctools_plugin_get_function($subtype, 'check editable');
}
@@ -379,7 +386,7 @@ function ctools_content_admin_title($type, $subtype, $conf, $context = NULL) {
if (is_array($type)) {
$plugin = $type;
}
else if (is_string($type)) {
elseif (is_string($type)) {
$plugin = ctools_get_content_type($type);
}
else {
@@ -397,10 +404,10 @@ function ctools_content_admin_title($type, $subtype, $conf, $context = NULL) {
return $function($subtype, $conf, $pane_context);
}
else if (isset($plugin['admin title'])) {
elseif (isset($plugin['admin title'])) {
return $plugin['admin title'];
}
else if (isset($plugin['title'])) {
elseif (isset($plugin['title'])) {
return $plugin['title'];
}
}
@@ -435,7 +442,7 @@ function ctools_content_get_defaults($plugin, $subtype) {
if (isset($plugin['defaults'])) {
$defaults = $plugin['defaults'];
}
else if (isset($subtype['defaults'])) {
elseif (isset($subtype['defaults'])) {
$defaults = $subtype['defaults'];
}
if (isset($defaults)) {
@@ -444,7 +451,7 @@ function ctools_content_get_defaults($plugin, $subtype) {
return $return;
}
}
else if (is_array($defaults)) {
elseif (is_array($defaults)) {
return $defaults;
}
}
@@ -478,7 +485,7 @@ function ctools_content_admin_info($type, $subtype, $conf, $context = NULL) {
if (empty($output) || !is_object($output)) {
$output = new stdClass();
// replace the _ with " " for a better output
// Replace the _ with " " for a better output.
$subtype = check_plain(str_replace("_", " ", $subtype));
$output->title = $subtype;
$output->content = t('No info available.');
@@ -487,7 +494,7 @@ function ctools_content_admin_info($type, $subtype, $conf, $context = NULL) {
}
/**
* Add the default FAPI elements to the content type configuration form
* Add the default FAPI elements to the content type configuration form.
*/
function ctools_content_configure_form_defaults($form, &$form_state) {
$plugin = $form_state['plugin'];
@@ -604,7 +611,7 @@ function ctools_content_form($op, $form_info, &$form_state, $plugin, $subtype_na
if (!empty($subtype['add form'])) {
_ctools_content_create_form_info($form_info, $subtype['add form'], $subtype, $subtype, $op);
}
else if (!empty($plugin['add form'])) {
elseif (!empty($plugin['add form'])) {
_ctools_content_create_form_info($form_info, $plugin['add form'], $plugin, $subtype, $op);
}
}
@@ -614,7 +621,7 @@ function ctools_content_form($op, $form_info, &$form_state, $plugin, $subtype_na
if (!empty($subtype['edit form'])) {
_ctools_content_create_form_info($form_info, $subtype['edit form'], $subtype, $subtype, $op);
}
else if (!empty($plugin['edit form'])) {
elseif (!empty($plugin['edit form'])) {
_ctools_content_create_form_info($form_info, $plugin['edit form'], $plugin, $subtype, $op);
}
}
@@ -633,7 +640,7 @@ function _ctools_content_create_form_info(&$form_info, $info, $plugin, $subtype,
if (empty($subtype['title'])) {
$title = t('Configure');
}
else if ($op == 'add') {
elseif ($op == 'add') {
$title = t('Configure new !subtype_title', array('!subtype_title' => $subtype['title']));
}
else {
@@ -648,7 +655,7 @@ function _ctools_content_create_form_info(&$form_info, $info, $plugin, $subtype,
),
);
}
else if (is_array($info)) {
elseif (is_array($info)) {
$form_info['order'] = array();
$form_info['forms'] = array();
$count = 0;
@@ -699,7 +706,7 @@ function ctools_content_get_available_types($contexts = NULL, $has_content = FAL
foreach ($plugins as $id => $plugin) {
foreach (ctools_content_get_subtypes($plugin) as $subtype_id => $subtype) {
// exclude items that require content if we're saying we don't
// Exclude items that require content if we're saying we don't
// provide it.
if (!empty($subtype['requires content']) && !$has_content) {
continue;
@@ -739,7 +746,6 @@ function ctools_content_get_available_types($contexts = NULL, $has_content = FAL
* Get an array of all content types that can be fed into the
* display editor for the add content list, regardless of
* availability.
*
*/
function ctools_content_get_all_types() {
$plugins = ctools_get_content_types();

View File

@@ -62,9 +62,8 @@ function ctools_content_autocomplete_entity($entity_type, $string = '') {
}
}
/*
* Use well known/tested entity reference code to build our search query
* From EntityReference_SelectionHandler_Generic class
/**
* Use EntityReference_SelectionHandler_Generic class to build our search query.
*/
function _ctools_buildQuery($entity_type, $entity_info, $match = NULL, $match_operator = 'CONTAINS') {
$base_table = $entity_info['base table'];
@@ -92,13 +91,13 @@ function _ctools_buildQuery($entity_type, $entity_info, $match = NULL, $match_op
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'.
// '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
// 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);
@@ -125,7 +124,7 @@ function _ctools_getReferencableEntities($entity_type, $entity_info, $match = NU
global $user;
$account = $user;
$options = array();
// We're an entity ID, return the id
// 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'])) {
@@ -143,10 +142,10 @@ function _ctools_getReferencableEntities($entity_type, $entity_info, $match = NU
// If you don't have access, or an access callback or a valid entity, just
// Return back the Entity ID.
return array(
$match => array(
$match => array(
'label' => $match,
'bundle' => NULL,
),
),
);
}

View File

@@ -14,4 +14,4 @@ function ctools_content_plugin_type(&$items) {
'path' => drupal_get_path('module', 'ctools') . '/includes',
),
);
}
}

View File

@@ -245,10 +245,10 @@ function ctools_access_admin_form_submit($form, &$form_state) {
// --------------------------------------------------------------------------
// AJAX menu entry points.
/**
* AJAX callback to add a new access test to the list.
*/
function ctools_access_ajax_add($fragment = NULL, $name = NULL) {
ctools_include('ajax');
ctools_include('modal');
@@ -263,7 +263,7 @@ function ctools_access_ajax_add($fragment = NULL, $name = NULL) {
ctools_ajax_render_error();
}
// Separate the fragment into 'module' and 'argument'
// Separate the fragment into 'module' and 'argument'.
if (strpos($fragment, '-') === FALSE) {
$module = $fragment;
$argument = NULL;
@@ -279,7 +279,7 @@ function ctools_access_ajax_add($fragment = NULL, $name = NULL) {
list($access, $contexts) = $function($argument);
// Make sure we have the logged in user context
// Make sure we have the logged in user context.
if (!isset($contexts['logged-in-user'])) {
$contexts['logged-in-user'] = ctools_access_get_loggedin_context();
}
@@ -306,6 +306,9 @@ function ctools_access_ajax_add($fragment = NULL, $name = NULL) {
);
$output = ctools_modal_form_wrapper('ctools_access_ajax_edit_item', $form_state);
$access = $form_state['access'];
$access['plugins'][$id] = $form_state['test'];
if (!isset($output[0])) {
$function = $module . '_ctools_access_set';
if (function_exists($function)) {
@@ -333,7 +336,7 @@ function ctools_access_ajax_edit($fragment = NULL, $id = NULL) {
ctools_ajax_render_error();
}
// Separate the fragment into 'module' and 'argument'
// Separate the fragment into 'module' and 'argument'.
if (strpos($fragment, '-') === FALSE) {
$module = $fragment;
$argument = NULL;
@@ -353,7 +356,7 @@ function ctools_access_ajax_edit($fragment = NULL, $id = NULL) {
ctools_ajax_render_error();
}
// Make sure we have the logged in user context
// Make sure we have the logged in user context.
if (!isset($contexts['logged-in-user'])) {
$contexts['logged-in-user'] = ctools_access_get_loggedin_context();
}
@@ -372,6 +375,9 @@ function ctools_access_ajax_edit($fragment = NULL, $id = NULL) {
);
$output = ctools_modal_form_wrapper('ctools_access_ajax_edit_item', $form_state);
$access = $form_state['access'];
$access['plugins'][$id] = $form_state['test'];
if (!isset($output[0])) {
$function = $module . '_ctools_access_set';
if (function_exists($function)) {
@@ -451,7 +457,7 @@ function ctools_access_ajax_delete($fragment = NULL, $id = NULL) {
ajax_render_error();
}
// Separate the fragment into 'module' and 'argument'
// Separate the fragment into 'module' and 'argument'.
if (strpos($fragment, '-') === FALSE) {
$module = $fragment;
$argument = NULL;
@@ -471,7 +477,7 @@ function ctools_access_ajax_delete($fragment = NULL, $id = NULL) {
unset($access['plugins'][$id]);
}
// re-cache
// re-cache.
$function = $module . '_ctools_access_set';
if (function_exists($function)) {
$function($argument, $access);

View File

@@ -395,7 +395,7 @@ function ctools_context_ajax_item_add($mechanism = NULL, $type = NULL, $cache_ke
if (!empty($form_state['cancel'])) {
$output = array(ctools_modal_command_dismiss());
}
else if (!empty($form_state['complete'])) {
elseif (!empty($form_state['complete'])) {
// Successful submit -- move temporary data to location.
// Create a reference to the place our context lives. Since this is fairly
@@ -580,7 +580,7 @@ function ctools_context_ajax_item_edit($mechanism = NULL, $type = NULL, $cache_k
if (!empty($form_state['cancel'])) {
$output = array(ctools_modal_command_dismiss());
}
else if (!empty($form_state['complete'])) {
elseif (!empty($form_state['complete'])) {
// successful submit
$ref[$position] = $conf;
if (isset($object->temporary)) {
@@ -657,7 +657,7 @@ function ctools_context_get_defaults($plugin_definition, $object, $type) {
if (isset($plugin_definition['defaults'])) {
$defaults = $plugin_definition['defaults'];
}
else if (isset($subtype['defaults'])) {
elseif (isset($subtype['defaults'])) {
$defaults = $subtype['defaults'];
}
@@ -667,7 +667,7 @@ function ctools_context_get_defaults($plugin_definition, $object, $type) {
$conf += $settings;
}
}
else if (is_array($defaults)) {
elseif (is_array($defaults)) {
$conf += $defaults;
}
}

View File

@@ -4,9 +4,9 @@
* @file
* Support for creating 'context' type task handlers.
*
* Context task handlers expect the task to provide 0 or more contexts. The
* task handler should use those contexts as selection rules, as well as
* rendering with them.
* Context task handlers expect the task to provide 0 or more contexts. The task
* handler should use those contexts as selection rules, as well as rendering
* with them.
*
* The functions and forms in this file should be common to every context type
* task handler made.
@@ -31,6 +31,7 @@
* If TRUE then this renderer owns the page and can use theme('page')
* for no blocks; if false, output is returned regardless of any no
* blocks settings.
*
* @return
* Either the output or NULL if there was output, FALSE if no handler
* accepted the task. If $page is FALSE then the $info block is returned instead.
@@ -84,7 +85,7 @@ function ctools_context_handler_get_render_handler($task, $subtask, $handlers, $
*/
function ctools_context_handler_default_test($handler, $base_contexts, $args) {
ctools_include('context');
// Add my contexts
// Add my contexts.
$contexts = ctools_context_handler_get_handler_contexts($base_contexts, $handler);
// Test.
@@ -128,7 +129,7 @@ function ctools_context_handler_render_handler($task, $subtask, $handler, $conte
'contexts' => $contexts,
'task' => $task,
'subtask' => $subtask,
'handler' => $handler
'handler' => $handler,
);
drupal_alter('ctools_render', $info, $page, $context);
@@ -141,12 +142,15 @@ function ctools_context_handler_render_handler($task, $subtask, $handler, $conte
switch ($info['response code']) {
case 403:
return MENU_ACCESS_DENIED;
case 404:
return MENU_NOT_FOUND;
case 410:
drupal_add_http_header('Status', '410 Gone');
drupal_exit();
break;
case 301:
case 302:
case 303:
@@ -162,7 +166,7 @@ function ctools_context_handler_render_handler($task, $subtask, $handler, $conte
'fragment' => $info['fragment'],
);
drupal_goto($info['destination'], $options, $info['response code']);
// @todo -- should other response codes be supported here?
// @todo -- should other response codes be supported here?
}
}
@@ -222,7 +226,7 @@ function ctools_context_handler_render_handler($task, $subtask, $handler, $conte
}
/**
* Default function to provide contextual link for a task as defined by the handler.
* Provides contextual link for a task as defined by the handler.
*
* This provides a simple link to th main content operation and is suitable
* for most normal handlers. Setting 'contextual link' to a function overrides
@@ -241,7 +245,7 @@ function ctools_task_handler_default_contextual_link($handler, $plugin, $context
if (is_array($plugin['tab operation'])) {
$trail = $plugin['tab operation'];
}
else if (function_exists($plugin['tab operation'])) {
elseif (function_exists($plugin['tab operation'])) {
$trail = $plugin['tab operation']($handler, $contexts, $args);
}
}
@@ -251,7 +255,8 @@ function ctools_task_handler_default_contextual_link($handler, $plugin, $context
'href' => $path,
'title' => $title,
'query' => drupal_get_destination(),
));
),
);
return $links;
}
@@ -259,17 +264,22 @@ function ctools_task_handler_default_contextual_link($handler, $plugin, $context
/**
* Called to execute actions that should happen before a handler is rendered.
*/
function ctools_context_handler_pre_render($handler, $contexts, $args) { }
function ctools_context_handler_pre_render($handler, $contexts, $args) {
foreach (module_implements('ctools_context_handler_pre_render') as $module) {
$function = $module . '_ctools_context_handler_pre_render';
$function($handler, $contexts, $args);
}
}
/**
* Compare arguments to contexts for selection purposes.
*
* @param $handler
* @param object $handler
* The handler in question.
* @param $contexts
* @param object $contexts
* The context objects provided by the task.
*
* @return
* @return bool
* TRUE if these contexts match the selection rules. NULL or FALSE
* otherwise.
*/
@@ -288,12 +298,15 @@ function ctools_context_handler_select($handler, $contexts) {
* These summary strings are used to communicate to the user what
* arguments the task handlers are selecting.
*
* @param $task
* @param object $task
* The loaded task plugin.
* @param $subtask
* @param object $subtask
* The subtask id.
* @param $handler
* @param object $handler
* The handler to be checked.
*
* @return array
* Returns array of summary strings for arguments selected by task handlers.
*/
function ctools_context_handler_summary($task, $subtask, $handler) {
if (empty($handler->conf['access']['plugins'])) {
@@ -320,7 +333,6 @@ function ctools_context_handler_summary($task, $subtask, $handler) {
// the task handler, for example) but sometimes we need them separately
// (when a task has contexts loaded and is trying out the task handlers,
// for example). Therefore there are two paths we can take to getting contexts.
/**
* Load the contexts for a task, using arguments.
*
@@ -368,7 +380,7 @@ function ctools_context_handler_get_all_contexts($task, $subtask, $handler) {
* expects things in a certain, kind of clunky format.
*/
function ctools_context_handler_get_handler_object($handler) {
$object = new stdClass;
$object = new stdClass();
$object->name = $handler->name;
$object->contexts = isset($handler->conf['contexts']) ? $handler->conf['contexts'] : array();
$object->relationships = isset($handler->conf['relationships']) ? $handler->conf['relationships'] : array();
@@ -382,7 +394,7 @@ function ctools_context_handler_get_handler_object($handler) {
* arguments from the task.
*/
function ctools_context_handler_get_task_object($task, $subtask, $handler) {
$object = new stdClass;
$object = new stdClass();
$object->name = !empty($handler->name) ? $handler->name : 'temp';
$object->base_contexts = ctools_context_handler_get_base_contexts($task, $subtask, TRUE);
$object->arguments = ctools_context_handler_get_task_arguments($task, $subtask);
@@ -456,7 +468,7 @@ function ctools_context_handler_edit_criteria($form, &$form_state) {
ctools_modal_add_plugin_js(ctools_get_access_plugins());
ctools_include('context-access-admin');
$form_state['module'] = (isset($form_state['module'])) ? $form_state['module'] : 'page_manager_task_handler';
// Encode a bunch of info into the argument so we can get our cache later
// Encode a bunch of info into the argument so we can get our cache later.
$form_state['callback argument'] = $form_state['task_name'] . '*' . $form_state['handler']->name;
$form_state['access'] = $form_state['handler']->conf['access'];
$form_state['no buttons'] = TRUE;
@@ -472,7 +484,7 @@ function ctools_context_handler_edit_criteria($form, &$form_state) {
}
/**
* Submit handler for rules selection
* Submit handler for rules selection.
*/
function ctools_context_handler_edit_criteria_submit(&$form, &$form_state) {
$form_state['handler']->conf['access']['logic'] = $form_state['values']['logic'];
@@ -537,4 +549,3 @@ function ctools_context_handler_edit_context_submit(&$form, &$form_state) {
unset($form_state['page']->context_cache[$cache_name]);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -25,7 +25,7 @@ function ctools_context_menu(&$items) {
'page callback' => 'ctools_context_ajax_item_delete',
) + $base;
// For the access system
// For the access system.
$base['file'] = 'includes/context-access-admin.inc';
$items['ctools/context/ajax/access/add'] = array(
'page callback' => 'ctools_access_ajax_add',

View File

@@ -19,7 +19,6 @@ function ctools_context_theme(&$theme) {
);
$theme['ctools_context_item_form'] = array(
'render element' => 'form',
// 'variables' => array('form' => NULL),
'file' => 'includes/context.theme.inc',
);
$theme['ctools_context_item_row'] = array(
@@ -27,7 +26,7 @@ function ctools_context_theme(&$theme) {
'file' => 'includes/context.theme.inc',
);
// For the access plugin
// For the access plugin.
$theme['ctools_access_admin_add'] = array(
'render element' => 'form',
'file' => 'includes/context-access-admin.inc',
@@ -62,10 +61,10 @@ function theme_ctools_context_item_row($vars) {
function theme_ctools_context_item_form($vars) {
$form = $vars['form'];
$output = '';
$type = $form['#ctools_context_type'];
$module = $form['#ctools_context_module'];
$cache_key = $form['#cache_key'];
$output = '';
$type = $form['#ctools_context_type'];
$module = $form['#ctools_context_module'];
$cache_key = $form['#cache_key'];
$type_info = ctools_context_info($type);
@@ -104,17 +103,17 @@ function theme_ctools_context_item_form($vars) {
if (!empty($form['buttons'])) {
// Display the add context item.
$row = array();
$row[] = array('data' => render($form['buttons'][$type]['item']), 'class' => array('title'));
$row[] = array('data' => render($form['buttons'][$type]['add']), 'class' => array('add'), 'width' => "60%");
$output .= '<div class="buttons">';
$output .= render($form['buttons'][$type]);
$theme_vars = array();
$theme_vars['header'] = array();
$theme_vars['rows'] = array($row);
$row = array();
$row[] = array('data' => render($form['buttons'][$type]['item']), 'class' => array('title'));
$row[] = array('data' => render($form['buttons'][$type]['add']), 'class' => array('add'), 'width' => "60%");
$output .= '<div class="buttons">';
$output .= render($form['buttons'][$type]);
$theme_vars = array();
$theme_vars['header'] = array();
$theme_vars['rows'] = array($row);
$theme_vars['attributes'] = array('id' => $type . '-add-table');
$output .= theme('table', $theme_vars);
$output .= '</div>';
$output .= theme('table', $theme_vars);
$output .= '</div>';
}
if (!empty($form['description'])) {
$output .= render($form['description']);
@@ -139,7 +138,7 @@ function theme_ctools_context_list($vars) {
$description = (!empty($vars['description'])) ? $vars['description'] : NULL;
$titles = array();
$output = '';
$count = 1;
$count = 1;
$contexts = ctools_context_load_contexts($object);
@@ -209,7 +208,7 @@ function theme_ctools_context_list($vars) {
}
}
// And relationships
// And relationships.
if (!empty($object->relationships)) {
foreach ($object->relationships as $relationship) {
$output .= '<tr>';
@@ -253,15 +252,15 @@ function theme_ctools_context_list($vars) {
}
/**
* ctools_context_list() but not in a table format because tabledrag
* won't let us have tables within tables and still drag.
* The ctools_context_list() function but not in a table format because
* tabledrag won't let us have tables within tables and still drag.
*/
function theme_ctools_context_list_no_table($vars) {
$object = $vars['object'];
ctools_add_css('context');
$titles = array();
$output = '';
$count = 1;
$count = 1;
// Describe 'built in' contexts.
if (!empty($object->base_contexts)) {
foreach ($object->base_contexts as $id => $context) {
@@ -312,7 +311,7 @@ function theme_ctools_context_list_no_table($vars) {
$count++;
}
}
// And relationships
// And relationships.
if (!empty($object->relationships)) {
foreach ($object->relationships as $relationship) {
$output .= '<div class="ctools-context-holder clearfix">';
@@ -341,4 +340,3 @@ function theme_ctools_context_list_no_table($vars) {
return $output;
}

View File

@@ -1,6 +1,6 @@
<?php
/*
/**
* @file
* CSS filtering functions. Contains a disassembler, filter, compressor, and
* decompressor.
@@ -149,11 +149,11 @@ function ctools_css_clear($id) {
*
* @param $css
* A chunk of well-formed CSS text to cache.
* @param $filter
* @param bool $filter
* If TRUE the css will be filtered. If FALSE the text will be cached
* as-is.
*
* @return $filename
* @return string
* The filename the CSS will be cached in.
*/
function ctools_css_cache($css, $filter = TRUE) {
@@ -164,7 +164,6 @@ function ctools_css_cache($css, $filter = TRUE) {
// Create the css/ within the files folder.
$path = 'public://ctools/css';
if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
// if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
drupal_set_message(t('Unable to create CTools CSS cache directory. Check the permissions on your files directory.'), 'error');
return;
}
@@ -213,7 +212,7 @@ function ctools_css_filter($css, $compressed = TRUE) {
* An array of css data, as produced by @see ctools_css_disassemble()
* disassembler and the @see ctools_css_filter_css_data() filter.
*
* @return string $css
* @return string
* css optimized for human viewing.
*/
function ctools_css_assemble($css_data) {
@@ -243,7 +242,7 @@ function ctools_css_assemble($css_data) {
* An array of css data, as produced by @see ctools_css_disassemble()
* disassembler and the @see ctools_css_filter_css_data() filter.
*
* @return string $css
* @return string
* css optimized for use.
*/
function ctools_css_compress($css_data) {
@@ -279,7 +278,7 @@ function ctools_css_compress($css_data) {
* @param string $css
* A string containing the css to be disassembled.
*
* @return array $disassembled_css
* @return array
* An array of disassembled, slightly cleaned-up/formatted css statements.
*/
function ctools_css_disassemble($css) {
@@ -385,7 +384,6 @@ function _ctools_css_disassemble_declaration($declaration) {
* An array of disassembled, filtered CSS.
*/
function ctools_css_filter_css_data($css, $allowed_properties = array(), $allowed_values = array(), $allowed_values_regex = '', $disallowed_values_regex = '') {
//function ctools_css_filter_css_data($css, &$filtered = NULL, $allowed_properties = array(), $allowed_values = array(), $allowed_values_regex = '', $disallowed_values_regex = '') {
// Retrieve the default list of allowed properties if none is provided.
$allowed_properties = !empty($allowed_properties) ? $allowed_properties : ctools_css_filter_default_allowed_properties();
// Retrieve the default list of allowed values if none is provided.
@@ -393,19 +391,18 @@ function ctools_css_filter_css_data($css, $allowed_properties = array(), $allowe
// Define allowed values regex if none is provided.
$allowed_values_regex = !empty($allowed_values_regex) ? $allowed_values_regex : '/(#[0-9a-f]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)/';
// Define disallowed url() value contents, if none is provided.
// $disallowed_values_regex = !empty($disallowed_values_regex) ? $disallowed_values_regex : '/[url|expression]\s*\(\s*[^\s)]+?\s*\)\s*/';
$disallowed_values_regex = !empty($disallowed_values_regex) ? $disallowed_values_regex : '/(url|expression)/';
foreach ($css as $selector_str => $declaration) {
foreach ($declaration as $property => $value) {
if (!in_array($property, $allowed_properties)) {
// $filtered['properties'][$selector_str][$property] = $value;
// $filtered['properties'][$selector_str][$property] = $value;.
unset($css[$selector_str][$property]);
continue;
}
$value = str_replace('!important', '', $value);
if (preg_match($disallowed_values_regex, $value) || !(in_array($value, $allowed_values) || preg_match($allowed_values_regex, $value))) {
// $filtered['values'][$selector_str][$property] = $value;
// $filtered['values'][$selector_str][$property] = $value;.
unset($css[$selector_str][$property]);
continue;
}

View File

@@ -44,7 +44,7 @@
*
* A fuller example, that hides the menu title when no menu is selected:
* @code
*function ctools_dependent_example() {
* function ctools_dependent_example() {
* $form = array();
* $form['menu'] = array(
* '#type' => 'fieldset',
@@ -72,12 +72,12 @@
* );
*
* return system_settings_form($form);
*}
* }
* @endcode
*
* An example for hiding checkboxes using #prefix and #suffix:
* @code
*function ctools_dependent_example_checkbox() {
* function ctools_dependent_example_checkbox() {
* $form = array();
* $form['object'] = array(
* '#type' => 'fieldset',
@@ -111,7 +111,7 @@
* );
*
* return system_settings_form($form);
*}
* }
* @endcode
*
* Deprecated:
@@ -125,7 +125,6 @@
/**
* Process callback to add dependency to form items.
*
*/
function ctools_dependent_process($element, &$form_state, &$form) {
return $element;

View File

@@ -75,7 +75,7 @@ function theme_links__ctools_dropbutton($vars) {
if (!empty($vars['links'])) {
$is_drop_button = (count($vars['links']) > 1);
// Add needed files
// Add needed files.
if ($is_drop_button) {
ctools_add_js('dropbutton');
ctools_add_css('dropbutton');
@@ -86,7 +86,7 @@ function theme_links__ctools_dropbutton($vars) {
static $id = 0;
$id++;
// Wrapping div
// Wrapping div.
$class = 'ctools-no-js';
$class .= ($is_drop_button) ? ' ctools-dropbutton' : '';
$class .= ' ctools-button';
@@ -98,21 +98,22 @@ function theme_links__ctools_dropbutton($vars) {
$output .= '<div class="' . $class . '" id="ctools-button-' . $id . '">';
// Add a twisty if this is a dropbutton
// Add a twisty if this is a dropbutton.
if ($is_drop_button) {
$vars['title'] = ($vars['title'] ? check_plain($vars['title']) : t('open'));
$output .= '<div class="ctools-link">';
if ($vars['image']) {
$output .= '<a href="#" class="ctools-twisty ctools-image">' . $vars['title'] . '</a>';
$output .= '<a href="#" class="ctools-twisty ctools-image"><span class="element-invisible">' . $vars['title'] . '</span></a>';
}
else {
$output .= '<a href="#" class="ctools-twisty ctools-text">' . $vars['title'] . '</a>';
$output .= '<a href="#" class="ctools-twisty ctools-text"><span class="element-invisible">' . $vars['title'] . '</span></a>';
}
$output .= '</div>'; // ctools-link
// ctools-link.
$output .= '</div>';
}
// The button content
// The button content.
$output .= '<div class="ctools-content">';
// Check for attributes. theme_links expects an array().
@@ -132,12 +133,11 @@ function theme_links__ctools_dropbutton($vars) {
// Call theme_links to render the list of links.
$output .= theme_links(array('links' => $vars['links'], 'attributes' => $vars['attributes'], 'heading' => ''));
$output .= '</div>'; // ctools-content
$output .= '</div>'; // ctools-dropbutton
$output .= '</div>'; // ctools-content.
$output .= '</div>'; // ctools-dropbutton.
return $output;
}
else {
return '';
}
}

View File

@@ -44,20 +44,21 @@ function ctools_dropdown_theme(&$items) {
/**
* Create a dropdown menu.
*
* @param $title
* The text to place in the clickable area to activate the dropdown.
* @param $links
* A list of links to provide within the dropdown, suitable for use
* in via Drupal's theme('links').
* @param $image
* If true, the dropdown link is an image and will not get extra decorations
* that a text dropdown link will.
* @param $class
* An optional class to add to the dropdown's container div to allow you
* to style a single dropdown however you like without interfering with
* other dropdowns.
* @param array $variables
* An associative array containing:
* - title: The text to place in the clickable area to activate the dropdown.
* - links: A list of links to provide within the dropdown, suitable for use
* in via Drupal's theme('links').
* - image: If true, the dropdown link is an image and will not get extra
* decorations that a text dropdown link will.
* - class: An optional class to add to the dropdown's container div to allow
* you to style a single dropdown however you like without interfering with
* other dropdowns.
*
* @return string
* Returns HTML for a language configuration form.
*/
function theme_ctools_dropdown($vars) {
function theme_ctools_dropdown($vars) {
// Provide a unique identifier for every dropdown on the page.
static $id = 0;
$id++;
@@ -67,9 +68,7 @@ function theme_ctools_dropdown($vars) {
ctools_add_js('dropdown');
ctools_add_css('dropdown');
$output = '';
$output .= '<div class="' . $class . '" id="ctools-dropdown-' . $id . '">';
$output = '<div class="' . $class . '" id="ctools-dropdown-' . $id . '">';
$output .= '<div class="ctools-dropdown-link-wrapper">';
if ($vars['image']) {
$output .= '<a href="#" class="ctools-dropdown-link ctools-dropdown-image-link">' . $vars['title'] . '</a>';
@@ -77,14 +76,13 @@ function theme_ctools_dropdown($vars) {
else {
$output .= '<a href="#" class="ctools-dropdown-link ctools-dropdown-text-link">' . check_plain($vars['title']) . '</a>';
}
$output .= '</div>'; // wrapper
$output .= '</div>';
$output .= '<div class="ctools-dropdown-container-wrapper">';
$output .= '<div class="ctools-dropdown-container">';
$output .= theme_links(array('links' => $vars['links'], 'attributes' => array(), 'heading' => ''));
$output .= '</div>'; // container
$output .= '</div>'; // container wrapper
$output .= '</div>'; // dropdown
$output .= '</div>';
$output .= '</div>';
$output .= '</div>';
return $output;
}

View File

@@ -24,19 +24,23 @@ function _ctools_entity_access(&$entity_info, $entity_type) {
// 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';
@@ -64,7 +68,7 @@ function _ctools_entity_access(&$entity_info, $entity_type) {
*
* @throws EntityMalformedException
*
* @return boolean
* @return bool
* TRUE if access is allowed, FALSE otherwise.
*/
function ctools_metadata_no_hook_node_access($op, $node = NULL, $account = NULL) {

View File

@@ -81,7 +81,6 @@ function ctools_export_ui_process(&$plugin, $info) {
// Add some default fields that appear often in exports
// If these use different keys they can easily be specified in the
// $plugin.
if (empty($plugin['export']['admin_title']) && !empty($schema['fields']['admin_title'])) {
$plugin['export']['admin_title'] = 'admin_title';
}
@@ -297,7 +296,6 @@ function ctools_export_ui_process(&$plugin, $info) {
);
// Define strings.
// For all strings, %title may be filled in at a later time via str_replace
// since we do not know the title now.
$plugin['strings'] += array(
@@ -335,7 +333,7 @@ function ctools_export_ui_process(&$plugin, $info) {
$plugin['strings']['confirmation']['delete'] += array(
'question' => t('Are you sure you want to delete %title?'),
'information' => t('This action will permanently remove this item from your database..'),
'information' => t('This action will permanently remove this item from your database.'),
'success' => t('The item has been deleted.'),
);
@@ -414,6 +412,7 @@ function ctools_export_ui_plugin_base_path($plugin) {
* The id in the menu items from the plugin.
* @param $export_key
* The export key of the item being edited, if it exists.
*
* @return
* The menu path to the plugin's list.
*/
@@ -429,12 +428,11 @@ function ctools_export_ui_plugin_menu_path($plugin, $item_id, $export_key = NULL
* Helper function to include CTools plugins and get an export-ui exportable.
*
* @param $plugin_name
* The plugin that should be laoded.
* The plugin that should be loaded.
*/
function ctools_get_export_ui($plugin_name) {
ctools_include('plugins');
return ctools_get_plugins('ctools', 'export_ui', $plugin_name);
}
/**
@@ -456,14 +454,14 @@ function ctools_export_ui_switcher_page($plugin_name, $op) {
$args = func_get_args();
$js = !empty($_REQUEST['js']);
// Load the $plugin information
// Load the $plugin information.
$plugin = ctools_get_export_ui($plugin_name);
$handler = ctools_export_ui_get_handler($plugin);
if ($handler) {
$method = $op . '_page';
if (method_exists($handler, $method)) {
// replace the first two arguments:
// Replace the first two arguments:
$args[0] = $js;
$args[1] = $_POST;
return call_user_func_array(array($handler, $method), $args);

View File

@@ -1,5 +1,9 @@
<?php
/**
* @file
*/
/**
* Delegated implementation of hook_menu().
*/

View File

@@ -17,4 +17,4 @@ function ctools_export_ui_plugin_type(&$items) {
),
'classes' => array('handler'),
);
}
}

View File

@@ -4,7 +4,7 @@
* @file
* Contains code to make it easier to have exportable objects.
*
* Documentation for exportable objects is contained in help/export.html
* Documentation for exportable objects is contained in help/export.html.
*/
/**
@@ -126,6 +126,7 @@ function ctools_export_crud_load_multiple($table, array $names) {
* If TRUE, the static cache of all objects will be flushed prior to
* loading all. This can be important on listing pages where items
* might have changed on the page load.
*
* @return
* An array of all loaded objects, keyed by the unique IDs of the export key.
*/
@@ -328,7 +329,6 @@ function ctools_export_crud_set_status($table, $object, $status) {
}
/**
* Enable a certain object.
*
@@ -426,7 +426,7 @@ function ctools_export_load_object($table, $type = 'all', $args = array()) {
}
}
// Build the query
// Build the query.
$query = db_select($table, 't__0')->fields('t__0');
$alias_count = 1;
if (!empty($schema['join'])) {
@@ -451,7 +451,7 @@ function ctools_export_load_object($table, $type = 'all', $args = array()) {
if ($type == 'names') {
$query->condition($export['key'], $args, 'IN');
}
else if ($type == 'conditions') {
elseif ($type == 'conditions') {
foreach ($args as $key => $value) {
if (isset($schema['fields'][$key])) {
$query->condition($key, $value);
@@ -499,7 +499,7 @@ function ctools_export_load_object($table, $type = 'all', $args = array()) {
if ($defaults) {
foreach ($defaults as $object) {
if ($type == 'conditions') {
// if this does not match all of our conditions, skip it.
// If this does not match all of our conditions, skip it.
foreach ($args as $key => $value) {
if (!isset($object->$key)) {
continue 2;
@@ -509,12 +509,12 @@ function ctools_export_load_object($table, $type = 'all', $args = array()) {
continue 2;
}
}
else if ($object->$key != $value) {
elseif ($object->$key != $value) {
continue 2;
}
}
}
else if ($type == 'names') {
elseif ($type == 'names') {
if (!in_array($object->{$export['key']}, $args)) {
continue;
}
@@ -561,7 +561,6 @@ function ctools_export_load_object($table, $type = 'all', $args = array()) {
}
}
// For conditions,
return $return;
}
@@ -807,10 +806,10 @@ function _ctools_export_get_some_defaults($table, $export, $names) {
function _ctools_export_unpack_object($schema, $data, $object = 'stdClass') {
if (is_string($object)) {
if (class_exists($object)) {
$object = new $object;
$object = new $object();
}
else {
$object = new stdClass;
$object = new stdClass();
}
}
@@ -873,14 +872,14 @@ function ctools_var_export($var, $prefix = '') {
$output .= $prefix . ')';
}
}
else if (is_object($var) && get_class($var) === 'stdClass') {
elseif (is_object($var) && get_class($var) === 'stdClass') {
// var_export() will export stdClass objects using an undefined
// magic method __set_state() leaving the export broken. This
// workaround avoids this by casting the object as an array for
// export and casting it back to an object when evaluated.
$output = '(object) ' . ctools_var_export((array) $var, $prefix);
}
else if (is_bool($var)) {
elseif (is_bool($var)) {
$output = $var ? 'TRUE' : 'FALSE';
}
else {
@@ -959,7 +958,7 @@ function ctools_export_object($table, $object, $indent = '', $identifier = NULL,
}
}
// And bottom additions here
// And bottom additions here.
foreach ($additions2 as $field => $value) {
$output .= $indent . '$' . $identifier . '->' . $field . ' = ' . ctools_var_export($value, $indent) . ";\n";
}
@@ -987,7 +986,7 @@ function ctools_export_get_schema($table) {
// simply hasn't been cached. If we've been asked, let's force the
// issue.
if (!$schema || empty($schema['export'])) {
// force a schema reset:
// Force a schema reset:
$schema = drupal_get_schema($table, TRUE);
}
@@ -999,7 +998,7 @@ function ctools_export_get_schema($table) {
return array();
}
// Add some defaults
// Add some defaults.
$schema['export'] += array(
'key' => 'name',
'key name' => 'Name',
@@ -1107,7 +1106,7 @@ function ctools_export_set_object_status($object, $new_status = TRUE) {
$export = $schema['export'];
$status = variable_get($export['status'], array());
// Compare
// Compare.
if (!$new_status && $object->export_type & EXPORT_IN_DATABASE) {
unset($status[$object->{$export['key']}]);
}
@@ -1150,12 +1149,12 @@ function ctools_export_new_object($table, $set_defaults = TRUE) {
$schema = ctools_export_get_schema($table);
$export = $schema['export'];
$object = new $export['object'];
$object = new $export['object']();
foreach ($schema['fields'] as $field => $info) {
if (isset($info['object default'])) {
$object->$field = $info['object default'];
}
else if (isset($info['default'])) {
elseif (isset($info['default'])) {
$object->$field = $info['default'];
}
else {
@@ -1180,11 +1179,11 @@ function ctools_export_new_object($table, $set_defaults = TRUE) {
function ctools_export_to_hook_code(&$code, $table, $names = array(), $name = 'foo') {
$schema = ctools_export_get_schema($table);
$export = $schema['export'];
// Use the schema-specified function for generating hook code, if one exists
// Use the schema-specified function for generating hook code, if one exists.
if (function_exists($export['to hook code callback'])) {
$output = $export['to hook code callback']($names, $name);
}
// Otherwise, the following code generates basic hook code
// Otherwise, the following code generates basic hook code.
else {
$output = ctools_export_default_to_hook_code($schema, $table, $names, $name);
}
@@ -1236,6 +1235,7 @@ function ctools_export_default_to_hook_code($schema, $table, $names, $name) {
return $output;
}
/**
* Default function for listing bulk exportable objects.
*/

View File

@@ -5,7 +5,6 @@
* Extend core fields with some helper functions to reduce code complexity within views and ctools plugins.
*/
/**
* Fake an instance of a field.
*
@@ -75,27 +74,30 @@ function ctools_fields_get_field_formatter_settings_form($field, $formatter_type
$conf['formatter_settings'] += $formatter['settings'];
}
$function = $formatter['module'] . '_field_formatter_settings_form';
if (function_exists($function)) {
$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;
}
$instance = ctools_fields_fake_field_instance($field['field_name'], $view_mode, $formatter_type, $conf['formatter_settings']);
if (function_exists($function)) {
$settings_form = $function($field, $instance, $view_mode, $form, $form_state);
}
if (empty($settings_form)) {
$settings_form = array();
}
// 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;
if (isset($field['cardinality']) && $field['cardinality'] != 1) {
list($prefix, $suffix) = explode('@count', t('Skip the first @count item(s)'));
@@ -208,15 +210,15 @@ function ctools_field_label($field_name) {
* - Otherwise NULL.
* @param $options
* An associative array of additional options, with the following keys:
* - 'field_name': The name of the field whose operation should be
* - 'field_name': The name of the field whose operation should be
* invoked. By default, the operation is invoked on all the fields
* in the entity's bundle. NOTE: This option is not compatible with
* the 'deleted' option; the 'field_id' option should be used
* instead.
* - 'field_id': The id of the field whose operation should be
* - 'field_id': The id of the field whose operation should be
* invoked. By default, the operation is invoked on all the fields
* in the entity's' bundles.
* - 'default': A boolean value, specifying which implementation of
* - 'default': A boolean value, specifying which implementation of
* the operation should be invoked.
* - if FALSE (default), the field types implementation of the operation
* will be invoked (hook_field_[op])
@@ -224,10 +226,10 @@ function ctools_field_label($field_name) {
* will be invoked (field_default_[op])
* Internal use only. Do not explicitely set to TRUE, but use
* _field_invoke_default() instead.
* - 'deleted': If TRUE, the function will operate on deleted fields
* - 'deleted': If TRUE, the function will operate on deleted fields
* as well as non-deleted fields. If unset or FALSE, only
* non-deleted fields are operated on.
* - 'language': A language code or an array of language codes keyed by field
* - 'language': A language code or an array of language codes keyed by field
* name. It will be used to narrow down to a single value the available
* languages to act on.
*
@@ -340,7 +342,7 @@ function ctools_field_foreign_keys($field_name) {
$foreign_keys[$field_name] = $field['foreign keys'];
}
else {
// try to fetch foreign keys from schema, as not everything
// Try to fetch foreign keys from schema, as not everything
// stores foreign keys properly in the field info.
$module = $field['module'];

View File

@@ -8,7 +8,6 @@
* if javascript is in use. Each item is keyed to the href that the button
* should go to. With javascript, the page is immediately redirected. Without
* javascript, the form is submitted and a drupal_goto() is given.
*
*/
/**
@@ -127,7 +126,7 @@ function ctools_jump_menu_submit($form, &$form_state) {
// This allows duplicate paths to be used in jump menus for multiple options.
$redirect_array = explode("::", $form_state['values']['jump']);
if(isset($redirect_array[1]) && !empty($redirect_array[1])){
if (isset($redirect_array[1]) && !empty($redirect_array[1])) {
$redirect = $redirect_array[1];
}
else {

View File

@@ -1,5 +1,9 @@
<?php
/**
* @file
*/
/**
* Returns array of language names.
*
@@ -32,7 +36,6 @@ function ctools_language_list($field = 'name', $all = FALSE) {
* Returns an array of language names similar to ctools_language_list() except
* that additional choices have been added for ease of use.
*/
function ctools_language_list_all() {
$languages = array(
'***CURRENT_LANGUAGE***' => t("Current user's language"),
@@ -41,4 +44,4 @@ function ctools_language_list_all() {
);
$languages = array_merge($languages, ctools_language_list());
return $languages;
}
}

View File

@@ -99,7 +99,10 @@ class ctools_math_expr {
'sqrt','abs','ln','log',
'time', 'ceil', 'floor', 'min', 'max', 'round');
function __construct() {
/**
* ctools_math_expr constructor.
*/
function __construct() {
// make the variables a little more accurate
$this->v['pi'] = pi();
$this->v['e'] = exp(1);

View File

@@ -55,9 +55,9 @@ function ctools_modal_add_js() {
'alt' => t('Close window'),
)),
'throbber' => theme('image', array(
'path' => ctools_image_path('throbber.gif'),
'title' => t('Loading...'),
'alt' => t('Loading'),
'path' => ctools_image_path('throbber.gif'),
'title' => t('Loading...'),
'alt' => t('Loading'),
)),
),
);
@@ -85,7 +85,7 @@ function ctools_modal_add_plugin_js($plugins) {
if (file_exists($file)) {
$js[$file] = TRUE;
}
else if (file(exists($subtype['path'] . '/' . $file))) {
elseif (file(exists($subtype['path'] . '/' . $file))) {
$js[$subtype['path'] . '/' . $file] = TRUE;
}
}
@@ -95,7 +95,7 @@ function ctools_modal_add_plugin_js($plugins) {
if (file_exists($file)) {
$css[$file] = TRUE;
}
else if (file(exists($subtype['path'] . '/' . $file))) {
elseif (file(exists($subtype['path'] . '/' . $file))) {
$css[$subtype['path'] . '/' . $file] = TRUE;
}
}
@@ -140,7 +140,7 @@ function ctools_modal_command_dismiss() {
}
/**
* Display loading screen in the modal
* Display loading screen in the modal.
*/
function ctools_modal_command_loading() {
return array(
@@ -189,7 +189,7 @@ 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
* 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
@@ -222,7 +222,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'])) {
return ctools_modal_form_render($form_state, $output);
return ctools_modal_form_render($form_state, $output);
}
return $output;

View File

@@ -27,6 +27,7 @@
* defaults to session_id().
*
* @deprecated $skip_cache is deprecated in favor of drupal_static*
*
* @return
* The data that was cached.
*/
@@ -42,8 +43,11 @@ function ctools_object_cache_get($obj, $name, $skip_cache = FALSE, $sid = NULL)
}
if (!array_key_exists($key, $cache)) {
$data = db_query('SELECT * FROM {ctools_object_cache} WHERE sid = :session_id AND obj = :object AND name = :name', array(':session_id' => $sid, ':object' => $obj, ':name' => $name))
->fetchObject();
$data = db_query('SELECT * FROM {ctools_object_cache} WHERE sid = :session_id AND obj = :object AND name = :name', array(
':session_id' => $sid,
':object' => $obj,
':name' => md5($name),
))->fetchObject();
if ($data) {
$cache[$key] = unserialize($data->data);
}
@@ -83,7 +87,7 @@ function ctools_object_cache_set($obj, $name, $cache, $sid = NULL) {
->fields(array(
'sid' => $sid,
'obj' => $obj,
'name' => $name,
'name' => md5($name),
'data' => serialize($cache),
'updated' => REQUEST_TIME,
))
@@ -91,7 +95,7 @@ function ctools_object_cache_set($obj, $name, $cache, $sid = NULL) {
}
/**
* Remove an object from the non-volatile ctools cache
* Remove an object from the non-volatile ctools cache.
*
* @param $obj
* A 128 character or less string to define what kind of object is being
@@ -103,7 +107,6 @@ function ctools_object_cache_set($obj, $name, $cache, $sid = NULL) {
* defaults to session_id().
*/
function ctools_object_cache_clear($obj, $name, $sid = NULL) {
if (!$sid) {
$sid = session_id();
}
@@ -111,13 +114,12 @@ function ctools_object_cache_clear($obj, $name, $sid = NULL) {
db_delete('ctools_object_cache')
->condition('sid', $sid)
->condition('obj', $obj)
->condition('name', $name)
->condition('name', md5($name))
->execute();
// Ensure the static cache is emptied of this obj:name set.
drupal_static_reset('ctools_object_cache_get');
}
/**
* Determine if another user has a given object cached.
*
@@ -142,8 +144,11 @@ function ctools_object_cache_test($obj, $name, $sid = NULL) {
$sid = session_id();
}
return db_query('SELECT s.uid, c.updated FROM {ctools_object_cache} c INNER JOIN {sessions} s ON c.sid = s.sid WHERE s.sid <> :session_id AND c.obj = :obj AND c.name = :name ORDER BY c.updated ASC', array(':session_id' => $sid, ':obj' => $obj, ':name' => $name))
->fetchObject();
return db_query('SELECT s.uid, c.updated FROM {ctools_object_cache} c INNER JOIN {sessions} s ON c.sid = s.sid WHERE s.sid <> :session_id AND c.obj = :obj AND c.name = :name ORDER BY c.updated ASC', array(
':session_id' => $sid,
':obj' => $obj,
':name' => md5($name),
))->fetchObject();
}
/**
@@ -162,6 +167,7 @@ function ctools_object_cache_test($obj, $name, $sid = NULL) {
* An array of objects containing the UID and updated date for each name found.
*/
function ctools_object_cache_test_objects($obj, $names) {
array_walk($names, 'md5');
return db_query("SELECT c.name, s.uid, c.updated FROM {ctools_object_cache} c INNER JOIN {sessions} s ON c.sid = s.sid WHERE c.obj = :obj AND c.name IN (:names) ORDER BY c.updated ASC", array(':obj' => $obj, ':names' => $names))
->fetchAllAssoc('name');
}
@@ -180,7 +186,7 @@ function ctools_object_cache_test_objects($obj, $names) {
function ctools_object_cache_clear_all($obj, $name) {
db_delete('ctools_object_cache')
->condition('obj', $obj)
->condition('name', $name)
->condition('name', md5($name))
->execute();
// Ensure the static cache is emptied of this obj:name set.
$cache = &drupal_static('ctools_object_cache_get', array());
@@ -197,7 +203,8 @@ function ctools_object_cache_clear_all($obj, $name) {
*/
function ctools_object_cache_clean($age = NULL) {
if (empty($age)) {
$age = 86400 * 7; // 7 days
// 7 days.
$age = 86400 * 7;
}
db_delete('ctools_object_cache')
->condition('updated', REQUEST_TIME - $age, '<')

View File

@@ -1,5 +1,9 @@
<?php
/**
* @file
*/
/**
* Fetch metadata on a specific page_wizard plugin.
*
@@ -53,7 +57,7 @@ function page_manager_get_wizard_cache($plugin) {
}
function page_manager_make_wizard_cache($plugin) {
$cache = new stdClass;
$cache = new stdClass();
$cache->plugin = $plugin;
if ($function = ctools_plugin_get_function($plugin, 'default cache')) {
$function($cache);

View File

@@ -10,6 +10,7 @@
*
* Implementing this
*/
/**
* Get a plugin configuration form.
*
@@ -100,7 +101,7 @@ function _ctools_plugin_configure_create_form_info(&$form_info, $plugin_definiti
if (empty($plugin_definition['title'])) {
$title = t('Configure');
}
else if ($op == 'add') {
elseif ($op == 'add') {
$title = t('Configure new !plugin_title', array('!plugin_title' => $plugin_definition['title']));
}
else {
@@ -134,10 +135,10 @@ function _ctools_plugin_configure_create_form_info(&$form_info, $plugin_definiti
$form_info['forms']['form']['wrapper'] = 'ctools_plugins_default_form_wrapper';
}
}
else if (is_array($info)) {
if (empty($form_info['order'])) {
$form_info['order'] = array();
}
elseif (is_array($info)) {
if (empty($form_info['order'])) {
$form_info['order'] = array();
}
if (empty($form_info['forms'])) {
$form_info['forms'] = array();
}

View File

@@ -2,7 +2,6 @@
/**
* @file
*
* Contains routines to organize and load plugins. It allows a special
* variation of the hook system so that plugins can be kept in separate
* .inc files, and can be either loaded all at once or loaded only when
@@ -70,7 +69,7 @@ function ctools_plugin_api_info($owner, $api, $minimum_version, $current_version
if (isset($info['version'])) {
$version = $info['version'];
}
else if (isset($info['api'])) {
elseif (isset($info['api'])) {
$version = $info['api'];
}
@@ -99,7 +98,7 @@ function ctools_plugin_api_info($owner, $api, $minimum_version, $current_version
}
// Only process if version is between minimum and current, inclusive.
if (version_compare($info['version'], $minimum_version, '>=') && version_compare($info['version'], $current_version, '<=')) {
if (version_compare($info['version'], $minimum_version, '>=') && version_compare($info['version'], $current_version, '<=')) {
if (!isset($info['path'])) {
$info['path'] = '';
}
@@ -151,7 +150,7 @@ function ctools_plugin_api_include($owner, $api, $minimum_version, $current_vers
if (isset($plugin_info["$api file"])) {
$file = $plugin_info["$api file"];
}
else if (isset($plugin_info['file'])) {
elseif (isset($plugin_info['file'])) {
$file = $plugin_info['file'];
}
else {
@@ -161,7 +160,7 @@ function ctools_plugin_api_include($owner, $api, $minimum_version, $current_vers
if (file_exists(DRUPAL_ROOT . "/$plugin_info[path]/$file")) {
require_once DRUPAL_ROOT . "/$plugin_info[path]/$file";
}
else if (file_exists(DRUPAL_ROOT . "/$file")) {
elseif (file_exists(DRUPAL_ROOT . "/$file")) {
require_once DRUPAL_ROOT . "/$file";
}
$already_done[$owner][$api][$module] = TRUE;
@@ -184,7 +183,7 @@ function ctools_plugin_api_get_hook($owner, $api) {
if (function_exists($function = $owner . '_' . $api . '_hook_name')) {
$hook = $function();
}
else if (function_exists($function = $owner . '_ctools_plugin_api_hook_name')) {
elseif (function_exists($function = $owner . '_ctools_plugin_api_hook_name')) {
$hook = $function();
}
@@ -225,7 +224,7 @@ function ctools_get_plugins($module, $type, $id = NULL) {
$info = ctools_plugin_get_plugin_type_info();
if (!isset($info[$module][$type])) {
// If we don't find the plugin we attempt a cache rebuild before bailing out
// If we don't find the plugin we attempt a cache rebuild before bailing out.
$info = ctools_plugin_get_plugin_type_info(TRUE);
// Bail out noisily if an invalid module/type combination is requested.
if (!isset($info[$module][$type])) {
@@ -258,9 +257,9 @@ function ctools_get_plugins($module, $type, $id = NULL) {
if (!empty($cache->data)) {
// Cache load succeeded so use the cached plugin list.
$plugins[$module][$type] = $cache->data;
$plugins[$module][$type] = $cache->data;
// Set $setup to true so we know things where loaded.
$setup[$module][$type] = TRUE;
$setup[$module][$type] = TRUE;
}
else {
// Cache load failed so store that we need to build and write the cache.
@@ -299,7 +298,6 @@ function ctools_get_plugins($module, $type, $id = NULL) {
}
}
// If we were told earlier that this is cacheable and the cache was empty,
// give something back.
if ($build_cache) {
@@ -313,7 +311,7 @@ function ctools_get_plugins($module, $type, $id = NULL) {
return array_filter($plugins[$module][$type]);
}
// Check to see if we need to look for the file
// Check to see if we need to look for the file.
if (!array_key_exists($id, $plugins[$module][$type])) {
// If we can have child plugins, check to see if the plugin name is in the
// format of parent:child and break it up if it is.
@@ -419,19 +417,20 @@ function ctools_get_plugins_reset() {
/**
* Load plugins from a directory.
*
* @param $info
* @param array $info
* The plugin info as returned by ctools_plugin_get_info()
* @param $file
* @param string $filename
* The file to load if we're looking for just one particular plugin.
*
* @return
* An array of information created for this plugin.
* @return array
* A (possibly empty) array of information created for this plugin.
*/
function ctools_plugin_load_includes($info, $filename = NULL) {
// Keep a static array so we don't hit file_scan_directory more than necessary.
$all_files = &drupal_static(__FUNCTION__, array());
// store static of plugin arrays for reference because they can't be reincluded.
// Store static of plugin arrays for reference because they can't be
// reincluded, so there is no point in using drupal_static().
static $plugin_arrays = array();
if (!isset($all_files[$info['module']][$info['type']])) {
@@ -466,24 +465,23 @@ function ctools_plugin_load_includes($info, $filename = NULL) {
}
foreach ($files as $file) {
if (!empty($info['info file'])) {
// Parse a .info file
// Parse a .info file.
$result = ctools_plugin_process_info($info, $module, $file);
}
else {
// Parse a hook.
$plugin = NULL; // ensure that we don't have something leftover from earlier.
// Ensure that we don't have something leftover from earlier.
$plugin = NULL;
if (isset($plugin_arrays[$file->uri])) {
$identifier = $plugin_arrays[$file->uri];
}
else {
include_once DRUPAL_ROOT . '/' . $file->uri;
// .inc files have a special format for the hook identifier.
// For example, 'foo.inc' in the module 'mogul' using the plugin
// whose hook is named 'borg_type' should have a function named (deep breath)
// mogul_foo_borg_type()
// whose hook is named 'borg_type' should have a function named
// (deep breath) mogul_foo_borg_type().
// If, however, the .inc file set the quasi-global $plugin array, we
// can use that and not even call a function. Set the $identifier
// appropriately and ctools_plugin_process() will handle it.
@@ -496,7 +494,8 @@ function ctools_plugin_load_includes($info, $filename = NULL) {
}
}
$result = ctools_plugin_process($info, $module, $identifier, dirname($file->uri), basename($file->uri), $file->name);
$result = ctools_plugin_process($info, $module, $identifier,
dirname($file->uri), basename($file->uri), $file->name);
}
if (is_array($result)) {
$plugins = array_merge($plugins, $result);
@@ -516,7 +515,7 @@ function ctools_plugin_load_includes($info, $filename = NULL) {
* @param $info
* The $info array for the plugin as returned by ctools_plugin_get_info().
*
* @return array $directories
* @return array
* An array of directories to search.
*/
function ctools_plugin_get_directories($info) {
@@ -542,10 +541,9 @@ function ctools_plugin_get_directories($info) {
}
/**
* Helper function to build a ctools-friendly list of themes capable of
* providing plugins.
* Helper to build a ctools-friendly list of themes capable of providing plugins.
*
* @return array $themes
* @return array
* A list of themes that can act as plugin providers, sorted parent-first with
* the active theme placed last.
*/
@@ -556,7 +554,7 @@ function _ctools_list_themes() {
$themes = $active = array();
$all_themes = list_themes();
foreach ($all_themes as $name => $theme) {
// Only search from active themes
// Only search from active themes.
if (empty($theme->status) && $theme->name != $current) {
continue;
}
@@ -567,19 +565,19 @@ function _ctools_list_themes() {
}
}
// Construct a parent-first list of all themes
// Construct a parent-first list of all themes.
foreach ($active as $name => $theme) {
$base_themes = isset($theme->base_themes) ? $theme->base_themes : array();
$themes = array_merge($themes, $base_themes, array($name => $theme->info['name']));
}
// Put the actual theme info objects into the array
// Put the actual theme info objects into the array.
foreach (array_keys($themes) as $name) {
if (isset($all_themes[$name])) {
$themes[$name] = $all_themes[$name];
}
}
// Make sure the current default theme always gets the last word
// Make sure the current default theme always gets the last word.
if ($current_key = array_search($current, array_keys($themes))) {
$themes += array_splice($themes, $current_key, 1);
}
@@ -587,7 +585,6 @@ function _ctools_list_themes() {
return $themes;
}
/**
* Find all the base themes for the specified theme.
*
@@ -603,9 +600,10 @@ function _ctools_list_themes() {
* The name of the theme whose base we are looking for.
* @param $used_keys
* A recursion parameter preventing endless loops.
* @return
*
* @return array
* Returns an array of all of the theme's ancestors; the first element's value
* will be NULL if an error occurred.
* will be NULL if an error occurred. (Note: this is NOT $arr[0]).
*/
function ctools_find_base_themes($themes, $key, $used_keys = array()) {
$base_key = $themes[$key]->info['base theme'];
@@ -633,7 +631,6 @@ function ctools_find_base_themes($themes, $key, $used_keys = array()) {
return $current_base_theme;
}
/**
* Load plugin info for the provided hook; this is handled separately from
* plugins from files.
@@ -658,22 +655,28 @@ function ctools_plugin_load_hooks($info) {
/**
* Process a single hook implementation of a ctools plugin.
*
* @param $info
* @param array $info
* The $info array about the plugin as returned by ctools_plugin_get_info()
* @param $module
* @param string $module
* The module that implements the plugin being processed.
* @param $identifier
* The plugin identifier, which is used to create the name of the hook
* function being called.
* @param $path
* @param string|array $identifier
* Used to create the base setting of return value. If:
* - $identifier is a string, a hook name is created from this and the 'hook'
* key of the $info array, and the return value of that hook function is
* used. The hook is called like this: $identifier_$hook($info);
* - $identifier is an array, this array is used directly.
* @param string $path
* The path where files utilized by this plugin will be found.
* @param $file
* @param string $file
* The file that was loaded for this plugin, if it exists.
* @param $base
* @param string $base
* The base plugin name to use. If a file was loaded for the plugin, this
* is the plugin to assume must be present. This is used to automatically
* translate the array to make the syntax more friendly to plugin
* implementors.
*
* @return null|array
* NULL on failure, otherwise an array containing the results keyed by name.
*/
function ctools_plugin_process($info, $module, $identifier, $path, $file = NULL, $base = NULL) {
if (is_array($identifier)) {
@@ -741,9 +744,19 @@ function _ctools_process_data($result, $plugin_type_info, $module, $path, $file)
return $result;
}
/**
* Process an info file for plugin information, rather than a hook.
*
* @param array $info
* The $info array about the plugin as returned by ctools_plugin_get_info()
* @param string $module
* The module that implements the plugin being processed.
* @param object $file
* An object containing 'uri' and 'name' properties. 'uri' is the name of the
* 'info' file to process. 'name' is the plugin key-name.
*
* @return null|array
* NULL on failure, otherwise an array containing the results keyed by name.
*/
function ctools_plugin_process_info($info, $module, $file) {
$result = drupal_parse_info_file($file->uri);
@@ -770,7 +783,7 @@ function ctools_plugin_get_info($module, $type) {
* @param $function_name
* The identifier of the function. For example, 'settings form'.
*
* @return
* @return string
* The actual name of the function to call, or NULL if the function
* does not exist.
*/
@@ -787,7 +800,7 @@ function ctools_plugin_get_function($plugin_definition, $function_name) {
}
if (!isset($plugin_definition[$function_name])) {
return;
return NULL;
}
if (is_array($plugin_definition[$function_name]) && isset($plugin_definition[$function_name]['function'])) {
@@ -822,7 +835,7 @@ function ctools_plugin_get_function($plugin_definition, $function_name) {
* @param $function_name
* The identifier of the function. For example, 'settings form'.
*
* @return
* @return string
* The actual name of the function to call, or NULL if the function
* does not exist.
*/
@@ -840,7 +853,7 @@ function ctools_plugin_load_function($module, $type, $id, $function_name) {
* @param $class_name
* The identifier of the class. For example, 'handler'.
*
* @return
* @return string
* The actual name of the class to call, or NULL if the class does not exist.
*/
function ctools_plugin_get_class($plugin_definition, $class_name) {
@@ -859,11 +872,11 @@ function ctools_plugin_get_class($plugin_definition, $class_name) {
if (!isset($plugin_definition[$class_name])) {
return;
}
else if (is_string($plugin_definition[$class_name])) {
elseif (is_string($plugin_definition[$class_name])) {
// Plugin uses the string form shorthand.
$return = $plugin_definition[$class_name];
}
else if (isset($plugin_definition[$class_name]['class'])) {
elseif (isset($plugin_definition[$class_name]['class'])) {
// Plugin uses the verbose array form.
$return = $plugin_definition[$class_name]['class'];
}
@@ -885,7 +898,7 @@ function ctools_plugin_get_class($plugin_definition, $class_name) {
* @param $class_name
* The identifier of the class. For example, 'handler'.
*
* @return
* @return string
* The actual name of the class to call, or NULL if the class does not exist.
*/
function ctools_plugin_load_class($module, $type, $id, $class_name) {

View File

@@ -2,7 +2,6 @@
/**
* @file
*
* Registry magic. In a separate file to minimize unnecessary code loading.
*/

View File

@@ -202,7 +202,7 @@ function ctools_stylizer_get_settings_name($settings) {
}
/**
* Get the path where images will be stored for a given style plugin and settings.
* Get the path where images will be stored for a style plugin and settings.
*
* This function will make sure the path exists.
*/
@@ -249,7 +249,7 @@ class ctools_stylizer_image_processor {
if (is_string($plugin['actions']) && function_exists($plugin['actions'])) {
$actions = $plugin['actions']($plugin, $settings);
}
else if (is_array($plugin['actions'])) {
elseif (is_array($plugin['actions'])) {
$actions = $plugin['actions'];
}
@@ -318,7 +318,7 @@ class ctools_stylizer_image_processor {
function command_load($name, $file) {
$this->log("New workspace: $name (from $file)");
if (!file_exists($file)) {
// Try it relative to the plugin
// Try it relative to the plugin.
$file = $this->plugin['path'] . '/' . $file;
if (!file_exists($file)) {
$this->log("Unable to open $file");
@@ -336,7 +336,7 @@ class ctools_stylizer_image_processor {
}
/**
* Create a new workspace using the properties of an existing workspace
* Create a new workspace using the properties of an existing workspace.
*/
function command_new_from($name, $workspace) {
$this->log("New workspace: $name from existing $workspace");
@@ -372,7 +372,7 @@ class ctools_stylizer_image_processor {
function command_merge_from($workspace, $x = 0, $y = 0) {
$this->log("Merge from: $workspace ($x, $y)");
if (empty($this->workspaces[$workspace])) {
$this->log("Workspace $name does not exist.", 'error');
$this->log("Workspace $workspace does not exist.", 'error');
return;
}
@@ -382,7 +382,7 @@ class ctools_stylizer_image_processor {
function command_merge_to($workspace, $x = 0, $y = 0) {
$this->log("Merge to: $workspace ($x, $y)");
if (empty($this->workspaces[$workspace])) {
$this->log("Workspace $name does not exist.", 'error');
$this->log("Workspace $workspace does not exist.", 'error');
return;
}
@@ -822,7 +822,7 @@ function ctools_stylizer_add_plugin_forms(&$form_info, $plugin, $op) {
if ($op == 'add' && isset($plugin['add form'])) {
$id = $plugin['add form'];
}
else if (isset($plugin['edit form'])) {
elseif (isset($plugin['edit form'])) {
$id = $plugin['edit form'];
}
else {

View File

@@ -25,4 +25,3 @@ function ctools_stylizer_theme(&$theme) {
'file' => 'includes/stylizer.inc',
);
}

View File

@@ -23,7 +23,7 @@ function ctools_passthrough($module, $type, &$items) {
require_once DRUPAL_ROOT . '/' . $file->uri;
list($tool) = explode('.', $file->name, 2);
$function = $module . '_' . str_replace ('-', '_', $tool) . '_' . str_replace('-', '_', $type);
$function = $module . '_' . str_replace('-', '_', $tool) . '_' . str_replace('-', '_', $type);
if (function_exists($function)) {
$function($items);
}

View File

@@ -67,4 +67,5 @@ if (!function_exists('uuid_is_valid')) {
function uuid_is_valid($uuid) {
return preg_match('/^' . UUID_PATTERN . '$/', $uuid);
}
}

View File

@@ -1,5 +1,9 @@
<?php
/**
* @file
*/
/**
* Generate new context classes by argument settings on the view.
*/

View File

@@ -47,7 +47,7 @@ function ctools_wizard_multistep_form($form_info, $step, &$form_state) {
// with form caching.
ctools_form_include($form_state, 'wizard');
// allow order array to be optional
// Allow order array to be optional.
if (empty($form_info['order'])) {
foreach ($form_info['forms'] as $step_id => $params) {
$form_info['order'][$step_id] = $params['title'];
@@ -83,7 +83,7 @@ function ctools_wizard_multistep_form($form_info, $step, &$form_state) {
$form_info['cache location'] = 'storage';
}
// If absolutely nothing was set for the cache area to work on
// If absolutely nothing was set for the cache area to work on.
if (!isset($form_state[$form_info['cache location']])) {
ctools_include('cache');
$form_state[$form_info['cache location']] = ctools_cache_get($form_info['cache mechanism'], $form_info['cache key']);
@@ -199,7 +199,7 @@ function ctools_wizard_multistep_form($form_info, $step, &$form_state) {
}
}
}
else if (isset($form_state['ajax next'])) {
elseif (isset($form_state['ajax next'])) {
// Clear a few items off the form state so we don't double post:
$next = $form_state['ajax next'];
unset($form_state['ajax next']);
@@ -299,7 +299,7 @@ function ctools_wizard_wrapper($form, &$form_state) {
'#wizard type' => 'next',
'#weight' => -2000,
'#limit_validation_errors' => array(),
// hardcode the submit so that it doesn't try to save data.
// Hardcode the submit so that it doesn't try to save data.
'#submit' => array('ctools_wizard_submit'),
'#attributes' => $button_attributes,
);
@@ -325,19 +325,18 @@ function ctools_wizard_wrapper($form, &$form_state) {
// end of the form list (i.e, there is a next) then it's "update and return"
// to be clear. If this is the end of the path and there is no next, we
// call it 'Finish'.
// Even if there is no direct return path (some forms may not want you
// leaving in the middle) the final button is always a Finish and it does
// whatever the return action is.
if (!empty($form_info['show return']) && !empty($form_state['next'])) {
$form['buttons']['return'] = array(
'#type' => 'submit',
'#value' => $form_info['return text'],
'#value' => $form_info['return text'],
'#wizard type' => 'return',
'#attributes' => $button_attributes,
);
}
else if (empty($form_state['next']) || !empty($form_info['free trail'])) {
elseif (empty($form_state['next']) || !empty($form_info['free trail'])) {
$form['buttons']['return'] = array(
'#type' => 'submit',
'#value' => $form_info['finish text'],
@@ -352,7 +351,7 @@ function ctools_wizard_wrapper($form, &$form_state) {
'#type' => 'submit',
'#value' => $form_info['cancel text'],
'#wizard type' => 'cancel',
// hardcode the submit so that it doesn't try to save data.
// Hardcode the submit so that it doesn't try to save data.
'#limit_validation_errors' => array(),
'#submit' => array('ctools_wizard_submit'),
'#attributes' => $button_attributes,
@@ -370,7 +369,6 @@ function ctools_wizard_wrapper($form, &$form_state) {
// Set up our submit handler after theirs. Since putting something here will
// skip Drupal's autodetect, we autodetect for it.
// We make sure ours is after theirs so that they get to change #next if
// the want to.
$form['#submit'] = array();
@@ -398,7 +396,7 @@ function ctools_wizard_wrapper($form, &$form_state) {
$params = array($url, $options);
}
$form['#action'] = call_user_func_array('url', $params);
$form['#action'] = call_user_func_array('url', $params);
}
if (isset($info['wrapper']) && function_exists($info['wrapper'])) {
@@ -418,7 +416,7 @@ function ctools_wizard_submit(&$form, &$form_state) {
if (isset($form_state['clicked_button']['#wizard type'])) {
$type = $form_state['clicked_button']['#wizard type'];
// if AJAX enabled, we proceed slightly differently here.
// If AJAX enabled, we proceed slightly differently here.
if (!empty($form_state['ajax'])) {
if ($type == 'next') {
$form_state['ajax next'] = $form_state['clicked_button']['#next'];
@@ -428,7 +426,7 @@ function ctools_wizard_submit(&$form, &$form_state) {
if ($type == 'cancel' && isset($form_state['form_info']['cancel path'])) {
$form_state['redirect'] = $form_state['form_info']['cancel path'];
}
else if ($type == 'next') {
elseif ($type == 'next') {
$form_state['redirect'] = ctools_wizard_get_path($form_state['form_info'], $form_state['clicked_button']['#next']);
if (!empty($_GET['destination'])) {
// We don't want drupal_goto redirect this request
@@ -437,10 +435,10 @@ function ctools_wizard_submit(&$form, &$form_state) {
unset($_GET['destination']);
}
}
else if (isset($form_state['form_info']['return path'])) {
elseif (isset($form_state['form_info']['return path'])) {
$form_state['redirect'] = $form_state['form_info']['return path'];
}
else if ($type == 'finish' && isset($form_state['form_info']['cancel path'])) {
elseif ($type == 'finish' && isset($form_state['form_info']['cancel path'])) {
$form_state['redirect'] = $form_state['form_info']['cancel path'];
}
}
@@ -469,10 +467,8 @@ function ctools_wizard_get_path($form_info, $step) {
if (!isset($path[1]) || !is_array($path[1])) {
$path[1] = array();
}
// Ensure that the query part of options is an array.
$path[1] += array('query' => array());
// Add the destination parameter, if not set already.
$path[1]['query'] += drupal_get_destination();
$path[1] += drupal_get_destination();
}
return $path;
@@ -505,15 +501,15 @@ function ctools_wizard_defaults(&$form_info) {
}
$form_info = $form_info + $defaults;
// set form callbacks if they aren't defined
// Set form callbacks if they aren't defined.
foreach ($form_info['forms'] as $step => $params) {
if (!$params['form id']) {
$form_callback = $hook . '_' . $step . '_form';
$form_info['forms'][$step]['form id'] = $form_callback;
if (empty($params['form id'])) {
$form_callback = $hook . '_' . $step . '_form';
$form_info['forms'][$step]['form id'] = $form_callback;
}
}
// set button callbacks
// Set button callbacks.
$callbacks = array(
'back callback' => '_back',
'next callback' => '_next',
@@ -523,10 +519,10 @@ function ctools_wizard_defaults(&$form_info) {
);
foreach ($callbacks as $key => $callback) {
// never overwrite if explicity defined
// Never overwrite if explicity defined.
if (empty($form_info[$key])) {
$wizard_callback = $hook . $callback;
if (function_exists($wizard_callback)) {
if (function_exists($wizard_callback)) {
$form_info[$key] = $wizard_callback;
}
}