';
- // This is not good translation practice as it relies on the structure of english
- // If I add the pulldown to the label, howerver, the box toggles when the pulldown is clicked.
- //$form['quickbackup']['destination']['copy']['#title'] = t('Save a copy to');
-
+ // This is not good translation practice as it relies on the structure of
+ // English. If I add the pulldown to the label, howerver, the box toggles
+ // when the pulldown is clicked.
+ // $form['quickbackup']['destination']['copy']['#title'] = t('Save a copy to');
unset($form['quickbackup']['source_id']);
unset($form['quickbackup']['destination']['destination_id']);
unset($form['quickbackup']['destination']['copy_destination']);
unset($form['quickbackup']['profile_id']);
- //unset($form['quickbackup']['submit']);
+ // unset($form['quickbackup']['submit']);
return drupal_render_children($form);
}
@@ -874,8 +935,8 @@ function theme_backup_migrate_ui_manual_quick_backup_form_inline($form) {
* Theme the quick schedule form.
*/
function theme_backup_migrate_ui_quick_schedule_form_inline($form) {
- drupal_add_js(drupal_get_path('module', 'backup_migrate') .'/backup_migrate.js');
- drupal_add_css(drupal_get_path('module', 'backup_migrate') .'/backup_migrate.css');
+ drupal_add_js(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.js');
+ drupal_add_css(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.css');
$form = $form['form'];
@@ -898,12 +959,14 @@ function theme_backup_migrate_ui_quick_schedule_form_inline($form) {
'!profile' => drupal_render($form['settings']['profile_id']),
'!keep' => drupal_render($form['settings']['keep']),
);
- $form['settings'] = array('inline' => array(
- '#type' => 'markup',
- "#prefix" => '
';
}
-
/**
* Theme file list form widget.
*/
@@ -951,7 +1011,7 @@ function theme_backup_migrate_file_list($vars) {
// Render the radios so they can be placed in the file list rendering.
$vars['element']['#display_options']['form_elements'] = array();
- if ($vars['element']['files']) {
+ if (isset($vars['element']['files']) && count($vars['element']['files'])) {
foreach (element_children($vars['element']['files']) as $id) {
$vars['element']['files'][$id]['#title'] = '';
$vars['element']['#display_options']['form_elements'][$id] = render($vars['element']['files'][$id]);
@@ -978,12 +1038,11 @@ function theme_backup_migrate_group($vars) {
return $output;
}
-
/**
* The backup/export form.
*/
function backup_migrate_ui_manual_backup_form($form, &$form_state, $profile) {
- drupal_add_js(drupal_get_path('module', 'backup_migrate') .'/backup_migrate.js', array('type' => 'module', 'scope' => 'footer'));
+ drupal_add_js(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.js', array('type' => 'module', 'scope' => 'footer'));
$form = array();
@@ -1013,8 +1072,9 @@ function backup_migrate_ui_manual_backup_form($form, &$form_state, $profile) {
$form += _backup_migrate_ui_backup_settings_form($profile);
- // Make the source settings dependent on the source selected.
- // Except don't because it looks super weird.
+ // Make the source settings dependent on the source selected. Except don't
+ // because it looks super weird.
+ // @code
// foreach (element_children($form['sources']) as $source) {
// $form['sources'][$source] = array(
// '#type' => 'backup_migrate_dependent',
@@ -1024,7 +1084,7 @@ function backup_migrate_ui_manual_backup_form($form, &$form_state, $profile) {
// 'settings' => $form['sources'][$source]
// );
// }
-
+ // @endcode
if (user_access('administer backup and migrate')) {
$form['save_settings'] = array(
"#type" => "checkbox",
@@ -1081,9 +1141,10 @@ function backup_migrate_ui_manual_backup_form($form, &$form_state, $profile) {
return _backup_migrate_ui_action_form($form, $form_state, 'backup');
}
-
/**
- * Submit the form. Save the values as defaults if desired and output the backup file.
+ * Submits the form.
+ *
+ * Save the values as defaults if desired and output the backup file.
*/
function backup_migrate_ui_manual_backup_form_submit($form, &$form_state) {
// Create a profile with the given settings.
@@ -1110,12 +1171,13 @@ function backup_migrate_ui_manual_backup_form_submit($form, &$form_state) {
}
/**
- * Alter a B&M action (backup/restore) form to allow for filters to add additional form steps.
- **/
+ * Alters a B&M action (backup/restore) form to allow for filters to add steps.
+ */
function _backup_migrate_ui_action_form($form, &$form_state, $op = 'backup') {
$form['operation'] = array('#type' => 'value', '#value' => $op);
- // If the form has been submitted at least once then see if there are additional form elements to add.
+ // If the form has been submitted at least once then see if there are
+ // additional form elements to add.
if (!empty($form_state['storage']['values']) && !empty($form_state['values']['settings'])) {
$page = _backup_migrate_filter_before_action_form($form_state['values']['settings'], $op);
if (!empty($page)) {
@@ -1140,9 +1202,11 @@ function _backup_migrate_ui_action_form($form, &$form_state, $op = 'backup') {
}
/**
- * Allow filters, sources and destinations to present additional form elements
- * to the end user before an action is submitted.
- **/
+ * Allows filters, sources and destinations to present additional form elements.
+ *
+ * The additional form elements will be shown to the user before an action is
+ * submitted.
+ */
function backup_migrate_ui_action_form_pre_validate($form, &$form_state) {
if (!empty($form_state['storage']['values'])) {
$form_state['values'] += $form_state['storage']['values'];
@@ -1150,9 +1214,11 @@ function backup_migrate_ui_action_form_pre_validate($form, &$form_state) {
}
/**
- * Allow filters, sources and destinations to present additional form elements
- * to the end user before an action is submitted.
- **/
+ * Allows filters, sources and destinations to present additional form elements.
+ *
+ * The additional form elements will be shown to the user before an action is
+ * submitted.
+ */
function backup_migrate_ui_action_form_post_validate($form, &$form_state) {
backup_migrate_include('filters');
@@ -1160,33 +1226,39 @@ function backup_migrate_ui_action_form_post_validate($form, &$form_state) {
// See if there are extra form items to be processed.
$form = _backup_migrate_filter_before_action_form($form_state['values']['settings'], $form_state['values']['operation']);
if ($form) {
- // First time through the form simply rebuild the form to show the additional fields.
+ // First time through the form simply rebuild the form to show the
+ // additional fields.
if (empty($form_state['storage']['values'])) {
$form_state['storage']['values'] = $form_state['values'];
$form_state['rebuild'] = TRUE;
}
else {
- backup_migrate_filters_before_action_form_validate($form_state['values']['settings'], $form_state['values']['operation'], $form, $form_state);
+ backup_migrate_filters_before_action_form_validate($form_state['values']['settings'], $form_state['values']['operation'], $form, $form_state);
}
}
}
}
/**
- * Allow filters, sources and destinations to present additional form elements
- * to the end user before an action is submitted.
- **/
+ * Allows filters, sources and destinations to present additional form elements.
+ *
+ * The additional form elements will be shown to the user before an action is
+ * submitted.
+ */
function backup_migrate_ui_action_form_pre_submit($form, &$form_state) {
if (!empty($form_state['storage']['values']) && !empty($form_state['values']['settings'])) {
// Check if there are any form elements to submit.
backup_migrate_filters_before_action_form_submit($form_state['values']['settings'], $form_state['values']['operation'], $form, $form_state);
- // Clear the storage so the form can continue as normal
+ // Clear the storage so the form can continue as normal.
unset($form_state['storage']);
}
}
/**
- * Retrieve an array of form items to be filled out before an action can continue.
+ * Retrieves form items to be filled out before an action can continue.
+ *
+ * @return array
+ * An array of form items.
*/
function _backup_migrate_filter_before_action_form($settings, $op) {
$form = array();
@@ -1262,9 +1334,9 @@ function backup_migrate_ui_manual_restore_form() {
$form['backup_migrate_restore_saved']['file'] = array(
'#type' => 'backup_migrate_file_list',
'#display_options' => array(
- 'limit' => 5,
- 'pager' => FALSE,
- 'more' => BACKUP_MIGRATE_MENU_PATH . '/backups',
+ 'limit' => 5,
+ 'pager' => FALSE,
+ 'more' => BACKUP_MIGRATE_MENU_PATH . '/backups',
'operations' => FALSE,
),
'#default_value' => $default,
@@ -1290,7 +1362,7 @@ function backup_migrate_ui_manual_restore_form() {
$form = array_merge_recursive($form, backup_migrate_filters_settings_form(backup_migrate_filters_settings_default('restore'), 'restore'));
// Add the advanced fieldset if there are any fields in it.
- if (@$form['advanced']) {
+ if (isset($form['advanced'])) {
$form['advanced']['#type'] = 'fieldset';
$form['advanced']['#title'] = t('Advanced Options');
$form['advanced']['#collapsed'] = TRUE;
@@ -1322,9 +1394,9 @@ function backup_migrate_ui_manual_restore_form_submit($form, &$form_state) {
if ($values['from'] == 'upload' && $file = file_save_upload('backup_migrate_restore_upload', $validators)) {
backup_migrate_perform_restore('upload', $file->uri, $values);
}
- else if ($values['from'] == 'saved' && $file = $values['file']) {
+ elseif ($values['from'] == 'saved' && $file = $values['file']) {
list($destination, $file_id) = explode('/', $file, 2);
- $file =
+ $file =
backup_migrate_perform_restore($destination, $file_id, $form_state['values']);
}
@@ -1344,11 +1416,11 @@ function backup_migrate_ui_export_form($form, &$form_state, $item) {
}
/**
- * List the previously created backups from accross multiple destinations.
+ * List the previously created backups from across multiple destinations.
*/
function backup_migrate_ui_saved_backups() {
backup_migrate_include('profiles', 'destinations', 'sources');
- drupal_add_css(drupal_get_path('module', 'backup_migrate') .'/backup_migrate.css');
+ drupal_add_css(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.css');
$remote = FALSE;
$now = $fetch_time = time();
@@ -1365,7 +1437,12 @@ function backup_migrate_ui_saved_backups() {
// Get the fetch link.
if ($fetch_time < $now) {
- $fetch = '
';
}
// Render the list.
@@ -1375,10 +1452,11 @@ function backup_migrate_ui_saved_backups() {
// Add a remote backups warning if there are no remote backups.
if (!$remote && user_access('administer backup and migrate')) {
- drupal_set_message(
- t('You do not have any offsite backups. For the highest level of protection, create an offsite destination or set up NodeSquirrel to save your backups to.',
- array('!addurl' => url(BACKUP_MIGRATE_MENU_PATH . '/settings/destination/add'),
- '!nsurl' => url(BACKUP_MIGRATE_MENU_PATH . '/nodesquirrel')
+ drupal_set_message(
+ t('You do not have any offsite backups. For the highest level of protection, create an offsite destination or set up NodeSquirrel to save your backups to.',
+ array(
+ '!addurl' => url(BACKUP_MIGRATE_MENU_PATH . '/settings/destination/add'),
+ '!nsurl' => url(BACKUP_MIGRATE_MENU_PATH . '/nodesquirrel'),
)), 'warning', FALSE);
}
@@ -1386,11 +1464,11 @@ function backup_migrate_ui_saved_backups() {
}
/**
- * List the previously created backups from accross multiple destinations.
+ * List the previously created backups from across multiple destinations.
*/
function backup_migrate_get_saved_backups($refresh = FALSE) {
backup_migrate_include('profiles', 'destinations', 'sources');
- drupal_add_css(drupal_get_path('module', 'backup_migrate') .'/backup_migrate.css');
+ drupal_add_css(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.css');
$remote = FALSE;
$now = $fetch_time = time();
@@ -1406,7 +1484,7 @@ function backup_migrate_get_saved_backups($refresh = FALSE) {
$remote = TRUE;
}
- // Refresh the destination
+ // Refresh the destination.
if ($refresh) {
$destination->file_cache_clear();
}
@@ -1429,6 +1507,27 @@ function backup_migrate_get_saved_backups($refresh = FALSE) {
return array($files, $fetch_time, $remote);
}
+/**
+ * Helper function for byte conversion.
+ */
+function backup_migrate_to_bytes($from) {
+ $number = substr($from, 0, -1);
+ switch (strtoupper(substr($from, -1))) {
+ case "M":
+ return $number * pow(1024, 2);
+
+ break;
+
+ case "G":
+ return $number * pow(1024, 3);
+
+ break;
+
+ default:
+ return $number * pow(1024, 2);
+ }
+}
+
/**
* Perform a backup with the given settings.
*/
@@ -1436,12 +1535,41 @@ function backup_migrate_perform_backup(&$settings) {
backup_migrate_include('destinations', 'files', 'filters');
timer_start('backup_migrate_backup');
- // If not in 'safe mode', increase the maximum execution time:
- if (!ini_get('safe_mode') && strpos(ini_get('disable_functions'), 'set_time_limit') === FALSE && ini_get('max_execution_time') < 1200) {
- set_time_limit(variable_get('backup_migrate_backup_max_time', 1200));
+ _backup_migrate_set_timeout();
+
+ // Conditionally increase the memory limit
+ // Get the current php memory limit.
+ $php_memory_limit = ini_get('memory_limit');
+
+ // Convert the php memory limit to bytes.
+ $php_memory_limit_bytes = backup_migrate_to_bytes($php_memory_limit);
+
+ // Get the current Backup Migrate memory limit.
+ // Hint: To further increase the memory limit used by Backup Migrate add one
+ // of the following line to the settings.php file:
+ // * $conf['backup_migrate_memory_limit'] = '512M';
+ // * $conf['backup_migrate_memory_limit'] = '1G';
+ $backup_migrate_memory_limit = variable_get('backup_migrate_memory_limit', '256M');
+
+ // Convert the Backup Migrate memory limit to bytes.
+ $backup_migrate_memory_limit_bytes = backup_migrate_to_bytes($backup_migrate_memory_limit);
+
+ // If not in 'safe mode', increase the memory limit.
+ if (!ini_get('safe_mode') && $php_memory_limit_bytes < $backup_migrate_memory_limit_bytes) {
+ // Ensure ini_set() is not disabled.
+ if (!strpos(ini_get('disable_functions'), 'ini_set')) {
+ // Convert bytes to megabytes, add the 'M' unit.
+ $backup_migrate_memory_limit = round($backup_migrate_memory_limit_bytes / 1024 / 1024) . 'M';
+
+ // Update the php memory limit.
+ ini_set('memory_limit', $backup_migrate_memory_limit);
+ }
+ }
+ if (variable_get('backup_migrate_verbose')) {
+ _backup_migrate_message("Memory limit: %limit", array('%limit' => ini_get('memory_limit')), 'success');
}
- // Confirm the destinations are valid
+ // Confirm the destinations are valid.
$valid = backup_migrate_destination_confirm_destination($settings);
if (!$valid) {
backup_migrate_backup_fail("Could not run backup because a there was no valid destination to save to.", array(), $settings);
@@ -1459,6 +1587,9 @@ function backup_migrate_perform_backup(&$settings) {
// Register shutdown callback to deal with timeouts.
register_shutdown_function('backup_migrate_shutdown', $settings);
+ if (variable_get('backup_migrate_verbose')) {
+ watchdog('backup_migrate', "Starting backup: %file", array('%file' => $file->filename()));
+ }
$file = backup_migrate_filters_backup($file, $settings);
if (!$file) {
if (_backup_migrate_check_timeout()) {
@@ -1470,13 +1601,19 @@ function backup_migrate_perform_backup(&$settings) {
return FALSE;
}
+ if (variable_get('backup_migrate_verbose')) {
+ watchdog('backup_migrate', "Preparing to save backup: %file", array('%file' => $file->filename()));
+ }
$file = backup_migrate_destination_save_file($file, $settings);
if (!$file) {
backup_migrate_backup_fail("Could not run backup because the file could not be saved to the destination.", array(), $settings);
return FALSE;
}
+ if (variable_get('backup_migrate_verbose')) {
+ watchdog('backup_migrate', "Backup succeeded: %file", array('%file' => $file->filename()));
+ }
- // Backup succeeded,
+ // Backup succeeded.
$time = timer_stop('backup_migrate_backup');
$message = '%source backed up successfully to %file (%size) in destination %dest in !time. !action';
$params = array(
@@ -1496,9 +1633,8 @@ function backup_migrate_perform_backup(&$settings) {
}
/**
- * Format an elapsed time given in milleseconds.
+ * Formats an elapsed time given in milleseconds.
*/
-
function backup_migrate_format_elapsed_time($time) {
$ms = t('!time ms', array('!time' => $time));
if ($time < 1000) {
@@ -1514,10 +1650,7 @@ function backup_migrate_perform_restore($destination_id, $file, $settings = arra
backup_migrate_include('files', 'filters');
timer_start('backup_migrate_restore');
- // If not in 'safe mode', increase the maximum execution time:
- if (!ini_get('safe_mode') && ini_get('max_execution_time') < variable_get('backup_migrate_backup_max_time', 1200)) {
- set_time_limit(variable_get('backup_migrate_restore_max_time', 1200));
- }
+ _backup_migrate_set_timeout();
// Make the settings into a default profile.
if (!is_object($settings)) {
@@ -1564,7 +1697,7 @@ function backup_migrate_perform_restore($destination_id, $file, $settings = arra
);
if ($destination && $destination->op('list files')) {
$path = $destination->get_settings_path();
- $params['!links'] = t('Restore again', array('!restoreurl' => url($path . '/list/restorefile/' . $destination->get_id() .'/'. $file->file_id())));
+ $params['!links'] = t('Restore again', array('!restoreurl' => url($path . '/list/restorefile/' . $destination->get_id() . '/' . $file->file_id())));
}
backup_migrate_restore_succeed($message, $params, $settings);
}
@@ -1588,7 +1721,7 @@ function backup_migrate_backup_fail($message, $params, $settings) {
}
/**
- * Clean up when a backup operation suceeds.
+ * Clean up when a backup operation succeeds.
*/
function backup_migrate_backup_succeed($message, $params, $settings) {
backup_migrate_include('filters', 'files');
@@ -1610,7 +1743,7 @@ function backup_migrate_restore_fail($message, $params, $settings) {
}
/**
- * Clean up when a restore operation suceeds.
+ * Clean up when a restore operation succeeds.
*/
function backup_migrate_restore_succeed($message, $params, $settings) {
backup_migrate_include('filters', 'files');
@@ -1620,93 +1753,84 @@ function backup_migrate_restore_succeed($message, $params, $settings) {
return FALSE;
}
-
/**
- * Cleanup after a success or failure.
+ * Cleans up after a success or failure.
*/
function backup_migrate_cleanup() {
- // Check that the cleanup function exists. If it doesn't then we probably didn't create any files to be cleaned up.
+ // Check that the cleanup function exists. If it doesn't then we probably
+ // didn't create any files to be cleaned up.
if (function_exists('_backup_migrate_temp_files_delete')) {
_backup_migrate_temp_files_delete();
}
}
-
/**
- * Shutdown callback. Called when the script terminates even if the script timed out.
+ * Shutdown callback.
+ *
+ * Called when the script terminates even if the script timed out.
*/
function backup_migrate_shutdown($settings) {
- // If we ran out of time, set an error so the user knows what happened
+ // If we ran out of time, set an error so the user knows what happened.
if (_backup_migrate_check_timeout()) {
backup_migrate_cleanup();
backup_migrate_backup_fail('The operation timed out. Try increasing your PHP max_execution_time setting.', array('!url' => 'http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time'), $settings);
- // The session will have already been written and closed, so we need to write any changes directly.
+ // The session will have already been written and closed, so we need to
+ // write any changes directly.
_drupal_session_write(session_id(), session_encode());
// Add a redirect or we'll just get whitescreened.
drupal_goto(BACKUP_MIGRATE_MENU_PATH);
}
}
-
-
-/* Actions/Workflow integration */
+/**
+ * Action to backup the drupal site.
+ *
+ * Requires actions.module.
+ *
+ * function action_backup_migrate_backup($op, $edit = array()) {
+ * switch ($op) {
+ * case 'do':
+ * _backup_migrate_backup_with_defaults();
+ * watchdog('action', 'Backed up database');
+ * break;.
+ * * Case 'metadata':
+ * return array(
+ * 'description' => t('Backup the database with the default settings'),
+ * 'type' => t('Backup and Migrate'),
+ * 'batchable' => TRUE,
+ * 'configurable' => FALSE,
+ * );
+ * * // Return an HTML config form for the action.
+ * * case 'form':
+ * return '';
+ * * // Validate the HTML form.
+ * * case 'validate':
+ * return TRUE;
+ * * // Process the HTML form to store configuration.
+ * * case 'submit':
+ * return '';
+ * }
+ * }.
+ */
/**
- * Action to backup the drupal site. Requires actions.module.
-function action_backup_migrate_backup($op, $edit = array()) {
- switch ($op) {
- case 'do':
- _backup_migrate_backup_with_defaults();
- watchdog('action', 'Backed up database');
- break;
-
- case 'metadata':
- return array(
- 'description' => t('Backup the database with the default settings'),
- 'type' => t('Backup and Migrate'),
- 'batchable' => TRUE,
- 'configurable' => FALSE,
- );
-
- // Return an HTML config form for the action.
-
- case 'form':
- return '';
-
- // Validate the HTML form.
-
- case 'validate':
- return TRUE;
-
- // Process the HTML form to store configuration.
-
- case 'submit':
- return '';
- }
-}
- */
-
-/*
* Implements hook_action_info().
-function backup_migrate_action_info() {
- return array(
- 'backup_migrate_action_backup' => array(
- 'label' => t('Backup the database'),
- 'description' => t('Backup the database with the default settings.'),
- ),
- );
-}
*/
-
-/*
+// function backup_migrate_action_info() {
+// return array(
+// 'backup_migrate_action_backup' => array(
+// 'label' => t('Backup the database'),
+// 'description' => t('Backup the database with the default settings.'),
+// ),
+// );
+// }
+/**
* Action callback.
*/
function backup_migrate_action_backup() {
_backup_migrate_backup_with_defaults();
}
-/* Utilities */
-
/**
* Backup the database with the default settings.
*/
@@ -1720,7 +1844,9 @@ function _backup_migrate_backup_with_defaults($destination_id = "manual") {
}
/**
- * Helper function to set a drupal message and watchdog message depending on whether the module is being run interactively.
+ * Helper function to set a Drupal message and watchdog message.
+ *
+ * Depends on whether the module is being run interactively.
*/
function _backup_migrate_message($message, $replace = array(), $type = 'status') {
// Only set a message if there is a callback handler to handle the message.
@@ -1728,23 +1854,32 @@ function _backup_migrate_message($message, $replace = array(), $type = 'status')
$callback($message, $replace, $type);
}
- // Store the message in case it's needed (for the status notification filter for example).
+ // Store the message in case it's needed (for the status notification filter
+ // for example).
_backup_migrate_messages($message, $replace, $type);
}
/**
- * Helper function to set a drupal message and watchdog message depending on whether the module is being run interactively.
+ * Helper function to set a Drupal message and watchdog message.
+ *
+ * Depends on whether the module is being run interactively.
*/
function _backup_migrate_messages($message = NULL, $replace = array(), $type = 'status') {
static $messages = array();
if ($message) {
- $messages[] = array('message' => $message, 'replace' => $replace, 'type' => $type);
+ $messages[] = array(
+ 'message' => $message,
+ 'replace' => $replace,
+ 'type' => $type,
+ );
}
return $messages;
}
/**
- * Send a message to the browser. The normal type of message handling for interactive use.
+ * Sends a message to the browser.
+ *
+ * The normal type of message handling for interactive use.
*/
function _backup_migrate_message_browser($message, $replace, $type) {
// Log the message as well for admins.
@@ -1759,7 +1894,7 @@ function _backup_migrate_message_browser($message, $replace, $type) {
}
/**
- * Log message if we are in a non-interactive mode such as a cron run.
+ * Logs a message if we are in a non-interactive mode such as a cron run.
*/
function _backup_migrate_message_log($message, $replace, $type) {
// We only want to log the errors or successful completions.
@@ -1769,7 +1904,7 @@ function _backup_migrate_message_log($message, $replace, $type) {
}
/**
- * Set or retrieve a message handler.
+ * Sets or retrieves a message handler.
*/
function _backup_migrate_message_callback($callback = NULL) {
static $current_callback = '_backup_migrate_message_log';
@@ -1779,6 +1914,29 @@ function _backup_migrate_message_callback($callback = NULL) {
return $current_callback;
}
+/**
+ * Increase the execution timeout, and also the database connection timeout.
+ */
+function _backup_migrate_set_timeout() {
+ // If not in 'safe mode', increase the maximum execution time:
+ $backup_max_time = variable_get('backup_migrate_backup_max_time', 1200);
+ if (!ini_get('safe_mode') && ini_get('max_execution_time') < $backup_max_time) {
+ drupal_set_time_limit($backup_max_time);
+ }
+
+ // Also increase the time mysql keeps the connection open.
+ if (Database::getConnection() instanceof DatabaseConnection_mysql) {
+ $mysql_wait_timeout = db_query('SELECT @@session.wait_timeout')->fetchField();
+ if ($mysql_wait_timeout < $backup_max_time) {
+ // This does not work with placeholders, so sanitize by casting to int.
+ db_query('SET SESSION wait_timeout = ' . (int) $backup_max_time);
+ }
+ }
+}
+
+/**
+ * Determines if time for a page execution has run out.
+ */
function _backup_migrate_check_timeout() {
static $timeout;
@@ -1786,41 +1944,47 @@ function _backup_migrate_check_timeout() {
if (ini_get('max_execution_time') == 0) {
return FALSE;
}
+
// Figure out when we should stop execution.
if (!$timeout) {
- $timeout = (!empty($_SERVER['REQUEST_TIME']) ? $_SERVER['REQUEST_TIME'] : time()) + ini_get('max_execution_time') - variable_get('backup_migrate_timeout_buffer', 5);
+ $backup_max_time = max(ini_get('max_execution_time'), variable_get('backup_migrate_backup_max_time', 1200));
+ $timeout = (!empty($_SERVER['REQUEST_TIME']) ? $_SERVER['REQUEST_TIME'] : time()) + $backup_max_time - variable_get('backup_migrate_timeout_buffer', 5);
}
+
return (time() > $timeout);
}
/**
- * Convert an associated array to an ini format string.
+ * Converts an associated array to an ini format string.
*/
function _backup_migrate_array_to_ini($data, $prefix = '') {
- $content = "";
+ $content = '';
foreach ($data as $key => $val) {
if ($prefix) {
- $key = $prefix . '[' . $key .']';
+ $key = $prefix . '[' . $key . ']';
}
if (is_array($val)) {
$content .= _backup_migrate_array_to_ini($val, $key);
}
else {
- $content .= $key . " = \"". $val ."\"\n";
+ $content .= $key . ' = "' . $val . "\"\n";
}
}
return $content;
}
/**
- * Execute a command line command. Returns false if the function failed.
+ * Execute a command line command.
+ *
+ * @return bool
+ * Returns FALSE if the function failed.
*/
function backup_migrate_exec($command, $args = array()) {
if (!function_exists('exec') || ini_get('safe_mode')) {
return FALSE;
}
- // Escape the arguments
+ // Escape the arguments.
foreach ($args as $key => $arg) {
$args[$key] = escapeshellarg($arg);
}
@@ -1828,14 +1992,16 @@ function backup_migrate_exec($command, $args = array()) {
$output = $result = NULL;
// Run the command.
- exec($command . ' 2>&1', $output, $result);
+ exec($command, $output, $result);
return $result == 0;
}
/**
- * A custom version of format size which treats 1GB as 1000 MB rather than 1024 MB
- * This is a more standard and expected version for storage (as opposed to memory).
+ * Format a size, treating 1GB as 1000 MB rather than 1024 MB.
+ *
+ * This is a more standard and expected version for storage (as opposed to
+ * memory).
*/
function backup_migrate_format_size($size, $langcode = LANGUAGE_NONE) {
$precision = 2;
@@ -1862,7 +2028,45 @@ function backup_migrate_format_size($size, $langcode = LANGUAGE_NONE) {
$size = ceil($size / 1000);
$string = '@size TB';
}
- return t($string, array('@size' => round($size/$multiply, $precision)), array('langcode' => $langcode));
+ return t($string, array('@size' => round($size / $multiply, $precision)), array('langcode' => $langcode));
}
-
+}
+
+/**
+ * Implements hook_mail().
+ */
+function backup_migrate_mail($key, &$message, $params) {
+ if ($key == 'backup_succeed') {
+ $message['id'] = 'backup_migrate_backup_succeed';
+ $message['subject'] = t('!site backup succeeded', array('!site' => variable_get('site_name', 'Drupal site')));
+ $message['body'][] = $params['body'];
+ }
+ elseif ($key == 'backup_fail') {
+ $message['id'] = 'backup_migrate_backup_fail';
+ $message['subject'] = t('!site backup failed', array('!site' => variable_get('site_name', 'Drupal site')));
+ $message['body'][] = $params['body'];
+ }
+}
+
+/**
+ * Identify the current memory usage.
+ *
+ * Uses the same formula as the Devel module.
+ *
+ * @return int
+ * The current memory usage, in megabytes.
+ */
+function backup_migrate_get_peak_memory_usage() {
+ return round(memory_get_peak_usage(TRUE) / 1024 / 1024, 2);
+}
+
+/**
+ * Returns the "name" element from an array.
+ *
+ * Callback for array_map() within
+ * backup_migrate_destination_db_mysql::_restore_db_from_file() and
+ * backup_migrate_source_db_mysql::_restore_db_from_file().
+ */
+function backup_migrate_array_name_value($a) {
+ return $a["name"];
}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/backup_migrate.drush.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/backup_migrate.drush.inc
index 6a44eb6..a321f22 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/backup_migrate.drush.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/backup_migrate.drush.inc
@@ -1,11 +1,10 @@
dt('Backup the site\'s database with Backup and Migrate.'),
'aliases' => array('bb'),
'examples' => array(
- 'drush bam-backup' => 'Backup the default databse to the manual backup directory using the default settings.',
- 'drush bam-backup db scheduled mysettings' => 'Backup the database to the scheduled directory using a settings profile called "mysettings"',
- 'drush bam-backup files' => 'Backup the files directory to the manual directory using the default settings. The Backup and Migrate Files module is required for files backups.',
+ 'drush bam-backup' => 'Backup the default database to the manual backup directory using the default settings.',
+ 'drush bam-backup db scheduled mysettings' => 'Backup the database to the scheduled directory using a settings profile called "mysettings"',
+ 'drush bam-backup files' => 'Backup the files directory to the manual directory using the default settings.',
),
'arguments' => array(
'source' => "Optional. The id of the source (usually a database) to backup. Use 'drush bam-sources' to get a list of sources. Defaults to 'db'",
@@ -41,7 +40,6 @@ function backup_migrate_drush_command() {
'callback' => 'backup_migrate_drush_destinations',
'description' => dt('Get a list of available destinations.'),
);
-
$items['bam-sources'] = array(
'callback' => 'backup_migrate_drush_sources',
'description' => dt('Get a list of available sources.'),
@@ -57,6 +55,17 @@ function backup_migrate_drush_command() {
'destination' => "Optional. The id of destination to list backups from. Use 'drush bam-destinations' to get a list of destinations.",
),
);
+ $items['bam-schedule'] = array(
+ 'callback' => 'backup_migrate_drush_schedule',
+ 'description' => dt('Backup using a specific schedule.'),
+ 'arguments' => array(
+ 'schedule_id' => dt('The ID of the schedule to run.'),
+ ),
+ );
+ $items['bam-schedules'] = array(
+ 'callback' => 'backup_migrate_drush_schedules',
+ 'description' => dt('Get a list of available schedules.'),
+ );
return $items;
}
@@ -67,12 +76,16 @@ function backup_migrate_drush_help($section) {
switch ($section) {
case 'drush:bam-backup':
return dt("Backup the site's database using default settings.");
+
case 'drush:bam-restore':
return dt('Restore the site\'s database with Backup and Migrate.');
+
case 'drush:bam-destinations':
return dt('Get a list of available destinations.');
+
case 'drush:bam-profiles':
return dt('Get a list of available settings profiles.');
+
case 'drush:bam-backups':
return dt('Get a list of previously created backup files.');
}
@@ -96,7 +109,7 @@ function backup_migrate_drush_backup($source_id = 'db', $destination_id = 'manua
return;
}
$settings = backup_migrate_get_profile($profile_id);
- if(!$settings) {
+ if (!$settings) {
_backup_migrate_message("Could not find the profile '@profile'. Try using 'drush bam-profiles' to get a list of available profiles.", array('@profile' => $profile_id), 'error');
return;
}
@@ -107,11 +120,49 @@ function backup_migrate_drush_backup($source_id = 'db', $destination_id = 'manua
backup_migrate_perform_backup($settings);
}
+/**
+ * Backup using schedule.
+ */
+function backup_migrate_drush_schedule($schedule_id = '') {
+ backup_migrate_include('schedules');
+
+ // Set the message mode to drush output.
+ _backup_migrate_message_callback('_backup_migrate_message_drush');
+
+ if (!($schedule = backup_migrate_get_schedule($schedule_id))) {
+ _backup_migrate_message("Could not find the schedule '@schedule'. Try using 'drush bam-schedules' to get a list of available schedules.", array('@schedule' => $schedule_id), 'error');
+ return;
+ }
+
+ if (!$schedule->enabled) {
+ _backup_migrate_message("Nothing to do, the schedule '@schedule' is disabled.", array('@schedule' => $schedule_id), 'warning');
+ return;
+ }
+
+ _backup_migrate_message("Starting schedule '$schedule_id'...");
+
+ backup_migrate_schedule_run($schedule_id);
+}
+
+/**
+ * Get a list of available destinations.
+ */
+function backup_migrate_drush_schedules() {
+ backup_migrate_include('schedules');
+ $rows = array(array(dt('ID'), dt('Name')));
+ foreach (backup_migrate_get_schedules() as $schedule) {
+ $rows[] = array(
+ $schedule->get_id(),
+ $schedule->get_name(),
+ );
+ }
+ drush_print_table($rows, TRUE, array(32, 32));
+}
+
/**
* Restore to the default database.
*/
function backup_migrate_drush_restore($source_id = '', $destination_id = '', $file_id = '') {
-
backup_migrate_include('profiles', 'destinations', 'sources');
// Set the message mode to drush output.
@@ -125,7 +176,7 @@ function backup_migrate_drush_restore($source_id = '', $destination_id = '', $fi
_backup_migrate_message("Could not find the destination '@destination'. Try using 'drush bam-destinations' to get a list of available destinations.", array('@destination' => $destination_id), 'error');
return;
}
- else if (!$file_id || !$file = backup_migrate_destination_get_file($destination_id, $file_id)) {
+ elseif (!$file_id || !$file = backup_migrate_destination_get_file($destination_id, $file_id)) {
_backup_migrate_message("Could not find the file '@file'. Try using 'drush bam-backups @destination' to get a list of available backup files in this destination destinations.", array('@destination' => $destination_id, '@file' => $file_id), 'error');
return;
}
@@ -136,7 +187,7 @@ function backup_migrate_drush_restore($source_id = '', $destination_id = '', $fi
}
_backup_migrate_message('Starting restore...');
$settings = array('source_id' => $source_id);
- backup_migrate_perform_restore($destination_id, $file_id);
+ backup_migrate_perform_restore($destination_id, $file_id, $settings);
}
/**
@@ -164,7 +215,7 @@ function _backup_migrate_drush_destinations($op = NULL) {
$rows[] = array(
$destination->get_id(),
$destination->get_name(),
- implode (', ', $destination->ops()),
+ implode(', ', $destination->ops()),
);
}
drush_print_table($rows, TRUE, array(32, 32));
@@ -181,7 +232,7 @@ function _backup_migrate_drush_sources($op = NULL) {
$rows[] = array(
$destination->get_id(),
$destination->get_name(),
- implode (', ', $destination->ops()),
+ implode(', ', $destination->ops()),
);
}
drush_print_table($rows, TRUE, array(32, 32));
@@ -203,7 +254,7 @@ function backup_migrate_drush_profiles() {
}
/**
- * Get a list of files in a given destination
+ * Get a list of files in a given destination.
*/
function backup_migrate_drush_destination_files($destination_id = NULL) {
backup_migrate_include('destinations');
@@ -220,7 +271,7 @@ function backup_migrate_drush_destination_files($destination_id = NULL) {
if ($destination) {
$destinations = array($destination);
}
- // List all destinations
+ // List all destinations.
else {
$destinations = backup_migrate_get_destinations('list files');
}
@@ -243,13 +294,15 @@ function backup_migrate_drush_destination_files($destination_id = NULL) {
}
}
- $headers = array(array(
- dt('Filename'),
- dt('Destination'),
- dt('Date'),
- dt('Age'),
- dt('Size'),
- ));
+ $headers = array(
+ array(
+ dt('Filename'),
+ dt('Destination'),
+ dt('Date'),
+ dt('Age'),
+ dt('Size'),
+ ),
+ );
if (count($rows)) {
array_multisort($sort, SORT_DESC, $rows);
@@ -264,8 +317,15 @@ function backup_migrate_drush_destination_files($destination_id = NULL) {
* Send a message to the drush log.
*/
function _backup_migrate_message_drush($message, $replace, $type) {
- // Use drush_log to display to the user.
- drush_log(strip_tags(dt($message, $replace)), str_replace('status', 'notice', $type));
+ // If this is an error use drush_set_error to notify the end user and set the
+ // exit status.
+ if ($type == 'error') {
+ drush_set_error(strip_tags(dt($message, $replace)));
+ }
+ else {
+ // Use drush_log to display to the user.
+ drush_log(strip_tags(dt($message, $replace)), str_replace('status', 'notice', $type));
+ }
// Watchdog log the message as well for admins.
_backup_migrate_message_log($message, $replace, $type);
}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/crud.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/crud.inc
index c6b0dcf..877427f 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/crud.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/crud.inc
@@ -56,14 +56,15 @@ function backup_migrate_crud_subtypes($type) {
backup_migrate_include($info['include']);
}
- // Allow modules (including this one) to declare backup and migrate subtypes.
- // We don't use module_invoke_all so we can avoid the side-effects of array_merge_recursive.
+ // Allow modules (including this one) to declare backup and migrate
+ // subtypes. We don't use module_invoke_all so we can avoid the
+ // side-effects of array_merge_recursive.
$out = array();
foreach (module_implements('backup_migrate_' . $type . '_subtypes') as $module) {
- $function = $module . '_backup_migrate_' . $type . '_subtypes';
+ $function = $module . '_backup_migrate_' . $type . '_subtypes';
$result = $function();
if (isset($result) && is_array($result)) {
- foreach ($result as $key => $val) {
+ foreach ($result as $key => $val) {
$out[$key] = $val;
}
}
@@ -87,7 +88,8 @@ function backup_migrate_crud_subtype_info($type, $subtype) {
/**
* Get a generic object of the given type to be used for static-like functions.
*
- * I'm not using actual static method calls since they don't work on variables prior to PHP 5.3.0
+ * I'm not using actual static method calls since they don't work on variables
+ * prior to PHP 5.3.0.
*/
function backup_migrate_crud_type_load($type, $subtype = NULL) {
$out = $info = NULL;
@@ -104,7 +106,7 @@ function backup_migrate_crud_type_load($type, $subtype = NULL) {
backup_migrate_include($info['include']);
}
if (!empty($info['file'])) {
- include_once './'. (isset($info['path']) ? $info['path'] : '') . $info['file'];
+ include_once './' . (isset($info['path']) ? $info['path'] : '') . $info['file'];
}
if (class_exists($info['class'])) {
@@ -132,10 +134,10 @@ function backup_migrate_crud_menu() {
$items = array();
foreach (backup_migrate_crud_types() as $type => $info) {
$item = backup_migrate_crud_type_load($type);
- $items += (array)$item->get_menu_items();
+ $items += (array) $item->get_menu_items();
foreach (backup_migrate_crud_subtypes($type) as $subtype => $info) {
$subitem = backup_migrate_crud_type_load($type, $subtype);
- $items += (array)$subitem->get_menu_items();
+ $items += (array) $subitem->get_menu_items();
}
}
return $items;
@@ -166,7 +168,7 @@ function backup_migrate_crud_ui_list($type) {
* Page callback to list all items.
*/
function backup_migrate_crud_ui_list_all() {
- $out = '';
+ $out = array();
foreach (backup_migrate_crud_types() as $type => $info) {
$type = backup_migrate_crud_type_load($type);
$out[] = theme('backup_migrate_group', array('title' => t($type->title_plural), 'body' => $type->get_list()));
@@ -189,7 +191,7 @@ function backup_migrate_crud_ui_edit($type, $item_id = NULL) {
/**
* Does a crud item with the given name exist.
- *
+ *
* Callback for the 'machine_name' form type.
*/
function backup_migrate_crud_item_exists($machine_name, $element, $form_state) {
@@ -232,7 +234,6 @@ function backup_migrate_crud_edit_form_submit($form, &$form_state) {
}
}
-
/**
* Page callback to delete an item.
*/
@@ -256,10 +257,11 @@ function backup_migrate_crud_delete_confirm_form($form, &$form_state, $item) {
if ($item->storage == BACKUP_MIGRATE_STORAGE_OVERRIDEN) {
$message = $item->revert_confirm_message();
return confirm_form($form, t('Are you sure?'), $item->get_settings_path(), $message, t('Revert'), t('Cancel'));
- } else {
+ }
+ else {
$message = $item->delete_confirm_message();
return confirm_form($form, t('Are you sure?'), $item->get_settings_path(), $message, t('Delete'), t('Cancel'));
- }
+ }
}
/**
@@ -322,7 +324,7 @@ function backup_migrate_crud_import_form($form, &$form_state) {
}
/**
- * Validate handler to import a view
+ * Validate handler to import a view.
*/
function backup_migrate_crud_import_form_validate($form, &$form_state) {
$item = backup_migrate_crud_create_from_import($form_state['values']['code']);
@@ -330,12 +332,12 @@ function backup_migrate_crud_import_form_validate($form, &$form_state) {
$form_state['values']['item'] = $item;
}
else {
- form_set_error('code', t('Unable to import item.'));
+ form_set_error('code', t('Unable to import item.'));
}
}
/**
- * import a item after confirmation.
+ * Import a item after confirmation.
*/
function backup_migrate_crud_import_form_submit($form, &$form_state) {
$item = $form_state['values']['item'];
@@ -373,7 +375,6 @@ function backup_migrate_crud_get_items($type) {
}
}
-
/**
* Get an item of the specified type.
*/
@@ -393,24 +394,26 @@ function backup_migrate_crud_create_item($type, $params) {
}
/**
- * A base class for items which can be stored in the database, listed, edited, deleted etc.
+ * A base class for items which can be stored in the database.
*/
class backup_migrate_item {
- var $show_in_list = TRUE;
- var $settings_path = '/settings/';
- var $db_table = '';
- var $type_name = '';
- var $storage = FALSE;
- var $default_values = array();
- var $singular = 'item';
- var $plural = 'items';
- var $title_plural = 'Items';
- var $title_singular = 'Item';
+ public $show_in_list = TRUE;
+ public $settings_path = '/settings/';
+ public $db_table = '';
+ public $type_name = '';
+ public $storage = FALSE;
+ public $default_values = array();
+ public $singular = 'item';
+ public $plural = 'items';
+ public $title_plural = 'Items';
+ public $title_singular = 'Item';
/**
- * This function is not supposed to be called. It is just here to help the po extractor out.
+ * This function is not supposed to be called.
+ *
+ * It is just here to help the po extractor out.
*/
- function strings() {
+ public function strings() {
// Help the pot extractor find these strings.
t('item');
t('items');
@@ -425,25 +428,25 @@ class backup_migrate_item {
t('Export !type');
}
-
/**
- * Constructor, set the basic info pulled from the db or generated programatically.
+ * Set the basic info pulled from the db or generated programatically.
*/
- function __construct($params = array()) {
- $this->from_array($this->_merge_defaults((array)$params, (array)$this->get_default_values()));
+ public function __construct($params = array()) {
+ $this->from_array($this->_merge_defaults((array) $params, (array) $this->get_default_values()));
}
/**
* Merge parameters with the given defaults.
*
- * Works like array_merge_recursive, but it doesn't turn scalar values into arrays.
+ * Works like array_merge_recursive, but it doesn't turn scalar values into
+ * arrays.
*/
- function _merge_defaults($params, $defaults) {
+ public function _merge_defaults($params, $defaults) {
foreach ($defaults as $key => $val) {
if (!isset($params[$key])) {
$params[$key] = $val;
}
- else if (is_array($params[$key])) {
+ elseif (is_array($params[$key])) {
$params[$key] = $this->_merge_defaults($params[$key], $val);
}
}
@@ -453,14 +456,14 @@ class backup_migrate_item {
/**
* Get the default values for standard parameters.
*/
- function get_default_values() {
+ public function get_default_values() {
return $this->default_values;
}
/**
* Save the item to the database.
- */
- function save() {
+ */
+ public function save() {
if (!$this->get_id()) {
$this->unique_id();
}
@@ -470,20 +473,19 @@ class backup_migrate_item {
/**
* Delete the item from the database.
- */
- function delete() {
- $keys = (array)$this->get_machine_name_field();
+ */
+ public function delete() {
+ $keys = (array) $this->get_machine_name_field();
db_query('DELETE FROM {' . $this->db_table . '} WHERE ' . $keys[0] . ' = :id', array(':id' => $this->get_id()));
}
-
/**
* Load an existing item from an array.
*/
- function from_array($params) {
+ public function from_array($params) {
foreach ($params as $key => $value) {
- if (method_exists($this, 'set_'. $key)) {
- $this->{'set_'. $key}($value);
+ if (method_exists($this, 'set_' . $key)) {
+ $this->{'set_' . $key}($value);
}
else {
$this->{$key} = $value;
@@ -494,7 +496,7 @@ class backup_migrate_item {
/**
* Return as an array of values.
*/
- function to_array() {
+ public function to_array() {
$out = array();
// Return fields as specified in the schema.
$schema = $this->get_schema();
@@ -509,7 +511,7 @@ class backup_migrate_item {
/**
* Return as an exported array of values.
*/
- function export() {
+ public function export() {
$out = $this->to_array();
$out['type_name'] = $this->type_name;
@@ -523,7 +525,7 @@ class backup_migrate_item {
/**
* Load an existing item from an database (serialized) array.
*/
- function load_row($data) {
+ public function load_row($data) {
$params = array();
$schema = $this->get_schema();
// Load fields as specified in the schema.
@@ -533,11 +535,10 @@ class backup_migrate_item {
$this->from_array($params);
}
-
/**
* Decode a loaded db row (unserialize necessary fields).
*/
- function decode_db_row($data) {
+ public function decode_db_row($data) {
$params = array();
$schema = $this->get_schema();
// Load fields as specified in the schema.
@@ -550,7 +551,7 @@ class backup_migrate_item {
/**
* Return the fields which must be serialized before saving to the db.
*/
- function get_serialized_fields() {
+ public function get_serialized_fields() {
$out = array();
$schema = $this->get_schema();
foreach ($schema['fields'] as $field => $info) {
@@ -564,7 +565,7 @@ class backup_migrate_item {
/**
* Get the primary key field title from the schema.
*/
- function get_primary_key() {
+ public function get_primary_key() {
$schema = $this->get_schema();
return @$schema['primary key'];
}
@@ -572,7 +573,7 @@ class backup_migrate_item {
/**
* Get the machine name field name from the schema.
*/
- function get_machine_name_field() {
+ public function get_machine_name_field() {
$schema = $this->get_schema();
if (isset($schema['export']['key'])) {
return $schema['export']['key'];
@@ -583,7 +584,7 @@ class backup_migrate_item {
/**
* Get the schema for the item type.
*/
- function get_schema() {
+ public function get_schema() {
return drupal_get_schema($this->db_table);
}
@@ -592,16 +593,16 @@ class backup_migrate_item {
*
* We only handle single field keys since that's all we need.
*/
- function get_id() {
- $keys = (array)$this->get_machine_name_field();
- return !empty($keys[0]) && !empty($this->{$keys[0]}) ? (string)$this->{$keys[0]} : '';
+ public function get_id() {
+ $keys = (array) $this->get_machine_name_field();
+ return !empty($keys[0]) && !empty($this->{$keys[0]}) ? (string) $this->{$keys[0]} : '';
}
/**
* Set the primary id for this item (if any is set).
*/
- function set_id($id) {
- $keys = (array)$this->get_machine_name_field();
+ public function set_id($id) {
+ $keys = (array) $this->get_machine_name_field();
if (!empty($keys[0])) {
return $this->{$keys[0]} = $id;
}
@@ -611,8 +612,8 @@ class backup_migrate_item {
/**
* Return a random (very very likely unique) string id for a new item.
*/
- function generate_id() {
- $id = md5(uniqid(mt_rand(), true));
+ public function generate_id() {
+ $id = md5(uniqid(mt_rand(), TRUE));
// Find the shortest possible unique id from (min 4 chars).
for ($i = 4; $i < 32; $i++) {
@@ -621,23 +622,27 @@ class backup_migrate_item {
return $new_id;
}
}
- // If we get here, then all 28 increasingly complex ids were already taken so we'll try again.
- // this could theoretially lead to an infinite loop, but the odds are incredibly low.
+ // If we get here, then all 28 increasingly complex ids were already taken
+ // so we'll try again; this could theoretially lead to an infinite loop,
+ // but the odds are incredibly low.
return $this->generate_id();
}
/**
- * Make sure this item has a unique id. Should only be called for new items or the item will collide with itself.
+ * Make sure this item has a unique id.
+ *
+ * Should only be called for new items or the item will collide with itself.
*/
- function unique_id() {
+ public function unique_id() {
$id = $this->get_id();
// Unset the autoincrement field so it can be regenerated.
- foreach ((array)$this->get_primary_key() as $key) {
- $this->{$key} = NULL;
+ foreach ((array) $this->get_primary_key() as $key) {
+ $this->{$key} = NULL;
}
- // If the item doesn't have an ID or if it's id is already taken, generate random one.
+ // If the item doesn't have an ID or if it's id is already taken, generate
+ // random one.
if (!$id || $this->item($id)) {
$this->set_id($this->generate_id());
}
@@ -646,26 +651,24 @@ class backup_migrate_item {
/**
* Get the name of the item.
*/
- function get_name() {
+ public function get_name() {
return @$this->name;
}
/**
* Get the member with the given key.
- */
- function get($key) {
- if (method_exists($this, 'get_'. $key)) {
- return $this->{'get_'. $key}();
+ */
+ public function get($key) {
+ if (method_exists($this, 'get_' . $key)) {
+ return $this->{'get_' . $key}();
}
return @$this->{$key};
}
- /* UI Stuff */
-
/**
* Get the action links for a destination.
*/
- function get_action_links() {
+ public function get_action_links() {
$out = array();
$item_id = $this->get_id();
@@ -675,13 +678,13 @@ class backup_migrate_item {
if (@$this->storage == BACKUP_MIGRATE_STORAGE_DB || @$this->storage == BACKUP_MIGRATE_STORAGE_OVERRIDEN) {
$out['edit'] = l(t("edit"), $path . "/edit/$item_id");
}
- else if (@$this->storage == BACKUP_MIGRATE_STORAGE_NONE) {
+ elseif (@$this->storage == BACKUP_MIGRATE_STORAGE_NONE) {
$out['edit'] = l(t("override"), $path . "/edit/$item_id");
}
if (@$this->storage == BACKUP_MIGRATE_STORAGE_DB) {
$out['delete'] = l(t("delete"), $path . "/delete/$item_id");
}
- else if (@$this->storage == BACKUP_MIGRATE_STORAGE_OVERRIDEN) {
+ elseif (@$this->storage == BACKUP_MIGRATE_STORAGE_OVERRIDEN) {
$out['delete'] = l(t("revert"), $path . "/delete/$item_id");
}
$out['export'] = l(t("export"), $path . "/export/$item_id");
@@ -691,11 +694,11 @@ class backup_migrate_item {
/**
* Get a table of all items of this type.
- */
- function get_list() {
+ */
+ public function get_list() {
$items = $this->all_items();
$rows = array();
- foreach ((array)$items as $item) {
+ foreach ((array) $items as $item) {
if ($item->show_in_list()) {
if ($row = $item->get_list_row()) {
$rows[] = $row;
@@ -709,30 +712,29 @@ class backup_migrate_item {
$out = t('There are no !items to display.', array('!items' => $this->plural));
}
if (user_access('administer backup and migrate')) {
- $out .= ' '. l(t('Create a new !item', array('!item' => $this->singular)), $this->get_settings_path() .'/add');
+ $out .= ' ' . l(t('Create a new !item', array('!item' => $this->singular)), $this->get_settings_path() . '/add');
}
return $out;
}
/**
* Get the columns needed to list the type.
- */
- function show_in_list() {
+ */
+ public function show_in_list() {
return $this->show_in_list;
}
/**
* Get the columns needed to list the type.
- */
- function get_settings_path() {
+ */
+ public function get_settings_path() {
return BACKUP_MIGRATE_MENU_PATH . $this->settings_path . $this->type_name;
}
-
/**
* Get the columns needed to list the type.
- */
- function get_list_column_info() {
+ */
+ public function get_list_column_info() {
return array(
'actions' => array('title' => t('Operations'), 'html' => TRUE),
);
@@ -740,8 +742,8 @@ class backup_migrate_item {
/**
* Get header for a lost of this type.
- */
- function get_list_header() {
+ */
+ public function get_list_header() {
$out = array();
foreach ($this->get_list_column_info() as $key => $col) {
$out[] = $col['title'];
@@ -751,8 +753,8 @@ class backup_migrate_item {
/**
* Get a row of data to be used in a list of items of this type.
- */
- function get_list_row() {
+ */
+ public function get_list_row() {
$out = array();
foreach ($this->get_list_column_info() as $key => $col) {
$out[$key] = empty($col['html']) ? check_plain($this->get($key)) : $this->get($key);
@@ -766,7 +768,7 @@ class backup_migrate_item {
/**
* Get the rendered action links for a destination.
*/
- function get_actions() {
+ public function get_actions() {
$links = $this->get_action_links();
return implode(" ", $links);
}
@@ -774,7 +776,7 @@ class backup_migrate_item {
/**
* Get the edit form for the item.
*/
- function edit_form() {
+ public function edit_form() {
$form = array();
$form['item'] = array(
'#type' => 'value',
@@ -811,37 +813,36 @@ class backup_migrate_item {
/**
* Validate the edit form for the item.
*/
- function edit_form_validate($form, &$form_state) {
+ public function edit_form_validate($form, &$form_state) {
}
/**
* Submit the edit form for the item.
*/
- function edit_form_submit($form, &$form_state) {
+ public function edit_form_submit($form, &$form_state) {
$this->from_array($form_state['values']);
$this->save();
_backup_migrate_message('Your !type was saved', array('!type' => t($this->singular)));
}
/**
- * Get the message to send to the user when confirming the deletion of the item.
+ * The message to send to the user when confirming the deletion of the item.
*/
- function delete_confirm_message() {
+ public function delete_confirm_message() {
return t('Are you sure you want to delete the !type %name?', array('!type' => t($this->singular), '%name' => $this->get('name')));
}
/**
- * Get the message to send to the user when confirming the deletion of the item.
+ * The message to send to the user when confirming the deletion of the item.
*/
- function revert_confirm_message() {
+ public function revert_confirm_message() {
return t('Are you sure you want to revert the !type %name back to the default settings?', array('!type' => t($this->singular), '%name' => $this->get('name')));
}
- /* Static Functions */
/**
* Get the menu items for manipulating this type.
*/
- function get_menu_items() {
+ public function get_menu_items() {
$path = $this->get_settings_path();
$type = $this->type_name;
@@ -853,13 +854,13 @@ class backup_migrate_item {
'weight' => 2,
'type' => MENU_LOCAL_TASK,
);
- $items[$path .'/list'] = array(
+ $items[$path . '/list'] = array(
'title' => 'List !type',
'title arguments' => array('!type' => t($this->title_plural)),
'weight' => 1,
'type' => MENU_DEFAULT_LOCAL_TASK,
);
- $items[$path .'/add'] = array(
+ $items[$path . '/add'] = array(
'title' => 'Add !type',
'title arguments' => array('!type' => t($this->title_singular)),
'page callback' => 'backup_migrate_menu_callback',
@@ -868,7 +869,7 @@ class backup_migrate_item {
'weight' => 2,
'type' => MENU_LOCAL_ACTION,
);
- $items[$path .'/delete'] = array(
+ $items[$path . '/delete'] = array(
'title' => 'Delete !type',
'title arguments' => array('!type' => t($this->title_singular)),
'page callback' => 'backup_migrate_menu_callback',
@@ -876,7 +877,7 @@ class backup_migrate_item {
'access arguments' => array('administer backup and migrate'),
'type' => MENU_CALLBACK,
);
- $items[$path .'/edit'] = array(
+ $items[$path . '/edit'] = array(
'title' => 'Edit !type',
'title arguments' => array('!type' => t($this->title_singular)),
'page callback' => 'backup_migrate_menu_callback',
@@ -884,7 +885,7 @@ class backup_migrate_item {
'access arguments' => array('administer backup and migrate'),
'type' => MENU_CALLBACK,
);
- $items[$path .'/export'] = array(
+ $items[$path . '/export'] = array(
'title' => 'Export !type',
'title arguments' => array('!type' => t($this->title_singular)),
'page callback' => 'backup_migrate_menu_callback',
@@ -895,11 +896,13 @@ class backup_migrate_item {
return $items;
}
-
/**
- * Create a new items with the given input. Doesn't load the parameters, but could use them to determine what type to create.
+ * Create a new items with the given input.
+ *
+ * Doesn't load the parameters, but could use them to determine what type to
+ * create.
*/
- function create($params = array()) {
+ public function create($params = array()) {
$type = get_class($this);
return new $type($params);
}
@@ -907,12 +910,12 @@ class backup_migrate_item {
/**
* Get all of the given items.
*/
- function all_items() {
- static $cache = array();
+ public function all_items() {
$items = array();
- // Get any items stored as a variable. This allows destinations to be defined in settings.php
- $defaults = (array)variable_get($this->db_table . '_defaults', array());
+ // Get any items stored as a variable. This allows destinations to be
+ // defined in settings.php
+ $defaults = (array) variable_get($this->db_table . '_defaults', array());
foreach ($defaults as $info) {
if (is_array($info) && $item = $this->create($info)) {
$items[$item->get_id()] = $item;
@@ -932,27 +935,16 @@ class backup_migrate_item {
// Allow other modules to declare destinations programatically.
$default_items = module_invoke_all($this->db_table);
- // Get CTools exported versions.
- if (function_exists('ctools_include')) {
- ctools_include('export');
- $defaults = ctools_export_load_object($this->db_table);
- foreach ($defaults as $info) {
- $info = (array)$info;
- if (!empty($info) && $item = $this->create($info)) {
- $default_items[$item->get_id()] = $item;
- }
- }
- }
-
// Get any items stored as a variable again to correctly mark overrides.
- $defaults = (array)variable_get($this->db_table . '_defaults', array());
+ $defaults = (array) variable_get($this->db_table . '_defaults', array());
foreach ($defaults as $info) {
if (is_array($info) && $item = $this->create($info)) {
$default_items[] = $item;
}
}
- // Add the default items to the array or set the storage flag if they've already been overridden.
+ // Add the default items to the array or set the storage flag if they've
+ // already been overridden.
foreach ($default_items as $item) {
if (isset($items[$item->get_id()])) {
$items[$item->get_id()]->storage = BACKUP_MIGRATE_STORAGE_OVERRIDEN;
@@ -963,9 +955,10 @@ class backup_migrate_item {
}
}
- // Allow other modules to alter the items. This should maybe be before the db override code above
- // but then the filters are not able to set defaults for missing values. Other modules should just
- // be careful not to overwrite the user's UI changes in an unexpected way.
+ // Allow other modules to alter the items. This should maybe be before the
+ // db override code above but then the filters are not able to set defaults
+ // for missing values. Other modules should just be careful not to
+ // overwrite the user's UI changes in an unexpected way.
drupal_alter($this->db_table, $items);
return $items;
@@ -974,7 +967,7 @@ class backup_migrate_item {
/**
* A particular item.
*/
- function item($item_id) {
+ public function item($item_id) {
$items = $this->all_items();
return !empty($items[$item_id]) ? $items[$item_id] : NULL;
}
@@ -982,8 +975,9 @@ class backup_migrate_item {
/**
* A particular item.
*/
- function item_exists($item_id) {
+ public function item_exists($item_id) {
$items = $this->all_items();
return !empty($items[$item_id]);
}
+
}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.browser.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.browser.inc
index af75649..707f2f1 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.browser.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.browser.inc
@@ -1,6 +1,5 @@
$file->uri));
backup_migrate_temp_files_add($file->uri);
@@ -46,6 +55,7 @@ class backup_migrate_destination_browser_upload extends backup_migrate_destinati
}
return NULL;
}
+
}
/**
@@ -54,11 +64,22 @@ class backup_migrate_destination_browser_upload extends backup_migrate_destinati
* @ingroup backup_migrate_destinations
*/
class backup_migrate_destination_browser_download extends backup_migrate_destination_browser {
- var $supported_ops = array('manual backup');
- // Browser downloads must always be the last destination as they must end the current process when they are done.
- var $weight = 1000;
- function __construct() {
+ /**
+ * {@inheritdoc}
+ */
+ public $supported_ops = array('manual backup');
+
+ /**
+ * Browser downloads must always be the last destination as they must end the
+ * current process when they are done.
+ */
+ public $weight = 1000;
+
+ /**
+ * Constructor.
+ */
+ public function __construct() {
$params = array();
$params['name'] = "Download";
$params['machine_name'] = 'download';
@@ -68,9 +89,9 @@ class backup_migrate_destination_browser_download extends backup_migrate_destina
/**
* File save destination callback.
*/
- function save_file($file, $settings) {
+ public function save_file($file, $settings) {
backup_migrate_include('files');
$file->transfer();
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.db.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.db.inc
index 9a2e23a..e44308e 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.db.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.db.inc
@@ -1,6 +1,5 @@
set_source($this->get_id());
@@ -40,10 +39,10 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Destination configuration callback.
*/
- function edit_form() {
+ public function edit_form() {
$form = parent::edit_form();
$form['scheme']['#title'] = t('Database type');
-// $form['scheme']['#options'] = array($GLOBALS['db_type'] => $GLOBALS['db_type']);
+ // $form['scheme']['#options'] = array($GLOBALS['db_type'] => $GLOBALS['db_type']);
$form['scheme']['#description'] = t('The type of the database. Drupal only supports one database type at a time, so this must be the same as the current database type.');
$form['path']['#title'] = t('Database name');
$form['path']['#description'] = t('The name of the database. The database must exist, it will not be created for you.');
@@ -54,7 +53,7 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Validate the configuration form. Make sure the db info is valid.
*/
- function edit_form_validate($form, &$form_state) {
+ public function edit_form_validate($form, &$form_state) {
if (!preg_match('/[a-zA-Z0-9_\$]+/', $form_state['values']['path'])) {
form_set_error('path', t('The database name is not valid.'));
}
@@ -62,56 +61,63 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
}
/**
- * Get the form for the settings for this destination.
+ * Get the default settings for this object.
*
- * Return the default tables whose data can be ignored. These tables mostly contain
- * info which can be easily reproducted (such as cache or search index)
- * but also tables which can become quite bloated but are not necessarily extremely
- * important to back up or migrate during development (such ass access log and watchdog)
+ * @return array
+ * The default tables whose data can be ignored. These tables mostly
+ * contain info which can be easily reproducted (such as cache or search
+ * index) but also tables which can become quite bloated but are not
+ * necessarily extremely important to back up or migrate during development
+ * (such as access log and watchdog).
*/
- function backup_settings_default() {
- $core = array(
- 'cache',
- 'cache_admin_menu',
- 'cache_browscap',
- 'cache_content',
- 'cache_filter',
- 'cache_calendar_ical',
- 'cache_location',
- 'cache_menu',
- 'cache_page',
- 'cache_reptag',
- 'cache_views',
- 'cache_views_data',
- 'cache_block',
- 'cache_update',
- 'cache_form',
- 'cache_bootstrap',
- 'cache_field',
- 'cache_image',
- 'cache_path',
- 'sessions',
- 'search_dataset',
- 'search_index',
- 'search_keywords_log',
- 'search_total',
- 'watchdog',
- 'accesslog',
- 'devel_queries',
- 'devel_times',
- );
- $nodata_tables = array_merge($core, module_invoke_all('devel_caches'));
- return array(
- 'nodata_tables' => $nodata_tables,
- 'exclude_tables' => array(),
+ public function backup_settings_default() {
+ $all_tables = $this->_get_table_names();
+
+ // Basic modules that should be excluded.
+ $basic = array(
+ // Default core tables.
+ 'accesslog',
+ 'sessions',
+ 'watchdog',
+ // Search module.
+ 'search_dataset',
+ 'search_index',
+ 'search_keywords_log',
+ 'search_total',
+ // Devel module.
+ 'devel_queries',
+ 'devel_times',
+ );
+
+ // Identify all cache tables.
+ $cache = array('cache');
+ foreach ($all_tables as $table_name) {
+ if (strpos($table_name, 'cache_') === 0) {
+ $cache[] = $table_name;
+ }
+ }
+
+ // Simpletest can create a lot of tables that do not need to be backed up,
+ // but all of them start with the string 'simpletest' so they can be easily
+ // excluded.
+ $simpletest = array();
+ foreach ($all_tables as $table_name) {
+ if (strpos($table_name, 'simpletest') === 0) {
+ $simpletest[] = $table_name;
+ }
+ }
+
+ return array(
+ 'nodata_tables' => array_merge($basic, $cache, module_invoke_all('devel_caches')),
+ 'exclude_tables' => $simpletest,
'utils_lock_tables' => FALSE,
- );
+ );
}
/**
* Get the form for the backup settings for this destination.
*/
- function backup_settings_form($settings) {
+ public function backup_settings_form($settings) {
$objects = $this->get_object_names();
$form['#description'] = t("You may omit specific tables, or specific table data from the backup file. Only omit data that you know you will not need such as cache data, or tables from other applications. Excluding tables can break your Drupal install, so do not change these settings unless you know what you're doing.");
$form['exclude_tables'] = array(
@@ -143,16 +149,15 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Backup from this source.
*/
- function backup_to_file($file, $settings) {
+ public function backup_to_file($file, $settings) {
$file->push_type($this->get_file_type_id());
backup_migrate_filters_invoke_all('pre_backup', $this, $file, $settings);
- //$this->lock_tables($settings);
-
+ // $this->lock_tables($settings);
// Switch to a different db if specified.
$success = $this->_backup_db_to_file($file, $settings);
- //$this->unlock_tables($settings);
+ // $this->unlock_tables($settings);
backup_migrate_filters_invoke_all('post_backup', $this, $file, $settings, $success);
return $success ? $file : FALSE;
@@ -161,7 +166,7 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Restore to this source.
*/
- function restore_from_file($file, &$settings) {
+ public function restore_from_file($file, &$settings) {
$num = 0;
$type = $this->get_file_type_id();
// Open the file using the file wrapper. Check that the dump is of the right type (allow .sql for legacy reasons).
@@ -183,7 +188,7 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Get the db connection for the specified db.
*/
- function _get_db_connection() {
+ public function _get_db_connection() {
if (!$this->connection) {
$target = $key = '';
$parts = explode(':', $this->get_id());
@@ -197,12 +202,12 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
// If the url is specified build it into a connection info array.
if (!empty($this->dest_url)) {
$info = array(
- 'driver' => empty($this->dest_url['scheme']) ? NULL : $this->dest_url['scheme'],
- 'host' => empty($this->dest_url['host']) ? NULL : $this->dest_url['host'],
- 'port' => empty($this->dest_url['port']) ? NULL : $this->dest_url['port'],
- 'username' => empty($this->dest_url['user']) ? NULL : $this->dest_url['user'],
- 'password' => empty($this->dest_url['pass']) ? NULL : $this->dest_url['pass'],
- 'database' => empty($this->dest_url['path']) ? NULL : $this->dest_url['path'],
+ 'driver' => empty($this->dest_url['scheme']) ? NULL : $this->dest_url['scheme'],
+ 'host' => empty($this->dest_url['host']) ? NULL : $this->dest_url['host'],
+ 'port' => empty($this->dest_url['port']) ? NULL : $this->dest_url['port'],
+ 'username' => empty($this->dest_url['user']) ? NULL : $this->dest_url['user'],
+ 'password' => empty($this->dest_url['pass']) ? NULL : $this->dest_url['pass'],
+ 'database' => empty($this->dest_url['path']) ? NULL : $this->dest_url['path'],
);
$key = uniqid('backup_migrate_tmp_');
$target = 'default';
@@ -223,21 +228,21 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Backup the databases to a file.
*/
- function _backup_db_to_file($file, $settings) {
+ public function _backup_db_to_file($file, $settings) {
// Must be overridden.
}
/**
* Backup the databases to a file.
*/
- function _restore_db_from_file($file, $settings) {
+ public function _restore_db_from_file($file, $settings) {
// Must be overridden.
}
/**
* Get a list of objects in the database.
*/
- function get_object_names() {
+ public function get_object_names() {
// Must be overridden.
$out = $this->_get_table_names();
if (method_exists($this, '_get_view_names')) {
@@ -249,7 +254,7 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Get a list of tables in the database.
*/
- function get_table_names() {
+ public function get_table_names() {
// Must be overridden.
$out = $this->_get_table_names();
return $out;
@@ -258,7 +263,7 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Get a list of tables in the database.
*/
- function _get_table_names() {
+ public function _get_table_names() {
// Must be overridden.
return array();
}
@@ -266,12 +271,12 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Lock the database in anticipation of a backup.
*/
- function lock_tables($settings) {
+ public function lock_tables($settings) {
if ($settings->filters['utils_lock_tables']) {
$tables = array();
foreach ($this->get_table_names() as $table) {
// There's no need to lock excluded or structure only tables because it doesn't matter if they change.
- if (empty($settings->filters['exclude_tables']) || !in_array($table, (array)$settings->filters['exclude_tables'])) {
+ if (empty($settings->filters['exclude_tables']) || !in_array($table, (array) $settings->filters['exclude_tables'])) {
$tables[] = $table;
}
}
@@ -282,14 +287,14 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Lock the list of given tables in the database.
*/
- function _lock_tables($tables) {
+ public function _lock_tables($tables) {
// Must be overridden.
}
/**
* Unlock any tables that have been locked.
*/
- function unlock_tables($settings) {
+ public function unlock_tables($settings) {
if ($settings->filters['utils_lock_tables']) {
$this->_unlock_tables();
}
@@ -298,14 +303,15 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Unlock the list of given tables in the database.
*/
- function _unlock_tables($tables) {
+ public function _unlock_tables($tables) {
// Must be overridden.
}
/**
* Get the file type for to backup this destination to.
*/
- function get_file_type_id() {
+ public function get_file_type_id() {
return 'sql';
}
+
}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.db.mysql.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.db.mysql.inc
index 77ccfa4..35a6d1b 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.db.mysql.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.db.mysql.inc
@@ -1,5 +1,9 @@
array(
"extension" => "sql",
@@ -41,17 +44,27 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
/**
* Declare any mysql databases defined in the settings.php file as a possible destination.
*/
- function destinations() {
+ public function destinations() {
$out = array();
global $databases;
- foreach ((array)$databases as $db_key => $target) {
- foreach ((array)$target as $tgt_key => $info) {
+ foreach ((array) $databases as $db_key => $target) {
+ foreach ((array) $target as $tgt_key => $info) {
// Only mysql/mysqli supported by this destination.
$key = $db_key . ':' . $tgt_key;
if ($info['driver'] === 'mysql') {
- $url = $info['driver'] . '://' . $info['username'] . ':' . $info['password'] . '@' . $info['host'] . (isset($info['port']) ? ':' . $info['port'] : '') . '/' . $info['database'];
+ // Compile the database connection string.
+ $url = 'mysql://';
+ $url .= urlencode($info['username']) . ':' . urlencode($info['password']);
+ $url .= '@';
+ $url .= urlencode($info['host']);
+ if (!empty($info['port'])) {
+ $url .= ':' . $info['port'];
+ }
+ $url .= '/' . urlencode($info['database']);
+
if ($destination = backup_migrate_create_destination('mysql', array('url' => $url))) {
- // Treat the default database differently because it is probably the only one available.
+ // Treat the default database differently because it is probably
+ // the only one available.
if ($key == 'default:default') {
$destination->set_id('db');
$destination->set_name(t('Default Database'));
@@ -60,8 +73,8 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
$destination->remove_op('manual backup');
}
else {
- $destination->set_id('db:'. $key);
- $destination->set_name($key .": ". $destination->get_display_location());
+ $destination->set_id('db:' . $key);
+ $destination->set_name($key . ": " . $destination->get_display_location());
}
$out[$destination->get_id()] = $destination;
}
@@ -74,14 +87,14 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
/**
* Get the file type for to backup this destination to.
*/
- function get_file_type_id() {
+ public function get_file_type_id() {
return 'mysql';
}
/**
* Get the form for the backup settings for this destination.
*/
- function backup_settings_form($settings) {
+ public function backup_settings_form($settings) {
$form = parent::backup_settings_form($settings);
$form['use_mysqldump'] = array(
@@ -94,15 +107,14 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
return $form;
}
-
/**
* Backup the databases to a file.
*
* Returns a list of sql commands, one command per line.
* That makes it easier to import without loading the whole file into memory.
- * The files are a little harder to read, but human-readability is not a priority
+ * The files are a little harder to read, but human-readability is not a priority.
*/
- function _backup_db_to_file($file, $settings) {
+ public function _backup_db_to_file($file, $settings) {
if (!empty($settings->filters['use_mysqldump']) && $this->_backup_db_to_file_mysqldump($file, $settings)) {
return TRUE;
}
@@ -145,16 +157,14 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
}
}
-
/**
* Backup the databases to a file using the mysqldump command.
*/
- function _backup_db_to_file_mysqldump($file, $settings) {
+ public function _backup_db_to_file_mysqldump($file, $settings) {
$success = FALSE;
$nodata_tables = array();
$alltables = $this->_get_tables();
-
$command = 'mysqldump --result-file=%file --opt -Q --host=%host --port=%port --user=%user --password=%pass %db';
$args = array(
'%file' => $file->filepath(),
@@ -168,17 +178,17 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
// Ignore the excluded and no-data tables.
$db = $this->dest_url['path'];
if (!empty($settings->filters['exclude_tables'])) {
- foreach ((array)$settings->filters['exclude_tables'] as $table) {
+ foreach ((array) $settings->filters['exclude_tables'] as $table) {
if (isset($alltables[$table])) {
- $command .= ' --ignore-table='. $db .'.'. $table;
+ $command .= ' --ignore-table=' . $db . '.' . $table;
}
}
}
if (!empty($settings->filters['nodata_tables'])) {
- foreach ((array)$settings->filters['nodata_tables'] as $table) {
+ foreach ((array) $settings->filters['nodata_tables'] as $table) {
if (isset($alltables[$table])) {
$nodata_tables[] = $table;
- $command .= ' --ignore-table='. $db .'.'. $table;
+ $command .= ' --ignore-table=' . $db . '.' . $table;
}
}
}
@@ -196,10 +206,19 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
/**
* Backup the databases to a file.
*/
- function _restore_db_from_file($file, $settings) {
+ public function _restore_db_from_file($file, $settings) {
$num = 0;
if ($file->open() && $conn = $this->_get_db_connection()) {
+ // Optionally drop all existing tables.
+ if (!empty($settings->filters['utils_drop_all_tables'])) {
+ $all_tables = $this->_get_tables();
+ $table_names = array_map('backup_migrate_array_name_value', $all_tables);
+ $table_list = join(', ', $table_names);
+ $stmt = $conn->prepare("DROP TABLE IF EXISTS $table_list;\n");
+ $stmt->execute();
+ }
+
// Read one line at a time and run the query.
while ($line = $this->_read_sql_command_from_file($file)) {
if (_backup_migrate_check_timeout()) {
@@ -222,17 +241,16 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
return $num;
}
-
/**
* Read a multiline sql command from a file.
*
* Supports the formatting created by mysqldump, but won't handle multiline comments.
*/
- function _read_sql_command_from_file($file) {
+ public function _read_sql_command_from_file($file) {
$out = '';
while ($line = $file->read()) {
$first2 = substr($line, 0, 2);
- $first3 = substr($line, 0, 2);
+ $first3 = substr($line, 0, 3);
// Ignore single line comments. This function doesn't support multiline comments or inline comments.
if ($first2 != '--' && ($first2 != '/*' || $first3 == '/*!')) {
@@ -249,7 +267,7 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
/**
* Get a list of tables in the database.
*/
- function _get_table_names() {
+ public function _get_table_names() {
$out = array();
foreach ($this->_get_tables() as $table) {
$out[$table['name']] = $table['name'];
@@ -260,7 +278,7 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
/**
* Get a list of views in the database.
*/
- function _get_view_names() {
+ public function _get_view_names() {
$out = array();
foreach ($this->_get_views() as $view) {
$out[$view['name']] = $view['name'];
@@ -271,29 +289,29 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
/**
* Lock the list of given tables in the database.
*/
- function _lock_tables($tables) {
+ public function _lock_tables($tables) {
if ($tables) {
$tables_escaped = array();
foreach ($tables as $table) {
- $tables_escaped[] = '`'. db_escape_table($table) .'` WRITE';
+ $tables_escaped[] = '`' . db_escape_table($table) . '` WRITE';
}
- $this->query('LOCK TABLES '. implode(', ', $tables_escaped));
+ $this->query('LOCK TABLES ' . implode(', ', $tables_escaped));
}
}
/**
* Unlock all tables in the database.
*/
- function _unlock_tables($settings) {
+ public function _unlock_tables($settings) {
$this->query('UNLOCK TABLES');
}
/**
* Get a list of tables in the db.
*/
- function _get_tables() {
+ public function _get_tables() {
$out = array();
- // get auto_increment values and names of all tables
+ // get auto_increment values and names of all tables.
$tables = $this->query("show table status", array(), array('fetch' => PDO::FETCH_ASSOC));
foreach ($tables as $table) {
// Lowercase the keys because between Drupal 7.12 and 7.13/14 the default query behavior was changed.
@@ -309,9 +327,9 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
/**
* Get a list of views in the db.
*/
- function _get_views() {
+ public function _get_views() {
$out = array();
- // get auto_increment values and names of all tables
+ // get auto_increment values and names of all tables.
$tables = $this->query("show table status", array(), array('fetch' => PDO::FETCH_ASSOC));
foreach ($tables as $table) {
// Lowercase the keys because between Drupal 7.12 and 7.13/14 the default query behavior was changed.
@@ -327,36 +345,36 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
/**
* Get the sql for the structure of the given table.
*/
- function _get_table_structure_sql($table) {
+ public function _get_table_structure_sql($table) {
$out = "";
- $result = $this->query("SHOW CREATE TABLE `". $table['name'] ."`", array(), array('fetch' => PDO::FETCH_ASSOC));
+ $result = $this->query("SHOW CREATE TABLE `" . $table['name'] . "`", array(), array('fetch' => PDO::FETCH_ASSOC));
foreach ($result as $create) {
// Lowercase the keys because between Drupal 7.12 and 7.13/14 the default query behavior was changed.
// See: http://drupal.org/node/1171866
$create = array_change_key_case($create);
- $out .= "DROP TABLE IF EXISTS `". $table['name'] ."`;\n";
+ $out .= "DROP TABLE IF EXISTS `" . $table['name'] . "`;\n";
// Remove newlines and convert " to ` because PDO seems to convert those for some reason.
$out .= strtr($create['create table'], array("\n" => ' ', '"' => '`'));
if ($table['auto_increment']) {
- $out .= " AUTO_INCREMENT=". $table['auto_increment'];
+ $out .= " AUTO_INCREMENT=" . $table['auto_increment'];
}
$out .= ";\n";
}
return $out;
}
-
+
/**
* Get the sql for the structure of the given table.
*/
- function _get_view_create_sql($view) {
+ public function _get_view_create_sql($view) {
$out = "";
- // Switch SQL mode to get rid of "CREATE ALGORITHM..." what requires more permissions + troubles with the DEFINER user
+ // Switch SQL mode to get rid of "CREATE ALGORITHM..." what requires more permissions + troubles with the DEFINER user.
$sql_mode = $this->query("SELECT @@SESSION.sql_mode")->fetchField();
$this->query("SET sql_mode = 'ANSI'");
$result = $this->query("SHOW CREATE VIEW `" . $view['name'] . "`", array(), array('fetch' => PDO::FETCH_ASSOC));
$this->query("SET SQL_mode = :mode", array(':mode' => $sql_mode));
foreach ($result as $create) {
- $out .= "DROP VIEW IF EXISTS `". $view['name'] ."`;\n";
+ $out .= "DROP VIEW IF EXISTS `" . $view['name'] . "`;\n";
$out .= "SET sql_mode = 'ANSI';\n";
$out .= strtr($create['Create View'], "\n", " ") . ";\n";
$out .= "SET sql_mode = '$sql_mode';\n";
@@ -365,67 +383,86 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
}
/**
- * Get the sql to insert the data for a given table
+ * Get the sql to insert the data for a given table.
*/
- function _dump_table_data_sql_to_file($file, $table) {
+ public function _dump_table_data_sql_to_file($file, $table) {
+ $rows_per_query = variable_get('backup_migrate_data_rows_per_query', 1000);
$rows_per_line = variable_get('backup_migrate_data_rows_per_line', 30);
$bytes_per_line = variable_get('backup_migrate_data_bytes_per_line', 2000);
-
- $lines = 0;
- $data = $this->query("SELECT * FROM `". $table['name'] ."`", array(), array('fetch' => PDO::FETCH_ASSOC));
- $rows = $bytes = 0;
- // Escape backslashes, PHP code, special chars
+ if (variable_get('backup_migrate_verbose')) {
+ _backup_migrate_message('Table: %table', array('%table' => $table['name']), 'success');
+ }
+
+ // Escape backslashes, PHP code, special chars.
$search = array('\\', "'", "\x00", "\x0a", "\x0d", "\x1a");
$replace = array('\\\\', "''", '\0', '\n', '\r', '\Z');
-
- $line = array();
- foreach ($data as $row) {
- // DB Escape the values.
- $items = array();
- foreach ($row as $key => $value) {
- $items[] = is_null($value) ? "null" : "'". str_replace($search, $replace, $value) ."'";
+
+ $lines = 0;
+ $from = 0;
+ $args = array('fetch' => PDO::FETCH_ASSOC);
+ while ($data = $this->query("SELECT * FROM `" . $table['name'] . "`", array(), $args, $from, $rows_per_query)) {
+ if ($data->rowCount() == 0) {
+ break;
}
-
- // If there is a row to be added.
- if ($items) {
- // Start a new line if we need to.
- if ($rows == 0) {
- $file->write("INSERT INTO `". $table['name'] ."` VALUES ");
- $bytes = $rows = 0;
+
+ $rows = $bytes = 0;
+
+ $line = array();
+ foreach ($data as $row) {
+ $from++;
+
+ // DB Escape the values.
+ $items = array();
+ foreach ($row as $key => $value) {
+ $items[] = is_null($value) ? "null" : "'" . str_replace($search, $replace, $value) . "'";
}
- // Otherwise add a comma to end the previous entry.
- else {
- $file->write(",");
- }
-
- // Write the data itself.
- $sql = implode(',', $items);
- $file->write('('. $sql .')');
- $bytes += strlen($sql);
- $rows++;
-
- // Finish the last line if we've added enough items
- if ($rows >= $rows_per_line || $bytes >= $bytes_per_line) {
- $file->write(";\n");
- $lines++;
- $bytes = $rows = 0;
+
+ // If there is a row to be added.
+ if ($items) {
+ // Start a new line if we need to.
+ if ($rows == 0) {
+ $file->write("INSERT INTO `" . $table['name'] . "` VALUES ");
+ $bytes = $rows = 0;
+ }
+ // Otherwise add a comma to end the previous entry.
+ else {
+ $file->write(",");
+ }
+
+ // Write the data itself.
+ $sql = implode(',', $items);
+ $file->write('(' . $sql . ')');
+ $bytes += strlen($sql);
+ $rows++;
+
+ // Finish the last line if we've added enough items.
+ if ($rows >= $rows_per_line || $bytes >= $bytes_per_line) {
+ $file->write(";\n");
+ $lines++;
+ $bytes = $rows = 0;
+ }
}
}
+
+ // Finish any unfinished insert statements.
+ if ($rows > 0) {
+ $file->write(";\n");
+ $lines++;
+ }
}
- // Finish any unfinished insert statements.
- if ($rows > 0) {
- $file->write(";\n");
- $lines++;
+
+ if (variable_get('backup_migrate_verbose')) {
+ _backup_migrate_message('Peak memory usage: %mem', array('%mem' => backup_migrate_get_peak_memory_usage() . 'MB'), 'success');
}
-
+
return $lines;
}
/**
* Get the db connection for the specified db.
*/
- function _get_db_connection() {
+ public function _get_db_connection() {
if (!$this->connection) {
$this->connection = parent::_get_db_connection();
// Set the sql mode because the default is ANSI,TRADITIONAL which is not aware of collation or storage engine.
@@ -435,11 +472,34 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
}
/**
- * Run a db query on this destination's db.
+ * Run a query on this destination's database using Drupal's MySQL engine.
+ *
+ * @param string $query
+ * The query string.
+ * @param array $args
+ * Arguments for the query.
+ * @param array $options
+ * Options to pass to the query.
+ * @param int|null $from
+ * The starting point for the query; when passed will perform a queryRange()
+ * method instead of a regular query().
+ * @param int|null $count
+ * The number of records to obtain from this query. Will be ignored if the
+ * $from argument is empty.
+ *
+ * @see DatabaseConnection_mysql::query()
+ * @see DatabaseConnection_mysql::queryRange()
*/
- function query($query, $args = array(), $options = array()) {
+ public function query($query, array $args = array(), array $options = array(), $from = NULL, $count = NULL) {
if ($conn = $this->_get_db_connection()) {
- return $conn->query($query, $args, $options);
+ // If no $from is passed in, just do a basic query.
+ if (is_null($from)) {
+ return $conn->query($query, $args, $options);
+ }
+ // The $from variable was passed in, so do a ranged query.
+ else {
+ return $conn->queryRange($query, $from, $count, $args, $options);
+ }
}
}
@@ -447,7 +507,7 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
* The header for the top of the sql dump file. These commands set the connection
* character encoding to help prevent encoding conversion issues.
*/
- function _get_sql_file_header() {
+ public function _get_sql_file_header() {
return "/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
@@ -459,11 +519,11 @@ SET NAMES utf8;
";
}
-
+
/**
* The footer of the sql dump file.
*/
- function _get_sql_file_footer() {
+ public function _get_sql_file_footer() {
return "
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -474,4 +534,5 @@ SET NAMES utf8;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
";
}
+
}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.email.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.email.inc
index c7d426d..192d8cc 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.email.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.email.inc
@@ -1,6 +1,5 @@
filepath());
$max = variable_get('backup_migrate_max_email_size', 20971520);
if ($size > $max) {
@@ -34,14 +33,14 @@ class backup_migrate_destination_email extends backup_migrate_destination {
/**
* Get the form for the settings for this filter.
*/
- function edit_form() {
+ public function edit_form() {
$form = parent::edit_form();
$form['location'] = array(
"#type" => "textfield",
"#title" => t("Email Address"),
"#default_value" => $this->get_location(),
"#required" => TRUE,
- "#description" => t('Enter the email address to send the backup files to. Make sure the email sever can handle large file attachments'),
+ "#description" => t('Enter the email address to send the backup files to. Make sure the email server can handle large file attachments'),
);
return $form;
}
@@ -49,11 +48,12 @@ class backup_migrate_destination_email extends backup_migrate_destination {
/**
* Validate the configuration form. Make sure the email address is valid.
*/
- function settings_form_validate($values) {
+ public function settings_form_validate($values) {
if (!valid_email_address($values['location'])) {
form_set_error('[location]', t('The e-mail address %mail is not valid.', array('%mail' => $form_state['values']['location'])));
}
}
+
}
/**
@@ -72,28 +72,30 @@ class backup_migrate_destination_email extends backup_migrate_destination {
* filename and "filename" which is just the filename.
*/
function _backup_migrate_destination_email_mail_backup($attachment, $to) {
- // Send mail
+ // Send mail.
$attach = fread(fopen($attachment->path, "r"), filesize($attachment->path));
$mail = new mime_mail();
$mail->from = variable_get('site_mail', ini_get('sendmail_from'));
- $mail->headers = 'Errors-To: [EMAIL='. $mail->from .']'. $mail->from .'[/EMAIL]';
+ $mail->headers = 'Errors-To: [EMAIL=' . $mail->from . ']' . $mail->from . '[/EMAIL]';
$mail->to = $to;
$mail->subject = t('Database backup from !site: !file', array('!site' => variable_get('site_name', 'drupal'), '!file' => $attachment->filename));
- $mail->body = t('Database backup attached.') ."\n\n";
+ $mail->body = t('Database backup attached.') . "\n\n";
$mail->add_attachment("$attach", $attachment->filename, "Content-Transfer-Encoding: base64 /9j/4AAQSkZJRgABAgEASABIAAD/7QT+UGhvdG9zaG", NULL, TRUE);
$mail->send();
}
-
+/**
+ *
+ */
class mime_mail {
- var $parts;
- var $to;
- var $from;
- var $headers;
- var $subject;
- var $body;
+ public $parts;
+ public $to;
+ public $from;
+ public $headers;
+ public $subject;
+ public $body;
- function mime_mail() {
+ public function __construct() {
$this->parts = array();
$this->to = "";
$this->from = "";
@@ -102,7 +104,7 @@ class mime_mail {
$this->body = "";
}
- function add_attachment($message, $name = "", $ctype = "application/octet-stream", $encode = NULL, $attach = FALSE) {
+ public function add_attachment($message, $name = "", $ctype = "application/octet-stream", $encode = NULL, $attach = FALSE) {
$this->parts[] = array(
"ctype" => $ctype,
"message" => $message,
@@ -112,29 +114,36 @@ class mime_mail {
);
}
- function build_message($part) {
+ public function build_message($part) {
$message = $part["message"];
$message = chunk_split(base64_encode($message));
$encoding = "base64";
$disposition = $part['attach'] ? "Content-Disposition: attachment; filename=$part[name]\n" : '';
- return "Content-Type: ". $part["ctype"] . ($part["name"] ? "; name = \"". $part["name"] ."\"" : "") ."\nContent-Transfer-Encoding: $encoding\n$disposition\n$message\n";
+ return "Content-Type: " . $part["ctype"] . ($part["name"] ? "; name = \"" . $part["name"] . "\"" : "") . "\nContent-Transfer-Encoding: $encoding\n$disposition\n$message\n";
}
- function build_multipart() {
- $boundary = "b". md5(uniqid(time()));
+ public function build_multipart() {
+ $boundary = "b" . md5(uniqid(time()));
$multipart = "Content-Type: multipart/mixed; boundary = $boundary\n\nThis is a MIME encoded message.\n\n--$boundary";
for ($i = sizeof($this->parts) - 1; $i >= 0; $i--) {
- $multipart .= "\n". $this->build_message($this->parts[$i]) ."--$boundary";
+ $multipart .= "\n" . $this->build_message($this->parts[$i]) . "--$boundary";
}
return $multipart .= "--\n";
}
- function send() {
+ public function send() {
$mime = "";
- if (!empty($this->from)) $mime .= "From: ". $this->from ."\n";
- if (!empty($this->headers)) $mime .= $this->headers ."\n";
- if (!empty($this->body)) $this->add_attachment($this->body, "", "text/plain");
- $mime .= "MIME-Version: 1.0\n". $this->build_multipart();
+ if (!empty($this->from)) {
+ $mime .= "From: " . $this->from . "\n";
+ }
+ if (!empty($this->headers)) {
+ $mime .= $this->headers . "\n";
+ }
+ if (!empty($this->body)) {
+ $this->add_attachment($this->body, "", "text/plain");
+ }
+ $mime .= "MIME-Version: 1.0\n" . $this->build_multipart();
mail(trim($this->to), $this->subject, "", $mime);
}
+
}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.file.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.file.inc
index c6f22b5..b943d45 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.file.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.file.inc
@@ -1,6 +1,5 @@
get_location());
+ public function get_realpath() {
+ if ($realpath = drupal_realpath($this->get_location())) {
+ return $realpath;
+ }
+ return $this->get_location();
}
/**
* File save destination callback.
*/
- function _save_file($file, $settings) {
+ public function _save_file($file, $settings) {
if ($this->confirm_destination() && $dir = $this->get_location()) {
- $filepath = rtrim($dir, "/") ."/". $file->filename();
+ $filepath = rtrim($dir, "/") . "/" . $file->filename();
+
+ // Allow files to be overwritten by the filesystem.
+ $replace_method = $settings->append_timestamp == 2 ? FILE_EXISTS_REPLACE : FILE_EXISTS_RENAME;
+
// Copy the file if there are multiple destinations.
if (count($settings->get_destinations()) > 1) {
- file_unmanaged_copy($file->filepath(), $filepath);
+ file_unmanaged_copy($file->filepath(), $filepath, $replace_method);
}
// Otherwise we can move it and save a delete.
else {
- file_unmanaged_move($file->filepath(), $filepath);
+ file_unmanaged_move($file->filepath(), $filepath, $replace_method);
}
// chmod, chown and chgrp the file if needed.
@@ -59,14 +64,14 @@ class backup_migrate_destination_files extends backup_migrate_destination {
/**
* Determine if we can read the given file.
*/
- function can_read_file($file_id) {
+ public function can_read_file($file_id) {
return $this->op('restore') && is_readable($this->get_filepath($file_id));
}
/**
* File load destination callback.
*/
- function load_file($file_id) {
+ public function load_file($file_id) {
$filepath = $this->get_filepath($file_id);
if (file_exists($filepath)) {
backup_migrate_include('files');
@@ -77,7 +82,7 @@ class backup_migrate_destination_files extends backup_migrate_destination {
/**
* Get the file object for the given file.
*/
- function get_file($file_id) {
+ public function get_file($file_id) {
$files = $this->list_files();
if (isset($files[$file_id])) {
isset($files[$file_id]);
@@ -88,15 +93,15 @@ class backup_migrate_destination_files extends backup_migrate_destination {
/**
* File list destination callback.
*/
- function _list_files() {
+ public function _list_files() {
$files = array();
if ($dir = $this->get_realpath()) {
if ($handle = @opendir($dir)) {
backup_migrate_include('files');
while (FALSE !== ($file = readdir($handle))) {
if (substr($file, 0, 1) !== '.') {
- $filepath = $dir ."/". $file;
- $files[$file] = new backup_file(array('filepath' => $filepath));
+ $filepath = $dir . "/" . $file;
+ $files[$file] = new backup_file(array('filepath' => $filepath));
}
}
}
@@ -107,7 +112,7 @@ class backup_migrate_destination_files extends backup_migrate_destination {
/**
* File delete destination callback.
*/
- function _delete_file($file_id) {
+ public function _delete_file($file_id) {
$filepath = $this->get_filepath($file_id);
file_unmanaged_delete($filepath);
}
@@ -115,9 +120,9 @@ class backup_migrate_destination_files extends backup_migrate_destination {
/**
* Get the filepath from the given file id.
*/
- function get_filepath($file_id) {
+ public function get_filepath($file_id) {
if ($dir = $this->get_realpath()) {
- $filepath = rtrim($dir, '/') .'/'. $file_id;
+ $filepath = rtrim($dir, '/') . '/' . $file_id;
return $filepath;
}
return FALSE;
@@ -126,7 +131,7 @@ class backup_migrate_destination_files extends backup_migrate_destination {
/**
* Get the form for the settings for the files destination.
*/
- function edit_form() {
+ public function edit_form() {
$form = parent::edit_form();
$form['location'] = array(
"#type" => "textfield",
@@ -166,7 +171,7 @@ class backup_migrate_destination_files extends backup_migrate_destination {
/**
* Validate the form for the settings for the files destination.
*/
- function edit_form_validate($form, &$form_state) {
+ public function edit_form_validate($form, &$form_state) {
$values = $form_state['values'];
if (isset($values['settings']['chmod']) && !empty($values['settings']['chmod']) && !preg_match('/0?[0-7]{3}/', $values['settings']['chmod'])) {
form_set_error('chmod', t('You must enter a valid chmod octal value (e.g. 644 or 0644) in the change mode field, or leave it blank.'));
@@ -177,7 +182,7 @@ class backup_migrate_destination_files extends backup_migrate_destination {
/**
* Submit the form for the settings for the files destination.
*/
- function edit_form_submit($form, &$form_state) {
+ public function edit_form_submit($form, &$form_state) {
// Add a 0 to the start of a 3 digit file mode to make it proper PHP encoded octal.
if (strlen($form_state['values']['settings']['chmod']) == 3) {
$form_state['values']['settings']['chmod'] = '0' . $form_state['values']['settings']['chmod'];
@@ -188,7 +193,7 @@ class backup_migrate_destination_files extends backup_migrate_destination {
/**
* Check that a destination is valid.
*/
- function confirm_destination() {
+ public function confirm_destination() {
if ($dir = $this->get_location()) {
return $this->check_dir($dir);
}
@@ -198,10 +203,10 @@ class backup_migrate_destination_files extends backup_migrate_destination {
/**
* Prepare the destination directory for the backups.
*/
- function check_dir($directory) {
+ public function check_dir($directory) {
if (!file_prepare_directory($directory, FILE_CREATE_DIRECTORY)) {
// Unable to create destination directory.
- _backup_migrate_message("Unable to create or write to the save directory '%directory'. Please check the file permissions that directory and try again.", array('%directory' => $directory), "error");
+ _backup_migrate_message("Unable to create or write to the save directory '%directory'. Please check the file permissions of that directory and try again.", array('%directory' => $directory), "error");
return FALSE;
}
@@ -216,25 +221,25 @@ class backup_migrate_destination_files extends backup_migrate_destination {
/**
* Check that a web accessible directory has been properly secured, othewise attempt to secure it.
*/
- function check_web_dir($directory) {
+ public function check_web_dir($directory) {
// Check if the file has already been tested.
- if (is_file($directory .'/tested.txt')) {
+ if (is_file($directory . '/tested.txt')) {
return $directory;
}
else {
file_create_htaccess($directory, TRUE);
-
+
// Check the user agent to make sure we're not responding to a request from drupal itself.
// That should prevent infinite loops which could be caused by poormanscron in some circumstances.
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Drupal') !== FALSE) {
return FALSE;
}
-
- // Check to see if the destination is publicly accessible
+
+ // Check to see if the destination is publicly accessible.
$test_contents = "this file should not be publicly accessible";
// Create the the text.txt file if it's not already there.
- if (!is_file($directory .'/test.txt') || file_get_contents($directory .'/test.txt') != $test_contents) {
- if ($fp = fopen($directory .'/test.txt', 'w')) {
+ if (!is_file($directory . '/test.txt') || file_get_contents($directory . '/test.txt') != $test_contents) {
+ if ($fp = fopen($directory . '/test.txt', 'w')) {
@fputs($fp, $test_contents);
fclose($fp);
}
@@ -244,16 +249,16 @@ class backup_migrate_destination_files extends backup_migrate_destination {
return FALSE;
}
}
-
+
// Attempt to read the test file via http. This may fail for other reasons,
// so it's not a bullet-proof check.
- if ($this->test_file_readable_remotely($directory .'/test.txt', $test_contents)) {
+ if ($this->test_file_readable_remotely($directory . '/test.txt', $test_contents)) {
$message = t("Security notice: Backup and Migrate will not save backup files to the server because the destination directory is publicly accessible. If you want to save files to the server, please secure the '%directory' directory", array('%directory' => $directory));
drupal_set_message($message, "error");
return FALSE;
}
// Directory tested OK, so we mark it as tested.
- if ($fp = fopen($directory .'/tested.txt', 'w')) {
+ if ($fp = fopen($directory . '/tested.txt', 'w')) {
$contents = t('The presence of this file indicates that this directory has been tested as safe to use as a destination for Backup and Migrate. If you change the permissions of this directory or change your web server settings, please delete this file so that the directory can be checked again.');
@fputs($fp, $contents);
fclose($fp);
@@ -265,7 +270,7 @@ class backup_migrate_destination_files extends backup_migrate_destination {
/**
* Check if the given directory is within the webroot and is therefore web accessible.
*/
- function dir_in_webroot($directory) {
+ public function dir_in_webroot($directory) {
$real_dir = drupal_realpath($directory);
$real_root = drupal_realpath(DRUPAL_ROOT);
if ($real_dir == $real_root || strpos($real_dir, $real_root . '/') === 0) {
@@ -274,10 +279,10 @@ class backup_migrate_destination_files extends backup_migrate_destination {
return FALSE;
}
-/**
+ /**
* Check if a file can be read remotely via http.
*/
- function test_file_readable_remotely($directory, $contents) {
+ public function test_file_readable_remotely($directory, $contents) {
$real_dir = drupal_realpath($directory);
$real_root = drupal_realpath(DRUPAL_ROOT);
if ($real_dir && $real_root) {
@@ -292,27 +297,29 @@ class backup_migrate_destination_files extends backup_migrate_destination {
}
return FALSE;
}
+
}
/**
* The manual files directory.
*/
class backup_migrate_destination_files_manual extends backup_migrate_destination_files {
- var $supported_ops = array('manual backup', 'restore', 'list files', 'configure', 'delete');
- function __construct($params = array()) {
+ public $supported_ops = array('manual backup', 'restore', 'list files', 'configure', 'delete');
+ public function __construct($params = array()) {
$dir = 'private://backup_migrate/manual';
parent::__construct($params + array('location' => $dir, 'name' => t('Manual Backups Directory')));
}
+
}
/**
* The scheduled files directory.
*/
class backup_migrate_destination_files_scheduled extends backup_migrate_destination_files {
- var $supported_ops = array('scheduled backup', 'restore', 'list files', 'configure', 'delete');
- function __construct($params = array()) {
+ public $supported_ops = array('scheduled backup', 'restore', 'list files', 'configure', 'delete');
+ public function __construct($params = array()) {
$dir = 'private://backup_migrate/scheduled';
parent::__construct($params + array('location' => $dir, 'name' => t('Scheduled Backups Directory')));
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.ftp.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.ftp.inc
index 34f24e0..2b94407 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.ftp.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.ftp.inc
@@ -11,13 +11,13 @@
* @ingroup backup_migrate_destinations
*/
class backup_migrate_destination_ftp extends backup_migrate_destination_remote {
- var $supported_ops = array('scheduled backup', 'manual backup', 'remote backup', 'restore', 'list files', 'configure', 'delete');
- var $ftp = NULL;
+ public $supported_ops = array('scheduled backup', 'manual backup', 'remote backup', 'restore', 'list files', 'configure', 'delete');
+ public $ftp = NULL;
/**
* Save to the ftp destination.
*/
- function _save_file($file, $settings) {
+ public function _save_file($file, $settings) {
$ftp = $this->ftp_object();
if (drupal_ftp_file_to_ftp($file->filepath(), $file->filename(), '.', $ftp)) {
return $file;
@@ -28,7 +28,7 @@ class backup_migrate_destination_ftp extends backup_migrate_destination_remote {
/**
* Load from the ftp destination.
*/
- function load_file($file_id) {
+ public function load_file($file_id) {
backup_migrate_include('files');
$file = new backup_file(array('filename' => $file_id));
$this->ftp_object();
@@ -41,16 +41,16 @@ class backup_migrate_destination_ftp extends backup_migrate_destination_remote {
/**
* Delete from the ftp destination.
*/
- function _delete_file($file_id) {
+ public function _delete_file($file_id) {
$this->ftp_object();
drupal_ftp_delete_file($file_id, $this->ftp);
}
- function _list_files() {
+ public function _list_files() {
backup_migrate_include('files');
$files = array();
$this->ftp_object();
- $ftp_files = (array)drupal_ftp_file_list('.', $this->ftp);
+ $ftp_files = (array) drupal_ftp_file_list('.', $this->ftp);
foreach ($ftp_files as $file) {
$files[$file['filename']] = new backup_file($file);
}
@@ -60,7 +60,7 @@ class backup_migrate_destination_ftp extends backup_migrate_destination_remote {
/**
* Get the form for the settings for this filter.
*/
- function edit_form() {
+ public function edit_form() {
$form = parent::edit_form();
$form['scheme']['#type'] = 'value';
$form['scheme']['#value'] = 'ftp';
@@ -79,15 +79,15 @@ class backup_migrate_destination_ftp extends backup_migrate_destination_remote {
return $form;
}
- function set_pasv($value) {
- $this->settings['pasv'] = (bool)$value;
+ public function set_pasv($value) {
+ $this->settings['pasv'] = (bool) $value;
}
- function get_pasv() {
+ public function get_pasv() {
return isset($this->settings['pasv']) ? $this->settings['pasv'] : FALSE;
}
- function ftp_object() {
+ public function ftp_object() {
if (!$this->ftp) {
$this->dest_url['port'] = empty($this->dest_url['port']) ? '21' : $this->dest_url['port'];
$this->dest_url['pasv'] = $this->get_pasv();
@@ -95,19 +95,18 @@ class backup_migrate_destination_ftp extends backup_migrate_destination_remote {
}
return $this->ftp;
}
+
}
// The FTP code below was taken from the ftp module by Aaron Winborn.
-
// Inspired by http://www.devarticles.com/c/a/PHP/My-FTP-Wrapper-Class-for-PHP/
// It's been drupalized, however, and most of the bugs from that example have been fixed.
// - winborn 2007-06-22 - 2007-06-28
-
define('DRUPAL_FTP_FT_DIRECTORY', 0);
define('DRUPAL_FTP_FT_FILE', 1);
/**
- * creates a new ftp object. if any elements of ftp_map are missing, they'll be filled with the server defaults.
+ * Creates a new ftp object. if any elements of ftp_map are missing, they'll be filled with the server defaults.
*/
function drupal_ftp_ftp_object($server, $port, $user, $pass, $dir, $pasv) {
$ftp = new stdClass();
@@ -123,17 +122,17 @@ function drupal_ftp_ftp_object($server, $port, $user, $pass, $dir, $pasv) {
}
/**
- * The drupal_ftp_connect function
+ * The drupal_ftp_connect function
* This function connects to an FTP server and attempts to change into the directory specified by
* the fourth parameter, $directory.
*/
function drupal_ftp_connect(&$ftp) {
- if (is_NULL($ftp)) {
+ if (is_null($ftp)) {
$ftp = drupal_ftp_ftp_object();
}
if (!$ftp->__conn && !drupal_ftp_connected($ftp)) {
- // Attempt to connect to the remote server
+ // Attempt to connect to the remote server.
$ftp->__conn = @ftp_connect($ftp->__server, $ftp->__port);
if (!$ftp->__conn) {
@@ -141,7 +140,7 @@ function drupal_ftp_connect(&$ftp) {
return FALSE;
}
- // Attempt to login to the remote server
+ // Attempt to login to the remote server.
$ftp->__login = @ftp_login($ftp->__conn, $ftp->__user, $ftp->__password);
if (!$ftp->__login) {
@@ -149,7 +148,7 @@ function drupal_ftp_connect(&$ftp) {
return FALSE;
}
- // Attempt to change into the working directory
+ // Attempt to change into the working directory.
$chdir = @ftp_chdir($ftp->__conn, $ftp->__directory);
if (!$chdir) {
@@ -157,7 +156,7 @@ function drupal_ftp_connect(&$ftp) {
return FALSE;
}
- // Set PASV - if needed
+ // Set PASV - if needed.
if ($ftp->__pasv) {
$pasv = @ftp_pasv($ftp->__conn, TRUE);
if (!$pasv) {
@@ -167,7 +166,7 @@ function drupal_ftp_connect(&$ftp) {
}
}
- // Everything worked OK, return TRUE
+ // Everything worked OK, return TRUE.
return TRUE;
}
@@ -178,38 +177,36 @@ function drupal_ftp_connect(&$ftp) {
*/
function drupal_ftp_connected(&$ftp) {
// Attempt to call the ftp_systype to see if the connect
- // to the FTP server is still alive and kicking
-
- if (is_NULL($ftp)) {
+ // to the FTP server is still alive and kicking.
+ if (is_null($ftp)) {
$ftp = drupal_ftp_ftp_object();
return FALSE;
}
if (!@ftp_systype($ftp->__conn)) {
- // The connection is dead
+ // The connection is dead.
return FALSE;
}
else {
- // The connection is still alive
+ // The connection is still alive.
return TRUE;
}
}
/**
- * This function tries to retrieve the contents of a file from the FTP server.
+ * This function tries to retrieve the contents of a file from the FTP server.
* Firstly it changes into the $directory directory, and then attempts to download the file $filename.
* The file is saved locally and its contents are returned to the caller of the function.
*/
function drupal_ftp_ftp_to_file($file, $filename, $directory, &$ftp) {
// Change into the remote directory and retrieve the content
- // of a file. Once retrieve, return this value to the caller
-
+ // of a file. Once retrieve, return this value to the caller.
if (!@drupal_ftp_connect($ftp)) {
return FALSE;
}
// We are now connected, so let's retrieve the file contents.
- // Firstly, we change into the directory
+ // Firstly, we change into the directory.
$chdir = @ftp_chdir($ftp->__conn, $directory);
if (!$chdir) {
@@ -217,7 +214,7 @@ function drupal_ftp_ftp_to_file($file, $filename, $directory, &$ftp) {
return FALSE;
}
- // We have changed into the directory, let's attempt to get the file
+ // We have changed into the directory, let's attempt to get the file.
$fp = @fopen($file, 'wb');
$get_file = @ftp_fget($ftp->__conn, $fp, $filename, FTP_BINARY);
fclose($fp);
@@ -228,7 +225,7 @@ function drupal_ftp_ftp_to_file($file, $filename, $directory, &$ftp) {
_backup_migrate_message('FTP Error: Unable to download file: @filename from @directory', array('@filename' => $filename, '@directory' => $directory), 'error');
return FALSE;
}
-
+
return TRUE;
}
@@ -241,15 +238,15 @@ function drupal_ftp_file_to_ftp($file, $ftp_filename, $ftp_directory, &$ftp) {
}
if ($source = drupal_realpath($file)) {
- // Now we can try to write to the remote file
- $complete_filename = $ftp_directory .'/'. $ftp_filename;
+ // Now we can try to write to the remote file.
+ $complete_filename = $ftp_directory . '/' . $ftp_filename;
$put_file = @ftp_put($ftp->__conn, $complete_filename, $source, FTP_BINARY);
if (!$put_file) {
_backup_migrate_message('FTP Error: Couldn\'t write to @complete_filename when trying to save file on the ftp server.', array('@complete_filename' => $complete_filename), 'error');
return FALSE;
}
- // Everything worked OK
+ // Everything worked OK.
return TRUE;
}
else {
@@ -259,19 +256,18 @@ function drupal_ftp_file_to_ftp($file, $ftp_filename, $ftp_directory, &$ftp) {
}
/**
- * The drupal_ftp_change_directory Function
+ * The drupal_ftp_change_directory Function
* This function simply changes into the $directory folder on the FTP server.
* If a connection or permission error occurs then _backup_migrate_message() will contain the error message.
*/
function drupal_ftp_change_directory($directory, &$ftp) {
// Switch to another directory on the web server. If we don't
- // have permissions then an error will occur
-
+ // have permissions then an error will occur.
if (!@drupal_ftp_connect($ftp)) {
return FALSE;
}
- // Try and change into another directory
+ // Try and change into another directory.
$chdir = ftp_chdir($ftp->__conn, $directory);
if (!$chdir) {
@@ -279,21 +275,20 @@ function drupal_ftp_change_directory($directory, &$ftp) {
return FALSE;
}
else {
- // Changing directories worked OK
+ // Changing directories worked OK.
return TRUE;
}
}
/**
- * The drupal_ftp_file_list Function
+ * The drupal_ftp_file_list Function
* This function will change into the $directory folder and get a list of files and directories contained in that folder.
* This function still needs a lot of work, but should work in most cases.
*/
function drupal_ftp_file_list($directory, &$ftp) {
// This function will attempt to change into the specified
// directory and retrieve a list of files as an associative
- // array. This list will include file name, size and date last modified
-
+ // array. This list will include file name, size and date last modified.
$file_array = array();
// Can we switch to the desired directory?
@@ -305,14 +300,14 @@ function drupal_ftp_file_list($directory, &$ftp) {
// This is slower than parsing the raw return values, but it is faster.
$file_list = ftp_nlist($ftp->__conn, $directory);
- // Save the list of files
+ // Save the list of files.
if (@is_array($file_list)) {
- // Interate through the array
+ // Interate through the array.
foreach ($file_list as $file) {
$file_array[] = array(
'filename' => $file,
- 'filesize' => ftp_size($ftp->__conn, $directory ."/". $file),
- 'filetime' => ftp_mdtm($ftp->__conn, $directory ."/". $file),
+ 'filesize' => ftp_size($ftp->__conn, $directory . "/" . $file),
+ 'filetime' => ftp_mdtm($ftp->__conn, $directory . "/" . $file),
);
}
}
@@ -321,13 +316,12 @@ function drupal_ftp_file_list($directory, &$ftp) {
}
/**
- * The drupal_ftp_create_directory Function
+ * The drupal_ftp_create_directory Function
* This function tries to make a new directory called $folder_name on the FTP server.
* If it can create the folder, then the folder is given appropriate rights with the CHMOD command.
*/
function drupal_ftp_create_directory($folder_name, &$ftp) {
- // Makes a new folder on the web server via FTP
-
+ // Makes a new folder on the web server via FTP.
if (!@drupal_ftp_connect($ftp)) {
return FALSE;
}
@@ -336,7 +330,7 @@ function drupal_ftp_create_directory($folder_name, &$ftp) {
if ($create_result == TRUE) {
// Can we change the files permissions?
- $exec_result = @ftp_site($ftp->__conn, 'chmod 0777 '. $folder_name .'/');
+ $exec_result = @ftp_site($ftp->__conn, 'chmod 0777 ' . $folder_name . '/');
if ($exec_result == TRUE) {
return TRUE;
@@ -353,11 +347,11 @@ function drupal_ftp_create_directory($folder_name, &$ftp) {
}
/**
- * The drupal_ftp_delete_file Function
+ * The drupal_ftp_delete_file Function
* This function attempts to delete a file called $filename from the FTP server.
*/
function drupal_ftp_delete_file($filename, &$ftp) {
- // Remove the specified file from the FTP server
+ // Remove the specified file from the FTP server.
if (!@drupal_ftp_connect($ftp)) {
return FALSE;
}
@@ -365,18 +359,18 @@ function drupal_ftp_delete_file($filename, &$ftp) {
$delete_result = @ftp_delete($ftp->__conn, $filename);
if ($delete_result == TRUE) {
- // The file/folder was renamed successfully
+ // The file/folder was renamed successfully.
return TRUE;
}
else {
- // Couldn't delete the selected file
+ // Couldn't delete the selected file.
_backup_migrate_message('FTP Error: Couldn\'t delete the selected file: @filename', array('@filename' => $filename), 'error');
return FALSE;
}
}
/**
- * The drupal_ftp_delete_folder Function
+ * The drupal_ftp_delete_folder Function
* This function was one of the hardest to write. It recursively deletes all files and folders from a directory called $folder_name.
*/
function drupal_ftp_delete_folder($folder_name, &$ftp) {
@@ -395,16 +389,16 @@ function drupal_ftp_delete_folder($folder_name, &$ftp) {
for ($i = 0; $i < sizeof($content); $i++) {
// If we can change into this then it's a directory.
- // If not, it's a file
+ // If not, it's a file.
if ($content[$i] != "." && $content[$i] != "..") {
if (@ftp_chdir($ftp->__conn, $content[$i])) {
- // We have a directory
+ // We have a directory.
$directories[] = $content[$i];
$dir_counter++;
@ftp_cdup($ftp->__conn);
}
else {
- // We have a file
+ // We have a file.
$files[] = $content[$i];
$file_counter++;
}
@@ -419,7 +413,7 @@ function drupal_ftp_delete_folder($folder_name, &$ftp) {
if ($directories[$j] != "." OR $directories[$j] != "..") {
$location = ftp_pwd($ftp->__conn);
drupal_ftp_delete_folder($directories[$j], $ftp);
- @ftp_cdup ($ftp->__conn);
+ @ftp_cdup($ftp->__conn);
@ftp_rmdir($ftp->__conn, $directories[$j]);
}
}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.inc
index 792e312..94bdcaa 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.inc
@@ -1,6 +1,5 @@
array(
'description' => t('Save the backup files to any directory on this server which the web-server can write to.'),
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.file.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/destinations.file.inc',
'class' => 'backup_migrate_destination_files',
'type_name' => t('Server Directory'),
'local' => TRUE,
'can_create' => TRUE,
),
'file_manual' => array(
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.file.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/destinations.file.inc',
'type_name' => t('Server Directory'),
'class' => 'backup_migrate_destination_files_manual',
),
'file_scheduled' => array(
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.file.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/destinations.file.inc',
'type_name' => t('Server Directory'),
'class' => 'backup_migrate_destination_files_scheduled',
),
@@ -46,16 +45,16 @@ function backup_migrate_backup_migrate_destination_subtypes() {
}
$out += array(
'browser_download' => array(
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.browser.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/destinations.browser.inc',
'class' => 'backup_migrate_destination_browser_download',
),
'browser_upload' => array(
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.browser.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/destinations.browser.inc',
'class' => 'backup_migrate_destination_browser_upload',
),
'nodesquirrel' => array(
- 'description' => t('Save the backup files to the NodeSquirrel.com backup service.'),
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.nodesquirrel.inc',
+ 'description' => t('Save the backup files to the NodeSquirrel backup service.', array('@link' => url('http://nodesquirrel.com'))),
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/destinations.nodesquirrel.inc',
'class' => 'backup_migrate_destination_nodesquirrel',
'type_name' => t('NodeSquirrel.com'),
'can_create' => TRUE,
@@ -63,15 +62,15 @@ function backup_migrate_backup_migrate_destination_subtypes() {
),
'ftp' => array(
'description' => t('Save the backup files to any a directory on an FTP server.'),
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.ftp.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/destinations.ftp.inc',
'class' => 'backup_migrate_destination_ftp',
'type_name' => t('FTP Directory'),
'can_create' => TRUE,
'remote' => TRUE,
),
's3' => array(
- 'description' => t('Save the backup files to a bucket on your !link.', array('!link' => l(t('Amazon S3 account'), 'http://aws.amazon.com/s3/'))),
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.s3.inc',
+ 'description' => t('Save the backup files to a bucket on your Amazon S3 account.', array('@link' => url('http://aws.amazon.com/s3/'))),
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/destinations.s3.inc',
'class' => 'backup_migrate_destination_s3',
'type_name' => t('Amazon S3 Bucket'),
'can_create' => TRUE,
@@ -80,7 +79,7 @@ function backup_migrate_backup_migrate_destination_subtypes() {
'email' => array(
'type_name' => t('Email'),
'description' => t('Send the backup as an email attachment to the specified email address.'),
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.email.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/destinations.email.inc',
'class' => 'backup_migrate_destination_email',
'can_create' => TRUE,
'remote' => TRUE,
@@ -134,7 +133,7 @@ function backup_migrate_backup_migrate_destinations() {
* 'all' - all available destinations should be returned
*/
function backup_migrate_get_destinations($op = 'all') {
- static $destinations = NULL;
+ $destinations = &drupal_static('backup_migrate_get_destinations', NULL);
// Get the list of destinations and cache them locally.
if ($destinations === NULL) {
@@ -190,7 +189,7 @@ function backup_migrate_destination_get_latest_file($destination_id) {
if ($destination = backup_migrate_get_destination($destination_id)) {
$files = $destination->list_files();
$max = 0;
- foreach ((array)$files as $file) {
+ foreach ((array) $files as $file) {
$info = $file->info();
// If there's a datestamp, it should override the filetime as it's probably more reliable.
@@ -276,7 +275,7 @@ function _backup_migrate_destination_get_file_links($destination_id, $file_id) {
* List the backup files in the given destination.
*/
function backup_migrate_ui_destination_display_files($destination_id = NULL) {
- drupal_add_css(drupal_get_path('module', 'backup_migrate') .'/backup_migrate.css');
+ drupal_add_css(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.css');
$rows = $sort = array();
if ($destination = backup_migrate_get_destination($destination_id)) {
@@ -302,7 +301,7 @@ function _backup_migrate_ui_destination_display_files($destination = NULL, $limi
// Get the fetch link.
if ($destination->cache_files && $destination->fetch_time) {
- $fetch = '
';
}
// Add the tags as a new row.
if (!empty($info['tags'])) {
- $tags = check_plain(implode(', ', (array)$info['tags']));
+ $tags = check_plain(implode(', ', (array) $info['tags']));
$description .= '
' . t('Tags:') . ' ' . $tags . '
';
}
// Add the other info.
if (!empty($info['bam_other_safe'])) {
foreach ($info['bam_other_safe'] as $label => $data) {
- $description .= '
' . $label . ' ' . $data . '
';
+ $description .= '
' . $label . ' ' . $data . '
';
}
}
@@ -508,7 +507,6 @@ function _backup_migrate_ui_destination_display_file_list_options($files, $limit
$end = $limit;
$start = 0;
-
$showing = t('Showing @start to @end of @total files.', array('@start' => $start + 1, '@end' => $end + 1, '@total' => $total));
// Limit the number of rows shown.
@@ -573,7 +571,7 @@ function backup_migrate_ui_destination_restore_file_confirm($form, &$form_state,
$form['destination_id'] = array('#type' => 'value', '#value' => $destination_id);
$form['file_id'] = array('#type' => 'value', '#value' => $file_id);
- $form = confirm_form($form, t('Are you sure you want to restore the database?'), BACKUP_MIGRATE_MENU_PATH . "/destination/list/files/". $destination_id, t('Are you sure you want to restore the database from the backup file %file_id? This will delete some or all of your data and cannot be undone. Always test your backups on a non-production server!', array('%file_id' => $file_id)), t('Restore'), t('Cancel'));
+ $form = confirm_form($form, t('Are you sure you want to restore the database?'), BACKUP_MIGRATE_MENU_PATH . "/destination/list/files/" . $destination_id, t('Are you sure you want to restore the database from the backup file %file_id? This will delete some or all of your data and cannot be undone. Always test your backups on a non-production server!', array('%file_id' => $file_id)), t('Restore'), t('Cancel'));
drupal_set_message(t('Restoring will delete some or all of your data and cannot be undone. Always test your backups on a non-production server!'), 'warning', FALSE);
$form = array_merge_recursive($form, backup_migrate_filters_settings_form(backup_migrate_filters_settings_default('restore'), 'restore'));
$form['actions']['#weight'] = 100;
@@ -582,8 +580,8 @@ function backup_migrate_ui_destination_restore_file_confirm($form, &$form_state,
if (@$form['advanced']) {
$form['advanced']['#type'] = 'fieldset';
$form['advanced']['#title'] = t('Advanced Options');
- $form['advanced']['#collapsed'] = true;
- $form['advanced']['#collapsible'] = true;
+ $form['advanced']['#collapsed'] = TRUE;
+ $form['advanced']['#collapsible'] = TRUE;
}
return $form;
@@ -598,7 +596,7 @@ function backup_migrate_ui_destination_restore_file_confirm_submit($form, &$form
if ($destination_id && $file_id) {
backup_migrate_perform_restore($destination_id, $file_id, $form_state['values']);
}
- $redir = user_access('access backup files') ? BACKUP_MIGRATE_MENU_PATH . "/destination/list/files/". $destination_id : BACKUP_MIGRATE_MENU_PATH;
+ $redir = user_access('access backup files') ? BACKUP_MIGRATE_MENU_PATH . "/destination/list/files/" . $destination_id : BACKUP_MIGRATE_MENU_PATH;
$form_state['redirect'] = $redir;
}
@@ -611,7 +609,7 @@ function backup_migrate_ui_destination_delete_file($destination_id = NULL, $file
}
_backup_migrate_message('Cannot delete the file: %file_id because it does not exist.', array('%file_id' => $file_id), 'error');
if ($destination_id && user_access('access backup files')) {
- drupal_goto(BACKUP_MIGRATE_MENU_PATH .'/destination/list/files/' . $destination_id);
+ drupal_goto(BACKUP_MIGRATE_MENU_PATH . '/destination/list/files/' . $destination_id);
}
drupal_goto(BACKUP_MIGRATE_MENU_PATH);
}
@@ -622,7 +620,7 @@ function backup_migrate_ui_destination_delete_file($destination_id = NULL, $file
function backup_migrate_ui_destination_delete_file_confirm($form, &$form_state, $destination_id, $file_id) {
$form['destination_id'] = array('#type' => 'value', '#value' => $destination_id);
$form['file_id'] = array('#type' => 'value', '#value' => $file_id);
- return confirm_form($form, t('Are you sure you want to delete the backup file?'), BACKUP_MIGRATE_MENU_PATH . '/destination/list/files/'. $destination_id, t('Are you sure you want to delete the backup file %file_id? This action cannot be undone.', array('%file_id' => $file_id)), t('Delete'), t('Cancel'));
+ return confirm_form($form, t('Are you sure you want to delete the backup file?'), BACKUP_MIGRATE_MENU_PATH . '/destination/list/files/' . $destination_id, t('Are you sure you want to delete the backup file %file_id? This action cannot be undone.', array('%file_id' => $file_id)), t('Delete'), t('Cancel'));
}
/**
@@ -635,7 +633,7 @@ function backup_migrate_ui_destination_delete_file_confirm_submit($form, &$form_
backup_migrate_destination_delete_file($destination_id, $file_id);
_backup_migrate_message('Database backup file deleted: %file_id', array('%file_id' => $file_id));
}
- $form_state['redirect'] = user_access('access backup files') ? BACKUP_MIGRATE_MENU_PATH . "/destination/list/files/". $destination_id : BACKUP_MIGRATE_MENU_PATH;
+ $form_state['redirect'] = user_access('access backup files') ? BACKUP_MIGRATE_MENU_PATH . "/destination/list/files/" . $destination_id : BACKUP_MIGRATE_MENU_PATH;
}
/* Utilities */
@@ -644,7 +642,7 @@ function backup_migrate_ui_destination_delete_file_confirm_submit($form, &$form_
* Get pulldown to select existing source options.
*/
function _backup_migrate_get_destination_pulldown($op, $destination_id = NULL, $copy_destination_id = NULL) {
- drupal_add_js(drupal_get_path('module', 'backup_migrate') .'/backup_migrate.js');
+ drupal_add_js(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.js');
$destinations = _backup_migrate_get_destination_form_item_options($op);
$form = array(
@@ -656,10 +654,10 @@ function _backup_migrate_get_destination_pulldown($op, $destination_id = NULL, $
'#title' => t('Backup Destination'),
'#options' => $destinations,
'#default_value' => $destination_id,
- //'#process' => array('_backup_migrate_process_destination_pulldown'),
+ // '#process' => array('_backup_migrate_process_destination_pulldown'),
);
if (user_access('administer backup and migrate')) {
- $form['destination_id']['#description'] = l(t("Create new destination"), BACKUP_MIGRATE_MENU_PATH . "/destination/add");
+ $form['destination_id']['#description'] = l(t('Create new destination'), BACKUP_MIGRATE_MENU_PATH . '/settings/destination/add');
}
$form['copy'] = array(
'#type' => 'checkbox',
@@ -679,8 +677,6 @@ function _backup_migrate_get_destination_pulldown($op, $destination_id = NULL, $
'#default_value' => $copy_destination_id,
);
-
-
return $form;
}
@@ -693,16 +689,16 @@ function _backup_migrate_process_destination_pulldown($element) {
'backup_migrate' => array(
'destination_selectors' => array(
$id => array(
- 'destination_selector' => $id,
+ 'destination_selector' => $id,
'copy_destination_selector' => $element['copy_destination']['copy_destination_id']['#id'],
'copy' => $element['copy']['#id'],
'labels' => array(
t('Local') => t('Save an offsite copy to'),
t('Offsite') => t('Save a local copy to'),
- )
- )
- )
- )
+ ),
+ ),
+ ),
+ ),
);
drupal_add_js($settings, 'setting');
@@ -750,7 +746,7 @@ function _backup_migrate_get_destination_form_item_options($op) {
t('Local') => $local,
t('Offsite') => $remote,
);
- }
+ }
else {
$out = $remote + $local;
}
@@ -761,25 +757,26 @@ function _backup_migrate_get_destination_form_item_options($op) {
* A base class for creating destinations.
*/
class backup_migrate_destination extends backup_migrate_location {
- var $db_table = "backup_migrate_destinations";
- var $type_name = "destination";
- var $default_values = array('settings' => array());
- var $singular = 'destination';
- var $plural = 'destinations';
- var $title_plural = 'Destinations';
- var $title_singular = 'Destination';
- var $cache_files = FALSE;
- var $fetch_time = NULL;
- var $cache_expire = 86400; // 24 hours
- var $weight = 0;
+ public $db_table = "backup_migrate_destinations";
+ public $type_name = "destination";
+ public $default_values = array('settings' => array());
+ public $singular = 'destination';
+ public $plural = 'destinations';
+ public $title_plural = 'Destinations';
+ public $title_singular = 'Destination';
+ public $cache_files = FALSE;
+ public $fetch_time = NULL;
+ public $cache_expire = 86400;
+ // 24 hours.
+ public $weight = 0;
- var $destination_type = "";
- var $supported_ops = array();
+ public $destination_type = "";
+ public $supported_ops = array();
/**
* This function is not supposed to be called. It is just here to help the po extractor out.
*/
- function strings() {
+ public function strings() {
// Help the pot extractor find these strings.
t('Destination');
t('Destinations');
@@ -790,7 +787,7 @@ class backup_migrate_destination extends backup_migrate_location {
/**
* Save the given file to the destination.
*/
- function save_file($file, $settings) {
+ public function save_file($file, $settings) {
$this->file_cache_clear();
// Save the file metadata if the destination supports it.
@@ -801,15 +798,15 @@ class backup_migrate_destination extends backup_migrate_location {
/**
* Save the given file to the destination.
*/
- function _save_file($file, $settings) {
+ public function _save_file($file, $settings) {
// This must be overriden.
return $file;
}
/**
- * Save the file metadata
+ * Save the file metadata.
*/
- function save_file_info($file, $settings) {
+ public function save_file_info($file, $settings) {
$info = $this->create_info_file($file);
// Save the info file and the actual file.
return $this->_save_file($info, $settings);
@@ -818,7 +815,7 @@ class backup_migrate_destination extends backup_migrate_location {
/**
* Load the file with the given destination specific id and return as a backup_file object.
*/
- function load_file($file_id) {
+ public function load_file($file_id) {
// This must be overriden.
return NULL;
}
@@ -826,7 +823,7 @@ class backup_migrate_destination extends backup_migrate_location {
/**
* Check if a file exists in the given destination.
*/
- function file_exists($file_id) {
+ public function file_exists($file_id) {
// Check if the file exists in the list of available files. Actual destination types may have more efficient ways of doing this.
$files = $this->list_files();
return isset($files[$file_id]);
@@ -835,7 +832,7 @@ class backup_migrate_destination extends backup_migrate_location {
/**
* List all the available files in the given destination with their destination specific id.
*/
- function list_files() {
+ public function list_files() {
$files = NULL;
if ($this->cache_files) {
$files = $this->file_cache_get();
@@ -846,6 +843,7 @@ class backup_migrate_destination extends backup_migrate_location {
if ($this->cache_files) {
$this->file_cache_set($files);
}
+ _backup_migrate_temp_files_delete();
}
$out = array();
@@ -863,22 +861,21 @@ class backup_migrate_destination extends backup_migrate_location {
/**
* List all the available files in the given destination with their destination specific id.
*/
- function count_files() {
+ public function count_files() {
return count($this->list_files());
}
-
/**
* List all the available files in the given destination with their destination specific id.
*/
- function _list_files() {
+ public function _list_files() {
return array();
}
/**
* Load up the file's metadata from the accompanying .info file if applicable.
*/
- function load_files_info($files) {
+ public function load_files_info($files) {
foreach ($files as $key => $file) {
// See if there is an info file with the same name as the backup.
if (isset($files[$key . '.info'])) {
@@ -887,7 +884,7 @@ class backup_migrate_destination extends backup_migrate_location {
// Allow the stored metadata to override the detected metadata.
unset($info['filename']);
$file->file_info = $info + $file->file_info;
- // Remove the metadata file from the list
+ // Remove the metadata file from the list.
unset($files[$key . '.info']);
}
@@ -896,14 +893,13 @@ class backup_migrate_destination extends backup_migrate_location {
$file->info_set('remote', $this->get('remote'));
}
-
return $files;
}
/**
* Create an ini file and write the meta data.
*/
- function create_info_file($file) {
+ public function create_info_file($file) {
$info = $this->_file_info_file($file);
$data = _backup_migrate_array_to_ini($file->file_info);
$info->put_contents($data);
@@ -913,7 +909,7 @@ class backup_migrate_destination extends backup_migrate_location {
/**
* Create the info file object.
*/
- function _file_info_file($file) {
+ public function _file_info_file($file) {
$info = new backup_file(array('filename' => $this->_file_info_filename($file->file_id())));
return $info;
}
@@ -921,24 +917,23 @@ class backup_migrate_destination extends backup_migrate_location {
/**
* Determine the file name of the info file for a file.
*/
- function _file_info_filename($file_id) {
+ public function _file_info_filename($file_id) {
return $file_id . '.info';
}
-
/**
* Cache the file list.
*/
- function file_cache_set($files) {
- cache_set('backup_migrate_file_list:'. $this->get_id(), $files, 'cache', time() + $this->cache_expire);
+ public function file_cache_set($files) {
+ cache_set('backup_migrate_file_list:' . $this->get_id(), $files, 'cache', time() + $this->cache_expire);
}
/**
* Retrieve the file list.
*/
- function file_cache_get() {
+ public function file_cache_get() {
backup_migrate_include('files');
- $cache = cache_get('backup_migrate_file_list:'. $this->get_id());
+ $cache = cache_get('backup_migrate_file_list:' . $this->get_id());
if (!empty($cache->data) && $cache->created > (time() - $this->cache_expire)) {
$this->fetch_time = $cache->created;
return $cache->data;
@@ -950,7 +945,7 @@ class backup_migrate_destination extends backup_migrate_location {
/**
* Retrieve the file list.
*/
- function file_cache_clear() {
+ public function file_cache_clear() {
if ($this->cache_files) {
$this->file_cache_set(NULL);
}
@@ -959,7 +954,7 @@ class backup_migrate_destination extends backup_migrate_location {
/**
* Delete the file with the given destination specific id.
*/
- function delete_file($file_id) {
+ public function delete_file($file_id) {
$this->file_cache_clear();
$this->_delete_file($file_id);
$this->_delete_file($this->_file_info_filename($file_id));
@@ -968,14 +963,14 @@ class backup_migrate_destination extends backup_migrate_location {
/**
* Delete the file with the given destination specific id.
*/
- function _delete_file($file_id) {
+ public function _delete_file($file_id) {
// This must be overriden.
}
/**
* Get the edit form for the item.
*/
- function edit_form() {
+ public function edit_form() {
if (get_class($this) !== 'backup_migrate_destination') {
$form = parent::edit_form();
$form['subtype'] = array(
@@ -990,17 +985,17 @@ class backup_migrate_destination extends backup_migrate_location {
'title' => t('Offsite Destinations'),
'description' => t('For the highest level of protection, set up an offsite backup destination in a location separate from your website.'),
'items' => array(),
- ),
+ ),
'local' => array(
'title' => t('Local Destinations'),
'description' => t('Local backups are quick and convenient but do not provide the additional safety of offsite backups.'),
'items' => array(),
- ),
+ ),
'other' => array(
'title' => t('Other Destinations'),
'description' => t('These destinations have not been classified because they were created for Backup and Migrate version 2. They may not work correctly with this version.'),
'items' => array(),
- ),
+ ),
);
@@ -1009,8 +1004,8 @@ class backup_migrate_destination extends backup_migrate_location {
foreach ($types as $key => $type) {
if (@$type['can_create']) {
$type_url_str = str_replace('_', '-', $key);
- $out = '
'. l($type['type_name'], $path . "/add/$type_url_str", array('attributes' => array('title' => t('Add a new @s destination.', array('@s' => $type['type_name']))))) .'
';
- $out .= '
'. filter_xss_admin($type['description']) .'
';
+ $out = '
' . l($type['type_name'], $path . "/add/$type_url_str", array('attributes' => array('title' => t('Add a new @s destination.', array('@s' => $type['type_name']))))) . '
';
+ $out .= '
' . filter_xss_admin($type['description']) . '
';
if (!empty($type['local'])) {
$items['local']['items'][] = $out;
@@ -1027,7 +1022,7 @@ class backup_migrate_destination extends backup_migrate_location {
$output = '
' . t('Choose the type of destination you would like to create:') . '
';
foreach ($items as $group) {
if (count($group['items'])) {
- $group['body'] = '
'. implode('', $group['items']) .'
';
+ $group['body'] = '
' . implode('', $group['items']) . '
';
$output .= theme('backup_migrate_group', $group);
}
}
@@ -1046,27 +1041,27 @@ class backup_migrate_destination extends backup_migrate_location {
/**
* Get the message to send to the user when confirming the deletion of the item.
*/
- function delete_confirm_message() {
+ public function delete_confirm_message() {
return t('Are you sure you want to delete the destination %name? Backup files already saved to this destination will not be deleted.', array('%name' => $this->get_name()));
}
/**
* Get a boolean representing if the destination is remote or local.
*/
- function get_remote() {
+ public function get_remote() {
return $this->op('remote backup');
}
/**
* Get the action links for a destination.
*/
- function get_action_links() {
+ public function get_action_links() {
$out = parent::get_action_links();
$item_id = $this->get_id();
// Don't display the download/delete/restore ops if they are not available for this destination.
if ($this->op('list files') && user_access("access backup files")) {
- $out = array('list files' => l(t("list files"), $this->get_settings_path() . '/list/files/'. $item_id)) + $out;
+ $out = array('list files' => l(t("list files"), $this->get_settings_path() . '/list/files/' . $item_id)) + $out;
}
if (!$this->op('configure') || !user_access('administer backup and migrate')) {
unset($out['edit']);
@@ -1077,7 +1072,7 @@ class backup_migrate_destination extends backup_migrate_location {
/**
* Get the action links for a file on a given destination.
*/
- function get_file_links($file_id) {
+ public function get_file_links($file_id) {
$out = array();
// Don't display the download/delete/restore ops if they are not available for this destination.
@@ -1088,13 +1083,13 @@ class backup_migrate_destination extends backup_migrate_location {
$destination_id = $this->get_id();
if ($can_read && user_access("access backup files")) {
- $out[] = l(t("download"), $path . '/downloadfile/'. $destination_id .'/'. $file_id);
+ $out[] = l(t("download"), $path . '/downloadfile/' . $destination_id . '/' . $file_id);
}
if ($can_read && user_access("restore from backup")) {
- $out[] = l(t("restore"), $path . '/list/restorefile/' . $destination_id .'/'. $file_id);
+ $out[] = l(t("restore"), $path . '/list/restorefile/' . $destination_id . '/' . $file_id);
}
if ($can_delete && user_access("delete backup files")) {
- $out[] = l(t("delete"), $path . '/list/deletefile/' . $destination_id .'/'. $file_id);
+ $out[] = l(t("delete"), $path . '/list/deletefile/' . $destination_id . '/' . $file_id);
}
return $out;
}
@@ -1102,55 +1097,55 @@ class backup_migrate_destination extends backup_migrate_location {
/**
* Determine if we can read the given file.
*/
- function can_read_file($file_id) {
+ public function can_read_file($file_id) {
return $this->op('restore');
}
/**
* Determine if we can read the given file.
*/
- function can_delete_file($file_id) {
+ public function can_delete_file($file_id) {
return $this->op('delete');
}
/**
* Get the form for the settings for this destination type.
*/
- function settings_default() {
+ public function settings_default() {
return array();
}
/**
* Get the form for the settings for this destination.
*/
- function settings_form($form) {
+ public function settings_form($form) {
return $form;
}
/**
* Validate the form for the settings for this destination.
*/
- function settings_form_validate($form_values) {
+ public function settings_form_validate($form_values) {
}
/**
* Submit the settings form. Any values returned will be saved.
*/
- function settings_form_submit($form_values) {
+ public function settings_form_submit($form_values) {
return $form_values;
}
/**
* Check that a destination is valid.
*/
- function confirm_destination() {
- return true;
+ public function confirm_destination() {
+ return TRUE;
}
/**
* Add the menu items specific to the destination type.
*/
- function get_menu_items() {
+ public function get_menu_items() {
$items = parent::get_menu_items();
$path = $this->get_settings_path();
@@ -1189,7 +1184,6 @@ class backup_migrate_destination extends backup_migrate_location {
return $items;
}
-
}
/**
@@ -1199,21 +1193,21 @@ class backup_migrate_destination_remote extends backup_migrate_destination {
/**
* The location is a URI so parse it and store the parts.
*/
- function get_location() {
+ public function get_location() {
return $this->url(FALSE);
}
/**
* The location to display is the url without the password.
*/
- function get_display_location() {
+ public function get_display_location() {
return $this->url(TRUE);
}
/**
* Return the location with the password.
*/
- function set_location($location) {
+ public function set_location($location) {
$this->location = $location;
$this->set_url($location);
}
@@ -1221,7 +1215,7 @@ class backup_migrate_destination_remote extends backup_migrate_destination {
/**
* Destination configuration callback.
*/
- function edit_form() {
+ public function edit_form() {
$form = parent::edit_form();
$form['scheme'] = array(
"#type" => "textfield",
@@ -1271,10 +1265,10 @@ class backup_migrate_destination_remote extends backup_migrate_destination {
/**
* Submit the configuration form. Glue the url together and add the old password back if a new one was not specified.
*/
- function edit_form_submit($form, &$form_state) {
+ public function edit_form_submit($form, &$form_state) {
$form_state['values']['pass'] = $form_state['values']['pass'] ? $form_state['values']['pass'] : $form_state['values']['old_password'];
$form_state['values']['location'] = $this->glue_url($form_state['values'], FALSE);
parent::edit_form_submit($form, $form_state);
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.nodesquirrel.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.nodesquirrel.inc
index c6281fb..4634bf1 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.nodesquirrel.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.nodesquirrel.inc
@@ -8,7 +8,7 @@
define('NODESQUIRREL_SECRET_KEY_PATTERN', '/^[0-9a-f]{32}\:?[0-9a-f]{32}$/');
/**
- * Check that a nodesquirel key is valid.
+ * Checks that a nodesquirel key is valid.
*/
function backup_migrate_nodesquirrel_check_secret_key($secret_key) {
if ($destination = backup_migrate_nodesquirrel_get_destination($secret_key)) {
@@ -20,7 +20,7 @@ function backup_migrate_nodesquirrel_check_secret_key($secret_key) {
}
/**
- * Get the NS destination for the given key.
+ * Gets the NS destination for the given key.
*/
function backup_migrate_nodesquirrel_get_destination($secret_key) {
if ($secret_key) {
@@ -32,9 +32,8 @@ function backup_migrate_nodesquirrel_get_destination($secret_key) {
return NULL;
}
-
/**
- * Get a helper link to activate a site and create a tree.
+ * Gets a helper link to activate a site and create a tree.
*/
function backup_migrate_nodesquirrel_get_activate_help_text() {
$activate_link = backup_migrate_nodesquirrel_get_activate_link();
@@ -42,20 +41,26 @@ function backup_migrate_nodesquirrel_get_activate_help_text() {
'#type' => 'item',
'#title' => t('Need a Secret Key?'),
'#markup' => t('Visit !nodesquirrel.', array('!nodesquirrel' => $activate_link)),
- '#description' => t('Don\'t worry if you don\'t have an account yet. You can create one when you get there.'),
+ '#description' => t("Don't worry if you don't have an account yet. You can create one when you get there."),
);
}
/**
- * Get a helper link to activate a site and create a tree.
+ * Gets a helper link to activate a site and create a tree.
*/
function backup_migrate_nodesquirrel_get_activate_link() {
- $activate_link = l('nodesquirrel.com/activate', variable_get('nodesquirrel_activate_url', 'http://manage.nodesquirrel.com/activate'), array('query' => array('url' => url('', array('absolute' => TRUE)), 'email' => variable_get('site_mail', ''), 'configure' => url($_GET['q'], array('absolute' => TRUE)))));
+ $activate_link = l('nodesquirrel.com/activate', variable_get('nodesquirrel_activate_url', 'https://manage.nodesquirrel.com/activate'), array(
+ 'query' => array(
+ 'url' => url('', array('absolute' => TRUE)),
+ 'email' => variable_get('site_mail', ''),
+ 'configure' => url($_GET['q'], array('absolute' => TRUE)),
+ ),
+ ));
return $activate_link;
}
/**
- * Get a helper link to activate a site and create a tree.
+ * Gets a helper link to activate a site and create a tree.
*/
function backup_migrate_nodesquirrel_get_manage_link($destination) {
$url = variable_get('nodesquirrel_manage_url', 'https://manage.nodesquirrel.com') . '/backups/' . $destination->_get_destination();
@@ -63,7 +68,7 @@ function backup_migrate_nodesquirrel_get_manage_link($destination) {
}
/**
- * Get a helper link to activate a site and create a tree.
+ * Gets a helper link to activate a site and create a tree.
*/
function backup_migrate_nodesquirrel_get_plan_link() {
$url = variable_get('nodesquirrel_manage_url', 'https://manage.nodesquirrel.com') . '/plan';
@@ -71,14 +76,13 @@ function backup_migrate_nodesquirrel_get_plan_link() {
}
/**
- * Get the path to the nodesquirrel settings tab.
+ * Gets the path to the nodesquirrel settings tab.
*/
function backup_migrate_nodesquirrel_settings_path() {
$path = BACKUP_MIGRATE_MENU_PATH . '/settings/destinations/nodesquirrel/edit';
return $path;
}
-
/**
* NodeSquirrel settings page callback.
*/
@@ -108,6 +112,13 @@ function backup_migrate_nodesquirrel_credentials_settings_form($key = '', $statu
$form['nodesquirrel_credentials']['secret_key_help'] = backup_migrate_nodesquirrel_get_activate_help_text();
}
+ $form['nodesquirrel_credentials']['nodesquirrel_failover'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Connection failover by disabling SSL certification validation'),
+ '#description' => t("If normal connections to NodeSquirrel fail due incompatibility between this server's PHP installation and the destination server, use this option to disable validating the destination's SSL certificate. Note: this has security implications and should be the last option taken; it probably would be safer to update the server's PHP."),
+ '#default_value' => variable_get('nodesquirrel_failover', FALSE),
+ );
+
return $form;
}
@@ -124,8 +135,11 @@ function backup_migrate_nodesquirrel_info_form() {
$form['nodesquirrel_info']['intro'] = array(
'#type' => 'markup',
- '#markup' => t('
NodeSquirrel is the cloud backup service for Drupal built by the maintainers of Backup and Migrate. It is secure, reliable and affordable.
NodeSquirrel is a paid service and profits help support Backup and Migrate.
NodeSquirrel is the cloud backup service built by the maintainers of Backup and Migrate.
NodeSquirrel is now free for all Drupal sites, courtesy of Pantheon.
Create your free account at !signup
', array(
+ '!nodesquirrel' => l('nodesquirrel.com', 'http://www.nodesquirrel.com'),
+ '!signup' => backup_migrate_nodesquirrel_get_activate_link(),
+ )),
+ );
return $form;
}
@@ -149,7 +163,7 @@ function backup_migrate_nodesquirrel_status_form($key, $destination, $status) {
if ($key && empty($status)) {
$form['nodesquirrel_status']['status']['#markup'] = t('Your secret key does not seem to be valid. Please check that you entered it correctly or visit !ns to generate a new key.', array('!ns' => backup_migrate_nodesquirrel_get_activate_link()));
}
- else if (!empty($destination) && is_array($status)) {
+ elseif (!empty($destination) && is_array($status)) {
if (!empty($status['lifetime_backups_used']) && !empty($status['lifetime_backups']) && $status['lifetime_backups_used'] >= $status['lifetime_backups']) {
$form['nodesquirrel_status']['status']['#markup'] = t('Your !num backup trial has expired. Visit !link to continue backing up.', array('!num' => $status['lifetime_backups'], '!link' => backup_migrate_nodesquirrel_get_plan_link()));
}
@@ -163,24 +177,22 @@ function backup_migrate_nodesquirrel_status_form($key, $destination, $status) {
$form['nodesquirrel_status']['plan_name'] = array(
'#type' => 'item',
'#title' => t('Current Plan'),
- '#markup' => check_plain($status['plan_name'])
+ '#markup' => check_plain($status['plan_name']),
);
- if (isset($status['plan_id']) && strpos($status['plan_id'], 'trial') !== FALSE) {
- if (isset($status['lifetime_backups']) && isset($status['lifetime_backups_used'])) {
- $remains = $status['lifetime_backups'] - $status['lifetime_backups_used'];
- $remains = $remains > 0 ? $remains : t('none');
- $form['nodesquirrel_status']['plan_name']['#markup'] .= ' ' . t('(@remains remaining of @backups backup trial)', array('@backups' => $status['lifetime_backups'], '@remains' => $remains));
- }
+ if (!empty($status['lifetime_backups']) && isset($status['lifetime_backups_used'])) {
+ $remains = $status['lifetime_backups'] - $status['lifetime_backups_used'];
+ $remains = $remains > 0 ? $remains : t('none');
+ $form['nodesquirrel_status']['plan_name']['#markup'] .= ' ' . t('(@remains remaining of @backups backup trial)', array('@backups' => $status['lifetime_backups'], '@remains' => $remains));
+ }
- if (isset($status['lifespan']) && isset($status['age']) && $status['lifespan'] > 0) {
- $remains = ceil(($status['lifespan'] - $status['age']) / 86400);
- if ($remains <= 0) {
- $form['nodesquirrel_status']['plan_name']['#markup'] .= ' ' . t('(Your !span day trial has expired.)', array('!span' => ceil($status['lifespan'] / 86400)));
- }
- else {
- $form['nodesquirrel_status']['plan_name']['#markup'] .= ' ' . format_plural($remains, '(1 day remaining)', '(!span days remaining)', array('!span' => ceil($remains)));
- }
+ if (!empty($status['lifespan']) && isset($status['age']) && $status['lifespan'] > 0) {
+ $remains = ceil(($status['lifespan'] - $status['age']) / 86400);
+ if ($remains <= 0) {
+ $form['nodesquirrel_status']['plan_name']['#markup'] .= ' ' . t('(Your !span day trial has expired.)', array('!span' => ceil($status['lifespan'] / 86400)));
+ }
+ else {
+ $form['nodesquirrel_status']['plan_name']['#markup'] .= ' ' . format_plural($remains, '(1 day remaining)', '(!span days remaining)', array('!span' => ceil($remains)));
}
}
@@ -190,7 +202,7 @@ function backup_migrate_nodesquirrel_status_form($key, $destination, $status) {
$form['nodesquirrel_status']['backups_used'] = array(
'#type' => 'item',
'#title' => t('Number of Stored Backups'),
- '#markup' => $status['backups_used'] == 0 ? t('None') : number_format($status['backups_used'])
+ '#markup' => $status['backups_used'] == 0 ? t('None') : number_format($status['backups_used']),
);
}
@@ -198,7 +210,10 @@ function backup_migrate_nodesquirrel_status_form($key, $destination, $status) {
$form['nodesquirrel_status']['last_backup'] = array(
'#type' => 'item',
'#title' => t('Last Backup'),
- '#markup' => empty($status['last_backup']) ? t('Never') : t('!date (!ago ago)', array('!date' => format_date($status['last_backup'], 'small'), '!ago' => format_interval(time() - $status['last_backup'], 1)))
+ '#markup' => empty($status['last_backup']) ? t('Never') : t('!date (!ago ago)', array(
+ '!date' => format_date($status['last_backup'], 'small'),
+ '!ago' => format_interval(time() - $status['last_backup'], 1),
+ )),
);
}
if ($status['bytes_per_locker']) {
@@ -206,14 +221,18 @@ function backup_migrate_nodesquirrel_status_form($key, $destination, $status) {
$form['nodesquirrel_status']['space'] = array(
'#type' => 'item',
'#title' => t('Storage Space'),
- '#markup' => t('!used used of !total (!remaining remaining)', array('!used' => backup_migrate_format_size($status['bytes_used']), '!total' => backup_migrate_format_size($status['bytes_per_locker']), '!remaining' => backup_migrate_format_size(max(0, $status['bytes_per_locker'] - $status['bytes_used']))))
+ '#markup' => t('!used used of !total (!remaining remaining)', array(
+ '!used' => backup_migrate_format_size($status['bytes_used']),
+ '!total' => backup_migrate_format_size($status['bytes_per_locker']),
+ '!remaining' => backup_migrate_format_size(max(0, $status['bytes_per_locker'] - $status['bytes_used'])),
+ )),
);
}
else {
$form['nodesquirrel_status']['space'] = array(
'#type' => 'item',
'#title' => t('Total Storage Space'),
- '#markup' => t('!total', array('!total' => backup_migrate_format_size($status['bytes_per_locker'])))
+ '#markup' => t('!total', array('!total' => backup_migrate_format_size($status['bytes_per_locker']))),
);
}
}
@@ -235,21 +254,25 @@ function backup_migrate_nodesquirrel_schedule_settings_form($destination, $statu
// If the schedule has been overriden it must be edited in the schedule tab.
$schedule = backup_migrate_crud_get_item('schedule', 'nodesquirrel');
- $default = 60*60*24;
+ $default = 60 * 60 * 24;
$form = array();
$form['nodesquirrel_schedule'] = array(
'#type' => 'fieldset',
'#title' => t('Backup Schedule'),
- '#description' => t('Set up a schedule to back up your site to NodeSquirrel. You can customize this schedule or add additional schedules in the !schedule.', array('!schedule' => l(t('Schedules tab'), BACKUP_MIGRATE_MENU_PATH . '/schedule'), '!cron' => l(t('cron'), 'http://drupal.org/cron'))),
+ '#description' => t('Set up a schedule to back up your site to NodeSquirrel. You can customize this schedule or add additional schedules in the !schedule.', array(
+ '!schedule' => l(t('Schedules tab'), BACKUP_MIGRATE_MENU_PATH . '/schedule'),
+ '!cron' => l(t('cron'), 'http://drupal.org/cron'),
+ )),
);
$key = 'nodesquirrel_schedule';
$form['nodesquirrel_schedule'][$key] = array();
$defaults = array(
- 'period' => empty($schedule) ? variable_get('nodesquirrel_schedule', 60*60*24) : $schedule->get('period'),
+ 'period' => empty($schedule) ? variable_get('nodesquirrel_schedule', 60 * 60 * 24) : $schedule->get('period'),
'enabled' => empty($schedule) ? variable_get('nodesquirrel_schedule_enabled', TRUE) : $schedule->get('enabled'),
'source_id' => empty($schedule) ? variable_get('nodesquirrel_schedule_source_id', 'db') : $schedule->get('source_id'),
+ 'keep' => empty($schedule) ? variable_get('nodesquirrel_schedule_keep', BACKUP_MIGRATE_SMART_DELETE) : $schedule->get('keep'),
);
$form['nodesquirrel_schedule'][$key]['nodesquirrel_schedule_enabled'] = array(
@@ -265,9 +288,9 @@ function backup_migrate_nodesquirrel_schedule_settings_form($destination, $statu
);
$form['nodesquirrel_schedule'][$key]['settings']['nodesquirrel_schedule_source_id'] = _backup_migrate_get_source_pulldown($defaults['source_id']);
$options = array(
- (60*60) => t('Once an hour'),
- (60*60*24) => t('Once a day'),
- (60*60*24*7) => t('Once a week'),
+ (60 * 60) => t('Once an hour'),
+ (60 * 60 * 24) => t('Once a day'),
+ (60 * 60 * 24 * 7) => t('Once a week'),
);
$period = $defaults['period'];
if (!isset($options[$period])) {
@@ -279,6 +302,12 @@ function backup_migrate_nodesquirrel_schedule_settings_form($destination, $statu
'#options' => $options,
'#default_value' => $period,
);
+ $form['nodesquirrel_schedule'][$key]['settings']['nodesquirrel_schedule_keep'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Automatically delete old backups'),
+ '#return_value' => $defaults['keep'] == BACKUP_MIGRATE_KEEP_ALL ? BACKUP_MIGRATE_SMART_DELETE : $defaults['keep'],
+ '#default_value' => $defaults['keep'],
+ );
return $form;
}
@@ -292,8 +321,8 @@ function backup_migrate_nodesquirrel_settings_form($form_state) {
$key = variable_get('nodesquirrel_secret_key', '');
$status = array();
- if ($destination = backup_migrate_nodesquirrel_get_destination($key)) {
- $status = $destination->check_limits();
+ if ($destination = backup_migrate_nodesquirrel_get_destination($key)) {
+ $status = $destination->check_limits();
}
$form += backup_migrate_nodesquirrel_info_form();
@@ -304,32 +333,34 @@ function backup_migrate_nodesquirrel_settings_form($form_state) {
return system_settings_form($form);
}
-
/**
* A destination for sending database backups to the NodeSquirel backup service.
*
* @ingroup backup_migrate_destinations
*/
class backup_migrate_destination_nodesquirrel extends backup_migrate_destination {
- var $supported_ops = array('scheduled backup', 'manual backup', 'remote backup', 'restore', 'list files', 'configure', 'delete');
- var $cache_files = TRUE;
- // Don't generate a metadata file as NodeSquirrel can save metadata natively.
- var $save_metadata = FALSE;
-
+ public $supported_ops = array(
+ 'scheduled backup',
+ 'manual backup',
+ 'remote backup',
+ 'restore',
+ 'list files',
+ 'configure',
+ 'delete',
+ );
+ public $cache_files = TRUE;
/**
- * Get the destination name. Provide a default.
+ * Don't generate a metadata file as NodeSquirrel can save metadata natively.
*/
- function get_name() {
- if (empty($this->name)) {
- return t('NodeSquirrel');
- }
- return $this->name;
+ public $save_metadata = FALSE;
+ public function __construct($params = array()) {
+ parent::__construct($params + array('name' => t('NodeSquirrel')));
}
/**
- * Get the menu items for manipulating this type.
+ * Gets the menu items for manipulating this type.
*/
- function get_menu_items() {
+ public function get_menu_items() {
$items = array();
$path = BACKUP_MIGRATE_MENU_PATH . '/nodesquirrel';
$items[$path] = array(
@@ -344,9 +375,9 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
}
/**
- * Declare any mysql databases defined in the settings.php file as a possible destination.
+ * Declares any MySQL databases defined in the settings.php file as a possible destination.
*/
- function destinations() {
+ public function destinations() {
$out = array();
$out['nodesquirrel'] = backup_migrate_create_destination('nodesquirrel', array('machine_name' => 'nodesquirrel'));
if ($secret_key = variable_get('nodesquirrel_secret_key', '')) {
@@ -361,7 +392,7 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
/**
* Returns a form to be completed before saving to the destination can be complete.
*/
- function before_backup_form($settings) {
+ public function before_backup_form($settings) {
$form = array();
$key = $this->settings('secret_key');
if (empty($key)) {
@@ -372,9 +403,9 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
}
/**
- * Validate the before_backup_form form.
+ * Validates the before_backup_form form.
*/
- function before_backup_form_validate($settings, $form, $form_state) {
+ public function before_backup_form_validate($settings, $form, $form_state) {
if (isset($form_state['values']['nodesquirrel_secret_key'])) {
$key = trim($form_state['values']['nodesquirrel_secret_key']);
if ($error = $this->vaidate_key($key)) {
@@ -384,32 +415,37 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
}
/**
- * Submit the before_backup_form form.
+ * Submits the before_backup_form form.
*/
- function before_backup_form_submit($settings, $form, $form_state) {
+ public function before_backup_form_submit($settings, $form, $form_state) {
if (isset($form_state['values']['nodesquirrel_secret_key'])) {
$this->settings['secret_key'] = $form_state['values']['nodesquirrel_secret_key'];
- variable_set('nodesquirrel_secret_key', $this->settings['secret_key']);
+ variable_set('nodesquirrel_secret_key', $this->settings['secret_key']);
}
}
-
/**
- * Save to the NodeSquirrel destination.
+ * Saves to the NodeSquirrel destination.
*/
- function save_file($file, $settings) {
+ public function save_file($file, $settings) {
if ($destination = $this->_get_destination()) {
- srand((double)microtime()*1000000);
+ srand((double) microtime() * 1000000);
$filename = $file->filename();
$filesize = filesize($file->filepath());
- $ticket = $this->_xmlrpc('backups.getUploadTicket', array($destination, $filename, $filesize, $file->file_info));
+ $ticket = $this->_xmlrpc('backups.getUploadTicket', array(
+ $destination,
+ $filename,
+ $filesize,
+ $file->file_info,
+ ));
if ($ticket) {
-
+
$url = $ticket['url'];
-
- // If the ticket requires authentication add our username/password to the url.
+
+ // If the ticket requires authentication add our username/password to
+ // the url.
if (!empty($ticket['auth']) && $ticket['auth'] = 'basic') {
$parts = parse_url($ticket['url']);
list($parts['user'], $parts['pass']) = $this->get_user_pass();
@@ -420,13 +456,15 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
if ($out->code == 200) {
// Confirm the upload.
- $confirm = $this->_xmlrpc('backups.confirmUpload', array($destination, $filename, $filesize));
+ $confirm = $this->_xmlrpc('backups.confirmUpload', array(
+ $destination,
+ $filename,
+ $filesize,
+ ));
if ($confirm['success']) {
// Set a message with a link to the manage console.
- $url = variable_get('nodesquirrel_manage_url', 'http://manage.nodesquirrel.com') . '/backups/' . $this->_get_destination();
- _backup_migrate_message('Your backup has been saved to your NodeSquirrel account. View it at !account', array('!account' => l($url, $url)));
-
+ _backup_migrate_message('Your backup has been saved to your NodeSquirrel account. View it at !account', array('!account' => backup_migrate_nodesquirrel_get_manage_link($this)));
return $file;
}
else {
@@ -438,7 +476,7 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
_backup_migrate_message('The NodeSquirrel server returned the following error: %err', array('%err' => $error), 'error');
}
}
- else if ($err = xmlrpc_error()) {
+ elseif ($err = xmlrpc_error()) {
// XMLRPC errors are already handled by the server function below.
}
else {
@@ -449,9 +487,9 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
}
/**
- * Load from the NodeSquirrel destination.
+ * Loads from the NodeSquirrel destination.
*/
- function load_file($file_id) {
+ public function load_file($file_id) {
if ($destination = $this->_get_destination()) {
backup_migrate_include('files');
$file = new backup_file(array('filename' => $file_id));
@@ -459,14 +497,15 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
$ticket = $this->_xmlrpc('backups.getDownloadTicket', array($destination, $file_id));
if ($ticket && $url = $ticket['url']) {
- // If the ticket requires authentication add our username/password to the url.
+ // If the ticket requires authentication add our username/password to
+ // the url.
if (!empty($ticket['auth']) && $ticket['auth'] = 'basic') {
$parts = parse_url($ticket['url']);
$parts['user'] = @$this->dest_url['user'];
$parts['pass'] = @$this->dest_url['pass'];
$url = $this->glue_url($parts, FALSE);
}
-
+
$out = drupal_http_request($url);
if ($out->code == 200) {
@@ -483,24 +522,24 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
}
/**
- * Delete from the NodeSquirrel destination.
+ * Deletes from the NodeSquirrel destination.
*/
- function delete_file($file_id) {
+ public function delete_file($file_id) {
if ($destination = $this->_get_destination()) {
$result = $this->_xmlrpc('backups.deleteFile', array($destination, $file_id));
}
}
/**
- * List the files in the remote destination.
+ * Lists the files in the remote destination.
*/
- function _list_files() {
+ public function _list_files() {
$files = array();
backup_migrate_include('files');
if ($destination = $this->_get_destination()) {
$file_list = $this->_xmlrpc('backups.listFiles', array($destination));
- foreach ((array)$file_list as $file) {
+ foreach ((array) $file_list as $file) {
$files[$file['filename']] = new backup_file($file);
}
}
@@ -509,9 +548,9 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
}
/**
- * List the files in the remote destination.
+ * Lists the files in the remote destination.
*/
- function check_limits() {
+ public function check_limits() {
if (empty($this->limits)) {
$this->limits = $this->_xmlrpc('backups.getLimits', array($this->_get_destination()));
}
@@ -519,20 +558,20 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
}
/**
- * Check that a destination is valid.
+ * Checks that a destination is valid.
*/
- function confirm_destination() {
+ public function confirm_destination() {
return $this->check_limits();
}
/**
- * Get the form for the settings for this destination.
+ * Gets the form for the settings for this destination.
*/
- function edit_form() {
+ public function edit_form() {
$form = parent::edit_form();
- // If this is a new destination but the default NS destination has not been created yet,
- // redirect to the NS config screen.
+ // If this is a new destination but the default NS destination has not been
+ // created yet, redirect to the NS config screen.
if (!$this->get_id() && !variable_get('nodesquirrel_secret_key', '')) {
drupal_goto(BACKUP_MIGRATE_MENU_PATH . '/nodesquirrel');
}
@@ -540,7 +579,8 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
$form['settings'] = array('#tree' => TRUE);
$activate_link = backup_migrate_nodesquirrel_get_activate_link();
- // Retrieve the key from the settings or get it from the get string if this is an auto-config action.
+ // Retrieve the key from the settings or get it from the get string if this
+ // is an auto-config action.
$key = $this->settings('secret_key');
if (!empty($_GET['key']) && preg_match(NODESQUIRREL_SECRET_KEY_PATTERN, $_GET['key'])) {
$key = $_GET['key'];
@@ -563,9 +603,12 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
}
/**
- * Submit the configuration form. Glue the url together and add the old password back if a new one was not specified.
+ * Submits the configuration form.
+ *
+ * Glue the url together and add the old password back if a new one was not
+ * specified.
*/
- function edit_form_validate($form, &$form_state) {
+ public function edit_form_validate($form, &$form_state) {
$key = trim($form_state['values']['settings']['secret_key']);
if ($error = $this->vaidate_key($key)) {
form_set_error('secret_key', $error);
@@ -573,9 +616,11 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
}
/**
- * Validate a secret key. Returns error text if the key is invalid.
+ * Validates a secret key.
+ *
+ * Returns error text if the key is invalid.
*/
- function vaidate_key($key) {
+ public function vaidate_key($key) {
$error = FALSE;
if ($key) {
if (!preg_match(NODESQUIRREL_SECRET_KEY_PATTERN, $key)) {
@@ -602,33 +647,36 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
}
/**
- * Submit the configuration form. Glue the url together and add the old password back if a new one was not specified.
+ * Submits the configuration form.
+ *
+ * Glue the url together and add the old password back if a new one was not
+ * specified.
*/
- function edit_form_submit($form, &$form_state) {
+ public function edit_form_submit($form, &$form_state) {
$form_state['values']['secret_key'] = check_plain($form_state['values']['settings']['secret_key']);
parent::edit_form_submit($form, $form_state);
}
/**
- * Get the destination id or warn the user that it has not been set.
+ * Gets the destination id or warn the user that it has not been set.
*/
- function _get_destination($warn = TRUE) {
+ public function _get_destination($warn = TRUE) {
list($id, $key) = $this->get_user_pass();
return $id;
}
/**
- * Get the destination id or warn the user that it has not been set.
+ * Gets the destination id or warn the user that it has not been set.
*/
- function _get_private_key($warn = TRUE) {
+ public function _get_private_key($warn = TRUE) {
list($id, $key) = $this->get_user_pass();
return $key;
}
/**
- * Break the secret key into the public/private key (user/pass).
+ * Breaks the secret key into the public/private key (user/pass).
*/
- function get_user_pass() {
+ public function get_user_pass() {
$key = $this->settings('secret_key');
// The username is the first 32 chars.
$user = substr($key, 0, 32);
@@ -637,40 +685,57 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
return array($user, $pass);
}
- function get_display_location() {
+ public function get_display_location() {
return t('NodeSquirrel.com');
}
- function add_scheme($url) {
- return 'http://' . $url;
+ public function add_scheme($url) {
+ return 'https://' . $url;
}
/**
- * Get the form for the settings for this destination.
+ * Gets the form for the settings for this destination.
*/
- function _xmlrpc($method, $args = array()) {
+ public function _xmlrpc($method, $args = array()) {
// Retrieve the severs or read them from a stored variable.
$servers = $this->_get_endpoints();
// Do the actual call.
- return $this->__xmlrpc($method, $args, $servers);
+ return $this->_xmlrpc_request($method, $args, $servers);
}
/**
- * Get the form for the settings for this destination.
+ * Gets the form for the settings for this destination.
*/
- function __xmlrpc($method, $args, $servers, $retry = 3) {
+ public function _xmlrpc_request($method, $args, $servers, $retry = 3) {
if ($servers && --$retry > 0) {
// Add the key authentication arguments if we can.
- if ($this->_sign_request($args)) {
+ if ($this->_sign_request($args)) {
$url = reset($servers);
// Try each available server in order.
while ($url) {
-
+
$url = $this->add_scheme($url);
- $out = xmlrpc($url, array($method => $args));
-
+ $options = array();
+ // Optionally disable SSL certification validation. This may be
+ // necessary if the server's SSL certificates are out of date because
+ // and might be incompatible with PHP 5.6's OpenSSL implementation.
+ // @see http://php.net/manual/en/migration56.openssl.php
+ // @see http://php.net/manual/en/context.ssl.php#context.ssl.verify-peer
+ if (variable_get('nodesquirrel_failover', FALSE)) {
+ $opts = array(
+ 'ssl' => array(
+ 'verify_peer' => FALSE,
+ ),
+ );
+ $options = array(
+ 'context' => stream_context_create($opts),
+ );
+ }
+
+ $out = xmlrpc($url, array($method => $args), $options);
+
// Check for errors.
$err = xmlrpc_error();
if ($err && $err->is_error) {
@@ -681,28 +746,30 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
// Some sort of server error. Try the next one.
$url = next($servers);
- // If we're at the end of the line then try refetching the urls
+ // If we're at the end of the line then try refetching the urls.
if (!$url) {
$servers = $this->_get_endpoints(TRUE, $retry);
- return $this->__xmlrpc($method, $args, $servers, $retry);
+ return $this->_xmlrpc_request($method, $args, $servers, $retry);
}
- break;
+ break;
+
case '300':
- // 'Multiple Choices' means that the existing server list needs to be refreshed.
+ // 'Multiple Choices' means that the existing server list needs
+ // to be refreshed.
$servers = $this->_get_endpoints(TRUE, $retry);
- return $this->__xmlrpc($method, $args, $servers, $retry);
- break;
+ return $this->_xmlrpc_request($method, $args, $servers, $retry);
+
case '401':
case '403':
// Authentication failed.
_backup_migrate_message('Couldn\'t log in to NodeSquirrel. The server error was: %err', array('%err' => $err->message), 'error');
return FALSE;
- break;
+
default:
- // Some sort of client error. Don't try the next server because it'll probably say the same thing.
+ // Some sort of client error. Don't try the next server because
+ // it'll probably say the same thing.
_backup_migrate_message('The NodeSquirrel server returned the following error: %err', array('%err' => $err->message), 'error');
return FALSE;
- break;
}
}
// No error, return the result.
@@ -714,10 +781,10 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
}
}
- /**
- * Genrate a hash with a given secret key, timestamp and random value.
+ /**
+ * Genrates a hash with a given secret key, timestamp and random value.
*/
- function _get_hash($time, $nonce) {
+ public function _get_hash($time, $nonce) {
if ($private_key = $this->_get_private_key()) {
$message = $time . ':' . $nonce . ':' . $private_key;
// Use HMAC-SHA1 to authenticate the call.
@@ -732,13 +799,13 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
return FALSE;
}
- /**
- * Genrate a hash with a given secret key, timestamp and random value.
+ /**
+ * Genrates a hash with a given secret key, timestamp and random value.
*/
- function _sign_request(&$args) {
- $nonce = md5(mt_rand());
- $time = time();
- $hash = $this->_get_hash($time, $nonce);
+ public function _sign_request(&$args) {
+ $nonce = md5(mt_rand());
+ $time = time();
+ $hash = $this->_get_hash($time, $nonce);
if ($hash) {
array_unshift($args, $nonce);
array_unshift($args, $time);
@@ -751,16 +818,17 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
}
/**
- * Retrieve the list of servers.
+ * Retrieves the list of servers.
*/
- function _get_endpoints($refresh = FALSE, $retry = 3) {
- $servers = (array)variable_get('nodesquirrel_endpoint_urls', array());
+ public function _get_endpoints($refresh = FALSE, $retry = 3) {
+ $servers = (array) variable_get('nodesquirrel_endpoint_urls', array());
// No servers saved or a force refreshr required.
if ($refresh || empty($servers)) {
$servers = array_unique(array_merge($servers, variable_get('nodesquirrel_default_endpoint_urls', array('api.nodesquirrel.com/services/xmlrpc'))));
- // Call the get endpoints method but use the default or previous servers to avoid infinite loops.
- $new_servers = $this->__xmlrpc('backups.getEndpoints', array($this->_get_destination(), 'xmlrpc'), $servers, $retry);
+ // Call the get endpoints method but use the default or previous servers
+ // to avoid infinite loops.
+ $new_servers = $this->_xmlrpc_request('backups.getEndpoints', array($this->_get_destination(), 'xmlrpc'), $servers, $retry);
if ($new_servers) {
variable_set('nodesquirrel_endpoint_urls', $new_servers);
$servers = $new_servers;
@@ -770,131 +838,163 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
}
/**
- * Post a file via http.
+ * Posts a file via HTTP.
*
- * This looks a lot like a clone of drupal_http_request but it can post a large
- * file without reading the whole file into memory.
+ * This looks a lot like a clone of drupal_http_request() but it can post a
+ * large file without reading the whole file into memory.
*/
- function _post_file($url, $method = 'GET', $params = array(), $file = NULL, $retry = 3) {
+ public function _post_file($url, $method = 'GET', $params = array(), $file = NULL, $retry = 3) {
global $db_prefix;
-
+
$result = new stdClass();
-
+
// Parse the URL and make sure we can handle the schema.
$uri = parse_url($url);
-
+
if ($uri == FALSE) {
$result->error = 'unable to parse URL';
$result->code = -1001;
return $result;
}
-
+
if (!isset($uri['scheme'])) {
$result->error = 'missing schema';
$result->code = -1002;
return $result;
}
-
+
+ // Avoid some "undefined variable" errors.
+ $errno = $errstr = NULL;
+
switch ($uri['scheme']) {
case 'http':
case 'feed':
$port = isset($uri['port']) ? $uri['port'] : 80;
- $host = $uri['host'] . ($port != 80 ? ':'. $port : '');
+ $host = $uri['host'] . ($port != 80 ? ':' . $port : '');
$fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
break;
+
case 'https':
- // Note: Only works for PHP 4.3 compiled with OpenSSL.
+ // Note: Only works for PHP 4.3+ compiled with OpenSSL.
$port = isset($uri['port']) ? $uri['port'] : 443;
- $host = $uri['host'] . ($port != 443 ? ':'. $port : '');
- $fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20);
+ $host = $uri['host'] . ($port != 443 ? ':' . $port : '');
+ $fp = @fsockopen('ssl://' . $uri['host'], $port, $errno, $errstr, 20);
+
+ // If fsockopen() doesn't work, try again after disabling SSL.
+ // Optionally disable SSL certification validation. This may be
+ // necessary if the server's SSL certificates are out of date and/or
+ // might be incompatible with PHP 5.6's OpenSSL implementation.
+ // @see http://php.net/manual/en/migration56.openssl.php
+ // @see http://php.net/manual/en/context.ssl.php#context.ssl.verify-peer
+ if (!$fp && variable_get('nodesquirrel_failover', FALSE)) {
+ $opts = array(
+ 'ssl' => array(
+ 'verify_peer' => FALSE,
+ ),
+ );
+ $context = stream_context_create($opts);
+ $fp = stream_socket_client('ssl://' . $uri['host'] . ':' . $port, $errno, $errstr, 20, STREAM_CLIENT_CONNECT, $context);
+ }
break;
+
default:
- $result->error = 'invalid schema '. $uri['scheme'];
+ $result->error = 'invalid schema ' . $uri['scheme'];
$result->code = -1003;
return $result;
}
-
+
// Make sure the socket opened properly.
if (!$fp) {
// When a network error occurs, we use a negative number so it does not
// clash with the HTTP status codes.
$result->code = -$errno;
$result->error = trim($errstr);
-
+
// Mark that this request failed. This will trigger a check of the web
// server's ability to make outgoing HTTP requests the next time that
// requirements checking is performed.
// @see system_requirements()
variable_set('drupal_http_request_fails', TRUE);
-
+
return $result;
}
-
+
// Construct the path to act on.
$path = isset($uri['path']) ? $uri['path'] : '/';
if (isset($uri['query'])) {
- $path .= '?'. $uri['query'];
+ $path .= '?' . $uri['query'];
}
// Prepare the data payload.
- $boundary = '---------------------------'. substr(md5(rand(0,32000)),0,10);
+ $boundary = '---------------------------' . substr(md5(rand(0, 32000)), 0, 10);
$data_footer = "\r\n--$boundary--\r\n";
$data_header = '';
foreach ($params as $key => $value) {
- $data_header .="--$boundary\r\n";
- $data_header .= "Content-Disposition: form-data; name=\"".$key."\"\r\n";
- $data_header .= "\r\n".$value."\r\n";
- $data_header .="--$boundary\r\n";
+ $data_header .= "--$boundary\r\n";
+ $data_header .= "Content-Disposition: form-data; name=\"" . $key . "\"\r\n";
+ $data_header .= "\r\n" . $value . "\r\n";
+ $data_header .= "--$boundary\r\n";
}
-
+
// Add the file header to the post payload.
- $data_header .="--$boundary\r\n";
- $data_header .= "Content-Disposition: form-data; name=\"file\"; filename=\"". $file->filename() ."\"\r\n";
+ $data_header .= "--$boundary\r\n";
+ $data_header .= "Content-Disposition: form-data; name=\"file\"; filename=\"" . $file->filename() . "\"\r\n";
$data_header .= "Content-Type: application/octet-stream;\r\n";
$data_header .= "\r\n";
// Calculate the content length.
$content_length = strlen($data_header . $data_footer) + filesize($file->filepath());
- //file_get_contents($file->filepath()));
-
+ // file_get_contents($file->filepath()));
// Create HTTP request.
$defaults = array(
// RFC 2616: "non-standard ports MUST, default ports MAY be included".
- // We don't add the port to prevent from breaking rewrite rules checking the
- // host that do not take into account the port number.
+ // We don't add the port to prevent from breaking rewrite rules checking
+ // the host that do not take into account the port number.
'Host' => "Host: $host",
'Content-type' => "Content-type: multipart/form-data, boundary=$boundary",
- 'User-Agent' => 'User-Agent: NodeSquirrel Client/1.x (+http://www.nodesquirrel.com) (Drupal '. VERSION .'; Backup and Migrate 2.x)',
- 'Content-Length' => 'Content-Length: '. $content_length
+ 'User-Agent' => 'User-Agent: NodeSquirrel Client/1.x (+http://www.nodesquirrel.com) (Drupal ' . VERSION . '; Backup and Migrate 2.x)',
+ 'Content-Length' => 'Content-Length: ' . $content_length,
);
- // If the server url has a user then attempt to use basic authentication
+ // If the server url has a user then attempt to use basic authentication.
if (isset($uri['user'])) {
- $defaults['Authorization'] = 'Authorization: Basic '. base64_encode($uri['user'] . (!empty($uri['pass']) ? ":". $uri['pass'] : ''));
+ $defaults['Authorization'] = 'Authorization: Basic ' . base64_encode($uri['user'] . (!empty($uri['pass']) ? ":" . $uri['pass'] : ''));
}
- $request = $method .' '. $path ." HTTP/1.0\r\n";
+ $request = $method . ' ' . $path . " HTTP/1.0\r\n";
$request .= implode("\r\n", $defaults);
- $request .= "\r\n\r\n";
+ $request .= "\r\n\r\n";
$result->request = $request;
+ $out = FALSE;
// Write the headers and start of the headers
- fwrite($fp, $request);
- fwrite($fp, $data_header);
+ if (($fp_in = fopen($file->filepath(), 'rb')) && fwrite($fp, $request) && fwrite($fp, $data_header)) {
+ // Copy the file 1M at a time.
+ do {
+ $data = fread($fp_in, 1024 * 1024);
+ $size = strlen($data);
+ $sent = 0;
+ while ($sent < $size && ($out = fwrite($fp, substr($data, $sent)))) {
+ $sent += $out;
+ }
+ } while ($out && !feof($fp_in));
- // Copy the file 512k at a time to prevent memory issues.
- if ($fp_in = fopen($file->filepath(), 'rb')) {
- while (!feof($fp_in)) {
- fwrite($fp, fread($fp_in, 1024 * 512));
+ // Finish the write.
+ if ($out) {
+ $out = fwrite($fp, $data_footer);
}
- $success = TRUE;
}
@fclose($fp_in);
- // Finish the write.
- fwrite($fp, $data_footer);
+ // Check for errors.
+ if (!$out) {
+ watchdog('backup_migrate', 'NodeSquirrel: network write failed', NULL, WATCHDOG_ERROR);
+ $result->code = -$errno;
+ $result->error = trim($errstr);
+ return $result;
+ }
// Fetch response.
$response = '';
@@ -902,72 +1002,113 @@ class backup_migrate_destination_nodesquirrel extends backup_migrate_destination
$response .= $chunk;
}
fclose($fp);
-
- if (variable_get('debug_http_request', FALSE)) {
- drupal_debug(date('r'));
- drupal_debug($request);
- drupal_debug($response);
- }
-
+
+ if (variable_get('debug_http_request', FALSE)) {
+ drupal_debug(date('r'));
+ drupal_debug($request);
+ drupal_debug($response);
+ }
+
// Parse response.
list($split, $result->data) = explode("\r\n\r\n", $response, 2);
$split = preg_split("/\r\n|\n|\r/", $split);
-
+
list($protocol, $code, $status_message) = explode(' ', trim(array_shift($split)), 3);
$result->protocol = $protocol;
$result->status_message = $status_message;
-
+
$result->headers = array();
-
+
// Parse headers.
while ($line = trim(array_shift($split))) {
list($header, $value) = explode(':', $line, 2);
if (isset($result->headers[$header]) && $header == 'Set-Cookie') {
// RFC 2109: the Set-Cookie response header comprises the token Set-
// Cookie:, followed by a comma-separated list of one or more cookies.
- $result->headers[$header] .= ','. trim($value);
+ $result->headers[$header] .= ',' . trim($value);
}
else {
$result->headers[$header] = trim($value);
}
}
-
+
$responses = array(
- 100 => 'Continue', 101 => 'Switching Protocols',
- 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content',
- 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect',
- 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Time-out', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Large', 415 => 'Unsupported Media Type', 416 => 'Requested range not satisfiable', 417 => 'Expectation Failed',
- 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Time-out', 505 => 'HTTP Version not supported'
+ 100 => 'Continue',
+ 101 => 'Switching Protocols',
+ 200 => 'OK',
+ 201 => 'Created',
+ 202 => 'Accepted',
+ 203 => 'Non-Authoritative Information',
+ 204 => 'No Content',
+ 205 => 'Reset Content',
+ 206 => 'Partial Content',
+ 300 => 'Multiple Choices',
+ 301 => 'Moved Permanently',
+ 302 => 'Found',
+ 303 => 'See Other',
+ 304 => 'Not Modified',
+ 305 => 'Use Proxy',
+ 307 => 'Temporary Redirect',
+ 400 => 'Bad Request',
+ 401 => 'Unauthorized',
+ 402 => 'Payment Required',
+ 403 => 'Forbidden',
+ 404 => 'Not Found',
+ 405 => 'Method Not Allowed',
+ 406 => 'Not Acceptable',
+ 407 => 'Proxy Authentication Required',
+ 408 => 'Request Time-out',
+ 409 => 'Conflict',
+ 410 => 'Gone',
+ 411 => 'Length Required',
+ 412 => 'Precondition Failed',
+ 413 => 'Request Entity Too Large',
+ 414 => 'Request-URI Too Large',
+ 415 => 'Unsupported Media Type',
+ 416 => 'Requested range not satisfiable',
+ 417 => 'Expectation Failed',
+ 500 => 'Internal Server Error',
+ 501 => 'Not Implemented',
+ 502 => 'Bad Gateway',
+ 503 => 'Service Unavailable',
+ 504 => 'Gateway Time-out',
+ 505 => 'HTTP Version not supported',
);
- // RFC 2616 states that all unknown HTTP codes must be treated the same as the
- // base code in their class.
+ // RFC 2616 states that all unknown HTTP codes must be treated the same as
+ // the base code in their class.
if (!isset($responses[$code])) {
$code = floor($code / 100) * 100;
}
-
+
switch ($code) {
- case 200: // OK
- case 304: // Not modified
+ case 200:
+ // OK.
+ case 304:
+ // Not modified.
break;
- case 301: // Moved permanently
- case 302: // Moved temporarily
- case 307: // Moved temporarily
+
+ case 301:
+ // Moved permanently.
+ case 302:
+ // Moved temporarily.
+ case 307:
+ // Moved temporarily.
$location = $result->headers['Location'];
-
+
if ($retry) {
$result = drupal_http_request($result->headers['Location'], $headers, $method, $data, --$retry);
$result->redirect_code = $result->code;
}
$result->redirect_url = $location;
-
+
break;
+
default:
$result->error = $status_message;
}
-
+
$result->code = $code;
return $result;
}
}
-
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.s3.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.s3.inc
index c049806..1bbffd3 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.s3.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.s3.inc
@@ -1,6 +1,5 @@
s3_object()) {
$path = $file->filename();
if ($s3->putObject($s3->inputFile($file->filepath(), FALSE), $this->get_bucket(), $this->remote_path($file->filename()), S3::ACL_PRIVATE)) {
@@ -33,7 +31,7 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
/**
* Load from the s3 destination.
*/
- function load_file($file_id) {
+ public function load_file($file_id) {
backup_migrate_include('files');
$file = new backup_file(array('filename' => $file_id));
if ($s3 = $this->s3_object()) {
@@ -48,7 +46,7 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
/**
* Delete from the s3 destination.
*/
- function _delete_file($file_id) {
+ public function _delete_file($file_id) {
if ($s3 = $this->s3_object()) {
$s3->deleteObject($this->get_bucket(), $this->remote_path($file_id));
}
@@ -57,12 +55,12 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
/**
* List all files from the s3 destination.
*/
- function _list_files() {
+ public function _list_files() {
backup_migrate_include('files');
$files = array();
if ($s3 = $this->s3_object()) {
$s3_files = $s3->getBucket($this->get_bucket(), $this->get_subdir());
- foreach ((array)$s3_files as $id => $file) {
+ foreach ((array) $s3_files as $id => $file) {
$info = array(
'filename' => $this->local_path($file['name']),
'filesize' => $file['size'],
@@ -77,15 +75,14 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
/**
* Get the form for the settings for this filter.
*/
- function edit_form() {
+ public function edit_form() {
// Check for the library.
$this->s3_object();
$form = parent::edit_form();
$form['scheme']['#type'] = 'value';
$form['scheme']['#value'] = 'https';
- $form['host']['#type'] = 'value';
- $form['host']['#value'] = 's3.amazonaws.com';
+ $form['host']['#default_value'] = @$this->dest_url['host'] ? $this->dest_url['host'] : 's3.amazonaws.com';
$form['path']['#title'] = 'S3 Bucket';
$form['path']['#default_value'] = $this->get_bucket();
@@ -98,7 +95,7 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
'#type' => 'textfield',
'#title' => t('Subdirectory'),
'#default_value' => $this->get_subdir(),
- '#weight' => 25
+ '#weight' => 25,
);
$form['settings']['#weight'] = 50;
@@ -108,11 +105,10 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
/**
* Submit the form for the settings for the s3 destination.
*/
- function edit_form_submit($form, &$form_state) {
+ public function edit_form_submit($form, &$form_state) {
// Append the subdir onto the path.
-
if (!empty($form_state['values']['subdir'])) {
- $form_state['values']['path'] .= '/'. trim($form_state['values']['subdir'], '/');
+ $form_state['values']['path'] .= '/' . trim($form_state['values']['subdir'], '/');
}
parent::edit_form_submit($form, $form_state);
}
@@ -120,9 +116,9 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
/**
* Generate a filepath with the correct prefix.
*/
- function remote_path($path) {
+ public function remote_path($path) {
if ($subdir = $this->get_subdir()) {
- $path = $subdir .'/'. $path;
+ $path = $subdir . '/' . $path;
}
return $path;
}
@@ -130,9 +126,9 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
/**
* Generate a filepath with the correct prefix.
*/
- function local_path($path) {
+ public function local_path($path) {
if ($subdir = $this->get_subdir()) {
- $path = str_replace($subdir .'/', '', $path);
+ $path = str_replace($subdir . '/', '', $path);
}
return $path;
}
@@ -140,7 +136,7 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
/**
* Get the bucket which is the first part of the path.
*/
- function get_bucket() {
+ public function get_bucket() {
$parts = explode('/', @$this->dest_url['path']);
return $parts[0];
}
@@ -148,7 +144,7 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
/**
* Get the bucket which is the first part of the path.
*/
- function get_subdir() {
+ public function get_subdir() {
// Support the older style of subdir saving.
if ($subdir = $this->settings('subdir')) {
return $subdir;
@@ -158,7 +154,7 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
return implode('/', array_filter($parts));
}
- function s3_object() {
+ public function s3_object() {
// Try to use libraries module if available to find the path.
if (function_exists('libraries_get_path')) {
$library_paths[] = libraries_get_path('s3-php5-curl');
@@ -169,11 +165,16 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
$library_paths[] = drupal_get_path('module', 'backup_migrate') . '/includes/s3-php5-curl';
$library_paths[] = drupal_get_path('module', 'backup_migrate') . '/includes';
- foreach($library_paths as $path) {
+ foreach ($library_paths as $path) {
if (file_exists($path . '/S3.php')) {
require_once $path . '/S3.php';
if (!$this->s3 && !empty($this->dest_url['user'])) {
- $this->s3 = new S3($this->dest_url['user'], $this->dest_url['pass']);
+ // The hostname can be overridden.
+ $host = 's3.amazonaws.com';
+ if (isset($this->dest_url['host'])) {
+ $host = $this->dest_url['host'];
+ }
+ $this->s3 = new S3($this->dest_url['user'], $this->dest_url['pass'], FALSE, $host);
}
return $this->s3;
}
@@ -181,4 +182,5 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
drupal_set_message(t('Due to drupal.org code hosting policies, the S3 library needed to use an S3 destination is no longer distributed with this module. You must download the library from !link and place it in one of these locations: %locations.', array('%locations' => implode(', ', $library_paths), '!link' => l('http://undesigned.org.za/2007/10/22/amazon-s3-php-class', 'http://undesigned.org.za/2007/10/22/amazon-s3-php-class'))), 'error', FALSE);
return NULL;
}
+
}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/files.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/files.inc
index 8931189..cb234b1 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/files.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/files.inc
@@ -1,6 +1,5 @@
filename;
- // Replace any tokens
+ // Replace any tokens.
if (module_exists('token') && function_exists('token_replace')) {
$filename = token_replace($filename);
}
- // Remove illegal characters
+ // Remove illegal characters.
$filename = _backup_migrate_clean_filename($filename);
// Generate a timestamp if needed.
$timestamp = '';
- if ($settings->append_timestamp && $settings->timestamp_format) {
+ if ($settings->append_timestamp == 1 && $settings->timestamp_format) {
$timestamp = format_date(time(), 'custom', $settings->timestamp_format);
}
@@ -178,7 +179,8 @@ function _backup_migrate_default_filename() {
return '[site:name]';
}
else {
- // Cleaning the string isn't strictly necessary but it looks better in the settings field.
+ // Cleaning the string isn't strictly necessary but it looks better in the
+ // settings field.
return _backup_migrate_clean_filename(variable_get('site_name', "backup_migrate"));
}
}
@@ -203,17 +205,17 @@ function _backup_migrate_file_dispose_buffer($buffer) {
* A backup file which allows for saving to and reading from the server.
*/
class backup_file {
- var $file_info = array();
- var $type = array();
- var $ext = array();
- var $path = "";
- var $name = "";
- var $handle = NULL;
+ public $file_info = array();
+ public $type = array();
+ public $ext = array();
+ public $path = "";
+ public $name = "";
+ public $handle = NULL;
/**
* Construct a file object given a file path, or create a temp file for writing.
*/
- function backup_file($params = array()) {
+ public function __construct($params = array()) {
if (isset($params['filepath']) && file_exists($params['filepath'])) {
$this->set_filepath($params['filepath']);
}
@@ -226,7 +228,7 @@ class backup_file {
/**
* Get the file_id if the file has been saved to a destination.
*/
- function file_id() {
+ public function file_id() {
// The default file_id is the filename. Destinations can override the file_id if needed.
return isset($this->file_info['file_id']) ? $this->file_info['file_id'] : $this->filename();
}
@@ -234,14 +236,17 @@ class backup_file {
/**
* Get the current filepath.
*/
- function filepath() {
- return drupal_realpath($this->path);
+ public function filepath() {
+ if ($filepath = drupal_realpath($this->path)) {
+ return $filepath;
+ }
+ return $this->path;
}
/**
* Get the final filename.
*/
- function filename($name = NULL) {
+ public function filename($name = NULL) {
if ($name) {
$this->name = $name;
}
@@ -253,11 +258,11 @@ class backup_file {
/**
* Set the current filepath.
*/
- function set_filepath($path) {
+ public function set_filepath($path) {
$this->path = $path;
$params = array(
'filename' => basename($path),
- 'file_id' => basename($path)
+ 'file_id' => basename($path),
);
if (file_exists($path)) {
$params['filesize'] = filesize($path);
@@ -269,56 +274,55 @@ class backup_file {
/**
* Get one or all pieces of info for the file.
*/
- function info($key = NULL) {
+ public function info($key = NULL) {
if ($key) {
return @$this->file_info[$key];
}
return $this->file_info;
}
-
/**
* Get one or all pieces of info for the file.
*/
- function info_set($key, $value) {
+ public function info_set($key, $value) {
$this->file_info[$key] = $value;
}
/**
* Get the file extension.
*/
- function extension() {
+ public function extension() {
return implode(".", $this->ext);
}
/**
* Get the file type.
*/
- function type() {
+ public function type() {
return $this->type;
}
/**
* Get the file mimetype.
*/
- function mimetype() {
+ public function mimetype() {
return @$this->type['filemime'] ? $this->type['filemime'] : 'application/octet-stream';
}
/**
* Get the file mimetype.
*/
- function type_id() {
+ public function type_id() {
return @$this->type['id'];
}
- function filesize() {
+ public function filesize() {
if (empty($this->file_info['filesize'])) {
$this->calculate_filesize();
}
return $this->file_info['filesize'];
}
- function calculate_filesize() {
+ public function calculate_filesize() {
$this->file_info['filesize'] = '';
if (!empty($this->path) && file_exists($this->path)) {
$this->file_info['filesize'] = filesize($this->path);
@@ -328,28 +332,28 @@ class backup_file {
/**
* Can this file be used to backup to.
*/
- function can_backup() {
+ public function can_backup() {
return @$this->type['backup'];
}
/**
* Can this file be used to restore to.
*/
- function can_restore() {
+ public function can_restore() {
return @$this->type['restore'];
}
/**
* Can this file be used to restore to.
*/
- function is_recognized_type() {
+ public function is_recognized_type() {
return @$this->type['restore'] || @$this->type['backup'];
}
/**
* Open a file for reading or writing.
*/
- function open($write = FALSE, $binary = FALSE) {
+ public function open($write = FALSE, $binary = FALSE) {
if (!$this->handle) {
$path = $this->filepath();
@@ -374,7 +378,7 @@ class backup_file {
/**
* Close a file when we're done reading/writing.
*/
- function close() {
+ public function close() {
fclose($this->handle);
$this->handle = NULL;
}
@@ -382,7 +386,7 @@ class backup_file {
/**
* Write a line to the file.
*/
- function write($data) {
+ public function write($data) {
if (!$this->handle) {
$this->handle = $this->open(TRUE);
}
@@ -394,7 +398,7 @@ class backup_file {
/**
* Read a line from the file.
*/
- function read($size = NULL) {
+ public function read($size = NULL) {
if (!$this->handle) {
$this->handle = $this->open();
}
@@ -407,14 +411,14 @@ class backup_file {
/**
* Write data to the file.
*/
- function put_contents($data) {
+ public function put_contents($data) {
file_put_contents($this->filepath(), $data);
}
/**
* Read data from the file.
*/
- function get_contents() {
+ public function get_contents() {
return file_get_contents($this->filepath());
}
@@ -422,10 +426,10 @@ class backup_file {
* Transfer file using http to client. Similar to the built in file_transfer,
* but it calls module_invoke_all('exit') so that temp files can be deleted.
*/
- function transfer() {
+ public function transfer() {
$headers = array(
array('key' => 'Content-Type', 'value' => $this->mimetype()),
- array('key' => 'Content-Disposition', 'value' => 'attachment; filename="'. $this->filename() .'"'),
+ array('key' => 'Content-Disposition', 'value' => 'attachment; filename="' . $this->filename() . '"'),
);
// In some circumstances, web-servers will double compress gzipped files.
// This may help aleviate that issue by disabling mod-deflate.
@@ -470,7 +474,7 @@ class backup_file {
/**
* Push a file extension onto the file and return the previous file path.
*/
- function push_type($extension) {
+ public function push_type($extension) {
$types = _backup_migrate_filetypes();
if ($type = @$types[$extension]) {
$this->push_filetype($type);
@@ -484,7 +488,7 @@ class backup_file {
/**
* Push a file extension onto the file and return the previous file path.
*/
- function pop_type() {
+ public function pop_type() {
$out = new backup_file(array('filepath' => $this->filepath()));
$this->pop_filetype();
$this->temporary_file();
@@ -494,7 +498,7 @@ class backup_file {
/**
* Set the current file type.
*/
- function set_filetype($type) {
+ public function set_filetype($type) {
$this->type = $type;
$this->ext = array($type['extension']);
}
@@ -502,7 +506,7 @@ class backup_file {
/**
* Set the current file type.
*/
- function push_filetype($type) {
+ public function push_filetype($type) {
$this->ext[] = $type['extension'];
$this->type = $type;
}
@@ -510,7 +514,7 @@ class backup_file {
/**
* Pop the current file type.
*/
- function pop_filetype() {
+ public function pop_filetype() {
array_pop($this->ext);
$this->detect_filetype_from_extension();
}
@@ -518,7 +522,7 @@ class backup_file {
/**
* Set the file info.
*/
- function set_file_info($file_info) {
+ public function set_file_info($file_info) {
$this->file_info = $file_info;
$this->ext = explode('.', @$this->file_info['filename']);
@@ -533,7 +537,7 @@ class backup_file {
/**
* Get the filetype info of the given file, or false if the file is not a valid type.
*/
- function detect_filetype_from_extension() {
+ public function detect_filetype_from_extension() {
$ext = end($this->ext);
$this->type = array();
$types = _backup_migrate_filetypes();
@@ -548,17 +552,17 @@ class backup_file {
/**
* Get a temporary file name with path.
*/
- function temporary_file() {
+ public function temporary_file() {
$file = drupal_tempnam('temporary://', 'backup_migrate_');
// Add the version without the extension. The tempnam function creates this for us.
backup_migrate_temp_files_add($file);
if ($this->extension()) {
- $file .= '.'. $this->extension();
+ $file .= '.' . $this->extension();
// Add the version with the extension. This is the one we will actually use.
backup_migrate_temp_files_add($file);
}
$this->path = $file;
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.backup_restore.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.backup_restore.inc
index cf80b59..47e4955 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.backup_restore.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.backup_restore.inc
@@ -1,9 +1,10 @@
0, 'restore' => 0);
+ public $op_weights = array('backup' => 0, 'restore' => 0);
/**
* Get the default destinations for this filter.
*/
- function destinations() {
+ public function destinations() {
$out = array();
foreach ($this->_get_destination_types() as $destination) {
if (method_exists($destination, 'destinations')) {
@@ -30,7 +31,7 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
/**
* Get the default sources for this filter.
*/
- function sources() {
+ public function sources() {
$out = array();
foreach ($this->_get_source_types() as $type) {
if (method_exists($type, 'sources')) {
@@ -43,7 +44,7 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
/**
* Get the default backup settings for this filter.
*/
- function backup_settings_default() {
+ public function backup_settings_default() {
backup_migrate_include('sources');
$out = array();
foreach (backup_migrate_get_sources() as $source) {
@@ -55,7 +56,7 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
/**
* Get the form for the settings for this filter.
*/
- function backup_settings_form_validate($form, &$form_state) {
+ public function backup_settings_form_validate($form, &$form_state) {
foreach ($this->_get_destination_types() as $destination) {
$destination->backup_settings_form_validate($form, $form_state);
}
@@ -64,7 +65,7 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
/**
* Submit the settings form. Any values returned will be saved.
*/
- function backup_settings_form_submit($form, &$form_state) {
+ public function backup_settings_form_submit($form, &$form_state) {
foreach ($this->_get_destination_types() as $destination) {
$destination->backup_settings_form_submit($form, $form_state);
}
@@ -73,7 +74,7 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
/**
* Get the default restore settings for this filter.
*/
- function restore_settings_default() {
+ public function restore_settings_default() {
$out = array();
foreach ($this->_get_destination_types() as $destination) {
$out += $destination->restore_settings_default();
@@ -84,13 +85,15 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
/**
* Get the form for the backup settings for this filter.
*/
- function backup_settings_form($settings) {
+ public function backup_settings_form($settings) {
backup_migrate_include('sources');
- $out = array('sources' => array(
- '#tree' => TRUE,
- ));
- foreach (backup_migrate_get_sources() as $source) {
- $source_settings = (array)(@$settings['sources'][$source->get_id()]) + $settings;
+ $out = array(
+ 'sources' => array(
+ '#tree' => TRUE,
+ ),
+ );
+ foreach (backup_migrate_get_sources() as $source) {
+ $source_settings = (array) (@$settings['sources'][$source->get_id()]) + $settings;
if ($form = $source->backup_settings_form($source_settings)) {
$out['sources'][$source->get_id()] = array(
'#type' => 'fieldset',
@@ -108,7 +111,7 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
/**
* Get the form for the restore settings for this filter.
*/
- function restore_settings_form($settings) {
+ public function restore_settings_form($settings) {
$form = array();
foreach ($this->_get_destination_types() as $destination) {
$destination->restore_settings_form($form, $settings);
@@ -119,7 +122,7 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
/**
* Get the before-backup form for the active sources and destinations.
*/
- function before_action_form($op, $settings) {
+ public function before_action_form($op, $settings) {
$form = array();
$method = 'before_' . $op . '_form';
if ($source = $settings->get_source()) {
@@ -138,7 +141,7 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
/**
* Get the before-backup form for the active sources and destinations.
*/
- function before_action_form_validate($op, $settings, $form, $form_state) {
+ public function before_action_form_validate($op, $settings, $form, $form_state) {
$method = 'before_' . $op . '_form_validate';
foreach ($settings->get_all_locations() as $location) {
if (method_exists($location, $method)) {
@@ -150,7 +153,7 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
/**
* Get the before-backup form for the active sources and destinations.
*/
- function before_action_form_submit($op, $settings, $form, $form_state) {
+ public function before_action_form_submit($op, $settings, $form, $form_state) {
$method = 'before_' . $op . '_form_submit';
foreach ($settings->get_all_locations() as $location) {
if (method_exists($location, $method)) {
@@ -162,7 +165,7 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
/**
* Get the file types supported by this destination.
*/
- function file_types() {
+ public function file_types() {
$types = array();
foreach ($this->_get_destination_types() as $destination) {
$types += $destination->file_types();
@@ -176,10 +179,10 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
/**
* Backup the data from the source specified in the settings.
*/
- function backup($file, $settings) {
+ public function backup($file, $settings) {
if ($source = $settings->get_source()) {
if (!empty($settings->filters['sources'][$source->get_id()])) {
- $settings->filters = (array)($settings->filters['sources'][$source->get_id()]) + $settings->filters;
+ $settings->filters = (array) ($settings->filters['sources'][$source->get_id()]) + $settings->filters;
}
$file = $source->backup_to_file($file, $settings);
@@ -192,10 +195,10 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
/**
* Restore the data from to source specified in the settings.
*/
- function restore($file, $settings) {
+ public function restore($file, $settings) {
if ($source = $settings->get_source()) {
if (!empty($settings->filters['sources'][$source->get_id()])) {
- $settings->filters = (array)($settings->filters['sources'][$source->get_id()]) + $settings->filters;
+ $settings->filters = (array) ($settings->filters['sources'][$source->get_id()]) + $settings->filters;
}
$num = $source->restore_from_file($file, $settings);
return $num ? $file : FALSE;
@@ -205,11 +208,14 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
}
/**
- * Get a list of dummy destinations representing each of the available destination types.
+ * Dummy destinations representing each of the available destination types.
+ *
+ * @return array
+ * All of the available destination types.
*/
- function _get_destination_types() {
+ public function _get_destination_types() {
backup_migrate_include('destinations');
- static $destinations = NULL;
+ $destinations = &drupal_static('backup_migrate_filter_backup_restore::_get_destination_types', NULL);
if (!is_array($destinations)) {
$destinations = array();
$types = backup_migrate_get_destination_subtypes();
@@ -217,7 +223,7 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
foreach ($types as $key => $type) {
// Include the necessary file if specified by the type.
if (!empty($type['file'])) {
- require_once './'. $type['file'];
+ require_once './' . $type['file'];
}
$destinations[] = new $type['class'](array());
}
@@ -226,19 +232,23 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
}
/**
- * Get a list of dummy destinations representing each of the available source types.
+ * Dummy destinations representing each of the available source types.
+ *
+ * @return array
+ * All of the available source types.
*/
- function _get_source_types() {
+ public function _get_source_types() {
backup_migrate_include('sources');
- static $sources = NULL;
+ $sources = &drupal_static('backup_migrate_filter_backup_restore::_get_source_types', NULL);
if (!is_array($sources)) {
$sources = array();
$types = backup_migrate_get_source_subtypes();
- // If no (valid) node type has been provided, display a node type overview.
+ // If no (valid) node type has been provided, display a node type
+ // overview.
foreach ($types as $key => $type) {
// Include the necessary file if specified by the type.
if (!empty($type['file'])) {
- require_once './'. $type['file'];
+ require_once './' . $type['file'];
}
$sources[] = new $type['class'](array());
}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.compression.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.compression.inc
index e399d29..e55ff92 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.compression.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.compression.inc
@@ -1,6 +1,5 @@
100, 'restore' => -100);
+ public $op_weights = array('backup' => 100, 'restore' => -100);
/**
* This function is called on a backup file after the backup has been completed.
*/
- function backup($file, $settings) {
+ public function backup($file, $settings) {
return $this->_backup_migrate_file_compress($file, $settings);
}
/**
* This function is called on a backup file before importing it.
*/
- function restore($file, $settings) {
+ public function restore($file, $settings) {
return $this->_backup_migrate_file_decompress($file, $settings);
}
/**
* Get the form for the settings for this filter.
*/
- function backup_settings_default() {
+ public function backup_settings_default() {
$options = $this->_backup_migrate_get_compression_form_item_options();
return array('compression' => isset($options['gzip']) ? 'gzip' : 'none');
}
@@ -39,7 +38,7 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
/**
* Get the form for the settings for this filter.
*/
- function backup_settings_form($settings) {
+ public function backup_settings_form($settings) {
$form = array();
$compression_options = $this->_backup_migrate_get_compression_form_item_options();
$form['file']['compression'] = array(
@@ -54,7 +53,7 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
/**
* Return a list of backup filetypes.
*/
- function file_types() {
+ public function file_types() {
return array(
"gzip" => array(
"extension" => "gz",
@@ -86,7 +85,7 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
/**
* Get the compression options as an options array for a form item.
*/
- function _backup_migrate_get_compression_form_item_options() {
+ public function _backup_migrate_get_compression_form_item_options() {
$compression_options = array("none" => t("No Compression"));
if (@function_exists("gzencode")) {
$compression_options['gzip'] = t("GZip");
@@ -103,15 +102,14 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
/**
* Gzip encode a file.
*/
- function _backup_migrate_gzip_encode($source, $dest, $level = 9, $settings) {
+ public function _backup_migrate_gzip_encode($source, $dest, $level = 9, $settings) {
$success = FALSE;
// Try command line gzip first.
-
if (!empty($settings->filters['use_cli'])) {
$success = backup_migrate_exec("gzip -c -$level %input > %dest", array('%input' => $source, '%dest' => $dest, '%level' => $level));
}
if (!$success && @function_exists("gzopen")) {
- if (($fp_out = gzopen($dest, 'wb'. $level)) && ($fp_in = fopen($source, 'rb'))) {
+ if (($fp_out = gzopen($dest, 'wb' . $level)) && ($fp_in = fopen($source, 'rb'))) {
while (!feof($fp_in)) {
gzwrite($fp_out, fread($fp_in, 1024 * 512));
}
@@ -126,7 +124,7 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
/**
* Gzip decode a file.
*/
- function _backup_migrate_gzip_decode($source, $dest, $settings) {
+ public function _backup_migrate_gzip_decode($source, $dest, $settings) {
$success = FALSE;
if (!empty($settings->filters['use_cli'])) {
@@ -149,7 +147,7 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
/**
* Bzip encode a file.
*/
- function _backup_migrate_bzip_encode($source, $dest) {
+ public function _backup_migrate_bzip_encode($source, $dest) {
$success = FALSE;
if (@function_exists("bzopen")) {
if (($fp_out = bzopen($dest, 'w')) && ($fp_in = fopen($source, 'rb'))) {
@@ -170,7 +168,7 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
/**
* Bzip decode a file.
*/
- function _backup_migrate_bzip_decode($source, $dest) {
+ public function _backup_migrate_bzip_decode($source, $dest) {
$success = FALSE;
if (@function_exists("bzopen")) {
if (($fp_out = fopen($dest, 'w')) && ($fp_in = bzopen($source, 'r'))) {
@@ -191,10 +189,10 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
/**
* Zip encode a file.
*/
- function _backup_migrate_zip_encode($source, $dest, $filename) {
+ public function _backup_migrate_zip_encode($source, $dest, $filename) {
$success = FALSE;
if (class_exists('ZipArchive')) {
- $zip = new ZipArchive;
+ $zip = new ZipArchive();
$res = $zip->open($dest, constant("ZipArchive::CREATE"));
if ($res === TRUE) {
$zip->addFile($source, $filename);
@@ -207,10 +205,10 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
/**
* Zip decode a file.
*/
- function _backup_migrate_zip_decode($source, $dest) {
+ public function _backup_migrate_zip_decode($source, $dest) {
$success = FALSE;
if (class_exists('ZipArchive')) {
- $zip = new ZipArchive;
+ $zip = new ZipArchive();
if (($fp_out = fopen($dest, "w")) && ($zip->open($source))) {
$filename = ($zip->getNameIndex(0));
if ($fp_in = $zip->getStream($filename)) {
@@ -230,7 +228,7 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
* Compress a file with the given settings.
* Also updates settings to reflect new file mime and file extension.
*/
- function _backup_migrate_file_compress($file, $settings) {
+ public function _backup_migrate_file_compress($file, $settings) {
switch ($settings->filters['compression']) {
case "gzip":
$from = $file->push_type('gzip');
@@ -264,7 +262,7 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
* Decompress a file with the given settings.
* Also updates settings to reflect new file mime and file extension.
*/
- function _backup_migrate_file_decompress($file, $settings) {
+ public function _backup_migrate_file_decompress($file, $settings) {
$success = FALSE;
switch ($file->type_id()) {
@@ -294,5 +292,5 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
}
return $success ? $file : NULL;
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.encryption.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.encryption.inc
index 74b679c..98e2361 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.encryption.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.encryption.inc
@@ -1,6 +1,5 @@
170, 'restore' => -170);
+ public $op_weights = array('backup' => 170, 'restore' => -170);
/**
- * This function is called on a backup file after the backup has been completed.
+ * Called on a backup file after the backup has been completed.
*/
- function backup($file, $settings) {
+ public function backup($file, $settings) {
return $this->file_encrypt($file, $settings);
}
/**
- * This function is called on a backup file before importing it.
+ * Called on a backup file before importing it.
*/
- function restore($file, $settings) {
+ public function restore($file, $settings) {
return $this->file_decrypt($file);
}
/**
- * Get the form for the settings for this filter.
+ * Gets the form for the settings for this filter.
*/
- function backup_settings_default() {
+ public function backup_settings_default() {
return array('encryption' => 'none');
}
/**
- * Get the form for the settings for this filter.
+ * Gets the form for the settings for this filter.
*/
- function backup_settings_form($settings) {
+ public function backup_settings_form($settings) {
$form = array();
$options = $this->_backup_migrate_get_encryption_form_item_options();
if (count($options) > 1) {
@@ -62,9 +61,9 @@ class backup_migrate_filter_encryption extends backup_migrate_filter {
}
/**
- * Return a list of backup filetypes.
+ * Returns a list of backup filetypes.
*/
- function file_types() {
+ public function file_types() {
return array(
"aes" => array(
"extension" => "aes",
@@ -76,9 +75,9 @@ class backup_migrate_filter_encryption extends backup_migrate_filter {
}
/**
- * Get the compression options as an options array for a form item.
+ * Gets the compression options as an options array for a form item.
*/
- function _backup_migrate_get_encryption_form_item_options() {
+ public function _backup_migrate_get_encryption_form_item_options() {
$options = array();
$options = array('' => t('No Encryption'));
if (@function_exists("aes_encrypt")) {
@@ -88,13 +87,14 @@ class backup_migrate_filter_encryption extends backup_migrate_filter {
}
/**
- * AES encrypt a file.
+ * AES encrypts a file.
*/
- function aes_encrypt($source, $dest) {
+ public function aes_encrypt($source, $dest) {
$success = FALSE;
if (function_exists('aes_encrypt')) {
if ($data = $source->get_contents()) {
- // Add a marker to the end of the data so we can trim the padding on decrpypt.
+ // Add a marker to the end of the data so we can trim the padding on
+ // decrpypt.
$data = pack("a*H2", $data, "80");
if ($data = aes_encrypt($data, FALSE)) {
$dest->put_contents($data);
@@ -106,9 +106,9 @@ class backup_migrate_filter_encryption extends backup_migrate_filter {
}
/**
- * Gzip decode a file.
+ * AES decodes a file.
*/
- function aes_decrypt($source, $dest) {
+ public function aes_decrypt($source, $dest) {
$success = FALSE;
if (function_exists('aes_decrypt')) {
if ($data = $source->get_contents()) {
@@ -124,10 +124,11 @@ class backup_migrate_filter_encryption extends backup_migrate_filter {
}
/**
- * Compress a file with the given settings.
- * Also updates settings to reflect new file mime and file extension.
+ * Compresses a file with the given settings.
+ *
+ * Also updates settings to reflect new file mime and file extension.
*/
- function file_encrypt($file, $settings) {
+ public function file_encrypt($file, $settings) {
if (!empty($settings->filters['encryption'])) {
switch ($settings->filters['encryption']) {
case "aes":
@@ -146,10 +147,11 @@ class backup_migrate_filter_encryption extends backup_migrate_filter {
}
/**
- * Decompress a file with the given settings.
- * Also updates settings to reflect new file mime and file extension.
+ * Decompresses a file with the given settings.
+ *
+ * Also updates settings to reflect new file mime and file extension.
*/
- function file_decrypt($file) {
+ public function file_decrypt($file) {
$success = FALSE;
if ($file) {
switch ($file->type_id()) {
@@ -157,11 +159,11 @@ class backup_migrate_filter_encryption extends backup_migrate_filter {
$from = $file->pop_type();
$success = $this->aes_decrypt($from, $file);
break;
+
default:
return $file;
- break;
- }
-
+ }
+
if (!$success) {
if (function_exists('aes_decrypt')) {
_backup_migrate_message("Could not decrpyt backup file. Please check that the file is valid and that the encryption key of the server matches the server that created the backup.", array(), 'error');
@@ -173,5 +175,5 @@ class backup_migrate_filter_encryption extends backup_migrate_filter {
}
return $success ? $file : NULL;
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.inc
index d0ed9ec..4b55f5d 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.inc
@@ -1,25 +1,24 @@
array(
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/filters.backup_restore.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/filters.backup_restore.inc',
'class' => 'backup_migrate_filter_backup_restore',
),
'compression' => array(
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/filters.compression.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/filters.compression.inc',
'class' => 'backup_migrate_filter_compression',
),
'encryption' => array(
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/filters.encryption.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/filters.encryption.inc',
'class' => 'backup_migrate_filter_encryption',
),
'statusnotify' => array(
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/filters.statusnotify.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/filters.statusnotify.inc',
'class' => 'backup_migrate_filter_statusnotify',
),
'utils' => array(
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/filters.utils.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/filters.utils.inc',
'class' => 'backup_migrate_filter_utils',
),
);
}
/**
- * Invoke the given method on all of the available filters.
+ * Invokes the given method on all of the available filters.
*/
function backup_migrate_filters_invoke_all() {
$args = func_get_args();
@@ -96,7 +95,7 @@ function backup_migrate_filters_invoke_all() {
}
/**
- * Filter a backup file before sending it to the destination.
+ * Filters a backup file before sending it to the destination.
*/
function backup_migrate_filters_backup($file, &$settings) {
backup_migrate_filters_invoke_all('pre_backup', $file, $settings);
@@ -112,7 +111,7 @@ function backup_migrate_filters_backup($file, &$settings) {
}
/**
- * Filter a backup file before sending it to the destination.
+ * Filters a backup file before sending it to the destination.
*/
function backup_migrate_filters_restore($file, &$settings) {
backup_migrate_filters_invoke_all('pre_restore', $file, $settings);
@@ -127,16 +126,16 @@ function backup_migrate_filters_restore($file, &$settings) {
}
/**
- * Get the backup settings for all of the filters.
+ * Gets the backup settings for all of the filters.
*/
function backup_migrate_filters_settings_form($settings, $op) {
- $out = backup_migrate_filters_invoke_all($op .'_settings_form', $settings);
+ $out = backup_migrate_filters_invoke_all($op . '_settings_form', $settings);
$out = backup_migrate_filters_settings_form_set_parents($out);
return $out;
}
/**
- * Add a form parent to the filter settings so that the filter values are saved in the right table.
+ * Adds form parent to filter settings so the values are saved in correct table.
*/
function backup_migrate_filters_settings_form_set_parents($form) {
foreach (element_children($form) as $key) {
@@ -149,24 +148,24 @@ function backup_migrate_filters_settings_form_set_parents($form) {
}
/**
- * Validate all the filters.
+ * Validates all the filters.
*/
function backup_migrate_filters_settings_form_validate($op, $form, &$form_state) {
- backup_migrate_filters_invoke_all($op .'_settings_form_validate', $form, $form_state);
+ backup_migrate_filters_invoke_all($op . '_settings_form_validate', $form, $form_state);
}
/**
- * Submit all of the filters.
+ * Submits all of the filters.
*/
function backup_migrate_filters_settings_form_submit($op, $form, &$form_state) {
- backup_migrate_filters_invoke_all($op .'_settings_form_submit', $form, $form_state);
+ backup_migrate_filters_invoke_all($op . '_settings_form_submit', $form, $form_state);
}
/**
- * Get the default settings for the filters.
+ * Gets the default settings for the filters.
*/
function backup_migrate_filters_settings_default($op) {
- return backup_migrate_filters_invoke_all($op .'_settings_default');
+ return backup_migrate_filters_invoke_all($op . '_settings_default');
}
/**
@@ -175,7 +174,7 @@ function backup_migrate_filters_settings_default($op) {
function backup_migrate_filters_before_action_form($settings, $op) {
$out = array();
$out += backup_migrate_filters_invoke_all('before_action_form', $op, $settings);
- $out += backup_migrate_filters_invoke_all('before_' . $op .'_form', $settings);
+ $out += backup_migrate_filters_invoke_all('before_' . $op . '_form', $settings);
return $out;
}
@@ -184,7 +183,7 @@ function backup_migrate_filters_before_action_form($settings, $op) {
*/
function backup_migrate_filters_before_action_form_validate($settings, $op, $form, &$form_state) {
backup_migrate_filters_invoke_all('before_action_form_validate', $op, $settings, $form, $form_state);
- backup_migrate_filters_invoke_all('before_' . $op .'_form_validate', $settings, $form, $form_state);
+ backup_migrate_filters_invoke_all('before_' . $op . '_form_validate', $settings, $form, $form_state);
}
/**
@@ -192,7 +191,7 @@ function backup_migrate_filters_before_action_form_validate($settings, $op, $for
*/
function backup_migrate_filters_before_action_form_submit($settings, $op, $form, &$form_state) {
backup_migrate_filters_invoke_all('before_action_form_submit', $op, $settings, $form, $form_state);
- backup_migrate_filters_invoke_all('before_' . $op .'_form_submit', $settings, $form, $form_state);
+ backup_migrate_filters_invoke_all('before_' . $op . '_form_submit', $settings, $form, $form_state);
}
/**
@@ -206,13 +205,13 @@ function backup_migrate_filters_file_types() {
* A base class for basing filters on.
*/
class backup_migrate_filter {
- var $weight = 0;
- var $op_weights = array();
+ public $weight = 0;
+ public $op_weights = array();
/**
* Get the weight of the filter for the given op.
*/
- function weight($op = NULL) {
+ public function weight($op = NULL) {
if ($op && isset($this->op_weights[$op])) {
return $this->op_weights[$op];
}
@@ -222,111 +221,110 @@ class backup_migrate_filter {
/**
* Get the form for the settings for this filter.
*/
- function backup_settings_default() {
+ public function backup_settings_default() {
return array();
}
/**
* Get the form for the settings for this filter.
*/
- function backup_settings_form($settings) {
+ public function backup_settings_form($settings) {
return array();
}
/**
* Get the form for the settings for this filter.
*/
- function backup_settings_form_validate($form, &$form_state) {
+ public function backup_settings_form_validate($form, &$form_state) {
}
/**
* Submit the settings form. Any values returned will be saved.
*/
- function backup_settings_form_submit($form, &$form_state) {
+ public function backup_settings_form_submit($form, &$form_state) {
}
/**
* Get the form for the settings for this filter.
*/
- function restore_settings_default() {
+ public function restore_settings_default() {
return array();
}
/**
* Get the form for the settings for this filter.
*/
- function restore_settings_form($settings) {
+ public function restore_settings_form($settings) {
return array();
}
/**
* Get the form for the settings for this filter.
*/
- function restore_settings_form_validate($form, &$form_state) {
+ public function restore_settings_form_validate($form, &$form_state) {
}
/**
* Submit the settings form. Any values returned will be saved.
*/
- function restore_settings_form_submit($form, &$form_state) {
+ public function restore_settings_form_submit($form, &$form_state) {
return $form_state['values'];
}
/**
* Get a list of file types handled by this filter.
*/
- function file_types() {
+ public function file_types() {
return array();
}
/**
* Declare any default destinations for this filter.
*/
- function destinations() {
+ public function destinations() {
return array();
}
-
/**
- * This function is called on a backup file after the backup has been completed.
+ * Called on a backup file after the backup has been completed.
*/
- function backup($file, $settings) {
+ public function backup($file, $settings) {
return $file;
}
/**
* This function is called immediately prior to backup.
*/
- function pre_backup($file, $settings) {
+ public function pre_backup($file, $settings) {
}
/**
* This function is called immediately post backup.
*/
- function post_backup($file, $settings) {
+ public function post_backup($file, $settings) {
}
-
+
/**
* This function is called on a backup file before importing it.
*/
- function restore($file, $settings) {
+ public function restore($file, $settings) {
return $file;
}
/**
* This function is called immediately prior to restore.
*/
- function pre_restore($file, $settings) {
+ public function pre_restore($file, $settings) {
}
/**
* This function is called immediately post restore.
*/
- function post_restore($file, $settings) {
+ public function post_restore($file, $settings) {
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.statusnotify.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.statusnotify.inc
index 28387a2..6101349 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.statusnotify.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.statusnotify.inc
@@ -1,6 +1,5 @@
FALSE,
'notify_failure_enable' => FALSE,
@@ -28,7 +27,7 @@ class backup_migrate_filter_statusnotify extends backup_migrate_filter {
/**
* Get the form for the settings for this filter.
*/
- function backup_settings_form($settings) {
+ public function backup_settings_form($settings) {
$form = array();
$form['advanced']['notify_success_enable'] = array(
"#type" => 'checkbox',
@@ -68,41 +67,39 @@ class backup_migrate_filter_statusnotify extends backup_migrate_filter {
/**
* Send the success email.
*/
- function backup_succeed($settings) {
+ public function backup_succeed($settings) {
if (@$settings->filters['notify_success_enable'] && $to = @$settings->filters['notify_success_email']) {
$messages = $this->get_messages();
- $subject = t('!site backup succeeded', array('!site' => variable_get('site_name', 'Drupal site')));
if ($messages = $this->get_messages()) {
$body = t("The site backup has completed successfully with the following messages:\n!messages", array('!messages' => $messages));
}
else {
$body = t("The site backup has completed successfully.\n");
}
- mail($settings->filters['notify_success_email'], $subject, $body);
+ drupal_mail('backup_migrate', 'backup_succeed', $settings->filters['notify_success_email'], language_default(), array('body' => $body));
}
}
/**
* Send the failure email.
*/
- function backup_fail($settings) {
+ public function backup_fail($settings) {
if (@$settings->filters['notify_failure_enable'] && $to = @$settings->filters['notify_failure_email']) {
$messages = $this->get_messages();
- $subject = t('!site backup failed', array('!site' => variable_get('site_name', 'Drupal site')));
if ($messages = $this->get_messages()) {
$body = t("The site backup has failed with the following messages:\n!messages", array('!messages' => $messages));
}
else {
$body = t("The site backup has failed for an unknown reason.");
}
- mail($settings->filters['notify_failure_email'], $subject, $body);
+ drupal_mail('backup_migrate', 'backup_fail', $settings->filters['notify_failure_email'], language_default(), array('body' => $body));
}
}
/**
* Render the messages and errors for the email.
*/
- function get_messages() {
+ public function get_messages() {
$out = "";
$messages = _backup_migrate_messages();
foreach ($messages as $message) {
@@ -110,5 +107,5 @@ class backup_migrate_filter_statusnotify extends backup_migrate_filter {
}
return $out;
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.utils.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.utils.inc
index b3eb1a1..87ecb14 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.utils.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.utils.inc
@@ -1,6 +1,5 @@
-1000, 'post_backup' => 1000);
- var $saved_devel_query = NULL;
+ public $op_weights = array('pre_backup' => -1000, 'post_backup' => 1000);
+ public $saved_devel_query = NULL;
/**
* Get the default backup settings for this filter.
*/
- function backup_settings_default() {
+ public function backup_settings_default() {
return array(
'utils_disable_query_log' => TRUE,
'utils_site_offline' => FALSE,
@@ -29,7 +28,7 @@ class backup_migrate_filter_utils extends backup_migrate_filter {
/**
* Get the default restore settings for this filter.
*/
- function restore_settings_default() {
+ public function restore_settings_default() {
return array(
'utils_disable_query_log' => TRUE,
'utils_site_offline' => FALSE,
@@ -39,7 +38,7 @@ class backup_migrate_filter_utils extends backup_migrate_filter {
/**
* Get the form for the backup settings for this filter.
*/
- function backup_settings_form($settings) {
+ public function backup_settings_form($settings) {
$form = array();
if (module_exists('devel') && variable_get('dev_query', 0)) {
$form['database']['utils_disable_query_log'] = array(
@@ -65,7 +64,7 @@ class backup_migrate_filter_utils extends backup_migrate_filter {
'#type' => 'textarea',
'#title' => t('Site off-line message'),
'#default_value' => !empty($settings['utils_site_offline_message']) ? $settings['utils_site_offline_message'] : variable_get('site_offline_message', t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal')))),
- '#description' => t('Message to show visitors when the site is in off-line mode.')
+ '#description' => t('Message to show visitors when the site is in off-line mode.'),
);
$form['advanced']['utils_description'] = array(
'#type' => 'textarea',
@@ -92,7 +91,7 @@ class backup_migrate_filter_utils extends backup_migrate_filter {
/**
* Get the form for the restore settings for this filter.
*/
- function restore_settings_form($settings) {
+ public function restore_settings_form($settings) {
$form = array();
if (module_exists('devel') && variable_get('dev_query', 0)) {
$form['advanced']['utils_disable_query_log'] = array(
@@ -118,7 +117,13 @@ class backup_migrate_filter_utils extends backup_migrate_filter {
'#type' => 'textarea',
'#title' => t('Site off-line message'),
'#default_value' => !empty($settings['utils_site_offline_message']) ? $settings['utils_site_offline_message'] : variable_get('site_offline_message', t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal')))),
- '#description' => t('Message to show visitors when the site is in off-line mode.')
+ '#description' => t('Message to show visitors when the site is in off-line mode.'),
+ );
+ $form['advanced']['utils_drop_all_tables'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Drop all tables before import (MySQL only)'),
+ '#default_value' => !empty($settings['utils_drop_all_tables']) ? $settings['utils_drop_all_tables'] : NULL,
+ '#description' => t('Drop all existing database tables before restoring the backup. This option is currently available on MySQL servers only.'),
);
$form['advanced']['use_cli'] = array(
"#type" => "checkbox",
@@ -135,25 +140,25 @@ class backup_migrate_filter_utils extends backup_migrate_filter {
return $form;
}
- function pre_backup($file, $settings) {
+ public function pre_backup($file, $settings) {
$this->take_site_offline($settings);
$this->disable_devel_query($settings);
}
- function post_backup($file, $settings) {
+ public function post_backup($file, $settings) {
$this->enable_devel_query($settings);
$this->take_site_online($settings);
if ($file) {
- $this->add_file_info($file, $settings);
+ $this->add_file_info($file, $settings);
}
}
- function pre_restore($file, $settings) {
+ public function pre_restore($file, $settings) {
$this->disable_devel_query($settings);
$this->take_site_offline($settings);
}
- function post_restore($file, $settings) {
+ public function post_restore($file, $settings) {
$this->enable_devel_query($settings);
$this->take_site_online($settings);
}
@@ -161,7 +166,7 @@ class backup_migrate_filter_utils extends backup_migrate_filter {
/**
* Disable devel query logging if it's active and the user has chosen to do so.
*/
- function disable_devel_query($settings) {
+ public function disable_devel_query($settings) {
$this->saved_devel_query = variable_get('dev_query', 0);
if (module_exists('devel') && variable_get('dev_query', 0) && !empty($settings->filters['utils_disable_query_log'])) {
variable_set('dev_query', 0);
@@ -171,7 +176,7 @@ class backup_migrate_filter_utils extends backup_migrate_filter {
/**
* Restore devel query to previous state.
*/
- function enable_devel_query($settings) {
+ public function enable_devel_query($settings) {
if (module_exists('devel')) {
variable_set('dev_query', $this->saved_devel_query);
}
@@ -180,7 +185,7 @@ class backup_migrate_filter_utils extends backup_migrate_filter {
/**
* Add the backup metadata to the file.
*/
- function add_file_info($file, $settings) {
+ public function add_file_info($file, $settings) {
$file->file_info['description'] = $settings->filters['utils_description'];
$file->file_info['datestamp'] = time();
$file->file_info['generator'] = 'Backup and Migrate (http://drupal.org/project/backup_migrate)';
@@ -204,31 +209,37 @@ class backup_migrate_filter_utils extends backup_migrate_filter {
/**
* Take the site offline if configured to do so.
*/
- function take_site_offline($settings) {
- // Save the current state of the site in case a restore overwrites it.
- $this->saved_site_offline = variable_get('maintenance_mode', 0);
- if (@$settings->filters['utils_site_offline']) {
- $this->saved_site_offline_message = variable_get('maintenance_mode_message', NULL);
- if (!empty($settings->filters['utils_site_offline_message'])) {
+ public function take_site_offline($settings) {
+ // If the site is already offline then don't do anything.
+ if (!variable_get('maintenance_mode', 0)) {
+ // Save the current state of the site in case a restore overwrites it.
+ if (!empty($settings->filters['utils_site_offline'])) {
+ $this->saved_site_offline = TRUE;
$this->saved_site_offline_message = variable_get('maintenance_mode_message', NULL);
- variable_set('maintenance_mode_message', $settings->filters['utils_site_offline_message']);
+ if (!empty($settings->filters['utils_site_offline_message'])) {
+ $this->saved_site_offline_message = variable_get('maintenance_mode_message', NULL);
+ variable_set('maintenance_mode_message', $settings->filters['utils_site_offline_message']);
+ }
+ variable_set('maintenance_mode', 1);
+ _backup_migrate_message('Site was taken offline.');
}
- variable_set('maintenance_mode', 1);
- _backup_migrate_message('Site was taken offline.');
}
}
/**
* Take the site online again after backup or restore.
*/
- function take_site_online($settings) {
+ public function take_site_online($settings) {
// Take the site back off/online because the restored db may have changed that setting.
- variable_set('maintenance_mode', $this->saved_site_offline);
- if ($settings->filters['utils_site_offline']) {
- if (!empty($this->saved_site_offline_message)) {
- variable_set('maintenance_mode_message', $this->saved_site_offline_message);
+ if (variable_get('maintenance_mode', 0) && !empty($this->saved_site_offline)) {
+ variable_set('maintenance_mode', 0);
+ if ($settings->filters['utils_site_offline']) {
+ if (!empty($this->saved_site_offline_message)) {
+ variable_set('maintenance_mode_message', $this->saved_site_offline_message);
+ }
+ _backup_migrate_message('Site was taken online.');
}
- _backup_migrate_message('Site was taken online.');
}
}
+
}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/locations.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/locations.inc
index 7cacd0f..d008341 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/locations.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/locations.inc
@@ -1,6 +1,5 @@
array());
- var $singular = 'location';
- var $plural = 'locations';
- var $title_plural = 'Locations';
- var $title_singular = 'Location';
+ public $db_table = "backup_migrate_destinations";
+ public $type_name = "location";
+ public $default_values = array('settings' => array());
+ public $singular = 'location';
+ public $plural = 'locations';
+ public $title_plural = 'Locations';
+ public $title_singular = 'Location';
- var $subtype = "";
- var $supported_ops = array();
+ public $subtype = "";
+ public $supported_ops = array();
/**
* This function is not supposed to be called. It is just here to help the po extractor out.
*/
- function strings() {
+ public function strings() {
// Help the pot extractor find these strings.
t('location');
t('locations');
@@ -104,49 +103,49 @@ class backup_migrate_location extends backup_migrate_item {
t('Locations');
}
- function ops() {
+ public function ops() {
return $this->supported_ops;
}
/**
* Does this location support the given operation.
*/
- function op($op) {
- $ops = (array)$this->ops();
+ public function op($op) {
+ $ops = (array) $this->ops();
return in_array($op, $ops);
}
/**
* Remove the given op from the support list.
*/
- function remove_op($op) {
+ public function remove_op($op) {
$key = array_search($op, $this->supported_ops);
if ($key !== FALSE) {
unset($this->supported_ops[$key]);
}
}
- function get_name() {
+ public function get_name() {
return @$this->name;
}
- function set_name($name) {
+ public function set_name($name) {
return $this->name = $name;
}
- function set_location($location) {
+ public function set_location($location) {
$this->location = $location;
}
- function get_location() {
+ public function get_location() {
return @$this->location;
}
- function get_display_location() {
+ public function get_display_location() {
return $this->get_location();
}
- function settings($key = NULL) {
+ public function settings($key = NULL) {
$out = $this->settings;
if ($key) {
$out = isset($out[$key]) ? $out[$key] : NULL;
@@ -157,7 +156,7 @@ class backup_migrate_location extends backup_migrate_item {
/**
* Get the type name of this location for display to the user.
*/
- function get_subtype_name() {
+ public function get_subtype_name() {
if ($type = $this->get('subtype')) {
$types = $this->location_types();
return isset($types[$type]['type_name']) ? $types[$type]['type_name'] : $type;
@@ -167,7 +166,7 @@ class backup_migrate_location extends backup_migrate_item {
/**
* Get the edit form for the item.
*/
- function edit_form() {
+ public function edit_form() {
if (!empty($this->supported_ops)) {
$form = parent::edit_form();
$form['subtype'] = array(
@@ -182,13 +181,13 @@ class backup_migrate_location extends backup_migrate_item {
foreach ($types as $key => $type) {
if (@$type['can_create']) {
$type_url_str = str_replace('_', '-', $key);
- $out = '
'. l($type['type_name'], BACKUP_MIGRATE_MENU_PATH . "/settings/$this->type_name/add/$type_url_str", array('attributes' => array('title' => t('Add a new @s location.', array('@s' => $type['type_name']))))) .'
';
- $out .= '
'. filter_xss_admin($type['description']) .'
';
+ $out = '
' . l($type['type_name'], BACKUP_MIGRATE_MENU_PATH . "/settings/$this->type_name/add/$type_url_str", array('attributes' => array('title' => t('Add a new @s location.', array('@s' => $type['type_name']))))) . '
';
+ $out .= '
' . filter_xss_admin($type['description']) . '
';
$items[] = $out;
}
}
if (count($items)) {
- $output = t('Choose the type of location you would like to create:') .'
'. implode('', $items) .'
';
+ $output = t('Choose the type of location you would like to create:') . '
' . implode('', $items) . '
';
}
else {
$output = t('No types available.');
@@ -204,21 +203,21 @@ class backup_migrate_location extends backup_migrate_item {
/**
* Get the available location types.
*/
- function location_types() {
+ public function location_types() {
return backup_migrate_get_location_subtypes();
}
/**
* Get the message to send to the user when confirming the deletion of the item.
*/
- function delete_confirm_message() {
+ public function delete_confirm_message() {
return t('Are you sure you want to delete the %name?', array('%name' => $this->get_name()));
}
/**
* Get the columns needed to list the type.
- */
- function get_list_column_info() {
+ */
+ public function get_list_column_info() {
$out = parent::get_list_column_info();
$out = array(
'name' => array('title' => t('Name')),
@@ -230,11 +229,11 @@ class backup_migrate_location extends backup_migrate_item {
/**
* Get a row of data to be used in a list of items of this type.
- */
- function get_list_row() {
+ */
+ public function get_list_row() {
$out = parent::get_list_row();
- // Supress locations with no actions as there's no value in showing them (and they may confuse new users).
+ // Suppress locations with no actions as there's no value in showing them (and they may confuse new users).
if (empty($out['actions'])) {
return NULL;
}
@@ -244,13 +243,13 @@ class backup_migrate_location extends backup_migrate_item {
/**
* Get the action links for a location.
*/
- function get_action_links() {
+ public function get_action_links() {
$out = parent::get_action_links();
$item_id = $this->get_id();
// Don't display the download/delete/restore ops if they are not available for this location.
if ($this->op('list files') && user_access("access backup files")) {
- $out = array('list files' => l(t("list files"), BACKUP_MIGRATE_MENU_PATH . "/$this->type_name/list/files/". $item_id)) + $out;
+ $out = array('list files' => l(t("list files"), BACKUP_MIGRATE_MENU_PATH . "/$this->type_name/list/files/" . $item_id)) + $out;
}
if (!$this->op('configure') || !user_access('administer backup and migrate')) {
unset($out['edit']);
@@ -261,94 +260,94 @@ class backup_migrate_location extends backup_migrate_item {
/**
* Determine if we can read the given file.
*/
- function can_read_file($file_id) {
+ public function can_read_file($file_id) {
return $this->op('restore');
}
/**
* Get the form for the settings for this location type.
*/
- function settings_default() {
+ public function settings_default() {
return array();
}
/**
* Get the form for the settings for this location.
*/
- function settings_form($form) {
+ public function settings_form($form) {
return $form;
}
/**
* Validate the form for the settings for this location.
*/
- function settings_form_validate($form_values) {
+ public function settings_form_validate($form_values) {
}
/**
* Submit the settings form. Any values returned will be saved.
*/
- function settings_form_submit($form_values) {
+ public function settings_form_submit($form_values) {
return $form_values;
}
/**
* Get the form for the settings for this filter.
*/
- function backup_settings_default() {
+ public function backup_settings_default() {
return array();
}
/**
* Get the form for the settings for this filter.
*/
- function backup_settings_form($settings) {
+ public function backup_settings_form($settings) {
return array();
}
/**
* Get the form for the settings for this filter.
*/
- function backup_settings_form_validate($form, &$form_state) {
+ public function backup_settings_form_validate($form, &$form_state) {
}
/**
* Submit the settings form. Any values returned will be saved.
*/
- function backup_settings_form_submit($form, &$form_state) {
+ public function backup_settings_form_submit($form, &$form_state) {
}
/**
* Get the form for the settings for this filter.
*/
- function restore_settings_default() {
+ public function restore_settings_default() {
return array();
}
/**
* Get the form for the settings for this filter.
*/
- function restore_settings_form($settings) {
+ public function restore_settings_form($settings) {
return array();
}
/**
* Get the form for the settings for this filter.
*/
- function restore_settings_form_validate($form_values) {
+ public function restore_settings_form_validate($form_values) {
}
/**
* Submit the settings form. Any values returned will be saved.
*/
- function restore_settings_form_submit($form_values) {
+ public function restore_settings_form_submit($form_values) {
return $form_values;
}
/**
* Create a new location of the correct type.
*/
- function create($params = array()) {
+ public function create($params = array()) {
$out = NULL;
$types = backup_migrate_get_location_subtypes();
// Get the type passed in in the params, or if none, check the url for a valid type name.
@@ -358,7 +357,7 @@ class backup_migrate_location extends backup_migrate_item {
if ($location_type && ($type = @$types[$location_type])) {
// Include the necessary file if specified by the type.
if (!empty($type['file'])) {
- require_once './'. $type['file'];
+ require_once './' . $type['file'];
}
$out = new $type['class']($params + array('subtype' => $location_type));
}
@@ -369,37 +368,37 @@ class backup_migrate_location extends backup_migrate_item {
return $out;
}
- /**
+ /**
* Get a url from the parts.
*/
- function url($hide_password = TRUE) {
+ public function url($hide_password = TRUE) {
return $this->glue_url($this->dest_url, $hide_password);
}
/**
* Glue a URLs component parts back into a URL.
*/
- function glue_url($parts, $hide_password = TRUE) {
+ public function glue_url($parts, $hide_password = TRUE) {
// Obscure the password if we need to.
$parts['pass'] = $hide_password ? "" : $parts['pass'];
// Assemble the URL.
$out = "";
- $out .= $parts['scheme'] .'://';
+ $out .= $parts['scheme'] . '://';
$out .= $parts['user'] ? urlencode($parts['user']) : '';
- $out .= ($parts['user'] && $parts['pass']) ? ":". urlencode($parts['pass']) : '';
+ $out .= ($parts['user'] && $parts['pass']) ? ":" . urlencode($parts['pass']) : '';
$out .= ($parts['user'] || $parts['pass']) ? "@" : "";
$out .= $parts['host'];
- $out .= !empty($parts['port']) ? ':'. $parts['port'] : '';
- $out .= "/". $parts['path'];
+ $out .= !empty($parts['port']) ? ':' . $parts['port'] : '';
+ $out .= "/" . $parts['path'];
return $out;
}
/**
* Break a URL into it's component parts.
*/
- function set_url($url) {
- $parts = (array)parse_url($url);
+ public function set_url($url) {
+ $parts = (array) parse_url($url);
$parts['user'] = urldecode(@$parts['user']);
$parts['pass'] = urldecode(@$parts['pass']);
$parts['path'] = urldecode(@$parts['path']);
@@ -410,7 +409,7 @@ class backup_migrate_location extends backup_migrate_item {
/**
* Retrieve a list of filetypes supported by this source/destination.
*/
- function file_types() {
+ public function file_types() {
return array();
}
@@ -423,67 +422,29 @@ class backup_migrate_location_remote extends backup_migrate_location {
/**
* The location is a URI so parse it and store the parts.
*/
- function get_location() {
+ public function get_location() {
return $this->url(FALSE);
}
/**
* The location to display is the url without the password.
*/
- function get_display_location() {
+ public function get_display_location() {
return $this->url(TRUE);
}
/**
* Return the location with the password.
*/
- function set_location($location) {
+ public function set_location($location) {
$this->location = $location;
$this->set_url($location);
}
/**
- * Get a url from the parts.
+ * Location configuration callback.
*/
- function url($hide_password = TRUE) {
- return $this->glue_url($this->dest_url, $hide_password);
- }
-
- /**
- * Glue a URLs component parts back into a URL.
- */
- function glue_url($parts, $hide_password = TRUE) {
- // Obscure the password if we need to.
- $parts['pass'] = $hide_password ? "" : $parts['pass'];
-
- // Assemble the URL.
- $out = "";
- $out .= $parts['scheme'] .'://';
- $out .= $parts['user'] ? urlencode($parts['user']) : '';
- $out .= ($parts['user'] && $parts['pass']) ? ":". urlencode($parts['pass']) : '';
- $out .= ($parts['user'] || $parts['pass']) ? "@" : "";
- $out .= $parts['host'];
- $out .= !empty($parts['port']) ? ':'. $parts['port'] : '';
- $out .= "/". $parts['path'];
- return $out;
- }
-
- /**
- * Break a URL into it's component parts.
- */
- function set_url($url) {
- $parts = (array)parse_url($url);
- $parts['user'] = urldecode(@$parts['user']);
- $parts['pass'] = urldecode(@$parts['pass']);
- $parts['path'] = urldecode(@$parts['path']);
- $parts['path'] = ltrim(@$parts['path'], "/");
- $this->dest_url = $parts;
- }
-
- /**
- * location configuration callback.
- */
- function edit_form() {
+ public function edit_form() {
$form = parent::edit_form();
$form['scheme'] = array(
"#type" => "select",
@@ -534,10 +495,10 @@ class backup_migrate_location_remote extends backup_migrate_location {
/**
* Submit the configuration form. Glue the url together and add the old password back if a new one was not specified.
*/
- function edit_form_submit($form, &$form_state) {
+ public function edit_form_submit($form, &$form_state) {
$form_state['values']['pass'] = $form_state['values']['pass'] ? $form_state['values']['pass'] : $form_state['values']['old_password'];
$form_state['values']['location'] = $this->glue_url($form_state['values'], FALSE);
parent::edit_form_submit($form, $form_state);
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/profiles.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/profiles.inc
index 47265b7..5492b62 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/profiles.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/profiles.inc
@@ -1,6 +1,5 @@
$profile) {
// Set the default values for filter setting which don't exist in the profile.
- $profiles[$id]->filters = (array)@$profile->filters + (array)backup_migrate_filters_settings_default('backup');
+ $profiles[$id]->filters = (array) @$profile->filters + (array) backup_migrate_filters_settings_default('backup');
}
}
@@ -80,7 +74,7 @@ function backup_migrate_backup_migrate_profiles() {
*/
function _backup_migrate_get_profile_form_item_options() {
$out = array();
- foreach ((array)backup_migrate_get_profiles() as $key => $profile) {
+ foreach ((array) backup_migrate_get_profiles() as $key => $profile) {
$out[$key] = $profile->get('name');
}
return $out;
@@ -91,8 +85,8 @@ function _backup_migrate_get_profile_form_item_options() {
*/
function _backup_migrate_ui_backup_settings_form($profile) {
drupal_add_js(array('backup_migrate' => array('checkboxLinkText' => t('View as checkboxes'))), array('type' => 'setting'));
- drupal_add_js(drupal_get_path('module', 'backup_migrate') .'/backup_migrate.js', array('type' => 'file', 'scope' => 'footer'));
- drupal_add_css(drupal_get_path('module', 'backup_migrate') .'/backup_migrate.css');
+ drupal_add_js(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.js', array('type' => 'file', 'scope' => 'footer'));
+ drupal_add_css(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.css');
backup_migrate_include('files', 'destinations', 'filters');
@@ -126,14 +120,19 @@ function _backup_migrate_ui_backup_settings_form($profile) {
}
$form['file']['append_timestamp'] = array(
- "#type" => "checkbox",
- "#title" => t("Append a timestamp."),
+ "#type" => "radios",
+ '#options' => array(
+ 0 => t('Create separate backups if `Backup file name` already exists'),
+ 2 => t('Overwrite the existing backup file'),
+ 1 => t('Append the timestamp'),
+ ),
+ "#title" => t("Save mode"),
"#default_value" => $profile->append_timestamp,
);
$form['file']['timestamp_format_wrapper'] = array(
'#type' => 'backup_migrate_dependent',
'#dependencies' => array(
- 'append_timestamp' => TRUE,
+ 'append_timestamp' => 1,
),
);
$form['file']['timestamp_format_wrapper']['timestamp_format'] = array(
@@ -150,8 +149,8 @@ function _backup_migrate_ui_backup_settings_form($profile) {
if ($form['advanced']) {
$form['advanced']['#type'] = 'fieldset';
$form['advanced']['#title'] = t('Advanced Options');
- $form['advanced']['#collapsed'] = true;
- $form['advanced']['#collapsible'] = true;
+ $form['advanced']['#collapsed'] = TRUE;
+ $form['advanced']['#collapsible'] = TRUE;
}
$form['#validate'][] = '_backup_migrate_ui_backup_settings_form_validate';
@@ -173,7 +172,7 @@ function _backup_migrate_ui_backup_settings_form_validate($form, &$form_state) {
function _backup_migrate_ui_backup_settings_form_submit($form, &$form_state) {
backup_migrate_filters_settings_form_submit('backup', $form, $form_state);
}
-
+
/**
* Get the default profile.
*/
@@ -207,17 +206,36 @@ function _backup_migrate_profile_saved_default_profile($profile_id = NULL) {
* A profile class for crud operations.
*/
class backup_migrate_profile extends backup_migrate_item {
- var $db_table = "backup_migrate_profiles";
- var $type_name = "profile";
- var $singular = 'settings profile';
- var $plural = 'settings profiles';
- var $title_plural = 'Settings Profiles';
- var $title_singular = 'Settings Profile';
+ public $db_table = "backup_migrate_profiles";
+ public $type_name = "profile";
+ public $singular = 'settings profile';
+ public $plural = 'settings profiles';
+ public $title_plural = 'Settings Profiles';
+ public $title_singular = 'Settings Profile';
+
+ /**
+ * Perform a shallow merge of the defaults and the parameters.
+ *
+ * This is needed because otherwise it will *combine* the nested arrays and
+ * make it impossible to deselect database tables from the 'nodata' setting.
+ *
+ * @param array $params
+ */
+ public function __construct(array $params = array()) {
+ $params = (array) $params;
+ $defaults = (array) $this->get_default_values();
+ foreach ($defaults as $key => $val) {
+ if (!isset($params[$key])) {
+ $params[$key] = $val;
+ }
+ }
+ $this->from_array($params);
+ }
/**
* This function is not supposed to be called. It is just here to help the po extractor out.
*/
- function strings() {
+ public function strings() {
// Help the pot extractor find these strings.
t('Settings Profile');
t('Settings Profiles');
@@ -228,22 +246,22 @@ class backup_migrate_profile extends backup_migrate_item {
/**
* Get the default values for standard parameters.
*/
- function get_default_values() {
+ public function get_default_values() {
return _backup_migrate_profile_default_profile() + array('name' => t("Untitled Profile"));
}
/**
* Get a table of all items of this type.
- */
- function get_list() {
- drupal_add_css(drupal_get_path('module', 'backup_migrate') .'/backup_migrate.css');
+ */
+ public function get_list() {
+ drupal_add_css(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.css');
return parent::get_list();
}
/**
* Get the columns needed to list the type.
- */
- function get_list_column_info() {
+ */
+ public function get_list_column_info() {
$out = parent::get_list_column_info();
$out = array(
'name' => array('title' => t('Name')),
@@ -256,7 +274,7 @@ class backup_migrate_profile extends backup_migrate_item {
/**
* Set the source of this setings profile. Takes either a source object or source id.
*/
- function set_source($source) {
+ public function set_source($source) {
if (is_object($source)) {
$this->source = $source;
$this->source_id = $source->get_id();
@@ -270,7 +288,7 @@ class backup_migrate_profile extends backup_migrate_item {
/**
* Get the source of the profile.
*/
- function get_source() {
+ public function get_source() {
backup_migrate_include('locations');
if (!empty($this->source_id) && (empty($this->source) || $this->source->get_id() !== $this->source_id)) {
$this->source = backup_migrate_get_source($this->source_id);
@@ -281,7 +299,7 @@ class backup_migrate_profile extends backup_migrate_item {
/**
* Get the name of the source.
*/
- function get_source_name() {
+ public function get_source_name() {
if ($source = $this->get_source()) {
return $source->get_name();
}
@@ -291,22 +309,22 @@ class backup_migrate_profile extends backup_migrate_item {
/**
* Get the destination of the profile.
*/
- function get_destination() {
- $destinations = (array)$this->get_destinations();
+ public function get_destination() {
+ $destinations = (array) $this->get_destinations();
return reset($destinations);
}
/**
* Get the destination of the profile.
*/
- function get_destinations() {
+ public function get_destinations() {
backup_migrate_include('destinations');
if (empty($this->destinations)) {
$this->destinations = array();
$ids = $weights = array();
if (!empty($this->destination_id)) {
- foreach ((array)$this->destination_id as $destination_id) {
- if (!in_array($destination_id, $ids) && $destination = backup_migrate_get_destination($destination_id)) {
+ foreach ((array) $this->destination_id as $destination_id) {
+ if (!in_array($destination_id, $ids) && $destination = backup_migrate_get_destination($destination_id)) {
$this->destinations[] = $destination;
$weights[] = $destination->get('weight');
$ids[] = $destination_id;
@@ -323,7 +341,7 @@ class backup_migrate_profile extends backup_migrate_item {
/**
* Get the name of the destination.
*/
- function get_destination_name() {
+ public function get_destination_name() {
$out = array();
foreach ($this->get_destinations() as $destination) {
$out[] = $destination->get_name();
@@ -335,9 +353,9 @@ class backup_migrate_profile extends backup_migrate_item {
}
/**
- * Get the source and destinations specified in the given settings profile
+ * Get the source and destinations specified in the given settings profile.
*/
- function get_all_locations() {
+ public function get_all_locations() {
$out = array();
$out += $this->get('destinations');
$out[] = $this->get('source');
@@ -347,7 +365,7 @@ class backup_migrate_profile extends backup_migrate_item {
/**
* Get the edit form.
*/
- function edit_form() {
+ public function edit_form() {
$form = parent::edit_form();
$form['name'] = array(
"#type" => "textfield",
@@ -362,8 +380,8 @@ class backup_migrate_profile extends backup_migrate_item {
/**
* Get the message to send to the user when confirming the deletion of the item.
*/
- function delete_confirm_message() {
+ public function delete_confirm_message() {
return t('Are you sure you want to delete the profile %name? Any schedules using this profile will be disabled.', array('%name' => $this->get('name')));
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/schedules.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/schedules.inc
index d0636d2..325b402 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/schedules.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/schedules.inc
@@ -4,13 +4,13 @@
* @file
* All of the schedule handling code needed for Backup and Migrate.
*/
-
+
define('BACKUP_MIGRATE_KEEP_ALL', 0);
define('BACKUP_MIGRATE_STANDARD_DELETE', -1);
define('BACKUP_MIGRATE_SMART_DELETE', -2);
define('BACKUP_MIGRATE_CRON_BUILTIN', 'builtin');
-define('BACKUP_MIGRATE_CRON_ELYSIA', 'elysia');
+define('BACKUP_MIGRATE_CRON_ELYSIA', 'elysia');
define('BACKUP_MIGRATE_CRON_NONE', 'none');
@@ -67,7 +67,7 @@ function backup_migrate_schedules_run() {
*/
function backup_migrate_schedule_run($schedule_id) {
backup_migrate_include('profiles');
- if ($schedule = backup_migrate_get_schedule($schedule_id)) {
+ if (($schedule = backup_migrate_get_schedule($schedule_id)) && $schedule->is_enabled()) {
$schedule->run();
}
backup_migrate_cleanup();
@@ -77,7 +77,7 @@ function backup_migrate_schedule_run($schedule_id) {
* Get all the available backup schedules.
*/
function backup_migrate_get_schedules() {
- static $schedules = NULL;
+ $schedules = &drupal_static('backup_migrate_get_schedules');
// Get the list of schedules and cache them locally.
if ($schedules === NULL) {
$schedules = backup_migrate_crud_get_items('schedule');
@@ -97,18 +97,18 @@ function backup_migrate_get_schedule($schedule_id) {
* A schedule class for crud operations.
*/
class backup_migrate_schedule extends backup_migrate_item {
- var $db_table = "backup_migrate_schedules";
- var $type_name = 'schedule';
- var $singular = 'schedule';
- var $plural = 'schedules';
- var $title_plural = 'Schedules';
- var $title_singular = 'Schedule';
- var $default_values = array();
+ public $db_table = "backup_migrate_schedules";
+ public $type_name = 'schedule';
+ public $singular = 'schedule';
+ public $plural = 'schedules';
+ public $title_plural = 'Schedules';
+ public $title_singular = 'Schedule';
+ public $default_values = array();
/**
* This function is not supposed to be called. It is just here to help the po extractor out.
*/
- function strings() {
+ public function strings() {
// Help the pot extractor find these strings.
t('Schedule');
t('Schedules');
@@ -119,23 +119,23 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Get the default values for this item.
*/
- function get_default_values() {
+ public function get_default_values() {
return array(
- 'name' => t("Untitled Schedule"),
- 'source_id' => 'db',
- 'enabled' => 1,
- 'keep' => BACKUP_MIGRATE_KEEP_ALL,
- 'period' => 60 * 60 * 24,
- 'storage' => BACKUP_MIGRATE_STORAGE_NONE,
- 'cron' => BACKUP_MIGRATE_CRON_BUILTIN,
- 'cron_schedule' => '0 4 * * *',
- );
+ 'name' => t("Untitled Schedule"),
+ 'source_id' => 'db',
+ 'enabled' => 1,
+ 'keep' => BACKUP_MIGRATE_KEEP_ALL,
+ 'period' => 60 * 60 * 24,
+ 'storage' => BACKUP_MIGRATE_STORAGE_NONE,
+ 'cron' => BACKUP_MIGRATE_CRON_BUILTIN,
+ 'cron_schedule' => '0 4 * * *',
+ );
}
/**
* Return as an array of values.
*/
- function to_array() {
+ public function to_array() {
$out = parent::to_array();
unset($out['last_run']);
return $out;
@@ -143,8 +143,8 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Get the columns needed to list the type.
- */
- function get_list_column_info() {
+ */
+ public function get_list_column_info() {
$out = parent::get_list_column_info();
$out = array(
'name' => array('title' => t('Name')),
@@ -160,8 +160,8 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Get the columns needed to list the type.
- */
- function get_settings_path() {
+ */
+ public function get_settings_path() {
// Pull the schedules tab up a level to the top.
return BACKUP_MIGRATE_MENU_PATH . '/' . $this->type_name;
}
@@ -169,7 +169,7 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Get the menu items for manipulating this type.
*/
- function get_menu_items() {
+ public function get_menu_items() {
$items = parent::get_menu_items();
$path = $this->get_settings_path();
return $items;
@@ -178,15 +178,15 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Get a row of data to be used in a list of items of this type.
*/
- function get_list_row() {
- drupal_add_css(drupal_get_path('module', 'backup_migrate') .'/backup_migrate.css');
+ public function get_list_row() {
+ drupal_add_css(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.css');
$row = parent::get_list_row();
if (!$this->is_enabled()) {
foreach ($row as $key => $field) {
if (!is_array($field)) {
$row[$key] = array('data' => $field, 'class' => 'schedule-list-disabled');
}
- else if (isset($row[$key]['class'])) {
+ elseif (isset($row[$key]['class'])) {
$row[$key]['class'] .= ' schedule-list-disabled';
}
else {
@@ -200,7 +200,7 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Is the schedule enabled and valid.
*/
- function is_enabled() {
+ public function is_enabled() {
$destination = $this->get_destination();
$profile = $this->get_profile();
return (!empty($this->enabled) && !empty($destination) && !empty($profile));
@@ -209,15 +209,15 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Get the destination object of the schedule.
*/
- function get_destination() {
- $destinations = (array)$this->get_destinations();
+ public function get_destination() {
+ $destinations = (array) $this->get_destinations();
return reset($destinations);
}
/**
* Get the destination object of the schedule.
*/
- function get_destination_ids() {
+ public function get_destination_ids() {
$out = array();
foreach (array('destination_id', 'copy_destination_id') as $key) {
if ($id = $this->get($key)) {
@@ -230,7 +230,7 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Get the destination object of the schedule.
*/
- function get_destinations() {
+ public function get_destinations() {
backup_migrate_include('destinations');
$out = array();
foreach ($this->get_destination_ids() as $id) {
@@ -244,14 +244,14 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Get the destination object of the schedule.
*/
- function get_destination_remote() {
+ public function get_destination_remote() {
backup_migrate_include('destinations');
return backup_migrate_get_destination($this->get('destination_remote_id'));
}
- /**
+ /**
* Get the destination object of the schedule.
*/
- function get_destination_local() {
+ public function get_destination_local() {
backup_migrate_include('destinations');
return backup_migrate_get_destination($this->get('destination_local_id'));
}
@@ -259,28 +259,28 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Get the name of the destination.
*/
- function get_destination_name() {
+ public function get_destination_name() {
if ($destinations = $this->get_destinations()) {
$out = array();
- foreach ((array)$destinations as $destination) {
+ foreach ((array) $destinations as $destination) {
$out[] = check_plain($destination->get_name());
}
return implode(', ', $out);
}
- return '
'. t("Missing") .'
';
+ return '
' . t("Missing") . '
';
}
/**
* Get the destination of the schedule.
*/
- function get_profile() {
+ public function get_profile() {
backup_migrate_include('profiles');
if ($settings = backup_migrate_get_profile($this->get('profile_id'))) {
$settings->file_info = empty($settings->file_info) ? array() : $settings->file_info;
$settings->file_info += array(
'schedule_id' => $this->get_id(),
'schedule_name' => $this->get('name'),
- );
+ );
}
return $settings;
@@ -289,23 +289,23 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Get the name of the source.
*/
- function get_profile_name() {
+ public function get_profile_name() {
if ($profile = $this->get_profile()) {
return check_plain($profile->get_name());
}
- return '
'. t("Missing") .'
';
+ return '
' . t("Missing") . '
';
}
/**
* Format a frequency in human-readable form.
*/
- function get_frequency_description() {
+ public function get_frequency_description() {
$period = $this->get_frequency_period();
$cron = $this->get('cron');
if ($cron == BACKUP_MIGRATE_CRON_BUILTIN) {
$out = format_plural(($this->period / $period['seconds']), $period['singular'], $period['plural']);
}
- else if ($cron == BACKUP_MIGRATE_CRON_ELYSIA) {
+ elseif ($cron == BACKUP_MIGRATE_CRON_ELYSIA) {
$out = $this->get('cron_schedule');
}
else {
@@ -317,26 +317,26 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Format the number to keep in human-readable form.
*/
- function get_keep_description() {
+ public function get_keep_description() {
return $this->generate_keep_description($this->keep);
}
/**
- * Format a number to keep in human readable from
+ * Format a number to keep in human readable from.
*/
- function generate_keep_description($keep, $terse = TRUE) {
+ public function generate_keep_description($keep, $terse = TRUE) {
if ($keep == BACKUP_MIGRATE_KEEP_ALL) {
return t('all backups');
}
- else if ($keep == BACKUP_MIGRATE_SMART_DELETE) {
+ elseif ($keep == BACKUP_MIGRATE_SMART_DELETE) {
$keep_hourly = variable_get('backup_migrate_smart_keep_hourly', BACKUP_MIGRATE_SMART_KEEP_HOURLY);
$keep_daily = variable_get('backup_migrate_smart_keep_daily', BACKUP_MIGRATE_SMART_KEEP_DAILY);
$keep_weekly = variable_get('backup_migrate_smart_keep_weekly', BACKUP_MIGRATE_SMART_KEEP_WEEKLY);
if ($terse) {
- return t('!hours hourly, !days daily, !weeks weekly backups',
+ return t('!hours hourly, !days daily, !weeks weekly backups',
array(
'!hours' => $keep_hourly == PHP_INT_MAX ? t('all') : $keep_hourly,
- '!days' => $keep_daily == PHP_INT_MAX ? t('all') : $keep_daily,
+ '!days' => $keep_daily == PHP_INT_MAX ? t('all') : $keep_daily,
'!weeks' => $keep_weekly == PHP_INT_MAX ? t('all') : $keep_weekly,
));
}
@@ -344,7 +344,7 @@ class backup_migrate_schedule extends backup_migrate_item {
return t('hourly backups !hours, daily backups !days and weekly backups !weeks',
array(
'!hours' => $keep_hourly == PHP_INT_MAX ? t('forever') : format_plural($keep_hourly, 'for 1 hour', 'for the past @count hours'),
- '!days' => $keep_daily == PHP_INT_MAX ? t('forever') : format_plural($keep_daily, 'for 1 day', 'for the past @count days'),
+ '!days' => $keep_daily == PHP_INT_MAX ? t('forever') : format_plural($keep_daily, 'for 1 day', 'for the past @count days'),
'!weeks' => $keep_weekly == PHP_INT_MAX ? t('forever') : format_plural($keep_weekly, 'for 1 week', 'for the past @count weeks'),
)
);
@@ -357,14 +357,14 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Format the enabled status in human-readable form.
*/
- function get_enabled_description() {
+ public function get_enabled_description() {
return !empty($this->enabled) ? t('Enabled') : t('Disabled');
}
/**
* Format the enabled status in human-readable form.
*/
- function get_last_run_description() {
+ public function get_last_run_description() {
$last_run = $this->get('last_run');
return !empty($last_run) ? format_date($last_run, 'small') : t('Never');
}
@@ -372,21 +372,21 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Get the number of excluded tables.
*/
- function get_exclude_tables_count() {
+ public function get_exclude_tables_count() {
return count($this->exclude_tables) ? count($this->exclude_tables) : t("No tables excluded");
}
/**
* Get the number of excluded tables.
*/
- function get_nodata_tables_count() {
+ public function get_nodata_tables_count() {
return count($this->nodata_tables) ? count($this->nodata_tables) : t("No data omitted");
}
/**
* Get the edit form.
*/
- function edit_form() {
+ public function edit_form() {
$form = parent::edit_form();
backup_migrate_include('destinations', 'sources', 'profiles');
@@ -404,7 +404,7 @@ class backup_migrate_schedule extends backup_migrate_item {
"#options" => _backup_migrate_get_profile_form_item_options(),
"#default_value" => $this->get('profile_id'),
);
- $form['profile_id']['#description'] = ' '. l(t("Create new profile"), BACKUP_MIGRATE_MENU_PATH . "/profile/add");
+ $form['profile_id']['#description'] = ' ' . l(t('Create new profile'), BACKUP_MIGRATE_MENU_PATH . '/settings/profile/add');
if (!$form['profile_id']['#options']) {
$form['profile_id']['#options'] = array('0' => t('-- None Available --'));
}
@@ -437,7 +437,7 @@ class backup_migrate_schedule extends backup_migrate_item {
"#default_value" => $cron ? $cron : BACKUP_MIGRATE_CRON_BUILTIN,
'#parents' => array('cron'),
);
-
+
$form['cron_settings']['period_settings'] = array(
'#type' => 'backup_migrate_dependent',
'#dependencies' => array(
@@ -465,7 +465,6 @@ class backup_migrate_schedule extends backup_migrate_item {
'#parents' => array('period', 'type'),
);
-
$form['cron_settings']['cron_elysia'] = array(
"#type" => "radio",
"#title" => t('Run using Elysia cron'),
@@ -474,7 +473,7 @@ class backup_migrate_schedule extends backup_migrate_item {
"#default_value" => $cron ? $cron : BACKUP_MIGRATE_CRON_BUILTIN,
'#parents' => array('cron'),
);
- if (!module_exists('elysia_cron')) {
+ if (!module_exists('elysia_cron') && !module_exists('ultimate_cron')) {
$form['cron_settings']['cron_elysia']['#disabled'] = TRUE;
$form['cron_settings']['cron_elysia']['#description'] .= ' ' . t('Install !elysia to enable this option.', array('!elysia' => l(t('Elysia Cron'), 'http://drupal.org/project/elysia_cron')));
}
@@ -488,7 +487,7 @@ class backup_migrate_schedule extends backup_migrate_item {
"#type" => "textfield",
"#title" => t('Cron Schedule'),
'#length' => 10,
- "#description" => t('Specify the frequecy of the schedule using standard cron notation. For more information see the !elysiareadme.', array('!elysiareadme' => l(t('the Elysia Cron README'), 'http://drupalcode.org/project/elysia_cron.git/blob/refs/heads/7.x-1.x:/README.txt'))),
+ "#description" => t('Specify the frequency of the schedule using standard cron notation. For more information see the !elysiareadme.', array('!elysiareadme' => l(t('the Elysia Cron README'), 'http://drupalcode.org/project/elysia_cron.git/blob/refs/heads/7.x-1.x:/README.txt'))),
"#default_value" => $this->get('cron_schedule'),
'#parents' => array('cron_schedule'),
);
@@ -502,8 +501,6 @@ class backup_migrate_schedule extends backup_migrate_item {
'#parents' => array('cron'),
);
-
-
$keep = $this->get('keep');
$form['delete'] = array(
'#type' => 'checkbox',
@@ -558,7 +555,7 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Submit the edit form.
*/
- function edit_form_validate($form, &$form_state) {
+ public function edit_form_validate($form, &$form_state) {
if (!is_numeric($form_state['values']['period']['number']) || $form_state['values']['period']['number'] <= 0) {
form_set_error('period][number', t('Backup period must be a number greater than 0.'));
}
@@ -566,10 +563,10 @@ class backup_migrate_schedule extends backup_migrate_item {
if (!$form_state['values']['delete']) {
$form_state['values']['keep'] = 0;
}
- else if ($form_state['values']['deletetype'] == BACKUP_MIGRATE_SMART_DELETE) {
+ elseif ($form_state['values']['deletetype'] == BACKUP_MIGRATE_SMART_DELETE) {
$form_state['values']['keep'] = BACKUP_MIGRATE_SMART_DELETE;
}
- else if (!is_numeric($form_state['values']['keep']) || $form_state['values']['keep'] <= 0) {
+ elseif (!is_numeric($form_state['values']['keep']) || $form_state['values']['keep'] <= 0) {
form_set_error('keep', t('Number to keep must be a number greater than 0.'));
}
parent::edit_form_validate($form, $form_state);
@@ -578,7 +575,7 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Submit the edit form.
*/
- function edit_form_submit($form, &$form_state) {
+ public function edit_form_submit($form, &$form_state) {
$periods = $this->frequency_periods();
$period = $periods[$form_state['values']['period']['type']];
$form_state['values']['period'] = $form_state['values']['period']['number'] * $period['seconds'];
@@ -586,9 +583,9 @@ class backup_migrate_schedule extends backup_migrate_item {
}
/**
- * Get the period of the frequency (ie: seconds, minutes etc.)
+ * Get the period of the frequency (ie: seconds, minutes etc.).
*/
- function get_frequency_period() {
+ public function get_frequency_period() {
foreach (array_reverse($this->frequency_periods()) as $period) {
if ($period['seconds'] && ($this->period % $period['seconds']) === 0) {
return $period;
@@ -600,7 +597,7 @@ class backup_migrate_schedule extends backup_migrate_item {
* Get a list of available backup periods. Only returns time periods which have a
* (reasonably) consistent number of seconds (ie: no months).
*/
- function frequency_periods() {
+ public function frequency_periods() {
return array(
'seconds' => array('type' => 'seconds', 'seconds' => 1, 'title' => t('Seconds'), 'singular' => t('Once a second'), 'plural' => t('Every @count seconds')),
'minutes' => array('type' => 'minutes', 'seconds' => 60, 'title' => t('Minutes'), 'singular' => t('Once a minute'), 'plural' => t('Every @count minutes')),
@@ -613,14 +610,14 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Get the message to send to the user when confirming the deletion of the item.
*/
- function delete_confirm_message() {
+ public function delete_confirm_message() {
return t('Are you sure you want to delete the schedule %name? Backups made with this schedule will not be deleted.', array('%name' => $this->get('name')));
}
/**
* Perform the cron action. Run the backup if enough time has elapsed.
*/
- function cron() {
+ public function cron() {
$now = time();
// Add a small negative buffer (1% of the entire period) to the time to account for slight difference in cron run length.
@@ -635,13 +632,17 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Run the actual schedule.
*/
- function run() {
+ public function run() {
+ // Clear cached profile data which could have been altered by previous
+ // schedule run; see #2672478
+ drupal_static_reset('backup_migrate_get_profiles');
+
if ($settings = $this->get_profile()) {
$settings->source_id = $this->get('source_id');
$settings->destination_id = $this->get('destination_ids');
- backup_migrate_perform_backup($settings);
$this->update_last_run(time());
+ backup_migrate_perform_backup($settings);
$this->remove_expired_backups();
}
else {
@@ -652,7 +653,7 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Set the last run time of a schedule to the given timestamp, or now if none specified.
*/
- function update_last_run($timestamp = NULL) {
+ public function update_last_run($timestamp = NULL) {
if ($timestamp === NULL) {
$timestamp = time();
}
@@ -662,31 +663,31 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Set the last run time of a schedule to the given timestamp, or now if none specified.
*/
- function get_last_run() {
+ public function get_last_run() {
return variable_get('backup_migrate_schedule_last_run_' . $this->get('id'), 0);
}
/**
* Remove older backups keeping only the number specified by the aministrator.
*/
- function remove_expired_backups() {
+ public function remove_expired_backups() {
backup_migrate_include('destinations');
$num_to_keep = $this->keep;
// If num to keep is not 0 (0 is infinity).
- foreach ((array)$this->get_destinations() as $destination) {
+ foreach ((array) $this->get_destinations() as $destination) {
if ($destination && $destination->op('delete') && $destination_files = $destination->list_files()) {
if ($num_to_keep == BACKUP_MIGRATE_SMART_DELETE) {
$this->smart_delete_backups(
- $destination,
+ $destination,
$destination_files,
variable_get('backup_migrate_smart_keep_subhourly', BACKUP_MIGRATE_SMART_KEEP_SUBHOURLY),
- variable_get('backup_migrate_smart_keep_hourly', BACKUP_MIGRATE_SMART_KEEP_HOURLY),
- variable_get('backup_migrate_smart_keep_daily', BACKUP_MIGRATE_SMART_KEEP_DAILY),
- variable_get('backup_migrate_smart_keep_weekly', BACKUP_MIGRATE_SMART_KEEP_WEEKLY)
+ variable_get('backup_migrate_smart_keep_hourly', BACKUP_MIGRATE_SMART_KEEP_HOURLY),
+ variable_get('backup_migrate_smart_keep_daily', BACKUP_MIGRATE_SMART_KEEP_DAILY),
+ variable_get('backup_migrate_smart_keep_weekly', BACKUP_MIGRATE_SMART_KEEP_WEEKLY)
);
}
- else if ($num_to_keep != BACKUP_MIGRATE_KEEP_ALL) {
+ elseif ($num_to_keep != BACKUP_MIGRATE_KEEP_ALL) {
$this->delete_backups($destination, $destination_files, $num_to_keep);
}
}
@@ -696,7 +697,7 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Remove older backups keeping only the number specified by the aministrator.
*/
- function delete_backups($destination, $files, $num_to_keep) {
+ public function delete_backups($destination, $files, $num_to_keep) {
backup_migrate_include('destinations');
$num_to_keep = $this->keep;
@@ -729,7 +730,7 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Delete files keeping the specified number of hourly, daily, weekly and monthly backups.
*/
- function smart_delete_backups($destination, $files, $keep_subhourly = 3600, $keep_hourly = 24, $keep_daily = 14, $keep_weekly = PHP_INT_MAX, $keep_monthly = PHP_INT_MAX) {
+ public function smart_delete_backups($destination, $files, $keep_subhourly = 3600, $keep_hourly = 24, $keep_daily = 14, $keep_weekly = PHP_INT_MAX, $keep_monthly = PHP_INT_MAX) {
$now = time();
$periods = array(
'subhourly' => array(
@@ -739,19 +740,19 @@ class backup_migrate_schedule extends backup_migrate_item {
'files' => array(),
),
'hourly' => array(
- 'delta' => 60*60,
+ 'delta' => 60 * 60,
'keep' => $keep_hourly,
'last_time' => 0,
'files' => array(),
),
'daily' => array(
- 'delta' => 60*60*24,
+ 'delta' => 60 * 60 * 24,
'keep' => $keep_daily,
'last_time' => 0,
'files' => array(),
),
'weekly' => array(
- 'delta' => 60*60*24*7,
+ 'delta' => 60 * 60 * 24 * 7,
'keep' => $keep_weekly,
'last_time' => 0,
'files' => array(),
@@ -786,7 +787,7 @@ class backup_migrate_schedule extends backup_migrate_item {
$keep_files[$id] = $id;
}
}
- // Keep oldest backup or it will get deleted if it doesn't fall on an exact multiple of the period
+ // Keep oldest backup or it will get deleted if it doesn't fall on an exact multiple of the period.
if ($id) {
$keep_files[$id] = $id;
}
@@ -799,5 +800,5 @@ class backup_migrate_schedule extends backup_migrate_item {
}
}
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/sources.archivesource.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.archivesource.inc
old mode 100755
new mode 100644
index b3625f7..73bf33a
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/sources.archivesource.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.archivesource.inc
@@ -1,4 +1,9 @@
'archive', 'location' => '.', 'name' => t('Entire Site (code, files & DB)'), 'show_in_list' => FALSE));
+ public function sources() {
+ $out = array();
+ $out['archive'] = backup_migrate_create_destination('archive', array(
+ 'machine_name' => 'archive',
+ 'location' => '.',
+ 'name' => t('Entire Site (code, files & DB)'),
+ 'show_in_list' => FALSE,
+ ));
return $out;
}
/**
- * Return a list of backup filetypes.
+ * Returns a list of backup filetypes.
*/
- function file_types() {
+ public function file_types() {
return array(
"sitearchive" => array(
"extension" => "sitearchive.tar",
@@ -43,14 +52,15 @@ class backup_migrate_files_destination_archivesource extends backup_migrate_dest
}
/**
- * Get the form for the settings for this destination.
+ * Gets the form for the settings for this destination.
*/
- function backup_settings_default() {
+ public function backup_settings_default() {
$out = parent::backup_settings_default();
$excludes = explode("\n", $out['exclude_filepaths']);
foreach ($excludes as $i => $exclude) {
$excludes[$i] = 'public://' . $exclude;
}
+ $excludes[] = 'private://backup_migrate';
$excludes[] = conf_path() . '/settings.php';
$excludes[] = file_directory_temp();
@@ -62,20 +72,22 @@ class backup_migrate_files_destination_archivesource extends backup_migrate_dest
/**
* Backup from this source.
*/
- function _backup_to_file_php($file, $settings) {
+ public function _backup_to_file_php($file, $settings) {
if ($this->check_libs()) {
+ $base_dir = $this->get_realpath();
+
$excluded_paths = empty($settings->filters['exclude_filepaths']) ? '' : $settings->filters['exclude_filepaths'];
- $exclude = $this->get_excluded_paths($excluded_paths);
- $files = $this->get_files_to_backup($this->get_location(), $settings, $exclude, realpath('.') . '/');
+ $exclude = $this->get_excluded_paths($settings);
+ $files = $this->get_files_to_backup($this->get_realpath(), $settings, $exclude);
if ($files) {
$manifest = $this->generate_manifest();
$db = $this->get_db();
$file->push_type('sitearchive');
- $gz = new Archive_Tar($file->filepath(), false);
+ $gz = new Archive_Tar($file->filepath(), FALSE);
- $gz->addModify(array($manifest), $file->name .'/', dirname($manifest));
- $gz->addModify($files, $file->name .'/docroot', $this->get_location());
+ $gz->addModify(array($manifest), $file->name . '/', dirname($manifest));
+ $gz->addModify($files, $file->name . '/docroot', $base_dir);
$gz->addModify($db, $file->name . '/', dirname($db));
unlink($manifest);
@@ -94,7 +106,7 @@ class backup_migrate_files_destination_archivesource extends backup_migrate_dest
/**
* Backup from this source.
*/
- function _backup_to_file_cli($file, $settings) {
+ public function _backup_to_file_cli($file, $settings) {
if (!empty($settings->filters['use_cli']) && function_exists('backup_migrate_exec') && function_exists('escapeshellarg')) {
$excluded_paths = empty($settings->filters['exclude_filepaths']) ? '' : $settings->filters['exclude_filepaths'];
foreach ($this->get_excluded_paths($excluded_paths) as $path) {
@@ -102,7 +114,8 @@ class backup_migrate_files_destination_archivesource extends backup_migrate_dest
}
$exclude = implode(' ', $exclude);
- // Create a symlink in a temp directory so we can rename the file in the archive.
+ // Create a symlink in a temp directory so we can rename the file in the
+ // archive.
$temp = backup_migrate_temp_directory();
$manifest = $this->generate_manifest();
@@ -113,7 +126,12 @@ class backup_migrate_files_destination_archivesource extends backup_migrate_dest
$file->push_type('sitearchive');
$link = $temp . '/docroot';
$input = realpath($this->get_location());
- backup_migrate_exec("ln -s %input %link; tar --dereference -C %temp -rf %output $exclude .", array('%output' => $file->filepath(), '%input' => $input, '%temp' => $temp, '%link' => $link));
+ backup_migrate_exec("ln -s %input %link; tar --dereference -C %temp -rf %output $exclude .", array(
+ '%output' => $file->filepath(),
+ '%input' => $input,
+ '%temp' => $temp,
+ '%link' => $link,
+ ));
return $file;
}
@@ -121,15 +139,15 @@ class backup_migrate_files_destination_archivesource extends backup_migrate_dest
}
/**
- * Generate a manifest file.
+ * Generates a manifest file.
*/
- function generate_manifest() {
+ public function generate_manifest() {
$info = array(
'Global' => array(
'datestamp' => time(),
'formatversion' => '2011-07-02',
'generator' => 'Backup and Migrate (http://drupal.org/project/backup_migrate)',
- 'generatorversion' => BACKUP_MIGRATE_VERSION,
+ 'generatorversion' => BACKUP_MIGRATE_VERSION,
),
'Site 0' => array(
'version' => VERSION,
@@ -153,18 +171,23 @@ class backup_migrate_files_destination_archivesource extends backup_migrate_dest
}
/**
- * Get a database dump to add to the archive.
+ * Gets a database dump to add to the archive.
*/
- function get_db() {
+ public function get_db() {
backup_migrate_include('destinations', 'files', 'filters', 'profiles');
$file = new backup_file();
- $settings = _backup_migrate_profile_saved_default_profile();
+ // Clone the default settings so we can make changes without them leaking
+ // out of this function.
+ $settings = clone _backup_migrate_profile_saved_default_profile();
$settings->source_id = 'db';
$settings->filters['compression'] = 'none';
+
+ // Execute the backup on the db with the default settings.
$file = backup_migrate_filters_backup($file, $settings);
- // Generate a tmp file with the correct final title (because ArchiveTar doesn't seem to allow renaming).
+ // Generate a tmp file with the correct final title (because ArchiveTar
+ // doesn't seem to allow renaming).
$tmpdir = backup_migrate_temp_directory();
$filepath = $tmpdir . '/database.sql';
rename($file->filepath(), $filepath);
@@ -173,10 +196,10 @@ class backup_migrate_files_destination_archivesource extends backup_migrate_dest
}
/**
- * Restore to this source.
+ * Restores to this source.
*/
- function _restore_from_file_php($file, &$settings) {
- $success = false;
+ public function _restore_from_file_php($file, &$settings) {
+ $success = FALSE;
if ($this->check_libs()) {
$from = $file->pop_type();
$temp = backup_migrate_temp_directory();
@@ -184,25 +207,25 @@ class backup_migrate_files_destination_archivesource extends backup_migrate_dest
$tar = new Archive_Tar($from->filepath());
$tar->extractModify($temp, $file->name);
- // Parse the manifest
+ // Parse the manifest.
$manifest = $this->read_manifest($temp);
// Currently only the first site in the archive is supported.
$site = $manifest['Site 0'];
- $docroot = $temp . '/' . $site['docroot'];
- $sqlfile = $temp . '/' . $site['database-file-default'];
+ $docroot = $temp . '/' . $site['docroot'];
+ $sqlfile = $temp . '/' . $site['database-file-default'];
$filepath = NULL;
if (isset($site['files-private'])) {
$filepath = $temp . '/' . $site['files-private'];
}
- else if (isset($site['files-public'])) {
+ elseif (isset($site['files-public'])) {
$filepath = $temp . '/' . $site['files-public'];
}
// Move the files from the temp directory.
if ($filepath && file_exists($filepath)) {
- _backup_migrate_move_files($filepath, file_directory_path());
+ _backup_migrate_move_files($filepath, variable_get('file_public_path', conf_path() . '/files'));
}
else {
_backup_migrate_message('Files were not restored because the archive did not seem to contain a files directory or was in a format that Backup and Migrate couldn\'t read', array(), 'warning');
@@ -210,7 +233,7 @@ class backup_migrate_files_destination_archivesource extends backup_migrate_dest
// Restore the sql db.
if ($sqlfile && file_exists($sqlfile)) {
- $db_settings = drupal_clone($settings);
+ $db_settings = clone $settings;
$db_settings->source_id = 'db';
$file = new backup_file(array('filepath' => $sqlfile));
$success = backup_migrate_filters_restore($file, $db_settings);
@@ -229,17 +252,17 @@ class backup_migrate_files_destination_archivesource extends backup_migrate_dest
}
/**
- * Restore to this source.
+ * Restores to this source.
*/
- function _restore_from_file_cli($file, &$settings) {
+ public function _restore_from_file_cli($file, &$settings) {
// @TODO: implement the cli version of the restore.
return FALSE;
}
/**
- * Generate a manifest file.
+ * Generates a manifest file.
*/
- function read_manifest($directory) {
+ public function read_manifest($directory) {
// Assume some defaults if values ore the manifest is missing.
$defaults = array(
'docroot' => 'docroot',
@@ -256,16 +279,17 @@ class backup_migrate_files_destination_archivesource extends backup_migrate_dest
return $out;
}
-
/**
- * Convert an associated array to an ini format string. Only allows 2 levels of depth to allow parse_ini_file to parse.
+ * Converts an associated array to an ini format string.
+ *
+ * Only allows 2 levels of depth to allow parse_ini_file to parse.
*/
- function _array_to_ini($sections) {
- $content = "";
+ public function _array_to_ini($sections) {
+ $content = "";
foreach ($sections as $section => $data) {
- $content .= '['. $section .']' . "\n";
+ $content .= '[' . $section . ']' . "\n";
foreach ($data as $key => $val) {
- $content .= $key . " = \"". $val ."\"\n";
+ $content .= $key . " = \"" . $val . "\"\n";
}
$content .= "\n";
}
@@ -273,10 +297,12 @@ class backup_migrate_files_destination_archivesource extends backup_migrate_dest
}
/**
- * Convert an associated array to an ini format string. Only allows 2 levels of depth to allow parse_ini_file to parse.
+ * Converts an associated array to an ini format string.
+ *
+ * Only allows 2 levels of depth to allow parse_ini_file to parse.
*/
- function _ini_to_array($path) {
+ public function _ini_to_array($path) {
return parse_ini_file($path, TRUE);
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/sources.db.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.db.inc
index 8bd75c3..a32dcd4 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/sources.db.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.db.inc
@@ -1,6 +1,5 @@
set_source($this->get_id());
@@ -40,7 +39,7 @@ class backup_migrate_source_db extends backup_migrate_source_remote {
/**
* Destination configuration callback.
*/
- function edit_form() {
+ public function edit_form() {
$form = parent::edit_form();
$form['scheme']['#default_value'] = $this->default_scheme();
$form['scheme']['#access'] = FALSE;
@@ -53,7 +52,7 @@ class backup_migrate_source_db extends backup_migrate_source_remote {
/**
* Validate the configuration form. Make sure the db info is valid.
*/
- function edit_form_validate($form, &$form_state) {
+ public function edit_form_validate($form, &$form_state) {
if (!preg_match('/[a-zA-Z0-9_\$]+/', $form_state['values']['path'])) {
form_set_error('path', t('The database name is not valid.'));
}
@@ -61,56 +60,63 @@ class backup_migrate_source_db extends backup_migrate_source_remote {
}
/**
- * Get the form for the settings for this destination.
+ * Get the default settings for this object.
*
- * Return the default tables whose data can be ignored. These tables mostly contain
- * info which can be easily reproducted (such as cache or search index)
- * but also tables which can become quite bloated but are not necessarily extremely
- * important to back up or migrate during development (such ass access log and watchdog)
+ * @return array
+ * The default tables whose data can be ignored. These tables mostly
+ * contain info which can be easily reproducted (such as cache or search
+ * index) but also tables which can become quite bloated but are not
+ * necessarily extremely important to back up or migrate during development
+ * (such as access log and watchdog).
*/
- function backup_settings_default() {
- $core = array(
- 'cache',
- 'cache_admin_menu',
- 'cache_browscap',
- 'cache_content',
- 'cache_filter',
- 'cache_calendar_ical',
- 'cache_location',
- 'cache_menu',
- 'cache_page',
- 'cache_reptag',
- 'cache_views',
- 'cache_views_data',
- 'cache_block',
- 'cache_update',
- 'cache_form',
- 'cache_bootstrap',
- 'cache_field',
- 'cache_image',
- 'cache_path',
- 'sessions',
- 'search_dataset',
- 'search_index',
- 'search_keywords_log',
- 'search_total',
- 'watchdog',
- 'accesslog',
- 'devel_queries',
- 'devel_times',
- );
- $nodata_tables = array_merge($core, module_invoke_all('devel_caches'));
- return array(
- 'nodata_tables' => $nodata_tables,
- 'exclude_tables' => array(),
+ public function backup_settings_default() {
+ $all_tables = $this->_get_table_names();
+
+ // Basic modules that should be excluded.
+ $basic = array(
+ // Default core tables.
+ 'accesslog',
+ 'sessions',
+ 'watchdog',
+ // Search module.
+ 'search_dataset',
+ 'search_index',
+ 'search_keywords_log',
+ 'search_total',
+ // Devel module.
+ 'devel_queries',
+ 'devel_times',
+ );
+
+ // Identify all cache tables.
+ $cache = array('cache');
+ foreach ($all_tables as $table_name) {
+ if (strpos($table_name, 'cache_') === 0) {
+ $cache[] = $table_name;
+ }
+ }
+
+ // Simpletest can create a lot of tables that do not need to be backed up,
+ // but all of them start with the string 'simpletest' so they can be easily
+ // excluded.
+ $simpletest = array();
+ foreach ($all_tables as $table_name) {
+ if (strpos($table_name, 'simpletest') === 0) {
+ $simpletest[] = $table_name;
+ }
+ }
+
+ return array(
+ 'nodata_tables' => drupal_map_assoc(array_merge($basic, $cache, module_invoke_all('devel_caches'))),
+ 'exclude_tables' => $simpletest,
'utils_lock_tables' => FALSE,
- );
+ );
}
/**
* Get the form for the backup settings for this destination.
*/
- function backup_settings_form($settings) {
+ public function backup_settings_form($settings) {
$objects = $this->get_object_names();
$form['#description'] = t("You may omit specific tables, or specific table data from the backup file. Only omit data that you know you will not need such as cache data, or tables from other applications. Excluding tables can break your Drupal install, so do not change these settings unless you know what you're doing.");
$form['exclude_tables'] = array(
@@ -141,23 +147,27 @@ class backup_migrate_source_db extends backup_migrate_source_remote {
/**
* Backup from this source.
*/
- function backup_to_file($file, $settings) {
+ public function backup_to_file($file, $settings) {
$file->push_type($this->get_file_type_id());
- //$this->lock_tables($settings);
-
+ // $this->lock_tables($settings);
// Switch to a different db if specified.
+ if (variable_get('backup_migrate_verbose')) {
+ _backup_migrate_message('Start peak memory usage: %mem', array('%mem' => backup_migrate_get_peak_memory_usage() . 'MB'), 'success');
+ }
$success = $this->_backup_db_to_file($file, $settings);
+ if (variable_get('backup_migrate_verbose')) {
+ _backup_migrate_message('Finish peak memory usage: %mem', array('%mem' => backup_migrate_get_peak_memory_usage() . 'MB'), 'success');
+ }
- //$this->unlock_tables($settings);
-
+ // $this->unlock_tables($settings);
return $success ? $file : FALSE;
}
/**
* Restore to this source.
*/
- function restore_from_file($file, &$settings) {
+ public function restore_from_file($file, &$settings) {
$num = 0;
$type = $this->get_file_type_id();
// Open the file using the file wrapper. Check that the dump is of the right type (allow .sql for legacy reasons).
@@ -179,7 +189,7 @@ class backup_migrate_source_db extends backup_migrate_source_remote {
/**
* Get the db connection for the specified db.
*/
- function _get_db_connection() {
+ public function _get_db_connection() {
if (!$this->connection) {
$target = $key = '';
$parts = explode(':', $this->get_id());
@@ -193,12 +203,12 @@ class backup_migrate_source_db extends backup_migrate_source_remote {
// If the url is specified build it into a connection info array.
if (!empty($this->dest_url)) {
$info = array(
- 'driver' => empty($this->dest_url['scheme']) ? NULL : $this->dest_url['scheme'],
- 'host' => empty($this->dest_url['host']) ? NULL : $this->dest_url['host'],
- 'port' => empty($this->dest_url['port']) ? NULL : $this->dest_url['port'],
- 'username' => empty($this->dest_url['user']) ? NULL : $this->dest_url['user'],
- 'password' => empty($this->dest_url['pass']) ? NULL : $this->dest_url['pass'],
- 'database' => empty($this->dest_url['path']) ? NULL : $this->dest_url['path'],
+ 'driver' => empty($this->dest_url['scheme']) ? NULL : $this->dest_url['scheme'],
+ 'host' => empty($this->dest_url['host']) ? NULL : $this->dest_url['host'],
+ 'port' => empty($this->dest_url['port']) ? NULL : $this->dest_url['port'],
+ 'username' => empty($this->dest_url['user']) ? NULL : $this->dest_url['user'],
+ 'password' => empty($this->dest_url['pass']) ? NULL : $this->dest_url['pass'],
+ 'database' => empty($this->dest_url['path']) ? NULL : $this->dest_url['path'],
);
$key = uniqid('backup_migrate_tmp_');
$target = 'default';
@@ -219,21 +229,21 @@ class backup_migrate_source_db extends backup_migrate_source_remote {
/**
* Backup the databases to a file.
*/
- function _backup_db_to_file($file, $settings) {
+ public function _backup_db_to_file($file, $settings) {
// Must be overridden.
}
/**
* Backup the databases to a file.
*/
- function _restore_db_from_file($file, $settings) {
+ public function _restore_db_from_file($file, $settings) {
// Must be overridden.
}
/**
* Get a list of objects in the database.
*/
- function get_object_names() {
+ public function get_object_names() {
// Must be overridden.
$out = $this->_get_table_names();
if (method_exists($this, '_get_view_names')) {
@@ -245,7 +255,7 @@ class backup_migrate_source_db extends backup_migrate_source_remote {
/**
* Get a list of tables in the database.
*/
- function get_table_names() {
+ public function get_table_names() {
// Must be overridden.
$out = $this->_get_table_names();
return $out;
@@ -254,7 +264,7 @@ class backup_migrate_source_db extends backup_migrate_source_remote {
/**
* Get a list of tables in the database.
*/
- function _get_table_names() {
+ public function _get_table_names() {
// Must be overridden.
return array();
}
@@ -262,12 +272,12 @@ class backup_migrate_source_db extends backup_migrate_source_remote {
/**
* Lock the database in anticipation of a backup.
*/
- function lock_tables($settings) {
+ public function lock_tables($settings) {
if ($settings->filters['utils_lock_tables']) {
$tables = array();
foreach ($this->get_table_names() as $table) {
// There's no need to lock excluded or structure only tables because it doesn't matter if they change.
- if (empty($settings->filters['exclude_tables']) || !in_array($table, (array)$settings->filters['exclude_tables'])) {
+ if (empty($settings->filters['exclude_tables']) || !in_array($table, (array) $settings->filters['exclude_tables'])) {
$tables[] = $table;
}
}
@@ -278,14 +288,14 @@ class backup_migrate_source_db extends backup_migrate_source_remote {
/**
* Lock the list of given tables in the database.
*/
- function _lock_tables($tables) {
+ public function _lock_tables($tables) {
// Must be overridden.
}
/**
* Unlock any tables that have been locked.
*/
- function unlock_tables($settings) {
+ public function unlock_tables($settings) {
if ($settings->filters['utils_lock_tables']) {
$this->_unlock_tables();
}
@@ -294,21 +304,21 @@ class backup_migrate_source_db extends backup_migrate_source_remote {
/**
* Unlock the list of given tables in the database.
*/
- function _unlock_tables($tables) {
+ public function _unlock_tables($tables) {
// Must be overridden.
}
/**
* Get the file type for to backup this destination to.
*/
- function get_file_type_id() {
+ public function get_file_type_id() {
return 'sql';
}
/**
* Get the version info for the given DB.
*/
- function _db_info() {
+ public function _db_info() {
return array(
'type' => FALSE,
'version' => t('Unknown'),
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/sources.db.mysql.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.db.mysql.inc
index 49ded37..ee67c86 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/sources.db.mysql.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.db.mysql.inc
@@ -1,5 +1,9 @@
array(
"extension" => "sql",
@@ -41,25 +44,34 @@ class backup_migrate_source_db_mysql extends backup_migrate_source_db {
/**
* Return the scheme for this db type.
*/
- function default_scheme() {
+ public function default_scheme() {
return 'mysql';
}
-
- /**
+ /**
* Declare any mysql databases defined in the settings.php file as a possible source.
*/
- function sources() {
+ public function sources() {
$out = array();
global $databases;
- foreach ((array)$databases as $db_key => $target) {
- foreach ((array)$target as $tgt_key => $info) {
+ foreach ((array) $databases as $db_key => $target) {
+ foreach ((array) $target as $tgt_key => $info) {
// Only mysql/mysqli supported by this source.
$key = $db_key . ':' . $tgt_key;
if ($info['driver'] === 'mysql') {
- $url = $info['driver'] . '://' . $info['username'] . ':' . $info['password'] . '@' . $info['host'] . (isset($info['port']) ? ':' . $info['port'] : '') . '/' . $info['database'];
+ // Compile the database connection string.
+ $url = 'mysql://';
+ $url .= urlencode($info['username']) . ':' . urlencode($info['password']);
+ $url .= '@';
+ $url .= urlencode($info['host']);
+ if (!empty($info['port'])) {
+ $url .= ':' . $info['port'];
+ }
+ $url .= '/' . urlencode($info['database']);
+
if ($source = backup_migrate_create_destination('mysql', array('url' => $url))) {
- // Treat the default database differently because it is probably the only one available.
+ // Treat the default database differently because it is probably
+ // the only one available.
if ($key == 'default:default') {
$source->set_id('db');
$source->set_name(t('Default Database'));
@@ -68,8 +80,8 @@ class backup_migrate_source_db_mysql extends backup_migrate_source_db {
$source->remove_op('manual backup');
}
else {
- $source->set_id('db:'. $key);
- $source->set_name($key .": ". $source->get_display_location());
+ $source->set_id('db:' . $key);
+ $source->set_name($key . ": " . $source->get_display_location());
}
$out[$source->get_id()] = $source;
}
@@ -82,7 +94,7 @@ class backup_migrate_source_db_mysql extends backup_migrate_source_db {
/**
* Get the file type for to backup this source to.
*/
- function get_file_type_id() {
+ public function get_file_type_id() {
return 'mysql';
}
@@ -91,9 +103,9 @@ class backup_migrate_source_db_mysql extends backup_migrate_source_db {
*
* Returns a list of sql commands, one command per line.
* That makes it easier to import without loading the whole file into memory.
- * The files are a little harder to read, but human-readability is not a priority
+ * The files are a little harder to read, but human-readability is not a priority.
*/
- function _backup_db_to_file($file, $settings) {
+ public function _backup_db_to_file($file, $settings) {
if (!empty($settings->filters['use_cli']) && $this->_backup_db_to_file_mysqldump($file, $settings)) {
return TRUE;
}
@@ -135,16 +147,14 @@ class backup_migrate_source_db_mysql extends backup_migrate_source_db {
}
}
-
/**
* Backup the databases to a file using the mysqldump command.
*/
- function _backup_db_to_file_mysqldump($file, $settings) {
+ public function _backup_db_to_file_mysqldump($file, $settings) {
$success = FALSE;
$nodata_tables = array();
$alltables = $this->_get_tables();
-
$command = 'mysqldump --result-file=%file --opt -Q --host=%host --port=%port --user=%user --password=%pass %db';
$args = array(
'%file' => $file->filepath(),
@@ -158,15 +168,15 @@ class backup_migrate_source_db_mysql extends backup_migrate_source_db {
// Ignore the excluded and no-data tables.
if (!empty($settings->filters['exclude_tables'])) {
$db = $this->dest_url['path'];
- foreach ((array)$settings->filters['exclude_tables'] as $table) {
+ foreach ((array) $settings->filters['exclude_tables'] as $table) {
if (isset($alltables[$table])) {
- $command .= ' --ignore-table='. $db .'.'. $table;
+ $command .= ' --ignore-table=' . $db . '.' . $table;
}
}
- foreach ((array)$settings->filters['nodata_tables'] as $table) {
+ foreach ((array) $settings->filters['nodata_tables'] as $table) {
if (isset($alltables[$table])) {
$nodata_tables[] = $table;
- $command .= ' --ignore-table='. $db .'.'. $table;
+ $command .= ' --ignore-table=' . $db . '.' . $table;
}
}
}
@@ -184,10 +194,19 @@ class backup_migrate_source_db_mysql extends backup_migrate_source_db {
/**
* Backup the databases to a file.
*/
- function _restore_db_from_file($file, $settings) {
+ public function _restore_db_from_file($file, $settings) {
$num = 0;
if ($file->open() && $conn = $this->_get_db_connection()) {
+ // Optionally drop all existing tables.
+ if (!empty($settings->filters['utils_drop_all_tables'])) {
+ $all_tables = $this->_get_tables();
+ $table_names = array_map('backup_migrate_array_name_value', $all_tables);
+ $table_list = join(', ', $table_names);
+ $stmt = $conn->prepare("DROP TABLE IF EXISTS $table_list;\n");
+ $stmt->execute();
+ }
+
// Read one line at a time and run the query.
while ($line = $this->_read_sql_command_from_file($file)) {
if (_backup_migrate_check_timeout()) {
@@ -210,17 +229,16 @@ class backup_migrate_source_db_mysql extends backup_migrate_source_db {
return $num;
}
-
/**
* Read a multiline sql command from a file.
*
* Supports the formatting created by mysqldump, but won't handle multiline comments.
*/
- function _read_sql_command_from_file($file) {
+ public function _read_sql_command_from_file($file) {
$out = '';
while ($line = $file->read()) {
$first2 = substr($line, 0, 2);
- $first3 = substr($line, 0, 2);
+ $first3 = substr($line, 0, 3);
// Ignore single line comments. This function doesn't support multiline comments or inline comments.
if ($first2 != '--' && ($first2 != '/*' || $first3 == '/*!')) {
@@ -237,7 +255,7 @@ class backup_migrate_source_db_mysql extends backup_migrate_source_db {
/**
* Get a list of tables in the database.
*/
- function _get_table_names() {
+ public function _get_table_names() {
$out = array();
foreach ($this->_get_tables() as $table) {
$out[$table['name']] = $table['name'];
@@ -248,7 +266,7 @@ class backup_migrate_source_db_mysql extends backup_migrate_source_db {
/**
* Get a list of views in the database.
*/
- function _get_view_names() {
+ public function _get_view_names() {
$out = array();
foreach ($this->_get_views() as $view) {
$out[$view['name']] = $view['name'];
@@ -259,29 +277,29 @@ class backup_migrate_source_db_mysql extends backup_migrate_source_db {
/**
* Lock the list of given tables in the database.
*/
- function _lock_tables($tables) {
+ public function _lock_tables($tables) {
if ($tables) {
$tables_escaped = array();
foreach ($tables as $table) {
- $tables_escaped[] = '`'. db_escape_table($table) .'` WRITE';
+ $tables_escaped[] = '`' . db_escape_table($table) . '` WRITE';
}
- $this->query('LOCK TABLES '. implode(', ', $tables_escaped));
+ $this->query('LOCK TABLES ' . implode(', ', $tables_escaped));
}
}
/**
* Unlock all tables in the database.
*/
- function _unlock_tables($settings) {
+ public function _unlock_tables($settings) {
$this->query('UNLOCK TABLES');
}
/**
* Get a list of tables in the db.
*/
- function _get_tables() {
+ public function _get_tables() {
$out = array();
- // get auto_increment values and names of all tables
+ // get auto_increment values and names of all tables.
$tables = $this->query("show table status", array(), array('fetch' => PDO::FETCH_ASSOC));
foreach ($tables as $table) {
// Lowercase the keys because between Drupal 7.12 and 7.13/14 the default query behavior was changed.
@@ -297,9 +315,9 @@ class backup_migrate_source_db_mysql extends backup_migrate_source_db {
/**
* Get a list of views in the db.
*/
- function _get_views() {
+ public function _get_views() {
$out = array();
- // get auto_increment values and names of all tables
+ // get auto_increment values and names of all tables.
$tables = $this->query("show table status", array(), array('fetch' => PDO::FETCH_ASSOC));
foreach ($tables as $table) {
// Lowercase the keys because between Drupal 7.12 and 7.13/14 the default query behavior was changed.
@@ -312,12 +330,12 @@ class backup_migrate_source_db_mysql extends backup_migrate_source_db {
return $out;
}
- /**
+ /**
* Get the sql for the structure of the given view.
*/
- function _get_view_create_sql($view) {
+ public function _get_view_create_sql($view) {
$out = "";
- // Switch SQL mode to get rid of "CREATE ALGORITHM..." what requires more permissions + troubles with the DEFINER user
+ // Switch SQL mode to get rid of "CREATE ALGORITHM..." what requires more permissions + troubles with the DEFINER user.
$sql_mode = $this->query("SELECT @@SESSION.sql_mode")->fetchField();
$this->query("SET sql_mode = 'ANSI'");
$result = $this->query("SHOW CREATE VIEW `" . $view['name'] . "`", array(), array('fetch' => PDO::FETCH_ASSOC));
@@ -326,7 +344,7 @@ class backup_migrate_source_db_mysql extends backup_migrate_source_db {
// Lowercase the keys because between Drupal 7.12 and 7.13/14 the default query behavior was changed.
// See: http://drupal.org/node/1171866
$create = array_change_key_case($create);
- $out .= "DROP VIEW IF EXISTS `". $view['name'] ."`;\n";
+ $out .= "DROP VIEW IF EXISTS `" . $view['name'] . "`;\n";
$out .= "SET sql_mode = 'ANSI';\n";
$out .= strtr($create['create view'], "\n", " ") . ";\n";
$out .= "SET sql_mode = '$sql_mode';\n";
@@ -339,86 +357,105 @@ class backup_migrate_source_db_mysql extends backup_migrate_source_db {
/**
* Get the sql for the structure of the given table.
*/
- function _get_table_structure_sql($table) {
+ public function _get_table_structure_sql($table) {
$out = "";
- $result = $this->query("SHOW CREATE TABLE `". $table['name'] ."`", array(), array('fetch' => PDO::FETCH_ASSOC));
+ $result = $this->query("SHOW CREATE TABLE `" . $table['name'] . "`", array(), array('fetch' => PDO::FETCH_ASSOC));
foreach ($result as $create) {
// Lowercase the keys because between Drupal 7.12 and 7.13/14 the default query behavior was changed.
// See: http://drupal.org/node/1171866
$create = array_change_key_case($create);
- $out .= "DROP TABLE IF EXISTS `". $table['name'] ."`;\n";
+ $out .= "DROP TABLE IF EXISTS `" . $table['name'] . "`;\n";
// Remove newlines and convert " to ` because PDO seems to convert those for some reason.
$out .= strtr($create['create table'], array("\n" => ' ', '"' => '`'));
if ($table['auto_increment']) {
- $out .= " AUTO_INCREMENT=". $table['auto_increment'];
+ $out .= " AUTO_INCREMENT=" . $table['auto_increment'];
}
$out .= ";\n";
}
return $out;
}
-
+
/**
- * Get the sql to insert the data for a given table
+ * Get the sql to insert the data for a given table.
*/
- function _dump_table_data_sql_to_file($file, $table) {
+ public function _dump_table_data_sql_to_file($file, $table) {
+ $rows_per_query = variable_get('backup_migrate_data_rows_per_query', 1000);
$rows_per_line = variable_get('backup_migrate_data_rows_per_line', 30);
$bytes_per_line = variable_get('backup_migrate_data_bytes_per_line', 2000);
-
- $lines = 0;
- $data = $this->query("SELECT * FROM `". $table['name'] ."`", array(), array('fetch' => PDO::FETCH_ASSOC));
- $rows = $bytes = 0;
- // Escape backslashes, PHP code, special chars
+ if (variable_get('backup_migrate_verbose')) {
+ _backup_migrate_message('Table: %table', array('%table' => $table['name']), 'success');
+ }
+
+ // Escape backslashes, PHP code, special chars.
$search = array('\\', "'", "\x00", "\x0a", "\x0d", "\x1a");
$replace = array('\\\\', "''", '\0', '\n', '\r', '\Z');
-
- $line = array();
- foreach ($data as $row) {
- // DB Escape the values.
- $items = array();
- foreach ($row as $key => $value) {
- $items[] = is_null($value) ? "null" : "'". str_replace($search, $replace, $value) ."'";
+
+ $lines = 0;
+ $from = 0;
+ $args = array('fetch' => PDO::FETCH_ASSOC);
+ while ($data = $this->query("SELECT * FROM `" . $table['name'] . "`", array(), $args, $from, $rows_per_query)) {
+ if ($data->rowCount() == 0) {
+ break;
}
-
- // If there is a row to be added.
- if ($items) {
- // Start a new line if we need to.
- if ($rows == 0) {
- $file->write("INSERT INTO `". $table['name'] ."` VALUES ");
- $bytes = $rows = 0;
+
+ $rows = $bytes = 0;
+
+ $line = array();
+ foreach ($data as $row) {
+ $from++;
+
+ // DB Escape the values.
+ $items = array();
+ foreach ($row as $key => $value) {
+ $items[] = is_null($value) ? "null" : "'" . str_replace($search, $replace, $value) . "'";
}
- // Otherwise add a comma to end the previous entry.
- else {
- $file->write(",");
- }
-
- // Write the data itself.
- $sql = implode(',', $items);
- $file->write('('. $sql .')');
- $bytes += strlen($sql);
- $rows++;
-
- // Finish the last line if we've added enough items
- if ($rows >= $rows_per_line || $bytes >= $bytes_per_line) {
- $file->write(";\n");
- $lines++;
- $bytes = $rows = 0;
+
+ // If there is a row to be added.
+ if ($items) {
+ // Start a new line if we need to.
+ if ($rows == 0) {
+ $file->write("INSERT INTO `" . $table['name'] . "` VALUES ");
+ $bytes = $rows = 0;
+ }
+ // Otherwise add a comma to end the previous entry.
+ else {
+ $file->write(",");
+ }
+
+ // Write the data itself.
+ $sql = implode(',', $items);
+ $file->write('(' . $sql . ')');
+ $bytes += strlen($sql);
+ $rows++;
+
+ // Finish the last line if we've added enough items.
+ if ($rows >= $rows_per_line || $bytes >= $bytes_per_line) {
+ $file->write(";\n");
+ $lines++;
+ $bytes = $rows = 0;
+ }
}
}
+
+ // Finish any unfinished insert statements.
+ if ($rows > 0) {
+ $file->write(";\n");
+ $lines++;
+ }
}
- // Finish any unfinished insert statements.
- if ($rows > 0) {
- $file->write(";\n");
- $lines++;
+
+ if (variable_get('backup_migrate_verbose')) {
+ _backup_migrate_message('Peak memory usage: %mem', array('%mem' => backup_migrate_get_peak_memory_usage() . 'MB'), 'success');
}
-
+
return $lines;
}
/**
* Get the db connection for the specified db.
*/
- function _get_db_connection() {
+ public function _get_db_connection() {
if (!$this->connection) {
$this->connection = parent::_get_db_connection();
// Set the sql mode because the default is ANSI,TRADITIONAL which is not aware of collation or storage engine.
@@ -428,11 +465,34 @@ class backup_migrate_source_db_mysql extends backup_migrate_source_db {
}
/**
- * Run a db query on this destination's db.
+ * Run a query on this source's database using Drupal's MySQL engine.
+ *
+ * @param string $query
+ * The query string.
+ * @param array $args
+ * Arguments for the query.
+ * @param array $options
+ * Options to pass to the query.
+ * @param int|null $from
+ * The starting point for the query; when passed will perform a queryRange()
+ * method instead of a regular query().
+ * @param int|null $count
+ * The number of records to obtain from this query. Will be ignored if the
+ * $from argument is empty.
+ *
+ * @see DatabaseConnection_mysql::query()
+ * @see DatabaseConnection_mysql::queryRange()
*/
- function query($query, $args = array(), $options = array()) {
+ public function query($query, array $args = array(), array $options = array(), $from = NULL, $count = NULL) {
if ($conn = $this->_get_db_connection()) {
- return $conn->query($query, $args, $options);
+ // If no $from is passed in, just do a basic query.
+ if (is_null($from)) {
+ return $conn->query($query, $args, $options);
+ }
+ // The $from variable was passed in, so do a ranged query.
+ else {
+ return $conn->queryRange($query, $from, $count, $args, $options);
+ }
}
}
@@ -440,11 +500,11 @@ class backup_migrate_source_db_mysql extends backup_migrate_source_db {
* The header for the top of the sql dump file. These commands set the connection
* character encoding to help prevent encoding conversion issues.
*/
- function _get_sql_file_header() {
+ public function _get_sql_file_header() {
$info = $this->_db_info();
return "-- Backup and Migrate (Drupal) MySQL Dump
--- Backup and Migrate Version: ". BACKUP_MIGRATE_VERSION ."
+-- Backup and Migrate Version: " . BACKUP_MIGRATE_VERSION . "
-- http://drupal.org/project/backup_migrate
-- Drupal Version: " . VERSION . "
-- http://drupal.org/
@@ -466,11 +526,11 @@ SET NAMES utf8;
";
}
-
+
/**
* The footer of the sql dump file.
*/
- function _get_sql_file_footer() {
+ public function _get_sql_file_footer() {
return "
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -485,7 +545,7 @@ SET NAMES utf8;
/**
* Get the version info for the given DB.
*/
- function _db_info() {
+ public function _db_info() {
$db = $this->_get_db_connection();
return array(
'type' => 'mysql',
@@ -494,4 +554,3 @@ SET NAMES utf8;
}
}
-
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/sources.filesource.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.filesource.inc
index 9008852..fb6b1e3 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/sources.filesource.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.filesource.inc
@@ -1,6 +1,5 @@
'files', 'location' => 'public://', 'name' => t('Public Files Directory'), 'show_in_list' => FALSE));
+ public function sources() {
+ $out = array();
+ $out['files'] = backup_migrate_create_destination('filesource', array(
+ 'machine_name' => 'files',
+ 'location' => 'public://',
+ 'name' => t('Public Files Directory'),
+ 'show_in_list' => FALSE,
+ ));
if (variable_get('file_private_path', FALSE)) {
- $out['files_private'] = backup_migrate_create_destination('filesource', array('machine_name' => 'files', 'location' => 'private://', 'name' => t('Private Files Directory'), 'show_in_list' => FALSE));
+ $out['files_private'] = backup_migrate_create_destination('filesource', array(
+ 'machine_name' => 'files',
+ 'location' => 'private://',
+ 'name' => t('Private Files Directory'),
+ 'show_in_list' => FALSE,
+ ));
}
return $out;
}
/**
- * Get the form for the settings for the files destination.
+ * Gets the form for the settings for the files destination.
*/
- function edit_form() {
+ public function edit_form() {
$form = parent::edit_form();
$form['location'] = array(
"#type" => "textfield",
"#title" => t("Directory path"),
"#default_value" => $this->get_location(),
"#required" => TRUE,
- "#description" => t('Enter the path to the directory to save the backups to. Use a relative path to pick a path relative to your Drupal root directory. The web server must be able to write to this path.'),
+ "#description" => t('Enter the path to the directory to back up. Use a relative path to pick a path relative to your Drupal root directory. The web server must be able to read from this path.'),
);
return $form;
}
/**
- * Return a list of backup filetypes.
+ * Returns a list of backup filetypes.
*/
- function file_types() {
+ public function file_types() {
return array(
"tar" => array(
"extension" => "tar",
@@ -61,27 +69,27 @@ class backup_migrate_destination_filesource extends backup_migrate_source {
}
/**
- * Get the form for the settings for this destination.
+ * Gets the form for the settings for this destination.
*
- * Return the default directories whose data can be ignored. These directories contain
- * info which can be easily reproducted. Also exclude the backup and migrate folder
- * to prevent exponential bloat.
+ * Return the default directories whose data can be ignored. These directories
+ * contain info which can be easily reproducted. Also exclude the backup and
+ * migrate folder to prevent exponential bloat.
*/
- function backup_settings_default() {
- return array(
- 'exclude_filepaths' => "backup_migrate\nstyles\ncss\njs\nctools\nless",
+ public function backup_settings_default() {
+ return array(
+ 'exclude_filepaths' => "backup_migrate\nstyles\ncss\njs\nctools\nless\nlanguages",
);
}
/**
* Get the form for the backup settings for this destination.
*/
- function backup_settings_form($settings) {
+ public function backup_settings_form($settings) {
$form['exclude_filepaths'] = array(
"#type" => "textarea",
"#multiple" => TRUE,
"#title" => t("Exclude the following files or directories"),
- "#default_value" => $settings['exclude_filepaths'],
+ "#default_value" => isset($settings['exclude_filepaths']) ? $settings['exclude_filepaths'] : '',
"#description" => t("A list of files or directories to be excluded from backups. Add one path per line relative to the directory being backed up."),
);
return $form;
@@ -90,7 +98,7 @@ class backup_migrate_destination_filesource extends backup_migrate_source {
/**
* Backup from this source.
*/
- function backup_to_file($file, $settings) {
+ public function backup_to_file($file, $settings) {
if ($out = $this->_backup_to_file_cli($file, $settings)) {
return $out;
}
@@ -102,13 +110,13 @@ class backup_migrate_destination_filesource extends backup_migrate_source {
/**
* Backup from this source.
*/
- function _backup_to_file_php($file, $settings) {
+ public function _backup_to_file_php($file, $settings) {
if ($this->check_libs()) {
- $excluded_paths = empty($settings->filters['exclude_filepaths']) ? '' : $settings->filters['exclude_filepaths'];
- $files = $this->get_files_to_backup($this->get_realpath(), $settings, $this->get_excluded_paths($excluded_paths), DRUPAL_ROOT . '/');
+ $excluded = $this->get_excluded_paths($settings);
+ $files = $this->get_files_to_backup($this->get_realpath(), $settings, $excluded);
if ($files) {
$file->push_type('tar');
- $gz = new Archive_Tar($file->filepath(), false);
+ $gz = new Archive_Tar($file->filepath(), FALSE);
$gz->addModify($files, '', $this->get_realpath());
return $file;
}
@@ -121,21 +129,25 @@ class backup_migrate_destination_filesource extends backup_migrate_source {
/**
* Backup from this source.
*/
- function _backup_to_file_cli($file, $settings) {
+ public function _backup_to_file_cli($file, $settings) {
if (!empty($settings->filters['use_cli']) && function_exists('backup_migrate_exec') && function_exists('escapeshellarg')) {
- $excluded_paths = empty($settings->filters['exclude_filepaths']) ? '' : $settings->filters['exclude_filepaths'];
+ $excluded = $this->get_excluded_paths($settings);
$exclude = array();
- foreach ($this->get_excluded_paths($excluded_paths) as $path) {
+ foreach ($excluded as $path) {
$exclude[] = '--exclude=' . escapeshellarg($path);
}
$exclude = implode(' ', $exclude);
- // Create a symlink in a temp directory so we can rename the file in the archive.
+ // Create a symlink in a temp directory so we can rename the file in the
+ // archive.
$temp = backup_migrate_temp_directory();
- $file->push_type('tar');
- backup_migrate_exec("tar --dereference -C %input -rf %output $exclude .", array('%output' => $file->filepath(), '%input' => $this->get_realpath(), '%temp' => $temp));
-
+ $file->push_type('tar');
+ backup_migrate_exec("tar --dereference -C %input -rf %output $exclude .", array(
+ '%output' => $file->filepath(),
+ '%input' => $this->get_realpath(),
+ '%temp' => $temp,
+ ));
return $file;
}
return FALSE;
@@ -144,7 +156,7 @@ class backup_migrate_destination_filesource extends backup_migrate_source {
/**
* Restore to this source.
*/
- function restore_from_file($file, &$settings) {
+ public function restore_from_file($file, &$settings) {
if ($out = $this->_restore_from_file_cli($file, $settings)) {
return $out;
}
@@ -156,7 +168,7 @@ class backup_migrate_destination_filesource extends backup_migrate_source {
/**
* Restore to this source.
*/
- function _restore_from_file_php($file, &$settings) {
+ public function _restore_from_file_php($file, &$settings) {
if ($this->check_libs()) {
$from = $file->pop_type();
$temp = backup_migrate_temp_directory();
@@ -165,10 +177,10 @@ class backup_migrate_destination_filesource extends backup_migrate_source {
$tar->extractModify($temp, $file->name);
// Older B&M Files format included a base 'files' directory.
- if (file_exists($temp .'/files')) {
+ if (file_exists($temp . '/files')) {
$temp = $temp . '/files';
}
- if (file_exists($temp .'/'. $file->name .'/files')) {
+ if (file_exists($temp . '/' . $file->name . '/files')) {
$temp = $temp . '/files';
}
@@ -183,16 +195,16 @@ class backup_migrate_destination_filesource extends backup_migrate_source {
/**
* Restore to this source.
*/
- function _restore_from_file_cli($file, &$settings) {
+ public function _restore_from_file_cli($file, &$settings) {
if (!empty($settings->filters['use_cli']) && function_exists('backup_migrate_exec')) {
$temp = backup_migrate_temp_directory();
backup_migrate_exec("tar -C %temp -xf %input", array('%input' => $file->filepath(), '%temp' => $temp));
// Older B&M Files format included a base 'files' directory.
- if (file_exists($temp .'/files')) {
+ if (file_exists($temp . '/files')) {
$temp = $temp . '/files';
}
- if (file_exists($temp .'/'. $file->name .'/files')) {
+ if (file_exists($temp . '/' . $file->name . '/files')) {
$temp = $temp . '/files';
}
@@ -204,10 +216,13 @@ class backup_migrate_destination_filesource extends backup_migrate_source {
}
/**
- * Get a list of files to backup from the given set if dirs. Exclude any that match the array $exclude.
+ * Gets a list of files to backup from the given set if dirs.
+ *
+ * Exclude any that match the array $exclude.
*/
- function get_files_to_backup($dir, $settings, $exclude = array(), $base_dir = '') {
+ public function get_files_to_backup($dir, $settings, $exclude = array()) {
$out = $errors = array();
+
if (!file_exists($dir)) {
backup_migrate_backup_fail('Directory %dir does not exist.', array('%dir' => $dir), $settings);
return FALSE;
@@ -216,25 +231,25 @@ class backup_migrate_destination_filesource extends backup_migrate_source {
while (($file = readdir($handle)) !== FALSE) {
if ($file != '.' && $file != '..' && !in_array($file, $exclude)) {
$real = realpath($dir . '/' . $file);
- $path = str_replace($base_dir, '', $real);
// If the path is not excluded.
- if (!in_array($path, $exclude)) {
+ if (!in_array($real, $exclude)) {
if (is_dir($real)) {
- $subdir = $this->get_files_to_backup($real, $settings, $exclude, $base_dir);
- // If there was an error reading the subdirectory then abort the backup.
+ $subdir = $this->get_files_to_backup($real, $settings, $exclude);
+ // If there was an error reading the subdirectory then abort the
+ // backup.
if ($subdir === FALSE) {
closedir($handle);
return FALSE;
}
// If the directory is empty, add an empty directory.
if (count($subdir) == 0) {
- $out[] = $path;
+ $out[] = $real;
}
$out = array_merge($out, $subdir);
}
else {
if (is_readable($real)) {
- $out[] = $path;
+ $out[] = $real;
}
else {
$errors[] = $dir . '/' . $file;
@@ -272,30 +287,46 @@ class backup_migrate_destination_filesource extends backup_migrate_source {
}
/**
- * Break the excpluded paths string into a usable list of paths.
+ * Breaks the excluded paths string into a usable list of paths.
*/
- function get_excluded_paths($paths) {
+ public function get_excluded_paths($settings) {
+ $base_dir = $this->get_realpath() . '/';
+ $paths = empty($settings->filters['exclude_filepaths']) ? '' : $settings->filters['exclude_filepaths'];
$out = explode("\n", $paths);
foreach ($out as $key => $val) {
- $out[$key] = trim($val, "/ \t\r\n");
+ $path = trim($val, "/ \t\r\n");
+ // If the path specified is a stream url or absolute path add the
+ // normalized version.
+ if ($real = drupal_realpath($path)) {
+ $out[$key] = $real;
+ }
+ // If the path is a relative path add it.
+ elseif ($real = drupal_realpath($base_dir . $path)) {
+ $out[$key] = $real;
+ }
+ // Otherwise add it as is even though it probably won't match any files.
+ else {
+ $out[$key] = $path;
+ }
}
return $out;
}
/**
- * Check that the required libraries are installed.
+ * Checks that the required libraries are installed.
*/
- function check_libs() {
- $result = true;
- // Drupal 7 has Archive_Tar built in so there should be no need to include anything here.
+ public function check_libs() {
+ $result = TRUE;
+ // Drupal 7 has Archive_Tar built in so there should be no need to include
+ // anything here.
return $result;
}
- /**
+ /**
* Get the file location.
*/
- function get_realpath() {
+ public function get_realpath() {
return drupal_realpath($this->get_location());
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/sources.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.inc
index 6c650fa..bc164cf 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/sources.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.inc
@@ -1,6 +1,5 @@
array(
'type_name' => t('Database'),
'description' => t('Import the backup directly into another database. Database sources can also be used as a source to backup from.'),
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/sources.db.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/sources.db.inc',
'class' => 'backup_migrate_source_db',
'can_create' => FALSE,
),
'mysql' => array(
'type_name' => t('MySQL Database'),
'description' => t('Import the backup directly into another MySQL database. Database sources can also be used as a source to backup from.'),
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/sources.db.mysql.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/sources.db.mysql.inc',
'class' => 'backup_migrate_source_db_mysql',
'can_create' => TRUE,
),
'filesource' => array(
'description' => t('A files directory which can be backed up from.'),
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/sources.filesource.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/sources.filesource.inc',
'class' => 'backup_migrate_destination_filesource',
'type_name' => t('File Directory'),
'can_create' => TRUE,
),
'archive' => array(
'description' => t('Create an archive of your entire site.'),
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/sources.archivesource.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/sources.archivesource.inc',
'class' => 'backup_migrate_files_destination_archivesource',
'type_name' => t('Site Archive'),
'can_create' => FALSE,
@@ -80,12 +79,12 @@ function backup_migrate_backup_migrate_source_subtypes() {
}
/**
- * Implementation of hook_backup_migrate_sources().
+ * Implements hook_backup_migrate_sources().
*
* Get the built in backup sources and those in the db.
*/
function backup_migrate_backup_migrate_sources() {
- $out = array();
+ $out = array();
// Expose the configured databases as sources.
backup_migrate_include('filters');
@@ -153,17 +152,19 @@ function _backup_migrate_get_source_form_item_options() {
* A base class for creating sources.
*/
class backup_migrate_source extends backup_migrate_location {
- var $db_table = "backup_migrate_sources";
- var $type_name = 'source';
- var $singular = 'source';
- var $plural = 'sources';
- var $title_plural = 'Sources';
- var $title_singular = 'Source';
+ public $db_table = "backup_migrate_sources";
+ public $type_name = 'source';
+ public $singular = 'source';
+ public $plural = 'sources';
+ public $title_plural = 'Sources';
+ public $title_singular = 'Source';
/**
- * This function is not supposed to be called. It is just here to help the po extractor out.
+ * This function is not supposed to be called.
+ *
+ * It is just here to help out the po extractor.
*/
- function strings() {
+ public function strings() {
// Help the pot extractor find these strings.
t('source');
t('sources');
@@ -174,7 +175,7 @@ class backup_migrate_source extends backup_migrate_location {
/**
* Get the available location types.
*/
- function location_types() {
+ public function location_types() {
return backup_migrate_get_source_subtypes();
}
@@ -184,32 +185,33 @@ class backup_migrate_source extends backup_migrate_location {
* A base class for creating sources.
*/
class backup_migrate_source_remote extends backup_migrate_source {
+
/**
* The location is a URI so parse it and store the parts.
*/
- function get_location() {
+ public function get_location() {
return $this->url(FALSE);
}
/**
* The location to display is the url without the password.
*/
- function get_display_location() {
+ public function get_display_location() {
return $this->url(TRUE);
}
/**
- * Return the location with the password.
+ * Returns the location with the password.
*/
- function set_location($location) {
+ public function set_location($location) {
$this->location = $location;
$this->set_url($location);
}
/**
- * source configuration callback.
+ * Source configuration callback.
*/
- function edit_form() {
+ public function edit_form() {
$form = parent::edit_form();
$form['scheme'] = array(
"#type" => "textfield",
@@ -251,18 +253,21 @@ class backup_migrate_source_remote extends backup_migrate_source {
"#type" => "value",
"#value" => @$this->dest_url['pass'],
);
- $form['pass']["#description"] .= t(' You do not need to enter a password unless you wish to change the currently saved password.');
+ $form['pass']["#description"] .= t('You do not need to enter a password unless you wish to change the currently saved password.');
}
return $form;
}
/**
- * Submit the configuration form. Glue the url together and add the old password back if a new one was not specified.
+ * Submits the configuration form.
+ *
+ * Glue the url together and add the old password back if a new one was not
+ * specified.
*/
- function edit_form_submit($form, &$form_state) {
+ public function edit_form_submit($form, &$form_state) {
$form_state['values']['pass'] = $form_state['values']['pass'] ? $form_state['values']['pass'] : $form_state['values']['old_password'];
$form_state['values']['location'] = $this->glue_url($form_state['values'], FALSE);
parent::edit_form_submit($form, $form_state);
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestBase.test b/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestBase.test
new file mode 100644
index 0000000..ad9663b
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestBase.test
@@ -0,0 +1,246 @@
+ $password,
+ );
+ user_save($account, $edit);
+ $account->pass_raw = $password;
+
+ // Login.
+ $this->drupalLogin($account);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function verbose($message, $title = NULL) {
+ // Handle arrays, objects, etc.
+ if (!is_string($message)) {
+ $message = "
\n" . print_r($message, TRUE) . "\n
\n";
+ }
+
+ // Optional title to go before the output.
+ if (!empty($title)) {
+ $title = '
' . check_plain($title) . "
\n";
+ }
+
+ parent::verbose($title . $message);
+ }
+
+ /**
+ * Confirm that a selector has the expected items.
+ */
+ protected function assertSelectOptions($select_id, array $options, $message = '') {
+ $elements = $this
+ ->xpath('//select[@id=:id]//option', array(
+ ':id' => $select_id,
+ ));
+ $results = $this->assertEqual(count($elements), count($options), t('The same number of items were found as were requested'));
+ $this->verbose($elements);
+
+ foreach ($options as $option) {
+ $elements = $this
+ ->xpath('//select[@id=:id]//option[@value=:option]', array(
+ ':id' => $select_id,
+ ':option' => $option,
+ ));
+ $this->verbose($elements);
+ $results *= $this->assertTrue(isset($elements[0]), $message ? $message : t('Option @option for field @id is present.', array(
+ '@option' => $option,
+ '@id' => $select_id,
+ )), t('Browser'));
+ }
+
+ return $results;
+ }
+
+ /**
+ * Confirm that a specific selector does not have items selected.
+ */
+ protected function assertNoOptionsSelected($id, $message = '') {
+ $elements = $this
+ ->xpath('//select[@id=:id]//option[@selected="selected"]', array(
+ ':id' => $id,
+ ));
+ return $this
+ ->assertTrue(!isset($elements[0]), $message ? $message : t('Field @id does not have any selected items.', array(
+ '@id' => $id,
+ )), t('Browser'));
+ }
+
+ /**
+ * Work out which compressor systems are supported by PHP.
+ *
+ * @return array
+ * The list of supported compressors. Will always include the item 'none'.
+ */
+ protected function supportedCompressors() {
+ $items = array('none');
+
+ // Work out which systems are supported.
+ if (@function_exists("gzencode")) {
+ $items[] = 'gzip';
+ }
+ if (@function_exists("bzcompress")) {
+ $items[] = 'bzip';
+ }
+ if (class_exists('ZipArchive')) {
+ $items[] = 'zip';
+ }
+
+ return $items;
+ }
+
+ /**
+ * Get a list of the files in a specific destination.
+ *
+ * @param string $destination_id
+ * The ID of the destination to check. Defaults to the manual file path.
+ *
+ * @return array
+ * The backup files found in the requested backup destination.
+ */
+ protected function listBackupFiles($destination_id = 'manual') {
+ $items = array();
+
+ backup_migrate_include('destinations');
+
+ // Load the destination object.
+ $destination = backup_migrate_get_destination($destination_id);
+ if (!empty($destination)) {
+ $items = $destination->list_files();
+ }
+
+ return $items;
+ }
+
+ /**
+ * Run a specific backup.
+ *
+ * @param string $destination_id
+ * The ID of the destination to check. Defaults to the manual file path.
+ */
+ protected function runBackup($destination_id = 'manual') {
+ $this->drupalGet(BACKUP_MIGRATE_MENU_PATH);
+ $this->assertResponse(200);
+ $edit = array(
+ 'destination_id' => $destination_id,
+ );
+ $this->drupalPost(NULL, $edit, 'Backup now');
+ $this->assertResponse(200);
+ // Confirm the response is as expected. This is split up into separate
+ // pieces because it'd be more effort than is necessary right now to confirm
+ // what the exact filename is.
+ $this->assertText('Default Database backed up successfully');
+ $this->assertText('in destination');
+ $this->assertLink('download');
+ $this->assertLink('restore');
+ $this->assertLink('delete');
+ }
+
+ /**
+ * Delete all of the files in a specific backup destination.
+ *
+ * @param string $destination_id
+ * The ID of the destination to check. Defaults to the manual file path.
+ */
+ protected function deleteBackups($destination_id = 'manual') {
+ $destination = backup_migrate_get_destination($destination_id);
+ $files = $this->listBackupFiles($destination_id);
+ if (!empty($files)) {
+ foreach ($files as $file_id => $file) {
+ $destination->delete_file($file_id);
+ }
+ }
+ }
+
+ /**
+ * Work out whether a backup filename includes a timestamp.
+ *
+ * @param object $file
+ * The backup file to examine.
+ *
+ * @return mixed
+ * Returns 1 if found, 0 if not found, FALSE if an error occurs.
+ */
+ protected function fileHasTimestamp($file) {
+ // Get the default filename, this is used later.
+ backup_migrate_include('files');
+ $default_filename = _backup_migrate_default_filename();
+ $ext = implode('.', $file->ext);
+ $pattern = "/{$default_filename}-(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d)-(\d\d)-(\d\d).{$ext}/";
+
+ return preg_match($pattern, $file->file_info['filename']);
+ }
+
+ /**
+ * Confirm that a backup filename includes a timestamp.
+ *
+ * @param object $file
+ * The backup file to examine.
+ *
+ * @return bool
+ * Indicates whether the file includes a timestamp.
+ */
+ protected function assertFileTimestamp($file) {
+ return $this->assertTrue($this->fileHasTimestamp($file));
+ }
+
+ /**
+ * Confirm that a backup filename does not include a timestamp.
+ *
+ * @param object $file
+ * The backup file to examine.
+ *
+ * @return bool
+ * Indicates whether the file does not include a timestamp.
+ */
+ protected function assertNoFileTimestamp($file) {
+ return !$this->assertFalse($this->fileHasTimestamp($file));
+ }
+
+ /**
+ * Get a profile.
+ *
+ * @param string $profile_id
+ * The name of the profile to load. Defaults to 'default'.
+ *
+ * @return object
+ * The profile object.
+ */
+ protected function getProfile($profile_id = 'default') {
+ backup_migrate_include('profiles');
+ return backup_migrate_get_profile($profile_id);
+ }
+
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestBasics.test b/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestBasics.test
new file mode 100644
index 0000000..d6ed7fb
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestBasics.test
@@ -0,0 +1,111 @@
+ 'Basic tests',
+ 'description' => 'Run through basic scenarios and functionality.',
+ 'group' => 'backup_migrate',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp(array $modules = array()) {
+ parent::setUp($modules);
+
+ // Log in as user 1, so that permissions are irrelevant.
+ $this->loginUser1();
+ }
+
+ /**
+ * Verify the main page has the expected functionality available.
+ */
+ public function testMainPage() {
+ // Load the main B&M page.
+ $this->drupalGet(BACKUP_MIGRATE_MENU_PATH);
+ $this->assertResponse(200);
+
+ // @todo Confirm each of the tabs are present.
+ // @todo Confirm each of the local tasks are present.
+ // Confirm the form has the expected fields.
+ $this->assertFieldByName('source_id');
+ $this->assertFieldByName('destination_id');
+ $this->assertFieldByName('profile_id');
+ $this->assertFieldByName('copy');
+ $this->assertFieldByName('copy_destination_id');
+ $this->assertFieldByName('description_enabled');
+ // This item should not have a value "selected", it just defaults to the
+ // first item being the active item.
+ $items = array('db', 'files', 'archive');
+ $this->assertSelectOptions('edit-source-id', $items);
+ $this->assertNoOptionsSelected('edit-source-id');
+ // This item should have a value "selected", not just the first item.
+ $items = array('manual', 'download', 'nodesquirrel');
+ $this->assertSelectOptions('edit-destination-id', $items);
+ $this->assertOptionSelected('edit-destination-id', 'download');
+ // This item should not have a value "selected", it just defaults to the
+ // first item being the active item.
+ $items = array('default');
+ $this->assertSelectOptions('edit-profile-id', $items);
+ $this->assertNoOptionsSelected('edit-profile-id');
+ // This item should not have a value "selected", it just defaults to the
+ // first item being the active item.
+ $items = array('manual', 'download', 'nodesquirrel');
+ $this->assertSelectOptions('edit-copy-destination-id', $items);
+ $this->assertNoOptionsSelected('edit-copy-destination-id');
+ }
+
+ /**
+ * Confirm the initial backup process works.
+ */
+ public function testFirstBackup() {
+ // Load the main B&M page.
+ $this->drupalGet(BACKUP_MIGRATE_MENU_PATH);
+ $this->assertResponse(200);
+
+ // Generate a backup and confirm it was created correctly.
+ $edit = array(
+ 'destination_id' => 'manual',
+ );
+ $this->drupalPost(NULL, $edit, 'Backup now');
+ $this->assertResponse(200);
+ // Confirm the response is as expected. This is split up into separate
+ // pieces because it'd be more effort than is necessary right now to confirm
+ // what the exact filename is.
+ $this->assertText('Default Database backed up successfully');
+ $this->assertText('in destination Manual Backups Directory');
+ $this->assertLink('download');
+ $this->assertLink('restore');
+ $this->assertLink('delete');
+
+ // Try requesting the backup file.
+ $xpath = $this
+ ->xpath('//a[normalize-space(text())=:label]', array(
+ ':label' => 'download',
+ ));
+ $this->verbose($xpath);
+ $this->assertTrue(isset($xpath[0]['href']));
+ $this->assertNotNull($xpath[0]['href']);
+ // @todo This doesn't work on drupalci, so work out how to fix it.
+ // $this->drupalGet($xpath[0]['href']);
+ $this->assertResponse(200);
+ }
+
+}
+
+// @todo Test permissions.
+// @todo Test admin forms.
diff --git a/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestProfiles.test b/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestProfiles.test
new file mode 100644
index 0000000..c8be956
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestProfiles.test
@@ -0,0 +1,168 @@
+ 'Destination tests',
+ 'description' => 'Run through basic scenarios and functionality.',
+ 'group' => 'backup_migrate',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp(array $modules = array()) {
+ parent::setUp($modules);
+
+ // Log in as user 1, so that permissions are irrelevant.
+ $this->loginUser1();
+ }
+
+ /**
+ * Verify the profile page has the expected functionality available.
+ */
+ public function testProfilePage() {
+ // Load the main B&M page.
+ $this->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/settings');
+ $this->assertResponse(200);
+
+ // Confirm the page has the expected settings details.
+ $this->assertText('Settings Profiles');
+ $this->assertText('Default Settings');
+ $this->assertLink('Create a new settings profile');
+ }
+
+ /**
+ * Confirm adding a new backup process works.
+ */
+ public function testAddDefaultProfile() {
+ // Load the main B&M page.
+ $this->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/settings/profile/add');
+ $this->assertResponse(200);
+
+ backup_migrate_include('files', 'profiles');
+ $filename = _backup_migrate_default_filename();
+ $defaults = _backup_migrate_profile_default_profile();
+
+ // Verify all of the expected fields exist.
+ $this->assertFieldByName('name');
+ $this->assertFieldByName('name', 'Untitled Profile');
+ $this->assertFieldByName('machine_name');
+ $this->assertFieldByName('filename');
+ $this->assertFieldByName('filename', $filename);
+ // @todo Confirm all of the expected options are present.
+ $this->assertFieldByName('append_timestamp');
+ $this->assertFieldByName('timestamp_format');
+ $this->assertFieldByName('timestamp_format', $defaults['timestamp_format']);
+ $this->assertFieldByName('filters[compression]');
+ $items = $this->supportedCompressors();
+ $this->assertSelectOptions('edit-filters-compression', $items);
+ $this->assertOptionSelected('edit-filters-compression', 'gzip');
+ $this->assertFieldByName('filters[sources][db][exclude_tables][]');
+ $this->assertFieldByName('filters[sources][db][nodata_tables][]');
+ $this->assertFieldByName('filters[sources][db][utils_lock_tables]');
+ $this->assertFieldByName('filters[sources][files][exclude_filepaths]');
+ $this->assertFieldByName('filters[sources][archive][exclude_filepaths]');
+ $this->assertFieldByName('filters[utils_site_offline]');
+ $this->assertFieldByName('filters[utils_site_offline_message]');
+ $this->assertFieldByName('filters[utils_description]');
+ $this->assertFieldByName('filters[use_cli]');
+ $this->assertFieldByName('filters[ignore_errors]');
+ $this->assertFieldByName('filters[notify_success_enable]');
+ $this->assertFieldByName('filters[notify_success_email]');
+ $this->assertFieldByName('filters[notify_failure_enable]');
+ $this->assertFieldByName('filters[notify_failure_email]');
+ }
+
+ /**
+ * Confirm the backup filename processes work as expected.
+ */
+ public function testFilenameOptions() {
+ // Load the profile. This will be interacted with directly because otherwise
+ // the number of form fields will likely make it impossible to execute
+ // properly due to the max_input_vars setting defaulting to 1000.
+ $profile = $this->getProfile();
+
+ // Run a backup.
+ $this->runBackup();
+
+ // Confirm that there is only one file and it has a timestamp of some sort.
+ $files1 = $this->listBackupFiles();
+ $this->verbose($files1);
+ $this->assertTrue(count($files1) === 1, 'One backup file was found.');
+ $this->assertFileTimestamp(array_shift($files1));
+
+ // Run another backup.
+ $this->runBackup();
+
+ // Confirm that there are two backup files.
+ $files1b = $this->listBackupFiles();
+ $this->verbose($files1b);
+ $this->assertTrue(count($files1b) === 2, 'Two backup files were found.');
+
+ // Cleanup before the next test - purge existing backups.
+ $this->deleteBackups();
+
+ // Change settings to "create separate backups".
+ $profile->append_timestamp = 0;
+ $profile->save();
+
+ // Run a backup.
+ $this->runBackup();
+
+ // Confirm that separate files are retained.
+ $files2 = $this->listBackupFiles();
+ $this->verbose($files2);
+ $this->assertTrue(count($files2) === 1, 'One backup file was found.');
+ $this->assertNoFileTimestamp(array_shift($files2));
+
+ // Run another backup.
+ $this->runBackup();
+
+ // Confirm that separate files are retained.
+ $files2b = $this->listBackupFiles();
+ $this->verbose($files2b);
+ $this->assertTrue(count($files2b) === 2, 'Two backup files were found.');
+
+ // Cleanup before the next test - purge existing backups.
+ $this->deleteBackups();
+
+ // Change settings to "overwrite".
+ $profile->append_timestamp = 2;
+ $profile->save();
+
+ // Run a backup.
+ $this->runBackup();
+
+ // Confirm that a new file was created.
+ $files3 = $this->listBackupFiles();
+ $this->verbose($files3);
+ $this->assertTrue(count($files3) === 1, 'One backup file was found.');
+ $this->assertNoFileTimestamp(array_shift($files3));
+
+ // Run the backup again.
+ $this->runBackup();
+
+ // Confirm that a new file was not created.
+ $files3b = $this->listBackupFiles();
+ $this->verbose($files3b);
+ $this->assertTrue(count($files3b) === 1, 'One backup file was found.');
+
+ // Cleanup - purge all backups.
+ $this->deleteBackups();
+ }
+
+}
diff --git a/sites/all/modules/contrib/admin/context/context.core.inc b/sites/all/modules/contrib/admin/context/context.core.inc
index 41ed93a..9e19831 100644
--- a/sites/all/modules/contrib/admin/context/context.core.inc
+++ b/sites/all/modules/contrib/admin/context/context.core.inc
@@ -94,11 +94,27 @@ function context_theme_registry_alter(&$theme_registry) {
*/
function context_ctools_render_alter($info, $page, $data) {
extract($data);
- if ($page && in_array($task['name'], array('node_view', 'node_edit'), TRUE)) {
- foreach ($contexts as $ctools_context) {
- if (in_array('node', $ctools_context->type) && !empty($ctools_context->data)) {
- context_node_condition($ctools_context->data, $task['name'] === 'node_view' ? 'view' : 'form');
- break;
+
+ // Check for page handlers.
+ if ($page) {
+ // Check for node page handler.
+ if (in_array($task['name'], array('node_view', 'node_edit'), TRUE)) {
+ foreach ($contexts as $ctools_context) {
+ if (in_array('node', $ctools_context->type) && !empty($ctools_context->data)) {
+ context_node_condition($ctools_context->data, $task['name'] === 'node_view' ? 'view' : 'form');
+ break;
+ }
+ }
+ }
+ // Check for taxonomy term page handler.
+ elseif (in_array($task['name'], array('term_view', 'term_edit'), TRUE)) {
+ foreach ($contexts as $ctools_context) {
+ if (in_array('taxonomy_term', $ctools_context->type) && !empty($ctools_context->data)) {
+ if ($plugin = context_get_plugin('condition', 'taxonomy_term')) {
+ $plugin->execute($ctools_context->data, $task['name'] === 'term_view' ? 'view' : 'form');
+ }
+ break;
+ }
}
}
}
diff --git a/sites/all/modules/contrib/admin/context/context.info b/sites/all/modules/contrib/admin/context/context.info
index a980c87..eef3a9c 100644
--- a/sites/all/modules/contrib/admin/context/context.info
+++ b/sites/all/modules/contrib/admin/context/context.info
@@ -8,9 +8,8 @@ files[] = tests/context.test
files[] = tests/context.conditions.test
files[] = tests/context.reactions.test
-; Information added by Drupal.org packaging script on 2015-01-06
-version = "7.x-3.6"
+; Information added by Drupal.org packaging script on 2019-02-26
+version = "7.x-3.10"
core = "7.x"
project = "context"
-datestamp = "1420573188"
-
+datestamp = "1551220089"
diff --git a/sites/all/modules/contrib/admin/context/context.install b/sites/all/modules/contrib/admin/context/context.install
index 0a5a145..0d902ef 100644
--- a/sites/all/modules/contrib/admin/context/context.install
+++ b/sites/all/modules/contrib/admin/context/context.install
@@ -103,7 +103,7 @@ function context_update_7000() {
}
}
if (empty($updated)) {
- $ret = t('No contexts requiring migration detected');
+ $ret = t('No contexts requiring migration detected.');
}
else {
$ret = t('The following contexts had theme reaction data migrated: @names', array('@names' => join(', ', $updated)));
diff --git a/sites/all/modules/contrib/admin/context/context.module b/sites/all/modules/contrib/admin/context/context.module
index 96808dd..c83b15e 100644
--- a/sites/all/modules/contrib/admin/context/context.module
+++ b/sites/all/modules/contrib/admin/context/context.module
@@ -192,11 +192,66 @@ function context_init() {
* theme('menu_link') for the menu rendering to html.
*/
function context_preprocess_menu_link(&$variables) {
- if($contexts = context_active_contexts()){
- foreach($contexts as $context){
- if((isset($context->reactions['menu']))){
- if ($variables['element']['#href'] == $context->reactions['menu']) {
- $variables['element']['#localized_options']['attributes']['class'][] = "active";
+ if ($contexts = context_active_contexts()) {
+ foreach ($contexts as $context) {
+ if (isset($context->reactions['menu'])) {
+ // In context module < v3.2 the url was a string. In version 3.3+ this is
+ // an array of urls. Implement interims BC layer.
+ //
+ // Examples:
+ // - OLD < v3.2 context reaction structure:
+ // array('menu' => 'taxonomy/term/1')
+ //
+ // - NEW 3.3+ context reaction structure:
+ // array(
+ // 'menu' => array(
+ // 0 => 'navigation:taxonomy/term/1'
+ // 1 => 'foo-menu:taxonomy/term/1'
+ // )
+ // )
+ $reactions_menu = is_array($context->reactions['menu']) ? array_values($context->reactions['menu']) : array($context->reactions['menu']);
+
+ // Get everything after the first ':' character (if found) as the url to
+ // match against element '#href'.
+ $urls = array();
+ foreach ($reactions_menu as $url) {
+ if (strpos($url, ':') !== FALSE) {
+ // Get unique menu name 'navigation' from 'navigation:taxonomy/term/1'
+ $reaction_menu = explode(':', $url);
+ $path = $reaction_menu[1];
+ $urls[$path] = $reaction_menu[0];
+ }
+ else {
+ // BC layer for menu contexts that have not re-saved. This is for
+ // urls like 'taxonomy/term/1'. We need to add a fake menu key
+ // 'bc-context-menu-layer' or the BC link get's removed by
+ // array_intersect below.
+ //
+ // @TODO: Remove BC layer in 4.x
+ $urls[$url] = 'context-reaction-menu-bc-layer';
+ }
+ }
+
+ // Filter urls by the menu name of the current link. The link reaction
+ // can be configured per menu link in specific menus and the contect
+ // reaction should not applied to other menus with the same menu link.
+ $menu_name = $variables['element']['#original_link']['menu_name'];
+ $menu_paths = array_intersect($urls, array($menu_name, 'context-reaction-menu-bc-layer'));
+ $reaction_menu_paths = array_keys($menu_paths);
+
+ // - If menu href and context reaction menu url match, add the 'active'
+ // css class to the link of this menu.
+ // - Do not add class twice on current page.
+ if (in_array($variables['element']['#href'], $reaction_menu_paths) && $variables['element']['#href'] != $_GET['q']) {
+ // Initialize classes array if not set.
+ if (!isset($variables['element']['#localized_options']['attributes']['class'])) {
+ $variables['element']['#localized_options']['attributes']['class'] = array();
+ }
+
+ // Do not add the 'active' class twice in views tabs.
+ if (!in_array('active', $variables['element']['#localized_options']['attributes']['class'])) {
+ $variables['element']['#localized_options']['attributes']['class'][] = 'active';
+ }
}
}
}
diff --git a/sites/all/modules/contrib/admin/context/context.plugins.inc b/sites/all/modules/contrib/admin/context/context.plugins.inc
index a0849bb..95d003d 100644
--- a/sites/all/modules/contrib/admin/context/context.plugins.inc
+++ b/sites/all/modules/contrib/admin/context/context.plugins.inc
@@ -37,7 +37,7 @@ function _context_context_registry() {
'plugin' => 'context_condition_path',
),
'query_string' => array(
- 'title' => t('Query String'),
+ 'title' => t('Query string'),
'description' => t('Set this context when any of the query strings above match the page query string. Put each query string on a separate line. You can use the "*" character as a wildcard and ~ to exclude one or more query strings.'),
'plugin' => 'context_condition_query_string',
),
@@ -119,7 +119,7 @@ function _context_context_registry() {
'plugin' => 'context_reaction_template_suggestions',
),
'theme' => array(
- 'title' => t('Theme Page'),
+ 'title' => t('Theme page'),
'description' => t('Control page theme variables using context.'),
'plugin' => 'context_reaction_theme',
),
diff --git a/sites/all/modules/contrib/admin/context/context_layouts/context_layouts.info b/sites/all/modules/contrib/admin/context/context_layouts/context_layouts.info
index 5ddb2cf..65880e3 100644
--- a/sites/all/modules/contrib/admin/context/context_layouts/context_layouts.info
+++ b/sites/all/modules/contrib/admin/context/context_layouts/context_layouts.info
@@ -6,9 +6,8 @@ core = 7.x
files[] = plugins/context_layouts_reaction_block.inc
-; Information added by Drupal.org packaging script on 2015-01-06
-version = "7.x-3.6"
+; Information added by Drupal.org packaging script on 2019-02-26
+version = "7.x-3.10"
core = "7.x"
project = "context"
-datestamp = "1420573188"
-
+datestamp = "1551220089"
diff --git a/sites/all/modules/contrib/admin/context/context_ui/context_ui.info b/sites/all/modules/contrib/admin/context/context_ui/context_ui.info
index 0006699..e5d17f8 100644
--- a/sites/all/modules/contrib/admin/context/context_ui/context_ui.info
+++ b/sites/all/modules/contrib/admin/context/context_ui/context_ui.info
@@ -8,9 +8,8 @@ configure = admin/structure/context
files[] = context.module
files[] = tests/context_ui.test
-; Information added by Drupal.org packaging script on 2015-01-06
-version = "7.x-3.6"
+; Information added by Drupal.org packaging script on 2019-02-26
+version = "7.x-3.10"
core = "7.x"
project = "context"
-datestamp = "1420573188"
-
+datestamp = "1551220089"
diff --git a/sites/all/modules/contrib/admin/context/context_ui/context_ui.js b/sites/all/modules/contrib/admin/context/context_ui/context_ui.js
index 308164f..56aa62a 100644
--- a/sites/all/modules/contrib/admin/context/context_ui/context_ui.js
+++ b/sites/all/modules/contrib/admin/context/context_ui/context_ui.js
@@ -12,11 +12,11 @@ function DrupalContextPlugins(form) {
$('.context-plugin-list > li', this.form).each(function() {
var plugin = $(this).attr('class').split('context-plugin-')[1].split(' ')[0];
if ($(this).is('.disabled')) {
- $('.context-plugin-selector select option[value='+plugin+']', this.form).show();
+ $('.context-plugin-selector select option[value="'+plugin+'"]', this.form).show();
}
else {
state.push(plugin);
- $('.context-plugin-selector select option[value='+plugin+']', this.form).hide();
+ $('.context-plugin-selector select option[value="'+plugin+'"]', this.form).hide();
}
});
// Set the hidden plugin list state.
diff --git a/sites/all/modules/contrib/admin/context/context_ui/context_ui.module b/sites/all/modules/contrib/admin/context/context_ui/context_ui.module
index 2ed2aa6..d694870 100644
--- a/sites/all/modules/contrib/admin/context/context_ui/context_ui.module
+++ b/sites/all/modules/contrib/admin/context/context_ui/context_ui.module
@@ -81,7 +81,7 @@ function context_ui_permission() {
'description' => 'Associate menus, views, blocks, etc. with different contexts to structure your site.'
);
$permissions['context ajax block access'] = array(
- 'title' => t('Access All Blocks'),
+ 'title' => t('Access all blocks'),
'description' => t('Allows users to access all rendered blocks via an AJAX callback. If you have some blocks that should not be rendered for some users but need those users to be able to use context UI, then implement hook_context_allow_ajax_block_access with the necessary logic.'),
);
return $permissions;
@@ -143,7 +143,7 @@ function context_ui_editor($form, &$form_state, $contexts) {
$form['title'] = array(
'#prefix' => '
',
- '#markup' => t('Select the Context/Layer to Edit'),
+ '#markup' => t('Select the context/layer to edit'),
'#suffix' => '
',
'#weight' => -2,
);
@@ -151,10 +151,7 @@ function context_ui_editor($form, &$form_state, $contexts) {
//add some help text to the top of the form
$form['help'] = array (
'#prefix' => '
',
- '#markup' => t('Select which context, or layer of blocks, to edit.
- Each context is configured to appear on different sets of pages so read the description carefully.
- When you are done editing click Done and save your changes.
- You may use the Stop Editing Layout link to close the editor.'),
+ '#markup' => t('Select which context, or layer of blocks, to edit. Each context is configured to appear on different sets of pages so read the description carefully. When you are done editing click Done and save your changes. You may use the Stop Editing Layout link to close the editor.'),
'#suffix' => '
";
+ $output .= '';
$output .= theme('table', array('rows' => $rows, 'attributes' => $attr));
}
return $output;
@@ -100,14 +100,13 @@ function template_preprocess_context_block_browser(&$vars) {
//add help text to tell people how to use the block browser
$help_text = array(
'#prefix' => '
',
- '#markup' => t('To add a block to the current region, simply click on the block. You may use the category filter to filter by
- block type or the search filter to find the block that you wish to add.'),
+ '#markup' => t('To add a block to the current region, simply click on the block. You may use the category filter to filter by block type or the search filter to find the block that you wish to add.'),
'#suffix' => '
+
+Text format: Full HTML
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.admin.inc b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.admin.inc
index 4449077..2d8afa3 100644
--- a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.admin.inc
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.admin.inc
@@ -18,10 +18,17 @@ function googleanalytics_admin_settings_form($form_state) {
'#title' => t('Web Property ID'),
'#type' => 'textfield',
'#default_value' => variable_get('googleanalytics_account', 'UA-'),
- '#size' => 15,
+ '#size' => 20,
'#maxlength' => 20,
'#required' => TRUE,
- '#description' => t('This ID is unique to each site you want to track separately, and is in the form of UA-xxxxxxx-yy. To get a Web Property ID, register your site with Google Analytics, or if you already have registered your site, go to your Google Analytics Settings page to see the ID next to every site profile. Find more information in the documentation.', array('@analytics' => 'http://www.google.com/analytics/', '@webpropertyid' => url('https://developers.google.com/analytics/resources/concepts/gaConceptsAccounts', array('fragment' => 'webProperty')))),
+ '#description' => t('This ID is unique to each site you want to track separately, and is in the form of UA-xxxxxxx-yy. To get a Web Property ID, register your site with Google Analytics, or if you already have registered your site, go to your Google Analytics Settings page to see the ID next to every site profile. Find more information in the documentation.', array('@analytics' => 'https://marketingplatform.google.com/about/analytics/', '@webpropertyid' => url('https://developers.google.com/analytics/resources/concepts/gaConceptsAccounts', array('fragment' => 'webProperty')))),
+ );
+
+ $form['account']['googleanalytics_premium'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Premium account'),
+ '#description' => t('If you are a Google Analytics Premium customer, you can use up to 200 instead of 20 custom dimensions and metrics.'),
+ '#default_value' => variable_get('googleanalytics_premium', FALSE),
);
// Visibility settings.
@@ -169,7 +176,7 @@ function googleanalytics_admin_settings_form($form_state) {
'#type' => 'fieldset',
'#title' => t('Users'),
);
- $t_permission = array('%permission' => t('opt-in or out of tracking'));
+ $t_permission = array('%permission' => t('Opt-in or out of tracking'));
$form['tracking']['user_vis_settings']['googleanalytics_custom'] = array(
'#type' => 'radios',
'#title' => t('Allow users to customize tracking on their account page'),
@@ -224,6 +231,18 @@ function googleanalytics_admin_settings_form($form_state) {
),
),
);
+
+ $colorbox_dependencies = '
';
+
+ $form['tracking']['linktracking']['googleanalytics_trackcolorbox'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Track content in colorbox modal dialogs'),
+ '#default_value' => variable_get('googleanalytics_trackcolorbox', 1),
+ '#description' => t('Enable to track the content shown in colorbox modal windows.') . $colorbox_dependencies,
+ '#disabled' => (module_exists('colorbox') ? FALSE : TRUE),
+ );
$form['tracking']['linktracking']['googleanalytics_tracklinkid'] = array(
'#type' => 'checkbox',
'#title' => t('Track enhanced link attribution'),
@@ -246,7 +265,7 @@ function googleanalytics_admin_settings_form($form_state) {
'#type' => 'checkboxes',
'#title' => t('Track messages of type'),
'#default_value' => variable_get('googleanalytics_trackmessages', array()),
- '#description' => t('This will track the selected message types shown to users. Tracking of form validation errors may help you identifying usability issues in your site. For each visit (user session), a maximum of approximately 500 combined GATC requests (both events and page views) can be tracked. Every message is tracked as one individual event. Note that - as the number of events in a session approaches the limit - additional events might not be tracked. Messages from excluded pages cannot tracked.'),
+ '#description' => t('This will track the selected message types shown to users. Tracking of form validation errors may help you identifying usability issues in your site. For each visit (user session), a maximum of approximately 500 combined GATC requests (both events and page views) can be tracked. Every message is tracked as one individual event. Note that - as the number of events in a session approaches the limit - additional events might not be tracked. Messages from excluded pages cannot be tracked.'),
'#options' => array(
'status' => t('Status message'),
'warning' => t('Warning message'),
@@ -297,7 +316,7 @@ function googleanalytics_admin_settings_form($form_state) {
$form['tracking']['privacy']['googleanalytics_privacy_donottrack'] = array(
'#type' => 'checkbox',
'#title' => t('Universal web tracking opt-out'),
- '#description' => t('If enabled and your server receives the Do-Not-Track header from the client browser, the Google Analytics module will not embed any tracking code into your site. Compliance with Do Not Track could be purely voluntary, enforced by industry self-regulation, or mandated by state or federal law. Please accept your visitors privacy. If they have opt-out from tracking and advertising, you should accept their personal decision. This feature is currently limited to logged in users and disabled page caching.', array('@donottrack' => 'http://donottrack.us/')),
+ '#description' => t('If enabled and your server receives the Do-Not-Track header from the client browser, the Google Analytics module will not embed any tracking code into your site. Compliance with Do Not Track could be purely voluntary, enforced by industry self-regulation, or mandated by state or federal law. Please accept your visitors privacy. If they have opt-out from tracking and advertising, you should accept their personal decision. This feature is currently limited to logged in users and disabled page caching.', array('@donottrack' => 'https://www.eff.org/issues/do-not-track')),
'#default_value' => variable_get('googleanalytics_privacy_donottrack', 1),
);
@@ -305,7 +324,7 @@ function googleanalytics_admin_settings_form($form_state) {
$form['googleanalytics_custom_dimension'] = array(
'#collapsed' => TRUE,
'#collapsible' => TRUE,
- '#description' => t('You can set values for Google Analytics Custom Dimensions here. You must have already configured your custom dimensions in the Google Analytics Management Interface. You may use tokens. Global and user tokens are always available; on node pages, node tokens are also available. A dimension value is allowed to have a maximum lenght of 150 bytes. Expect longer values to get trimmed.', array('@custom_var_documentation' => 'https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets', '@setup_documentation' => 'https://support.google.com/analytics/answer/2709829')),
+ '#description' => t('You can set values for Google Analytics Custom Dimensions here. You must have already configured your custom dimensions in the Google Analytics Management Interface. You may use tokens. Global and user tokens are always available; on node pages, node tokens are also available. A dimension value is allowed to have a maximum length of 150 bytes. Expect longer values to get trimmed.', array('@custom_var_documentation' => 'https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets', '@setup_documentation' => 'https://support.google.com/analytics/answer/2709829')),
'#theme' => 'googleanalytics_admin_custom_var_table',
'#title' => t('Custom dimensions'),
'#tree' => TRUE,
@@ -314,8 +333,10 @@ function googleanalytics_admin_settings_form($form_state) {
$googleanalytics_custom_dimension = variable_get('googleanalytics_custom_dimension', array());
- // Google Analytics supports up to 20 custom dimensions.
- for ($i = 1; $i <= 20; $i++) {
+ // Standard Google Analytics accounts support up to 20 custom dimensions,
+ // premium accounts support up to 200 custom dimensions.
+ $limit = (variable_get('googleanalytics_premium', FALSE)) ? 200 : 20;
+ for ($i = 1; $i <= $limit; $i++) {
$form['googleanalytics_custom_dimension']['indexes'][$i]['index'] = array(
'#default_value' => $i,
'#description' => t('Index number'),
@@ -342,7 +363,7 @@ function googleanalytics_admin_settings_form($form_state) {
$form['googleanalytics_custom_dimension']['googleanalytics_description'] = array(
'#type' => 'item',
- '#description' => t('You can supplement Google Analytics\' basic IP address tracking of visitors by segmenting users based on custom dimensions. Section 7 of the Google Analytics terms of service requires that You will not (and will not allow any third party to) use the Service to track, collect or upload any data that personally identifies an individual (such as a name, userid, email address or billing information), or other data which can be reasonably linked to such information by Google. You will have and abide by an appropriate Privacy Policy and will comply with all applicable laws and regulations relating to the collection of information from Visitors. You must post a Privacy Policy and that Privacy Policy must provide notice of Your use of cookies that are used to collect traffic data, and You must not circumvent any privacy features (e.g., an opt-out) that are part of the Service.', array('@ga_tos' => 'http://www.google.com/analytics/terms/gb.html')),
+ '#description' => t('You can supplement Google Analytics\' basic IP address tracking of visitors by segmenting users based on custom dimensions. Section 7 of the Google Analytics terms of service requires that You will not (and will not allow any third party to) use the Service to track, collect or upload any data that personally identifies an individual (such as a name, userid, email address or billing information), or other data which can be reasonably linked to such information by Google. You will have and abide by an appropriate Privacy Policy and will comply with all applicable laws and regulations relating to the collection of information from Visitors. You must post a Privacy Policy and that Privacy Policy must provide notice of Your use of cookies that are used to collect traffic data, and You must not circumvent any privacy features (e.g., an opt-out) that are part of the Service.', array('@ga_tos' => 'https://www.google.com/analytics/terms/gb.html')),
);
if (module_exists('token')) {
$form['googleanalytics_custom_dimension']['googleanalytics_token_tree'] = array(
@@ -365,8 +386,9 @@ function googleanalytics_admin_settings_form($form_state) {
$googleanalytics_custom_metric = variable_get('googleanalytics_custom_metric', array());
- // Google Analytics supports up to 20 custom metrics.
- for ($i = 1; $i <= 20; $i++) {
+ // Standard Google Analytics accounts support up to 20 custom metrics,
+ // premium accounts support up to 200 custom metrics.
+ for ($i = 1; $i <= $limit; $i++) {
$form['googleanalytics_custom_metric']['indexes'][$i]['index'] = array(
'#default_value' => $i,
'#description' => t('Index number'),
@@ -393,7 +415,7 @@ function googleanalytics_admin_settings_form($form_state) {
$form['googleanalytics_custom_metric']['googleanalytics_description'] = array(
'#type' => 'item',
- '#description' => t('You can supplement Google Analytics\' basic IP address tracking of visitors by segmenting users based on custom metrics. Section 7 of the Google Analytics terms of service requires that You will not (and will not allow any third party to) use the Service to track, collect or upload any data that personally identifies an individual (such as a name, userid, email address or billing information), or other data which can be reasonably linked to such information by Google. You will have and abide by an appropriate Privacy Policy and will comply with all applicable laws and regulations relating to the collection of information from Visitors. You must post a Privacy Policy and that Privacy Policy must provide notice of Your use of cookies that are used to collect traffic data, and You must not circumvent any privacy features (e.g., an opt-out) that are part of the Service.', array('@ga_tos' => 'http://www.google.com/analytics/terms/gb.html')),
+ '#description' => t('You can supplement Google Analytics\' basic IP address tracking of visitors by segmenting users based on custom metrics. Section 7 of the Google Analytics terms of service requires that You will not (and will not allow any third party to) use the Service to track, collect or upload any data that personally identifies an individual (such as a name, userid, email address or billing information), or other data which can be reasonably linked to such information by Google. You will have and abide by an appropriate Privacy Policy and will comply with all applicable laws and regulations relating to the collection of information from Visitors. You must post a Privacy Policy and that Privacy Policy must provide notice of Your use of cookies that are used to collect traffic data, and You must not circumvent any privacy features (e.g., an opt-out) that are part of the Service.', array('@ga_tos' => 'https://www.google.com/analytics/terms/gb.html')),
);
if (module_exists('token')) {
$form['googleanalytics_custom_metric']['googleanalytics_token_tree'] = array(
@@ -428,12 +450,14 @@ function googleanalytics_admin_settings_form($form_state) {
);
}
+ $user_access_add_js_snippets = !user_access('add JS snippets for google analytics');
+ $user_access_add_js_snippets_permission_warning = $user_access_add_js_snippets ? ' ' . t('This field has been disabled because you do not have sufficient permissions to edit it.') . '' : '';
$form['advanced']['codesnippet'] = array(
'#type' => 'fieldset',
'#title' => t('Custom JavaScript code'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
- '#description' => t('You can add custom Google Analytics code snippets here. These will be added every time tracking is in effect. Before you add your custom code, you should read the Google Analytics Tracking Code - Functional Overview and the Google Analytics Tracking API documentation. Do not include the <script> tags, and always end your code with a semicolon (;).', array('@snippets' => 'http://drupal.org/node/248699', '@ga_concepts_overview' => 'https://developers.google.com/analytics/resources/concepts/gaConceptsTrackingOverview', '@ga_js_api' => 'https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference')),
+ '#description' => t('You can add custom Google Analytics code snippets here. These will be added every time tracking is in effect. Before you add your custom code, you should read the Google Analytics Tracking Code - Functional Overview and the Google Analytics Tracking API documentation. Do not include the <script> tags, and always end your code with a semicolon (;).', array('@snippets' => 'https://drupal.org/node/248699', '@ga_concepts_overview' => 'https://developers.google.com/analytics/resources/concepts/gaConceptsTrackingOverview', '@ga_js_api' => 'https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference')),
);
$form['advanced']['codesnippet']['googleanalytics_codesnippet_create'] = array(
'#type' => 'textarea',
@@ -447,15 +471,17 @@ function googleanalytics_admin_settings_form($form_state) {
'#type' => 'textarea',
'#title' => t('Code snippet (before)'),
'#default_value' => variable_get('googleanalytics_codesnippet_before', ''),
+ '#disabled' => $user_access_add_js_snippets,
'#rows' => 5,
- '#description' => t('Code in this textarea will be added beforega("send", "pageview");.'),
+ '#description' => t('Code in this textarea will be added beforega("send", "pageview");.') . $user_access_add_js_snippets_permission_warning,
);
$form['advanced']['codesnippet']['googleanalytics_codesnippet_after'] = array(
'#type' => 'textarea',
'#title' => t('Code snippet (after)'),
'#default_value' => variable_get('googleanalytics_codesnippet_after', ''),
+ '#disabled' => $user_access_add_js_snippets,
'#rows' => 5,
- '#description' => t('Code in this textarea will be added afterga("send", "pageview");. This is useful if you\'d like to track a site in two accounts.'),
+ '#description' => t('Code in this textarea will be added afterga("send", "pageview");. This is useful if you\'d like to track a site in two accounts.') . $user_access_add_js_snippets_permission_warning,
);
$form['advanced']['googleanalytics_debug'] = array(
@@ -541,6 +567,12 @@ function googleanalytics_admin_settings_form_validate($form, &$form_state) {
/**
* Layout for the custom variables table in the admin settings form.
+ *
+ * @param array $variables
+ * An array contains the form elements.
+ *
+ * @return string
+ * The rendered output.
*/
function theme_googleanalytics_admin_custom_var_table($variables) {
$form = $variables['form'];
@@ -551,7 +583,7 @@ function theme_googleanalytics_admin_custom_var_table($variables) {
);
$rows = array();
- foreach (element_children($form['indexes']) as $key => $id) {
+ foreach (element_children($form['indexes']) as $id) {
$rows[] = array(
'data' => array(
drupal_render($form['indexes'][$id]['index']),
@@ -600,11 +632,18 @@ function googleanalytics_token_element_validate(&$element, &$form_state) {
return $element;
}
+/**
+ * @param array $value
+ * An array of token values.
+ *
+ * @return array
+ * A unique array of invalid tokens.
+ */
function _googleanalytics_get_forbidden_tokens($value) {
$invalid_tokens = array();
$value_tokens = is_string($value) ? token_scan($value) : $value;
- foreach ($value_tokens as $type => $tokens) {
+ foreach ($value_tokens as $tokens) {
if (array_filter($tokens, '_googleanalytics_contains_forbidden_token')) {
$invalid_tokens = array_merge($invalid_tokens, array_values($tokens));
}
@@ -617,8 +656,9 @@ function _googleanalytics_get_forbidden_tokens($value) {
/**
* Validate if a string contains forbidden tokens not allowed by privacy rules.
*
- * @param $token_string
+ * @param string $token_string
* A string with one or more tokens to be validated.
+ *
* @return boolean
* TRUE if blacklisted token has been found, otherwise FALSE.
*/
@@ -724,7 +764,7 @@ function _googleanalytics_extract_create_field_values($string) {
$list = array_map('trim', $list);
$list = array_filter($list, 'strlen');
- foreach ($list as $position => $text) {
+ foreach ($list as $text) {
// Check for an explicit key.
$matches = array();
if (preg_match('/(.*)\|(.*)/', $text, $matches)) {
@@ -755,16 +795,18 @@ function _googleanalytics_validate_create_field_name($name) {
// List of supported field names:
// https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#create
$create_only_fields = array(
- 'clientId',
- 'userId',
- 'sampleRate',
- 'siteSpeedSampleRate',
- 'alwaysSendReferrer',
'allowAnchor',
+ 'alwaysSendReferrer',
+ 'clientId',
'cookieName',
'cookieDomain',
'cookieExpires',
'legacyCookieDomain',
+ 'legacyHistoryImport',
+ 'sampleRate',
+ 'siteSpeedSampleRate',
+ 'storage',
+ 'useAmpClientId',
);
if ($name == 'name') {
@@ -773,6 +815,9 @@ function _googleanalytics_validate_create_field_name($name) {
if ($name == 'allowLinker') {
return t('Create only field name %name is a disallowed field name. Please select Multiple top-level domains under What are you tracking to enable cross domain tracking.', array('%name' => $name));
}
+ if ($name == 'userId') {
+ return t('Create only field name %name is a disallowed field name. Please enable Track User ID under Tracking scope > Users.', array('%name' => $name));
+ }
if (!in_array($name, $create_only_fields)) {
return t('Create only field name %name is an unknown field name. Field names are case sensitive. Please see create only fields documentation for supported field names.', array('%name' => $name, '@url' => 'https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#create'));
}
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.admin.js b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.admin.js
index 083eeaa..c81470d 100644
--- a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.admin.js
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.admin.js
@@ -65,6 +65,15 @@ Drupal.behaviors.trackingSettingsSummary = {
if ($('input#edit-googleanalytics-trackfiles', context).is(':checked')) {
vals.push(Drupal.t('Downloads'));
}
+ if ($('input#edit-googleanalytics-trackcolorbox', context).is(':checked')) {
+ vals.push(Drupal.t('Colorbox'));
+ }
+ if ($('input#edit-googleanalytics-tracklinkid', context).is(':checked')) {
+ vals.push(Drupal.t('Link attribution'));
+ }
+ if ($('input#edit-googleanalytics-trackurlfragments', context).is(':checked')) {
+ vals.push(Drupal.t('URL fragments'));
+ }
if (!vals.length) {
return Drupal.t('Not tracked');
}
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.debug.js b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.debug.js
index 861f7fd..7186230 100644
--- a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.debug.js
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.debug.js
@@ -8,16 +8,16 @@ $(document).ready(function() {
// clicks on all elements.
$(document.body).bind("mousedown keyup touchstart", function(event) {
console.group("Running Google Analytics for Drupal.");
- console.info(event);
+ console.info("Event '%s' has been detected.", event.type);
// Catch the closest surrounding link of a clicked element.
$(event.target).closest("a,area").each(function() {
- console.info("Element '%o' has been detected. Link '%s' found.", this, this.href);
+ console.info("Closest element '%o' has been found. URL '%s' extracted.", this, this.href);
// Is the clicked URL internal?
if (Drupal.googleanalytics.isInternal(this.href)) {
// Skip 'click' tracking, if custom tracking events are bound.
- if ($(this).is('.colorbox')) {
+ if ($(this).is('.colorbox') && (Drupal.settings.googleanalytics.trackColorbox)) {
// Do nothing here. The custom event will handle all tracking.
console.info("Click on .colorbox item has been detected.");
}
@@ -25,12 +25,22 @@ $(document).ready(function() {
else if (Drupal.settings.googleanalytics.trackDownload && Drupal.googleanalytics.isDownload(this.href)) {
// Download link clicked.
console.info("Download url '%s' has been found. Tracked download as extension '%s'.", Drupal.googleanalytics.getPageUrl(this.href), Drupal.googleanalytics.getDownloadExtension(this.href).toUpperCase());
- ga("send", "event", "Downloads", Drupal.googleanalytics.getDownloadExtension(this.href).toUpperCase(), Drupal.googleanalytics.getPageUrl(this.href));
+ ga("send", {
+ "hitType": "event",
+ "eventCategory": "Downloads",
+ "eventAction": Drupal.googleanalytics.getDownloadExtension(this.href).toUpperCase(),
+ "eventLabel": Drupal.googleanalytics.getPageUrl(this.href),
+ "transport": "beacon"
+ });
}
else if (Drupal.googleanalytics.isInternalSpecial(this.href)) {
// Keep the internal URL for Google Analytics website overlay intact.
console.info("Click on internal special link '%s' has been tracked.", Drupal.googleanalytics.getPageUrl(this.href));
- ga("send", "pageview", { "page": Drupal.googleanalytics.getPageUrl(this.href) });
+ ga("send", {
+ "hitType": "pageview",
+ "page": Drupal.googleanalytics.getPageUrl(this.href),
+ "transport": "beacon"
+ });
}
else {
// e.g. anchor in same page or other internal page link
@@ -41,13 +51,25 @@ $(document).ready(function() {
if (Drupal.settings.googleanalytics.trackMailto && $(this).is("a[href^='mailto:'],area[href^='mailto:']")) {
// Mailto link clicked.
console.info("Click on e-mail '%s' has been tracked.", this.href.substring(7));
- ga("send", "event", "Mails", "Click", this.href.substring(7));
+ ga("send", {
+ "hitType": "event",
+ "eventCategory": "Mails",
+ "eventAction": "Click",
+ "eventLabel": this.href.substring(7),
+ "transport": "beacon"
+ });
}
else if (Drupal.settings.googleanalytics.trackOutbound && this.href.match(/^\w+:\/\//i)) {
- if (Drupal.settings.googleanalytics.trackDomainMode != 2 || (Drupal.settings.googleanalytics.trackDomainMode == 2 && !Drupal.googleanalytics.isCrossDomain(this.hostname, Drupal.settings.googleanalytics.trackCrossDomains))) {
+ if (Drupal.settings.googleanalytics.trackDomainMode !== 2 || (Drupal.settings.googleanalytics.trackDomainMode === 2 && !Drupal.googleanalytics.isCrossDomain(this.hostname, Drupal.settings.googleanalytics.trackCrossDomains))) {
// External link clicked / No top-level cross domain clicked.
console.info("Outbound link '%s' has been tracked.", this.href);
- ga("send", "event", "Outbound links", "Click", this.href);
+ ga("send", {
+ "hitType": "event",
+ "eventCategory": "Outbound links",
+ "eventAction": "Click",
+ "eventLabel": this.href,
+ "transport": "beacon"
+ });
}
else {
console.info("Internal link '%s' clicked, not tracked.", this.href);
@@ -63,19 +85,27 @@ $(document).ready(function() {
if (Drupal.settings.googleanalytics.trackUrlFragments) {
window.onhashchange = function() {
console.info("Track URL '%s' as pageview. Hash '%s' has changed.", location.pathname + location.search + location.hash, location.hash);
- ga('send', 'pageview', location.pathname + location.search + location.hash);
- }
+ ga("send", {
+ "hitType": "pageview",
+ "page": location.pathname + location.search + location.hash
+ });
+ };
}
// Colorbox: This event triggers when the transition has completed and the
// newly loaded content has been revealed.
- $(document).bind("cbox_complete", function () {
- var href = $.colorbox.element().attr("href");
- if (href) {
- console.info("Colorbox transition to url '%s' has been tracked.", Drupal.googleanalytics.getPageUrl(href));
- ga("send", "pageview", { "page": Drupal.googleanalytics.getPageUrl(href) });
- }
- });
+ if (Drupal.settings.googleanalytics.trackColorbox) {
+ $(document).bind("cbox_complete", function () {
+ var href = $.colorbox.element().attr("href");
+ if (href) {
+ console.info("Colorbox transition to url '%s' has been tracked.", Drupal.googleanalytics.getPageUrl(href));
+ ga("send", {
+ "hitType": "pageview",
+ "page": Drupal.googleanalytics.getPageUrl(href)
+ });
+ }
+ });
+ }
});
@@ -92,7 +122,7 @@ $(document).ready(function() {
Drupal.googleanalytics.isCrossDomain = function (hostname, crossDomains) {
/**
* jQuery < 1.6.3 bug: $.inArray crushes IE6 and Chrome if second argument is
- * `null` or `undefined`, http://bugs.jquery.com/ticket/10076,
+ * `null` or `undefined`, https://bugs.jquery.com/ticket/10076,
* https://github.com/jquery/jquery/commit/a839af034db2bd934e4d4fa6758a3fed8de74174
*
* @todo: Remove/Refactor in D8
@@ -151,8 +181,8 @@ Drupal.googleanalytics.isInternalSpecial = function (url) {
* Extract the relative internal URL from an absolute internal URL.
*
* Examples:
- * - http://mydomain.com/node/1 -> /node/1
- * - http://example.com/foo/bar -> http://example.com/foo/bar
+ * - https://mydomain.com/node/1 -> /node/1
+ * - https://example.com/foo/bar -> https://example.com/foo/bar
*
* @param string url
* The web url to check.
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.info b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.info
index adbf134..591816a 100644
--- a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.info
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.info
@@ -5,9 +5,8 @@ package = Statistics
configure = admin/config/system/googleanalytics
files[] = googleanalytics.test
test_dependencies[] = token
-; Information added by Drupal.org packaging script on 2014-11-29
-version = "7.x-2.1"
+; Information added by Drupal.org packaging script on 2019-01-31
+version = "7.x-2.6"
core = "7.x"
project = "google_analytics"
-datestamp = "1417276982"
-
+datestamp = "1548968597"
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.install b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.install
index d7b2edf..08b4e05 100644
--- a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.install
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.install
@@ -10,6 +10,7 @@
*/
function googleanalytics_uninstall() {
variable_del('googleanalytics_account');
+ variable_del('googleanalytics_premium');
variable_del('googleanalytics_cache');
variable_del('googleanalytics_codesnippet_create');
variable_del('googleanalytics_codesnippet_before');
@@ -25,6 +26,7 @@ function googleanalytics_uninstall() {
variable_del('googleanalytics_roles');
variable_del('googleanalytics_site_search');
variable_del('googleanalytics_trackadsense');
+ variable_del('googleanalytics_trackcolorbox');
variable_del('googleanalytics_trackdoubleclick');
variable_del('googleanalytics_tracker_anonymizeip');
variable_del('googleanalytics_trackfiles');
@@ -40,7 +42,7 @@ function googleanalytics_uninstall() {
variable_del('googleanalytics_visibility_roles');
variable_del('googleanalytics_privacy_donottrack');
- // Remove backup variables if exist. Remove this code in D8.
+ // Remove backup variables if they exist. Remove this code in D8.
variable_del('googleanalytics_codesnippet_after_backup_7200');
variable_del('googleanalytics_codesnippet_before_backup_7200');
}
@@ -87,7 +89,8 @@ function googleanalytics_requirements($phase) {
}
/**
- * Upgrade old extension variable to new and use old name as enabled/disabled flag.
+ * Upgrade old extension variable to new and use old name as enabled/disabled
+ * flag.
*/
function googleanalytics_update_6000() {
variable_set('googleanalytics_trackfiles_extensions', variable_get('googleanalytics_trackfiles', '7z|aac|avi|csv|doc|exe|flv|gif|gz|jpe?g|js|mp(3|4|e?g)|mov|pdf|phps|png|ppt|rar|sit|tar|torrent|txt|wma|wmv|xls|xml|zip'));
@@ -100,7 +103,8 @@ function googleanalytics_update_6000() {
function googleanalytics_update_6001() {
variable_set('googleanalytics_visibility', 0);
- // Remove tracking from all administrative pages, see http://drupal.org/node/34970.
+ // Remove tracking from all administrative pages, see:
+ // https://drupal.org/node/34970.
$pages = array(
'admin*',
'user*',
@@ -113,11 +117,12 @@ function googleanalytics_update_6001() {
}
/**
- * Upgrade role settings and per user tracking settings
- * of "User 1" and remove outdated tracking variables.
+ * Upgrade role settings and per user tracking settings of "User 1" and remove
+ * outdated tracking variables.
*/
function googleanalytics_update_6002() {
- // Upgrade enabled/disabled roles to new logic (correct for upgrades from 5.x-1.4 and 6.x-1.0).
+ // Upgrade enabled/disabled roles to new logic (correct for upgrades from
+ // 5.x-1.4 and 6.x-1.0).
$roles = array();
$messages = array();
foreach (user_roles() as $rid => $name) {
@@ -136,7 +141,7 @@ function googleanalytics_update_6002() {
if (!$track_user1 = variable_get('googleanalytics_track__user1', 1)) {
variable_set('googleanalytics_custom', 1);
- // Load user 1 object, set appropriate value and save new user settings back.
+ // Load user 1 object, set appropriate value and save new user settings.
$account = user_load(1);
$account = user_save($account, array('data' => array('googleanalytics' => array('custom' => 0))), 'account');
$messages[] = t('Disabled user specific page tracking for site administrator.');
@@ -151,11 +156,11 @@ function googleanalytics_update_6002() {
}
/**
- * #262468: Clear menu cache to solve stale menu data in 5.x-1.5 and 6.x-1.1
+ * #262468: Clear menu cache to solve stale menu data in 5.x-1.5 and 6.x-1.1.
*/
function googleanalytics_update_6003() {
menu_rebuild();
- return t('Menu has been rebuild.');
+ return t('Menu has been rebuilt.');
}
/**
@@ -230,8 +235,9 @@ function googleanalytics_update_6006() {
/**
* Remove "User identifier" and "User name" from segmentation fields.
*
- * This is a data protection and privacy law change. For more information see Google Analytics
- * terms of use section 8.1 (http://www.google.com/analytics/en-GB/tos.html).
+ * This is a data protection and privacy law change. For more information see
+ * Google Analytics terms of use section 8.1:
+ * https://www.google.com/analytics/en-GB/tos.html
*/
function googleanalytics_update_6007() {
$profile_fields = variable_get('googleanalytics_segmentation', array());
@@ -292,15 +298,15 @@ function googleanalytics_update_6300() {
$messages[] = t('Upgraded custom "before" code snippet.');
}
- // Upgrade of AFTER code snippet.
- // We cannot update this code snippet automatically. Show message that the upgrade has been skipped.
+ // Upgrade of AFTER code snippet. We cannot update this code snippet
+ // automatically. Show message that the upgrade has been skipped.
$code_after = variable_get('googleanalytics_codesnippet_after', '');
if (!empty($code_after)) {
drupal_set_message(Database::getConnection()->prefixTables("Automatic upgrade of Google Analytics custom 'after' code snippet has been skipped. Backup of previous code snippet has been saved in database table '{variable}' as 'googleanalytics_codesnippet_after_backup_6300'. You need to manually upgrade the custom 'after' code snippet."), 'error');
$messages[] = t('Skipped custom "after" code snippet.');
}
- return empty($messages) ? t('No custom code snipped found. Nothing to do.') : implode(' ', $messages);
+ return empty($messages) ? t('No custom code snippet found. Nothing to do.') : implode(' ', $messages);
}
/**
@@ -355,18 +361,20 @@ function googleanalytics_update_7002() {
$googleanalytics_custom_vars['slots'][1]['slot'] = 1;
$googleanalytics_custom_vars['slots'][1]['name'] = 'User roles';
$googleanalytics_custom_vars['slots'][1]['value'] = '[current-user:role-names]';
- $googleanalytics_custom_vars['slots'][1]['scope'] = 1; // Sets the scope to visitor-level.
+ // Sets the scope to visitor-level.
+ $googleanalytics_custom_vars['slots'][1]['scope'] = 1;
variable_set('googleanalytics_custom_var', $googleanalytics_custom_vars);
- return t('The deprecated profile segmentation setting for "User roles" has been added to custom variables. You need to deselect all selected profile fields in Google Analytics settings and upgrade other profile fields manually or you may loose tracking data in future! See Google Analytics Custom Variables for more information.', array('@customvar' => 'https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables', '@admin' => url('admin/config/system/googleanalytics')));
+ return t('The deprecated profile segmentation setting for "User roles" has been added to custom variables. You need to deselect all selected profile fields in Google Analytics settings and upgrade other profile fields manually or you may lose tracking data in future! See Google Analytics Custom Variables for more information.', array('@customvar' => 'https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables', '@admin' => url('admin/config/system/googleanalytics')));
}
else {
- return t('You need to deselect all selected profile fields in Google Analytics settings and upgrade other profile fields manually or you may loose tracking data in future! See Google Analytics Custom Variables for more information.', array('@customvar' => 'https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables', '@admin' => url('admin/config/system/googleanalytics')));
+ return t('You need to deselect all selected profile fields in Google Analytics settings and upgrade other profile fields manually or you may lose tracking data in future! See Google Analytics Custom Variables for more information.', array('@customvar' => 'https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables', '@admin' => url('admin/config/system/googleanalytics')));
}
}
/**
- * Rename googleanalytics_trackoutgoing variable to googleanalytics_trackoutbound.
+ * Rename googleanalytics_trackoutgoing variable to
+ * googleanalytics_trackoutbound.
*/
function googleanalytics_update_7003() {
variable_set('googleanalytics_trackoutbound', variable_get('googleanalytics_trackoutgoing', 1));
@@ -376,7 +384,8 @@ function googleanalytics_update_7003() {
}
/**
- * Rename googleanalytics_visibility variable to googleanalytics_visibility_pages for consistency.
+ * Rename googleanalytics_visibility variable to
+ * googleanalytics_visibility_pages for consistency.
*/
function googleanalytics_update_7004() {
variable_set('googleanalytics_visibility_pages', variable_get('googleanalytics_visibility', 1));
@@ -400,7 +409,7 @@ function googleanalytics_update_7005() {
$diff = array_diff($pages, preg_split('/(\r\n?|\n)/', variable_get('googleanalytics_pages', implode("\n", $pages))));
if (empty($diff)) {
- // No diff to previous settings found. Update with new settings.
+ // No difference to previous settings found. Update with new settings.
$pages = array(
'admin',
'admin/*',
@@ -436,7 +445,8 @@ function googleanalytics_update_7007() {
}
/**
- * Delete custom ga.js code snipptes to prevent malfunctions in new Universal Analytics tracker. A backup of your snippets will be created.
+ * Delete custom ga.js code snippets to prevent malfunctions in new Universal
+ * Analytics tracker. A backup of your snippets will be created.
*/
function googleanalytics_update_7200() {
$messages = array();
@@ -446,23 +456,24 @@ function googleanalytics_update_7200() {
if (!empty($googleanalytics_codesnippet_before) && stristr($googleanalytics_codesnippet_before, '_gaq.push(')) {
variable_set('googleanalytics_codesnippet_before_backup_7200', $googleanalytics_codesnippet_before);
variable_del('googleanalytics_codesnippet_before');
- drupal_set_message(Database::getConnection()->prefixTables("A backup of your previous Google Analytics code snippet has been saved in database table '{variable}' as 'googleanalytics_codesnippet_before_backup_7200'. You need to manually upgrade the custom 'before' code snippet."), 'warning');
- $messages[] = t('Manual upgrade of custom "before" code snippet is required.');
+ drupal_set_message(Database::getConnection()->prefixTables("A backup of your previous Google Analytics code snippet (ga.js) has been saved in database table '{variable}' as 'googleanalytics_codesnippet_before_backup_7200'. You need to manually upgrade the custom 'before' code snippet to analytics.js API."), 'warning');
+ $messages[] = t('Manual upgrade of custom "before" code snippet from ja.js to analytics.js API is required.');
}
$googleanalytics_codesnippet_after = variable_get('googleanalytics_codesnippet_after', '');
if (!empty($googleanalytics_codesnippet_after) && stristr($googleanalytics_codesnippet_after, '_gaq.push(')) {
variable_set('googleanalytics_codesnippet_after_backup_7200', $googleanalytics_codesnippet_after);
variable_del('googleanalytics_codesnippet_after');
- drupal_set_message(Database::getConnection()->prefixTables("A backup of your previous Google Analytics code snippet has been saved in database table '{variable}' as 'googleanalytics_codesnippet_before_backup_7200'. You need to manually upgrade the custom 'before' code snippet."), 'warning');
- $messages[] = t('Manual upgrade of custom "after" code snippet is required.');
+ drupal_set_message(Database::getConnection()->prefixTables("A backup of your previous Google Analytics code snippet (ga.js) has been saved in database table '{variable}' as 'googleanalytics_codesnippet_after_backup_7200'. You need to manually upgrade the custom 'after' code snippet to analytics.js API."), 'warning');
+ $messages[] = t('Manual upgrade of custom "after" code snippet from ja.js to analytics.js API is required.');
}
- return empty($messages) ? t('No custom code snipped found. Nothing to do.') : implode(' ', $messages);
+ return empty($messages) ? t('No custom code snippet found. Nothing to do.') : implode(' ', $messages);
}
/**
- * Delete obsolete custom variables. Custom variables are now custom dimensions and metrics.
+ * Delete obsolete custom variables. Custom variables are now custom dimensions
+ * and metrics.
*/
function googleanalytics_update_7201() {
variable_del('googleanalytics_custom_var');
@@ -474,7 +485,7 @@ function googleanalytics_update_7201() {
* Delete obsolete JavaScript scope variable.
*/
function googleanalytics_update_7202() {
- // Remove obsolete scope variable
+ // Remove obsolete scope variable.
variable_del('googleanalytics_js_scope');
return t('Removed obsolete JavaScript scope variable.');
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.js b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.js
index 1eed3c3..5ba42ca 100644
--- a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.js
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.js
@@ -14,29 +14,51 @@ $(document).ready(function() {
// Is the clicked URL internal?
if (Drupal.googleanalytics.isInternal(this.href)) {
// Skip 'click' tracking, if custom tracking events are bound.
- if ($(this).is('.colorbox')) {
+ if ($(this).is('.colorbox') && (Drupal.settings.googleanalytics.trackColorbox)) {
// Do nothing here. The custom event will handle all tracking.
//console.info("Click on .colorbox item has been detected.");
}
// Is download tracking activated and the file extension configured for download tracking?
else if (Drupal.settings.googleanalytics.trackDownload && Drupal.googleanalytics.isDownload(this.href)) {
// Download link clicked.
- ga("send", "event", "Downloads", Drupal.googleanalytics.getDownloadExtension(this.href).toUpperCase(), Drupal.googleanalytics.getPageUrl(this.href));
+ ga("send", {
+ "hitType": "event",
+ "eventCategory": "Downloads",
+ "eventAction": Drupal.googleanalytics.getDownloadExtension(this.href).toUpperCase(),
+ "eventLabel": Drupal.googleanalytics.getPageUrl(this.href),
+ "transport": "beacon"
+ });
}
else if (Drupal.googleanalytics.isInternalSpecial(this.href)) {
// Keep the internal URL for Google Analytics website overlay intact.
- ga("send", "pageview", { "page": Drupal.googleanalytics.getPageUrl(this.href) });
+ ga("send", {
+ "hitType": "pageview",
+ "page": Drupal.googleanalytics.getPageUrl(this.href),
+ "transport": "beacon"
+ });
}
}
else {
if (Drupal.settings.googleanalytics.trackMailto && $(this).is("a[href^='mailto:'],area[href^='mailto:']")) {
// Mailto link clicked.
- ga("send", "event", "Mails", "Click", this.href.substring(7));
+ ga("send", {
+ "hitType": "event",
+ "eventCategory": "Mails",
+ "eventAction": "Click",
+ "eventLabel": this.href.substring(7),
+ "transport": "beacon"
+ });
}
else if (Drupal.settings.googleanalytics.trackOutbound && this.href.match(/^\w+:\/\//i)) {
- if (Drupal.settings.googleanalytics.trackDomainMode != 2 || (Drupal.settings.googleanalytics.trackDomainMode == 2 && !Drupal.googleanalytics.isCrossDomain(this.hostname, Drupal.settings.googleanalytics.trackCrossDomains))) {
+ if (Drupal.settings.googleanalytics.trackDomainMode !== 2 || (Drupal.settings.googleanalytics.trackDomainMode === 2 && !Drupal.googleanalytics.isCrossDomain(this.hostname, Drupal.settings.googleanalytics.trackCrossDomains))) {
// External link clicked / No top-level cross domain clicked.
- ga("send", "event", "Outbound links", "Click", this.href);
+ ga("send", {
+ "hitType": "event",
+ "eventCategory": "Outbound links",
+ "eventAction": "Click",
+ "eventLabel": this.href,
+ "transport": "beacon"
+ });
}
}
}
@@ -46,18 +68,26 @@ $(document).ready(function() {
// Track hash changes as unique pageviews, if this option has been enabled.
if (Drupal.settings.googleanalytics.trackUrlFragments) {
window.onhashchange = function() {
- ga('send', 'pageview', location.pathname + location.search + location.hash);
- }
+ ga("send", {
+ "hitType": "pageview",
+ "page": location.pathname + location.search + location.hash
+ });
+ };
}
// Colorbox: This event triggers when the transition has completed and the
// newly loaded content has been revealed.
- $(document).bind("cbox_complete", function () {
- var href = $.colorbox.element().attr("href");
- if (href) {
- ga("send", "pageview", { "page": Drupal.googleanalytics.getPageUrl(href) });
- }
- });
+ if (Drupal.settings.googleanalytics.trackColorbox) {
+ $(document).bind("cbox_complete", function () {
+ var href = $.colorbox.element().attr("href");
+ if (href) {
+ ga("send", {
+ "hitType": "pageview",
+ "page": Drupal.googleanalytics.getPageUrl(href)
+ });
+ }
+ });
+ }
});
@@ -74,7 +104,7 @@ $(document).ready(function() {
Drupal.googleanalytics.isCrossDomain = function (hostname, crossDomains) {
/**
* jQuery < 1.6.3 bug: $.inArray crushes IE6 and Chrome if second argument is
- * `null` or `undefined`, http://bugs.jquery.com/ticket/10076,
+ * `null` or `undefined`, https://bugs.jquery.com/ticket/10076,
* https://github.com/jquery/jquery/commit/a839af034db2bd934e4d4fa6758a3fed8de74174
*
* @todo: Remove/Refactor in D8
@@ -133,8 +163,8 @@ Drupal.googleanalytics.isInternalSpecial = function (url) {
* Extract the relative internal URL from an absolute internal URL.
*
* Examples:
- * - http://mydomain.com/node/1 -> /node/1
- * - http://example.com/foo/bar -> http://example.com/foo/bar
+ * - https://mydomain.com/node/1 -> /node/1
+ * - https://example.com/foo/bar -> https://example.com/foo/bar
*
* @param string url
* The web url to check.
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.module b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.module
index 4051b1b..0026703 100644
--- a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.module
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.module
@@ -7,7 +7,7 @@
* Adds the required Javascript to all your Drupal pages to allow tracking by
* the Google Analytics statistics package.
*
- * @author: Alexander Hass
+ * @author: Alexander Hass
*/
/**
@@ -17,7 +17,7 @@ define('GOOGLEANALYTICS_TRACKFILES_EXTENSIONS', '7z|aac|arc|arj|asf|asx|avi|bin|
/**
* Define default path exclusion list to remove tracking from admin pages,
- * see http://drupal.org/node/34970 for more information.
+ * see https://drupal.org/node/34970 for more information.
*/
define('GOOGLEANALYTICS_PAGES', "admin\nadmin/*\nbatch\nnode/add*\nnode/*/*\nuser/*/*");
@@ -36,7 +36,7 @@ function googleanalytics_api() {
function googleanalytics_help($path, $arg) {
switch ($path) {
case 'admin/config/system/googleanalytics':
- return t('Google Analytics is a free (registration required) website traffic and marketing effectiveness service.', array('@ga_url' => 'http://www.google.com/analytics/'));
+ return t('Google Analytics is a free (registration required) website traffic and marketing effectiveness service.', array('@ga_url' => 'https://marketingplatform.google.com/about/analytics/'));
}
}
@@ -69,6 +69,11 @@ function googleanalytics_permission() {
'description' => t('Enter PHP code in the field for tracking visibility settings.'),
'restrict access' => TRUE,
),
+ 'add JS snippets for google analytics' => array(
+ 'title' => t('Add JavaScript snippets'),
+ 'description' => 'Enter JavaScript code snippets for advanced Google Analytics functionality.',
+ 'restrict access' => TRUE,
+ ),
);
}
@@ -93,7 +98,7 @@ function googleanalytics_menu() {
* Implements hook_page_alter() to insert JavaScript to the appropriate scope/region of the page.
*/
function googleanalytics_page_alter(&$page) {
- global $user;
+ global $base_path, $user;
$id = variable_get('googleanalytics_account', '');
@@ -125,8 +130,11 @@ function googleanalytics_page_alter(&$page) {
$link_settings['trackDownload'] = $track_download;
$link_settings['trackDownloadExtensions'] = $trackfiles_extensions;
}
+ if (module_exists('colorbox') && ($track_colorbox = variable_get('googleanalytics_trackcolorbox', 1))) {
+ $link_settings['trackColorbox'] = $track_colorbox;
+ }
if ($track_domain_mode = variable_get('googleanalytics_domain_mode', 0)) {
- $link_settings['trackDomainMode'] = $track_domain_mode;
+ $link_settings['trackDomainMode'] = (int) $track_domain_mode;
}
if ($track_cross_domains = variable_get('googleanalytics_cross_domains', '')) {
$link_settings['trackCrossDomains'] = preg_split('/(\r\n?|\n)/', $track_cross_domains);
@@ -193,11 +201,23 @@ function googleanalytics_page_alter(&$page) {
// Track access denied (403) and file not found (404) pages.
if ($status == '403 Forbidden') {
- // See http://www.google.com/support/analytics/bin/answer.py?answer=86927
- $url_custom = '"/403.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
+ // See https://www.google.com/support/analytics/bin/answer.py?answer=86927
+ $url_custom = '"' . $base_path . '403.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
}
elseif ($status == '404 Not Found') {
- $url_custom = '"/404.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
+ $url_custom = '"' . $base_path . '404.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
+ }
+
+ // #2693595: User has entered an invalid login and clicked on forgot
+ // password link. This link contains the username or email address and may
+ // get send to Google if we do not override it. Override only if 'name'
+ // query param exists. Last custom url condition, this need to win.
+ //
+ // URLs to protect are:
+ // - user/password?name=username
+ // - user/password?name=foo@example.com
+ if (arg(0) == 'user' && arg(1) == 'password' && array_key_exists('name', drupal_get_query_parameters())) {
+ $url_custom = '"' . $base_path . 'user/password"';
}
// Add custom dimensions and metrics.
@@ -248,11 +268,10 @@ function googleanalytics_page_alter(&$page) {
$script .= '})(window,document,"script",';
// Which version of the tracking library should be used?
- $library_tracker_url = '//www.google-analytics.com/' . ($debug ? 'analytics_debug.js' : 'analytics.js');
- $library_cache_url = 'http:' . $library_tracker_url;
+ $library_tracker_url = 'https://www.google-analytics.com/' . ($debug ? 'analytics_debug.js' : 'analytics.js');
// Should a local cached copy of analytics.js be used?
- if (variable_get('googleanalytics_cache', 0) && $url = _googleanalytics_cache($library_cache_url)) {
+ if (variable_get('googleanalytics_cache', 0) && $url = _googleanalytics_cache($library_tracker_url)) {
// A dummy query-string is added to filenames, to gain control over
// browser-caching. The string changes on every update or full cache
// flush, forcing browsers to load a new copy of the files, as the
@@ -294,10 +313,7 @@ function googleanalytics_page_alter(&$page) {
// Track logged in users across all devices.
if (variable_get('googleanalytics_trackuserid', 0) && user_is_logged_in()) {
- // The USER_ID value should be a unique, persistent, and non-personally
- // identifiable string identifier that represents a user or signed-in
- // account across devices.
- $create_only_fields['userId'] = drupal_hmac_base64($user->uid, drupal_get_private_key() . drupal_get_hash_salt());
+ $create_only_fields['userId'] = google_analytics_user_id_hash($user->uid);
}
// Create a tracker.
@@ -352,13 +368,30 @@ function googleanalytics_page_alter(&$page) {
// Custom tracking. Prepend before all other JavaScript.
// @TODO: https://support.google.com/adsense/answer/98142
// sounds like it could be appended to $script.
- drupal_add_js($googleanalytics_adsense_script, array('type' => 'inline', 'group' => JS_LIBRARY-1));
+ drupal_add_js($googleanalytics_adsense_script, array('type' => 'inline', 'group' => JS_LIBRARY-1, 'requires_jquery' => FALSE));
}
- drupal_add_js($script, array('scope' => 'header', 'type' => 'inline'));
+ drupal_add_js($script, array('scope' => 'header', 'type' => 'inline', 'requires_jquery' => FALSE));
}
}
+/**
+ * Generate user id hash to implement USER_ID.
+ *
+ * The USER_ID value should be a unique, persistent, and non-personally
+ * identifiable string identifier that represents a user or signed-in
+ * account across devices.
+ *
+ * @param int $uid
+ * User id.
+ *
+ * @return string
+ * User id hash.
+ */
+function google_analytics_user_id_hash($uid) {
+ return drupal_hmac_base64($uid, drupal_get_private_key() . drupal_get_hash_salt());
+}
+
/**
* Implements hook_field_extra_fields().
*/
@@ -440,7 +473,7 @@ function googleanalytics_user_presave(&$edit, $account, $category) {
function googleanalytics_cron() {
// Regenerate the tracking code file every day.
if (REQUEST_TIME - variable_get('googleanalytics_last_cache', 0) >= 86400 && variable_get('googleanalytics_cache', 0)) {
- _googleanalytics_cache('http://www.google-analytics.com/analytics.js', TRUE);
+ _googleanalytics_cache('https://www.google-analytics.com/analytics.js', TRUE);
variable_set('googleanalytics_last_cache', REQUEST_TIME);
}
}
@@ -456,14 +489,14 @@ function googleanalytics_preprocess_search_results(&$variables) {
// found. But the pager item mumber can tell the number of search results.
global $pager_total_items;
- drupal_add_js('window.googleanalytics_search_results = ' . intval($pager_total_items[0]) . ';', array('type' => 'inline', 'group' => JS_LIBRARY-1));
+ drupal_add_js('window.googleanalytics_search_results = ' . intval($pager_total_items[0]) . ';', array('type' => 'inline', 'group' => JS_LIBRARY-1, 'requires_jquery' => FALSE));
}
}
/**
* Helper function for grabbing search keys. Function is missing in D7.
*
- * http://api.drupal.org/api/function/search_get_keys/6
+ * https://api.drupal.org/api/function/search_get_keys/6
*/
function googleanalytics_search_get_keys() {
static $return;
@@ -504,6 +537,10 @@ function _googleanalytics_cache($location, $synchronize = FALSE) {
if ($data_hash_local != $data_hash_remote && file_prepare_directory($path)) {
// Save updated tracking code file to disk.
file_unmanaged_save_data($result->data, $file_destination, FILE_EXISTS_REPLACE);
+ // Based on Drupal Core drupal_build_css_cache().
+ if (variable_get('css_gzip_compression', TRUE) && variable_get('clean_url', 0) && extension_loaded('zlib')) {
+ file_unmanaged_save_data(gzencode($result->data, 9, FORCE_GZIP), $file_destination . '.gz', FILE_EXISTS_REPLACE);
+ }
watchdog('googleanalytics', 'Locally cached tracking code file has been updated.', array(), WATCHDOG_INFO);
// Change query-strings on css/js files to enforce reload for all users.
@@ -516,6 +553,10 @@ function _googleanalytics_cache($location, $synchronize = FALSE) {
// There is no need to flush JS here as core refreshes JS caches
// automatically, if new files are added.
file_unmanaged_save_data($result->data, $file_destination, FILE_EXISTS_REPLACE);
+ // Based on Drupal Core drupal_build_css_cache().
+ if (variable_get('css_gzip_compression', TRUE) && variable_get('clean_url', 0) && extension_loaded('zlib')) {
+ file_unmanaged_save_data(gzencode($result->data, 9, FORCE_GZIP), $file_destination . '.gz', FILE_EXISTS_REPLACE);
+ }
watchdog('googleanalytics', 'Locally cached tracking code file has been saved.', array(), WATCHDOG_INFO);
// Return the local JS file path.
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.test b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.test
index 0b64bb8..52c3148 100644
--- a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.test
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.test
@@ -6,6 +6,13 @@
*/
class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
+ /**
+ * User without permissions to edit snippets.
+ *
+ * @var \StdClass
+ */
+ protected $noSnippetUser;
+
public static function getInfo() {
return array(
'name' => 'Google Analytics basic tests',
@@ -25,6 +32,8 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
);
// User to set up google_analytics.
+ $this->noSnippetUser = $this->drupalCreateUser($permissions);
+ $permissions[] = 'add JS snippets for google analytics';
$this->admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($this->admin_user);
}
@@ -48,13 +57,33 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
$edit['googleanalytics_account'] = $this->randomName(2);
$this->drupalPost('admin/config/system/googleanalytics', $edit, t('Save configuration'));
$this->assertRaw(t('A valid Google Analytics Web Property ID is case sensitive and formatted like UA-xxxxxxx-yy.'), '[testGoogleAnalyticsConfiguration]: Invalid Web Property ID number validated.');
+
+ // User should have access to code snippets.
+ $this->assertFieldByName('googleanalytics_codesnippet_create');
+ $this->assertFieldByName('googleanalytics_codesnippet_before');
+ $this->assertFieldByName('googleanalytics_codesnippet_after');
+ $this->assertNoFieldByXPath("//textarea[@name='googleanalytics_codesnippet_create' and @disabled='disabled']", NULL, '"Create only fields" is enabled.');
+ $this->assertNoFieldByXPath("//textarea[@name='googleanalytics_codesnippet_before' and @disabled='disabled']", NULL, '"Code snippet (before)" is enabled.');
+ $this->assertNoFieldByXPath("//textarea[@name='googleanalytics_codesnippet_after' and @disabled='disabled']", NULL, '"Code snippet (after)" is enabled.');
+
+ // Login as user without JS permissions.
+ $this->drupalLogin($this->noSnippetUser);
+ $this->drupalGet('admin/config/system/googleanalytics');
+
+ // User should *not* have access to snippets, but create fields.
+ $this->assertFieldByName('googleanalytics_codesnippet_create');
+ $this->assertFieldByName('googleanalytics_codesnippet_before');
+ $this->assertFieldByName('googleanalytics_codesnippet_after');
+ $this->assertNoFieldByXPath("//textarea[@name='googleanalytics_codesnippet_create' and @disabled='disabled']", NULL, '"Create only fields" is enabled.');
+ $this->assertFieldByXPath("//textarea[@name='googleanalytics_codesnippet_before' and @disabled='disabled']", NULL, '"Code snippet (before)" is disabled.');
+ $this->assertFieldByXPath("//textarea[@name='googleanalytics_codesnippet_after' and @disabled='disabled']", NULL, '"Code snippet (after)" is disabled.');
}
function testGoogleAnalyticsPageVisibility() {
// Verify that no tracking code is embedded into the webpage; if there is
// only the module installed, but UA code not configured. See #2246991.
$this->drupalGet('');
- $this->assertNoRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed without UA code configured.');
+ $this->assertNoRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed without UA code configured.');
$ua_code = 'UA-123456-1';
variable_set('googleanalytics_account', $ua_code);
@@ -75,7 +104,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
$this->assertNoRaw($ua_code, '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed on admin page.');
$this->drupalGet('admin/config/system/googleanalytics');
// Checking for tracking code URI here, as $ua_code is displayed in the form.
- $this->assertNoRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed on admin subpage.');
+ $this->assertNoRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed on admin subpage.');
// Test whether tracking code display is properly flipped.
variable_set('googleanalytics_visibility_pages', 1);
@@ -83,7 +112,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
$this->assertRaw($ua_code, '[testGoogleAnalyticsPageVisibility]: Tracking code is displayed on admin page.');
$this->drupalGet('admin/config/system/googleanalytics');
// Checking for tracking code URI here, as $ua_code is displayed in the form.
- $this->assertRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is displayed on admin subpage.');
+ $this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is displayed on admin subpage.');
$this->drupalGet('');
$this->assertNoRaw($ua_code, '[testGoogleAnalyticsPageVisibility]: Tracking code is NOT displayed on front page.');
@@ -97,13 +126,15 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
// Enable tracking code for all user roles.
variable_set('googleanalytics_roles', array());
+ $base_path = base_path();
+
// Test whether 403 forbidden tracking code is shown if user has no access.
$this->drupalGet('admin');
- $this->assertRaw('/403.html', '[testGoogleAnalyticsPageVisibility]: 403 Forbidden tracking code shown if user has no access.');
+ $this->assertRaw($base_path . '403.html', '[testGoogleAnalyticsPageVisibility]: 403 Forbidden tracking code shown if user has no access.');
// Test whether 404 not found tracking code is shown on non-existent pages.
$this->drupalGet($this->randomName(64));
- $this->assertRaw('/404.html', '[testGoogleAnalyticsPageVisibility]: 404 Not Found tracking code shown on non-existent page.');
+ $this->assertRaw($base_path . '404.html', '[testGoogleAnalyticsPageVisibility]: 404 Not Found tracking code shown on non-existent page.');
// DNT Tests:
// Enable system internal page cache for anonymous users.
@@ -139,7 +170,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
(function(q,u,i,c,k){window['GoogleAnalyticsObject']=q;
window[q]=window[q]||function(){(window[q].q=window[q].q||[]).push(arguments)},
window[q].l=1*new Date();c=i.createElement(u),k=i.getElementsByTagName(u)[0];
- c.async=true;c.src='//www.google-analytics.com/analytics.js';
+ c.async=true;c.src='https://www.google-analytics.com/analytics.js';
k.parentNode.insertBefore(c,k)})('ga','script',document);
ga('create', 'UA-123456-7');
ga('send', 'pageview');
@@ -150,7 +181,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
// Test whether tracking code uses latest JS.
variable_set('googleanalytics_cache', 0);
$this->drupalGet('');
- $this->assertRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsTrackingCode]: Latest tracking code used.');
+ $this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsTrackingCode]: Latest tracking code used.');
// Test whether anonymize visitors IP address feature has been enabled.
variable_set('googleanalytics_tracker_anonymizeip', 0);
@@ -227,13 +258,14 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
$this->assertRaw('ga("create", "' . $ua_code . '", {"cookieDomain":"auto","allowLinker":true', '[testGoogleAnalyticsTrackingCode]: "allowLinker" has been found. Cross domain tracking is active.');
$this->assertRaw('ga("require", "linker");', '[testGoogleAnalyticsTrackingCode]: Require linker has been found. Cross domain tracking is active.');
$this->assertRaw('ga("linker:autoLink", ["www.example.com","www.example.net"]);', '[testGoogleAnalyticsTrackingCode]: "linker:autoLink" has been found. Cross domain tracking is active.');
+ $this->assertRaw('"trackDomainMode":2,', '[testGoogleAnalyticsTrackingCode]: Domain mode value is of type integer.');
$this->assertRaw('"trackCrossDomains":["www.example.com","www.example.net"]', '[testGoogleAnalyticsTrackingCode]: Cross domain tracking with www.example.com and www.example.net is active.');
variable_set('googleanalytics_domain_mode', 0);
// Test whether debugging script has been enabled.
variable_set('googleanalytics_debug', 1);
$this->drupalGet('');
- $this->assertRaw('//www.google-analytics.com/analytics_debug.js', '[testGoogleAnalyticsTrackingCode]: Google debugging script has been enabled.');
+ $this->assertRaw('https://www.google-analytics.com/analytics_debug.js', '[testGoogleAnalyticsTrackingCode]: Google debugging script has been enabled.');
// Check if text and link is shown on 'Status Reports' page.
// Requires 'administer site configuration' permission.
@@ -243,7 +275,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
// Test whether debugging script has been disabled.
variable_set('googleanalytics_debug', 0);
$this->drupalGet('');
- $this->assertRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsTrackingCode]: Google debugging script has been disabled.');
+ $this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsTrackingCode]: Google debugging script has been disabled.');
// Test whether the CREATE and BEFORE and AFTER code is added to the tracker.
$codesnippet_create = array(
@@ -284,6 +316,7 @@ class GoogleAnalyticsCustomDimensionsAndMetricsTest extends DrupalWebTestCase {
// User to set up google_analytics.
$this->admin_user = $this->drupalCreateUser($permissions);
+ $this->drupalLogin($this->admin_user);
}
function testGoogleAnalyticsCustomDimensions() {
@@ -362,34 +395,30 @@ class GoogleAnalyticsCustomDimensionsAndMetricsTest extends DrupalWebTestCase {
1 => array(
'index' => 1,
'value' => '6',
- 'value_expected' => 6,
),
2 => array(
'index' => 2,
'value' => '8000',
- 'value_expected' => 8000,
),
3 => array(
'index' => 3,
'value' => '7.8654',
- 'value_expected' => 7.8654,
),
4 => array(
'index' => 4,
'value' => '1123.4',
- 'value_expected' => 1123.4,
),
5 => array(
'index' => 5,
'value' => '5,67',
- 'value_expected' => 5,
),
);
+
variable_set('googleanalytics_custom_metric', $googleanalytics_custom_metric);
$this->drupalGet('');
foreach ($googleanalytics_custom_metric as $metric) {
- $this->assertRaw('ga("set", ' . drupal_json_encode('metric' . $metric['index']) . ', ' . drupal_json_encode($metric['value_expected']) . ');', '[testGoogleAnalyticsCustomDimensionsAndMetrics]: Metric #' . $metric['index'] . ' is shown.');
+ $this->assertRaw('ga("set", ' . drupal_json_encode('metric' . $metric['index']) . ', ' . drupal_json_encode((float) $metric['value']) . ');', '[testGoogleAnalyticsCustomDimensionsAndMetrics]: Metric #' . $metric['index'] . ' is shown.');
}
// Test whether tokens are replaced in custom metric values.
@@ -421,6 +450,75 @@ class GoogleAnalyticsCustomDimensionsAndMetricsTest extends DrupalWebTestCase {
$this->assertNoRaw('ga("set", ' . drupal_json_encode('metric3') . ', ' . drupal_json_encode('') . ');', '[testGoogleAnalyticsCustomDimensionsAndMetrics]: Empty value is not shown.');
$this->assertRaw('ga("set", ' . drupal_json_encode('metric4') . ', ' . drupal_json_encode(0) . ');', '[testGoogleAnalyticsCustomDimensionsAndMetrics]: Value 0 is shown.');
}
+
+ /**
+ * Tests if Custom Dimensions token form validation works.
+ */
+ public function testGoogleAnalyticsCustomDimensionsTokenFormValidation() {
+ $ua_code = 'UA-123456-1';
+
+ // Check form validation.
+ $edit['googleanalytics_account'] = $ua_code;
+ $edit['googleanalytics_custom_dimension[indexes][1][value]'] = '[current-user:name]';
+ $edit['googleanalytics_custom_dimension[indexes][2][value]'] = '[current-user:edit-url]';
+ $edit['googleanalytics_custom_dimension[indexes][3][value]'] = '[user:name]';
+ $edit['googleanalytics_custom_dimension[indexes][4][value]'] = '[term:name]';
+ $edit['googleanalytics_custom_dimension[indexes][5][value]'] = '[term:tid]';
+
+ $this->drupalPost('admin/config/system/googleanalytics', $edit, t('Save configuration'));
+
+ $this->assertRaw(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', array('%element-title' => t('Custom dimension value #@index', array('@index' => 1)), '@invalid-tokens' => implode(', ', array('[current-user:name]')))));
+ $this->assertRaw(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', array('%element-title' => t('Custom dimension value #@index', array('@index' => 2)), '@invalid-tokens' => implode(', ', array('[current-user:edit-url]')))));
+ $this->assertRaw(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', array('%element-title' => t('Custom dimension value #@index', array('@index' => 3)), '@invalid-tokens' => implode(', ', array('[user:name]')))));
+ // BUG #2037595
+ //$this->assertNoRaw(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', array('%element-title' => t('Custom dimension value #@index', array('@index' => 4)), '@invalid-tokens' => implode(', ', array('[term:name]')))));
+ //$this->assertNoRaw(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', array('%element-title' => t('Custom dimension value #@index', array('@index' => 5)), '@invalid-tokens' => implode(', ', array('[term:tid]')))));
+ }
+}
+
+/**
+ * Test custom url functionality of Google Analytics module.
+ */
+class GoogleAnalyticsCustomUrls extends DrupalWebTestCase {
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Google Analytics custom url tests',
+ 'description' => 'Test custom url functionality of Google Analytics module.',
+ 'group' => 'Google Analytics',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('googleanalytics');
+
+ $permissions = array(
+ 'access administration pages',
+ 'administer google analytics',
+ );
+
+ // User to set up google_analytics.
+ $this->admin_user = $this->drupalCreateUser($permissions);
+ }
+
+ /**
+ * Tests if user password page urls are overridden.
+ */
+ public function testGoogleAnalyticsUserPasswordPage() {
+ $base_path = base_path();
+ $ua_code = 'UA-123456-4';
+ variable_set('googleanalytics_account', $ua_code);
+
+ $this->drupalGet('user/password', array('query' => array('name' => 'foo')));
+ $this->assertRaw('ga("set", "page", "' . $base_path . 'user/password"');
+
+ $this->drupalGet('user/password', array('query' => array('name' => 'foo@example.com')));
+ $this->assertRaw('ga("set", "page", "' . $base_path . 'user/password"');
+
+ $this->drupalGet('user/password');
+ $this->assertNoRaw('ga("set", "page",', '[testGoogleAnalyticsCustomUrls]: Custom url not set.');
+ }
+
}
class GoogleAnalyticsStatusMessagesTest extends DrupalWebTestCase {
@@ -460,7 +558,7 @@ class GoogleAnalyticsStatusMessagesTest extends DrupalWebTestCase {
//drupal_set_message('Example status message.', 'status');
//drupal_set_message('Example warning message.', 'warning');
//drupal_set_message('Example error message.', 'error');
- //drupal_set_message('Example error message with html tags and link.', 'error');
+ //drupal_set_message('Example error message with html tags and link.', 'error');
//$this->drupalGet('');
//$this->assertNoRaw('ga("send", "event", "Messages", "Status message", "Example status message.");', '[testGoogleAnalyticsStatusMessages]: Example status message is not enabled for tracking.');
//$this->assertNoRaw('ga("send", "event", "Messages", "Warning message", "Example warning message.");', '[testGoogleAnalyticsStatusMessages]: Example warning message is not enabled for tracking.');
@@ -684,13 +782,13 @@ class GoogleAnalyticsPhpFilterTest extends DrupalWebTestCase {
// Check tracking code visibility.
variable_set('googleanalytics_pages', '');
$this->drupalGet('');
- $this->assertRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is displayed on frontpage page.');
+ $this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is displayed on frontpage page.');
$this->drupalGet('admin');
- $this->assertRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is displayed on admin page.');
+ $this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is displayed on admin page.');
variable_set('googleanalytics_pages', '');
$this->drupalGet('');
- $this->assertNoRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is not displayed on frontpage page.');
+ $this->assertNoRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is not displayed on frontpage page.');
// Test administration form.
variable_set('googleanalytics_pages', '');
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.test.js b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.test.js
index 05c720f..f22d6f1 100644
--- a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.test.js
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.test.js
@@ -77,7 +77,7 @@ $(document).ready(function() {
Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isInternal(base_url + Drupal.settings.basePath + 'node/1?foo=bar'), "Link '" + base_url + Drupal.settings.basePath + "node/1?foo=bar' has been detected as internal link.");
Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isInternal(base_url + Drupal.settings.basePath + 'node/1?foo=bar#foo'), "Link '" + base_url + Drupal.settings.basePath + "node/1?foo=bar#foo' has been detected as internal link.");
Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isInternal(base_url + Drupal.settings.basePath + 'go/foo'), "Link '" + base_url + Drupal.settings.basePath + "go/foo' has been detected as internal link.");
- Drupal.googleanalytics.test.assertFalse(Drupal.googleanalytics.isInternal('http://example.com/node/3'), "Link 'http://example.com/node/3' has been detected as external link.");
+ Drupal.googleanalytics.test.assertFalse(Drupal.googleanalytics.isInternal('https://example.com/node/3'), "Link 'https://example.com/node/3' has been detected as external link.");
console.groupEnd();
console.group("Test 'isInternalSpecial':");
@@ -86,9 +86,11 @@ $(document).ready(function() {
console.groupEnd();
console.group("Test 'getPageUrl':");
- Drupal.googleanalytics.test.assertSame(base_path, Drupal.googleanalytics.getPageUrl(base_url + Drupal.settings.basePath + 'node/1'), "Absolute internal URL '" + Drupal.settings.basePath + "node/1' has been extracted from full qualified url '" + base_url + base_path + "'.");
- Drupal.googleanalytics.test.assertSame(base_path, Drupal.googleanalytics.getPageUrl(Drupal.settings.basePath + 'node/1'), "Absolute internal URL '" + Drupal.settings.basePath + "node/1' has been extracted from absolute url '" + base_path + "'.");
- Drupal.googleanalytics.test.assertSame('http://example.com/node/2', Drupal.googleanalytics.getPageUrl('http://example.com/node/2'), "Full qualified external url 'http://example.com/node/2' has been extracted.");
+ Drupal.google_analytics.test.assertSame(base_path, Drupal.google_analytics.getPageUrl(window.location.href), "Absolute internal URL '" + base_path + "' has been extracted from full qualified url '" + window.location.href + "'.");
+ Drupal.google_analytics.test.assertSame(base_path, Drupal.google_analytics.getPageUrl(base_path), "Absolute internal URL '" + base_path + "' has been extracted from absolute url '" + base_path + "'.");
+ //Drupal.googleanalytics.test.assertSame(base_path, Drupal.googleanalytics.getPageUrl(base_url + Drupal.settings.basePath + 'node/1'), "Absolute internal URL '" + Drupal.settings.basePath + "node/1' has been extracted from full qualified url '" + base_url + base_path + "'.");
+ //Drupal.googleanalytics.test.assertSame(base_path, Drupal.googleanalytics.getPageUrl(Drupal.settings.basePath + 'node/1'), "Absolute internal URL '" + Drupal.settings.basePath + "node/1' has been extracted from absolute url '" + base_path + "'.");
+ Drupal.googleanalytics.test.assertSame('https://example.com/node/2', Drupal.googleanalytics.getPageUrl('https://example.com/node/2'), "Full qualified external url 'https://example.com/node/2' has been extracted.");
Drupal.googleanalytics.test.assertSame('//example.com/node/2', Drupal.googleanalytics.getPageUrl('//example.com/node/2'), "Full qualified external url '//example.com/node/2' has been extracted.");
console.groupEnd();
@@ -105,9 +107,9 @@ $(document).ready(function() {
if (Drupal.settings.googleanalytics.trackCrossDomains) {
console.dir(Drupal.settings.googleanalytics.trackCrossDomains);
Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isCrossDomain('example.com', Drupal.settings.googleanalytics.trackCrossDomains), "URL 'example.com' has been found in cross domain list.");
- Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isCrossDomain('example.net', Drupal.settings.googleanalytics.trackCrossDomains), "URL 'example.com' has been found in cross domain list.");
+ Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isCrossDomain('example.net', Drupal.settings.googleanalytics.trackCrossDomains), "URL 'example.net' has been found in cross domain list.");
Drupal.googleanalytics.test.assertFalse(Drupal.googleanalytics.isCrossDomain('www.example.com', Drupal.settings.googleanalytics.trackCrossDomains), "URL 'www.example.com' not found in cross domain list.");
- Drupal.googleanalytics.test.assertFalse(Drupal.googleanalytics.isCrossDomain('www.example.net', Drupal.settings.googleanalytics.trackCrossDomains), "URL 'www.example.com' not found in cross domain list.");
+ Drupal.googleanalytics.test.assertFalse(Drupal.googleanalytics.isCrossDomain('www.example.net', Drupal.settings.googleanalytics.trackCrossDomains), "URL 'www.example.net' not found in cross domain list.");
}
else {
console.warn('Cross domain tracking is not enabled. Tests skipped.');
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.variable.inc b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.variable.inc
index 6a65735..5b88b1f 100644
--- a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.variable.inc
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.variable.inc
@@ -13,7 +13,7 @@ function googleanalytics_variable_info($options) {
'type' => 'string',
'title' => t('Web Property ID', array(), $options),
'default' => 'UA-',
- 'description' => t('This ID is unique to each site you want to track separately, and is in the form of UA-xxxxxxx-yy. To get a Web Property ID, register your site with Google Analytics, or if you already have registered your site, go to your Google Analytics Settings page to see the ID next to every site profile. Find more information in the documentation.', array('@analytics' => 'http://www.google.com/analytics/', '@webpropertyid' => url('https://developers.google.com/analytics/resources/concepts/gaConceptsAccounts', array('fragment' => 'webProperty'))), $options),
+ 'description' => t('This ID is unique to each site you want to track separately, and is in the form of UA-xxxxxxx-yy. To get a Web Property ID, register your site with Google Analytics, or if you already have registered your site, go to your Google Analytics Settings page to see the ID next to every site profile. Find more information in the documentation.', array('@analytics' => 'https://marketingplatform.google.com/about/analytics/', '@webpropertyid' => url('https://developers.google.com/analytics/resources/concepts/gaConceptsAccounts', array('fragment' => 'webProperty'))), $options),
'required' => TRUE,
'group' => 'googleanalytics',
'localize' => TRUE,
@@ -40,6 +40,10 @@ function googleanalytics_variable_group_info() {
/**
* Validate Web Property ID variable.
+ *
+ * @param array $variable
+ *
+ * @return string
*/
function googleanalytics_validate_googleanalytics_account($variable) {
// Replace all type of dashes (n-dash, m-dash, minus) with the normal dashes.
diff --git a/sites/all/modules/contrib/admin/module_filter/CHANGELOG.txt b/sites/all/modules/contrib/admin/module_filter/CHANGELOG.txt
old mode 100755
new mode 100644
index 218bc30..5513831
--- a/sites/all/modules/contrib/admin/module_filter/CHANGELOG.txt
+++ b/sites/all/modules/contrib/admin/module_filter/CHANGELOG.txt
@@ -1,50 +1,193 @@
-Module Filter 7.x-1.8, 2013-08-08
+Module Filter 7.x-2.1, 2017-06-09
---------------------------------
+Issue #2437439 by mikhail.krainiuk, greenSkin, jayhawkfan75: Module Filter does
+ not care about anchors in permission links.
+Issue #2866236 by Munavijayalakshmi, dhruveshdtripathi: Typo error in
+ README.TXT file.
+Issue #2452067 by Madis: Option to show description expanded as default
+ not working.
+Issue #2580791 by makbul_khan8: Coding standards and few function without
+ help comments.
+Issue #2153697 by annya: Disabling option "Number of enabled modules" breaks
+ tabs functionality.
+Issue #1710230 by willvincent: On | Off buttons does not change state with
+ jquery_update module active.
+Added option to show description as expanded by default.
+Improved description field so when it is open, interacting with it's contents
+ does not make it collapse.
+Placed collapsed/expanded images inside of module for easier, more reliable
+ access.
+Added option to place version in own column.
+Issue #2113191 by joelpittet: Category tabs not working.
+
+
+Module Filter 7.x-2.0, 2015-02-22
+---------------------------------
+Simplifying the table rows by hiding version and requirements until a
+ particular description is clicked.
+#2235553 by greenSkin: Fixed latest jquery_update breaks module filter.
+#2304687 by mpdonadio: Fixed Remove hardcoded operations.
+#2293029 by topsitemakers: Fixed Take header offset into account when selecting
+ a tab.
+#2290213 by topsitemakers: Minor typo in description - "has no affect" -> "has
+ no effect".
+#2141743, #2141743 by greenSkin: Fixed issues related to the new dynamically
+ positioned tabs and using the dynamically positioned save button.
+by greenSkin: Tabs now should always be visible while scrolling large lists of
+ modules.
+#1854348 by alexweber, greenSkin: Make filter textfield wider on modules page
+ when viewing as tabs.
+by greenSkin: Fixed what was suppose to be a call to variable_set().
+#1370492 by greenSkin: Remember selected tab after modules form submit.
by greenSkin: Changed the title for the 'module_filter_dynamic_save_position'
checkbox to make it clearer what it does.
-#1933384 by kaidjohnson: Fixed jQuery UI button breaks functionality.
-#1166414 by greenSkin: Fixed module filter + tabs disabled = broken modules
- page.
-
-
-Module Filter 7.x-1.7, 2012-07-05
----------------------------------
+#1166414 by greenSkin: Fixed broken submit when tabs are disabled. We no longer
+ reroute the theme of the system modules page unless tabs are enabled.
+by greenSkin: Fixed issue on Available updates page where the update state
+ would not be remembered.
+by greenSkin: Fixed 7200 update to rebuild the theme registry at the same time
+ as rebuilding the menu.
+by greenSkin: Fixed issue relating to row coloring when enabling/disabling
+ modules via switch due to recent fix for jQuery Update module.
+by greenSkin: Added functionality to show recently enabled/disabled modules.
+#1710230 by littlekoala, greenSkin: Fixed On | Off buttons does not change
+ state with jquery_update() module active.
+by greenSkin: Added description to filter textfield on permissions page.
+by greenSkin: Added filter to user permissions page.
+by greenSkin: Fixed styling when JavaScript is disabled.
+by greenSkin: Fixed compatiblility with page_actions.
+#1351184 klonos, greenSkin: Added support for update_advanced "Ignored from
+ settings".
+#1149978 by good_man, greenSkin: Added RTL Styling for tabs and toggle switch.
+by greenSkin: Hide toggle switch when JavaScript is disabled.
+by greenSkin: Added support for ctools dropbutton as well as views styling for
+ ctools dropbutton.
+by greenSkin: Improved hash validation.
+by greenSkin: Added ability for tabs to be disabled. Direct use case is when
+ the "New" tab contains zero new modules.
+by greenSkin: Added title to "New" tab link that helps to describe the criteria
+ of a "new" module.
+#1320796 by greenSkin: Added some validation checks before trying to select a
+ tab in case the tab does not actually exist.
+#1429248 by klonos, greenSkin: Fixed Modules page table header overlaps
+ admin_menu().
+#1494694 by greenSkin: Added Let me decide if I want the cursor to focus on the
+ search box or not.
+#1515256 by catmat, greenSkin: Fixed Tabbed theme may remove functional
+ content.
+by greenSkin: Integrated dynamic positioning of the save button back in, but
+ if the module page_actions is enabled we let it handle the save button. See
+ issue #1424994.
+by greenSkin: Clicking on module name now affects the toggle switch.
+by greenSkin: Do not render the switch for incompatible modules.
#1033012 by greenSkin: Hide incompatible module rows when the 'Unavailable'
checkbox is unchecked.
-#1170388 by greenSkin: Fixed conflict with Overlay module. Added class
- "overlay-exclude" to tab links.
+by greenSkin: Performance tweak to counting the number of enabled modules.
+by greenSkin: Base new modules on the filectime of their .info file.
+#1424034 by greenSkin: Now adds the jquery.cookie.js file when needed.
+by greenSkin: Removed tweaks to the save configuration button in favor
+ http://drupal.org/project/page_actions.
+by greenSkin: Updated hook_uninstall to del all Module Filter variables.
+by greenSkin: No longer including machine name in the tab summary of modules to
+ enable/disable.
+by greenSkin: Made switches honor disabled checkboxes. A disabled switch can
+ not be turned on or off.
+by greenSkin: Added setting to toggle between using the switch or checkbox for
+ enabling/disabling modules.
+by greenSkin: Centered enable switch.
+by greenSkin: Moved couple styles to be applied via JavaScript instead of CSS
+ so they get applied once the initial loading has finished.
+by greenSkin: Implemented a "switch" look instead of checkboxes.
+by greenSkin: Remember last selected state on "Available updates" page.
+by greenSkin: Switched to using filectime() rather than filemtime() for
+ determining new modules.
+#1354134 by klonos, greenSkin: Module list now formats correctly in core
+ "Garland" theme.
+#1354134 by klonos, greenSkin: Module list now formats correctly in core
+ "Garland" theme.
#1124218 by jyee, greenSkin: Suppress form submission when hitting the enter
key while the filter input is focused.
-
-
-Module Filter 7.x-1.6, 2011-09-15
----------------------------------
-#1241662 by Niklas Fiekas: Sort modules by display name.
+by greenSkin: Simplified filter rules for updates page. Instead of checkboxes,
+ now using radios.
+by greenSkin: Fixed "All" tab to be selected by default when the page is first
+ loaded.
+#1350124 by greenSkin: Fixed filtering on package tab.
+by greenSkin: Added the "All" tab back. Added a "New" tab that lists modules
+ installed within the last week.
+by greenSkin: Fixed "No Results" not showing within selected tabs.
+#1259876 by greenSkin: Filter criteria remembered after save.
+by greenSkin: Remove deprecated function moduleGetID() from JavaScript code.
+by greenSkin: Filter now uses OR instead of AND when filtering multiply
+ queries.
+#1288590 by greenSkin: Fixed Drupal.settings.moduleFilter.enabledCounts[id] is
+ undefined.
+#1344214 by eMPee584: Fixed Notice: Undefined index: #default_value in
+ theme_module_filter_system_modules_tabs().
+#1170388 by greenSkin: Fixed confict with Overlay module. Added class
+ "overlay-exclude" to tab links. Added setting to toggle the use of a URL
+ fragment when selecting tabs.
+by greenSkin: Added README.txt.
+by greenSkin: Fixed table row striping.
+by greenSkin: Fixed regular expression to not require an operator be at the
+ beginning. Make filter queries filter with AND instead of OR. Each query will
+ further filter the list rather than potentially add to it.
+by greenSkin: Spruced up the regular expression for splitting query strings.
+by greenSkin: Added "description:" operator.
+by greenSkin: Added operator support to filter. Added "requires:" and
+ "requiredBy:" operators.
+by greenSkin: Filter now processes multiple queries separated by spaces. Use
+ quotes for a single query that includes space(s).
+by greenSkin: Fixed not updating the index when a module is enabled/disabled.
+by greenSkin: Fixed visual aid for enabling/disabling modules. Previously had
+ failed to remove +/- from tab summary.
+by Kiphaas7, greenSkin: Tabs can now be configured to hide when they contain
+ no results.
+by Kiphaas7, greenSkin: Added result info to tabs. When a filter is performed,
+ a count per tab is displayed of the number of visible results for that tab.
+by greenSkin: Now more descriptive of what modules are being enabled/disabled.
+by greenSkin: Moved module operation links to below "Requires" and
+ "Required by" section.
+by greenSkin: Added a suggest class to tabs when their module is hovered.
+by greenSkin: Distinguished difference between tab ID and hash.
+by greenSkin: Only alter the menu item 'admin/reports/updates' if it first
+ exists.
+by greenSkin: Added update to force a menu rebuild. This is needed to let
+ Module Filter alter the Update Status menu item in order to provide our
+ filter on its page.
#1254140 by greenSkin: No longer return anything in hook_update_7100.
-by greenSkin: Fixed bug with visual aids sometimes not updating correctly.
-
-
-Module Filter 7.x-1.5, 2011-08-16
----------------------------------
-by greenSkin: Brought the 7.x branch current with the 6.x branch features.
-
-
-Module Filter 7.x-1.3, 2011-03-07
----------------------------------
-by realityloop: Updated CHANGELOG.txt
-
-
-Module Filter 7.x-1.2, 2011-03-07
----------------------------------
-by realityloop: Changed placement of Submit buttons for other languages
-
-
-Module Filter 7.x-1.1, 2011-03-07
----------------------------------
-by realityloop: first commit via git, broke the release somehow :/
-
-
-Module Filter 7.x-1.0, 2011-01-04
----------------------------------
-by realityloop: Fixed Undefined index error.
-by greenSkin: Removed unused .css and .js files.
+#1257860 by greenSkin: Added filter to update status report.
+by greenSkin: Moved hiding of the inputs wrapper to css rather than a style
+ attribute.
+by greenSkin: Added missing semi-colons in JavaScript.
+by greenSkin: Changed hook comment from using "Implementation of" to
+ "Implements".
+by greenSkin: Fixed showing all modules by default when no hash is present.
+by greenSkin: Turned off autocomplete for filter textfield.
+by greenSkin: Now using "all" for hash when no tab is selected.
+by greenSkin: Implemented visual aids (displays number of modules being
+ enabled/disabled as well as coloring the modules row accordingly).
+by greenSkin: Implemented the enabled count (displays the number of enabled
+ modules of total for a package.
+by greenSkin: Updated tabs setting description.
+by greenSkin: Added missing period.
+by greenSkin: Made dynamic save position default to on. Updated element title
+ on admin page and removed "DEVELOPMENTAL" from description.
+by greenSkin: Improved fixed-top positioning when toolbar is enabled.
+by greenSkin: Added fixed classes for submit button wrapper.
+by greenSkin: Changed module-filter-tabs from a class to an id.
+by greenSkin: Fixed filter on modules page when tabs are disabled.
+by greenSkin: Set min-height to #module-filter-modules.
+by greenSkin: Implemented module_filter element and using attached js and css
+ more.
+by greenSkin: Filter input and checkboxes can now have their default values set
+ based on query params.
+by greenSkin: Tabs now use URL fragments.
+by greenSkin: Fixed regular expression used to determine tab ID.
+by greenSkin: Tabs have been re-written and are functioning.
+by greenSkin: Added Module Filter to "Administration" package.
+by greenSkin: Improved filtering performance.
+by greenSkin: New filter code.
+by greenSkin: Initial tab layout modified. Modules are all in one table but
+ look like they are in packages. All JavaScript has to do on load now is
+ remove the package name and header rows from tbody then sort the rows.
+by greenSkin: Modified the menu item's description.
diff --git a/sites/all/modules/contrib/admin/module_filter/LICENSE.txt b/sites/all/modules/contrib/admin/module_filter/LICENSE.txt
old mode 100755
new mode 100644
diff --git a/sites/all/modules/contrib/admin/module_filter/README.txt b/sites/all/modules/contrib/admin/module_filter/README.txt
new file mode 100644
index 0000000..b03d970
--- /dev/null
+++ b/sites/all/modules/contrib/admin/module_filter/README.txt
@@ -0,0 +1,107 @@
+Description
+-----------
+This module provides a method for filtering modules on the modules page as well
+as for filtering projects on the update status report.
+
+The supplied filter is simpler than using your browsers find feature which
+searches the entire page. The provided filter will filter modules/projects that
+do not meet your input.
+
+Along with the filter textfield there are additional
+checkboxes that help to narrow the search more. The modules page contains four
+checkboxes: Enabled, Disabled, Required, and Unavailable. While the first two
+are self-explanatory, the latter two can take an explanation. The Required
+checkbox affects visibility of modules that are enabled and have other
+module(s) that require it also enabled. The Unavailable checkbox affects
+visibility of modules that are disabled and depend on module(s) that are
+missing.
+
+The update status report filter also contains four checkboxes: Up-to-Date,
+Update available, Security update, and Unknown. These directly affect the
+visibility of each project; whether it is up-to-date, there is an update
+available, a security update is available, or the status is unknown.
+
+Installation
+------------
+To install this module, do the following:
+
+1. Extract the tar ball that you downloaded from Drupal.org.
+
+2. Upload the entire directory and all its contents to your modules directory.
+
+Configuration
+-------------
+To enable and configure this module do the following:
+
+1. Go to Admin -> Modules, and enable Module Filter.
+
+2. Go to Admin -> Configuration -> User interface -> Module filter, and make
+ any necessary configuration changes.
+
+Tabs
+----
+By default Module Filter alters the modules page into tabs (Can be disabled on
+configuration page). In the tabs view, each package is converted to a vertical
+tab rather than a fieldset which greatly increases the ability to browse them.
+
+There are several benefits to using the tabs view over the standard view for
+the modules page. I've listed the key benefits below as well as additional
+information that pertains to each.
+
+1. The increased ease of browsing between packages.
+
+2. Allows all modules to be listed alphabetically outside of their package,
+ making it all the easier to find the module by name rather than package it
+ happens to be in.
+
+3. The operations for a module are moved within the description column giving
+ the description more "elbow room".
+
+4. Filtering is restricted to within the active tab or globally when no tab is
+ selected. By default no tab is selected which will list all modules. When a
+ tab is active and you want to get back to the 'all' state click on the
+ active tab to deselect it.
+
+5. The number of enabled modules per tab is shown on the active tab. (Can be
+ disabled on configuration page)
+
+6. Nice visual aids become available showing what modules are to be
+ enabled/disabled and the number of matching modules in each tab when
+ filtering. (Can be disabled on configuration page)
+
+7. The save configuration button becomes more accessible, either staying at
+ the bottom of the window when the tabs exceed past the bottom and at the
+ top when scrolling past the tabs. (Can be disabled on configuration page)
+
+8. When filtering, tabs that do not contain matches can be hidden. (Can be
+ enabled on configuration page)
+
+9. Tab states are remembered like individual pages allowing you to move
+ forward and backward within your selections via your browsers
+ forward/backward buttons.
+
+10. When viewing all modules (no active tab) and mousing over modules it's tab
+ becomes highlighted to signify which tab it belongs to.
+
+Filter operators
+----------------
+The modules page's filter has three filter operators available. Filter
+operators allow alternative filtering techniques. A filter operator is applied
+by typing within the filter textfield 'operator:' (where operator is the
+operator type) followed immediately with the string to pass to the operator
+function (e.g. 'requires:block'). The available operators are:
+
+description:
+ Filter based on a module's description.
+
+requiredBy:
+ Filter based on what a module is required by.
+
+requires:
+ Filter based on what a module requires.
+
+Multiple filters (or queries) can be applied by space delimiting. For example,
+the filter string 'description:ctools views' would filter down to modules with
+"ctools" in the description and "views" within the module's name. To pass a
+space within a single query wrap it within double quotes (e.g. 'requires:"chaos
+tools"' or '"bulk export"').
diff --git a/sites/all/modules/contrib/admin/module_filter/css/dynamic_position.css b/sites/all/modules/contrib/admin/module_filter/css/dynamic_position.css
new file mode 100644
index 0000000..bc3b3e7
--- /dev/null
+++ b/sites/all/modules/contrib/admin/module_filter/css/dynamic_position.css
@@ -0,0 +1,23 @@
+html.js #module-filter-submit {
+ background-color: #F6F6F6;
+ width: 239px;
+ border: 1px solid #ccc;
+ border-top: 0;
+}
+html.js #module-filter-submit .form-actions {
+ text-align: center;
+ margin: 0;
+}
+html.js #module-filter-submit input {
+ margin: 2em 0 1em;
+}
+html.js #module-filter-submit.fixed {
+ position: fixed;
+ border-top: 1px solid #ccc;
+}
+html.js #module-filter-submit.fixed-top {
+ top: 0;
+}
+html.js #module-filter-submit.fixed-bottom {
+ bottom: 0;
+}
diff --git a/sites/all/modules/contrib/admin/module_filter/css/module_filter.css b/sites/all/modules/contrib/admin/module_filter/css/module_filter.css
old mode 100755
new mode 100644
index d2353ba..b03bbb7
--- a/sites/all/modules/contrib/admin/module_filter/css/module_filter.css
+++ b/sites/all/modules/contrib/admin/module_filter/css/module_filter.css
@@ -1,4 +1,26 @@
-
+.module-filter-inputs-wrapper {
+ display: none;
+}
+.module-filter-clear {
+ display: inline;
+ position: relative;
+}
+.module-filter-clear a {
+ margin-left: 5px;
+ font-size: 11px;
+ position: absolute;
+}
#module-filter-show-wrapper .form-item {
display: inline;
}
+.module-filter-no-results {
+ text-align: center;
+ text-transform: uppercase;
+ color: #888;
+}
+#module-filter-modules {
+ position: relative;
+}
+#module-filter-modules table {
+ position: absolute;
+}
diff --git a/sites/all/modules/contrib/admin/module_filter/css/module_filter_tab-rtl.css b/sites/all/modules/contrib/admin/module_filter/css/module_filter_tab-rtl.css
new file mode 100644
index 0000000..b70f6ef
--- /dev/null
+++ b/sites/all/modules/contrib/admin/module_filter/css/module_filter_tab-rtl.css
@@ -0,0 +1,54 @@
+#module-filter-tabs {
+ float: right;
+}
+#module-filter-tabs li.selected a,
+#module-filter-tabs li.selected a:hover,
+#module-filter-tabs li.selected a:focus,
+#module-filter-tabs li.selected a:active {
+ background-color: #fff;
+ margin-left: -1px;
+ margin-right: 0;
+}
+.admin-operations {
+ float: left;
+}
+#module-filter-modules {
+ margin-right: 240px;
+}
+html.js .toggle-enable {
+ background-image: -webkit-gradient(linear, 100% 0%, 0% 0%, color-stop(50%, red), color-stop(50%, orange), color-stop(100%, orange));
+ background-image: -moz-linear-gradient(right, red 50%, orange 50%, orange 100%);
+ background-image: linear-gradient(right, red 50%, orange 50%, orange 100%);
+}
+html.js .toggle-enable.enabled {
+ background-image: -webkit-gradient(linear, 100% 0%, 0% 0%, color-stop(50%, orange), color-stop(50%, green), color-stop(100%, green));
+ background-image: -moz-linear-gradient(right, orange 50%, green 50%, green 100%);
+ background-image: linear-gradient(right, orange 50%, green 50%, green 100%);
+}
+html.js .toggle-enable.disabled {
+ background: #ccc;
+ border-color: #ddd;
+ cursor: auto;
+}
+html.js .toggle-enable.disabled div {
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #FEFEFE), color-stop(100%, #EEEEEE));
+ background-image: -moz-linear-gradient(top, #FEFEFE 0%, #EEEEEE 100%);
+ background-image: linear-gradient(top, #FEFEFE 0%, #EEEEEE 100%);
+}
+html.js .toggle-enable div {
+ -webkit-transition: right 0.2s;
+ -mox-transition: right 0.2s;
+ -o-transition: right 0.2s;
+ transition: right 0.2s;
+}
+html.js .toggle-enable div:before {
+ content: "ON";
+ left: -24px;
+}
+html.js .toggle-enable div:after {
+ content: "OFF";
+ left: -24px;
+}
+html.js .toggle-enable.off div {
+ right: 24px;
+}
diff --git a/sites/all/modules/contrib/admin/module_filter/css/module_filter_tab.css b/sites/all/modules/contrib/admin/module_filter/css/module_filter_tab.css
old mode 100755
new mode 100644
index 47e7337..fd7d0f0
--- a/sites/all/modules/contrib/admin/module_filter/css/module_filter_tab.css
+++ b/sites/all/modules/contrib/admin/module_filter/css/module_filter_tab.css
@@ -1,136 +1,259 @@
+.sticky-header {
+ z-index: 1;
+}
-#module-filter-wrapper .form-item {
- border: 0px none;
+#module-filter-tabs {
+ float: left;
+}
+#module-filter-tabs ul {
+ width: 239px;
+ list-style: none;
+ list-style-image: none;
+ background-color: #ddd;
+ border: 1px solid #ccc;
+ border-top: none;
+ margin: 0;
+ padding: 0;
+ line-height: 1;
+}
+#module-filter-tabs li {
+ background: #eee;
+ border-top: 1px solid #ccc;
+ padding: 0;
+ margin: 0;
+ min-width: 0;
+}
+#module-filter-tabs li#new-tab {
+ margin-bottom: 10px;
+ border-bottom: 1px solid #ccc;
+}
+#module-filter-tabs li.disabled,
+#module-filter-tabs li#new-tab.disabled {
+ pointer-events: none;
+ cursor: default;
+ background: #ccc;
+ border-top-color: #bbb;
+ border-bottom-color: #bbb;
+}
+#module-filter-tabs li.disabled a,
+#module-filter-tabs li.disabled span {
+ color: #999;
+}
+#module-filter-tabs li.suggest {
+ background: #F9F9F9;
+}
+#module-filter-tabs li a {
+ display: block;
+ text-decoration: none;
+ padding: 10px;
+}
+#module-filter-tabs li a span.result-info {
+ float: right;
+ font-size: 10px;
+ color: #999;
+ margin-top: 3px;
+}
+#module-filter-tabs li a span.visual-aid {
+ font-size: 8px;
+/* float: right;*/
+}
+#module-filter-tabs li span.visual-aid {
+ font-weight: bold;
+}
+#module-filter-tabs li a span.enabling {
+ color: green;
+}
+#module-filter-tabs li a span.disabling {
+ color: red;
+}
+#module-filter-tabs li strong {
+ font-size: 0.923em;
+}
+#module-filter-tabs li a:hover,
+#module-filter-tabs li a:focus {
+ outline: 1px dotted;
+ background: #d5d5d5;
+ text-decoration: none;
+ outline: 0;
+}
+#module-filter-tabs li.selected a,
+#module-filter-tabs li.selected a:hover,
+#module-filter-tabs li.selected a:focus,
+#module-filter-tabs li.selected a:active {
+ background-color: #fff;
+ margin-right: -1px;
+}
+#module-filter-tabs li .summary {
+ display: block;
+ margin-bottom: 0;
+ color: #666;
+ font-size: 0.846em;
+ padding-top: 0.4em;
+}
+#module-filter-tabs li .summary .count {
+ display: none;
+}
+#module-filter-tabs li.selected .summary .count {
+ display: block;
+}
+html.js #module-filter-submit input {
+ margin: 2em 2em 1em;
+}
+html.js .module-filter-inputs-wrapper {
+ text-align: center;
+}
+html.js .module-filter-inputs-wrapper .form-item {
margin: 0;
padding: 9px;
}
-#module-filter-wrapper .form-item:after {
-/* display: block;*/
- clear: none;
+html.js .module-filter-inputs-wrapper label {
+ display: inline;
}
-#module-filter-left {
- float: left;
- background-color: #F6F6F6;
- border: 1px solid #D6DBDE;
- margin-right: -1px;
- width: 185px;
+html.js .module-filter-inputs-wrapper input[name="module_filter[name]"] {
+ width: 80%;
}
-#module-filter-left ul {
- margin: 0px;
- padding: 0px;
- list-style: none;
+html.js #module-filter-show-wrapper {
+ margin-bottom: 1em;
}
-#module-filter-left ul li {
- background: #EFEFEF none repeat scroll 0 0;;
- border-bottom: 1px solid #D6DBDE;
- margin: 0px;
- padding: 0px;
- list-style-image: none;
+html.js #module-filter-modules {
+ margin-left: 240px;
+ border: 1px solid #ccc;
}
-#module-filter-left ul li.active {
- margin-right: -1px;
- width: 186px;
- background-color: #FFFFFF;
- position: relative;
+#module-filter-modules table {
+ border-top: none;
+ border-right: none;
+ border-left: none;
}
-#module-filter-left ul li a {
- color: #777777;
- display: block;
- padding: 0.5em;
- line-height: 100%;
- font-size: 90%;
- outline: none;
-}
-#module-filter-left ul li.active a {
- background-color: #FFFFFF;
- color: #000000;
- font-weight: bold;
-}
-#module-filter-left ul li a:hover {
- background-color: #F6F6F6;
- text-decoration: none;
-}
-#module-filter-left ul li.active a:hover {
- background-color: #FFFFFF;
-}
-#module-filter-left ul li a span.visual-aid {
- font-size: 8px;
- float: right;
-}
-#module-filter-left ul li a span.enabling {
- color: green;
-}
-#module-filter-left ul li a span.disabling {
- color: red;
- margin-left: 5px;
-}
-#module-filter-left ul li a span.counts {
- font-weight: normal;
- display: none;
- font-size: 0.8em;
- color: #333333;
- padding: 2px 0 0;
-}
-#module-filter-left ul li.active a span.counts {
- display: block;
-}
-#module-filter-submit {
+html.js #module-filter-modules table {
margin: 0;
+ border-bottom: none;
}
-#module-filter-submit .form-actions {
- text-align: center;
+html.js #module-filter-modules table tr,
+html.js #module-filter-modules table td {
+ border-left: 0;
+ border-right: 0;
}
-#module-filter-submit input.form-submit {
- margin: 1em 0 0;
+#module-filter-modules table thead {
+ display: none;
}
-#module-filter-submit.fixed {
- position: fixed;
- background-color: #F6F6F6;
- border: 1px solid #D6DBDE;
- margin-left: -1px;
- width: 185px;
+#module-filter-modules table tr.admin-package-title,
+#module-filter-modules table tr.admin-package-title td {
+ border: none !important;
+ border-top: 1px solid #ccc !important;
+ background-color: transparent !important;
+ padding: 10px 0 0;
}
-#module-filter-submit.fixed-top {
- top: 0;
+#module-filter-modules table tr.admin-package-title.first,
+#module-filter-modules table tr.admin-package-title.first td {
+ border-top: none !important;
}
-#module-filter-submit.fixed-bottom {
- bottom: 0;
+#module-filter-modules table tr.admin-package-header td {
+ border: 1px solid #ccc;
+ text-transform: uppercase;
+ background: #E1E2DC;
+ font-weight: normal;
+ padding: 3px 10px;
}
-#module-filter-right {
- display: block;
-}
-#module-filter-squeeze {
- margin-left: 186px;
- background-color: #FFFFFF;
- border: 1px solid #D6DBDE;
- height: auto !important;
-}
-.form-item-module-filter-name {
- text-align: center;
-}
-.form-item-module-filter-name label {
- display: inline;
-}
-#module-filter-show-wrapper .form-checkboxes {
- text-align: center;
-}
-#module-filter-show-wrapper .form-item:after {
- display: inline;
-}
-table.package {
- margin: 1em 0;
-}
-table.package,
-table.package thead,
-table.package tbody,
-table.package tbody tr,
-table.package td:last-child {
- border-right: 0 none;
- border-left: 0 none;
-}
-table.package tr.enabling {
+#module-filter-modules table tr.enabling {
background-color: #dfd;
}
-table.package tr.disabling {
+#module-filter-modules table tr.disabling {
background-color: #fcc;
}
+#module-filter-modules span.module-machine-name {
+ font-size: 0.9em;
+ font-weight: normal;
+}
+.admin-version {
+ white-space: nowrap;
+}
+.admin-operations a.module-link {
+ display: inline;
+}
+
+html.js .toggle-enable {
+ margin: auto;
+ position: relative;
+ width: 50px;
+ overflow: hidden;
+ height: 18px;
+ line-height: 18px;
+ font-size: 11px;
+ text-align: center;
+ cursor: pointer;
+ border: 1px solid #ccc;
+ -moz-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ -khtml-border-radius: 3px;
+ border-radius: 3px;
+ -moz-box-shadow: 0 0 10px rgba(0,0,0,0.50) inset;
+ -webkit-box-shadow: 0 0 10px rgba(0,0,0,0.50) inset;
+ box-shadow: 0 0 10px rgba(0,0,0,0.50) inset;
+ background-clip: padding-box;
+ background-image: -webkit-gradient(linear, 0% 0%, 100% 0%, color-stop(50%, red), color-stop(50%, orange), color-stop(100%, orange));
+ background-image: -moz-linear-gradient(left, red 50%, orange 50%, orange 100%);
+ background-image: linear-gradient(left, red 50%, orange 50%, orange 100%);
+}
+html.js .toggle-enable.enabled {
+ background-image: -webkit-gradient(linear, 0% 0%, 100% 0%, color-stop(50%, orange), color-stop(50%, green), color-stop(100%, green));
+ background-image: -moz-linear-gradient(left, orange 50%, green 50%, green 100%);
+ background-image: linear-gradient(left, orange 50%, green 50%, green 100%);
+}
+html.js .toggle-enable.disabled {
+ background: #ccc;
+ border-color: #ddd;
+ cursor: auto;
+}
+html.js .toggle-enable div {
+ position: relative;
+ color: #777;
+ width: 26px;
+ -moz-border-radius: 2px;
+ -webkit-border-radius: 2px;
+ -khtml-border-radius: 2px;
+ border-radius: 2px;
+ background: white;
+ text-shadow: 1px 1px 0 white;
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #FEFEFE), color-stop(100%, #EAEAEA));
+ background-image: -moz-linear-gradient(top, #FEFEFE 0%, #EAEAEA 100%);
+ background-image: linear-gradient(top, #FEFEFE 0%, #EAEAEA 100%);
+ -webkit-transition: left 0.2s;
+ -mox-transition: left 0.2s;
+ -o-transition: left 0.2s;
+ transition: left 0.2s;
+}
+html.js .toggle-enable.disabled div {
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #FEFEFE), color-stop(100%, #EEEEEE));
+ background-image: -moz-linear-gradient(top, #FEFEFE 0%, #EEEEEE 100%);
+ background-image: linear-gradient(top, #FEFEFE 0%, #EEEEEE 100%);
+}
+html.js .toggle-enable div:after,
+html.js .toggle-enable div:before {
+ color: white;
+ text-shadow: none;
+ width: 25px;
+ position: absolute;
+ top: 0;
+ font-size: 9px;
+ font-weight: bold;
+}
+html.js .toggle-enable div:before {
+ content: "OFF";
+ left: -24px;
+}
+html.js .toggle-enable div:after {
+ content: "ON";
+ right: -24px;
+}
+html.js .toggle-enable.off div {
+ left: 24px;
+}
+
+#module-filter-tabs.top-fixed {
+ position: fixed;
+ top: 0;
+}
+#module-filter-tabs.bottom-fixed {
+ position: fixed;
+ bottom: 0;
+}
diff --git a/sites/all/modules/contrib/admin/module_filter/css/modules.css b/sites/all/modules/contrib/admin/module_filter/css/modules.css
new file mode 100644
index 0000000..0659825
--- /dev/null
+++ b/sites/all/modules/contrib/admin/module_filter/css/modules.css
@@ -0,0 +1,53 @@
+#system-modules table {
+ table-layout: fixed;
+}
+#system-modules th.checkbox {
+ width: 8%;
+}
+#system-modules th.name {
+ width: 25%;
+}
+#system-modules th.version {
+ width: 10%;
+}
+#system-modules th.links {
+ width: 15%;
+}
+#system-modules td {
+ vertical-align: top;
+}
+#system-modules .expand.inner {
+ background: transparent url(../images/collapsed.png) left 0.6em no-repeat;
+ margin-left: -12px;
+ padding-left: 12px;
+}
+#system-modules .expanded.expand.inner {
+ background: transparent url(../images/expanded.png) left 0.6em no-repeat;
+}
+#system-modules .description {
+ cursor: pointer;
+}
+#system-modules .description .inner {
+ overflow: hidden; /* truncates descriptions if too long */
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+#system-modules .description .inner.expanded > * {
+ cursor: auto;
+}
+#system-modules .description .requirements,
+#system-modules .description .links {
+ display: none;
+}
+#system-modules .description .expanded.inner {
+ overflow: visible;
+ white-space: normal;
+}
+#system-modules .description .expanded .requirements,
+#system-modules .description .expanded .links {
+ display: block;
+}
+#system-modules .requirements {
+ padding: 5px 0;
+ max-width: 490px;
+}
diff --git a/sites/all/modules/contrib/admin/module_filter/css/update_status.css b/sites/all/modules/contrib/admin/module_filter/css/update_status.css
new file mode 100644
index 0000000..c0bee44
--- /dev/null
+++ b/sites/all/modules/contrib/admin/module_filter/css/update_status.css
@@ -0,0 +1,18 @@
+#module-filter-update-status-form {
+ float: right;
+}
+.module-filter-inputs-wrapper label {
+ display: inline;
+}
+.module-filter-inputs-wrapper .form-item-module-filter-name {
+ margin-bottom: 0;
+ padding-bottom: 0;
+ text-align: right;
+}
+#module-filter-show-wrapper .form-item {
+ padding: 5px;
+}
+p.module-filter-no-results {
+ clear: both;
+ padding-top: 30px;
+}
diff --git a/sites/all/modules/contrib/admin/module_filter/images/collapsed.png b/sites/all/modules/contrib/admin/module_filter/images/collapsed.png
new file mode 100644
index 0000000000000000000000000000000000000000..91f3fd40ede024798b6de5ea2675bb692a3cfa95
GIT binary patch
literal 105
zcmeAS@N?(olHy`uVBq!ia0vp^>>$j@3?%=}IXVGIu?6^qxc>kDAIJlF_r}R
y1v5B2yO9Ru2zt6WhH%Ixhb6Q*Xr>9K@iDN~Fr3*g^XWQJlEKr}&t;ucLK6T5e;aZD
literal 0
HcmV?d00001
diff --git a/sites/all/modules/contrib/admin/module_filter/images/expanded.png b/sites/all/modules/contrib/admin/module_filter/images/expanded.png
new file mode 100644
index 0000000000000000000000000000000000000000..46f39ecb351cff65243fa9a614a69d039e1302a5
GIT binary patch
literal 106
zcmeAS@N?(olHy`uVBq!ia0vp^>>$j@3?%=}IXVGIu?6^qxc>kDAIJlF_r}R
z1v5B2yO9Ru2zk0VhE&W+{&76uaKb@_0}N~oA{!VF-#vS9IZ&3t)78&qol`;+0EMF;
ATL1t6
literal 0
HcmV?d00001
diff --git a/sites/all/modules/contrib/admin/module_filter/js/dynamic_position.js b/sites/all/modules/contrib/admin/module_filter/js/dynamic_position.js
old mode 100755
new mode 100644
index 10c66b4..41c5731
--- a/sites/all/modules/contrib/admin/module_filter/js/dynamic_position.js
+++ b/sites/all/modules/contrib/admin/module_filter/js/dynamic_position.js
@@ -1,33 +1,48 @@
(function($) {
- Drupal.behaviors.moduleFilterDynamicPosition = {
- attach: function() {
- $(window).scroll(function() {
+
+Drupal.behaviors.moduleFilterDynamicPosition = {
+ attach: function(context) {
+ var $window = $(window);
+
+ $('#module-filter-wrapper', context).once('dynamic-position', function() {
+ // Move the submit button just below the tabs.
+ $('#module-filter-tabs').append($('#module-filter-submit'));
+
+ var positionSubmit = function() {
+ var $tabs = $('#module-filter-tabs');
+ var $submit = $('#module-filter-submit', $tabs);
+
// Vertical movement.
- var top = $('#module-filter-tabs').offset().top;
- var bottom = top + $('#module-filter-tabs').height();
- var windowHeight = $(window).height();
- if (((bottom - windowHeight) > ($(window).scrollTop() - $('#module-filter-submit').height())) && $(window).scrollTop() + windowHeight - $('#module-filter-submit').height() - $('#all-tab').height() > top) {
- $('#module-filter-submit').removeClass('fixed-top').addClass('fixed fixed-bottom');
+ var bottom = $tabs.offset().top + $tabs.outerHeight();
+ if ($submit.hasClass('fixed-bottom')) {
+ bottom += $submit.height();
}
- else if (bottom < $(window).scrollTop()) {
- $('#module-filter-submit').removeClass('fixed-bottom').addClass('fixed fixed-top');
+ if (bottom >= $window.height() + $window.scrollTop()) {
+ $submit.addClass('fixed fixed-bottom');
+ $tabs.css('padding-bottom', $submit.height());
}
else {
- $('#module-filter-submit').removeClass('fixed fixed-bottom fixed-top');
+ $submit.removeClass('fixed fixed-bottom');
+ $tabs.css('padding-bottom', 0);
}
// Horizontal movement.
- if ($('#module-filter-submit').hasClass('fixed-bottom') || $('#module-filter-submit').hasClass('fixed-top')) {
- var left = $('#module-filter-tabs').offset().left - $(window).scrollLeft();
- if (left != $('#module-filter-submit').offset().left - $(window).scrollLeft()) {
- $('#module-filter-submit').css('left', left);
+ if ($submit.hasClass('fixed-bottom') || $submit.hasClass('fixed-top')) {
+ var left = $tabs.offset().left - $window.scrollLeft();
+ if (left != $submit.offset().left - $window.scrollLeft()) {
+ $submit.css('left', left);
}
}
- });
- $(window).trigger('scroll');
- $(window).resize(function() {
- $(window).trigger('scroll');
- });
- }
+ };
+
+ // Control the positioning.
+ $window.scroll(positionSubmit);
+ $window.resize(positionSubmit);
+ var moduleFilter = $('input[name="module_filter[name]"]').data('moduleFilter');
+ moduleFilter.element.bind('moduleFilter:adjustHeight', positionSubmit);
+ moduleFilter.adjustHeight();
+ });
}
+};
+
})(jQuery);
diff --git a/sites/all/modules/contrib/admin/module_filter/js/module_filter.js b/sites/all/modules/contrib/admin/module_filter/js/module_filter.js
old mode 100755
new mode 100644
index 49f6b7a..4fcf6e6
--- a/sites/all/modules/contrib/admin/module_filter/js/module_filter.js
+++ b/sites/all/modules/contrib/admin/module_filter/js/module_filter.js
@@ -1,120 +1,274 @@
-
(function ($) {
- var moduleFilterTimeOut;
- var moduleFilterTextFilter = '';
- Drupal.behaviors.moduleFilter = {
- attach: function() {
- $("#module-filter-wrapper").show();
- $('input[name="module_filter[name]"]').focus();
- $('input[name="module_filter[name]"]').keyup(function(e) {
- switch (e.which) {
- case 13:
- if (moduleFilterTimeOut) {
- clearTimeout(moduleFilterTimeOut);
- }
+Drupal.ModuleFilter = {};
- moduleFilter(moduleFilterTextFilter);
- break;
- default:
- if (moduleFilterTextFilter != $(this).val()) {
- moduleFilterTextFilter = this.value;
- if (moduleFilterTimeOut) {
- clearTimeout(moduleFilterTimeOut);
- }
+Drupal.ModuleFilter.explode = function(string) {
+ var queryArray = string.match(/([a-zA-Z]+\:(\w+|"[^"]+")*)|\w+|"[^"]+"/g);
+ if (!queryArray) {
+ queryArray = new Array();
+ }
+ var i = queryArray.length;
+ while (i--) {
+ queryArray[i] = queryArray[i].replace(/"/g, "");
+ }
+ return queryArray;
+};
- moduleFilterTimeOut = setTimeout('moduleFilter("' + moduleFilterTextFilter + '")', 500);
- }
- break;
+Drupal.ModuleFilter.getState = function(key) {
+ if (!Drupal.ModuleFilter.state) {
+ Drupal.ModuleFilter.state = {};
+ var cookie = $.cookie('DrupalModuleFilter');
+ var query = cookie ? cookie.split('&') : [];
+ if (query) {
+ for (var i in query) {
+ // Extra check to avoid js errors in Chrome, IE and Safari when
+ // combined with JS like twitter's widget.js.
+ // See http://drupal.org/node/798764.
+ if (typeof(query[i]) == 'string' && query[i].indexOf('=') != -1) {
+ var values = query[i].split('=');
+ if (values.length === 2) {
+ Drupal.ModuleFilter.state[values[0]] = values[1];
+ }
}
- });
- $('input[name="module_filter[name]"]').keypress(function(e) {
- if (e.which == 13) e.preventDefault();
- });
-
- $('#edit-module-filter-show-enabled').change(function() {
- moduleFilter($('input[name="module_filter[name]"]').val());
- });
- $('#edit-module-filter-show-disabled').change(function() {
- moduleFilter($('input[name="module_filter[name]"]').val());
- });
- $('#edit-module-filter-show-required').change(function() {
- moduleFilter($('input[name="module_filter[name]"]').val());
- });
- $('#edit-module-filter-show-unavailable').change(function() {
- moduleFilter($('input[name="module_filter[name]"]').val());
- });
+ }
}
}
+ return Drupal.ModuleFilter.state[key] ? Drupal.ModuleFilter.state[key] : false;
+};
- moduleFilter = function(string) {
- stringLowerCase = string.toLowerCase();
+Drupal.ModuleFilter.setState = function(key, value) {
+ var existing = Drupal.ModuleFilter.getState(key);
+ if (existing != value) {
+ Drupal.ModuleFilter.state[key] = value;
+ var query = [];
+ for (var i in Drupal.ModuleFilter.state) {
+ query.push(i + '=' + Drupal.ModuleFilter.state[i]);
+ }
+ $.cookie('DrupalModuleFilter', query.join('&'), { expires: 7, path: '/' });
+ }
+};
- $("fieldset table tbody tr td label strong").each(function(i) {
- var $row = $(this).parents('tr');
- var module = $(this).text();
- var moduleLowerCase = module.toLowerCase();
- var $fieldset = $row.parents('fieldset');
+Drupal.ModuleFilter.Filter = function(element, selector, options) {
+ var self = this;
- if (string != '') {
- if ($fieldset.hasClass('collapsed')) {
- $fieldset.removeClass('collapsed');
+ this.element = element;
+ this.text = $(this.element).val();
+
+ this.settings = Drupal.settings.moduleFilter;
+
+ this.selector = selector;
+
+ this.options = $.extend({
+ delay: 500,
+ striping: false,
+ childSelector: null,
+ empty: Drupal.t('No results'),
+ rules: new Array()
+ }, options);
+ if (this.options.wrapper == undefined) {
+ this.options.wrapper = $(self.selector).parent();
+ }
+
+ // Add clear button.
+ this.element.after('
';
+ }
+}
diff --git a/sites/all/modules/contrib/dev/ctools/CHANGELOG.txt b/sites/all/modules/contrib/dev/ctools/CHANGELOG.txt
deleted file mode 100644
index c5bd5e6..0000000
--- a/sites/all/modules/contrib/dev/ctools/CHANGELOG.txt
+++ /dev/null
@@ -1,82 +0,0 @@
-Current API VERSION: 2.0. See API.txt for more information.
-
-ctools 7.x-1.x-dev
-==================
-#1008120: "New custom content" shows empty form if custom content panes module is not enabled.
-#999302 by troky: Fix jump menu. Apparently this wasn't actually committed the last time it was committed.
-#1065976 by tekante and David_Rothstein: Reset plugin static cache during module enable to prevent stale data from harming export ui.
-#1016510 by EclipseGC: Make the taxonomy system page functional.
-
-ctools 7.x-1.x-alpha2 (05-Jan-2011)
-===================================
-
-#911396 by alex_b: Prevent notices in export UI.
-#919768 by mikey_p: Allow url options to be sent to ctools_ajax_command_url().
-#358953 by cedarm: Allow term context to return lowercase, spaces to dashes versions of terms.
-#931434 by EclipseGc: Argument plugin for node revision ID.
-#910656: CTools AJAX sample wizard demo "domesticated" checkbox value not stored.
-#922442 by EugenMayer, neclimdul and voxpelli: Make sure ctools_include can handle '' or NULL directory.
-#919956 by traviss359: Correct example in wizard advanced help.
-#942968: Fix taxonomy term access rule with tag term vocabs.
-#840344: node add argument had crufty code causing notices.
-#944462 by longhairedgit: Invalid character in regex causes rare notice.
-#938778 by dereine: Fix profile content type for D7 updates.
-Add detach event to modal close so that wysiwyg can detach the editor.
-Variant titles showing up as blank if more than one variant on a page.
-#940016: token support was not yet updated for D7.
-#940446: Skip validation on back and cancel buttons in all wizards.
-#954492: Redirect not always working in wizard.inc
-#955348: Lack of redirect on "Update" button in Page Manager causing data loss sometimes.
-#941778: Update and save button should not appear in the "Add variant" path.
-#955070 by EclipseGc: Update ctools internal page tokens to work properly on content all content.
-#956890 by EclipseGc: Update views_content to not use views dependency since that is gone.
-#954728 by EclipseGc: Update node template page function name to not collide with new hook_node_view().
-#946534 by EclipseGc: Add support for field content on all entitities.
-#952586 by EclipseGc: Fix node_author content type.
-#959206: If a context is not set when rendering content, attempt to guess the context (fixes Views panes where "From context" was added but pane was never edited.)
-#961654 by benshell: drupal_alter() only supports 4 arguments.
-#911362 by alex_b: Facilitate plugin cache resets for tests.
-#945360 by naxoc: node_tag_new() not updated to D7.
-#953804 by EclipseGc: Fix node comment rendering.
-#953542 by EclipseGc: Fix node rendering.
-#953776 by EclipseGc: Fix node link rendering.
-#954772 by EclipseGc: Fix node build mode selection in node content type.
-#954762 by EclipseGc: Fix comment forbidden theme call.
-#954894 by EclipseGc: Fix breadcrumb content type.
-#955180 by EclipseGc: Fix page primary navigation type.
-#957190 by EclipseGc: Fix page secondary navigation type.
-#957194 by EclipseGc: Remove mission content type, since D7 no longer has a site mission.
-#957348 by EclipseGc: Fix search form URL path.
-#952586 by andypost: Use format_username for displaying unlinked usernames.
-#963800 by benshell: Fix query to fetch custom block title.
-#983496 by Amitaibu: Fix term argument to use proper load function.
-#989484 by Amitaibu: Fix notice in views plugin.
-#982496: Fix token context.
-#995026: Fix export UI during enable/disable which would throw notices and not properly set/unset menu items.
-#998870 by Amitaibu: Fix notice when content has no icon by using function already designed for that.
-#983576 by Amitaibu: Node view fallback task showed white screen.
-#1004644 by pillarsdotnet: Update a missed theme() call to D7.
-#1006162 by aspilicious: .info file cleanup.
-#998312 by dereine: Support the expanded/hidden options that Views did for dependent.js
-#955030: Remove no longer supported footer message content type.
-Fix broken query in term context config.
-#992022 by pcambra: Fix node autocomplete.
-#946302 by BerdArt and arywyr: Fix PHP 5.3 reference error.
-#980528 by das-peter: Notice fix with entity settings.
-#999302 by troky: ctools_jump_menu() needed updating to new form parameters.
-#964174: stylizer plugin theme delegation was in the wrong place, causing errors.
-#991658 by burlap: Fully load the "user" context for the logged in user because not all fields are in $user.
-#1014866 by das-peter: Smarter title panes, notice fix on access plugin descriptions.
-#1015662 by troky: plugin .info files were not using correct filepaths.
-#941780 by EclipseGc: Restore the "No blocks" functionality.
-#951048 by EclipseGc: Tighter entity integration so that new entities are automatic contexts and relationships.
-#941800 by me and aspilicious: Use Drupal 7 #machine_name automation on page manager pages and all export_ui defaults.
-Disabled exportables and pages not properly greyed out.
-#969208 by me and benshell: Get user_view and user profile working.
-#941796: Recategorize blocks
-
-ctools 7.x-1.x-alpha1
-=====================
-
-Changelog reset for 7.x
-Basic conversion done during sprint.
diff --git a/sites/all/modules/contrib/dev/ctools/UPGRADE.txt b/sites/all/modules/contrib/dev/ctools/UPGRADE.txt
index 844ecce..2fbfa4f 100644
--- a/sites/all/modules/contrib/dev/ctools/UPGRADE.txt
+++ b/sites/all/modules/contrib/dev/ctools/UPGRADE.txt
@@ -60,4 +60,4 @@ Upgrading from ctools-6.x-1.x to ctools-7.x-2.x:
For all of these forms, the separate settings #trees in the form are now
gone, so form ids may be adjusted. Also, these are now all real forms
- using CTools form wizard instead of fake subforms as previously.
\ No newline at end of file
+ using CTools form wizard instead of fake subforms as previously.
diff --git a/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.info b/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.info
index 1e9031d..9bb3394 100644
--- a/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.info
+++ b/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.info
@@ -3,12 +3,9 @@ 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 2015-01-28
-version = "7.x-1.6"
+; Information added by Drupal.org packaging script on 2019-02-08
+version = "7.x-1.15"
core = "7.x"
project = "ctools"
-datestamp = "1422471484"
-
+datestamp = "1549603691"
diff --git a/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.module b/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.module
index afb15b9..1050caa 100644
--- a/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.module
+++ b/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.module
@@ -137,7 +137,7 @@ function bulk_export_export($cli = FALSE, $options = array()) {
// Add hook_ctools_plugin_api at the top of the module code, if there is any.
if ($api_code) {
foreach ($api_code as $api_hook => $text) {
- $api = "\n/**\n";
+ $api = "\n/**\n";
$api .= " * Implements hook_$api_hook().\n";
$api .= " */\n";
$api .= "function {$module_name}_$api_hook(\$module, \$api) {\n";
@@ -148,7 +148,7 @@ function bulk_export_export($cli = FALSE, $options = array()) {
}
if ($module_code) {
- $module = "conf['css_id'] = 'my-id';
+}
+
/**
* @} End of "addtogroup hooks".
*/
diff --git a/sites/all/modules/contrib/dev/ctools/ctools.info b/sites/all/modules/contrib/dev/ctools/ctools.info
index bd2e3c1..188b55d 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools.info
+++ b/sites/all/modules/contrib/dev/ctools/ctools.info
@@ -2,16 +2,25 @@ 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 2015-01-28
-version = "7.x-1.6"
+; Tests.
+files[] = tests/context.test
+files[] = tests/css.test
+files[] = tests/css_cache.test
+files[] = tests/ctools.plugins.test
+files[] = tests/ctools.test
+files[] = tests/math_expression.test
+files[] = tests/math_expression_stack.test
+files[] = tests/object_cache.test
+files[] = tests/object_cache_unit.test
+files[] = tests/page_tokens.test
+
+; Information added by Drupal.org packaging script on 2019-02-08
+version = "7.x-1.15"
core = "7.x"
project = "ctools"
-datestamp = "1422471484"
-
+datestamp = "1549603691"
diff --git a/sites/all/modules/contrib/dev/ctools/ctools.install b/sites/all/modules/contrib/dev/ctools/ctools.install
index e96c743..d50bc9f 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools.install
+++ b/sites/all/modules/contrib/dev/ctools/ctools.install
@@ -12,24 +12,25 @@
function ctools_requirements($phase) {
$requirements = array();
if ($phase == 'runtime') {
+ $t = get_t();
$requirements['ctools_css_cache'] = array(
- 'title' => t('CTools CSS Cache'),
+ 'title' => $t('CTools CSS Cache'),
'severity' => REQUIREMENT_OK,
- 'value' => t('Exists'),
+ 'value' => $t('Exists'),
);
$path = 'public://ctools/css';
if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
- $requirements['ctools_css_cache']['description'] = t('The CTools CSS cache directory, %path could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.', array('%path' => file_uri_target($path)));
+ $requirements['ctools_css_cache']['description'] = $t('The CTools CSS cache directory, %path could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.', array('%path' => file_uri_target($path)));
$requirements['ctools_css_cache']['severity'] = REQUIREMENT_ERROR;
- $requirements['ctools_css_cache']['value'] = t('Unable to create');
+ $requirements['ctools_css_cache']['value'] = $t('Unable to create');
}
if (!function_exists('error_get_last')) {
- $requirements['ctools_php_52']['title'] = t('CTools PHP requirements');
- $requirements['ctools_php_52']['description'] = t('CTools requires certain features only available in PHP 5.2.0 or higher.');
+ $requirements['ctools_php_52']['title'] = $t('CTools PHP requirements');
+ $requirements['ctools_php_52']['description'] = $t('CTools requires certain features only available in PHP 5.2.0 or higher.');
$requirements['ctools_php_52']['severity'] = REQUIREMENT_WARNING;
- $requirements['ctools_php_52']['value'] = t('PHP !version', array('!version' => phpversion()));
+ $requirements['ctools_php_52']['value'] = $t('PHP !version', array('!version' => phpversion()));
}
}
@@ -40,7 +41,19 @@ function ctools_requirements($phase) {
* Implements hook_schema().
*/
function ctools_schema() {
- return ctools_schema_3();
+ return ctools_schema_4();
+}
+
+/**
+ * Version 4 of the CTools schema.
+ */
+function ctools_schema_4() {
+ $schema = ctools_schema_3();
+
+ // Removed due to alternative database configuration issues.
+ // @see https://www.drupal.org/project/ctools/issues/2941920
+
+ return $schema;
}
/**
@@ -49,7 +62,7 @@ function ctools_schema() {
function ctools_schema_3() {
$schema = ctools_schema_2();
- // update the 'obj' field to be 128 bytes long:
+ // Update the 'obj' field to be 128 bytes long:
$schema['ctools_object_cache']['fields']['obj']['length'] = 128;
return $schema;
@@ -61,7 +74,7 @@ function ctools_schema_3() {
function ctools_schema_2() {
$schema = ctools_schema_1();
- // update the 'name' field to be 128 bytes long:
+ // Update the 'name' field to be 128 bytes long:
$schema['ctools_object_cache']['fields']['name']['length'] = 128;
// Update the 'data' field to be type 'blob'.
@@ -95,10 +108,10 @@ function ctools_schema_2() {
'serialize' => TRUE,
),
'filter' => array(
- 'type' => 'int',
- 'size' => 'tiny',
- 'description' => 'Whether or not this CSS needs to be filtered.',
- ),
+ 'type' => 'int',
+ 'size' => 'tiny',
+ 'description' => 'Whether or not this CSS needs to be filtered.',
+ ),
),
'primary key' => array('cid'),
);
@@ -197,7 +210,7 @@ function ctools_update_6003() {
if ($result) {
db_delete('system')->condition('name', 'panels_views')->execute();
module_enable(array('views_content'), TRUE);
- }
+ }
}
/**
@@ -216,7 +229,7 @@ function ctools_update_6005() {
}
/**
- * ctools_custom_content table was originally here, but is now moved to
+ * The ctools_custom_content table was originally here, but is now moved to
* its own module.
*/
function ctools_update_6007() {
@@ -230,18 +243,18 @@ function ctools_update_6007() {
}
/**
- * ctools_object_cache needs to be defined as a blob.
+ * The ctools_object_cache needs to be defined as a blob.
*/
function ctools_update_6008() {
db_delete('ctools_object_cache')
->execute();
db_change_field('ctools_object_cache', 'data', 'data', array(
- 'type' => 'blob',
- 'size' => 'big',
- 'description' => 'Serialized data being stored.',
- 'serialize' => TRUE,
- )
+ 'type' => 'blob',
+ 'size' => 'big',
+ 'description' => 'Serialized data being stored.',
+ 'serialize' => TRUE,
+ )
);
}
@@ -263,3 +276,24 @@ function ctools_update_7001() {
'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.',
));
}
+
+/**
+ * Increase the length of the ctools_object_cache.name column to 255.
+ */
+function ctools_update_7002() {
+ // Removed due to alternative database configuration issues.
+ // @see https://www.drupal.org/project/ctools/issues/2941920
+}
+
+/**
+ * Revert the length of the ctools_object_cache.name column back to 128.
+ */
+function ctools_update_7003() {
+ db_delete('ctools_object_cache')->execute();
+ db_change_field('ctools_object_cache', 'name', 'name', array(
+ 'type' => 'varchar',
+ 'length' => '128',
+ 'not null' => TRUE,
+ 'description' => 'The name of the object this cache is attached to.',
+ ));
+}
diff --git a/sites/all/modules/contrib/dev/ctools/ctools.module b/sites/all/modules/contrib/dev/ctools/ctools.module
index c37b96f..62f2919 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools.module
+++ b/sites/all/modules/contrib/dev/ctools/ctools.module
@@ -9,7 +9,7 @@
* must be implemented in the module file.
*/
-define('CTOOLS_API_VERSION', '2.0.8');
+define('CTOOLS_API_VERSION', '2.0.9');
/**
* The current working ctools version.
@@ -22,8 +22,11 @@ define('CTOOLS_API_VERSION', '2.0.8');
* 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)
+ *
+ * @deprecated in CTools 1.15 and will be removed before CTools 2.0.0.
+ * Use the version provided by the drupal.org packaging system.
*/
-define('CTOOLS_MODULE_VERSION', '7.x-1.6');
+define('CTOOLS_MODULE_VERSION', '7.x-1.13');
/**
* Test the CTools API version.
@@ -75,6 +78,9 @@ define('CTOOLS_MODULE_VERSION', '7.x-1.6');
* The minimum version of CTools necessary for your software to run with it.
* @param $maximum
* The maximum version of CTools allowed for your software to run with it.
+ *
+ * @return bool
+ * TRUE if the running ctools is usable, FALSE otherwise.
*/
function ctools_api_version($minimum, $maximum = NULL) {
if (version_compare(CTOOLS_API_VERSION, $minimum, '<')) {
@@ -89,8 +95,7 @@ function ctools_api_version($minimum, $maximum = NULL) {
}
// -----------------------------------------------------------------------
-// General utility functions
-
+// General utility functions.
/**
* Include .inc files as necessary.
*
@@ -118,6 +123,7 @@ function ctools_api_version($minimum, $maximum = NULL) {
* @param $dir
* Optional subdirectory containing the include file.
*/
+
function ctools_include($file, $module = 'ctools', $dir = 'includes') {
static $used = array();
@@ -147,8 +153,8 @@ function ctools_form_include(&$form_state, $file, $module = 'ctools', $dir = 'in
/**
* Add an arbitrary path to the $form_state so it can work with form cache.
*
- * module_load_include uses an unfortunately annoying syntax to work, making it
- * difficult to translate the more simple $path + $file syntax.
+ * The module_load_include() function uses an unfortunately annoying syntax to
+ * work, making it difficult to translate the more simple $path + $file syntax.
*/
function ctools_form_include_file(&$form_state, $filename) {
if (!isset($form_state['build_info']['args'])) {
@@ -172,6 +178,9 @@ function ctools_form_include_file(&$form_state, $filename) {
* Optional module containing the include.
* @param $dir
* Optional subdirectory containing the include file.
+ *
+ * @return string
+ * A string containing the appropriate path from drupal root.
*/
function ctools_image_path($image, $module = 'ctools', $dir = 'images') {
return drupal_get_path('module', $module) . "/$dir/" . $image;
@@ -211,6 +220,9 @@ function ctools_add_css($file, $module = 'ctools', $dir = 'css') {
* Optional module containing the include.
* @param $dir
* Optional subdirectory containing the include file.
+ *
+ * @return string
+ * A string containing the appropriate path from drupal root.
*/
function ctools_attach_css($file, $module = 'ctools', $dir = 'css') {
return drupal_get_path('module', $module) . "/$dir/$file.css";
@@ -249,6 +261,9 @@ function ctools_add_js($file, $module = 'ctools', $dir = 'js') {
* Optional module containing the include.
* @param $dir
* Optional subdirectory containing the include file.
+ *
+ * @return string
+ * A string containing the appropriate path from drupal root.
*/
function ctools_attach_js($file, $module = 'ctools', $dir = 'js') {
return drupal_get_path('module', $module) . "/$dir/$file.js";
@@ -267,16 +282,29 @@ function ctools_get_roles() {
return user_roles();
}
-/*
- * Break x,y,z and x+y+z into an array. Numeric only.
+/**
+ * Parse integer sequences of the form "x,y,z" or "x+y+z" into separate values.
+ *
+ * A string with integers separated by comma (,) is reported as an 'and' set;
+ * separation by a plus sign (+) or a space ( ) is an 'or' set. The meaning
+ * of this is up to the caller. Negative or fractional numbers are not
+ * recognised.
+ *
+ * Additional space characters within or around the sequence are not allowed.
*
* @param $str
* The string to parse.
*
- * @return $object
- * An object containing
- * - operator: Either 'and' or 'or'
- * - value: An array of numeric values.
+ * @return object
+ * An object containing the properties:
+ *
+ * - operator: Either 'and' or 'or' when there are multiple matched values.
+ * Absent when invalid_input is TRUE or there is only one value.
+ * - value: An array of integers (never strings) from $str. An empty array is
+ * returned if the input is empty. A single integer input is returned
+ * as a single value, but no 'operator' is defined.
+ * - invalid_input: TRUE if input could not be parsed and the values array
+ * will contain just -1. This property is otherwise absent.
*/
function ctools_break_phrase($str) {
$object = new stdClass();
@@ -286,7 +314,7 @@ function ctools_break_phrase($str) {
$object->operator = 'or';
$object->value = preg_split('/[+ ]/', $str);
}
- else if (preg_match('/^([0-9]+,)*[0-9]+$/', $str)) {
+ elseif (preg_match('/^([0-9]+,)*[0-9]+$/', $str)) {
$object->operator = 'and';
$object->value = explode(',', $str);
}
@@ -304,7 +332,7 @@ function ctools_break_phrase($str) {
// Doubly ensure that all values are numeric only.
foreach ($object->value as $id => $value) {
- $object->value[$id] = intval($value);
+ $object->value[$id] = (int) $value;
}
return $object;
@@ -314,23 +342,29 @@ function ctools_break_phrase($str) {
* Set a token/value pair to be replaced later in the request, specifically in
* ctools_page_token_processing().
*
- * @param $token
+ * @param string $token
* The token to be replaced later, during page rendering. This should
- * ideally be a string inside of an HTML comment, so that if there is
- * no replacement, the token will not render on the page.
- * @param $type
+ * ideally be a string inside of an HTML comment, so that if there is
+ * no replacement, the token will not render on the page.
+ * If $token is NULL, the token set is not changed, but is still
+ * returned.
+ * @param string $type
* The type of the token. Can be either 'variable', which will pull data
- * directly from the page variables
- * @param $argument
- * If $type == 'variable' then argument should be the key to fetch from
- * the $variables. If $type == 'callback' then it should either be the
- * callback, or an array that will be sent to call_user_func_array().
+ * directly from the page variables, or 'callback', which causes a function
+ * to be called to calculate the value. No other values are supported.
+ * @param string|array $argument
+ * For $type of:
+ * - 'variable': argument should be the key to fetch from the $variables.
+ * - 'callback': then it should either be the callback function name as a
+ * string, or an array that will be sent to call_user_func_array(). Argument
+ * arrays must not use array keys (i.e. $a[0] is the first and $a[1] the
+ * second element, etc.)
*
- * @return
+ * @return array
* A array of token/variable names to be replaced.
*/
function ctools_set_page_token($token = NULL, $type = NULL, $argument = NULL) {
- static $tokens = array();
+ $tokens = &drupal_static('ctools_set_page_token', array());
if (isset($token)) {
$tokens[$token] = array($type, $argument);
@@ -339,13 +373,32 @@ function ctools_set_page_token($token = NULL, $type = NULL, $argument = NULL) {
}
/**
- * Easily set a token from the page variables.
+ * Reset the defined page tokens within this request.
+ *
+ * Introduced for simpletest purposes. Normally not needed.
+ */
+function ctools_reset_page_tokens() {
+ drupal_static_reset('ctools_set_page_token');
+}
+
+/**
+ * Set a replacement token from the containing element's children during #post_render.
*
* This function can be used like this:
- * $token = ctools_set_variable_token('tabs');
+ * $token = ctools_set_variable_token('tabs');
*
- * $token will then be a simple replacement for the 'tabs' about of the
- * variables available in the page template.
+ * The token "" would then be replaced by the value of
+ * this element's (sibling) render array key 'tabs' during post-render (or be
+ * deleted if there was no such key by that point).
+ *
+ * @param string $token
+ * The token string for the page callback, e.g. 'title'.
+ *
+ * @return string
+ * The constructed token.
+ *
+ * @see ctools_set_callback_token()
+ * @see ctools_page_token_processing()
*/
function ctools_set_variable_token($token) {
$string = '';
@@ -354,10 +407,45 @@ function ctools_set_variable_token($token) {
}
/**
- * Easily set a token from the page variables.
+ * Set a replacement token from the value of a function during #post_render.
*
* This function can be used like this:
- * $token = ctools_set_variable_token('id', 'mymodule_myfunction');
+ * $token = ctools_set_callback_token('id', 'mymodule_myfunction');
+ *
+ * Or this (from its use in ctools_page_title_content_type_render):
+ * $token = ctools_set_callback_token('title', array(
+ * 'ctools_page_title_content_type_token', $conf['markup'], $conf['id'], $conf['class']
+ * )
+ * );
+ *
+ * The token (e.g: "")
+ * would then be replaced during post-render by the return value of:
+ *
+ * ctools_page_title_content_type_token($value_markup, $value_id, $value_class);
+ *
+ * @param string $token
+ * The token string for the page callback, e.g. 'title'.
+ *
+ * @param string|array $callback
+ * For callback functions that require no args, the name of the function as a
+ * string; otherwise an array of two or more elements: the function name
+ * followed by one or more function arguments.
+ *
+ * NB: the value of $callback must be a procedural (non-class) function that
+ * passes the php function_exists() check.
+ *
+ * The callback function itself will be called with args dependent
+ * on $callback. If:
+ * - $callback is a string, the function is called with a reference to the
+ * render array;
+ * - $callback is an array, the function is called with $callback merged
+ * with an array containing a reference to the render array.
+ *
+ * @return string
+ * The constructed token.
+ *
+ * @see ctools_set_variable_token()
+ * @see ctools_page_token_processing()
*/
function ctools_set_callback_token($token, $callback) {
// If the callback uses arguments they are considered in the token.
@@ -384,9 +472,9 @@ function ctools_set_no_blocks($blocks = FALSE) {
/**
* 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');
@@ -413,6 +501,7 @@ function ctools_uuid_generate() {
/**
* Check that a string appears to be in the format of a UUID.
+ *
* @see http://drupal.org/project/uuid
*
* @param $uuid
@@ -468,6 +557,8 @@ function ctools_class_add($classes, $hook = 'html') {
*/
function ctools_class_remove($classes, $hook = 'html') {
if (!is_array($classes)) {
+ // @todo Consider using explode(' ', $classes);
+ // @todo Consider checking that $classes is a string before adding.
$classes = array($classes);
}
@@ -480,12 +571,35 @@ function ctools_class_remove($classes, $hook = 'html') {
}
}
-// -----------------------------------------------------------------------
-// Drupal core hooks
+/**
+ * Reset the storage used for ctools_class_add and ctools_class_remove.
+ *
+ * @see ctools_class_add()
+ * @see ctools_class_remove()
+ */
+function ctools_class_reset() {
+ drupal_static_reset('ctools_process_classes');
+}
+/**
+ * Return the classes for the body (added by ctools_class_add).
+ *
+ * @return array
+ * A copy of the array of classes to add to the body tag. If none have been
+ * added, this will be an empty array.
+ *
+ * @see ctools_class_add()
+ */
+function ctools_get_classes() {
+ return drupal_static('ctools_process_classes', array());
+}
+
+// -----------------------------------------------------------------------
+// Drupal core hooks.
/**
* Implement hook_init to keep our global CSS at the ready.
*/
+
function ctools_init() {
ctools_add_css('ctools');
// If we are sure that CTools' AJAX is in use, change the error handling.
@@ -504,7 +618,7 @@ function ctools_init() {
* Shutdown handler used during ajax operations to help catch fatal errors.
*/
function ctools_shutdown_handler() {
- if (function_exists('error_get_last') AND ($error = error_get_last())) {
+ if (function_exists('error_get_last') && ($error = error_get_last())) {
switch ($error['type']) {
case E_ERROR:
case E_CORE_ERROR:
@@ -583,7 +697,6 @@ function ctools_flush_caches() {
/**
* Implements hook_element_info_alter().
- *
*/
function ctools_element_info_alter(&$type) {
ctools_include('dependent');
@@ -618,12 +731,33 @@ function ctools_registry_files_alter(&$files, $indexed_modules) {
}
// -----------------------------------------------------------------------
-// CTools hook implementations.
+// FAPI hooks that must be in the .module file.
+/**
+ * Alter the comment form to get a little more control over it.
+ */
+function ctools_form_comment_form_alter(&$form, &$form_state) {
+ if (!empty($form_state['ctools comment alter'])) {
+ // Force the form to post back to wherever we are.
+ $form['#action'] = url($_GET['q'], array('fragment' => 'comment-form'));
+ if (empty($form['#submit'])) {
+ $form['#submit'] = array('comment_form_submit');
+ }
+ $form['#submit'][] = 'ctools_node_comment_form_submit';
+ }
+}
+
+function ctools_node_comment_form_submit(&$form, &$form_state) {
+ $form_state['redirect'][0] = $_GET['q'];
+}
+
+// -----------------------------------------------------------------------
+// CTools hook implementations.
/**
* Implementation of hook_ctools_plugin_directory() to let the system know
* where all our own plugins are.
*/
+
function ctools_ctools_plugin_directory($owner, $plugin_type) {
if ($owner == 'ctools') {
return 'plugins/' . $plugin_type;
@@ -644,11 +778,11 @@ function ctools_ctools_plugin_type() {
// -----------------------------------------------------------------------
// Drupal theme preprocess hooks that must be in the .module file.
-
/**
* A theme preprocess function to automatically allow panels-based node
* templates based upon input when the panel was configured.
*/
+
function ctools_preprocess_node(&$vars) {
// The 'ctools_template_identifier' attribute of the node is added when the pane is
// rendered.
@@ -658,14 +792,13 @@ 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().
+ * @see ctools_block_list_alter()
*/
function ctools_page_alter(&$page) {
$check = drupal_static('ctools_set_no_blocks', TRUE);
@@ -695,6 +828,7 @@ function ctools_page_token_processing($children, $elements) {
case 'variable':
$tokens[$token] = isset($elements[$argument]) ? $elements[$argument] : '';
break;
+
case 'callback':
if (is_string($argument) && function_exists($argument)) {
$tokens[$token] = $argument($elements);
@@ -723,7 +857,7 @@ function ctools_process(&$variables, $hook) {
return;
}
- $classes = drupal_static('ctools_process_classes', array());
+ $classes = ctools_get_classes();
// Process the classses to add.
if (!empty($classes[$hook]['add'])) {
@@ -744,7 +878,6 @@ function ctools_process(&$variables, $hook) {
// -----------------------------------------------------------------------
// Menu callbacks that must be in the .module file.
-
/**
* Determine if the current user has access via a plugin.
*
@@ -768,6 +901,7 @@ function ctools_process(&$variables, $hook) {
* @return
* TRUE if access is granted, false if otherwise.
*/
+
function ctools_access_menu($access) {
// Short circuit everything if there are no access tests.
if (empty($access['plugins'])) {
@@ -796,7 +930,7 @@ function ctools_access_menu($access) {
* An indexed array of zero or more permission strings to be checked by
* user_access().
*
- * @return
+ * @return bool
* Iff all checks pass will this function return TRUE. If an invalid argument
* is passed (e.g., not a string), this function errs on the safe said and
* returns FALSE.
@@ -858,7 +992,6 @@ function ctools_export_ui_load($item_name, $plugin_name) {
// -----------------------------------------------------------------------
// Caching callbacks on behalf of export-ui.
-
/**
* Menu access callback for various tasks of export-ui.
*/
@@ -902,7 +1035,7 @@ function ctools_export_ui_ctools_access_get($argument) {
}
/**
- * Callback for access control ajax form on behalf of export ui
+ * Callback for access control ajax form on behalf of export ui.
*
* Returns the cached access config and contexts used.
* Note that this is assuming that access will be in $item->access -- if it
@@ -935,8 +1068,9 @@ function ctools_menu_local_tasks_alter(&$data, $router_item, $root_path) {
}
/**
- * Implement hook_block_list_alter() to potentially remove blocks.
+ * Implements hook_block_list_alter().
*
+ * Used to potentially remove blocks.
* This exists in order to replicate Drupal 6's "no blocks" functionality.
*/
function ctools_block_list_alter(&$blocks) {
@@ -999,6 +1133,7 @@ function ctools_ctools_entity_context_alter(&$plugin, &$entity, $plugin_id) {
case 'entity_id:taxonomy_term':
$plugin['no ui'] = TRUE;
break;
+
case 'entity:user':
$plugin = ctools_get_context('user');
unset($plugin['no ui']);
@@ -1018,3 +1153,53 @@ function ctools_ctools_entity_context_alter(&$plugin, &$entity, $plugin_id) {
}
}
}
+
+/**
+ * Implements hook_field_create_field().
+ */
+function ctools_field_create_field($field) {
+ ctools_flush_field_caches();
+}
+
+/**
+ * Implements hook_field_create_instance().
+ */
+function ctools_field_create_instance($instance) {
+ ctools_flush_field_caches();
+}
+
+/**
+ * Implements hook_field_delete_field().
+ */
+function ctools_field_delete_field($field) {
+ ctools_flush_field_caches();
+}
+
+/**
+ * Implements hook_field_delete_instance().
+ */
+function ctools_field_delete_instance($instance) {
+ ctools_flush_field_caches();
+}
+
+/**
+ * Implements hook_field_update_field().
+ */
+function ctools_field_update_field($field, $prior_field, $has_data) {
+ ctools_flush_field_caches();
+}
+
+/**
+ * Implements hook_field_update_instance().
+ */
+function ctools_field_update_instance($instance, $prior_instance) {
+ ctools_flush_field_caches();
+}
+
+/**
+ * Clear field related caches.
+ */
+function ctools_flush_field_caches() {
+ // Clear caches of 'Entity field' content type plugin.
+ cache_clear_all('ctools_entity_field_content_type_content_types', 'cache');
+}
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.info b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.info
index 2180cec..3fc3556 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.info
+++ b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.info
@@ -2,12 +2,10 @@ 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 2015-01-28
-version = "7.x-1.6"
+; Information added by Drupal.org packaging script on 2019-02-08
+version = "7.x-1.15"
core = "7.x"
project = "ctools"
-datestamp = "1422471484"
-
+datestamp = "1549603691"
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.install b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.install
index 3f00877..70afb3c 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.install
+++ b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.install
@@ -1,5 +1,9 @@
t('Custom rulesets are combinations of access plugins you can use for access control, selection criteria and pane visibility.'),
);
- // Load all mini panels and their displays.
+ // Load all mini panels and their displays.
ctools_include('export');
$items = ctools_export_crud_load_all('ctools_access_ruleset');
$count = 0;
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/access/ruleset.inc b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/access/ruleset.inc
index f8abea6..95f32c3 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/access/ruleset.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/access/ruleset.inc
@@ -35,7 +35,7 @@ function ctools_ruleset_ctools_access_merge_plugin($plugin, $parent, $item) {
$plugin['required context'] = array();
foreach ($item->requiredcontexts as $context) {
$info = ctools_get_context($context['name']);
- // TODO: allow an optional setting
+ // TODO: allow an optional setting.
$plugin['required context'][] = new ctools_context_required($context['identifier'], $info['context name']);
}
}
@@ -72,7 +72,7 @@ function ctools_ruleset_ctools_access_get_children($plugin, $parent) {
}
/**
- * Settings form for the 'by ruleset' access plugin
+ * Settings form for the 'by ruleset' access plugin.
*/
function ctools_ruleset_ctools_access_settings(&$form, &$form_state, $conf) {
if (!empty($form_state['plugin']['ruleset']->admin_description)) {
@@ -106,4 +106,3 @@ function ctools_ruleset_ctools_access_summary($conf, $context, $plugin) {
return check_plain($plugin['ruleset']->admin_title);
}
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset.inc b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset.inc
index d2a1c60..2589ac3 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset.inc
@@ -1,5 +1,9 @@
'ctools_access_ruleset',
'access' => 'administer ctools access ruleset',
@@ -26,4 +30,3 @@ $plugin = array(
),
),
);
-
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset_ui.class.php b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset_ui.class.php
index b181464..c9f8c20 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset_ui.class.php
+++ b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset_ui.class.php
@@ -2,7 +2,7 @@
class ctools_access_ruleset_ui extends ctools_export_ui {
- function edit_form_context(&$form, &$form_state) {
+ public function edit_form_context(&$form, &$form_state) {
ctools_include('context-admin');
ctools_context_admin_includes();
ctools_add_css('ruleset');
@@ -27,7 +27,7 @@ class ctools_access_ruleset_ui extends ctools_export_ui {
ctools_context_add_relationship_form($module, $form, $form_state, $form['right']['relationships_table'], $form_state['item'], $name);
}
- function edit_form_rules(&$form, &$form_state) {
+ public function edit_form_rules(&$form, &$form_state) {
// The 'access' UI passes everything via $form_state, unlike the 'context' UI.
// The main difference is that one is about 3 years newer than the other.
ctools_include('context');
@@ -43,11 +43,12 @@ class ctools_access_ruleset_ui extends ctools_export_ui {
$form = ctools_access_admin_form($form, $form_state);
}
- function edit_form_rules_submit(&$form, &$form_state) {
+ public function edit_form_rules_submit(&$form, &$form_state) {
$form_state['item']->access['logic'] = $form_state['values']['logic'];
}
- function edit_form_submit(&$form, &$form_state) {
+ public function edit_form_submit(&$form, &$form_state) {
parent::edit_form_submit($form, $form_state);
}
+
}
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/css/ctools-ajax-sample.css b/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/css/ctools-ajax-sample.css
index 8df17de..c312e99 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/css/ctools-ajax-sample.css
+++ b/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/css/ctools-ajax-sample.css
@@ -1,52 +1,52 @@
div.ctools-sample-modal-content {
- background:none;
- border:0;
- color:#000000;
- margin:0;
- padding:0;
- text-align:left;
+ background: none;
+ border: 0;
+ color: #000;
+ margin: 0;
+ padding: 0;
+ text-align: left;
}
-div.ctools-sample-modal-content .modal-scroll{
- overflow:hidden;
- overflow-y:auto;
+div.ctools-sample-modal-content .modal-scroll {
+ overflow: hidden;
+ overflow-y: auto;
}
div.ctools-sample-modal-content #popups-overlay {
- background-color:transparent;
+ background-color: transparent;
}
div.ctools-sample-modal-content #popups-loading {
- width:248px;
- position:absolute;
- display:none;
- opacity:1;
+ width: 248px;
+ position: absolute;
+ display: none;
+ opacity: 1;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
- z-index:99;
+ z-index: 99;
}
div.ctools-sample-modal-content #popups-loading span.popups-loading-message {
- background:#FFF url(../images/loading-large.gif) no-repeat 8px center;
- display:block;
- color:#444444;
- font-family:Arial;
- font-size:22px;
- font-weight:bold;
- height:36px;
- line-height:36px;
- padding:0 40px;
+ background: #fff url(../images/loading-large.gif) no-repeat 8px center;
+ display: block;
+ color: #444;
+ font-family: Arial, serif;
+ font-size: 22px;
+ font-weight: bold;
+ height: 36px;
+ line-height: 36px;
+ padding: 0 40px;
}
div.ctools-sample-modal-content #popups-loading table,
div.ctools-sample-modal-content .popups-box table {
- margin:0px;
+ margin: 0;
}
div.ctools-sample-modal-content #popups-loading tbody,
div.ctools-sample-modal-content .popups-box tbody {
- border:none;
+ border: none;
}
div.ctools-sample-modal-content .popups-box tr {
- background-color:transparent;
+ background-color: transparent;
}
div.ctools-sample-modal-content td.popups-border {
background: url(../images/popups-border.png);
- background-color:transparent;
+ background-color: transparent;
border: none;
}
div.ctools-sample-modal-content td.popups-tl,
@@ -54,79 +54,94 @@ div.ctools-sample-modal-content td.popups-tr,
div.ctools-sample-modal-content td.popups-bl,
div.ctools-sample-modal-content td.popups-br {
background-repeat: no-repeat;
- height:10px;
- padding:0px;
+ height: 10px;
+ padding: 0;
+}
+div.ctools-sample-modal-content td.popups-tl {
+ background-position: 0 0;
}
-div.ctools-sample-modal-content td.popups-tl { background-position: 0px 0px; }
div.ctools-sample-modal-content td.popups-t,
div.ctools-sample-modal-content td.popups-b {
- background-position: 0px -40px;
+ background-position: 0 -40px;
background-repeat: repeat-x;
}
-div.ctools-sample-modal-content td.popups-tr { background-position: 0px -10px; width: 10px; }
+div.ctools-sample-modal-content td.popups-tr {
+ background-position: 0 -10px;
+ width: 10px;
+}
div.ctools-sample-modal-content td.popups-cl,
div.ctools-sample-modal-content td.popups-cr {
background-position: -10px 0;
background-repeat: repeat-y;
- width:10px;
+ width: 10px;
}
div.ctools-sample-modal-content td.popups-cl,
div.ctools-sample-modal-content td.popups-cr,
-div.ctools-sample-modal-content td.popups-c { padding:0; border: none; }
-div.ctools-sample-modal-content td.popups-c { background:#fff; }
-div.ctools-sample-modal-content td.popups-bl { background-position: 0px -20px; }
-div.ctools-sample-modal-content td.popups-br { background-position: 0px -30px; width: 10px; }
+div.ctools-sample-modal-content td.popups-c {
+ padding: 0;
+ border: none;
+}
+div.ctools-sample-modal-content td.popups-c {
+ background: #fff;
+}
+div.ctools-sample-modal-content td.popups-bl {
+ background-position: 0 -20px;
+}
+div.ctools-sample-modal-content td.popups-br {
+ background-position: 0 -30px;
+ width: 10px;
+}
div.ctools-sample-modal-content .popups-box,
div.ctools-sample-modal-content #popups-loading {
- border: 0px solid #454545;
- opacity:1;
- overflow:hidden;
- padding:0;
- background-color:transparent;
+ border: 0 solid #454545;
+ opacity: 1;
+ overflow: hidden;
+ padding: 0;
+ background-color: transparent;
}
div.ctools-sample-modal-content .popups-container {
- overflow:hidden;
- height:100%;
- background-color:#fff;
+ overflow: hidden;
+ height: 100%;
+ background-color: #fff;
}
div.ctools-sample-modal-content div.popups-title {
- -moz-border-radius-topleft: 0px;
- -webkit-border-radius-topleft: 0px;
- margin-bottom:0px;
- background-color:#ff7200;
- border:1px solid #ce5c00;
- padding:4px 10px 5px;
- color:white;
- font-size:1em;
- font-weight:bold;
+ -moz-border-radius-topleft: 0;
+ -webkit-border-radius-topleft: 0;
+ margin-bottom: 0;
+ background-color: #ff7200;
+ border: 1px solid #ce5c00;
+ padding: 4px 10px 5px;
+ color: white;
+ font-size: 1em;
+ font-weight: bold;
}
div.ctools-sample-modal-content .popups-body {
- background-color:#fff;
- padding:8px;
+ background-color: #fff;
+ padding: 8px;
}
div.ctools-sample-modal-content .popups-box .popups-buttons,
div.ctools-sample-modal-content .popups-box .popups-footer {
- background-color:#fff;
+ background-color: #fff;
}
div.ctools-sample-modal-content .popups-title a.close {
color: #fff;
- text-decoration:none;
+ text-decoration: none;
}
div.ctools-sample-modal-content .popups-close {
- font-size:120%;
- float:right;
- text-align:right;
+ font-size: 120%;
+ float: right;
+ text-align: right;
}
div.ctools-sample-modal-content .modal-loading-wrapper {
- width:220px;
- height:19px;
- margin:0 auto;
- margin-top:2%;
+ width: 220px;
+ height: 19px;
+ margin: 0 auto;
+ margin-top: 2%;
}
-div.ctools-sample-modal-content tbody{
- border:none;
+div.ctools-sample-modal-content tbody {
+ border: none;
}
div.ctools-sample-modal-content .modal-content .modal-throbber-wrapper img {
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.info b/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.info
index 009662f..c2a52df 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.info
+++ b/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.info
@@ -1,13 +1,11 @@
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 2015-01-28
-version = "7.x-1.6"
+; Information added by Drupal.org packaging script on 2019-02-08
+version = "7.x-1.15"
core = "7.x"
project = "ctools"
-datestamp = "1422471484"
-
+datestamp = "1549603691"
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.install b/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.install
index 04325db..e0fdfc6 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.install
+++ b/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.install
@@ -1,18 +1,18 @@
'Chaos Tools AJAX Demo',
- 'page callback' => 'ctools_ajax_sample_page',
- 'access callback' => TRUE,
- 'type' => MENU_NORMAL_ITEM,
+ 'title' => 'Chaos Tools AJAX Demo',
+ 'page callback' => 'ctools_ajax_sample_page',
+ 'access callback' => TRUE,
+ 'type' => MENU_NORMAL_ITEM,
);
$items['ctools_ajax_sample/simple_form'] = array(
'title' => 'Simple Form',
@@ -26,39 +26,39 @@ function ctools_ajax_sample_menu() {
'type' => MENU_CALLBACK,
);
$items['ctools_ajax_sample/%ctools_js/hello'] = array(
- 'title' => 'Hello World',
- 'page callback' => 'ctools_ajax_sample_hello',
- 'page arguments' => array(1),
- 'access callback' => TRUE,
- 'type' => MENU_CALLBACK,
+ 'title' => 'Hello World',
+ 'page callback' => 'ctools_ajax_sample_hello',
+ 'page arguments' => array(1),
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
);
$items['ctools_ajax_sample/%ctools_js/tablenix/%'] = array(
- 'title' => 'Hello World',
- 'page callback' => 'ctools_ajax_sample_tablenix',
- 'page arguments' => array(1, 3),
- 'access callback' => TRUE,
- 'type' => MENU_CALLBACK,
+ 'title' => 'Hello World',
+ 'page callback' => 'ctools_ajax_sample_tablenix',
+ 'page arguments' => array(1, 3),
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
);
$items['ctools_ajax_sample/%ctools_js/login'] = array(
- 'title' => 'Login',
- 'page callback' => 'ctools_ajax_sample_login',
- 'page arguments' => array(1),
- 'access callback' => TRUE,
- 'type' => MENU_CALLBACK,
+ 'title' => 'Login',
+ 'page callback' => 'ctools_ajax_sample_login',
+ 'page arguments' => array(1),
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
);
$items['ctools_ajax_sample/%ctools_js/animal'] = array(
- 'title' => 'Animal',
- 'page callback' => 'ctools_ajax_sample_animal',
- 'page arguments' => array(1),
- 'access callback' => TRUE,
- 'type' => MENU_CALLBACK,
+ 'title' => 'Animal',
+ 'page callback' => 'ctools_ajax_sample_animal',
+ 'page arguments' => array(1),
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
);
$items['ctools_ajax_sample/%ctools_js/login/%'] = array(
- 'title' => 'Post-Login Action',
- 'page callback' => 'ctools_ajax_sample_login_success',
- 'page arguments' => array(1, 3),
- 'access callback' => TRUE,
- 'type' => MENU_CALLBACK,
+ 'title' => 'Post-Login Action',
+ 'page callback' => 'ctools_ajax_sample_login_success',
+ 'page arguments' => array(1, 3),
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
);
$items['ctools_ajax_sample/jumped'] = array(
'title' => 'Successful Jumping',
@@ -104,11 +104,11 @@ function ctools_ajax_sample_theme() {
}
// ---------------------------------------------------------------------------
-// Page callbacks
-
+// Page callbacks.
/**
* Page callback to display links and render a container for AJAX stuff.
*/
+
function ctools_ajax_sample_page() {
global $user;
@@ -156,14 +156,14 @@ function ctools_ajax_sample_page() {
// The extra class points to the info in ctools-sample-style which we added
// to the settings, prefixed with 'ctools-modal'.
- $links[] = ctools_modal_text_button(t('Modal Login (custom style)'), 'ctools_ajax_sample/nojs/login', t('Login via modal'), 'ctools-modal-ctools-sample-style');
+ $links[] = ctools_modal_text_button(t('Modal Login (custom style)'), 'ctools_ajax_sample/nojs/login', t('Login via modal'), 'ctools-modal-ctools-sample-style');
}
// Four ways to do our animal picking wizard.
$button_form = ctools_ajax_sample_ajax_button_form();
$links[] = l(t('Wizard (no modal)'), 'ctools_ajax_sample/nojs/animal');
$links[] = ctools_modal_text_button(t('Wizard (default modal)'), 'ctools_ajax_sample/nojs/animal', t('Pick an animal'));
- $links[] = ctools_modal_text_button(t('Wizard (custom modal)'), 'ctools_ajax_sample/nojs/animal', t('Pick an animal'), 'ctools-modal-ctools-sample-style');
+ $links[] = ctools_modal_text_button(t('Wizard (custom modal)'), 'ctools_ajax_sample/nojs/animal', t('Pick an animal'), 'ctools-modal-ctools-sample-style');
$links[] = drupal_render($button_form);
$links[] = ctools_ajax_text_button(t('Hello world!'), "ctools_ajax_sample/nojs/hello", t('Replace text with "hello world"'));
@@ -176,9 +176,9 @@ function ctools_ajax_sample_page() {
// Create a table that we can have data removed from via AJAX.
$header = array(t('Row'), t('Content'), t('Actions'));
$rows = array();
- for($i = 1; $i < 11; $i++) {
+ for ($i = 1; $i < 11; $i++) {
$rows[] = array(
- 'class' => array('ajax-sample-row-'. $i),
+ 'class' => array('ajax-sample-row-' . $i),
'data' => array(
$i,
md5($i),
@@ -189,10 +189,10 @@ function ctools_ajax_sample_page() {
$output .= theme('table', array('header' => $header, 'rows' => $rows, array('class' => array('ajax-sample-table'))));
- // Show examples of ctools javascript widgets
- $output .= '
'. t('CTools Javascript Widgets') .'
';
+ // Show examples of ctools javascript widgets.
+ $output .= '
' . t('CTools Javascript Widgets') . '
';
- // Create a drop down menu
+ // Create a drop down menu.
$links = array();
$links[] = array('title' => t('Link 1'), 'href' => $_GET['q']);
$links[] = array('title' => t('Link 2'), 'href' => $_GET['q']);
@@ -201,16 +201,16 @@ function ctools_ajax_sample_page() {
$output .= '
' . t('Drop Down Menu') . '
';
$output .= theme('ctools_dropdown', array('title' => t('Click to Drop Down'), 'links' => $links));
- // Create a collapsible div
+ // Create a collapsible div.
$handle = t('Click to Collapse');
$content = 'Nulla ligula ante, aliquam at adipiscing egestas, varius vel arcu. Etiam laoreet elementum mi vel consequat. Etiam scelerisque lorem vel neque consequat quis bibendum libero congue. Nulla facilisi. Mauris a elit a leo feugiat porta. Phasellus placerat cursus est vitae elementum.';
- $output .= '
Login successful. You can now choose whether to ' . $inplace . ', or go to ' . $account . '.
');
}
print ajax_render($output);
exit;
@@ -283,7 +284,7 @@ function ctools_ajax_sample_login($js = NULL) {
*/
function ctools_ajax_sample_login_success($js, $action) {
if (!$js) {
- // we should never be here out of ajax context
+ // We should never be here out of ajax context.
return MENU_NOT_FOUND;
}
@@ -291,11 +292,11 @@ function ctools_ajax_sample_login_success($js, $action) {
ctools_add_js('ajax-responder');
$commands = array();
if ($action == 'inplace') {
- // stay here
+ // Stay here.
$commands[] = ctools_ajax_command_reload();
}
else {
- // bounce bounce
+ // Bounce bounce.
$commands[] = ctools_ajax_command_redirect('user');
}
print ajax_render($commands);
@@ -318,18 +319,18 @@ function ctools_ajax_sample_animal($js = NULL, $step = NULL) {
'show back' => TRUE,
'show cancel' => TRUE,
'show return' => FALSE,
- 'next callback' => 'ctools_ajax_sample_wizard_next',
+ 'next callback' => 'ctools_ajax_sample_wizard_next',
'finish callback' => 'ctools_ajax_sample_wizard_finish',
'cancel callback' => 'ctools_ajax_sample_wizard_cancel',
- // this controls order, as well as form labels
+ // This controls order, as well as form labels.
'order' => array(
'start' => t('Choose animal'),
),
- // here we map a step to a form id.
+ // Here we map a step to a form id.
'forms' => array(
- // e.g. this for the step at wombat/create
+ // e.g. this for the step at wombat/create.
'start' => array(
- 'form id' => 'ctools_ajax_sample_start'
+ 'form id' => 'ctools_ajax_sample_start',
),
),
);
@@ -341,7 +342,6 @@ function ctools_ajax_sample_animal($js = NULL, $step = NULL) {
// in creation.
//
// We skip all this here by just using an id of 1.
-
$object_id = 1;
if (empty($step)) {
@@ -406,7 +406,7 @@ function ctools_ajax_sample_animal($js = NULL, $step = NULL) {
$commands[] = ajax_command_html('#ctools-sample', $animal);
$commands[] = ctools_modal_command_dismiss();
}
- else if (!empty($form_state['cancel'])) {
+ elseif (!empty($form_state['cancel'])) {
// If cancelling, return to the activity.
$commands[] = ctools_modal_command_dismiss();
}
@@ -420,7 +420,7 @@ function ctools_ajax_sample_animal($js = NULL, $step = NULL) {
if ($output === FALSE || !empty($form_state['complete'])) {
return $animal;
}
- else if (!empty($form_state['cancel'])) {
+ elseif (!empty($form_state['cancel'])) {
drupal_goto('ctools_ajax_sample');
}
else {
@@ -430,11 +430,11 @@ function ctools_ajax_sample_animal($js = NULL, $step = NULL) {
}
// ---------------------------------------------------------------------------
-// Themes
-
+// Themes.
/**
* Theme function for main rendered output.
*/
+
function theme_ctools_ajax_sample_container($vars) {
$output = '
';
$output .= $vars['content'];
@@ -445,7 +445,6 @@ function theme_ctools_ajax_sample_container($vars) {
// ---------------------------------------------------------------------------
// Stuff needed for our little wizard.
-
/**
* Get a list of our animals and associated forms.
*
@@ -453,6 +452,7 @@ function theme_ctools_ajax_sample_container($vars) {
* which is often how it will work in the real world. If using CTools, what
* you would probably really have, here, is a set of plugins for each animal.
*/
+
function ctools_ajax_sample_animals() {
return array(
'sheep' => array(
@@ -478,10 +478,10 @@ function ctools_ajax_sample_animals() {
// ---------------------------------------------------------------------------
// Wizard caching helpers.
-
/**
* Store our little cache so that we can retain data from form to form.
*/
+
function ctools_ajax_sample_cache_set($id, $object) {
ctools_include('object-cache');
ctools_object_cache_set('ctools_ajax_sample', $id, $object);
@@ -495,7 +495,7 @@ function ctools_ajax_sample_cache_get($id) {
$object = ctools_object_cache_get('ctools_ajax_sample', $id);
if (!$object) {
// Create a default object.
- $object = new stdClass;
+ $object = new stdClass();
$object->type = 'unknown';
$object->name = '';
}
@@ -513,18 +513,18 @@ function ctools_ajax_sample_cache_clear($id) {
// ---------------------------------------------------------------------------
// Wizard in-between helpers; what to do between or after forms.
-
/**
* Handle the 'next' click on the add/edit pane form wizard.
*
* All we need to do is store the updated pane in the cache.
*/
+
function ctools_ajax_sample_wizard_next(&$form_state) {
ctools_ajax_sample_cache_set($form_state['object_id'], $form_state['object']);
}
/**
- * Handle the 'finish' click on teh add/edit pane form wizard.
+ * Handle the 'finish' click on the add/edit pane form wizard.
*
* All we need to do is set a flag so the return can handle adding
* the pane.
@@ -542,10 +542,10 @@ function ctools_ajax_sample_wizard_cancel(&$form_state) {
// ---------------------------------------------------------------------------
// Wizard forms for our simple info collection wizard.
-
/**
* Wizard start form. Choose an animal.
*/
+
function ctools_ajax_sample_start($form, &$form_state) {
$form_state['title'] = t('Choose animal');
@@ -713,7 +713,7 @@ function ctools_ajax_sample_show_raptor($object) {
}
/**
- * Helper function to provide a sample jump menu form
+ * Helper function to provide a sample jump menu form.
*/
function ctools_ajax_sample_jump_menu_form() {
$url = url('ctools_ajax_sample/jumped');
@@ -723,7 +723,7 @@ function ctools_ajax_sample_jump_menu_form() {
}
/**
- * Provide a message to the user that the jump menu worked
+ * Provide a message to the user that the jump menu worked.
*/
function ctools_ajax_sample_jump_menu_page() {
$return_link = l(t('Return to the examples page.'), 'ctools_ajax_sample');
@@ -732,7 +732,7 @@ function ctools_ajax_sample_jump_menu_page() {
}
/**
- * Provide a form for an example ajax modal button
+ * Provide a form for an example ajax modal button.
*/
function ctools_ajax_sample_ajax_button_form() {
$form = array();
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.info b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.info
index b991d61..2bc7348 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.info
+++ b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.info
@@ -2,12 +2,10 @@ 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 2015-01-28
-version = "7.x-1.6"
+; Information added by Drupal.org packaging script on 2019-02-08
+version = "7.x-1.15"
core = "7.x"
project = "ctools"
-datestamp = "1422471484"
-
+datestamp = "1549603691"
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.install b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.install
index b4512f2..dcf87e7 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.install
+++ b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.install
@@ -1,5 +1,9 @@
type == 'custom') {
- if(!isset($pane->configuration['name'])) {
+ if (!isset($pane->configuration['name'])) {
$name_of_pane = $pane->subtype;
}
else {
@@ -80,7 +80,7 @@ function ctools_custom_content_panels_dashboard_blocks(&$vars) {
'description' => t('Custom content panes are basic HTML you enter that can be reused in all of your panels.'),
);
- // Load all mini panels and their displays.
+ // Load all mini panels and their displays.
ctools_include('export');
$items = ctools_export_crud_load_all('ctools_custom_content');
$count = 0;
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content.inc b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content.inc
index 467dc58..c7933bc 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content.inc
@@ -1,5 +1,9 @@
'ctools_custom_content',
'access' => 'administer custom content',
@@ -17,4 +21,3 @@ $plugin = array(
'handler' => 'ctools_custom_content_ui',
);
-
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content_ui.class.php b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content_ui.class.php
index 56fe4b2..e56f7a7 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content_ui.class.php
+++ b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content_ui.class.php
@@ -2,7 +2,7 @@
class ctools_custom_content_ui extends ctools_export_ui {
- function edit_form(&$form, &$form_state) {
+ public function edit_form(&$form, &$form_state) {
// Correct for an error that came in because filter format changed.
if (is_array($form_state['item']->settings['body'])) {
$form_state['item']->settings['format'] = $form_state['item']->settings['body']['format'];
@@ -23,6 +23,22 @@ class ctools_custom_content_ui extends ctools_export_ui {
'#title' => t('Title'),
);
+ $form['title_heading'] = array(
+ '#title' => t('Title heading'),
+ '#type' => 'select',
+ '#default_value' => isset($form_state['item']->settings['title_heading']) ? $form_state['item']->settings['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'),
+ ),
+ );
+
$form['body'] = array(
'#type' => 'text_format',
'#title' => t('Body'),
@@ -38,17 +54,18 @@ class ctools_custom_content_ui extends ctools_export_ui {
);
}
- function edit_form_submit(&$form, &$form_state) {
+ public function edit_form_submit(&$form, &$form_state) {
parent::edit_form_submit($form, $form_state);
// Since items in our settings are not in the schema, we have to do these manually:
$form_state['item']->settings['title'] = $form_state['values']['title'];
+ $form_state['item']->settings['title_heading'] = $form_state['values']['title_heading'];
$form_state['item']->settings['body'] = $form_state['values']['body']['value'];
$form_state['item']->settings['format'] = $form_state['values']['body']['format'];
$form_state['item']->settings['substitute'] = $form_state['values']['substitute'];
}
- function list_form(&$form, &$form_state) {
+ public function list_form(&$form, &$form_state) {
parent::list_form($form, $form_state);
$options = array('all' => t('- All -'));
@@ -65,7 +82,7 @@ class ctools_custom_content_ui extends ctools_export_ui {
);
}
- function list_filter($form_state, $item) {
+ public function list_filter($form_state, $item) {
if ($form_state['values']['category'] != 'all' && $form_state['values']['category'] != $item->category) {
return TRUE;
}
@@ -73,7 +90,7 @@ class ctools_custom_content_ui extends ctools_export_ui {
return parent::list_filter($form_state, $item);
}
- function list_sort_options() {
+ public function list_sort_options() {
return array(
'disabled' => t('Enabled, title'),
'title' => t('Title'),
@@ -83,21 +100,25 @@ class ctools_custom_content_ui extends ctools_export_ui {
);
}
- function list_build_row($item, &$form_state, $operations) {
- // Set up sorting
+ public function list_build_row($item, &$form_state, $operations) {
+ // Set up sorting.
switch ($form_state['values']['order']) {
case 'disabled':
$this->sorts[$item->name] = empty($item->disabled) . $item->admin_title;
break;
+
case 'title':
$this->sorts[$item->name] = $item->admin_title;
break;
+
case 'name':
$this->sorts[$item->name] = $item->name;
break;
+
case 'category':
$this->sorts[$item->name] = $item->category;
break;
+
case 'storage':
$this->sorts[$item->name] = $item->type . $item->admin_title;
break;
@@ -117,7 +138,7 @@ class ctools_custom_content_ui extends ctools_export_ui {
);
}
- function list_table_header() {
+ public function list_table_header() {
return array(
array('data' => t('Name'), 'class' => array('ctools-export-ui-name')),
array('data' => t('Title'), 'class' => array('ctools-export-ui-title')),
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/README.txt b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/README.txt
index 42edcdc..2f9b0ff 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/README.txt
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/README.txt
@@ -11,4 +11,4 @@ There are a number of ways to profit from this:
2. There is a sample panel. You can access it at /ctools_plugin_example/xxxx
to see how it works.
-3. There is Advanced Help at admin/advanced_help/ctools_plugin_example.
\ No newline at end of file
+3. There is Advanced Help at admin/advanced_help/ctools_plugin_example.
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.info b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.info
index f526be6..3f268db 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.info
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.info
@@ -1,16 +1,14 @@
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 2015-01-28
-version = "7.x-1.6"
+; Information added by Drupal.org packaging script on 2019-02-08
+version = "7.x-1.15"
core = "7.x"
project = "ctools"
-datestamp = "1422471484"
-
+datestamp = "1549603691"
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.module b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.module
index 01d5338..a9a6080 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.module
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.module
@@ -1,9 +1,8 @@
.pages_default.inc
+ * .pages_default.inc.
*/
function ctools_plugin_example_ctools_plugin_api($module, $api) {
// @todo -- this example should explain how to put it in a different file.
@@ -71,7 +70,8 @@ function ctools_plugin_example_ctools_plugin_api($module, $api) {
}
/**
- * Just provide an explanation page for the admin section
+ * Just provide an explanation page for the admin section.
+ *
* @return unknown_type
*/
function ctools_plugin_example_explanation_page() {
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.pages_default.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.pages_default.inc
index 10a7619..ed3ffd7 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.pages_default.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.pages_default.inc
@@ -6,7 +6,7 @@
*/
/**
- * Default panels pages for CTools Plugin Example
+ * Default panels pages for CTools Plugin Example.
*
* To pick up this file, your module needs to implement
* hook_ctools_plugin_api() - See ctools_plugin_example_ctools_plugin_api() in
@@ -23,12 +23,10 @@
* @return
* Array of pages, normally exported from Panels.
*/
-
function ctools_plugin_example_default_page_manager_pages() {
- // begin exported panel.
-
- $page = new stdClass;
+ // Begin exported panel.
+ $page = new stdClass();
$page->disabled = FALSE; /* Edit this to true to make a default page disabled initially */
$page->api_version = 1;
$page->name = 'ctools_plugin_example';
@@ -37,31 +35,31 @@ function ctools_plugin_example_default_page_manager_pages() {
$page->admin_description = 'This panel provides no functionality to a working Drupal system. It\'s intended to display the various sample plugins provided by the CTools Plugin Example module. ';
$page->path = 'ctools_plugin_example/%sc';
$page->access = array(
- 'logic' => 'and',
+ 'logic' => 'and',
);
$page->menu = array(
- 'type' => 'normal',
- 'title' => 'CTools plugin example',
- 'name' => 'navigation',
- 'weight' => '0',
- 'parent' => array(
- 'type' => 'none',
- 'title' => '',
+ 'type' => 'normal',
+ 'title' => 'CTools plugin example',
'name' => 'navigation',
'weight' => '0',
- ),
+ 'parent' => array(
+ 'type' => 'none',
+ 'title' => '',
+ 'name' => 'navigation',
+ 'weight' => '0',
+ ),
);
$page->arguments = array(
- 'sc' => array(
- 'id' => 2,
- 'identifier' => 'simplecontext-arg',
- 'name' => 'simplecontext_arg',
- 'settings' => array(),
- ),
+ 'sc' => array(
+ 'id' => 2,
+ 'identifier' => 'simplecontext-arg',
+ 'name' => 'simplecontext_arg',
+ 'settings' => array(),
+ ),
);
$page->conf = array();
$page->default_handlers = array();
- $handler = new stdClass;
+ $handler = new stdClass();
$handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */
$handler->api_version = 1;
$handler->name = 'page_ctools_panel_context';
@@ -70,44 +68,45 @@ function ctools_plugin_example_default_page_manager_pages() {
$handler->handler = 'panel_context';
$handler->weight = 0;
$handler->conf = array(
- 'title' => 'Panel',
- 'no_blocks' => FALSE,
- 'css_id' => '',
- 'css' => '',
- 'contexts' => array(
- '0' => array(
- 'name' => 'simplecontext',
- 'id' => 1,
- 'identifier' => 'Configured simplecontext (not from argument)',
- 'keyword' => 'configured_simplecontext',
- 'context_settings' => array(
- 'sample_simplecontext_setting' => 'default simplecontext setting',
- ),
- ),
- ),
- 'relationships' => array(
- '0' => array(
- 'context' => 'argument_simplecontext_arg_2',
- 'name' => 'relcontext_from_simplecontext',
- 'id' => 1,
- 'identifier' => 'Relcontext from simplecontext (from relationship)',
- 'keyword' => 'relcontext',
- ),
- ),
- 'access' => array(
- 'logic' => 'and',
- ),
+ 'title' => 'Panel',
+ 'no_blocks' => FALSE,
+ 'css_id' => '',
+ 'css' => '',
+ 'contexts' => array(
+ '0' => array(
+ 'name' => 'simplecontext',
+ 'id' => 1,
+ 'identifier' => 'Configured simplecontext (not from argument)',
+ 'keyword' => 'configured_simplecontext',
+ 'context_settings' => array(
+ 'sample_simplecontext_setting' => 'default simplecontext setting',
+ ),
+ ),
+ ),
+ 'relationships' => array(
+ '0' => array(
+ 'context' => 'argument_simplecontext_arg_2',
+ 'name' => 'relcontext_from_simplecontext',
+ 'id' => 1,
+ 'identifier' => 'Relcontext from simplecontext (from relationship)',
+ 'keyword' => 'relcontext',
+ ),
+ ),
+ 'access' => array(
+ 'logic' => 'and',
+ ),
+ 'pipeline' => 'standard',
);
- $display = new panels_display;
+ $display = new panels_display();
$display->layout = 'threecol_33_34_33_stacked';
$display->layout_settings = array();
$display->panel_settings = array(
- 'style' => 'rounded_corners',
- 'style_settings' => array(
- 'default' => array(
- 'corner_location' => 'pane',
- ),
- ),
+ 'style' => 'rounded_corners',
+ 'style_settings' => array(
+ 'default' => array(
+ 'corner_location' => 'pane',
+ ),
+ ),
);
$display->cache = array();
$display->title = 'CTools plugin example panel';
@@ -115,7 +114,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$display->title_pane = 1;
$display->content = array();
$display->panels = array();
- $pane = new stdClass;
+ $pane = new stdClass();
$pane->pid = 'new-1';
$pane->panel = 'left';
$pane->type = 'no_context_content_type';
@@ -135,7 +134,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$pane->position = 0;
$display->content['new-1'] = $pane;
$display->panels['left'][0] = 'new-1';
- $pane = new stdClass;
+ $pane = new stdClass();
$pane->pid = 'new-2';
$pane->panel = 'left';
$pane->type = 'custom';
@@ -148,15 +147,15 @@ function ctools_plugin_example_default_page_manager_pages() {
'settings' => array(
'greater_than' => '1',
'arg_length' => '4',
- ),
+ ),
'context' => 'argument_simplecontext_arg_2',
- ),
- ),
+ ),
+ ),
);
$pane->configuration = array(
'title' => 'Long Arg Visibility Block',
'body' => 'This block will be here when the argument is longer than configured arg length. It uses the \'arg_length\' access plugin to test against the length of the argument used for Simplecontext.',
- 'format' => '1',
+ 'format' => 'filtered_html',
'substitute' => 1,
);
$pane->cache = array();
@@ -166,7 +165,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$pane->position = 1;
$display->content['new-2'] = $pane;
$display->panels['left'][1] = 'new-2';
- $pane = new stdClass;
+ $pane = new stdClass();
$pane->pid = 'new-3';
$pane->panel = 'left';
$pane->type = 'custom';
@@ -179,15 +178,15 @@ function ctools_plugin_example_default_page_manager_pages() {
'settings' => array(
'greater_than' => '0',
'arg_length' => '4',
- ),
+ ),
'context' => 'argument_simplecontext_arg_2',
- ),
- ),
+ ),
+ ),
);
$pane->configuration = array(
'title' => 'Short Arg Visibility',
'body' => 'This block appears when the simplecontext argument is less than the configured length.',
- 'format' => '1',
+ 'format' => 'filtered_html',
'substitute' => 1,
);
$pane->cache = array();
@@ -197,7 +196,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$pane->position = 2;
$display->content['new-3'] = $pane;
$display->panels['left'][2] = 'new-3';
- $pane = new stdClass;
+ $pane = new stdClass();
$pane->pid = 'new-4';
$pane->panel = 'middle';
$pane->type = 'simplecontext_content_type';
@@ -241,7 +240,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$pane->position = 0;
$display->content['new-4'] = $pane;
$display->panels['middle'][0] = 'new-4';
- $pane = new stdClass;
+ $pane = new stdClass();
$pane->pid = 'new-5';
$pane->panel = 'middle';
$pane->type = 'simplecontext_content_type';
@@ -285,7 +284,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$pane->position = 1;
$display->content['new-5'] = $pane;
$display->panels['middle'][1] = 'new-5';
- $pane = new stdClass;
+ $pane = new stdClass();
$pane->pid = 'new-6';
$pane->panel = 'middle';
$pane->type = 'custom';
@@ -299,7 +298,7 @@ function ctools_plugin_example_default_page_manager_pages() {
item1 is %sc:item1
item2 is %sc:item2
description is %sc:description',
- 'format' => '1',
+ 'format' => 'filtered_html',
'substitute' => 1,
);
$pane->cache = array();
@@ -309,7 +308,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$pane->position = 2;
$display->content['new-6'] = $pane;
$display->panels['middle'][2] = 'new-6';
- $pane = new stdClass;
+ $pane = new stdClass();
$pane->pid = 'new-7';
$pane->panel = 'right';
$pane->type = 'relcontext_content_type';
@@ -353,7 +352,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$pane->position = 0;
$display->content['new-7'] = $pane;
$display->panels['right'][0] = 'new-7';
- $pane = new stdClass;
+ $pane = new stdClass();
$pane->pid = 'new-8';
$pane->panel = 'top';
$pane->type = 'custom';
@@ -365,7 +364,7 @@ function ctools_plugin_example_default_page_manager_pages() {
'body' => 'The CTools Plugin Example module (and this panel page) are just here to demonstrate how to build CTools plugins.
',
- 'format' => '2',
+ 'format' => 'full_html',
'substitute' => 1,
);
$pane->cache = array();
@@ -378,12 +377,11 @@ function ctools_plugin_example_default_page_manager_pages() {
$handler->conf['display'] = $display;
$page->default_handlers[$handler->name] = $handler;
- // end of exported panel.
+ // End of exported panel.
$pages['ctools_plugin_example_demo_page'] = $page;
- // begin exported panel
-
- $page = new stdClass;
+ // Begin exported panel.
+ $page = new stdClass();
$page->disabled = FALSE; /* Edit this to true to make a default page disabled initially */
$page->api_version = 1;
$page->name = 'ctools_plugin_example_base';
@@ -396,7 +394,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$page->arguments = array();
$page->conf = array();
$page->default_handlers = array();
- $handler = new stdClass;
+ $handler = new stdClass();
$handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */
$handler->api_version = 1;
$handler->name = 'page_ctools_plugin_example_base_panel_context';
@@ -405,14 +403,15 @@ function ctools_plugin_example_default_page_manager_pages() {
$handler->handler = 'panel_context';
$handler->weight = 0;
$handler->conf = array(
- 'title' => 'Panel',
- 'no_blocks' => FALSE,
- 'css_id' => '',
- 'css' => '',
- 'contexts' => array(),
- 'relationships' => array(),
+ 'title' => 'Panel',
+ 'no_blocks' => FALSE,
+ 'css_id' => '',
+ 'css' => '',
+ 'contexts' => array(),
+ 'relationships' => array(),
+ 'pipeline' => 'standard',
);
- $display = new panels_display;
+ $display = new panels_display();
$display->layout = 'onecol';
$display->layout_settings = array();
$display->panel_settings = array();
@@ -421,7 +420,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$display->hide_title = FALSE;
$display->content = array();
$display->panels = array();
- $pane = new stdClass;
+ $pane = new stdClass();
$pane->pid = 'new-1';
$pane->panel = 'middle';
$pane->type = 'custom';
@@ -431,7 +430,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$pane->configuration = array(
'title' => 'Use this page with an argument',
'body' => 'This demo page works if you use an argument, like ctools_plugin_example/xxxxx.',
- 'format' => '1',
+ 'format' => 'filtered_html',
'substitute' => NULL,
);
$pane->cache = array();
@@ -443,9 +442,8 @@ function ctools_plugin_example_default_page_manager_pages() {
$display->panels['middle'][0] = 'new-1';
$handler->conf['display'] = $display;
$page->default_handlers[$handler->name] = $handler;
- // end exported panel.
-
+ // End exported panel.
$pages['base_page'] = $page;
return $pages;
-}
\ No newline at end of file
+}
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/access/arg_length.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/access/arg_length.inc
index 2a09eea..3b5d863 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/access/arg_length.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/access/arg_length.inc
@@ -59,7 +59,8 @@ function ctools_plugin_example_arg_length_ctools_access_check($conf, $context) {
*/
function ctools_plugin_example_arg_length_ctools_access_summary($conf, $context) {
return t('Simpletext argument must be !comp @length characters',
- array('!comp' => $conf['greater_than'] ? 'greater than' : 'less than or equal to',
- '@length' => $conf['arg_length']));
+ array(
+ '!comp' => $conf['greater_than'] ? 'greater than' : 'less than or equal to',
+ '@length' => $conf['arg_length'],
+ ));
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/access/example_role.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/access/example_role.inc
index bbe364c..75721e8 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/access/example_role.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/access/example_role.inc
@@ -4,7 +4,7 @@
* @file
* Plugin to provide access control based upon role membership.
* This is directly from the ctools module, but serves as a good
- * example of an access plugin
+ * example of an access plugin.
*/
/**
@@ -73,4 +73,3 @@ function ctools_plugin_example_example_role_ctools_access_summary($conf, $contex
}
return format_plural(count($names), '@identifier must have role "@roles"', '@identifier can be one of "@roles"', array('@roles' => implode(', ', $names), '@identifier' => $context->identifier));
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/arguments/simplecontext_arg.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/arguments/simplecontext_arg.inc
index 51c7c60..7fb732c 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/arguments/simplecontext_arg.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/arguments/simplecontext_arg.inc
@@ -2,7 +2,6 @@
/**
* @file
- *
* Sample plugin to provide an argument handler for a simplecontext.
*
* Given any argument to the page, simplecontext will get it
@@ -18,14 +17,12 @@
*/
$plugin = array(
'title' => t("Simplecontext arg"),
- // keyword to use for %substitution
+ // Keyword to use for %substitution.
'keyword' => 'simplecontext',
'description' => t('Creates a "simplecontext" from the arg.'),
'context' => 'simplecontext_arg_context',
- // 'settings form' => 'simplecontext_arg_settings_form',
-
// placeholder_form is used in panels preview, for example, so we can
- // preview without getting the arg from a URL
+ // preview without getting the arg from a URL.
'placeholder form' => array(
'#type' => 'textfield',
'#description' => t('Enter the simplecontext arg'),
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/no_context_content_type.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/no_context_content_type.inc
index 3c02ab8..48ce0f5 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/no_context_content_type.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/no_context_content_type.inc
@@ -5,7 +5,6 @@
* "No context" sample content type. It operates with no context at all. It would
* be basically the same as a 'custom content' block, but it's not even that
* sophisticated.
- *
*/
/**
@@ -33,7 +32,7 @@ $plugin = array(
'icon' => 'icon_example.png',
'category' => array(t('CTools Examples'), -9),
- // this example does not provide 'admin info', which would populate the
+ // This example does not provide 'admin info', which would populate the
// panels builder page preview.
);
@@ -56,7 +55,7 @@ function no_context_content_type_render($subtype, $conf, $args, $context) {
$ctools_help = theme('advanced_help_topic', array('module' => 'ctools', 'topic' => 'plugins', 'type' => 'title'));
$ctools_plugin_example_help = theme('advanced_help_topic', array('module' => 'ctools_plugin_example', 'topic' => 'Chaos-Tools--CTools--Plugin-Examples', 'type' => 'title'));
- // The title actually used in rendering
+ // The title actually used in rendering.
$block->title = check_plain("No-context content type");
$block->content = t("
Welcome to the CTools Plugin Example demonstration content type.
@@ -84,7 +83,6 @@ function no_context_content_type_render($subtype, $conf, $args, $context) {
* Note that if we had not provided an entry for this in hook_content_types,
* this could have had the default name
* ctools_plugin_example_no_context_content_type_edit_form.
- *
*/
function no_context_content_type_edit_form($form, &$form_state) {
$conf = $form_state['conf'];
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/relcontext_content_type.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/relcontext_content_type.inc
index bf54dce..ced6411 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/relcontext_content_type.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/relcontext_content_type.inc
@@ -1,6 +1,5 @@
array(t('CTools Examples'), -9),
'edit form' => 'relcontext_edit_form',
- // this example does not provide 'admin info', which would populate the
+ // This example does not provide 'admin info', which would populate the
// panels builder page preview.
-
);
/**
@@ -60,7 +58,7 @@ function relcontext_content_type_render($subtype, $conf, $args, $context) {
In our case, the configuration form (\$conf) has just one field, 'config_item_1;
and it's configured with:
");
- if (!empty($conf)) {
+ if (!empty($conf)) {
$block->content .= '
' . var_export($conf['config_item_1'], TRUE) . '
';
}
if (!empty($context)) {
@@ -77,7 +75,6 @@ function relcontext_content_type_render($subtype, $conf, $args, $context) {
/**
* 'Edit' callback for the content type.
* This example just returns a form.
- *
*/
function relcontext_edit_form($form, &$form_state) {
$conf = $form_state['conf'];
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/simplecontext_content_type.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/simplecontext_content_type.inc
index a308683..e34fa18 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/simplecontext_content_type.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/simplecontext_content_type.inc
@@ -1,6 +1,5 @@
'simplecontext_content_type_edit_form',
'admin title' => 'ctools_plugin_example_simplecontext_content_type_admin_title',
- // presents a block which is used in the preview of the data.
+ // Presents a block which is used in the preview of the data.
// Pn Panels this is the preview pane shown on the panels building page.
'admin info' => 'ctools_plugin_example_simplecontext_content_type_admin_info',
'category' => array(t('CTools Examples'), -9),
@@ -103,7 +101,6 @@ function simplecontext_content_type_render($subtype, $conf, $args, $context) {
/**
* 'Edit' callback for the content type.
* This example just returns a form.
- *
*/
function simplecontext_content_type_edit_form($form, &$form_state) {
$conf = $form_state['conf'];
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/contexts/relcontext.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/contexts/relcontext.inc
index 0c7ef11..61e25db 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/contexts/relcontext.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/contexts/relcontext.inc
@@ -80,4 +80,3 @@ function relcontext_settings_form($conf, $external = FALSE) {
);
return $form;
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/contexts/simplecontext.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/contexts/simplecontext.inc
index e19a842..0ee4658 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/contexts/simplecontext.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/contexts/simplecontext.inc
@@ -1,10 +1,8 @@
t("Simplecontext"),
'description' => t('A single "simplecontext" context, or data element.'),
- 'context' => 'ctools_plugin_example_context_create_simplecontext', // func to create context
+// Func to create context.
+ 'context' => 'ctools_plugin_example_context_create_simplecontext',
'context name' => 'simplecontext',
'settings form' => 'simplecontext_settings_form',
'keyword' => 'simplecontext',
@@ -69,7 +68,7 @@ function ctools_plugin_example_context_create_simplecontext($empty, $data = NULL
// This is used for keyword.
$context->title = $data;
$context->argument = $data;
- // Make up a bogus context
+ // Make up a bogus context.
$context->data = new stdClass();
$context->data->item1 = t("Item1");
$context->data->item2 = t("Item2");
@@ -102,8 +101,6 @@ function simplecontext_settings_form($conf, $external = FALSE) {
return $form;
}
-
-
/**
* Provide a list of sub-keywords.
*
@@ -125,10 +122,11 @@ function simplecontext_convert($context, $type) {
switch ($type) {
case 'item1':
return $context->data->item1;
+
case 'item2':
return $context->data->item2;
+
case 'description':
return $context->data->description;
}
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/panels.pages.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/panels.pages.inc
index d3022af..25422cf 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/panels.pages.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/panels.pages.inc
@@ -19,24 +19,24 @@ function ctools_plugin_example_default_panel_pages() {
$page->load_flags = 1;
$page->css_id = '';
$page->arguments = array(
- 0 =>
+ 0 =>
array(
- 'name' => 'simplecontext_arg',
- 'id' => 1,
- 'default' => '404',
- 'title' => '',
- 'identifier' => 'Simplecontext arg',
- 'keyword' => 'simplecontext',
+ 'name' => 'simplecontext_arg',
+ 'id' => 1,
+ 'default' => '404',
+ 'title' => '',
+ 'identifier' => 'Simplecontext arg',
+ 'keyword' => 'simplecontext',
),
);
$page->relationships = array(
- 0 =>
+ 0 =>
array(
- 'context' => 'argument_simplecontext_arg_1',
- 'name' => 'relcontext_from_simplecontext',
- 'id' => 1,
- 'identifier' => 'Relcontext from Simplecontext',
- 'keyword' => 'relcontext',
+ 'context' => 'argument_simplecontext_arg_1',
+ 'name' => 'relcontext_from_simplecontext',
+ 'id' => 1,
+ 'identifier' => 'Relcontext from Simplecontext',
+ 'keyword' => 'relcontext',
),
);
$page->no_blocks = '0';
@@ -58,14 +58,14 @@ function ctools_plugin_example_default_panel_pages() {
$pane->subtype = 'custom';
$pane->access = array();
$pane->configuration = array(
- 'style' => 'default',
- 'override_title' => 0,
- 'override_title_text' => '',
- 'css_id' => '',
- 'css_class' => '',
- 'title' => '"No Context Item"',
- 'body' => 'The "no context item" content type is here to demonstrate that you can create a content_type that does not require a context. This is probably the same as just creating a custom php block on the fly, and might serve the same purpose.',
- 'format' => '1',
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'title' => '"No Context Item"',
+ 'body' => 'The "no context item" content type is here to demonstrate that you can create a content_type that does not require a context. This is probably the same as just creating a custom php block on the fly, and might serve the same purpose.',
+ 'format' => '1',
);
$pane->cache = array();
$display->content['new-1'] = $pane;
@@ -78,14 +78,14 @@ function ctools_plugin_example_default_panel_pages() {
$pane->subtype = 'description';
$pane->access = array();
$pane->configuration = array(
- 'style' => 'default',
- 'override_title' => 0,
- 'override_title_text' => '',
- 'css_id' => '',
- 'css_class' => '',
- 'item1' => 'one',
- 'item2' => 'two',
- 'item3' => 'three',
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'item1' => 'one',
+ 'item2' => 'two',
+ 'item3' => 'three',
);
$pane->cache = array();
$display->content['new-2'] = $pane;
@@ -98,16 +98,16 @@ function ctools_plugin_example_default_panel_pages() {
$pane->subtype = 'custom';
$pane->access = array();
$pane->configuration = array(
- 'style' => 'default',
- 'override_title' => 0,
- 'override_title_text' => '',
- 'css_id' => '',
- 'css_class' => '',
- 'title' => 'Simplecontext',
- 'body' => 'The "Simplecontext" content and content type demonstrate a very basic context and how to display it.
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'title' => 'Simplecontext',
+ 'body' => 'The "Simplecontext" content and content type demonstrate a very basic context and how to display it.
Simplecontext includes configuration, so it can get info from the config. It can also get its information to run from a simplecontext context, generated either from an arg to the panels page or via explicitly adding a context to the page.',
- 'format' => '1',
+ 'format' => '1',
);
$pane->cache = array();
$display->content['new-3'] = $pane;
@@ -119,17 +119,17 @@ function ctools_plugin_example_default_panel_pages() {
$pane->shown = '1';
$pane->subtype = 'description';
$pane->access = array(
- 0 => '2',
- 1 => '4',
+ 0 => '2',
+ 1 => '4',
);
$pane->configuration = array(
- 'context' => 'argument_simplecontext_arg_1',
- 'style' => 'default',
- 'override_title' => 0,
- 'override_title_text' => '',
- 'css_id' => '',
- 'css_class' => '',
- 'config_item_1' => 'simplecontext called from arg',
+ 'context' => 'argument_simplecontext_arg_1',
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'config_item_1' => 'simplecontext called from arg',
);
$pane->cache = array();
$display->content['new-4'] = $pane;
@@ -142,14 +142,14 @@ function ctools_plugin_example_default_panel_pages() {
$pane->subtype = 'custom';
$pane->access = array();
$pane->configuration = array(
- 'style' => 'default',
- 'override_title' => 0,
- 'override_title_text' => '',
- 'css_id' => '',
- 'css_class' => '',
- 'title' => 'Relcontext',
- 'body' => 'The relcontext content_type gets its data from a relcontext, which is an example of a relationship. This panel should be run with an argument like "/xxx", which allows the simplecontext to get its context, and then the relcontext is configured in this panel to get (create) its data from the simplecontext.',
- 'format' => '1',
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'title' => 'Relcontext',
+ 'body' => 'The relcontext content_type gets its data from a relcontext, which is an example of a relationship. This panel should be run with an argument like "/xxx", which allows the simplecontext to get its context, and then the relcontext is configured in this panel to get (create) its data from the simplecontext.',
+ 'format' => '1',
);
$pane->cache = array();
$display->content['new-5'] = $pane;
@@ -162,13 +162,13 @@ function ctools_plugin_example_default_panel_pages() {
$pane->subtype = 'description';
$pane->access = array();
$pane->configuration = array(
- 'context' => 'relationship_relcontext_from_simplecontext_1',
- 'style' => 'default',
- 'override_title' => 0,
- 'override_title_text' => '',
- 'css_id' => '',
- 'css_class' => '',
- 'config_item_1' => 'default1',
+ 'context' => 'relationship_relcontext_from_simplecontext_1',
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'config_item_1' => 'default1',
);
$pane->cache = array();
$display->content['new-6'] = $pane;
@@ -181,13 +181,13 @@ function ctools_plugin_example_default_panel_pages() {
$pane->subtype = 'custom_php';
$pane->access = array();
$pane->configuration = array(
- 'style' => 'default',
- 'override_title' => 0,
- 'override_title_text' => '',
- 'css_id' => '',
- 'css_class' => '',
- 'title' => '',
- 'body' => '$arg = arg(1);
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'title' => '',
+ 'body' => '$arg = arg(1);
$arg0 = arg(0);
if (!$arg) {
$block->content = <<displays = array();
$pages['ctools_plugin_example'] = $page;
-
return $pages;
}
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/relationships/relcontext_from_simplecontext.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/relationships/relcontext_from_simplecontext.inc
index 6224621..087d5ec 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/relationships/relcontext_from_simplecontext.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/relationships/relcontext_from_simplecontext.inc
@@ -1,9 +1,7 @@
'Space separated list of exportables you want to view.',
),
'options' => array(
- 'indent' => 'The string to use for indentation when dispalying the exportable export code. Defaults to \'\'.',
+ 'indent' => 'The string to use for indentation when displaying the exportable export code. Defaults to \'\'.',
'no-colour' => 'Remove any colour formatting from export string output. Ideal if you are sending the output of this command to a file.',
'module' => $module_text,
'all' => $all_text,
@@ -140,13 +140,14 @@ function ctools_drush_help($section) {
switch ($section) {
case 'meta:ctools:title':
return dt('CTools commands');
+
case 'meta:entity:summary':
return dt('CTools drush commands.');
}
}
/**
- * Drush callback: export
+ * Drush callback: export.
*/
function ctools_drush_export($module = 'foo') {
$error = FALSE;
@@ -338,7 +339,7 @@ function _ctools_drush_selection_screen(array $tables = array()) {
$build[$table_choice]['count'] = count($multi_select);
$selections[$table_choice] = array();
foreach ($multi_select as $key) {
- $selections[$table_choice][$key] = $key;
+ $selections[$table_choice][$key] = $key;
}
}
}
@@ -445,11 +446,13 @@ function ctools_drush_export_info() {
}
}
}
+
/**
* Drush callback: Acts as the hub for all op commands to keep
* all arg handling etc in one place.
*/
function ctools_drush_export_op_command() {
+ $args = func_get_args();
// Get all info for the current drush command.
$command = drush_get_command();
$op = '';
@@ -457,17 +460,20 @@ function ctools_drush_export_op_command() {
switch ($command['command']) {
case 'ctools-export-view':
$op = 'view';
- break;
+ break;
+
case 'ctools-export-revert':
// Revert is same as deleting. As any objects in the db are deleted.
$op = 'delete';
- break;
+ break;
+
case 'ctools-export-enable':
$op = 'enable';
- break;
+ break;
+
case 'ctools-export-disable':
$op = 'disable';
- break;
+ break;
}
if (!$op) {
@@ -475,7 +481,7 @@ function ctools_drush_export_op_command() {
}
if (drush_get_option('all', FALSE)) {
- $info = _ctools_drush_export_info('', TRUE);
+ $info = _ctools_drush_export_info(array(), TRUE);
$exportable_info = $info['exportables'];
$all = drush_confirm(dt('Are you sure you would like to !op all exportables on the system?',
@@ -490,7 +496,6 @@ function ctools_drush_export_op_command() {
}
}
else {
- $args = func_get_args();
// Table name should always be first arg...
$table_name = array_shift($args);
// Any additional args are assumed to be exportable names.
@@ -512,7 +517,6 @@ function ctools_drush_export_op_command() {
* @param $op
* @param $table_name
* @param $exportables
- *
*/
function ctools_drush_export_op($op = '', $table_name = '', $exportables = NULL) {
$objects = ctools_export_crud_load_multiple($table_name, array_keys($exportables));
@@ -538,7 +542,7 @@ function ctools_drush_export_op($op = '', $table_name = '', $exportables = NULL)
* @param $object_names
*
* @return
- * Array of exportable objects (filtered if necessary, by name etc..) or FALSE if not.
+ * Array of exportable objects (filtered if necessary, by name etc..) or FALSE if not.
*/
function _ctools_drush_export_op_command_logic($op = '', $table_name = NULL, array $object_names = array()) {
if (!$table_name) {
@@ -644,7 +648,7 @@ function _ctools_drush_export_info(array $table_names = array(), $load = FALSE)
return array('exportables' => $exportables, 'schemas' => $schemas);
}
-/*
+/**
* View a single object.
*
* @param $table_name
@@ -662,7 +666,7 @@ function _ctools_drush_export_view($table_name, $object) {
}
}
-/*
+/**
* Revert a single object.
*
* @param $table_name
@@ -681,7 +685,7 @@ function _ctools_drush_export_delete($table_name, $object) {
}
}
-/*
+/**
* Enable a single object.
*
* @param $table_name
@@ -701,7 +705,7 @@ function _ctools_drush_export_enable($table_name, $object) {
}
}
-/*
+/**
* Disable a single object.
*
* @param $table_name
@@ -723,9 +727,9 @@ function _ctools_drush_export_disable($table_name, $object) {
/**
* Filter a nested array of exportables by export module.
*
- * @param $exportables array
+ * @param array $exportables
* Passed by reference. A nested array of exportables, keyed by table name.
- * @param $export_module string
+ * @param string $export_module
* The name of the export module providing the exportable.
*/
function _ctools_drush_export_module_filter($exportables, $export_module) {
@@ -778,7 +782,7 @@ function _ctools_drush_object_is_disabled($object) {
/**
* Determine if an object is enabled.
*
- * @see _ctools_drush_object_is_disabled.
+ * @see _ctools_drush_object_is_disabled()
*/
function _ctools_drush_object_is_enabled($object) {
return (empty($object->disabled)) ? TRUE : FALSE;
@@ -835,7 +839,7 @@ function _ctools_drush_object_is_not_code_only($object) {
* Array of exportables to count.
*
* @return
- * Array of count data containing the following:
+ * Array of count data containing the following:
* 'total' - A total count of all exportables.
* 'exportables' - An array of exportable counts per table.
*/
@@ -867,26 +871,32 @@ function _ctools_drush_filter_exportables($exportables, $filter) {
// Show enabled exportables only.
case 'enabled':
$eval = '_ctools_drush_object_is_disabled';
- break;
+ break;
+
// Show disabled exportables only.
case 'disabled':
$eval = '_ctools_drush_object_is_enabled';
- break;
+ break;
+
// Show overridden exportables only.
case 'overridden':
$eval = '_ctools_drush_object_is_not_overridden';
- break;
+ break;
+
// Show database only exportables.
case 'database':
$eval = '_ctools_drush_object_is_not_db_only';
- break;
+ break;
+
// Show code only exportables.
case 'code':
$eval = '_ctools_drush_object_is_not_code_only';
- break;
+ break;
+
// Do nothing.
case 'all':
break;
+
default:
drush_log(dt('Invalid filter option. Available options are: enabled, disabled, overridden, database, and code.'), 'error');
return;
@@ -983,33 +993,42 @@ class shellColours {
'light_gray' => '47',
);
+ /**
+ * shellColours constructor.
+ */
private function __construct() {}
- // Returns coloured string
+ /**
+ * Returns coloured string.
+ */
public static function getColouredOutput($string, $foreground_colour = NULL, $background_colour = NULL) {
$coloured_string = "";
- // Check if given foreground colour found
+ // Check if given foreground colour found.
if ($foreground_colour) {
$coloured_string .= "\033[" . self::$foreground_colours[$foreground_colour] . "m";
}
- // Check if given background colour found
+ // Check if given background colour found.
if ($background_colour) {
$coloured_string .= "\033[" . self::$background_colours[$background_colour] . "m";
}
- // Add string and end colouring
- $coloured_string .= $string . "\033[0m";
+ // Add string and end colouring.
+ $coloured_string .= $string . "\033[0m";
return $coloured_string;
}
- // Returns all foreground colour names
+ /**
+ * Returns all foreground colour names.
+ */
public static function getForegroundColours() {
return array_keys(self::$foreground_colours);
}
- // Returns all background colour names
+ /**
+ * Returns all background colour names.
+ */
public static function getBackgroundColours() {
return array_keys(self::$background_colours);
}
diff --git a/sites/all/modules/contrib/dev/ctools/help/export.html b/sites/all/modules/contrib/dev/ctools/help/export.html
index ce24cad..573c98a 100644
--- a/sites/all/modules/contrib/dev/ctools/help/export.html
+++ b/sites/all/modules/contrib/dev/ctools/help/export.html
@@ -154,7 +154,7 @@ function mymodule_schema() {
Bulk export callback to provide a list of exportable objects to be chosen for bulk exporting. Defaults to $module . '_' . $table . '_list' if the function exists. If it is not, a default listing function will be provided that will make a best effort to list the titles. See ctools_export_default_list().
to hook code callback
-
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'.
+
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'.
boolean
Explicitly indicate if a table field contains a boolean or not. The Schema API does not model the
diff --git a/sites/all/modules/contrib/dev/ctools/help/modal.html b/sites/all/modules/contrib/dev/ctools/help/modal.html
index ea823a0..761fd2e 100644
--- a/sites/all/modules/contrib/dev/ctools/help/modal.html
+++ b/sites/all/modules/contrib/dev/ctools/help/modal.html
@@ -82,7 +82,7 @@ function ctools_modal_text_button($text, $dest, $alt, $class = '') {
modalSize: an array of data to control the sizing of the modal. It can contain:
type: Either fixed or scale. If fixed, the modal will always be a fixed size. If scale the modal will scale to a percentage of the browser window. Default: scale.
-
width: If fixed the width in pixels. If scale the percentage of the screen expressed as a number less than zero. (For 80 percent, use .8, for example). Default: .8
+
width: If fixed the width in pixels. If scale the percentage of the screen expressed as a number less than zero. (For 80 percent, use .8, for example). Default: .8
height: If fixed the height in pixels. If scale the percentage of the screen expressed as a number less than zero. (For 80 percent, use .8, for example). Default: .8
addWidth: Any additional width to add to the modal in pixels. Only useful if the type is scale. Default: 0
addHeight: Any additional height to add to the modal in pixels. Only useful if the type is scale. Default: 0
@@ -168,7 +168,7 @@ function ctools_ajax_sample_login($js) {
function ctools_ajax_hello_world($js) {
$title = t('Greetings');
- $output = '<p>' . t('Hello world') . ''</p>';
+ $output = '<p>' . t('Hello world') . '</p>';
if ($js) {
ctools_modal_render($title, $output);
}
diff --git a/sites/all/modules/contrib/dev/ctools/help/plugins-creating.html b/sites/all/modules/contrib/dev/ctools/help/plugins-creating.html
index 2323705..6d5b35f 100644
--- a/sites/all/modules/contrib/dev/ctools/help/plugins-creating.html
+++ b/sites/all/modules/contrib/dev/ctools/help/plugins-creating.html
@@ -26,7 +26,7 @@ The following information can be specified for each plugin type:
If 'cache' is TRUE, then this value specifies the cache table where the cached plugin information will be stored.
classes
Defaults to:array()
-
An array of class identifiers(i.e. plugin array keys) which a plugin of this type uses to provide classes to the CTools autoloader. For example, if classes is set to array('class'), then CTools will search each $plugin['class'] for a class to autoload. Depending of the plugin structure, a class identifier may be either:
+
An array of class identifiers(i.e. plugin array keys) which a plugin of this type uses to provide classes to the CTools autoloader. For example, if classes is set to array('class'), then CTools will search each $plugin['class'] for a class to autoload. Depending of the plugin structure, a class identifier may be either:
- a file name:
the file which holds the class with the name structure as: [filename].[class].php
@@ -35,6 +35,7 @@ The following information can be specified for each plugin type:
if the class is in the same file as the $plugin
the plugin .inc file can have a different name than the class identifier
+
defaults
Defaults to:array()
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.
diff --git a/sites/all/modules/contrib/dev/ctools/includes/action-links.theme.inc b/sites/all/modules/contrib/dev/ctools/includes/action-links.theme.inc
index 3a2398a..f53f59c 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/action-links.theme.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/action-links.theme.inc
@@ -1,4 +1,5 @@
' . $links . '';
-}
\ No newline at end of file
+}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/ajax.inc b/sites/all/modules/contrib/dev/ctools/includes/ajax.inc
index 96f5068..4d72d0c 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/ajax.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/ajax.inc
@@ -1,6 +1,10 @@
'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;
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/includes/cache.inc b/sites/all/modules/contrib/dev/ctools/includes/cache.inc
index 3918683..cace800 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/cache.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/cache.inc
@@ -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);
}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/cleanstring.inc b/sites/all/modules/contrib/dev/ctools/includes/cleanstring.inc
index 56b3e36..11ffcef 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/cleanstring.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/cleanstring.inc
@@ -1,5 +1,4 @@
$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 {
diff --git a/sites/all/modules/contrib/dev/ctools/includes/collapsible.theme.inc b/sites/all/modules/contrib/dev/ctools/includes/collapsible.theme.inc
index f7bbbb3..81df4bc 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/collapsible.theme.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/collapsible.theme.inc
@@ -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;
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/includes/content.inc b/sites/all/modules/contrib/dev/ctools/includes/content.inc
index b4660b4..49c3565 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/content.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/content.inc
@@ -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);
}
@@ -155,6 +155,11 @@ function ctools_content_get_subtypes($type) {
// Walk through the subtypes and ensure minimal settings are
// retained.
foreach ($subtypes as $id => $subtype) {
+ // Ensure that the 'subtype_id' value exists.
+ if (!isset($subtype['subtype_id'])) {
+ $subtypes[$id]['subtype_id'] = $id;
+ }
+
// Use exact name since this is a modify by reference.
ctools_content_prepare_subtype($subtypes[$id], $plugin);
}
@@ -202,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;
@@ -217,6 +229,7 @@ function ctools_content_prepare_subtype(&$subtype, $plugin) {
}
}
+ // Trigger hook_ctools_content_subtype_alter().
drupal_alter('ctools_content_subtype', $subtype, $plugin);
}
@@ -241,8 +254,8 @@ function ctools_content_prepare_subtype(&$subtype, $plugin) {
* Any incoming content, if this display is a wrapper.
*
* @return
- * The content as rendered by the plugin. This content should be an array
- * with the following possible keys:
+ * The content as rendered by the plugin, or NULL.
+ * This content should be an object with the following possible properties:
* - title: The safe to render title of the content.
* - title_heading: The title heading.
* - content: The safe to render HTML content.
@@ -294,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;
@@ -304,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.
@@ -320,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);
}
@@ -341,7 +354,16 @@ function ctools_content_editable($type, $subtype, $conf) {
return FALSE;
}
- if ($function = ctools_plugin_get_function($subtype, 'check editable')) {
+ $function = FALSE;
+
+ if (!empty($subtype['check editable'])) {
+ $function = ctools_plugin_get_function($subtype, 'check editable');
+ }
+ elseif (!empty($type['check editable'])) {
+ $function = ctools_plugin_get_function($type, 'check editable');
+ }
+
+ if ($function) {
return $function($type, $subtype, $conf);
}
@@ -364,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 {
@@ -382,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'];
}
}
@@ -420,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)) {
@@ -429,7 +451,7 @@ function ctools_content_get_defaults($plugin, $subtype) {
return $return;
}
}
- else if (is_array($defaults)) {
+ elseif (is_array($defaults)) {
return $defaults;
}
}
@@ -463,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.');
@@ -472,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'];
@@ -589,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);
}
}
@@ -599,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);
}
}
@@ -618,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 {
@@ -633,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;
@@ -684,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;
@@ -724,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();
diff --git a/sites/all/modules/contrib/dev/ctools/includes/content.menu.inc b/sites/all/modules/contrib/dev/ctools/includes/content.menu.inc
index ba32cb5..64d44b0 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/content.menu.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/content.menu.inc
@@ -23,12 +23,13 @@ function ctools_content_menu(&$items) {
/**
* Helper function for autocompletion of entity titles.
*/
-function ctools_content_autocomplete_entity($type, $string = '') {
+function ctools_content_autocomplete_entity($entity_type, $string = '') {
if ($string != '') {
- global $user;
- $entity_info = entity_get_info($type);
- if ($type == 'node') {
- $entity_info['entity keys']['bundle field'] = 'type';
+ $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
@@ -42,84 +43,77 @@ function ctools_content_autocomplete_entity($type, $string = '') {
// If an ID match was found, use that ID rather than the whole string.
if ($match) {
$entity_id = $preg_matches[1];
- $entity = entity_load($type, array($entity_id));
-
- // Format results in an array so later we could add attributes to the
- // autocomplete text that is returned.
- $results = array($entity_id => array(
- 'label' => $entity[$entity_id]->$entity_info['entity keys']['label'],
- ));
+ $results = _ctools_getReferencableEntities($entity_type, $entity_info, $entity_id, '=', 1);
}
else {
- $results = _ctools_getReferencableEntities($type, $entity_info, $string, 'LIKE', 10);
+ // 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]" => '' . t('Entity Type !entity_type does not support autocomplete search.', array('!entity_type' => $entity_type)) . ''));
+ return;
+ }
+ $results = _ctools_getReferencableEntities($entity_type, $entity_info, $string, 'LIKE', 10);
}
- foreach($results as $entity_id => $result) {
- if (!$entity_info['entity keys']['label']) {
- $matches["[id: $entity_id]"] = '' . $entity_id . '';
- }
- else {
- $matches[$result['label'] . " [id: $entity_id]"] = '' . check_plain($result['label']) . '';
- $matches[$result['label'] . " [id: $entity_id]"] .= isset($result['bundle field']) ? ' (' . check_plain($result['bundle field']) . ')' : '';
- }
+ foreach ($results as $entity_id => $result) {
+ $matches[$result['label'] . " [id: $entity_id]"] = '' . check_plain($result['label']) . '';
+ $matches[$result['label'] . " [id: $entity_id]"] .= isset($result['bundle']) ? ' (' . check_plain($result['bundle']) . ')' : '';
}
drupal_json_output($matches);
}
}
-/*
- * 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'];
- $query = db_select($base_table)
- ->fields($base_table, array($entity_info['entity keys']['id']));
+ $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($entity_info['entity keys']['label'])) {
- $query->condition($base_table .'.'. $entity_info['entity keys']['label'], '%' . $match . '%' , $match_operator);
- }
- }
-
- // Add a label to the query, if the label exists
- if (isset($entity_info['entity keys']['label'])) {
- $query->fields($base_table, array($entity_info['entity keys']['label']));
- }
-
- // Add bundle field to the query, if it exists.
- if (isset($entity_info['entity keys']['bundle field'])) {
- $query->fields($base_table, array($entity_info['entity keys']['bundle field']));
- }
-
- // Add a generic entity access tag to the query.
- $query->addTag('ctools');
-
- 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') && !count(module_implements('node_grants'))) {
- $node_alias = $query->innerJoin('node', 'n', '%alias.nid = comment.nid');
- $query->condition($node_alias . '.status', NODE_PUBLISHED);
- }
- $query->addTag('node_access');
+ 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 {
- $query->addTag($entity_type . '_access');
+ 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);
}
- // Add the sort option.
- if(isset($entity_info['entity keys']['label'])) {
- $query->orderBy($base_table .'.'. $entity_info['entity keys']['label'], 'ASC');
+ // 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');
+ }
- return $query;
+ // Add the sort option.
+ if (isset($label_key)) {
+ $query->orderBy($base_table . '.' . $label_key, 'ASC');
+ }
+
+ return $query;
}
/**
@@ -127,23 +121,58 @@ function _ctools_buildQuery($entity_type, $entity_info, $match = NULL, $match_op
* Entity Reference module.
*/
function _ctools_getReferencableEntities($entity_type, $entity_info, $match = NULL, $match_operator = 'LIKE', $limit = 0) {
+ global $user;
+ $account = $user;
$options = array();
-
- $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) {
- $options[$record->{$entity_info['entity keys']['id']}] = array(
- 'label' => isset($entity_info['entity keys']['label']) ? check_plain($record->{$entity_info['entity keys']['label']}) : $record->{$entity_info['entity keys']['id']},
- 'bundle field' => isset($entity_info['entity keys']['bundle field']) ? check_plain($record->{$entity_info['entity keys']['bundle field']}) : '',
- );
+ // 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,
+ ),
+ );
}
- return $options;
-}
\ No newline at end of file
+ // 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();
+}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/content.plugin-type.inc b/sites/all/modules/contrib/dev/ctools/includes/content.plugin-type.inc
index a0debc3..0364a92 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/content.plugin-type.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/content.plugin-type.inc
@@ -14,4 +14,4 @@ function ctools_content_plugin_type(&$items) {
'path' => drupal_get_path('module', 'ctools') . '/includes',
),
);
-}
\ No newline at end of file
+}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/context-access-admin.inc b/sites/all/modules/contrib/dev/ctools/includes/context-access-admin.inc
index 76643cf..d8c4f3b 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/context-access-admin.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/context-access-admin.inc
@@ -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();
}
@@ -367,12 +370,14 @@ function ctools_access_ajax_edit($fragment = NULL, $id = NULL) {
'contexts' => $contexts,
'title' => t('Edit criteria'),
'ajax' => TRUE,
- 'ajax' => TRUE,
'modal' => TRUE,
'modal return' => TRUE,
);
$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)) {
@@ -452,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;
@@ -472,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);
diff --git a/sites/all/modules/contrib/dev/ctools/includes/context-admin.inc b/sites/all/modules/contrib/dev/ctools/includes/context-admin.inc
index 2d8c8f9..533c89f 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/context-admin.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/context-admin.inc
@@ -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') {
@@ -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
@@ -561,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') {
@@ -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;
}
}
@@ -736,6 +736,15 @@ function ctools_edit_context_form_defaults($form, &$form_state) {
'#default_value' => $conf['keyword'],
);
+ if ($type_info['key'] == 'requiredcontexts') {
+ $form['optional'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Context is optional'),
+ '#default_value' => !empty($form_state['conf']['optional']),
+ '#description' => t('This context need not be present for the component to function.'),
+ );
+ }
+
$form['#submit'][] = 'ctools_edit_context_form_defaults_submit';
return $form;
@@ -752,6 +761,9 @@ function ctools_edit_context_form_defaults_submit(&$form, &$form_state) {
$form_state['conf']['default'] = $form_state['values']['default'];
$form_state['conf']['title'] = $form_state['values']['title'];
}
+ if ($form_state['type info']['key'] == 'requiredcontexts') {
+ $form_state['conf']['optional'] = $form_state['values']['optional'];
+ }
$form_state['conf']['identifier'] = $form_state['values']['identifier'];
$form_state['conf']['keyword'] = $form_state['values']['keyword'];
diff --git a/sites/all/modules/contrib/dev/ctools/includes/context-task-handler.inc b/sites/all/modules/contrib/dev/ctools/includes/context-task-handler.inc
index 21ceea5..ed4acad 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/context-task-handler.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/context-task-handler.inc
@@ -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]);
}
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/includes/context.inc b/sites/all/modules/contrib/dev/ctools/includes/context.inc
index 6628b5f..0fc6208 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/context.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/context.inc
@@ -2,7 +2,6 @@
/**
* @file
- *
* Contains code related to the ctools system of 'context'.
*
* Context, originally from Panels, is a method of packaging objects into
@@ -28,28 +27,104 @@
* of the context is important.
*/
class ctools_context {
- var $type = NULL;
- var $data = NULL;
- // The title of this object.
- var $title = '';
- // The title of the page if this object exists
- var $page_title = '';
- // The identifier (in the UI) of this object
- var $identifier = '';
- var $argument = NULL;
- var $keyword = '';
- var $original_argument = NULL;
- var $restrictions = array();
- var $empty = FALSE;
+ /**
+ * @var string|array
+ * A string naming this specific context type. The values 'any' and 'none'
+ * are special:
+ * - 'any': used in is_type() to match any other type.
+ * - 'none': used to signal the type is not defined.
+ */
+ public $type;
- function ctools_context($type = 'none', $data = NULL) {
- $this->type = $type;
- $this->data = $data;
+ /**
+ * @var mixed
+ * The data payload for this context object.
+ */
+ public $data;
+
+ /**
+ * @var string
+ * The title of this object.
+ */
+ public $title;
+
+ /**
+ * @var string
+ * The title of the page if this object exists
+ */
+ public $page_title;
+
+ /**
+ * @var string
+ * The identifier (in the UI) of this object.
+ */
+ public $identifier;
+
+ /**
+ * @var
+ */
+ public $argument;
+
+ /**
+ * @var string
+ */
+ public $keyword;
+
+ /**
+ * @var
+ */
+ public $original_argument;
+
+ /**
+ * @var array
+ */
+ public $restrictions;
+
+ /**
+ * @var bool
+ */
+ public $empty;
+
+ /**
+ * The ctools_context constructor.
+ *
+ * @param string $type
+ * The type name of this context. Should be unique. Use the machine_name
+ * conventions: lowercase, short, underscores and no spaces.
+ * @param mixed $data
+ * The data payload, if required for this context.
+ */
+ public function __construct($type = 'none', $data = NULL) {
+ $this->type = $type;
+ $this->data = $data;
$this->title = t('Unknown context');
+ $this->page_title = '';
+ $this->identifier = '';
+ $this->keyword = '';
+ $this->restrictions = array();
+ $this->empty = FALSE;
+ // Other vars are NULL.
}
- function is_type($type) {
- if ($type == 'any' || $this->type == 'any') {
+ /**
+ * Determine whether this object is of type @var $type .
+ *
+ * Both the internal value ($this->type) and the supplied value ($type) can
+ * be a string or an array of strings, and if one or both are arrays the match
+ * succeeds if at least one common element is found.
+ *
+ * Type names
+ *
+ * @param string|array $type
+ * 'type' can be:
+ * - 'any' to match all types (this is true of the internal value too).
+ * - an array of type name strings, when more than one type is acceptable.
+ *
+ * @return bool
+ * True if the type matches, False otherwise.
+ */
+ public function is_type($type) {
+ if ($type === 'any' || $this->type === 'any') {
return TRUE;
}
@@ -58,32 +133,71 @@ class ctools_context {
return (bool) array_intersect($a, $b);
}
- function get_argument() {
+ /**
+ * Return the argument.
+ *
+ * @return mixed
+ * The value of $argument.
+ */
+ public function get_argument() {
return $this->argument;
}
- function get_original_argument() {
+ /**
+ * Return the value of argument (or arg) variable as it was passed in.
+ *
+ * For example see ctools_plugin_load_function() and ctools_terms_context().
+ *
+ * @return mixed
+ * The original arg value.
+ */
+ public function get_original_argument() {
if (!is_null($this->original_argument)) {
return $this->original_argument;
}
return $this->argument;
}
- function get_keyword() {
+ /**
+ * Return the keyword.
+ *
+ * @return mixed
+ * The value of $keyword.
+ */
+ public function get_keyword() {
return $this->keyword;
}
- function get_identifier() {
+ /**
+ * Return the identifier.
+ *
+ * @return mixed
+ * The value of $identifier.
+ */
+ public function get_identifier() {
return $this->identifier;
}
- function get_title() {
+ /**
+ * Return the title.
+ *
+ * @return mixed
+ * The value of $title.
+ */
+ public function get_title() {
return $this->title;
}
- function get_page_title() {
+ /**
+ * Return the page title.
+ *
+ * @return mixed
+ * The value of $page_title.
+ */
+ public function get_page_title() {
return $this->page_title;
}
+
}
/**
@@ -91,39 +205,57 @@ class ctools_context {
* match a required context type.
*/
class ctools_context_required {
- var $keywords = '';
+ /**
+ * @var array
+ * Keyword strings associated with the context.
+ */
+ public $keywords;
/**
* If set, the title will be used in the selector to identify
* the context. This is very useful when multiple contexts
* are required to inform the user will be used for what.
*/
- var $title = NULL;
+ public $title;
/**
* Test to see if this context is required.
*/
- var $required = TRUE;
+ public $required = TRUE;
/**
* If TRUE, skip the check in ctools_context_required::select()
* for contexts whose names may have changed.
*/
- var $skip_name_check = FALSE;
+ public $skip_name_check = FALSE;
/**
+ * The ctools_context_required constructor.
*
- * @param $title
- * The first parameter should be the 'title' of the context for use
- * in UYI selectors when multiple contexts qualify.
- * @param ...
+ * Note: Constructor accepts a variable number of arguments, with optional
+ * type-dependent args at the end of the list and one required argument,
+ * the title. Note in particular that skip_name_check MUST be passed in as
+ * a boolean (and not, for example, as an integer).
+ *
+ * @param string $title
+ * The title of the context for use in UI selectors when multiple contexts
+ * qualify.
+ * @param string $keywords
* One or more keywords to use for matching which contexts are allowed.
+ * @param array $restrictions
+ * Array of context restrictions.
+ * @param bool $skip_name_check
+ * If True, skip the check in select() for contexts whose names may have
+ * changed.
*/
- function ctools_context_required($title) {
+ public function __construct($title) {
+ // If it was possible, using variadic syntax this should be:
+ // __construct($title, string ...$keywords, array $restrictions = NULL, bool $skip = NULL)
+ // but that form isn't allowed.
$args = func_get_args();
$this->title = array_shift($args);
- // If we have a boolean value at the end for $skip_name_check, store it
+ // If we have a boolean value at the end for $skip_name_check, store it.
if (is_bool(end($args))) {
$this->skip_name_check = array_pop($args);
}
@@ -133,20 +265,44 @@ class ctools_context_required {
$this->restrictions = array_pop($args);
}
- if (count($args) == 1) {
+ if (count($args) === 1) {
$args = array_shift($args);
}
$this->keywords = $args;
}
- function filter($contexts) {
+ /**
+ * Filter the contexts to determine which apply in the current environment.
+ *
+ * A context passes the filter if:
+ * - the context matches 'type' of the required keywords (uses
+ * ctools_context::is_type(), so includes 'any' matches, etc).
+ * - AND if restrictions are present, there are some common elements between
+ * the requirement and the context.
+ *
+ * @param array $contexts
+ * An array of ctools_context objects (or something which will cast to an
+ * array of them). The contexts to apply the filter on.
+ *
+ * @return array
+ * An array of context objects, keyed with the same keys used for $contexts,
+ * which pass the filter.
+ *
+ * @see ctools_context::is_type()
+ */
+ public function filter($contexts) {
$result = array();
- // See which of these contexts are valid
+ /**
+ * See which of these contexts are valid.
+ * @var ctools_context $context
+ */
foreach ((array) $contexts as $cid => $context) {
if ($context->is_type($this->keywords)) {
+
// Compare to see if our contexts were met.
if (!empty($this->restrictions) && !empty($context->restrictions)) {
+
foreach ($this->restrictions as $key => $values) {
// If we have a restriction, the context must either not have that
// restriction listed, which means we simply don't know what it is,
@@ -155,11 +311,16 @@ class ctools_context_required {
if (!is_array($values)) {
$values = array($values);
}
- if (!empty($context->restrictions[$key]) && !array_intersect($values, $context->restrictions[$key])) {
+
+ if (!empty($context->restrictions[$key])
+ && !array_intersect($values, $context->restrictions[$key])
+ ) {
+ // Break out to check next context; this one fails the filter.
continue 2;
}
}
}
+ // This context passes the filter.
$result[$cid] = $context;
}
}
@@ -167,7 +328,28 @@ class ctools_context_required {
return $result;
}
- function select($contexts, $context) {
+ /**
+ * Select one context from the list of contexts, accounting for changed IDs.
+ *
+ * Fundamentally, this returns $contexts[$context] or FALSE if that does not
+ * exist. Additional logic accounts for changes in context names and dealing
+ * with a $contexts parameter that is not an array.
+ *
+ * If we had requested a $context but that $context doesn't exist in our
+ * context list, there is a good chance that what happened is the context
+ * IDs changed. Look for another context that satisfies our requirements,
+ * unless $skip_name_check is set.
+ *
+ * @param ctools_context|array $contexts
+ * A context, or an array of ctools_context.
+ * @param string $context
+ * A context ID.
+ *
+ * @return bool|ctools_context
+ * The matching ctools_context, or False if no such context was found.
+ */
+ public function select($contexts, $context) {
+ // Easier to deal with a standalone object as a 1-element array of objects.
if (!is_array($contexts)) {
if (is_object($contexts) && $contexts instanceof ctools_context) {
$contexts = array($contexts->id => $contexts);
@@ -177,11 +359,12 @@ class ctools_context_required {
}
}
- // If we had requested a $context but that $context doesn't exist
- // in our context list, there is a good chance that what happened
- // is our context IDs changed. See if there's another context
- // that satisfies our requirements.
- if (!$this->skip_name_check && !empty($context) && !isset($contexts[$context])) {
+ // If we had requested a $context but that $context doesn't exist in our
+ // context list, there is a good chance that what happened is the context
+ // IDs changed. Check for another context that satisfies our requirements.
+ if (!$this->skip_name_check
+ && !empty($context) && !isset($contexts[$context])
+ ) {
$choices = $this->filter($contexts);
// If we got a hit, take the first one that matches.
@@ -196,6 +379,7 @@ class ctools_context_required {
}
return $contexts[$context];
}
+
}
/**
@@ -203,28 +387,73 @@ class ctools_context_required {
* can produce empty contexts to use as placeholders.
*/
class ctools_context_optional extends ctools_context_required {
- var $required = FALSE;
- function ctools_context_optional() {
- $args = func_get_args();
- call_user_func_array(array($this, 'ctools_context_required'), $args);
+
+ /**
+ * {@inheritdoc}
+ */
+ public $required = FALSE;
+
+ /**
+ * Add the 'empty' context to the existing set.
+ *
+ * @param array &$contexts
+ * An array of ctools_context objects.
+ */
+ public function add_empty(&$contexts) {
+ $context = new ctools_context('any');
+ $context->title = t('No context');
+ $context->identifier = t('No context');
+ $contexts['empty'] = $context;
}
/**
- * Add the 'empty' context which is possible for optional
+ * Filter the contexts to determine which apply in the current environment.
+ *
+ * As for ctools_context_required, but we add the empty context to those
+ * passed in so the check is optional (i.e. if nothing else matches, the
+ * empty context will, and so there will always be at least one matched).
+ *
+ * @param array $contexts
+ * An array of ctools_context objects (or something which will cast to an
+ * array of them). The contexts to apply the filter on.
+ *
+ * @return array
+ * An array of context objects, keyed with the same keys used for $contexts,
+ * which pass the filter.
+ *
+ * @see ctools_context::is_type()
*/
- function add_empty(&$contexts) {
- $context = new ctools_context('any');
- $context->title = t('No context');
- $context->identifier = t('No context');
- $contexts = array_merge(array('empty' => $context), $contexts);
- }
-
- function filter($contexts) {
+ public function filter($contexts) {
+ /**
+ * @todo We are assuming here that $contexts is actually an array, whereas
+ * ctools_context_required::filter only requires $contexts is convertible
+ * to an array.
+ */
$this->add_empty($contexts);
return parent::filter($contexts);
}
- function select($contexts, $context) {
+ /**
+ * Select and return one context from the list of applicable contexts.
+ *
+ * Fundamentally, this returns $contexts[$context] or the empty context if
+ * that does not exist.
+ *
+ * @param array $contexts
+ * The applicable contexts to check.
+ * @param string $context
+ * The context id to check for.
+ *
+ * @return bool|ctools_context
+ * The matching ctools_context, or False if no such context was found.
+ *
+ * @see ctools_context_required::select()
+ */
+ public function select($contexts, $context) {
+ /**
+ * @todo We are assuming here that $contexts is actually an array, whereas
+ * ctools_context_required::select permits ctools_context objects as well.
+ */
$this->add_empty($contexts);
if (empty($context)) {
return $contexts['empty'];
@@ -234,11 +463,12 @@ class ctools_context_optional extends ctools_context_required {
// Don't flip out if it can't find the context; this is optional, put
// in an empty.
- if ($result == FALSE) {
+ if ($result === FALSE) {
$result = $contexts['empty'];
}
return $result;
}
+
}
/**
@@ -253,20 +483,20 @@ class ctools_context_optional extends ctools_context_required {
* Since multiple contexts can be required, this function will accept either
* an array of all required contexts, or just a single required context object.
*
- * @param $contexts
+ * @param array $contexts
* A keyed array of all available contexts.
- * @param $required
- * A ctools_context_required or ctools_context_optional object, or an array
- * of such objects.
+ * @param array|ctools_context_required|ctools_context_optional $required
+ * A *_required or *_optional object, or an array of such objects, which
+ * define the selection condition.
*
- * @return
+ * @return array
* A keyed array of contexts that match the filter.
*/
function ctools_context_filter($contexts, $required) {
if (is_array($required)) {
$result = array();
- foreach ($required as $r) {
- $result = array_merge($result, _ctools_context_filter($contexts, $r));
+ foreach ($required as $item) {
+ $result = array_merge($result, _ctools_context_filter($contexts, $item));
}
return $result;
}
@@ -274,6 +504,21 @@ function ctools_context_filter($contexts, $required) {
return _ctools_context_filter($contexts, $required);
}
+/**
+ * Helper function for ctools_context_filter().
+ *
+ * Used to transform the required context during the merge into the final array.
+ *
+ * @internal This function DOES NOT form part of the CTools API.
+ *
+ * @param array $contexts
+ * A keyed array of all available contexts.
+ * @param ctools_context_required|ctools_context_optional $required
+ * A ctools_context_required or ctools_context_optional object, although if
+ * given something else will return an empty array.
+ *
+ * @return array
+ */
function _ctools_context_filter($contexts, $required) {
$result = array();
@@ -293,12 +538,17 @@ function _ctools_context_filter($contexts, $required) {
* If an array of required contexts is provided, one selector will be
* provided for each context.
*
- * @param $contexts
+ * @param array $contexts
* A keyed array of all available contexts.
- * @param $required
+ * @param array|ctools_context_required|ctools_context_optional $required
* The required context object or array of objects.
+ * @param array|string $default
+ * The default value for the select object, suitable for a #default_value
+ * render key. Where $required is an array, this is an array keyed by the
+ * same key values as $required for all keys where an empty string is not a
+ * suitable default. Otherwise it is just the default value.
*
- * @return
+ * @return array
* A form element, or NULL if there are no contexts that satisfy the
* requirements.
*/
@@ -306,8 +556,10 @@ function ctools_context_selector($contexts, $required, $default) {
if (is_array($required)) {
$result = array('#tree' => TRUE);
$count = 1;
- foreach ($required as $id => $r) {
- $result[] = _ctools_context_selector($contexts, $r, isset($default[$id]) ? $default[$id] : '', $count++);
+ foreach ($required as $id => $item) {
+ $result[] = _ctools_context_selector(
+ $contexts, $item, isset($default[$id]) ? $default[$id] : '', $count++
+ );
}
return $result;
}
@@ -315,6 +567,27 @@ function ctools_context_selector($contexts, $required, $default) {
return _ctools_context_selector($contexts, $required, $default);
}
+/**
+ * Helper function for ctools_context_selector().
+ *
+ * @internal This function DOES NOT form part of the CTools API. Use the API
+ * function ctools_context_selector() instead.
+ *
+ * @param array $contexts
+ * A keyed array of all available contexts.
+ * @param ctools_context_required|ctools_context_optional $required
+ * The required context object.
+ * @param $default
+ * The default value for the select object, suitable for a #default_value
+ * render key.
+ * @param int $num
+ * If supplied and non-zero, the title of the select form element will be
+ * "Context $num", otherwise it will be "Context".
+ *
+ * @return array
+ * A form element, or NULL if there are no contexts that satisfy the
+ * requirements.
+ */
function _ctools_context_selector($contexts, $required, $default, $num = 0) {
$filtered = ctools_context_filter($contexts, $required);
$count = count($filtered);
@@ -358,8 +631,8 @@ function _ctools_context_selector($contexts, $required, $default, $num = 0) {
* @param $required
* The required context object or array of objects.
*
- * @return
- * TRUE if there are enough contexts, FALSE if there are not.
+ * @return bool
+ * True if there are enough contexts, otherwise False.
*/
function ctools_context_match_requirements($contexts, $required) {
if (!is_array($required)) {
@@ -392,8 +665,13 @@ function ctools_context_match_requirements($contexts, $required) {
* A keyed array of all available contexts.
* @param $required
* The required context object or array of objects.
+ * @param array|string $default
+ * The default value for the select object, suitable for a #default_value
+ * render key. Where $required is an array, this is an array keyed by the
+ * same key values as $required for all keys where an empty string is not a
+ * suitable default. Otherwise it is just the default value.
*
- * @return
+ * @return array
* A form element, or NULL if there are no contexts that satisfy the
* requirements.
*/
@@ -401,8 +679,11 @@ function ctools_context_converter_selector($contexts, $required, $default) {
if (is_array($required)) {
$result = array('#tree' => TRUE);
$count = 1;
- foreach ($required as $id => $r) {
- $result[] = _ctools_context_converter_selector($contexts, $r, isset($default[$id]) ? $default[$id] : '', $count++);
+ foreach ($required as $id => $dependency) {
+ $default_id = isset($default[$id]) ? $default[$id] : '';
+ $result[] = _ctools_context_converter_selector(
+ $contexts, $dependency, $default_id, $count++
+ );
}
return $result;
}
@@ -410,17 +691,36 @@ function ctools_context_converter_selector($contexts, $required, $default) {
return _ctools_context_converter_selector($contexts, $required, $default);
}
+/**
+ * Helper function for ctools_context_converter_selector().
+ *
+ * @internal This function DOES NOT form part of the CTools API. Use the API
+ * function ctools_context_converter_selector() instead.
+ *
+ * @param array $contexts
+ * A keyed array of all available contexts.
+ * @param ctools_context $required
+ * The required context object.
+ * @param $default
+ * The default value for the select object, suitable for a #default_value
+ * render key.
+ * @param int $num
+ * If supplied and non-zero, the title of the select form element will be
+ * "Context $num", otherwise it will be "Context".
+ *
+ * @return array|null
+ * A form element, or NULL if there are no contexts that satisfy the
+ * requirements.
+ */
function _ctools_context_converter_selector($contexts, $required, $default, $num = 0) {
$filtered = ctools_context_filter($contexts, $required);
$count = count($filtered);
- $form = array();
-
if ($count > 1) {
// If there's more than one to choose from, create a select widget.
$options = array();
foreach ($filtered as $cid => $context) {
- if ($context->type == 'any') {
+ if ($context->type === 'any') {
$options[''] = t('No context');
continue;
}
@@ -450,10 +750,22 @@ function _ctools_context_converter_selector($contexts, $required, $default, $num
'#default_value' => $default,
);
}
+ else {
+ // Not enough choices to need a selector, so don't make one.
+ return NULL;
+ }
}
/**
* Get a list of converters available for a given context.
+ *
+ * @param string $cid
+ * A context ID.
+ * @param ctools_context $context
+ * The context for which converters are needed.
+ *
+ * @return array
+ * A list of context converters.
*/
function ctools_context_get_converters($cid, $context) {
if (empty($context->plugin)) {
@@ -465,6 +777,17 @@ function ctools_context_get_converters($cid, $context) {
/**
* Get a list of converters available for a given context.
+ *
+ * @internal This function DOES NOT form part of the CTools API. Use the API
+ * function ctools_context_get_converters() instead.
+ *
+ * @param string $id
+ * A context ID.
+ * @param string $plugin_name
+ * The name of the context plugin.
+ *
+ * @return array
+ * A list of context converters.
*/
function _ctools_context_get_converters($id, $plugin_name) {
$plugin = ctools_get_context($plugin_name);
@@ -476,7 +799,7 @@ function _ctools_context_get_converters($id, $plugin_name) {
if (is_array($plugin['convert list'])) {
$converters = $plugin['convert list'];
}
- else if ($function = ctools_plugin_get_function($plugin, 'convert list')) {
+ elseif ($function = ctools_plugin_get_function($plugin, 'convert list')) {
$converters = (array) $function($plugin);
}
@@ -496,7 +819,13 @@ function _ctools_context_get_converters($id, $plugin_name) {
}
/**
- * Get a list of all contexts + converters available.
+ * Get a list of all contexts converters available.
+ *
+ * For all contexts returned by ctools_get_contexts(), return the converter
+ * for all contexts that have one.
+ *
+ * @return array
+ * A list of context converters, keyed by the title of the converter.
*/
function ctools_context_get_all_converters() {
$contexts = ctools_get_contexts();
@@ -516,21 +845,24 @@ function ctools_context_get_all_converters() {
/**
* Let the context convert an argument based upon the converter that was given.
*
- * @param $context
- * The context object
- * @param $converter
- * The converter to use, which should be a string provided by the converter list.
- * @param $converter_options
- * A n array of options to pass on to the generation function. For contexts
+ * @param ctools_context $context
+ * The context object.
+ * @param string $converter
+ * The type of converter to use, which should be a string provided by the
+ * converter list function.
+ * @param array $converter_options
+ * An array of options to pass on to the generation function. For contexts
* that use token module, of particular use is 'sanitize' => FALSE which can
* get raw tokens. This should ONLY be used in values that will later be
* treated as unsafe user input since these values are by themselves unsafe.
* It is particularly useful to get raw values from Field API.
+ *
+ * @return string|null
*/
function ctools_context_convert_context($context, $converter, $converter_options = array()) {
// Contexts without plugins might be optional placeholders.
if (empty($context->plugin)) {
- return;
+ return NULL;
}
$value = $context->argument;
@@ -551,22 +883,35 @@ function ctools_context_convert_context($context, $converter, $converter_options
* Choose a context or contexts based upon the selection made via
* ctools_context_filter.
*
- * @param $contexts
- * A keyed array of all available contexts
- * @param $required
- * The required context object provided by the plugin
+ * @param array $contexts
+ * A keyed array of all available contexts.
+ * @param array|ctools_context_required $required
+ * The required context object(s) provided by the plugin.
* @param $context
- * The selection made using ctools_context_selector
+ * The selection made using ctools_context_selector().
+ *
+ * @return ctools_context|array|false
+ * Returns FALSE if $required is not an object, or array of objects, or
+ * the value of $required->select() for the context, or an array of those (if
+ * passed an array in $required).
*/
function ctools_context_select($contexts, $required, $context) {
if (is_array($required)) {
+
+ /**
+ * @var array $required
+ * Array of required context objects.
+ * @var ctools_context_required $item
+ * A required context object.
+ */
$result = array();
- foreach ($required as $id => $r) {
+ foreach ($required as $id => $item) {
+ // @todo What's the difference between the following and "empty($item)" ?
if (empty($required[$id])) {
continue;
}
- if (($result[] = _ctools_context_select($contexts, $r, $context[$id])) === FALSE) {
+ if (($result[] = _ctools_context_select($contexts, $item, $context[$id])) === FALSE) {
return FALSE;
}
}
@@ -576,6 +921,22 @@ function ctools_context_select($contexts, $required, $context) {
return _ctools_context_select($contexts, $required, $context);
}
+/**
+ * Helper function for calling the required context object's selection function.
+ *
+ * This function DOES NOT form part of the CTools API.
+ *
+ * @param array $contexts
+ * A keyed array of all available contexts.
+ * @param ctools_context_required $required
+ * The required context object provided by the plugin.
+ * @param $context
+ * The selection made using ctools_context_selector().
+ *
+ * @return ctools_context|bool
+ * FALSE if the $required is not an object. A ctools_context object if one
+ * matched.
+ */
function _ctools_context_select($contexts, $required, $context) {
if (!is_object($required)) {
return FALSE;
@@ -587,16 +948,14 @@ function _ctools_context_select($contexts, $required, $context) {
/**
* Create a new context object.
*
- * @param $type
+ * @param string $type
* The type of context to create; this loads a plugin.
- * @param $data
+ * @param mixed $data
* The data to put into the context.
- * @param $empty
- * Whether or not this context is specifically empty.
* @param $conf
* A configuration structure if this context was created via UI.
*
- * @return
+ * @return ctools_context
* A $context or NULL if one could not be created.
*/
function ctools_context_create($type, $data = NULL, $conf = FALSE) {
@@ -619,7 +978,7 @@ function ctools_context_create($type, $data = NULL, $conf = FALSE) {
* @param $type
* The type of context to create; this loads a plugin.
*
- * @return
+ * @return ctools_context
* A $context or NULL if one could not be created.
*/
function ctools_context_create_empty($type) {
@@ -636,8 +995,21 @@ function ctools_context_create_empty($type) {
/**
* Perform keyword and context substitutions.
+ *
+ * @param string $string
+ * The string in which to replace keywords.
+ * @param array $keywords
+ * Array of keyword-replacement pairs.
+ * @param array $contexts
+ *
+ * @param array $converter_options
+ * Options to pass on to ctools_context_convert_context(), defaults to an
+ * empty array.
+ *
+ * @return string
+ * The returned string, with substitutions performed.
*/
-function ctools_context_keyword_substitute($string, $keywords, $contexts, $converter_options = array()) {
+function ctools_context_keyword_substitute($string, $keywords, $contexts, array $converter_options = array()) {
// Ensure a default keyword exists:
$keywords['%%'] = '%';
@@ -660,7 +1032,7 @@ function ctools_context_keyword_substitute($string, $keywords, $contexts, $conve
// If the keyword is already set by something passed in, don't try to
// overwrite it.
- if (!empty($keywords['%' . $keyword])) {
+ if (array_key_exists('%' . $keyword, $keywords)) {
continue;
}
@@ -680,14 +1052,21 @@ function ctools_context_keyword_substitute($string, $keywords, $contexts, $conve
}
}
- if (empty($context_keywords[$context]) || !empty($context_keywords[$context]->empty)) {
- $keywords['%' . $keyword] = '';
- }
- else if (!empty($converter)) {
- $keywords['%' . $keyword] = ctools_context_convert_context($context_keywords[$context], $converter, $converter_options);
+ if (!isset($context_keywords[$context])) {
+ $keywords['%' . $keyword] = '%' . $keyword;
}
else {
- $keywords['%' . $keyword] = $context_keywords[$keyword]->title;
+ if (empty($context_keywords[$context]) || !empty($context_keywords[$context]->empty)) {
+ $keywords['%' . $keyword] = '';
+ }
+ else {
+ if (!empty($converter)) {
+ $keywords['%' . $keyword] = ctools_context_convert_context($context_keywords[$context], $converter, $converter_options);
+ }
+ else {
+ $keywords['%' . $keyword] = $context_keywords[$keyword]->title;
+ }
+ }
}
}
}
@@ -695,18 +1074,22 @@ function ctools_context_keyword_substitute($string, $keywords, $contexts, $conve
}
/**
- * Determine a unique context ID for a context
+ * Determine a unique context ID for a context.
*
* Often contexts of many different types will be placed into a list. This
* ensures that even though contexts of multiple types may share IDs, they
* are unique in the final list.
*/
function ctools_context_id($context, $type = 'context') {
- if (!$context['id']) {
+ // If not set, FALSE or empty.
+ if (!isset($context['id']) || !$context['id']) {
$context['id'] = 1;
}
- return $type . '_' . $context['name'] . '_' . $context['id'];
+ // @todo is '' the appropriate default value?
+ $name = isset($context['name']) ? $context['name'] : '';
+
+ return $type . '_' . $name . '_' . $context['id'];
}
/**
@@ -714,42 +1097,46 @@ function ctools_context_id($context, $type = 'context') {
*
* This finds the next id available for the named object.
*
- * @param $objects
- * A list of context descriptor objects, i.e, arguments, relationships, contexts, etc.
- * @param $name
+ * @param array $objects
+ * A list of context descriptor objects, i.e, arguments, relationships,
+ * contexts, etc.
+ * @param string $name
* The name being used.
+ *
+ * @return int
+ * The next integer id available.
*/
function ctools_context_next_id($objects, $name) {
$id = 0;
- // Figure out which instance of this argument we're creating
+ // Figure out which instance of this argument we're creating.
if (!$objects) {
return $id + 1;
}
foreach ($objects as $object) {
- if (isset($object['name']) && $object['name'] == $name) {
- if ($object['id'] > $id) {
+ if (isset($object['name']) && $object['name'] === $name) {
+ if (isset($object['id']) && $object['id'] > $id) {
$id = $object['id'];
}
+ // @todo If obj has no 'id', should we increment local id? $id = $id + 1;
}
}
return $id + 1;
}
-
// ---------------------------------------------------------------------------
// Functions related to contexts from arguments.
-
/**
- * Fetch metadata on a specific argument plugin.
+ * Fetch metadata for a specific argument plugin.
*
* @param $argument
* Name of an argument plugin.
*
- * @return
+ * @return array
* An array with information about the requested argument plugin.
*/
+
function ctools_get_argument($argument) {
ctools_include('plugins');
return ctools_get_plugins('ctools', 'arguments', $argument);
@@ -758,7 +1145,7 @@ function ctools_get_argument($argument) {
/**
* Fetch metadata for all argument plugins.
*
- * @return
+ * @return array
* An array of arrays with information about all available argument plugins.
*/
function ctools_get_arguments() {
@@ -778,22 +1165,23 @@ function ctools_get_arguments() {
* - keyword: The keyword used for this argument for substitutions.
*
* @param $arg
- * The actual argument received. This is expected to be a string from a URL but
- * this does not have to be the only source of arguments.
+ * The actual argument received. This is expected to be a string from a URL
+ * but this does not have to be the only source of arguments.
* @param $empty
* If true, the $arg will not be used to load the context. Instead, an empty
* placeholder context will be loaded.
*
- * @return
+ * @return ctools_context
* A context object if one can be loaded.
*/
function ctools_context_get_context_from_argument($argument, $arg, $empty = FALSE) {
ctools_include('plugins');
if (empty($argument['name'])) {
- return;
+ return NULL;
}
- if ($function = ctools_plugin_load_function('ctools', 'arguments', $argument['name'], 'context')) {
+ $function = ctools_plugin_load_function('ctools', 'arguments', $argument['name'], 'context');
+ if ($function) {
// Backward compatibility: Merge old style settings into new style:
if (!empty($argument['settings'])) {
$argument += $argument['settings'];
@@ -805,8 +1193,8 @@ function ctools_context_get_context_from_argument($argument, $arg, $empty = FALS
if (is_object($context)) {
$context->identifier = $argument['identifier'];
$context->page_title = isset($argument['title']) ? $argument['title'] : '';
- $context->keyword = $argument['keyword'];
- $context->id = ctools_context_id($argument, 'argument');
+ $context->keyword = $argument['keyword'];
+ $context->id = ctools_context_id($argument, 'argument');
$context->original_argument = $arg;
if (!empty($context->empty)) {
@@ -822,6 +1210,12 @@ function ctools_context_get_context_from_argument($argument, $arg, $empty = FALS
/**
* Retrieve a list of empty contexts for all arguments.
+ *
+ * @param array $arguments
+ *
+ * @return array
+ *
+ * @see ctools_context_get_context_from_arguments()
*/
function ctools_context_get_placeholders_from_argument($arguments) {
$contexts = array();
@@ -837,19 +1231,21 @@ function ctools_context_get_placeholders_from_argument($arguments) {
/**
* Load the contexts for a given list of arguments.
*
- * @param $arguments
+ * @param array $arguments
* The array of argument definitions.
- * @param &$contexts
+ * @param array &$contexts
* The array of existing contexts. New contexts will be added to this array.
- * @param $args
+ * @param array $args
* The arguments to load.
*
- * @return
- * FALSE if an argument wants to 404.
+ * @return bool
+ * TRUE if all is well, FALSE if an argument wants to 404.
+ *
+ * @see ctools_context_get_context_from_argument()
*/
function ctools_context_get_context_from_arguments($arguments, &$contexts, $args) {
foreach ($arguments as $argument) {
- // pull the argument off the list.
+ // Pull the argument off the list.
$arg = array_shift($args);
$id = ctools_context_id($argument, 'argument');
@@ -864,7 +1260,10 @@ function ctools_context_get_context_from_arguments($arguments, &$contexts, $args
$context = $contexts[$id];
}
- if ((empty($context) || empty($context->data)) && !empty($argument['default']) && $argument['default'] == '404') {
+ if ((empty($context) || empty($context->data))
+ && !empty($argument['default'])
+ && $argument['default'] === '404'
+ ) {
return FALSE;
}
}
@@ -873,16 +1272,18 @@ function ctools_context_get_context_from_arguments($arguments, &$contexts, $args
// ---------------------------------------------------------------------------
// Functions related to contexts from relationships.
-
/**
- * Fetch metadata on a specific relationship plugin.
+ * Fetch plugin metadata for a specific relationship plugin.
*
- * @param $content type
+ * @param $relationship
* Name of a panel content type.
*
- * @return
+ * @return array
* An array with information about the requested relationship.
+ *
+ * @see ctools_get_relationships()
*/
+
function ctools_get_relationship($relationship) {
ctools_include('plugins');
return ctools_get_plugins('ctools', 'relationships', $relationship);
@@ -891,8 +1292,10 @@ function ctools_get_relationship($relationship) {
/**
* Fetch metadata for all relationship plugins.
*
- * @return
+ * @return array
* An array of arrays with information about all available relationships.
+ *
+ * @see ctools_get_relationship()
*/
function ctools_get_relationships() {
ctools_include('plugins');
@@ -900,8 +1303,9 @@ function ctools_get_relationships() {
}
/**
+ * Return a context from a relationship.
*
- * @param $relationship
+ * @param array $relationship
* The configuration of a relationship. It must contain the following data:
* - name: The name of the relationship plugin being used.
* - relationship_settings: The configuration based upon the plugin forms.
@@ -909,18 +1313,21 @@ function ctools_get_relationships() {
* defined by the UI.
* - keyword: The keyword used for this relationship for substitutions.
*
- * @param $source_context
+ * @param ctools_context $source_context
* The context this relationship is based upon.
- *
- * @param $placeholders
+ * @param bool $placeholders
* If TRUE, placeholders are acceptable.
*
- * @return
- * A context object if one can be loaded.
+ * @return ctools_context|null
+ * A context object if one can be loaded, otherwise NULL.
+ *
+ * @see ctools_context_get_relevant_relationships()
+ * @see ctools_context_get_context_from_relationships()
*/
function ctools_context_get_context_from_relationship($relationship, $source_context, $placeholders = FALSE) {
ctools_include('plugins');
- if ($function = ctools_plugin_load_function('ctools', 'relationships', $relationship['name'], 'context')) {
+ $function = ctools_plugin_load_function('ctools', 'relationships', $relationship['name'], 'context');
+ if ($function) {
// Backward compatibility: Merge old style settings into new style:
if (!empty($relationship['relationship_settings'])) {
$relationship += $relationship['relationship_settings'];
@@ -931,7 +1338,7 @@ function ctools_context_get_context_from_relationship($relationship, $source_con
if ($context) {
$context->identifier = $relationship['identifier'];
$context->page_title = isset($relationship['title']) ? $relationship['title'] : '';
- $context->keyword = $relationship['keyword'];
+ $context->keyword = $relationship['keyword'];
if (!empty($context->empty)) {
$context->placeholder = array(
'type' => 'relationship',
@@ -941,6 +1348,7 @@ function ctools_context_get_context_from_relationship($relationship, $source_con
return $context;
}
}
+ return NULL;
}
/**
@@ -954,18 +1362,24 @@ function ctools_context_get_context_from_relationship($relationship, $source_con
* @param $contexts
* An array of contexts used to figure out which relationships are relevant.
*
- * @return
+ * @return array
* An array of relationship keys that are relevant for the given set of
* contexts.
+ *
+ * @see ctools_context_filter()
+ * @see ctools_context_get_context_from_relationship()
+ * @see ctools_context_get_context_from_relationships()
*/
function ctools_context_get_relevant_relationships($contexts) {
$relevant = array();
$relationships = ctools_get_relationships();
- // Go through each relationship
+ // Go through each relationship.
foreach ($relationships as $rid => $relationship) {
// For each relationship, see if there is a context that satisfies it.
- if (empty($relationship['no ui']) && ctools_context_filter($contexts, $relationship['required context'])) {
+ if (empty($relationship['no ui'])
+ && ctools_context_filter($contexts, $relationship['required context'])
+ ) {
$relevant[$rid] = $relationship['title'];
}
}
@@ -974,7 +1388,7 @@ function ctools_context_get_relevant_relationships($contexts) {
}
/**
- * Fetch all active relationships
+ * Fetch all active relationships.
*
* @param $relationships
* An keyed array of relationship data including:
@@ -989,10 +1403,11 @@ function ctools_context_get_relevant_relationships($contexts) {
*
* @param $placeholders
* If TRUE, placeholders are acceptable.
+ *
+ * @see ctools_context_get_context_from_relationship()
+ * @see ctools_context_get_relevant_relationships()
*/
function ctools_context_get_context_from_relationships($relationships, &$contexts, $placeholders = FALSE) {
- $return = array();
-
foreach ($relationships as $rdata) {
if (!isset($rdata['context'])) {
continue;
@@ -1023,16 +1438,16 @@ function ctools_context_get_context_from_relationships($relationships, &$context
// ---------------------------------------------------------------------------
// Functions related to loading contexts from simple context definitions.
-
/**
* Fetch metadata on a specific context plugin.
*
- * @param $context
+ * @param string $context
* Name of a context.
*
- * @return
+ * @return array
* An array with information about the requested panel context.
*/
+
function ctools_get_context($context) {
static $gate = array();
ctools_include('plugins');
@@ -1056,7 +1471,7 @@ function ctools_get_context($context) {
/**
* Fetch metadata for all context plugins.
*
- * @return
+ * @return array
* An array of arrays with information about all available panel contexts.
*/
function ctools_get_contexts() {
@@ -1065,27 +1480,38 @@ function ctools_get_contexts() {
}
/**
+ * Return a context object from a context definition array.
*
- * @param $context
+ * The input $context contains the information needed to identify and invoke
+ * the context plugin and create the plugin context from that.
+ *
+ * @param array $context
* The configuration of a context. It must contain the following data:
* - name: The name of the context plugin being used.
* - context_settings: The configuration based upon the plugin forms.
* - identifier: The human readable identifier for this context, usually
* defined by the UI.
* - keyword: The keyword used for this context for substitutions.
- * @param $type
+ * @param string $type
* This is either 'context' which indicates the context will be loaded
- * from data in the settings, or 'required_context' which means the
+ * from data in the settings, or 'requiredcontext' which means the
* context must be acquired from an external source. This is the method
* used to pass pure contexts from one system to another.
+ * @param mixed $argument
+ * Optional information passed to the plugin context via the arg defined in
+ * the plugin's "placeholder name" field.
*
- * @return
+ * @return ctools_context|null
* A context object if one can be loaded.
+ *
+ * @see ctools_get_context()
+ * @see ctools_plugin_get_function()
*/
function ctools_context_get_context_from_context($context, $type = 'context', $argument = NULL) {
ctools_include('plugins');
$plugin = ctools_get_context($context['name']);
- if ($function = ctools_plugin_get_function($plugin, 'context')) {
+ $function = ctools_plugin_get_function($plugin, 'context');
+ if ($function) {
// Backward compatibility: Merge old style settings into new style:
if (!empty($context['context_settings'])) {
$context += $context['context_settings'];
@@ -1100,7 +1526,7 @@ function ctools_context_get_context_from_context($context, $type = 'context', $a
if ($return) {
$return->identifier = $context['identifier'];
$return->page_title = isset($context['title']) ? $context['title'] : '';
- $return->keyword = $context['keyword'];
+ $return->keyword = $context['keyword'];
if (!empty($context->empty)) {
$context->placeholder = array(
@@ -1112,6 +1538,8 @@ function ctools_context_get_context_from_context($context, $type = 'context', $a
return $return;
}
}
+
+ return NULL;
}
/**
@@ -1125,7 +1553,10 @@ function ctools_context_get_context_from_context($context, $type = 'context', $a
* Either 'context' or 'requiredcontext', which indicates whether the contexts
* are loaded from internal data or copied from an external source.
* @param $placeholders
- * If true, placeholders are acceptable.
+ * If True, placeholders are acceptable.
+ *
+ * @return array
+ * Array of contexts, keyed by context ID.
*/
function ctools_context_get_context_from_contexts($contexts, $type = 'context', $placeholders = FALSE) {
$return = array();
@@ -1144,17 +1575,20 @@ function ctools_context_get_context_from_contexts($contexts, $type = 'context',
/**
* Match up external contexts to our required contexts.
*
- * This function is used to create a list of contexts with proper
- * IDs based upon a list of required contexts.
+ * This function is used to create a list of contexts with proper IDs based
+ * upon a list of required contexts.
*
- * These contexts passed in should match the numeric positions of the
- * required contexts. The caller must ensure this has already happened
- * correctly as this function will not detect errors here.
+ * These contexts passed in should match the numeric positions of the required
+ * contexts. The caller must ensure this has already happened correctly as this
+ * function will not detect errors here.
*
* @param $required
* A list of required contexts as defined by the UI.
* @param $contexts
* A list of matching contexts as passed in from the calling system.
+ *
+ * @return array
+ * Array of contexts, keyed by context ID.
*/
function ctools_context_match_required_contexts($required, $contexts) {
$return = array();
@@ -1163,10 +1597,10 @@ function ctools_context_match_required_contexts($required, $contexts) {
}
foreach ($required as $r) {
- $context = clone(array_shift($contexts));
+ $context = clone array_shift($contexts);
$context->identifier = $r['identifier'];
$context->page_title = isset($r['title']) ? $r['title'] : '';
- $context->keyword = $r['keyword'];
+ $context->keyword = $r['keyword'];
$return[ctools_context_id($r, 'requiredcontext')] = $context;
}
@@ -1178,31 +1612,35 @@ function ctools_context_match_required_contexts($required, $contexts) {
*
* Not all of the types need to be supported by this object.
*
- * This function is not used to load contexts from external data, but may
- * be used to load internal contexts and relationships. Otherwise it can also
- * be used to generate a full set of placeholders for UI purposes.
+ * This function is not used to load contexts from external data, but may be
+ * used to load internal contexts and relationships. Otherwise it can also be
+ * used to generate a full set of placeholders for UI purposes.
*
- * @param $object
+ * @param object $object
* An object that contains some or all of the following variables:
*
- * - requiredcontexts: A list of UI configured contexts that are required
- * from an external source. Since these require external data, they will
- * only be added if $placeholders is set to TRUE, and empty contexts will
- * be created.
- * - arguments: A list of UI configured arguments that will create contexts.
- * Since these require external data, they will only be added if $placeholders
- * is set to TRUE.
- * - contexts: A list of UI configured contexts that have no external source,
- * and are essentially hardcoded. For example, these might configure a
- * particular node or a particular taxonomy term.
- * - relationships: A list of UI configured contexts to be derived from other
- * contexts that already exist from other sources. For example, these might
- * be used to get a user object from a node via the node author relationship.
- * @param $placeholders
- * If TRUE, this will generate placeholder objects for types this function
+ * - requiredcontexts: A list of UI configured contexts that are required
+ * from an external source. Since these require external data, they will
+ * only be added if $placeholders is set to TRUE, and empty contexts will
+ * be created.
+ * - arguments: A list of UI configured arguments that will create contexts.
+ * As these require external data, they will only be added if $placeholders
+ * is set to TRUE.
+ * - contexts: A list of UI configured contexts that have no external source,
+ * and are essentially hardcoded. For example, these might configure a
+ * particular node or a particular taxonomy term.
+ * - relationships: A list of UI configured contexts to be derived from other
+ * contexts that already exist from other sources. For example, these might
+ * be used to get a user object from a node via the node author
+ * relationship.
+ * @param bool $placeholders
+ * If True, this will generate placeholder objects for any types this function
* cannot load.
- * @param $contexts
+ * @param array $contexts
* An array of pre-existing contexts that will be part of the return value.
+ *
+ * @return array
+ * Merged output of all results of ctools_context_get_context_from_contexts().
*/
function ctools_context_load_contexts($object, $placeholders = TRUE, $contexts = array()) {
if (!empty($object->base_contexts)) {
@@ -1226,7 +1664,7 @@ function ctools_context_load_contexts($object, $placeholders = TRUE, $contexts =
$contexts += ctools_context_get_context_from_contexts($object->contexts, 'context', $placeholders);
}
- // add contexts from relationships
+ // Add contexts from relationships.
if (!empty($object->relationships) && is_array($object->relationships)) {
ctools_context_get_context_from_relationships($object->relationships, $contexts, $placeholders);
}
@@ -1245,7 +1683,7 @@ function ctools_context_load_contexts($object, $placeholders = TRUE, $contexts =
function ctools_context_get_form($contexts) {
if (!empty($contexts)) {
foreach ($contexts as $id => $context) {
- // if a form shows its id as being a 'required context' that means the
+ // If a form shows its id as being a 'required context' that means the
// the context is external to this display and does not count.
if (!empty($context->form_id) && substr($id, 0, 15) != 'requiredcontext') {
return $context;
@@ -1264,7 +1702,7 @@ function ctools_context_get_form($contexts) {
* The arguments. These will be acquired from $form_state['values'] and the
* keys must match the context IDs.
*
- * @return
+ * @return array
* A new $contexts array containing the replaced contexts. Not all contexts
* may be replaced if, for example, an argument was unable to be converted
* into a context.
@@ -1283,12 +1721,14 @@ function ctools_context_replace_placeholders($contexts, $arguments) {
$new_context = ctools_context_get_context_from_relationship($relationship, $contexts[$relationship['context']]);
}
break;
+
case 'argument':
if (isset($arguments[$cid]) && $arguments[$cid] !== '') {
$argument = $context->placeholder['conf'];
$new_context = ctools_context_get_context_from_argument($argument, $arguments[$cid]);
}
break;
+
case 'context':
if (!empty($arguments[$cid])) {
$context_info = $context->placeholder['conf'];
@@ -1337,32 +1777,37 @@ function ctools_context_replace_form(&$form, $contexts) {
if (is_array($plugin['placeholder form'])) {
$form[$cid] = $plugin['placeholder form'];
}
- else if (function_exists($plugin['placeholder form'])) {
- $widget = $plugin['placeholder form']($info);
- if ($widget) {
- $form[$cid] = $widget;
+ else {
+ if (function_exists($plugin['placeholder form'])) {
+ $widget = $plugin['placeholder form']($info);
+ if ($widget) {
+ $form[$cid] = $widget;
+ }
}
}
if (!empty($form[$cid])) {
- $form[$cid]['#title'] = t('@identifier (@keyword)', array('@keyword' => '%' . $context->keyword, '@identifier' => $context->identifier));
+ $form[$cid]['#title'] = t('@identifier (@keyword)', array(
+ '@keyword' => '%' . $context->keyword,
+ '@identifier' => $context->identifier,
+ ));
}
}
}
}
// ---------------------------------------------------------------------------
-// Functions related to loading access control plugins
-
+// Functions related to loading access control plugins.
/**
* Fetch metadata on a specific access control plugin.
*
* @param $name
* Name of a plugin.
*
- * @return
+ * @return array
* An array with information about the requested access control plugin.
*/
+
function ctools_get_access_plugin($name) {
ctools_include('plugins');
return ctools_get_plugins('ctools', 'access', $name);
@@ -1371,7 +1816,7 @@ function ctools_get_access_plugin($name) {
/**
* Fetch metadata for all access control plugins.
*
- * @return
+ * @return array
* An array of arrays with information about all available access control plugins.
*/
function ctools_get_access_plugins() {
@@ -1383,8 +1828,14 @@ function ctools_get_access_plugins() {
* Fetch a list of access plugins that are available for a given list of
* contexts.
*
- * if 'logged-in-user' is not in the list of contexts, it will be added as
+ * If 'logged-in-user' is not in the list of contexts, it will be added as
* this is required.
+ *
+ * @param array $contexts
+ * Array of ctools_context objects with which to select access plugins.
+ *
+ * @return array
+ * Array of applicable access plugins. Can be empty.
*/
function ctools_get_relevant_access_plugins($contexts) {
if (!isset($contexts['logged-in-user'])) {
@@ -1394,7 +1845,9 @@ function ctools_get_relevant_access_plugins($contexts) {
$all_plugins = ctools_get_access_plugins();
$plugins = array();
foreach ($all_plugins as $id => $plugin) {
- if (!empty($plugin['required context']) && !ctools_context_match_requirements($contexts, $plugin['required context'])) {
+ if (!empty($plugin['required context'])
+ && !ctools_context_match_requirements($contexts, $plugin['required context'])
+ ) {
continue;
}
$plugins[$id] = $plugin;
@@ -1409,14 +1862,17 @@ function ctools_get_relevant_access_plugins($contexts) {
function ctools_access_get_loggedin_context() {
$context = ctools_context_create('entity:user', array('type' => 'current'), TRUE);
$context->identifier = t('Logged in user');
- $context->keyword = 'viewer';
- $context->id = 0;
+ $context->keyword = 'viewer';
+ $context->id = 0;
return $context;
}
/**
* Get a summary of an access plugin's settings.
+ *
+ * @return string
+ * The summary text.
*/
function ctools_access_summary($plugin, $contexts, $test) {
if (!isset($contexts['logged-in-user'])) {
@@ -1426,8 +1882,9 @@ function ctools_access_summary($plugin, $contexts, $test) {
$description = '';
if ($function = ctools_plugin_get_function($plugin, 'summary')) {
$required_context = isset($plugin['required context']) ? $plugin['required context'] : array();
- $context = isset($test['context']) ? $test['context'] : array();
- $description = $function($test['settings'], ctools_context_select($contexts, $required_context, $context), $plugin);
+ $context = isset($test['context']) ? $test['context'] : array();
+ $selected_context = ctools_context_select($contexts, $required_context, $context);
+ $description = $function($test['settings'], $selected_context, $plugin);
}
if (!empty($test['not'])) {
@@ -1439,10 +1896,23 @@ function ctools_access_summary($plugin, $contexts, $test) {
/**
* Get a summary of a group of access plugin's settings.
+ *
+ * @param $access
+ * An array of settings theoretically set by the user, including the array
+ * of plugins to check:
+ * - 'plugins': the array of plugin metadata info to check
+ * - 'logic': (optional) either 'and' or 'or', indicating how to combine
+ * restrictions. Defaults to 'or'.
+ * @param array $contexts
+ * An array of zero or more contexts that may be used to determine if
+ * the user has access.
+ *
+ * @return string
+ * The summary text. Can be NULL if there are no plugins defined.
*/
function ctools_access_group_summary($access, $contexts) {
- if (empty($access['plugins'])) {
- return;
+ if (empty($access['plugins']) || !is_array($access['plugins'])) {
+ return NULL;
}
$descriptions = array();
@@ -1451,21 +1921,29 @@ function ctools_access_group_summary($access, $contexts) {
$descriptions[] = ctools_access_summary($plugin, $contexts, $test);
}
- $separator = (isset($access['logic']) && $access['logic'] == 'and') ? t(', and ') : t(', or ');
+ $separator =
+ (isset($access['logic']) && $access['logic'] === 'and')
+ ? t(', and ') : t(', or ');
return implode($separator, $descriptions);
}
/**
- * Determine if the current user has access via plugin.
+ * Determine if the current user has access via a plugin.
*
- * @param $settings
- * An array of settings theoretically set by the user.
- * @param $contexts
+ * @param array $settings
+ * An array of settings theoretically set by the user, including the array
+ * of plugins to check:
+ * - 'plugins': the array of plugin metadata info to check
+ * - 'logic': (optional) either 'and' or 'or', indicating how to combine
+ * restrictions. The 'or' case is not fully implemented and returns the
+ * input contexts unchanged.
+ *
+ * @param array $contexts
* An array of zero or more contexts that may be used to determine if
* the user has access.
*
- * @return
- * TRUE if access is granted, false if otherwise.
+ * @return bool
+ * TRUE if access is granted, FALSE if otherwise.
*/
function ctools_access($settings, $contexts = array()) {
if (empty($settings['plugins'])) {
@@ -1504,15 +1982,15 @@ function ctools_access($settings, $contexts = array()) {
// Pass if 'or' and this rule passed.
return TRUE;
}
- else if (!$pass && $settings['logic'] == 'and') {
- // Fail if 'and' and htis rule failed.
+ elseif (!$pass && $settings['logic'] == 'and') {
+ // Fail if 'and' and this rule failed.
return FALSE;
}
}
// Return TRUE if logic was and, meaning all rules passed.
// Return FALSE if logic was or, meaning no rule passed.
- return $settings['logic'] == 'and';
+ return ($settings['logic'] === 'and');
}
/**
@@ -1521,7 +1999,7 @@ function ctools_access($settings, $contexts = array()) {
* @param $plugin
* The access plugin being used.
*
- * @return
+ * @return array
* A default configured test that should be placed in $access['plugins'];
*/
function ctools_access_new_test($plugin) {
@@ -1543,7 +2021,6 @@ function ctools_access_new_test($plugin) {
}
}
-
$default = NULL;
if (isset($plugin['default'])) {
$default = $plugin['default'];
@@ -1557,7 +2034,7 @@ function ctools_access_new_test($plugin) {
if (is_array($default)) {
$test['settings'] = $default;
}
- else if (function_exists($default)) {
+ elseif (function_exists($default)) {
$test['settings'] = $default();
}
else {
@@ -1571,11 +2048,23 @@ function ctools_access_new_test($plugin) {
/**
* Apply restrictions to contexts based upon the access control configured.
*
- * These restrictions allow the UI to not show content that may not
- * be relevant to all types of a particular context.
+ * These restrictions allow the UI to not show content that may not be relevant
+ * to all types of a particular context.
+ *
+ * @param array $settings
+ * Array of keys specifying the settings:
+ * - 'plugins': the array of plugin metadata info to check. If not set, or
+ * not an array, the function returns with no action.
+ * - 'logic': (optional) either 'and' or 'or', indicating how to combine
+ * restrictions. Defaults to 'and'.
+ * The 'or' case is not fully implemented and returns with no action if
+ * there is more than one plugin.
+ *
+ * @param array $contexts
+ * Array of available contexts.
*/
function ctools_access_add_restrictions($settings, $contexts) {
- if (empty($settings['plugins'])) {
+ if (empty($settings['plugins']) || !is_array($settings['plugins'])) {
return;
}
@@ -1584,16 +2073,20 @@ function ctools_access_add_restrictions($settings, $contexts) {
}
// We're not going to try to figure out restrictions on the or.
- if ($settings['logic'] == 'or' && count($settings['plugins']) > 1) {
+ if ($settings['logic'] === 'or' && count($settings['plugins']) > 1) {
return;
}
foreach ($settings['plugins'] as $test) {
$plugin = ctools_get_access_plugin($test['name']);
- if ($plugin && $function = ctools_plugin_get_function($plugin, 'restrictions')) {
+ // $plugin is 'array()' on error.
+ if ($plugin
+ && $function = ctools_plugin_get_function($plugin, 'restrictions')
+ ) {
$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);
+
if ($contexts !== FALSE) {
$function($test['settings'], $contexts);
}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/context.menu.inc b/sites/all/modules/contrib/dev/ctools/includes/context.menu.inc
index ee227cb..798d167 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/context.menu.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/context.menu.inc
@@ -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',
diff --git a/sites/all/modules/contrib/dev/ctools/includes/context.theme.inc b/sites/all/modules/contrib/dev/ctools/includes/context.theme.inc
index 8f660b8..d0d866f 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/context.theme.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/context.theme.inc
@@ -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 .= '
';
}
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 .= '
';
@@ -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 .= '
';
@@ -341,4 +340,3 @@ function theme_ctools_context_list_no_table($vars) {
return $output;
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/includes/css.inc b/sites/all/modules/contrib/dev/ctools/includes/css.inc
index 9813a87..83fe1c3 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/css.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/css.inc
@@ -1,6 +1,6 @@
$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;
}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/dependent.inc b/sites/all/modules/contrib/dev/ctools/includes/dependent.inc
index 74de919..20c25de 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/dependent.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/dependent.inc
@@ -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;
diff --git a/sites/all/modules/contrib/dev/ctools/includes/dropbutton.theme.inc b/sites/all/modules/contrib/dev/ctools/includes/dropbutton.theme.inc
index fcdd5a3..4b95ef0 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/dropbutton.theme.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/dropbutton.theme.inc
@@ -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 .= '
';
- // 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 .= '
';
}
- // The button content
+ // The button content.
$output .= '
';
// 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 .= '
'; // ctools-content
- $output .= '
'; // ctools-dropbutton
+ $output .= ''; // ctools-content.
+ $output .= ''; // ctools-dropbutton.
return $output;
}
else {
return '';
}
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/includes/dropdown.theme.inc b/sites/all/modules/contrib/dev/ctools/includes/dropdown.theme.inc
index 7e748f5..b763687 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/dropdown.theme.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/dropdown.theme.inc
@@ -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 .= '
'; // dropdown
+ $output .= '';
+ $output .= '';
+ $output .= '';
+
return $output;
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/includes/entity-access.inc b/sites/all/modules/contrib/dev/ctools/includes/entity-access.inc
new file mode 100644
index 0000000..69f2c33
--- /dev/null
+++ b/sites/all/modules/contrib/dev/ctools/includes/entity-access.inc
@@ -0,0 +1,154 @@
+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;
+}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/export-ui.inc b/sites/all/modules/contrib/dev/ctools/includes/export-ui.inc
index 16e57d6..72e5a2f 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/export-ui.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/export-ui.inc
@@ -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);
diff --git a/sites/all/modules/contrib/dev/ctools/includes/export-ui.menu.inc b/sites/all/modules/contrib/dev/ctools/includes/export-ui.menu.inc
index d27bf15..0fda8c2 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/export-ui.menu.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/export-ui.menu.inc
@@ -1,5 +1,9 @@
array('handler'),
);
-}
\ No newline at end of file
+}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/export.inc b/sites/all/modules/contrib/dev/ctools/includes/export.inc
index 0b85c2e..d2fff2f 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/export.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/export.inc
@@ -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 {
@@ -902,7 +901,8 @@ function ctools_export_object($table, $object, $indent = '', $identifier = NULL,
$output = $indent . '$' . $identifier . ' = new ' . get_class($object) . "();\n";
if ($schema['export']['can disable']) {
- $output .= $indent . '$' . $identifier . '->disabled = FALSE; /* Edit this to true to make a default ' . $identifier . ' disabled initially */' . "\n";
+ $disabled = !isset($object->disabled) || $object->disabled != TRUE ? 'FALSE' : 'TRUE';
+ $output .= $indent . '$' . $identifier . '->disabled = ' . $disabled . '; /* Edit this to true to make a default ' . $identifier . ' disabled initially */' . "\n";
}
if (!empty($schema['export']['api']['current_version'])) {
$output .= $indent . '$' . $identifier . '->api_version = ' . $schema['export']['api']['current_version'] . ";\n";
@@ -958,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";
}
@@ -986,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);
}
@@ -998,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',
@@ -1106,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']}]);
}
@@ -1149,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 {
@@ -1179,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);
}
@@ -1227,7 +1227,7 @@ function ctools_export_default_to_hook_code($schema, $table, $names, $name) {
$output .= " \${$export['identifier']}s = array();\n\n";
foreach ($objects as $object) {
$output .= ctools_export_crud_export($table, $object, ' ');
- $output .= " \${$export['identifier']}s['" . check_plain($object->$export['key']) . "'] = \${$export['identifier']};\n\n";
+ $output .= " \${$export['identifier']}s['" . check_plain($object->{$export['key']}) . "'] = \${$export['identifier']};\n\n";
}
$output .= " return \${$export['identifier']}s;\n";
$output .= "}\n";
@@ -1235,6 +1235,7 @@ function ctools_export_default_to_hook_code($schema, $table, $names, $name) {
return $output;
}
+
/**
* Default function for listing bulk exportable objects.
*/
diff --git a/sites/all/modules/contrib/dev/ctools/includes/fields.inc b/sites/all/modules/contrib/dev/ctools/includes/fields.inc
index f379f5e..0d3256f 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/fields.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/fields.inc
@@ -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)'));
@@ -137,7 +139,7 @@ function ctools_fields_get_field_formatter_settings_form($field, $formatter_type
*/
function ctools_fields_get_field_formatter_info($fields) {
$info = array();
- $field_info = module_invoke_all('field_formatter_info');
+ $field_info = field_info_formatter_types();
foreach ($fields as $field) {
foreach ($field_info as $format_name => $formatter_info) {
if (in_array($field['type'], $formatter_info['field types'])) {
@@ -145,7 +147,6 @@ function ctools_fields_get_field_formatter_info($fields) {
}
}
}
- drupal_alter('field_formatter_info', $info);
return $info;
}
@@ -209,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])
@@ -225,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.
*
@@ -341,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'];
diff --git a/sites/all/modules/contrib/dev/ctools/includes/jump-menu.inc b/sites/all/modules/contrib/dev/ctools/includes/jump-menu.inc
index a5f99aa..e2ae1cf 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/jump-menu.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/jump-menu.inc
@@ -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.
- *
*/
/**
@@ -51,7 +50,7 @@ function ctools_jump_menu($form, &$form_state, $select, $options = array()) {
'hide' => TRUE,
);
- ctools_add_js('jump-menu');
+ $form['#attached']['js'][] = ctools_attach_js('jump-menu');
if (!empty($options['choose'])) {
$select = array('' => $options['choose']) + $select;
@@ -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 {
diff --git a/sites/all/modules/contrib/dev/ctools/includes/language.inc b/sites/all/modules/contrib/dev/ctools/includes/language.inc
index 9a7850b..a850670 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/language.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/language.inc
@@ -1,5 +1,9 @@
t("Current user's language"),
@@ -41,4 +44,4 @@ function ctools_language_list_all() {
);
$languages = array_merge($languages, ctools_language_list());
return $languages;
-}
\ No newline at end of file
+}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/math-expr.inc b/sites/all/modules/contrib/dev/ctools/includes/math-expr.inc
index beffb93..d82281e 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/math-expr.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/math-expr.inc
@@ -99,7 +99,10 @@ class ctools_math_expr {
'sqrt','abs','ln','log',
'time', 'ceil', 'floor', 'min', 'max', 'round');
- function ctools_math_expr() {
+ /**
+ * ctools_math_expr constructor.
+ */
+ function __construct() {
// make the variables a little more accurate
$this->v['pi'] = pi();
$this->v['e'] = exp(1);
@@ -271,7 +274,7 @@ class ctools_math_expr {
} elseif (in_array($op, $ops) and !$expecting_op) {
return $this->trigger("unexpected operator '$op'");
} else { // I don't even want to know what you did to get here
- return $this->trigger("an unexpected error occured");
+ return $this->trigger("an unexpected error occurred");
}
if ($index == strlen($expr)) {
if (in_array($op, $ops)) { // did we end with an operator? bad.
diff --git a/sites/all/modules/contrib/dev/ctools/includes/modal.inc b/sites/all/modules/contrib/dev/ctools/includes/modal.inc
index ee969ab..18b216f 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/modal.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/modal.inc
@@ -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'),
)),
),
);
@@ -66,6 +66,7 @@ function ctools_modal_add_js() {
drupal_add_library('system', 'jquery.form');
drupal_add_library('system', 'drupal.progress');
drupal_add_library('system', 'drupal.ajax');
+ drupal_add_library('system', 'ui');
ctools_add_js('modal');
ctools_add_css('modal');
@@ -84,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;
}
}
@@ -94,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;
}
}
@@ -139,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(
@@ -188,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
@@ -221,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;
diff --git a/sites/all/modules/contrib/dev/ctools/includes/object-cache.inc b/sites/all/modules/contrib/dev/ctools/includes/object-cache.inc
index 29225b0..ef52f9a 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/object-cache.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/object-cache.inc
@@ -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, '<')
diff --git a/sites/all/modules/contrib/dev/ctools/includes/page-wizard.inc b/sites/all/modules/contrib/dev/ctools/includes/page-wizard.inc
index a211361..9690aae 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/page-wizard.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/page-wizard.inc
@@ -1,5 +1,9 @@
plugin = $plugin;
if ($function = ctools_plugin_get_function($plugin, 'default cache')) {
$function($cache);
diff --git a/sites/all/modules/contrib/dev/ctools/includes/plugins-admin.inc b/sites/all/modules/contrib/dev/ctools/includes/plugins-admin.inc
index d4ead0a..c11fcfd 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/plugins-admin.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/plugins-admin.inc
@@ -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();
}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/plugins.inc b/sites/all/modules/contrib/dev/ctools/includes/plugins.inc
index eadb68f..7b53ae1 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/plugins.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/plugins.inc
@@ -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'];
}
@@ -79,7 +78,9 @@ function ctools_plugin_api_info($owner, $api, $minimum_version, $current_version
}
// Only process if version is between minimum and current, inclusive.
- if (version_compare($version, $minimum_version, '>=') && version_compare($version, $current_version, '<=')) {
+ if (($version == $minimum_version) || ($version == $current_version)
+ || (version_compare($version, $minimum_version, '>=')
+ && version_compare($version, $current_version, '<='))) {
if (!isset($info['path'])) {
$info['path'] = drupal_get_path('module', $module);
}
@@ -97,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'] = '';
}
@@ -110,7 +111,7 @@ function ctools_plugin_api_info($owner, $api, $minimum_version, $current_version
}
// Allow other modules to hook in.
- drupal_alter($hook, $cache[$owner][$api]);
+ drupal_alter($hook, $cache[$owner][$api], $owner, $api);
}
return $cache[$owner][$api];
@@ -149,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 {
@@ -159,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;
@@ -182,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();
}
@@ -198,22 +199,22 @@ function ctools_plugin_api_get_hook($owner, $api) {
/**
* Fetch a group of plugins by name.
*
- * @param $module
- * The name of the module that utilizes this plugin system. It will be
- * used to call hook_ctools_plugin_$plugin() to get more data about the plugin.
- * @param $type
+ * @param string $module
+ * The name of the module that utilizes this plugin system. It will be used to
+ * get more data about the plugin as defined on hook_ctools_plugin_type().
+ * @param string $type
* The type identifier of the plugin.
- * @param $id
+ * @param string $id
* If specified, return only information about plugin with this identifier.
* The system will do its utmost to load only plugins with this id.
*
- * @return
- * An array of information arrays about the plugins received. The contents
- * of the array are specific to the plugin.
+ * @return array
+ * An array of information arrays about the plugins received. The contents of
+ * the array are specific to the plugin.
*/
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.
+ // lookups every time.
static $drupal_static_fast;
if (!isset($drupal_static_fast)) {
$drupal_static_fast['plugins'] = &drupal_static('ctools_plugins', array());
@@ -222,10 +223,14 @@ function ctools_get_plugins($module, $type, $id = NULL) {
$info = ctools_plugin_get_plugin_type_info();
- // Bail out noisily if an invalid module/type combination is requested.
if (!isset($info[$module][$type])) {
- watchdog('ctools', 'Invalid plugin module/type combination requested: module @module and type @type', array('@module' => $module, '@type' => $type), WATCHDOG_ERROR);
- return array();
+ // 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])) {
+ watchdog('ctools', 'Invalid plugin module/type combination requested: module @module and type @type', array('@module' => $module, '@type' => $type), WATCHDOG_ERROR);
+ return array();
+ }
}
// Make sure our plugins array is populated.
@@ -233,8 +238,8 @@ function ctools_get_plugins($module, $type, $id = NULL) {
$plugins[$module][$type] = array();
}
- // Attempt to shortcut this whole piece of code if we already have
- // the requested plugin:
+ // Attempt to shortcut this whole piece of code if we already have the
+ // requested plugin:
if ($id && array_key_exists($id, $plugins[$module][$type])) {
return $plugins[$module][$type][$id];
}
@@ -252,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.
@@ -269,8 +274,8 @@ function ctools_get_plugins($module, $type, $id = NULL) {
$plugins[$module][$type] = ctools_plugin_load_hooks($info[$module][$type]);
}
- // Then see if we should load all files. We only do this if we
- // want a list of all plugins or there was a cache miss.
+ // Then see if we should load all files. We only do this if we want a list of
+ // all plugins or there was a cache miss.
if (empty($setup[$module][$type]) && ($build_cache || !$id)) {
$setup[$module][$type] = TRUE;
$plugins[$module][$type] = array_merge($plugins[$module][$type], ctools_plugin_load_includes($info[$module][$type]));
@@ -293,9 +298,8 @@ 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 we were told earlier that this is cacheable and the cache was empty,
+ // give something back.
if ($build_cache) {
cache_set("plugins:$module:$type", $plugins[$module][$type], $info[$module][$type]['cache table']);
}
@@ -307,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.
@@ -413,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']])) {
@@ -460,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 {
-
- require_once DRUPAL_ROOT . '/' . $file->uri;
+ 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.
@@ -490,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);
@@ -510,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) {
@@ -536,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.
*/
@@ -550,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;
}
@@ -561,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);
}
@@ -581,7 +585,6 @@ function _ctools_list_themes() {
return $themes;
}
-
/**
* Find all the base themes for the specified theme.
*
@@ -597,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'];
@@ -627,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.
@@ -652,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)) {
@@ -735,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);
@@ -764,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.
*/
@@ -781,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'])) {
@@ -816,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.
*/
@@ -834,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) {
@@ -853,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'];
}
@@ -879,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) {
diff --git a/sites/all/modules/contrib/dev/ctools/includes/registry.inc b/sites/all/modules/contrib/dev/ctools/includes/registry.inc
index 9d4328e..7e517bb 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/registry.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/registry.inc
@@ -2,7 +2,6 @@
/**
* @file
- *
* Registry magic. In a separate file to minimize unnecessary code loading.
*/
diff --git a/sites/all/modules/contrib/dev/ctools/includes/stylizer.inc b/sites/all/modules/contrib/dev/ctools/includes/stylizer.inc
index 9fdc81d..488a7f3 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/stylizer.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/stylizer.inc
@@ -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;
}
@@ -500,7 +500,7 @@ class ctools_stylizer_image_processor {
$palette[$luminosity_input]['green'] = $green;
$palette[$luminosity_input]['blue'] = $blue;
- // Now we complete the palette, first we'll do it tothe black, and then to
+ // Now we complete the palette, first we'll do it to the black, and then to
// the white.
// From input to black
@@ -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 {
diff --git a/sites/all/modules/contrib/dev/ctools/includes/stylizer.theme.inc b/sites/all/modules/contrib/dev/ctools/includes/stylizer.theme.inc
index 85346c1..0ceedff 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/stylizer.theme.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/stylizer.theme.inc
@@ -25,4 +25,3 @@ function ctools_stylizer_theme(&$theme) {
'file' => 'includes/stylizer.inc',
);
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/includes/utility.inc b/sites/all/modules/contrib/dev/ctools/includes/utility.inc
index 82fc147..3c939a4 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/utility.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/utility.inc
@@ -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);
}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/uuid.inc b/sites/all/modules/contrib/dev/ctools/includes/uuid.inc
index b0567d3..f51838b 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/uuid.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/uuid.inc
@@ -9,7 +9,9 @@
/**
* Pattern for detecting a valid UUID.
*/
-define('UUID_PATTERN', '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}');
+if (!defined('UUID_PATTERN')) {
+ 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.
@@ -25,7 +27,8 @@ function _ctools_uuid_generate_com() {
* Generates an universally unique identifier using the PECL extension.
*/
function _ctools_uuid_generate_pecl() {
- return uuid_create(UUID_TYPE_DEFAULT);
+ $uuid_type = UUID_TYPE_DEFAULT;
+ return uuid_create($uuid_type);
}
/**
@@ -64,4 +67,5 @@ if (!function_exists('uuid_is_valid')) {
function uuid_is_valid($uuid) {
return preg_match('/^' . UUID_PATTERN . '$/', $uuid);
}
+
}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/views.inc b/sites/all/modules/contrib/dev/ctools/includes/views.inc
index 4ef6439..9c1ee6c 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/views.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/views.inc
@@ -1,5 +1,9 @@
$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;
}
}
diff --git a/sites/all/modules/contrib/dev/ctools/js/auto-submit.js b/sites/all/modules/contrib/dev/ctools/js/auto-submit.js
index a3e9aa4..b658577 100644
--- a/sites/all/modules/contrib/dev/ctools/js/auto-submit.js
+++ b/sites/all/modules/contrib/dev/ctools/js/auto-submit.js
@@ -36,9 +36,11 @@ Drupal.behaviors.CToolsAutoSubmit = {
attach: function(context) {
// 'this' references the form element
function triggerSubmit (e) {
- var $this = $(this);
- if (!$this.hasClass('ctools-ajaxing')) {
- $this.find('.ctools-auto-submit-click').click();
+ if ($.contains(document.body, this)) {
+ var $this = $(this);
+ if (!$this.hasClass('ctools-ajaxing')) {
+ $this.find('.ctools-auto-submit-click').click();
+ }
}
}
diff --git a/sites/all/modules/contrib/dev/ctools/js/dependent.js b/sites/all/modules/contrib/dev/ctools/js/dependent.js
index f74ec81..a60fc12 100644
--- a/sites/all/modules/contrib/dev/ctools/js/dependent.js
+++ b/sites/all/modules/contrib/dev/ctools/js/dependent.js
@@ -97,7 +97,13 @@
else {
switch ($(trigger).attr('type')) {
case 'checkbox':
- var val = $(trigger).attr('checked') ? true : false;
+ // **This check determines if using a jQuery version 1.7 or newer which requires the use of the prop function instead of the attr function when not called on an attribute
+ if ($().prop) {
+ var val = $(trigger).prop('checked') ? true : false;
+ }
+ else {
+ var val = $(trigger).attr('checked') ? true : false;
+ }
if (val) {
$(trigger).siblings('label').removeClass('hidden-options').addClass('expanded-options');
@@ -148,34 +154,41 @@
len++;
}
- var object = $('#' + id + '-wrapper');
- if (!object.size()) {
- // Some elements can't use the parent() method or they can
- // damage things. They are guaranteed to have wrappers but
- // only if dependent.inc provided them. This check prevents
- // problems when multiple AJAX calls cause settings to build
- // up.
- var $original = $('#' + id);
- if ($original.is('fieldset') || $original.is('textarea')) {
- continue;
- }
-
- object = $('#' + id).parent();
+ var $original = $('#' + id);
+ if ($original.is('fieldset') || $original.is('textarea')) {
+ continue;
}
+ var object = $original.parent();
+
if (Drupal.settings.CTools.dependent[id].type == 'disable') {
if (Drupal.settings.CTools.dependent[id].num <= len) {
// Show if the element if criteria is matched
- object.attr('disabled', false);
- object.addClass('dependent-options');
- object.children().attr('disabled', false);
+ // **This check determines if using a jQuery version 1.7 or newer which requires the use of the prop function instead of the attr function when not called on an attribute
+ if (typeof $().prop == 'function') {
+ object.prop('disabled', false);
+ object.addClass('dependent-options');
+ object.children().prop('disabled', false);
+ }
+ else {
+ object.attr('disabled', false);
+ object.addClass('dependent-options');
+ object.children().attr('disabled', false);
+ }
}
else {
// Otherwise hide. Use css rather than hide() because hide()
// does not work if the item is already hidden, for example,
// in a collapsed fieldset.
- object.attr('disabled', true);
- object.children().attr('disabled', true);
+ // **This check determines if using a jQuery version 1.7 or newer which requires the use of the prop function instead of the attr function when not called on an attribute
+ if (typeof $().prop == 'function') {
+ object.prop('disabled', true);
+ object.children().prop('disabled', true);
+ }
+ else {
+ object.attr('disabled', true);
+ object.children().attr('disabled', true);
+ }
}
}
else {
diff --git a/sites/all/modules/contrib/dev/ctools/js/modal.js b/sites/all/modules/contrib/dev/ctools/js/modal.js
index 37908cf..ec7b02a 100644
--- a/sites/all/modules/contrib/dev/ctools/js/modal.js
+++ b/sites/all/modules/contrib/dev/ctools/js/modal.js
@@ -48,7 +48,8 @@
modalOptions: {
opacity: .55,
background: '#fff'
- }
+ },
+ modalClass: 'default'
};
var settings = {};
@@ -97,8 +98,8 @@
resize();
$('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));
+ Drupal.CTools.Modal.modalContent(Drupal.CTools.Modal.modal, settings.modalOptions, settings.animation, settings.animationSpeed, settings.modalClass);
+ $('#modalContent .modal-content').html(Drupal.theme(settings.throbberTheme)).addClass('ctools-modal-loading');
// Position autocomplete results based on the scroll position of the modal.
$('#modalContent .modal-content').delegate('input.form-autocomplete', 'keyup', function() {
@@ -120,18 +121,18 @@
*/
Drupal.theme.prototype.CToolsModalDialog = function () {
var html = ''
- html += '
';
return html;
}
@@ -141,11 +142,11 @@
*/
Drupal.theme.prototype.CToolsModalThrobber = function () {
var html = '';
- html += '
';
- html += '
';
- html += Drupal.CTools.Modal.currentSettings.throbber;
- html += '
';
+ html += '
';
+ html += '
';
+ html += Drupal.CTools.Modal.currentSettings.throbber;
html += '
';
+ html += '
';
return html;
};
@@ -264,7 +265,10 @@
}
// An empty event means we were triggered via .click() and
// in jquery 1.4 this won't trigger a submit.
- if (event.bubbles == undefined) {
+ // We also have to check jQuery version to prevent
+ // IE8 + jQuery 1.4.4 to break on other events
+ // bound to the submit button.
+ if (jQuery.fn.jquery.substr(0, 3) === '1.4' && typeof event.bubbles === "undefined") {
$(this.form).trigger('submit');
return false;
}
@@ -298,7 +302,18 @@
// Attach behaviors within a modal dialog.
var settings = response.settings || ajax.settings || Drupal.settings;
- Drupal.attachBehaviors('#modalContent', settings);
+ Drupal.attachBehaviors($('#modalContent'), settings);
+
+ if ($('#modal-content').hasClass('ctools-modal-loading')) {
+ $('#modal-content').removeClass('ctools-modal-loading');
+ }
+ else {
+ // If the modal was already shown, and we are simply replacing its
+ // content, then focus on the first focusable element in the modal.
+ // (When first showing the modal, focus will be placed on the close
+ // button by the show() function called above.)
+ $('#modal-content :focusable:first').focus();
+ }
}
/**
@@ -349,8 +364,9 @@
* @param css obj of css attributes
* @param animation (fadeIn, slideDown, show)
* @param speed (valid animation speeds slow, medium, fast or # in ms)
+ * @param modalClass class added to div#modalContent
*/
- Drupal.CTools.Modal.modalContent = function(content, css, animation, speed) {
+ Drupal.CTools.Modal.modalContent = function(content, css, animation, speed, modalClass) {
// If our animation isn't set, make it just show/pop
if (!animation) {
animation = 'show';
@@ -362,7 +378,7 @@
}
}
- if (!speed) {
+ if (!speed && 0 !== speed) {
speed = 'fast';
}
@@ -402,9 +418,56 @@
if( docHeight < winHeight ) docHeight = winHeight;
// Create our divs
- $('body').append('
' + $(content).html() + '
');
+ $('body').append('
' + $(content).html() + '
');
- // Keyboard and focus event handler ensures focus stays on modal elements only
+ // Get a list of the tabbable elements in the modal content.
+ var getTabbableElements = function () {
+ var tabbableElements = $('#modalContent :tabbable'),
+ radioButtons = tabbableElements.filter('input[type="radio"]');
+
+ // The list of tabbable elements from jQuery is *almost* right. The
+ // exception is with groups of radio buttons. The list from jQuery will
+ // include all radio buttons, when in fact, only the selected radio button
+ // is tabbable, and if no radio buttons in a group are selected, then only
+ // the first is tabbable.
+ if (radioButtons.length > 0) {
+ // First, build up an index of which groups have an item selected or not.
+ var anySelected = {};
+ radioButtons.each(function () {
+ var name = this.name;
+
+ if (typeof anySelected[name] === 'undefined') {
+ anySelected[name] = radioButtons.filter('input[name="' + name + '"]:checked').length !== 0;
+ }
+ });
+
+ // Next filter out the radio buttons that aren't really tabbable.
+ var found = {};
+ tabbableElements = tabbableElements.filter(function () {
+ var keep = true;
+
+ if (this.type == 'radio') {
+ if (anySelected[this.name]) {
+ // Only keep the selected one.
+ keep = this.checked;
+ }
+ else {
+ // Only keep the first one.
+ if (found[this.name]) {
+ keep = false;
+ }
+ found[this.name] = true;
+ }
+ }
+
+ return keep;
+ });
+ }
+
+ return tabbableElements.get();
+ };
+
+ // Keyboard and focus event handler ensures only modal elements gain focus.
modalEventHandler = function( event ) {
target = null;
if ( event ) { //Mozilla
@@ -428,7 +491,7 @@
return true;
}
else {
- $('#modalContent').focus();
+ getTabbableElements()[0].focus();
}
event.preventDefault();
@@ -436,16 +499,70 @@
$('body').bind( 'focus', modalEventHandler );
$('body').bind( 'keypress', modalEventHandler );
+ // Keypress handler Ensures you can only TAB to elements within the modal.
+ // Based on the psuedo-code from WAI-ARIA 1.0 Authoring Practices section
+ // 3.3.1 "Trapping Focus".
+ modalTabTrapHandler = function (evt) {
+ // We only care about the TAB key.
+ if (evt.which != 9) {
+ return true;
+ }
+
+ var tabbableElements = getTabbableElements(),
+ firstTabbableElement = tabbableElements[0],
+ lastTabbableElement = tabbableElements[tabbableElements.length - 1],
+ singleTabbableElement = firstTabbableElement == lastTabbableElement,
+ node = evt.target;
+
+ // If this is the first element and the user wants to go backwards, then
+ // jump to the last element.
+ if (node == firstTabbableElement && evt.shiftKey) {
+ if (!singleTabbableElement) {
+ lastTabbableElement.focus();
+ }
+ return false;
+ }
+ // If this is the last element and the user wants to go forwards, then
+ // jump to the first element.
+ else if (node == lastTabbableElement && !evt.shiftKey) {
+ if (!singleTabbableElement) {
+ firstTabbableElement.focus();
+ }
+ return false;
+ }
+ // If this element isn't in the dialog at all, then jump to the first
+ // or last element to get the user into the game.
+ else if ($.inArray(node, tabbableElements) == -1) {
+ // Make sure the node isn't in another modal (ie. WYSIWYG modal).
+ var parents = $(node).parents().get();
+ for (var i = 0; i < parents.length; ++i) {
+ var position = $(parents[i]).css('position');
+ if (position == 'absolute' || position == 'fixed') {
+ return true;
+ }
+ }
+
+ if (evt.shiftKey) {
+ lastTabbableElement.focus();
+ }
+ else {
+ firstTabbableElement.focus();
+ }
+ }
+ };
+ $('body').bind('keydown', modalTabTrapHandler);
+
// Create our content div, get the dimensions, and hide it
var modalContent = $('#modalContent').css('top','-1000px');
- var mdcTop = wt + ( winHeight / 2 ) - ( modalContent.outerHeight() / 2);
+ var $modalHeader = modalContent.find('.modal-header');
+ var mdcTop = wt + Math.max((winHeight / 2) - (modalContent.outerHeight() / 2), 0);
var mdcLeft = ( winWidth / 2 ) - ( modalContent.outerWidth() / 2);
$('#modalBackdrop').css(css).css('top', 0).css('height', docHeight + 'px').css('width', docWidth + 'px').show();
modalContent.css({top: mdcTop + 'px', left: mdcLeft + 'px'}).hide()[animation](speed);
// Bind a click for closing the modalContent
modalContentClose = function(){close(); return false;};
- $('.close').bind('click', modalContentClose);
+ $('.close', $modalHeader).bind('click', modalContentClose);
// Bind a keypress on escape for closing the modalContent
modalEventEscapeCloseHandler = function(event) {
@@ -457,35 +574,57 @@
$(document).bind('keydown', modalEventEscapeCloseHandler);
+ // Per WAI-ARIA 1.0 Authoring Practices, initial focus should be on the
+ // close button, but we should save the original focus to restore it after
+ // the dialog is closed.
+ var oldFocus = document.activeElement;
+ $('.close', $modalHeader).focus();
+
// Close the open modal content and backdrop
function close() {
// Unbind the events
$(window).unbind('resize', modalContentResize);
$('body').unbind( 'focus', modalEventHandler);
$('body').unbind( 'keypress', modalEventHandler );
- $('.close').unbind('click', modalContentClose);
- $('body').unbind('keypress', modalEventEscapeCloseHandler);
+ $('body').unbind( 'keydown', modalTabTrapHandler );
+ $('.close', $modalHeader).unbind('click', modalContentClose);
+ $(document).unbind('keydown', modalEventEscapeCloseHandler);
$(document).trigger('CToolsDetachBehaviors', $('#modalContent'));
- // Set our animation parameters and use them
- if ( animation == 'fadeIn' ) animation = 'fadeOut';
- if ( animation == 'slideDown' ) animation = 'slideUp';
- if ( animation == 'show' ) animation = 'hide';
+ // Closing animation.
+ switch (animation) {
+ case 'fadeIn':
+ modalContent.fadeOut(speed, modalContentRemove);
+ break;
- // Close the content
- modalContent.hide()[animation](speed);
+ case 'slideDown':
+ modalContent.slideUp(speed, modalContentRemove);
+ break;
- // Remove the content
+ case 'show':
+ modalContent.hide(speed, modalContentRemove);
+ break;
+ }
+ }
+
+ // Remove the content.
+ modalContentRemove = function () {
$('#modalContent').remove();
$('#modalBackdrop').remove();
+
+ // Restore focus to where it was before opening the dialog.
+ $(oldFocus).focus();
};
- // Move and resize the modalBackdrop and modalContent on resize of the window
- modalContentResize = function(){
+ // Move and resize the modalBackdrop and modalContent on window resize.
+ modalContentResize = function () {
+ // Reset the backdrop height/width to get accurate document size.
+ $('#modalBackdrop').css('height', '').css('width', '');
- // position code lifted from http://www.quirksmode.org/viewport/compatibility.html
+ // Position code lifted from:
+ // http://www.quirksmode.org/viewport/compatibility.html
if (self.pageYOffset) { // all except Explorer
- var wt = self.pageYOffset;
+ 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
@@ -501,7 +640,7 @@
// Get where we should move content to
var modalContent = $('#modalContent');
- var mdcTop = wt + ( winHeight / 2 ) - ( modalContent.outerHeight() / 2);
+ var mdcTop = wt + Math.max((winHeight / 2) - (modalContent.outerHeight() / 2), 0);
var mdcLeft = ( winWidth / 2 ) - ( modalContent.outerWidth() / 2);
// Apply the changes
@@ -509,8 +648,6 @@
modalContent.css('top', mdcTop + 'px').css('left', mdcLeft + 'px').show();
};
$(window).bind('resize', modalContentResize);
-
- $('#modalContent').focus();
};
/**
@@ -533,8 +670,12 @@
$(window).unbind('resize', modalContentResize);
$('body').unbind('focus', modalEventHandler);
$('body').unbind('keypress', modalEventHandler);
- $('.close').unbind('click', modalContentClose);
- $(document).trigger('CToolsDetachBehaviors', $('#modalContent'));
+ $('body').unbind( 'keydown', modalTabTrapHandler );
+ var $modalContent = $('#modalContent');
+ var $modalHeader = $modalContent.find('.modal-header');
+ $('.close', $modalHeader).unbind('click', modalContentClose);
+ $('body').unbind('keypress', modalEventEscapeCloseHandler);
+ $(document).trigger('CToolsDetachBehaviors', $modalContent);
// jQuery magic loop through the instances and run the animations or removal.
content.each(function(){
diff --git a/sites/all/modules/contrib/dev/ctools/js/states-show.js b/sites/all/modules/contrib/dev/ctools/js/states-show.js
new file mode 100644
index 0000000..88df584
--- /dev/null
+++ b/sites/all/modules/contrib/dev/ctools/js/states-show.js
@@ -0,0 +1,43 @@
+/**
+ * @file
+ * Custom state for handling visibility
+ */
+
+/**
+ * Add a new state to Drupal #states. We use this to toggle element-invisible
+ * to show/hidden #states elements. This allows elements to be visible to
+ * screen readers.
+ *
+ * To use:
+ * $form['my_form_field'] = array(
+ * ..
+ * // Only show this field if 'some_other_field' is checked.
+ * '#states => array(
+ * 'show' => array(
+ * 'some-other-field' => array('checked' => TRUE),
+ * ),
+ * ),
+ * ..
+ * // Required to load the 'show' state handler.
+ * '#attached' => array(
+ * 'js' => array(ctools_attach_js('states-show')),
+ * ),
+ * );
+ */
+
+(function ($) {
+ 'use strict';
+
+ Drupal.states.State.aliases.hidden = '!show';
+
+ // Show/hide form items by toggling the 'element-invisible' class. This is a
+ // more accessible option than the core 'visible' state.
+ $(document).bind('state:show', function(e) {
+ if (e.trigger) {
+ var element = $(e.target).closest('.form-item, .form-submit, .form-wrapper');
+ element.toggle(e.value);
+ e.value === true ? element.removeClass('element-invisible') : element.addClass('element-invisible');
+ }
+ });
+
+})(jQuery);
diff --git a/sites/all/modules/contrib/dev/ctools/js/stylizer.js b/sites/all/modules/contrib/dev/ctools/js/stylizer.js
index 16d6c49..12ab720 100644
--- a/sites/all/modules/contrib/dev/ctools/js/stylizer.js
+++ b/sites/all/modules/contrib/dev/ctools/js/stylizer.js
@@ -5,7 +5,7 @@
Drupal.CTools.Stylizer.addFarbtastic = function(context) {
// This behavior attaches by ID, so is only valid once on a page.
- if ($('ctools_stylizer_color_scheme_form .color-form.Stylizer-processed').size()) {
+ if ($('#ctools_stylizer_color_scheme_form .color-form.Stylizer-processed').size()) {
return;
}
diff --git a/sites/all/modules/contrib/dev/ctools/page_manager/css/page-manager.css b/sites/all/modules/contrib/dev/ctools/page_manager/css/page-manager.css
index 1a7dd5e..5abe39e 100644
--- a/sites/all/modules/contrib/dev/ctools/page_manager/css/page-manager.css
+++ b/sites/all/modules/contrib/dev/ctools/page_manager/css/page-manager.css
@@ -100,7 +100,7 @@ body form#page-manager-list-pages-form {
#page-manager-edit .page-manager-edit-operations li {
list-style: none;
- background: #F6F6F6;
+ background: #f6f6f6;
border-top: 1px solid #aaa;
border-left: 1px solid #aaa;
border-right: 1px solid #aaa;
@@ -111,7 +111,7 @@ body form#page-manager-list-pages-form {
#page-manager-edit .page-manager-edit-operations li.active,
#page-manager-edit .page-manager-edit-operations li.active-group .page-manager-group-title {
- background: #FFFFFF url(../images/arrow-active.png) no-repeat scroll right center;
+ background: #ffffff url(../images/arrow-active.png) no-repeat scroll right center;
}
#page-manager-edit .page-manager-edit-operations li.changed,
@@ -123,7 +123,7 @@ body form#page-manager-list-pages-form {
/** provide a reset for non active stray paths */
#page-manager-edit .page-manager-edit-operations li.active-group li.not-active .page-manager-group-title,
#page-manager-edit .page-manager-edit-operations li.changed-group li.not-changed .page-manager-group-title {
- background: #F6F6F6;
+ background: #f6f6f6;
}
#page-manager-edit .page-manager-edit-operations li.active {
@@ -132,7 +132,7 @@ body form#page-manager-list-pages-form {
#page-manager-edit .page-manager-edit-operations li.active a,
#page-manager-edit .page-manager-edit-operations li.active a:hover {
- background: #FFFFFF url(../images/arrow-active.png) no-repeat scroll right center;
+ background: #ffffff url(../images/arrow-active.png) no-repeat scroll right center;
color: #000000;
font-weight: bold;
}
@@ -271,8 +271,8 @@ body form#page-manager-list-pages-form {
#page-manager-edit .actions li a {
display: block;
padding: 0.2em 0.5em;
- color:#0062A0;
- background-color: #F6F6F6;
+ color: #0062a0;
+ background-color: #f6f6f6;
}
#page-manager-edit .page-manager-changed {
diff --git a/sites/all/modules/contrib/dev/ctools/page_manager/help/getting-started.html b/sites/all/modules/contrib/dev/ctools/page_manager/help/getting-started.html
index 4e4f24a..6a75a37 100644
--- a/sites/all/modules/contrib/dev/ctools/page_manager/help/getting-started.html
+++ b/sites/all/modules/contrib/dev/ctools/page_manager/help/getting-started.html
@@ -4,7 +4,7 @@ Note: this page is currently very preliminary. Please visit ' . $task['name'] . '__',
+ '#field_prefix' => '' . $form_state['task_name'] . '__',
'#field_suffix' => '',
);
}
@@ -1466,7 +1466,7 @@ function page_manager_handler_add_form($form, $form_state, $features = array())
* 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;
+ $name = $form_state['task_name'] . '__' . $name;
return count(ctools_export_load_object('page_manager_handlers', 'names', array($name)));
}
@@ -1542,25 +1542,42 @@ function page_manager_handler_import_submit(&$form, &$form_state) {
* Rearrange the order of variants.
*/
function page_manager_handler_rearrange($form, &$form_state) {
+ ctools_include('context-task-handler');
$page = $form_state['page'];
$form['handlers'] = array('#tree' => TRUE);
+ // Get the number of variants to be displayed in order to set the delta
+ // to the proper value. This fixes problems in previous versions with sorting
+ // large numbers of variants.
+ $delta = count($page->handler_info)/2 + 1;
+
foreach ($page->handler_info as $id => $info) {
if ($info['changed'] & PAGE_MANAGER_CHANGED_DELETED) {
continue;
}
$handler = $page->handlers[$id];
$plugin = page_manager_get_task_handler($handler->handler);
-
+ $object = ctools_context_handler_get_task_object($page->task, $page->subtask, $handler);
+ $display = new stdClass();
+ $display->context = ctools_context_load_contexts($object, TRUE);
+ $content = page_manager_get_handler_title($plugin, $handler, $page->task, $page->subtask_id);
+ $access = ctools_access_group_summary(!empty($handler->conf['access']) ? $handler->conf['access'] : array(), $display->context);
+ if ($access) {
+ $access = t('This panel will be selected if @conditions.', array('@conditions' => $access));
+ }
+ else {
+ $access = t('This panel will always be selected.');
+ }
+ $content .= '
\ No newline at end of file
+
diff --git a/sites/all/modules/contrib/dev/ctools/page_manager/theme/page_manager.theme.inc b/sites/all/modules/contrib/dev/ctools/page_manager/theme/page_manager.theme.inc
index 6435d1c..3df55a8 100644
--- a/sites/all/modules/contrib/dev/ctools/page_manager/theme/page_manager.theme.inc
+++ b/sites/all/modules/contrib/dev/ctools/page_manager/theme/page_manager.theme.inc
@@ -27,10 +27,10 @@ function template_preprocess_page_manager_edit_page(&$vars) {
$vars['locked'] = theme('page_manager_lock', array('page' => $page));
$vars['changed'] = theme('page_manager_changed', array('text' => t('Locked'), 'description' => t('This page is being edited by another user and you cannot make changes to it.')));
}
- else if (!empty($page->new)) {
+ elseif (!empty($page->new)) {
$vars['changed'] = theme('page_manager_changed', array('text' => t('New'), 'description' => t('This page is newly created and has not yet been saved to the database. It will not be available until you save it.')));
}
- else if (!empty($page->changed)) {
+ elseif (!empty($page->changed)) {
$vars['changed'] = theme('page_manager_changed', array('text' => t('Changed'), 'description' => t('This page has been modified, but these modifications are not yet live. While modifying this page, it is locked from modification by other users.')));
}
@@ -49,9 +49,9 @@ function template_preprocess_page_manager_edit_page(&$vars) {
*/
function theme_page_manager_handler_rearrange($vars) {
$form = &$vars['form'];
- // Assemble the data for a table from everything in $form['handlers']
+ // Assemble the data for a table from everything in $form['handlers'].
foreach (element_children($form['handlers']) as $id) {
- // provide a reference shortcut.
+ // Provide a reference shortcut.
$element = &$form['handlers'][$id];
if (isset($element['title'])) {
$row = array();
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/compare_users.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/compare_users.inc
index c271ff4..e0a7f1b 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/compare_users.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/compare_users.inc
@@ -2,7 +2,7 @@
/**
* @file
- * Ctools access plugin to provide access/visiblity if two user contexts are equal.
+ * CTools access plugin to provide access/visiblity if two user contexts are equal.
*/
/**
@@ -20,12 +20,12 @@ $plugin = array(
'summary' => 'ctools_compare_users_ctools_access_summary',
'required context' => array(
new ctools_context_required(t('First User'), 'user'),
- new ctools_context_required(t("Second User"), 'user')
+ new ctools_context_required(t("Second User"), 'user'),
),
);
/**
- * Settings form for the 'by perm' access plugin
+ * Settings form for the 'by perm' access plugin.
*/
function ctools_compare_users_settings($form, &$form_state, $conf) {
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/context_exists.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/context_exists.inc
index aabc62d..e5d2b5e 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/context_exists.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/context_exists.inc
@@ -2,7 +2,7 @@
/**
* @file
- * Plugin to provide access control/visibility based on existence of a specified context
+ * Plugin to provide access control/visibility based on existence of a specified context.
*/
$plugin = array(
@@ -16,7 +16,7 @@ $plugin = array(
);
/**
- * Settings form
+ * Settings form.
*/
function ctools_context_exists_ctools_access_settings($form, &$form_state, $conf) {
$form['settings']['exists'] = array(
@@ -29,17 +29,17 @@ function ctools_context_exists_ctools_access_settings($form, &$form_state, $conf
}
/**
- * Check for access
+ * Check for access.
*/
function ctools_context_exists_ctools_access_check($conf, $context) {
- // xor returns false if the two bools are the same, and true if they are not.
+ // Xor returns false if the two bools are the same, and true if they are not.
// i.e, if we asked for context_exists and it does, return true.
// If we asked for context does not exist and it does, return false.
return (empty($context->data) xor !empty($conf['exists']));
}
/**
- * Provide a summary description based upon the specified context
+ * Provide a summary description based upon the specified context.
*/
function ctools_context_exists_ctools_access_summary($conf, $context) {
if (!empty($conf['exists'])) {
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/entity_bundle.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/entity_bundle.inc
index e07a048..fce3419 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/entity_bundle.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/entity_bundle.inc
@@ -43,7 +43,7 @@ function ctools_entity_bundle_ctools_access_get_children($plugin, $parent) {
}
/**
- * Settings form for the 'by entity_bundle' access plugin
+ * Settings form for the 'by entity_bundle' access plugin.
*/
function ctools_entity_bundle_ctools_access_settings($form, &$form_state, $conf) {
$plugin = $form_state['plugin'];
@@ -133,4 +133,3 @@ function ctools_entity_bundle_ctools_access_summary($conf, $context, $plugin) {
return format_plural(count($names), '@identifier is bundle "@types"', '@identifier bundle is one of "@types"', array('@types' => implode(', ', $names), '@identifier' => $context->identifier));
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/entity_field_value.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/entity_field_value.inc
index fa94a48..60d2c2e 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/entity_field_value.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/entity_field_value.inc
@@ -48,7 +48,7 @@ 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.
+ // Check that the entity, bundle and field arrays have a value.
// If not, load theme using machine names.
if (empty($entity)) {
$entity = entity_get_info($entity_type);
@@ -68,14 +68,14 @@ function _ctools_entity_field_value_ctools_access_get_child($plugin, $parent, $e
$plugin['description'] = t('Control access by @entity entity bundle.', array('@entity' => $entity_type));
$plugin['name'] = $parent . ':' . $entity_type . ':' . $bundle_type . ':' . $field_name;
$plugin['required context'] = new ctools_context_required(t(ucfirst($entity_type)), $entity_type, array(
- 'type' => $bundle_type,
- ));
+ 'type' => $bundle_type,
+ ));
return $plugin;
}
/**
- * Settings form for the 'by entity_bundle' access plugin
+ * Settings form for the 'by entity_bundle' access plugin.
*/
function ctools_entity_field_value_ctools_access_settings($form, &$form_state, $conf) {
$plugin = $form_state['plugin'];
@@ -88,7 +88,7 @@ function ctools_entity_field_value_ctools_access_settings($form, &$form_state, $
$columns[$column] = _field_sql_storage_columnname($field_name, $column);
}
ctools_include('fields');
- $entity = (object)array(
+ $entity = (object) array(
$entity_info['entity keys']['bundle'] => $bundle_type,
);
@@ -115,7 +115,7 @@ function ctools_entity_field_value_ctools_access_settings($form, &$form_state, $
$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.
+ // Weight is really not important once this is populated and will only interfere with the form layout.
foreach (element_children($form['settings']) as $element) {
unset($form['settings'][$element]['#weight']);
}
@@ -145,7 +145,8 @@ function ctools_entity_field_value_ctools_access_settings_submit($form, &$form_s
function _ctools_entity_field_value_get_proper_form_items($field, $form_items, $columns) {
$items = array();
- if (!is_array($form_items)) { // Single value item.
+ // Single value item.
+ if (!is_array($form_items)) {
foreach ($columns as $column) {
$items[0][$column] = $form_items;
}
@@ -175,7 +176,7 @@ function _ctools_entity_field_value_get_proper_form_items($field, $form_items, $
foreach ($columns as $column) {
if (isset($form_items[$column])) {
$has_columns = TRUE;
- $item[$column] = $form_items[$column];
+ $item[$column] = $form_items[$column];
}
else {
$item[$column] = '';
@@ -353,7 +354,7 @@ function ctools_entity_field_value_ctools_access_summary($conf, $context, $plugi
$display['type'] = 'entityreference_label';
break;
- default :
+ default:
// Use field instance formatter setting.
break;
}
@@ -381,7 +382,7 @@ function ctools_entity_field_value_ctools_access_summary($conf, $context, $plugi
if (is_array($elements)) {
foreach ($elements as $element_key => $element) {
if (is_numeric($element_key)) {
- $value_str= strip_tags(drupal_render($element));
+ $value_str = strip_tags(drupal_render($element));
if (strlen($value_str) > 0) {
$output[] = $value_str;
}
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/front.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/front.inc
index 1bbc6e0..8718a14 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/front.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/front.inc
@@ -19,7 +19,7 @@ $plugin = array(
);
/**
- * Settings form for the 'by parent term' access plugin
+ * Settings form for the 'by parent term' access plugin.
*/
function ctools_front_ctools_access_settings($form, &$form_state, $conf) {
// No additional configuration necessary.
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/node_access.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/node_access.inc
index fcd275d..c153cc5 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/node_access.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/node_access.inc
@@ -24,7 +24,7 @@ $plugin = array(
);
/**
- * Settings form for the 'by node_access' access plugin
+ * Settings form for the 'by node_access' access plugin.
*/
function ctools_node_access_ctools_access_settings($form, &$form_state, $conf) {
$form['settings']['type'] = array(
@@ -86,4 +86,3 @@ function ctools_node_access_ctools_access_summary($conf, $context) {
return t('@user can create nodes of the same type as @node.', $replacement);
}
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/node_comment.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/node_comment.inc
index 915ee20..6cebdaf 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/node_comment.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/node_comment.inc
@@ -1,4 +1,5 @@
implode(', ', $names), '@identifier' => $context->identifier));
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/node_status.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/node_status.inc
index ad5ba40..137f282 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/node_status.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/node_status.inc
@@ -30,4 +30,3 @@ function ctools_node_status_ctools_access_check($conf, $context) {
function ctools_node_status_ctools_access_summary($conf, $context) {
return t('Returns true if the nodes status is "published".');
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/node_type.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/node_type.inc
index 23a3845..d89532a 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/node_type.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/node_type.inc
@@ -22,7 +22,7 @@ $plugin = array(
);
/**
- * Settings form for the 'by node_type' access plugin
+ * Settings form for the 'by node_type' access plugin.
*/
function ctools_node_type_ctools_access_settings($form, &$form_state, $conf) {
$types = node_type_get_types();
@@ -114,4 +114,3 @@ function ctools_node_type_ctools_access_summary($conf, $context) {
return format_plural(count($names), '@identifier is type "@types"', '@identifier type is one of "@types"', array('@types' => implode(', ', $names), '@identifier' => $context->identifier));
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/path_visibility.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/path_visibility.inc
index 60b8612..1612e1c 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/path_visibility.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/path_visibility.inc
@@ -11,12 +11,12 @@ $plugin = array(
'callback' => 'ctools_path_visibility_ctools_access_check',
'settings form' => 'ctools_path_visibility_ctools_access_settings',
'summary' => 'ctools_path_visibility_ctools_access_summary',
- 'required context' => new ctools_context_optional(t('Path'), 'string'),
+ 'required context' => new ctools_context_optional(t('Path'), 'string'),
'default' => array('visibility_setting' => 1, 'paths' => ''),
);
/**
- * Settings form
+ * Settings form.
*/
function ctools_path_visibility_ctools_access_settings($form, &$form_state, $conf) {
$form['settings']['note'] = array(
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/perm.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/perm.inc
index 67516fa..cb2bb81 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/perm.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/perm.inc
@@ -20,11 +20,11 @@ $plugin = array(
);
/**
- * Settings form for the 'by perm' access plugin
+ * Settings form for the 'by perm' access plugin.
*/
function ctools_perm_ctools_access_settings($form, &$form_state, $conf) {
$perms = array();
- // Get list of permissions
+ // Get list of permissions.
foreach (module_list(FALSE, FALSE, TRUE) as $module) {
// By keeping them keyed by module we can use optgroups with the
// 'select' type.
@@ -70,4 +70,3 @@ function ctools_perm_ctools_access_summary($conf, $context) {
$permissions = module_invoke_all('permission');
return t('@identifier has "@perm"', array('@identifier' => $context->identifier, '@perm' => $permissions[$conf['perm']]['title']));
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/php.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/php.inc
index 35da86d..4e9d056 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/php.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/php.inc
@@ -20,7 +20,7 @@ $plugin = array(
);
/**
- * Settings form for the 'by perm' access plugin
+ * Settings form for the 'by perm' access plugin.
*
* @todo Need a way to provide a list of all available contexts to be used by
* the eval-ed PHP.
@@ -38,7 +38,7 @@ function ctools_php_ctools_access_settings($form, &$form_state, $conf) {
'#type' => 'textarea',
'#title' => t('PHP Code'),
'#default_value' => $conf['php'],
- '#description' => t('Access will be granted if the following PHP code returns TRUE. Do not include <?php ?>. Note that executing incorrect PHP-code can break your Drupal site. All contexts will be available in the $contexts variable.'),
+ '#description' => t('Access will be granted if the following PHP code returns TRUE. Do not include <?php ?>. Note that executing incorrect PHP-code can break your Drupal site. All contexts will be available in the $contexts variable.'),
);
if (!user_access('use PHP for settings')) {
$form['settings']['php']['#disabled'] = TRUE;
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/query_string_exists.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/query_string_exists.inc
new file mode 100644
index 0000000..fb3b433
--- /dev/null
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/query_string_exists.inc
@@ -0,0 +1,44 @@
+ t('Query string exists'),
+ 'description' => t('Control access by whether or not a query string exists.'),
+ 'callback' => 'ctools_query_string_exists_ctools_access_check',
+ 'settings form' => 'ctools_query_string_exists_ctools_access_settings',
+ 'summary' => 'ctools_query_string_exists_ctools_access_summary',
+ 'defaults' => array('key' => ''),
+);
+
+/**
+ * Settings form.
+ */
+function ctools_query_string_exists_ctools_access_settings($form, &$form_state, $config) {
+ $form['settings']['key'] = array(
+ '#title' => t('Query string key'),
+ '#description' => t('Enter the key of the query string.'),
+ '#type' => 'textfield',
+ '#required' => TRUE,
+ '#default_value' => $config['key'],
+ );
+
+ return $form;
+}
+
+/**
+ * Check for access.
+ */
+function ctools_query_string_exists_ctools_access_check($config, $context) {
+ return isset($_GET[$config['key']]);
+}
+
+/**
+ * Provide a summary description.
+ */
+function ctools_query_string_exists_ctools_access_summary($config, $context) {
+ return t('@identifier exists', array('@identifier' => $config['key']));
+}
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/role.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/role.inc
index b633254..4d8cbae 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/role.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/role.inc
@@ -21,7 +21,7 @@ $plugin = array(
);
/**
- * Settings form for the 'by role' access plugin
+ * Settings form for the 'by role' access plugin.
*/
function ctools_role_ctools_access_settings($form, &$form_state, $conf) {
$form['settings']['rids'] = array(
@@ -76,4 +76,3 @@ function ctools_role_ctools_access_summary($conf, $context) {
return format_plural(count($names), '@identifier has role "@roles"', '@identifier has one of "@roles"', array('@roles' => implode(', ', $names), '@identifier' => $context->identifier));
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/site_language.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/site_language.inc
index 9ff2f70..5b7b724 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/site_language.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/site_language.inc
@@ -22,7 +22,7 @@ if (module_exists('locale')) {
}
/**
- * Settings form for the 'by site_language' access plugin
+ * Settings form for the 'by site_language' access plugin.
*/
function ctools_site_language_ctools_access_settings($form, &$form_state, $conf) {
$options = array(
@@ -84,4 +84,3 @@ function ctools_site_language_ctools_access_summary($conf, $context) {
return format_plural(count($names), 'Site language is "@languages"', 'Site language is one of "@languages"', array('@languages' => implode(', ', $names)));
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/string_equal.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/string_equal.inc
index ad1c88d..feb48e9 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/string_equal.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/string_equal.inc
@@ -2,7 +2,7 @@
/**
* @file
- * Plugin to provide access control/visibility based on specified context string matching user-specified string
+ * Plugin to provide access control/visibility based on specified context string matching user-specified string.
*/
$plugin = array(
@@ -16,7 +16,7 @@ $plugin = array(
);
/**
- * Settings form
+ * Settings form.
*/
function ctools_string_equal_ctools_access_settings($form, &$form_state, $conf) {
$form['settings']['operator'] = array(
@@ -47,7 +47,7 @@ function ctools_string_equal_ctools_access_settings($form, &$form_state, $conf)
}
/**
- * Check for access
+ * Check for access.
*/
function ctools_string_equal_ctools_access_check($conf, $context) {
if (empty($context) || empty($context->data)) {
@@ -66,29 +66,34 @@ function ctools_string_equal_ctools_access_check($conf, $context) {
switch ($conf['operator']) {
case '=':
return $string === $value;
+
case '!=':
return $string !== $value;
+
case 'regex':
return preg_match($value, $string);
+
case '!regex':
return !preg_match($value, $string);
}
}
/**
- * Provide a summary description based upon the specified context
+ * Provide a summary description based upon the specified context.
*/
function ctools_string_equal_ctools_access_summary($conf, $context) {
$values = array('@identifier' => $context->identifier, '@value' => $conf['value']);
switch ($conf['operator']) {
case '=':
return t('@identifier is "@value"', $values);
+
case '!=':
return t('@identifier is not "@value"', $values);
+
case 'regex':
return t('@identifier matches "@value"', $values);
+
case '!regex':
return t('@identifier does not match "@value"', $values);
}
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/string_length.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/string_length.inc
index 91abf22..3af504b 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/string_length.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/string_length.inc
@@ -57,14 +57,19 @@ function ctools_string_length_ctools_access_check($conf, $context) {
switch ($conf['operator']) {
case '<':
return $length < $conf['length'];
+
case '<=':
return $length <= $conf['length'];
+
case '=':
return $length == $conf['length'];
+
case '!=':
return $length != $conf['length'];
+
case '>':
return $length > $conf['length'];
+
case '>=':
return $length >= $conf['length'];
}
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/term.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/term.inc
index 36e70de..50ec0d9 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/term.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/term.inc
@@ -22,7 +22,7 @@ $plugin = array(
);
/**
- * Settings form for the 'by term' access plugin
+ * Settings form for the 'by term' access plugin.
*/
function ctools_term_ctools_access_settings($form, &$form_state, $conf) {
// If no configuration was saved before, set some defaults.
@@ -51,7 +51,6 @@ function ctools_term_ctools_access_settings($form, &$form_state, $conf) {
// A note: Dependency works strangely on these forms as they have never been
// updated to a more modern system so they are not individual forms of their
// own like the content types.
-
$form['settings']['#tree'] = TRUE;
// Loop over each of the configured vocabularies.
@@ -124,6 +123,8 @@ function ctools_term_ctools_access_summary($conf, $context) {
return format_plural(count($terms),
'@term can be the term "@terms"',
'@term can be one of these terms: @terms',
- array('@terms' => implode(', ', $terms),
- '@term' => $context->identifier));
+ array(
+ '@terms' => implode(', ', $terms),
+ '@term' => $context->identifier,
+ ));
}
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/term_has_parent.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/term_has_parent.inc
index a079e92..16f4fbf 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/term_has_parent.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/term_has_parent.inc
@@ -1,4 +1,5 @@
!empty($conf['vid_' . $vid]) ? $conf['vid_' . $vid] : '',
'#size' => 10,
'#multiple' => TRUE,
- //@todo: Remove the following workaround when the following patch is in core. {@see:http://drupal.org/node/1117526}
+ // @todo: Remove the following workaround when the following patch is in core. {@see:http://drupal.org/node/1117526}
'#name' => sprintf("settings[%u][]", $vid),
'#attributes' => array('multiple' => 'multiple'),
);
@@ -71,7 +71,6 @@ function ctools_term_has_parent_ctools_access_settings($form, &$form_state, $con
foreach (taxonomy_get_tree($vocabulary->vid) as $term) {
$terms[$term->tid] = str_repeat('-', $term->depth) . ($term->depth ? ' ' : '') . $term->name;
}
- //$form['settings']['vid_' . $vid]['#type'] = 'select';
$form['settings']['vid_' . $vid]['#type'] = 'checkboxes';
$form['settings']['vid_' . $vid]['#options'] = $terms;
unset($terms);
@@ -116,37 +115,36 @@ function ctools_term_has_parent_ctools_access_check($conf, $context) {
// we'll start looking up the hierarchy from our context term id.
$current_term = $context->data->tid;
- $term='';
+ $term = '';
- // scan up the tree.
- while (true) {
- // select parent as term_parent to avoid PHP5 complications with the parent keyword
- //@todo: Find a way to reduce the number of queries required for really deep hierarchies.
- $term = db_query("SELECT parent AS term_parent, tid AS tid FROM {taxonomy_term_hierarchy} th WHERE th.tid = :tid", array(':tid'=>$current_term))->fetchObject();
+ // Scan up the tree.
+ while (TRUE) {
+ // Select parent as term_parent to avoid PHP5 complications with the parent keyword.
+ // @todo: Find a way to reduce the number of queries required for really deep hierarchies.
+ $term = db_query("SELECT parent AS term_parent, tid AS tid FROM {taxonomy_term_hierarchy} th WHERE th.tid = :tid", array(':tid' => $current_term))->fetchObject();
- // if no term is found, get out of the loop
+ // If no term is found, get out of the loop.
if (!$term || empty($term->tid)) {
break;
}
- // check the term selected, if the user asked it to.
+ // Check the term selected, if the user asked it to.
if (!empty($conf['include_self']) && isset($conf['vid_' . $vid][$term->tid])) {
return TRUE;
}
- // did we find the parent TID we were looking for?
+ // Did we find the parent TID we were looking for?
if (isset($conf['vid_' . $vid][$term->tid])) {
// YES, we're done!
return TRUE;
}
// Nope, we didn't find it.
-
// If this is the top of the hierarchy, stop scanning.
- if ($term->term_parent==0) {
+ if ($term->term_parent == 0) {
break;
}
- // update the parent, and keep scanning.
+ // Update the parent, and keep scanning.
$current_term = $term->term_parent;
}
@@ -157,7 +155,7 @@ function ctools_term_has_parent_ctools_access_check($conf, $context) {
* Provide a summary description based upon the checked terms.
*/
function ctools_term_has_parent_ctools_access_summary($conf, $context) {
- $vid = (int)$conf['vid'];
+ $vid = (int) $conf['vid'];
$terms = array();
foreach ($conf['vid_' . $vid] as $tid) {
$term = taxonomy_term_load($tid);
@@ -167,6 +165,8 @@ function ctools_term_has_parent_ctools_access_summary($conf, $context) {
return format_plural(count($terms),
'@term can have the parent "@terms"',
'@term can have one of these parents: @terms',
- array('@terms' => implode(', ', $terms),
- '@term' => $context->identifier));
+ array(
+ '@terms' => implode(', ', $terms),
+ '@term' => $context->identifier,
+ ));
}
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/term_parent.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/term_parent.inc
index acbaf87..27375df 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/term_parent.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/term_parent.inc
@@ -22,7 +22,7 @@ $plugin = array(
);
/**
- * Settings form for the 'by parent term' access plugin
+ * Settings form for the 'by parent term' access plugin.
*/
function ctools_term_parent_ctools_access_settings($form, &$form_state, $conf) {
// If no configuration was saved before, set some defaults.
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/term_vocabulary.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/term_vocabulary.inc
index b003138..8e9a0ca 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/term_vocabulary.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/term_vocabulary.inc
@@ -2,7 +2,7 @@
/**
* @file
- * Plugin to provide access control based upon term vocabulary
+ * Plugin to provide access control based upon term vocabulary.
*/
/**
@@ -20,12 +20,12 @@ $plugin = array(
'required context' => new ctools_context_required(t('Vocabulary'), array(
'taxonomy_term',
'terms',
- 'taxonomy_vocabulary'
+ 'taxonomy_vocabulary',
)),
);
/**
- * Settings form for the 'by term_vocabulary' access plugin
+ * Settings form for the 'by term_vocabulary' access plugin.
*/
function ctools_term_vocabulary_ctools_access_settings($form, &$form_state, $conf) {
$options = array();
@@ -101,7 +101,7 @@ function ctools_term_vocabulary_ctools_access_summary($conf, $context) {
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
+ '@identifier' => $context->identifier,
));
}
@@ -123,5 +123,3 @@ function _ctools_term_vocabulary_ctools_access_map_vids(&$conf) {
}
}
}
-
-
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/access/theme.inc b/sites/all/modules/contrib/dev/ctools/plugins/access/theme.inc
index 4f4be6d..67e3e6f 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/access/theme.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/access/theme.inc
@@ -19,7 +19,7 @@ $plugin = array(
);
/**
- * Settings form for the 'by theme' access plugin
+ * Settings form for the 'by theme' access plugin.
*/
function ctools_theme_ctools_access_settings($form, &$form_state, $conf) {
$themes = array();
@@ -44,10 +44,10 @@ function ctools_theme_ctools_access_check($conf, $context) {
if (!empty($GLOBALS['theme'])) {
$theme = $GLOBALS['theme'];
}
- else if (!empty($GLOBALS['custom_theme'])) {
+ elseif (!empty($GLOBALS['custom_theme'])) {
$theme = $GLOBALS['custom_theme'];
}
- else if (!empty($GLOBALS['user']->theme)) {
+ elseif (!empty($GLOBALS['user']->theme)) {
$theme = $GLOBALS['user']->theme;
}
else {
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/arguments/entity_id.inc b/sites/all/modules/contrib/dev/ctools/plugins/arguments/entity_id.inc
index 214dc55..73bfe1e 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/arguments/entity_id.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/arguments/entity_id.inc
@@ -2,8 +2,7 @@
/**
* @file
- *
- * Plugin to provide an argument handler for all entity ids
+ * Plugin to provide an argument handler for all entity ids.
*/
/**
@@ -17,7 +16,7 @@ $plugin = array(
'get child' => 'ctools_argument_entity_id_get_child',
'get children' => 'ctools_argument_entity_id_get_children',
'default' => array(
- 'entity_id' => ''
+ 'entity_id' => '',
),
'placeholder form' => 'ctools_argument_entity_id_ctools_argument_placeholder',
);
@@ -41,6 +40,7 @@ function ctools_argument_entity_id_get_children($original_plugin, $parent) {
$plugins[$plugin_id] = $plugin;
}
drupal_alter('ctools_entity_contexts', $plugins);
+
return $plugins;
}
@@ -60,9 +60,12 @@ 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);
+ $match = preg_match('/\[id: (\d+)\]/', $arg, $preg_matches);
if (!$match) {
$match = preg_match('/^id: (\d+)/', $arg, $preg_matches);
}
@@ -70,18 +73,18 @@ function ctools_argument_entity_id_context($arg = NULL, $conf = NULL, $empty = F
if ($match) {
$id = $preg_matches[1];
}
- if (is_numeric($id)) {
+ 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) {
@@ -119,7 +122,7 @@ function ctools_argument_entity_id_settings_form(&$form, &$form_state, $conf) {
$form['settings']['entity_id'] = array(
'#type' => 'value',
- '#value' => $conf['entity_id'],
+ '#value' => isset($conf['entity_id']) ? $conf['entity_id'] : '',
);
$form['settings']['entity_type'] = array(
@@ -132,11 +135,12 @@ function ctools_argument_entity_id_settings_form(&$form, &$form_state, $conf) {
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,
+ '#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,
+ '#weight' => -10,
);
+
return $conf;
}
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/arguments/nid.inc b/sites/all/modules/contrib/dev/ctools/plugins/arguments/nid.inc
index 9aaec0e..cbb56d3 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/arguments/nid.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/arguments/nid.inc
@@ -2,8 +2,7 @@
/**
* @file
- *
- * Plugin to provide an argument handler for a node id
+ * Plugin to provide an argument handler for a node id.
*/
/**
@@ -47,4 +46,3 @@ function ctools_argument_nid_context($arg = NULL, $conf = NULL, $empty = FALSE)
return ctools_context_create('node', $node);
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/arguments/node_add.inc b/sites/all/modules/contrib/dev/ctools/plugins/arguments/node_add.inc
index c811311..f249a94 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/arguments/node_add.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/arguments/node_add.inc
@@ -2,8 +2,7 @@
/**
* @file
- *
- * Plugin to provide an argument handler for a Node add form
+ * Plugin to provide an argument handler for a Node add form.
*/
/**
@@ -12,7 +11,7 @@
*/
$plugin = array(
'title' => t("Node add form: node type"),
- // keyword to use for %substitution
+ // Keyword to use for %substitution.
'keyword' => 'node_type',
'description' => t('Creates a node add form context from a node type argument.'),
'context' => 'ctools_node_add_context',
@@ -29,4 +28,3 @@ function ctools_node_add_context($arg = NULL, $conf = NULL, $empty = FALSE) {
return ctools_context_create('node_add_form', $arg);
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/arguments/node_edit.inc b/sites/all/modules/contrib/dev/ctools/plugins/arguments/node_edit.inc
index c7cdf29..8bd0768 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/arguments/node_edit.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/arguments/node_edit.inc
@@ -2,8 +2,7 @@
/**
* @file
- *
- * Plugin to provide an argument handler for a Node edit form
+ * Plugin to provide an argument handler for a Node edit form.
*/
/**
@@ -12,7 +11,7 @@
*/
$plugin = array(
'title' => t("Node edit form: node ID"),
- // keyword to use for %substitution
+ // Keyword to use for %substitution.
'keyword' => 'node',
'description' => t('Creates a node edit form context from a node ID argument.'),
'context' => 'ctools_node_edit_context',
@@ -48,4 +47,3 @@ function ctools_node_edit_context($arg = NULL, $conf = NULL, $empty = FALSE) {
// This will perform a node_access check, so we don't have to.
return ctools_context_create('node_edit_form', $node);
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/arguments/rid.inc b/sites/all/modules/contrib/dev/ctools/plugins/arguments/rid.inc
index 2661153..d0cc30c 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/arguments/rid.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/arguments/rid.inc
@@ -2,8 +2,7 @@
/**
* @file
- *
- * Plugin to provide an argument handler for a node revision id
+ * Plugin to provide an argument handler for a node revision id.
*/
/**
@@ -47,4 +46,3 @@ function ctools_argument_rid_context($arg = NULL, $conf = NULL, $empty = FALSE)
return ctools_context_create('node', $node);
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/arguments/string.inc b/sites/all/modules/contrib/dev/ctools/plugins/arguments/string.inc
index ed4ffbb..005e40e 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/arguments/string.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/arguments/string.inc
@@ -2,16 +2,16 @@
/**
* @file
- *
- * Plugin to provide an argument handler for a raw string
+ * Plugin to provide an argument handler for a raw string.
*/
+
/**
* Plugins are described by creating a $plugin array which will be used
* by the system that includes this file.
*/
$plugin = array(
'title' => t("String"),
- // keyword to use for %substitution
+ // Keyword to use for %substitution.
'keyword' => 'string',
'description' => t('A string is a minimal context that simply holds a string that can be used for some other purpose.'),
'settings form' => 'ctools_string_settings_form',
@@ -20,7 +20,8 @@ $plugin = array(
'#type' => 'textfield',
'#description' => t('Enter a value for this argument'),
),
- 'path placeholder' => 'ctools_string_path_placeholder', // This is in pagemanager.
+// This is in pagemanager.
+ 'path placeholder' => 'ctools_string_path_placeholder',
);
/**
@@ -39,7 +40,7 @@ function ctools_string_context($arg = NULL, $conf = NULL, $empty = FALSE) {
}
/**
- * Settings form for the argument
+ * Settings form for the argument.
*/
function ctools_string_settings_form(&$form, &$form_state, $conf) {
$form['settings']['use_tail'] = array(
@@ -48,7 +49,6 @@ function ctools_string_settings_form(&$form, &$form_state, $conf) {
'#default_value' => !empty($conf['use_tail']),
'#description' => t('If checked, this string will include all arguments. For example, if the path is "path/%" and the user visits "path/foo/bar", if this is not checked the string will be "foo". If it is checked the string will be "foo/bar".'),
);
-// return $form;
}
/**
@@ -61,4 +61,4 @@ function ctools_string_path_placeholder($argument) {
else {
return '%pm_arg_tail';
}
-}
\ No newline at end of file
+}
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/arguments/term.inc b/sites/all/modules/contrib/dev/ctools/plugins/arguments/term.inc
index 868c8aa..f72e93d 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/arguments/term.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/arguments/term.inc
@@ -2,8 +2,7 @@
/**
* @file
- *
- * Plugin to provide an argument handler for a Taxonomy term
+ * Plugin to provide an argument handler for a Taxonomy term.
*/
/**
@@ -12,12 +11,13 @@
*/
$plugin = array(
'title' => t("Taxonomy term: ID"),
- // keyword to use for %substitution
+ // Keyword to use for %substitution.
'keyword' => 'term',
'description' => t('Creates a single taxonomy term from a taxonomy ID or taxonomy term name.'),
'context' => 'ctools_term_context',
'default' => array('input_form' => 'tid', 'breadcrumb' => TRUE, 'transform' => FALSE),
'settings form' => 'ctools_term_settings_form',
+ 'settings form validate' => 'ctools_term_settings_form_validate',
'placeholder form' => 'ctools_term_ctools_argument_placeholder',
'breadcrumb' => 'ctools_term_breadcrumb',
);
@@ -31,6 +31,16 @@ function ctools_term_context($arg = NULL, $conf = NULL, $empty = FALSE) {
return ctools_context_create_empty('entity:taxonomy_term');
}
+ if (isset($conf['vocabularies'])) {
+ $vocabularies = $conf['vocabularies'];
+ }
+ else {
+ $vids = isset($conf['vids']) ? $conf['vids'] : array();
+
+ // Convert legacy use of vids to machine names.
+ $vocabularies = _ctools_term_vocabulary_machine_name_convert($vids);
+ }
+
if (is_object($arg)) {
$term = $arg;
}
@@ -50,14 +60,13 @@ function ctools_term_context($arg = NULL, $conf = NULL, $empty = FALSE) {
}
$terms = taxonomy_get_term_by_name($arg);
-
- $conf['vids'] = is_array($conf['vids']) ? array_filter($conf['vids']) : NULL;
- if ((count($terms) > 1) && isset($conf['vids'])) {
+ // If only one term is found, fall through to vocabulary check below.
+ if ((count($terms) > 1) && $vocabularies) {
foreach ($terms as $potential) {
- foreach ($conf['vids'] as $vid => $active) {
- if ($active && $potential->vid == $vid) {
+ foreach ($vocabularies as $machine_name) {
+ if ($potential->vocabulary_machine_name == $machine_name) {
$term = $potential;
- // break out of the foreaches AND the case
+ // Break out of the foreaches AND the case.
break 3;
}
}
@@ -72,7 +81,7 @@ function ctools_term_context($arg = NULL, $conf = NULL, $empty = FALSE) {
}
}
- if (!empty($conf['vids']) && array_filter($conf['vids']) && empty($conf['vids'][$term->vid])) {
+ if ($vocabularies && !isset($vocabularies[$term->vocabulary_machine_name])) {
return NULL;
}
@@ -82,7 +91,7 @@ function ctools_term_context($arg = NULL, $conf = NULL, $empty = FALSE) {
}
/**
- * Settings form for the argument
+ * Settings form for the argument.
*/
function ctools_term_settings_form(&$form, &$form_state, $conf) {
// @todo allow synonym use like Views does.
@@ -98,13 +107,20 @@ function ctools_term_settings_form(&$form, &$form_state, $conf) {
$vocabularies = taxonomy_get_vocabularies();
$options = array();
foreach ($vocabularies as $vid => $vocab) {
- $options[$vid] = $vocab->name;
+ $options[$vocab->machine_name] = $vocab->name;
}
- $form['settings']['vids'] = array(
+
+ // Fallback on legacy 'vids', when no vocabularies are available.
+ if (empty($conf['vocabularies']) && !empty($conf['vids'])) {
+ $conf['vocabularies'] = _ctools_term_vocabulary_machine_name_convert(array_filter($conf['vids']));
+ unset($conf['vids']);
+ }
+
+ $form['settings']['vocabularies'] = array(
'#title' => t('Limit to these vocabularies'),
'#type' => 'checkboxes',
'#options' => $options,
- '#default_value' => !empty($conf['vids']) ? $conf['vids'] : array(),
+ '#default_value' => !empty($conf['vocabularies']) ? $conf['vocabularies'] : array(),
'#description' => t('If no vocabularies are checked, terms from all vocabularies will be accepted.'),
);
@@ -120,7 +136,12 @@ function ctools_term_settings_form(&$form, &$form_state, $conf) {
'#type' => 'checkbox',
'#default_value' => !empty($conf['transform']),
);
-// return $form;
+}
+
+function ctools_term_settings_form_validate(&$form, &$form_state) {
+ // Filter the selected vocabularies to avoid storing redundant data.
+ $vocabularies = array_filter($form_state['values']['settings']['vocabularies']);
+ form_set_value($form['settings']['vocabularies'], $vocabularies, $form_state);
}
/**
@@ -134,6 +155,7 @@ function ctools_term_ctools_argument_placeholder($conf) {
'#type' => 'textfield',
'#description' => t('Enter a taxonomy term ID.'),
);
+
case 'term':
return array(
'#type' => 'textfield',
@@ -161,3 +183,21 @@ function ctools_term_breadcrumb($conf, $context) {
$breadcrumb = array_merge(drupal_get_breadcrumb(), array_reverse($breadcrumb));
drupal_set_breadcrumb($breadcrumb);
}
+
+/**
+ * Helper function to convert convert legacy vocabulary ids into machine names.
+ *
+ * @param array $vids
+ * Array of either vids.
+ *
+ * @return array
+ * A keyed array of machine names.
+ */
+function _ctools_term_vocabulary_machine_name_convert($vids) {
+ $vocabularies = taxonomy_vocabulary_load_multiple($vids);
+ $return = array();
+ foreach ($vocabularies as $vocabulary) {
+ $return[$vocabulary->machine_name] = $vocabulary->machine_name;
+ }
+ return $return;
+}
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/arguments/terms.inc b/sites/all/modules/contrib/dev/ctools/plugins/arguments/terms.inc
index 4298ea9..b816e1c 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/arguments/terms.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/arguments/terms.inc
@@ -2,8 +2,7 @@
/**
* @file
- *
- * Plugin to provide an argument handler for a Taxonomy term
+ * Plugin to provide an argument handler for a Taxonomy term.
*/
/**
@@ -12,7 +11,7 @@
*/
$plugin = array(
'title' => t("Taxonomy term (multiple): ID"),
- // keyword to use for %substitution
+ // Keyword to use for %substitution.
'keyword' => 'term',
'description' => t('Creates a group of taxonomy terms from a list of tids separated by a comma or a plus sign. In general the first term of the list will be used for panes.'),
'context' => 'ctools_terms_context',
@@ -45,7 +44,7 @@ function ctools_terms_context($arg = NULL, $conf = NULL, $empty = FALSE) {
}
/**
- * Settings form for the argument
+ * Settings form for the argument.
*/
function ctools_terms_settings_form(&$form, &$form_state, $conf) {
$form['settings']['breadcrumb'] = array(
@@ -54,7 +53,6 @@ function ctools_terms_settings_form(&$form, &$form_state, $conf) {
'#default_value' => !empty($conf['breadcrumb']),
'#description' => t('If checked, taxonomy term parents will appear in the breadcrumb trail.'),
);
-// return $form;
}
/**
@@ -65,6 +63,7 @@ function ctools_terms_breadcrumb($conf, $context) {
return;
}
+ $current = new stdClass();
$current->tid = $context->tids[0];
$breadcrumb = array();
while ($parents = taxonomy_get_parents($current->tid)) {
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/arguments/uid.inc b/sites/all/modules/contrib/dev/ctools/plugins/arguments/uid.inc
index f9d5315..c6ca3cc 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/arguments/uid.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/arguments/uid.inc
@@ -2,8 +2,7 @@
/**
* @file
- *
- * Plugin to provide an argument handler for a user id
+ * Plugin to provide an argument handler for a user id.
*/
/**
@@ -12,7 +11,7 @@
*/
$plugin = array(
'title' => t("User: ID"),
- // keyword to use for %substitution
+ // Keyword to use for %substitution.
'keyword' => 'user',
'description' => t('Creates a user context from a user ID argument.'),
'context' => 'ctools_argument_uid_context',
@@ -21,7 +20,8 @@ $plugin = array(
'#description' => t('Enter the user ID of a user for this argument'),
),
'default' => array('to_arg' => TRUE),
- 'path placeholder' => '%pm_uid_arg', // This is in pagemanager.
+// This is in pagemanager.
+ 'path placeholder' => '%pm_uid_arg',
'path placeholder to_arg' => TRUE,
'no ui' => TRUE,
);
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/arguments/user_edit.inc b/sites/all/modules/contrib/dev/ctools/plugins/arguments/user_edit.inc
index 32b2b81..9c52b58 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/arguments/user_edit.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/arguments/user_edit.inc
@@ -2,8 +2,7 @@
/**
* @file
- *
- * Plugin to provide an argument handler for a Taxonomy term
+ * Plugin to provide an argument handler for a Taxonomy term.
*/
/**
@@ -12,7 +11,7 @@
*/
$plugin = array(
'title' => t("User edit form: User ID"),
- // keyword to use for %substitution
+ // Keyword to use for %substitution.
'keyword' => 'user',
'description' => t('Creates a user edit form context from a user ID argument.'),
'context' => 'ctools_user_edit_context',
@@ -30,18 +29,18 @@ function ctools_user_edit_context($arg = NULL, $conf = NULL, $empty = FALSE) {
if ($empty) {
return ctools_context_create_empty('user_edit_form');
}
- if(is_object($arg)){
+ if (is_object($arg)) {
return ctools_context_create('user_edit_form', $arg);
}
if (!is_numeric($arg)) {
return FALSE;
}
- $account= user_load($arg);
+ $account = user_load($arg);
if (!$account) {
return NULL;
}
// This will perform a node_access check, so we don't have to.
return ctools_context_create('user_edit_form', $account);
-}
\ No newline at end of file
+}
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/arguments/user_name.inc b/sites/all/modules/contrib/dev/ctools/plugins/arguments/user_name.inc
index f6f3b46..ed74d9d 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/arguments/user_name.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/arguments/user_name.inc
@@ -2,8 +2,7 @@
/**
* @file
- *
- * Plugin to provide an argument handler for a username
+ * Plugin to provide an argument handler for a username.
*/
/**
@@ -12,7 +11,7 @@
*/
$plugin = array(
'title' => t("User: name"),
- // keyword to use for %substitution
+ // Keyword to use for %substitution.
'keyword' => 'user',
'description' => t('Creates a user context from a user name.'),
'context' => 'ctools_argument_user_name_context',
@@ -42,6 +41,3 @@ function ctools_argument_user_name_context($arg = NULL, $conf = NULL, $empty = F
}
return ctools_context_create('user', $account);
}
-
-
-
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/arguments/vid.inc b/sites/all/modules/contrib/dev/ctools/plugins/arguments/vid.inc
index 064b22d..db68acd 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/arguments/vid.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/arguments/vid.inc
@@ -2,8 +2,7 @@
/**
* @file
- *
- * Plugin to provide an argument handler for a vocabulary id
+ * Plugin to provide an argument handler for a vocabulary id.
*/
/**
@@ -12,7 +11,7 @@
*/
$plugin = array(
'title' => t("Vocabulary: ID"),
- // keyword to use for %substitution
+ // Keyword to use for %substitution.
'keyword' => 'vocabulary',
'description' => t('Creates a vocabulary context from a vocabulary ID argument.'),
'context' => 'ctools_vid_context',
@@ -43,4 +42,3 @@ function ctools_vid_context($arg = NULL, $conf = NULL, $empty = FALSE) {
return ctools_context_create('vocabulary', $vocabulary);
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/cache/export_ui.inc b/sites/all/modules/contrib/dev/ctools/plugins/cache/export_ui.inc
index 53483a5..f21af10 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/cache/export_ui.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/cache/export_ui.inc
@@ -6,7 +6,7 @@
*/
$plugin = array(
- // cache plugins are the rare plugin types that have no real UI but
+ // 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',
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/cache/simple.inc b/sites/all/modules/contrib/dev/ctools/plugins/cache/simple.inc
index 570398b..c44d798 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/cache/simple.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/cache/simple.inc
@@ -6,7 +6,7 @@
*/
$plugin = array(
- // cache plugins are the rare plugin types that have no real UI but
+ // 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',
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/content_types/block/block.inc b/sites/all/modules/contrib/dev/ctools/plugins/content_types/block/block.inc
index 4d4c31c..ff75c75 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/content_types/block/block.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/content_types/block/block.inc
@@ -51,7 +51,7 @@ function ctools_block_content_type_content_types() {
if ($module_blocks) {
foreach ($module_blocks as $delta => $block) {
$info = _ctools_block_content_type_content_type($module, $delta, $block);
- // this check means modules can remove their blocks; particularly useful
+ // This check means modules can remove their blocks; particularly useful
// if they offer the block some other way (like we do for views)
if ($info) {
$types["$module-$delta"] = $info;
@@ -168,7 +168,7 @@ function ctools_block_content_type_render($subtype, $conf) {
if ($module == 'block' && !empty($info) && isset($info->title)) {
$block->title = $info->title;
}
- else if (isset($block->subject)) {
+ elseif (isset($block->subject)) {
$block->title = $block->subject;
}
else {
@@ -208,70 +208,6 @@ function ctools_block_content_type_edit_form_submit($form, &$form_state) {
}
}
-/**
- * Returns an edit form for a block.
- */
-//function ctools_block_content_type_edit_form($id, $parents, $conf) {
-// if (user_access('administer advanced pane settings')) {
-// $form['block_visibility'] = array(
-// '#type' => 'checkbox',
-// '#title' => t('Use block visibility settings (see block config)'),
-// '#default_value' => !empty($conf['block_visibility']),
-// '#description' => t('If checked, the block visibility settings for this block will apply to this block.'),
-// );
-// // Module-specific block configurations.
-// if ($settings = module_invoke($module, 'block', 'configure', $delta)) {
-// // Specifically modify a couple of core block forms.
-// if ($module == 'block') {
-// unset($settings['submit']);
-// $settings['info']['#type'] = 'value';
-// $settings['info']['#value'] = $settings['info']['#default_value'];
-// }
-// ctools_admin_fix_block_tree($settings);
-// $form['block_settings'] = array(
-// '#type' => 'fieldset',
-// '#title' => t('Block settings'),
-// '#description' => t('Settings in this section are global and are for all blocks of this type, anywhere in the system.'),
-// '#tree' => FALSE,
-// );
-//
-//
-// $form['block_settings'] += $settings;
-// }
-// }
-//
-// return $form;
-//}
-
-//function ctools_admin_submit_block(&$form_values) {
-// if (!empty($form_values['block_settings'])) {
-// module_invoke($form_values['module'], 'block', 'save', $form_values['delta'], $form_values['block_settings']);
-// }
-//}
-//
-///**
-// * Because form api cannot collapse just part of a tree, and the block settings
-// * assume no tree, we have to collapse the tree ourselves.
-// */
-//function ctools_admin_fix_block_tree(&$form, $key = NULL) {
-// if ($key) {
-// if (!empty($form['#parents'])) {
-// $form['#parents'] = array_merge(array('configuration', 'block_settings'), $form['#parents']);
-// }
-// else if (empty($form['#tree'])) {
-// $form['#parents'] = array('configuration', 'block_settings', $key);
-// }
-// }
-//
-// if (isset($form['#type']) && $form['#type'] == 'textarea' && !empty($form['#rows']) && $form['#rows'] > 10) {
-// $form['#rows'] = 10;
-// }
-//
-// foreach (element_children($form) as $key) {
-// ctools_admin_fix_block_tree($form[$key], $key);
-// }
-//}
-
/**
* Returns the administrative title for a type.
*/
@@ -338,8 +274,10 @@ function ctools_default_block_info($module, $delta, &$info) {
}
}
-// These are all on behalf of modules that don't implement ctools but that
-// we care about.
+/**
+ * These are all on behalf of modules that don't implement ctools but that
+ * we care about.
+ */
function menu_ctools_block_info($module, $delta, &$info) {
$info['icon'] = 'icon_core_block_menu.png';
$info['category'] = t('Menus');
@@ -360,7 +298,7 @@ function forum_ctools_block_info($module, $delta, &$info) {
break;
default:
- // safety net
+ // Safety net.
ctools_default_block_info($module, $delta, $info);
}
}
@@ -372,9 +310,9 @@ function profile_ctools_block_info($module, $delta, &$info) {
}
function book_ctools_block_info($module, $delta, &$info) {
- // Hide the book navigation block which isn't as rich as what we can
- // do with context.
- $info = NULL;
+ $info['title'] = t('Book navigation menu');
+ $info['icon'] = 'icon_core_block_menu.png';
+ $info['category'] = t('Node');
}
function blog_ctools_block_info($module, $delta, &$info) {
@@ -455,7 +393,7 @@ function user_ctools_block_info($module, $delta, &$info) {
break;
default:
- // safety net
+ // Safety net.
ctools_default_block_info($module, $delta, $info);
}
}
@@ -508,7 +446,7 @@ function ctools_user_login_pane_render($subtype, $conf, $panel_args, $contexts)
return;
}
- $info = new stdClass;
+ $info = new stdClass();
$info->module = $module;
$info->delta = $delta;
@@ -537,7 +475,7 @@ function ctools_user_login_pane_render($subtype, $conf, $panel_args, $contexts)
if ($module == 'block') {
$block->title = $info->title;
}
- else if (isset($block->subject)) {
+ elseif (isset($block->subject)) {
$block->title = $block->subject;
}
else {
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/content_types/comment/comment_created.inc b/sites/all/modules/contrib/dev/ctools/plugins/content_types/comment/comment_created.inc
new file mode 100644
index 0000000..b3f454a
--- /dev/null
+++ b/sites/all/modules/contrib/dev/ctools/plugins/content_types/comment/comment_created.inc
@@ -0,0 +1,76 @@
+ TRUE,
+ 'title' => t('Comment created date'),
+ 'icon' => 'icon_comment.png',
+ 'description' => t('The date the referenced comment was created.'),
+ 'required context' => new ctools_context_required(t('Comment'), 'entity:comment'),
+ 'category' => t('Comment'),
+ 'defaults' => array(
+ 'format' => 'small',
+ ),
+);
+
+/**
+ * Render the custom content type.
+ */
+function ctools_comment_created_content_type_render($subtype, $conf, $panel_args, $context) {
+ if (empty($context) || empty($context->data)) {
+ return;
+ }
+
+ // Get a shortcut to the comment.
+ $comment = $context->data;
+
+ // Build the content type block.
+ $block = new stdClass();
+ $block->module = 'comment_created';
+ $block->title = t('Created date');
+ $block->content = format_date($comment->created, $conf['format']);
+ $block->delta = $comment->cid;
+
+ return $block;
+}
+
+/**
+ * Returns an edit form for custom type settings.
+ */
+function ctools_comment_created_content_type_edit_form($form, &$form_state) {
+ $conf = $form_state['conf'];
+ $date_types = array();
+
+ foreach (system_get_date_types() as $date_type => $definition) {
+ $date_types[$date_type] = format_date(REQUEST_TIME, $date_type);
+ }
+ $form['format'] = array(
+ '#title' => t('Date format'),
+ '#type' => 'select',
+ '#options' => $date_types,
+ '#default_value' => $conf['format'],
+ );
+ return $form;
+}
+
+/**
+ * Submit handler for the custom type settings form.
+ */
+function ctools_comment_created_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_comment_created_content_type_admin_title($subtype, $conf, $context) {
+ return t('"@s" created date', array('@s' => $context->identifier));
+}
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/content_types/comment/comment_links.inc b/sites/all/modules/contrib/dev/ctools/plugins/content_types/comment/comment_links.inc
index c8fefcc..ed454f9 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/content_types/comment/comment_links.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/content_types/comment/comment_links.inc
@@ -1,9 +1,11 @@
TRUE,
'title' => t('Comment links'),
@@ -26,10 +28,10 @@ function ctools_comment_links_content_type_render($subtype, $conf, $panel_args,
return;
}
- $comment = isset($context->data) ? clone($context->data) : NULL;
+ $comment = isset($context->data) ? clone $context->data : NULL;
$block = new stdClass();
$block->module = 'comment';
- $block->delta = $comment->cid;
+ $block->delta = $comment->cid;
if (empty($comment)) {
$block->delta = 'placeholder';
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/content_types/comment/comment_reply_form.inc b/sites/all/modules/contrib/dev/ctools/plugins/content_types/comment/comment_reply_form.inc
index c05effb..a18ece9 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/content_types/comment/comment_reply_form.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/content_types/comment/comment_reply_form.inc
@@ -2,7 +2,7 @@
/**
* @file
- * Ctools content-type plugin to provide a comment-reply form (replying either
+ * CTools content-type plugin to provide a comment-reply form (replying either
* to a node or to another comment).
*/
@@ -14,21 +14,23 @@ if (module_exists('comment')) {
'icon' => 'icon_comment.png',
'description' => t('A form to add a new comment reply.'),
'required context' => array(
- new ctools_context_required(t('Node'), 'node'),
- new ctools_context_optional(t('Comment'), 'comment'),
- ),
+ new ctools_context_required(t('Node'), 'node'),
+ new ctools_context_optional(t('Comment'), 'comment'),
+ ),
'category' => t('Comment'),
'render callback' => 'ctools_comment_reply_form_content_type_render',
- 'defaults' => array('anon_links' => false),
+ 'defaults' => array('anon_links' => FALSE),
);
}
function ctools_comment_reply_form_content_type_render($subtype, $conf, $panel_args, $context) {
- $comment = ($context[1]->identifier == t('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;
+ if ($comment) {
+ $block->delta = $comment->cid;
+ }
$block->title = t('Add comment');
$node = $context[0]->data;
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/content_types/contact/contact.inc b/sites/all/modules/contrib/dev/ctools/plugins/content_types/contact/contact.inc
index 63283f5..bac30c4 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/content_types/contact/contact.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/content_types/contact/contact.inc
@@ -1,5 +1,9 @@
module = 'contact';
- $block->delta = 'form';
- $block->title = t('Contact');
+ $block = new stdClass();
+ $block->module = 'contact';
+ $block->delta = 'form';
+ $block->title = t('Contact');
module_load_include('inc', 'contact', 'contact.pages');
$block->content = drupal_get_form('contact_site_form');
@@ -45,11 +49,6 @@ function ctools_contact_content_type_edit_form($form, &$form_state) {
*/
function ctools_contact_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];
- }
-*/
}
/**
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/content_types/contact/user_contact.inc b/sites/all/modules/contrib/dev/ctools/plugins/content_types/contact/user_contact.inc
index 9b3726a..5bd3657 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/content_types/contact/user_contact.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/content_types/contact/user_contact.inc
@@ -1,5 +1,9 @@
module = 'contact';
- $block->delta = 'form';
- $block->title = t('Contact @name', array('@name' => $context->data->name));
+ $block = new stdClass();
+ $block->module = 'contact';
+ $block->delta = 'form';
+ $block->title = t('Contact @name', array('@name' => $context->data->name));
module_load_include('inc', 'contact', 'contact.pages');
$block->content = drupal_get_form('contact_personal_form', $context->data);
@@ -51,11 +55,6 @@ function ctools_user_contact_content_type_edit_form($form, &$form_state) {
*/
function ctools_user_contact_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];
- }
-*/
}
/**
diff --git a/sites/all/modules/contrib/dev/ctools/plugins/content_types/custom/custom.inc b/sites/all/modules/contrib/dev/ctools/plugins/content_types/custom/custom.inc
index ac2f2a3..84fe3c5 100644
--- a/sites/all/modules/contrib/dev/ctools/plugins/content_types/custom/custom.inc
+++ b/sites/all/modules/contrib/dev/ctools/plugins/content_types/custom/custom.inc
@@ -16,7 +16,7 @@
$plugin = array(
'title' => t('Custom content'),
'no title override' => TRUE,
- 'defaults' => array('admin_title' => '', 'title' => '', 'body' => '', 'format' => filter_default_format(), 'substitute' => TRUE),
+ 'defaults' => array('admin_title' => '', 'title' => '', 'title_heading' => 'h2', 'body' => '', 'format' => filter_default_format(), 'substitute' => TRUE),
'js' => array('misc/autocomplete.js', 'misc/textarea.js', 'misc/collapse.js'),
// Make sure the edit form is only used for some subtypes.
'edit form' => '',
@@ -135,6 +135,7 @@ function ctools_custom_content_type_get_conf($subtype, $conf) {
$settings = array(
'admin_title' => t('Missing/deleted content'),
'title' => '',
+ 'title_heading' => '',
'body' => '',
'format' => filter_default_format(),
'substitute' => TRUE,
@@ -177,9 +178,10 @@ function ctools_custom_content_type_render($subtype, $conf, $args, $contexts) {
static $delta = 0;
- $block = new stdClass();
- $block->subtype = ++$delta;
- $block->title = filter_xss_admin($settings['title']);
+ $block = new stdClass();
+ $block->subtype = ++$delta;
+ $block->title = filter_xss_admin($settings['title']);
+ $block->title_heading = isset($settings['title_heading']) ? $settings['title_heading'] : 'h2';
// Add keyword substitutions if we were configured to do so.
$content = $settings['body'];
@@ -267,7 +269,8 @@ function ctools_custom_content_type_edit_form($form, &$form_state) {
$form_state['settings'] = $settings;
if ($settings['custom_type'] == 'fixed') {
- return $form; // no form for this case.
+ // No form for this case.
+ return $form;
}
$form['admin_title'] = array(
@@ -277,10 +280,36 @@ function ctools_custom_content_type_edit_form($form, &$form_state) {
'#description' => t('This title will be used administratively to identify this pane. If blank, the regular title will be used.'),
);
+ // Copy over the title override settings for a title heading.
+ $form['aligner_start'] = array(
+ '#markup' => '
';
+ }
+ else {
+ return '';
+ }
+}
diff --git a/sites/all/modules/contrib/dev/ctools/tests/plugins/cached/ctoolsCachedPluginArray.class.php b/sites/all/modules/contrib/dev/ctools/tests/plugins/cached/ctoolsCachedPluginArray.class.php
index 3037daa..c6753ad 100644
--- a/sites/all/modules/contrib/dev/ctools/tests/plugins/cached/ctoolsCachedPluginArray.class.php
+++ b/sites/all/modules/contrib/dev/ctools/tests/plugins/cached/ctoolsCachedPluginArray.class.php
@@ -1,7 +1,8 @@
$context_info) {
if (!strpos($context_info, '.')) {
- // old skool: support pre-converter contexts as well.
+ // Old skool: support pre-converter contexts as well.
$cid = $context_info;
$converter = '';
}
@@ -150,7 +150,7 @@ function views_content_views_content_type_render($subtype, $conf, $panel_args, $
$block = new stdClass();
$block->module = 'views';
- $block->delta = $view->name . '-' . $view->current_display;
+ $block->delta = $view->name . '-' . $view->current_display;
if (!empty($conf['link_to_view'])) {
$block->title_link = $view->get_url();
@@ -165,7 +165,7 @@ function views_content_views_content_type_render($subtype, $conf, $panel_args, $
// pager type that Views uses.
if ($conf['override_pager_settings']) {
if (method_exists($view, 'init_pager')) {
- // Views 3 version
+ // Views 3 version.
$view->set_items_per_page($conf['nodes_per_page']);
$view->set_offset($conf['offset']);
@@ -237,7 +237,7 @@ function views_content_views_select_display($form, &$form_state) {
'#type' => 'select',
'#title' => t('Display'),
'#options' => $displays,
- '#description' => t('Choose which display of this view you wish to use.')
+ '#description' => t('Choose which display of this view you wish to use.'),
);
return $form;
@@ -271,7 +271,6 @@ function views_content_views_content_type_edit_form($form, &$form_state) {
// and check for that and forcibly set them to the right converter so that
// it doesn't get changed to some whacky default. Oooor just let it get changed
// to 'no context', I suppose.
-
$required = array();
if (isset($view->display_handler) && $arguments = $view->display_handler->get_handlers('argument')) {
foreach ($arguments as $arg) {
@@ -434,7 +433,7 @@ function views_content_views_content_type_admin_info($subtype, $conf, $contexts)
}
if (!strpos($context_info, '.')) {
- // old skool: support pre-converter contexts as well.
+ // Old skool: support pre-converter contexts as well.
$cid = $context_info;
$converter = '';
}
@@ -446,8 +445,10 @@ function views_content_views_content_type_admin_info($subtype, $conf, $contexts)
$converters = ctools_context_get_converters($cid . '.', $contexts[$cid]);
$converter = !empty($converters[$context_info]) ? $converters[$context_info] : t('Default');
$block->content .= '
where items between [] characters would be customized
+based on the user input.
+
+The link project supports both, internal and external URLs. URLs are validated
+on input. Here are some examples of data input and the default view of a link:
+http://drupal.org results in http://drupal.org, but drupal.org results in
+http://drupal.org, while will convert into http://drupal.org and
+node/74971 into http://drupal.org/project/link
+
+Anchors and query strings may also be used in any of these cases, including:
+node/74971/edit?destination=node/74972#pager
+
+
+THEMING AND OUTPUT
+------------------
+Since link module is mainly a data storage field in a modular framework, the
+theming and output is up to the site builder and other additional modules. There
+are many modules in the Drupal repository, which control the output of fields
+perfectly and can handle rules, user actions, markup dependencies, and can vary
+the output under many different conditions, with much more efficience and
+flexibility for different scenarios. Please check out modules like views,
+display suite, panels, etc for such needs
+
+
+MAINTAINERS
+-----------
+
+Current maintainers:
+ * John C Fiala (jcfiala) - https://www.drupal.org/user/163643
+ * Renato Gonçalves (RenatoG) - https://www.drupal.org/user/3326031
+ * Clemens Tolboom (clemens.tolboom) - https://www.drupal.org/user/125814
+ * diqidoq - https://www.drupal.org/user/1001934
+ * dropcube - https://www.drupal.org/user/37031
+ * Tom Kirkpatrick (mrfelton) - https://www.drupal.org/user/305669
+ * Sumit Madan (sumitmadan) - https://www.drupal.org/user/1538790
+ * Daniel Kudwien (sun) - https://www.drupal.org/user/54136
diff --git a/sites/all/modules/contrib/fields/link/link-rtl.css b/sites/all/modules/contrib/fields/link/link-rtl.css
index 0359487..613db5d 100644
--- a/sites/all/modules/contrib/fields/link/link-rtl.css
+++ b/sites/all/modules/contrib/fields/link/link-rtl.css
@@ -1,7 +1,6 @@
.link-field-column {
float: right;
}
-
.link-field-column.link-field-url .form-text {
direction: ltr;
text-align: left;
diff --git a/sites/all/modules/contrib/fields/link/link.css b/sites/all/modules/contrib/fields/link/link.css
index 1590e7a..6250df7 100644
--- a/sites/all/modules/contrib/fields/link/link.css
+++ b/sites/all/modules/contrib/fields/link/link.css
@@ -2,7 +2,6 @@
float: left;
width: 48%;
}
-
.link-field-column .form-text {
width: 95%;
}
diff --git a/sites/all/modules/contrib/fields/link/link.diff.inc b/sites/all/modules/contrib/fields/link/link.diff.inc
index 9e34123..b01ba6e 100644
--- a/sites/all/modules/contrib/fields/link/link.diff.inc
+++ b/sites/all/modules/contrib/fields/link/link.diff.inc
@@ -11,11 +11,11 @@
function link_field_diff_view($items, $context) {
$diff_items = array();
foreach ($items as $delta => $item) {
- if ($item['url'] && $item['title']) {
+ if ($item['url'] && isset($item['title'])) {
$diff_items[$delta] = $item['title'] . ' (' . $item['url'] . ')';
}
else {
- $diff_items[$delta] = $item['title'] . $item['url'];
+ $diff_items[$delta] = $item['url'];
}
}
return $diff_items;
diff --git a/sites/all/modules/contrib/fields/link/link.info b/sites/all/modules/contrib/fields/link/link.info
index 016b799..351e178 100644
--- a/sites/all/modules/contrib/fields/link/link.info
+++ b/sites/all/modules/contrib/fields/link/link.info
@@ -3,7 +3,6 @@ description = Defines simple link field types.
core = 7.x
package = Fields
-files[] = link.module
files[] = link.migrate.inc
; Tests
@@ -12,15 +11,15 @@ files[] = tests/link.attribute.test
files[] = tests/link.crud.test
files[] = tests/link.crud_browser.test
files[] = tests/link.token.test
+files[] = tests/link.entity_token.test
files[] = tests/link.validate.test
; Views Handlers
files[] = views/link_views_handler_argument_target.inc
files[] = views/link_views_handler_filter_protocol.inc
-; Information added by Drupal.org packaging script on 2014-10-21
-version = "7.x-1.3"
+; Information added by Drupal.org packaging script on 2019-02-20
+version = "7.x-1.6"
core = "7.x"
project = "link"
-datestamp = "1413924830"
-
+datestamp = "1550680687"
diff --git a/sites/all/modules/contrib/fields/link/link.install b/sites/all/modules/contrib/fields/link/link.install
index 14e745d..8125b69 100644
--- a/sites/all/modules/contrib/fields/link/link.install
+++ b/sites/all/modules/contrib/fields/link/link.install
@@ -6,10 +6,38 @@
*/
/**
- * Upgrade notes:
- * Things we need to make sure work when upgrading from Drupal 6 to Drupal 7:
+ * Upgrade notes.
+ *
+ * Things we need to make sure work when upgrading from Drupal 6 to Drupal 7:.
*/
+/**
+ * Implements hook_uninstall().
+ */
+function link_install() {
+ // Notify the user they may want to install token.
+ if (!module_exists('token')) {
+ $t = get_t();
+ drupal_set_message($t('If you install the Token, static title can use any other entity field as its value.', array(
+ '!url' => 'http://drupal.org/project/token',
+ )));
+ }
+}
+
+/**
+ * Removes unused link_extra_domains variable.
+ */
+function link_update_7002() {
+ variable_del('link_extra_domains');
+}
+
+/**
+ * Implements hook_uninstall().
+ */
+function link_uninstall() {
+ variable_del('link_allowed_domains');
+}
+
/**
* Implements hook_field_schema().
*/
@@ -46,19 +74,21 @@ function link_update_last_removed() {
}
/**
- * Handles moving settings data from field_config.data to field_config_instance.data.
+ * Implements hook_update_N().
+ *
+ * Handles moving settings data from field_config.data to
+ * field_config_instance.data.
*/
function link_update_7000() {
-
- // For each field that is a link field, we need to copy the settings from the general field level down to the instance.
- //$field_data = array();
+
+ // For each field that is a link field, we need to copy the settings from the
+ // general field level down to the instance.
$result = db_query("SELECT id, field_name, data FROM {field_config} WHERE module = 'link' AND type = 'link_field'");
foreach ($result as $field) {
- $field_id = $field->id;
- $name = $field->field_name;
+
$field_data = unserialize($field->data);
-
- $instances = db_query("SELECT id, data FROM {field_config_instance} WHERE field_id = :field_id", array(':field_id' => $field_id));
+
+ $instances = db_query("SELECT id, data FROM {field_config_instance} WHERE field_id = :field_id", array(':field_id' => $field->id));
foreach ($instances as $instance) {
// If this field has been updated already, we want to skip it.
$instance_data = unserialize($instance->data);
@@ -71,8 +101,8 @@ function link_update_7000() {
}
}
if ($update_instance) {
- // update the database.
- $num_updated = db_update('field_config_instance')
+ // Update the database.
+ db_update('field_config_instance')
->fields(array('data' => serialize($instance_data)))
->condition('id', $instance->id)
->execute();
@@ -80,22 +110,19 @@ function link_update_7000() {
}
}
}
-
+
return t("Instance settings have been set with the data from the field settings.");
}
/**
- * Renames all displays from foobar to link_foobar
+ * Renames all displays from foobar to link_foobar.
*/
function link_update_7001() {
// Update the display type for each link field type.
$result = db_query("SELECT id, field_name, data FROM {field_config} WHERE module = 'link' AND type = 'link_field'");
foreach ($result as $field) {
- $field_id = $field->id;
- $name = $field->field_name;
- $field_data = unserialize($field->data);
-
- $instances = db_query("SELECT id, data FROM {field_config_instance} WHERE field_id = :field_id", array(':field_id' => $field_id));
+
+ $instances = db_query("SELECT id, data FROM {field_config_instance} WHERE field_id = :field_id", array(':field_id' => $field->id));
foreach ($instances as $instance) {
// If this field has been updated already, we want to skip it.
$instance_data = unserialize($instance->data);
diff --git a/sites/all/modules/contrib/fields/link/link.migrate.inc b/sites/all/modules/contrib/fields/link/link.migrate.inc
index fc8363f..4900051 100644
--- a/sites/all/modules/contrib/fields/link/link.migrate.inc
+++ b/sites/all/modules/contrib/fields/link/link.migrate.inc
@@ -11,11 +11,9 @@
* $this->addFieldMapping('field_my_link', 'source_url');
* $this->addFieldMapping('field_my_link:title', 'source_title');
* $this->addFieldMapping('field_my_link:attributes', 'source_attributes');
- * @endcode
*
- * With earlier versions of Migrate, you must pass an arguments array:
+ * # With earlier versions of Migrate, you must pass an arguments array:
*
- * @code
* $link_args = array(
* 'title' => array('source_field' => 'source_title'),
* 'attributes' => array('source_field' => 'source_attributes'),
@@ -25,6 +23,10 @@
* @endcode
*/
+if (!class_exists('MigrateFieldHandler')) {
+ return;
+}
+
/**
* Implements hook_migrate_api().
*/
@@ -35,12 +37,20 @@ function link_migrate_api() {
);
}
+// @codingStandardsIgnoreLine
class MigrateLinkFieldHandler extends MigrateFieldHandler {
+
+ /**
+ * Construct.
+ */
public function __construct() {
$this->registerTypes(array('link_field'));
}
- static function arguments($title = NULL, $attributes = NULL, $language = NULL) {
+ /**
+ * Arguments.
+ */
+ public static function arguments($title = NULL, $attributes = NULL, $language = NULL) {
$arguments = array();
if (!is_null($title)) {
$arguments['title'] = $title;
@@ -57,16 +67,21 @@ class MigrateLinkFieldHandler extends MigrateFieldHandler {
/**
* Implementation of MigrateFieldHandler::fields().
*
- * @param $type
- * The field type.
- * @param $instance
- * Instance info for the field.
+ * @param array $type
+ * The field type.
+ * @param array $instance
+ * Instance info for the field.
* @param Migration $migration
- * The migration context for the parent field. We can look at the mappings
- * and determine which subfields are relevant.
+ * The migration context for the parent field. We can look at the mappings
+ * and determine which subfields are relevant.
+ *
* @return array
+ * Array with values.
+ *
+ * @codingStandardsIgnoreStart
*/
public function fields($type, $instance, $migration = NULL) {
+ // @codingStandardsIgnoreEnd
return array(
'title' => t('Subfield: The link title attribute'),
'attributes' => t('Subfield: The attributes for this link'),
@@ -74,6 +89,9 @@ class MigrateLinkFieldHandler extends MigrateFieldHandler {
);
}
+ /**
+ * Prepare.
+ */
public function prepare($entity, array $field_info, array $instance, array $values) {
if (isset($values['arguments'])) {
$arguments = $values['arguments'];
@@ -105,9 +123,17 @@ class MigrateLinkFieldHandler extends MigrateFieldHandler {
}
}
$item['url'] = $value;
- $return[$language][$delta] = $item;
+
+ if (is_array($language)) {
+ $current_language = $language[$delta];
+ }
+ else {
+ $current_language = $language;
+ }
+ $return[$current_language][$delta] = $item;
}
return isset($return) ? $return : NULL;
}
+
}
diff --git a/sites/all/modules/contrib/fields/link/link.module b/sites/all/modules/contrib/fields/link/link.module
index b0c53c3..8b3094f 100644
--- a/sites/all/modules/contrib/fields/link/link.module
+++ b/sites/all/modules/contrib/fields/link/link.module
@@ -10,8 +10,6 @@ define('LINK_INTERNAL', 'internal');
define('LINK_FRONT', 'front');
define('LINK_EMAIL', 'email');
define('LINK_NEWS', 'news');
-define('LINK_DOMAINS', 'aero|arpa|asia|biz|build|com|cat|ceo|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|post|pro|tel|travel|mobi|local|xxx');
-
define('LINK_TARGET_DEFAULT', 'default');
define('LINK_TARGET_NEW_WINDOW', '_blank');
define('LINK_TARGET_TOP', '_top');
@@ -22,6 +20,22 @@ define('LINK_TARGET_USER', 'user');
*/
define('LINK_URL_MAX_LENGTH', 2048);
+/**
+ * Implements hook_help().
+ */
+function link_help($path, $arg) {
+ switch ($path) {
+ case 'admin/help#link':
+ $output = '
About
';
+ $output .= '
' . 'The link provides a standard custom content field for links. Links can be easily added to any content types and profiles and include advanced validating and different ways of storing internal or external links and URLs. It also supports additional link text title, site wide tokens for titles and title attributes, target attributes, css class attribution, static repeating values, input conversion, and many more.' . '
';
+ $output .= '
' . 'Requirements / Dependencies' . '
';
+ $output .= '
' . 'Fields API is provided already by core [no dependencies].' . '
';
+ $output .= '
Configuration
';
+ $output .= '
' . 'Configuration is only slightly more complicated than a text field. Link text titles for URLs can be made required, set as instead of URL, optional (default), or left out entirely. If no link text title is provided, the trimmed version of the complete URL will be displayed. The target attribute should be set to "_blank", "top", or left out completely (checkboxes provide info). The rel=nofollow attribute prevents the link from being followed by certain search engines.' . '
';
+ return $output;
+ }
+}
+
/**
* Implements hook_field_info().
*/
@@ -98,6 +112,7 @@ function link_field_instance_settings_form($field, $instance) {
'optional' => t('Optional Title'),
'required' => t('Required Title'),
'value' => t('Static Title'),
+ 'select' => t('Selected Title'),
'none' => t('No Title'),
);
@@ -111,9 +126,26 @@ function link_field_instance_settings_form($field, $instance) {
$form['title_value'] = array(
'#type' => 'textfield',
- '#title' => t('Static title'),
+ '#title' => t('Static or default title'),
'#default_value' => isset($instance['settings']['title_value']) ? $instance['settings']['title_value'] : '',
- '#description' => t('This title will always be used if “Static Title” is selected above.'),
+ '#description' => t('This title will 1) always be used if "Static Title" is selected above, or 2) used if "Optional title" is selected above and no title is entered when creating content.'),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="instance[settings][title]"]' => array('value' => 'value'),
+ ),
+ ),
+ );
+
+ $form['title_allowed_values'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Title allowed values'),
+ '#default_value' => isset($instance['settings']['title_allowed_values']) ? $instance['settings']['title_allowed_values'] : '',
+ '#description' => t('When using "Selected Title", you can allow users to select the title from a limited set of values (eg. Home, Office, Other). Enter here all possible values that title can take, one value per line.'),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="instance[settings][title]"]' => array('value' => 'select'),
+ ),
+ ),
);
$form['title_label_use_field_label'] = array(
@@ -181,7 +213,7 @@ function link_field_instance_settings_form($field, $instance) {
$form['attributes']['rel'] = array(
'#type' => 'textfield',
'#title' => t('Rel Attribute'),
- '#description' => t('When output, this link will have this rel attribute. The most common usage is rel="nofollow" which prevents some search engines from spidering entered links.'),
+ '#description' => t('When output, this link will have this rel attribute. The most common usage is rel="nofollow" which prevents some search engines from spidering entered links.'),
'#default_value' => empty($instance['settings']['attributes']['rel']) ? '' : $instance['settings']['attributes']['rel'],
'#field_prefix' => 'rel = "',
'#field_suffix' => '"',
@@ -207,7 +239,7 @@ function link_field_instance_settings_form($field, $instance) {
$form['attributes']['class'] = array(
'#type' => 'textfield',
'#title' => t('Additional CSS Class'),
- '#description' => t('When output, this link will have this class attribute. Multiple classes should be separated by spaces.'),
+ '#description' => t('When output, this link will have this class attribute. Multiple classes should be separated by spaces. Only alphanumeric characters and hyphens are allowed'),
'#default_value' => empty($instance['settings']['attributes']['class']) ? '' : $instance['settings']['attributes']['class'],
);
$form['attributes']['configurable_title'] = array(
@@ -218,7 +250,7 @@ function link_field_instance_settings_form($field, $instance) {
$form['attributes']['title'] = array(
'#title' => t("Default link 'title' Attribute"),
'#type' => 'textfield',
- '#description' => t('When output, links will use this "title" attribute if the user does not provide one and when different from the link text. Read WCAG 1.0 Guidelines for links comformances. Tokens values will be evaluated.'),
+ '#description' => t('When output, links will use this "title" attribute if the user does not provide one and when different from the link text. Read WCAG 1.0 Guidelines for links comformances. Tokens values will be evaluated.'),
'#default_value' => empty($instance['settings']['attributes']['title']) ? '' : $instance['settings']['attributes']['title'],
'#field_prefix' => 'title = "',
'#field_suffix' => '"',
@@ -228,11 +260,17 @@ function link_field_instance_settings_form($field, $instance) {
}
/**
+ * Form validate.
+ *
* #element_validate handler for link_field_instance_settings_form().
*/
function link_field_settings_form_validate($element, &$form_state, $complete_form) {
if ($form_state['values']['instance']['settings']['title'] === 'value' && empty($form_state['values']['instance']['settings']['title_value'])) {
- form_set_error('title_value', t('A default title must be provided if the title is a static value.'));
+ form_set_error('instance][settings][title_value', t('A default title must be provided if the title is a static value.'));
+ }
+ if ($form_state['values']['instance']['settings']['title'] === 'select'
+ && empty($form_state['values']['instance']['settings']['title_allowed_values'])) {
+ form_set_error('instance][settings][title_allowed_values', t('You must enter one or more allowed values for link Title, the title is a selected value.'));
}
if (!empty($form_state['values']['instance']['settings']['display']['url_cutoff']) && !is_numeric($form_state['values']['instance']['settings']['display']['url_cutoff'])) {
form_set_error('display', t('URL Display Cutoff value must be numeric.'));
@@ -277,6 +315,16 @@ function link_field_validate($entity_type, $entity, $field, $instance, $langcode
}
}
+ foreach ($items as $delta => $value) {
+ if (isset($value['attributes']) && is_string($value['attributes'])) {
+ $errors[$field['field_name']][$langcode][$delta][] = array(
+ 'error' => 'link_required',
+ 'message' => t('String values are not acceptable for attributes.'),
+ 'error_element' => array('url' => TRUE, 'title' => FALSE),
+ );
+ }
+ }
+
if ($instance['settings']['url'] === 'optional' && $instance['settings']['title'] === 'optional' && $instance['required'] && !$optional_field_found) {
$errors[$field['field_name']][$langcode][0][] = array(
'error' => 'link_required',
@@ -291,7 +339,7 @@ function link_field_validate($entity_type, $entity, $field, $instance, $langcode
*/
function link_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
foreach ($items as $delta => $value) {
- _link_process($items[$delta], $delta, $field, $entity);
+ _link_process($items[$delta], $delta, $field, $entity, $instance);
}
}
@@ -300,7 +348,7 @@ function link_field_insert($entity_type, $entity, $field, $instance, $langcode,
*/
function link_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) {
foreach ($items as $delta => $value) {
- _link_process($items[$delta], $delta, $field, $entity);
+ _link_process($items[$delta], $delta, $field, $entity, $instance);
}
}
@@ -343,10 +391,10 @@ function link_field_widget_form(&$form, &$form_state, $field, $instance, $langco
* Implements hook_field_widget_error().
*/
function link_field_widget_error($element, $error, $form, &$form_state) {
- if ($error['error_element']['title']) {
+ if (!empty($error['error_element']['title'])) {
form_error($element['title'], $error['message']);
}
- elseif ($error['error_element']['url']) {
+ elseif (!empty($error['error_element']['url'])) {
form_error($element['url'], $error['message']);
}
}
@@ -371,8 +419,22 @@ function _link_load($field, $item, $instance) {
/**
* Prepares the item attributes and url for storage.
+ *
+ * @param array $item
+ * Link field values.
+ * @param array $delta
+ * The sequence number for current values.
+ * @param array $field
+ * The field structure array.
+ * @param object $entity
+ * Entity object.
+ * @param array $instance
+ * The instance structure for $field on $entity's bundle.
+ *
+ * @codingStandardsIgnoreStart
*/
-function _link_process(&$item, $delta, $field, $entity) {
+function _link_process(&$item, $delta, $field, $entity, $instance) {
+ // @codingStandardsIgnoreEnd
// Trim whitespace from URL.
if (!empty($item['url'])) {
$item['url'] = trim($item['url']);
@@ -391,7 +453,8 @@ function _link_process(&$item, $delta, $field, $entity) {
// Don't save an invalid default value (e.g. 'http://').
if ((isset($field['widget']['default_value'][$delta]['url']) && $item['url'] == $field['widget']['default_value'][$delta]['url']) && is_object($entity)) {
- if (!link_validate_url($item['url'])) {
+ $langcode = !empty($entity) ? field_language($instance['entity_type'], $entity, $instance['field_name']) : LANGUAGE_NONE;
+ if (!link_validate_url($item['url'], $langcode)) {
unset($item['url']);
}
}
@@ -403,7 +466,7 @@ function _link_process(&$item, $delta, $field, $entity) {
function _link_validate(&$item, $delta, $field, $entity, $instance, $langcode, &$optional_field_found, &$errors) {
if ($item['url'] && !(isset($instance['default_value'][$delta]['url']) && $item['url'] === $instance['default_value'][$delta]['url'] && !$instance['required'])) {
// Validate the link.
- if (link_validate_url(trim($item['url'])) == FALSE) {
+ if (!link_validate_url(trim($item['url']), $langcode)) {
$errors[$field['field_name']][$langcode][$delta][] = array(
'error' => 'link_required',
'message' => t('The value %value provided for %field is not a valid URL.', array(
@@ -430,9 +493,10 @@ function _link_validate(&$item, $delta, $field, $entity, $instance, $langcode, &
'error_element' => array('url' => TRUE, 'title' => FALSE),
);
}
- // In a totally bizzaro case, where URLs and titles are optional but the field is required, ensure there is at least one link.
+ // In a totally bizzaro case, where URLs and titles are optional but the field
+ // is required, ensure there is at least one link.
if ($instance['settings']['url'] === 'optional' && $instance['settings']['title'] === 'optional'
- && (strlen(trim($item['url'])) !== 0 || strlen(trim($item['title'])) !== 0)) {
+ && (strlen(trim($item['url'])) !== 0 || strlen(trim($item['title'])) !== 0)) {
$optional_field_found = TRUE;
}
// Require entire field.
@@ -448,16 +512,19 @@ function _link_validate(&$item, $delta, $field, $entity, $instance, $langcode, &
/**
* Clean up user-entered values for a link field according to field settings.
*
- * @param array $item
+ * @param array $item
* A single link item, usually containing url, title, and attributes.
- * @param int $delta
+ * @param int $delta
* The delta value if this field is one of multiple fields.
- * @param array $field
+ * @param array $field
* The CCK field definition.
- * @param object $entity
+ * @param object $entity
* The entity containing this link.
+ *
+ * @codingStandardsIgnoreStart
*/
function _link_sanitize(&$item, $delta, &$field, $instance, &$entity) {
+ // @codingStandardsIgnoreEnd
// Don't try to process empty links.
if (empty($item['url']) && empty($item['title'])) {
return;
@@ -471,22 +538,24 @@ function _link_sanitize(&$item, $delta, &$field, $instance, &$entity) {
$entity_info = entity_get_info($entity_type);
$property_id = $entity_info['entity keys']['id'];
$entity_token_type = isset($entity_info['token type']) ? $entity_info['token type'] : (
- $entity_type == 'taxonomy_term' || $entity_type == 'taxonomy_vocabulary' ? str_replace('taxonomy_', '', $entity_type) : $entity_type
+ $entity_type == 'taxonomy_term' || $entity_type == 'taxonomy_vocabulary' ? str_replace('taxonomy_', '', $entity_type) : $entity_type
);
if (isset($instance['settings']['enable_tokens']) && $instance['settings']['enable_tokens']) {
- global $user;
- // Load the entity if necessary for entities in views.
- if (isset($entity->{$property_id})) {
- $entity_loaded = entity_load($entity_type, array($entity->{$property_id}));
- $entity_loaded = array_pop($entity_loaded);
+ $text_tokens = token_scan($item['url']);
+ if (!empty($text_tokens)) {
+ // Load the entity if necessary for entities in views.
+ if (isset($entity->{$property_id})) {
+ $entity_loaded = entity_load($entity_type, array($entity->{$property_id}));
+ $entity_loaded = array_pop($entity_loaded);
+ }
+ else {
+ $entity_loaded = $entity;
+ }
+ $item['url'] = token_replace($item['url'], array($entity_token_type => $entity_loaded));
}
- else {
- $entity_loaded = $entity;
- }
- $item['url'] = token_replace($item['url'], array($entity_token_type => $entity_loaded));
}
- $type = link_validate_url($item['url']);
+ $type = link_url_type($item['url']);
// If the type of the URL cannot be determined and URL validation is disabled,
// then assume LINK_EXTERNAL for later processing.
if ($type == FALSE && $instance['settings']['validate_url'] === 0) {
@@ -496,12 +565,13 @@ function _link_sanitize(&$item, $delta, &$field, $instance, &$entity) {
$url_parts = _link_parse_url($url);
if (!empty($url_parts['url'])) {
- $item['url'] = $url_parts['url'];
- $item += array(
- 'query' => isset($url_parts['query']) ? $url_parts['query'] : NULL,
- 'fragment' => isset($url_parts['fragment']) ? $url_parts['fragment'] : NULL,
- 'absolute' => !empty($instance['settings']['absolute_url']),
- 'html' => TRUE,
+ $item['url'] = url($url_parts['url'],
+ array(
+ 'query' => isset($url_parts['query']) ? $url_parts['query'] : NULL,
+ 'fragment' => isset($url_parts['fragment']) ? $url_parts['fragment'] : NULL,
+ 'absolute' => !empty($instance['settings']['absolute_url']),
+ 'html' => TRUE,
+ )
);
}
@@ -532,28 +602,51 @@ function _link_sanitize(&$item, $delta, &$field, $instance, &$entity) {
}
}
// Use the title defined by the user at the widget level.
- elseif (isset($item['title'])) {
+ elseif (drupal_strlen(trim($item['title']))) {
$title = $item['title'];
}
+ // Use the static title if a user-defined title is optional and a static title
+ // has been defined.
+ elseif ($instance['settings']['title'] == 'optional' && drupal_strlen(trim($instance['settings']['title_value']))) {
+ $title = $instance['settings']['title_value'];
+ }
else {
$title = '';
}
// Replace title tokens.
+ if ($title && $instance['settings']['enable_tokens']) {
+ $text_tokens = token_scan($title);
+ if (!empty($text_tokens)) {
+ // Load the entity if necessary for entities in views.
+ if (isset($entity->{$property_id})) {
+ $entity_loaded = entity_load($entity_type, array($entity->{$property_id}));
+ $entity_loaded = array_pop($entity_loaded);
+ }
+ else {
+ $entity_loaded = $entity;
+ }
+ $title = token_replace($title, array($entity_token_type => $entity_loaded));
+ }
+ }
if ($title && ($instance['settings']['title'] == 'value' || $instance['settings']['enable_tokens'])) {
- // Load the entity if necessary for entities in views.
- if (isset($entity->{$property_id})) {
- $entity_loaded = entity_load($entity_type, array($entity->{$property_id}));
- $entity_loaded = array_pop($entity_loaded);
- }
- else {
- $entity_loaded = $entity;
- }
- $title = token_replace($title, array($entity_token_type => $entity_loaded));
- $title = filter_xss($title, array('b', 'br', 'code', 'em', 'i', 'img', 'span', 'strong', 'sub', 'sup', 'tt', 'u'));
+ $title = filter_xss($title, array(
+ 'b',
+ 'br',
+ 'code',
+ 'em',
+ 'i',
+ 'img',
+ 'span',
+ 'strong',
+ 'sub',
+ 'sup',
+ 'tt',
+ 'u',
+ ));
$item['html'] = TRUE;
}
- $item['title'] = empty($title) ? $item['display_url'] : $title;
+ $item['title'] = empty($title) && $title !== '0' ? $item['display_url'] : $title;
if (!isset($item['attributes'])) {
$item['attributes'] = array();
@@ -599,22 +692,38 @@ function _link_sanitize(&$item, $delta, &$field, $instance, &$entity) {
// Handle "title" link attribute.
if (!empty($item['attributes']['title']) && module_exists('token')) {
- // Load the entity (necessary for entities in views).
- if (isset($entity->{$property_id})) {
- $entity_loaded = entity_load($entity_type, array($entity->{$property_id}));
- $entity_loaded = array_pop($entity_loaded);
+ $text_tokens = token_scan($item['attributes']['title']);
+ if (!empty($text_tokens)) {
+ // Load the entity (necessary for entities in views).
+ if (isset($entity->{$property_id})) {
+ $entity_loaded = entity_load($entity_type, array($entity->{$property_id}));
+ $entity_loaded = array_pop($entity_loaded);
+ }
+ else {
+ $entity_loaded = $entity;
+ }
+ $item['attributes']['title'] = token_replace($item['attributes']['title'], array($entity_token_type => $entity_loaded));
}
- else {
- $entity_loaded = $entity;
- }
- $item['attributes']['title'] = token_replace($item['attributes']['title'], array($entity_token_type => $entity_loaded));
- $item['attributes']['title'] = filter_xss($item['attributes']['title'], array('b', 'br', 'code', 'em', 'i', 'img', 'span', 'strong', 'sub', 'sup', 'tt', 'u'));
+ $item['attributes']['title'] = filter_xss($item['attributes']['title'], array(
+ 'b',
+ 'br',
+ 'code',
+ 'em',
+ 'i',
+ 'img',
+ 'span',
+ 'strong',
+ 'sub',
+ 'sup',
+ 'tt',
+ 'u',
+ ));
}
// Handle attribute classes.
if (!empty($item['attributes']['class'])) {
$classes = explode(' ', $item['attributes']['class']);
foreach ($classes as &$class) {
- $class = drupal_html_class($class);
+ $class = drupal_clean_css_identifier($class);
}
$item['attributes']['class'] = implode(' ', $classes);
}
@@ -660,7 +769,8 @@ function _link_parse_url($url) {
* Replaces the PHP parse_str() function.
*
* Because parse_str replaces the following characters in query parameters name
- * in order to maintain compability with deprecated register_globals directive:
+ * in order to maintain compatibility with deprecated register_globals
+ * directive:
*
* - chr(32) ( ) (space)
* - chr(46) (.) (dot)
@@ -700,11 +810,21 @@ function link_theme() {
'link_formatter_link_plain' => array(
'variables' => array('element' => NULL, 'field' => NULL),
),
+ 'link_formatter_link_host' => array(
+ 'variables' => array('element' => NULL),
+ ),
'link_formatter_link_absolute' => array(
'variables' => array('element' => NULL, 'field' => NULL),
),
'link_formatter_link_domain' => array(
- 'variables' => array('element' => NULL, 'display' => NULL, 'field' => NULL),
+ 'variables' => array(
+ 'element' => NULL,
+ 'display' => NULL,
+ 'field' => NULL,
+ ),
+ ),
+ 'link_formatter_link_no_protocol' => array(
+ 'variables' => array('element' => NULL, 'field' => NULL),
),
'link_formatter_link_title_plain' => array(
'variables' => array('element' => NULL, 'field' => NULL),
@@ -791,7 +911,8 @@ function _link_default_attributes() {
* Build the form element. When creating a form using FAPI #process,
* note that $element['#value'] is already set.
*
- * The $fields array is in $complete_form['#field_info'][$element['#field_name']].
+ * The $fields array is in
+ * $complete_form['#field_info'][$element['#field_name']].
*/
function link_field_process($element, $form_state, $complete_form) {
$instance = field_widget_instance($element, $form_state);
@@ -803,7 +924,7 @@ function link_field_process($element, $form_state, $complete_form) {
'#required' => ($element['#delta'] == 0 && $settings['url'] !== 'optional') ? $element['#required'] : FALSE,
'#default_value' => isset($element['#value']['url']) ? $element['#value']['url'] : NULL,
);
- if ($settings['title'] !== 'none' && $settings['title'] !== 'value') {
+ if (in_array($settings['title'], array('optional', 'required'))) {
// Figure out the label of the title field.
if (!empty($settings['title_label_use_field_label'])) {
// Use the element label as the title field label.
@@ -815,15 +936,31 @@ function link_field_process($element, $form_state, $complete_form) {
$title_label = t('Title');
}
+ // Default value.
+ $title_maxlength = 128;
+ if (!empty($settings['title_maxlength'])) {
+ $title_maxlength = $settings['title_maxlength'];
+ }
+
$element['title'] = array(
'#type' => 'textfield',
- '#maxlength' => $settings['title_maxlength'],
+ '#maxlength' => $title_maxlength,
'#title' => $title_label,
- '#description' => t('The link title is limited to @maxlength characters maximum.', array('@maxlength' => $settings['title_maxlength'])),
+ '#description' => t('The link title is limited to @maxlength characters maximum.', array('@maxlength' => $title_maxlength)),
'#required' => ($settings['title'] == 'required' && (($element['#delta'] == 0 && $element['#required']) || !empty($element['#value']['url']))) ? TRUE : FALSE,
'#default_value' => isset($element['#value']['title']) ? $element['#value']['title'] : NULL,
);
}
+ elseif ($settings['title'] == 'select') {
+ $options = drupal_map_assoc(array_filter(explode("\n", str_replace("\r", "\n", trim($settings['title_allowed_values'])))));
+ $element['title'] = array(
+ '#type' => 'select',
+ '#title' => t('Title'),
+ '#description' => t('Select the a title for this link.'),
+ '#default_value' => isset($element['#value']['title']) ? $element['#value']['title'] : NULL,
+ '#options' => $options,
+ );
+ }
// Initialize field attributes as an array if it is not an array yet.
if (!is_array($settings['attributes'])) {
@@ -859,8 +996,9 @@ function link_field_process($element, $form_state, $complete_form) {
);
}
- // If the title field is avaliable or there are field accepts multiple values
- // then allow the individual field items display the required asterisk if needed.
+ // If the title field is available or there are field accepts multiple values
+ // then allow the individual field items display the required asterisk if
+ // needed.
if (isset($element['title']) || isset($element['_weight'])) {
// To prevent an extra required indicator, disable the required flag on the
// base element since all the sub-fields are already required if desired.
@@ -885,6 +1023,11 @@ function link_field_formatter_info() {
'field types' => array('link_field'),
'multiple values' => FIELD_BEHAVIOR_DEFAULT,
),
+ 'link_host' => array(
+ 'label' => t('Host, as plain text'),
+ 'field types' => array('link_field'),
+ 'multiple values' => FIELD_BEHAVIOR_DEFAULT,
+ ),
'link_url' => array(
'label' => t('URL, as link'),
'field types' => array('link_field'),
@@ -908,6 +1051,11 @@ function link_field_formatter_info() {
'strip_www' => FALSE,
),
),
+ 'link_no_protocol' => array(
+ 'label' => t('URL with the protocol removed'),
+ 'field types' => array('link_field'),
+ 'multiple values' => FIELD_BEHAVIOR_DEFAULT,
+ ),
'link_short' => array(
'label' => t('Short, as link with title "Link"'),
'field types' => array('link_field'),
@@ -947,8 +1095,9 @@ function link_field_formatter_settings_form($field, $instance, $view_mode, $form
* Implements hook_field_formatter_settings_summary().
*/
function link_field_formatter_settings_summary($field, $instance, $view_mode) {
+
$display = $instance['display'][$view_mode];
- $settings = $display['settings'];
+
if ($display['type'] == 'link_domain') {
if ($display['settings']['strip_www']) {
return t('Strip www. from domain');
@@ -993,7 +1142,7 @@ function theme_link_formatter_link_default($vars) {
}
// If only a title, display the title.
elseif (!empty($vars['element']['title'])) {
- return $link_options['html'] ? $vars['element']['title'] : check_plain($vars['element']['title']);
+ return !empty($link_options['html']) ? $vars['element']['title'] : check_plain($vars['element']['title']);
}
elseif (!empty($vars['element']['url'])) {
return l($vars['element']['title'], $vars['element']['url'], $link_options);
@@ -1015,6 +1164,14 @@ function theme_link_formatter_link_plain($vars) {
return empty($vars['element']['url']) ? check_plain($vars['element']['title']) : url($vars['element']['url'], $link_options);
}
+/**
+ * Theme function for 'host' text field formatter.
+ */
+function theme_link_formatter_link_host($vars) {
+ $host = @parse_url($vars['element']['url']);
+ return isset($host['host']) ? check_plain($host['host']) : '';
+}
+
/**
* Formats a link as an absolute URL.
*/
@@ -1037,11 +1194,27 @@ function theme_link_formatter_link_domain($vars) {
return $vars['element']['url'] ? l($domain, $vars['element']['url'], $link_options) : '';
}
+/**
+ * Formats a link without the http:// or https://.
+ */
+function theme_link_formatter_link_no_protocol($vars) {
+ $link_options = $vars['element'];
+ unset($link_options['title']);
+ unset($link_options['url']);
+ // We drop any scheme of the url.
+ $scheme = parse_url($vars['element']['url']);
+ $search = '/' . preg_quote($scheme['scheme'] . '://', '/') . '/';
+ $replace = '';
+ $display_url = preg_replace($search, $replace, $vars['element']['url'], 1);
+
+ return $vars['element']['url'] ? l($display_url, $vars['element']['url'], $link_options) : '';
+}
+
/**
* Formats a link's title as plain text.
*/
function theme_link_formatter_link_title_plain($vars) {
- return empty($vars['element']['title']) ? '' : check_plain($vars['element']['title']);
+ return empty($vars['element']['title']) ? '' : check_plain(decode_entities($vars['element']['title']));
}
/**
@@ -1101,7 +1274,8 @@ function theme_link_formatter_link_separate($vars) {
/**
* Implements hook_token_list().
*
- * @TODO: hook_token_list no longer exists - this should change to hook_token_info().
+ * @TODO: hook_token_list no longer exists - this should change to
+ * hook_token_info().
*/
function link_token_list($type = 'all') {
if ($type === 'field' || $type === 'all') {
@@ -1116,7 +1290,8 @@ function link_token_list($type = 'all') {
/**
* Implements hook_token_values().
*
- * @TODO: hook_token_values no longer exists - this should change to hook_tokens().
+ * @TODO: hook_token_values no longer exists - this should change to
+ * hook_tokens().
*/
function link_token_values($type, $object = NULL) {
if ($type === 'field') {
@@ -1142,26 +1317,27 @@ function link_views_api() {
/**
* Forms a valid URL if possible from an entered address.
- *
+ *
* Trims whitespace and automatically adds an http:// to addresses without a
- * protocol specified
+ * protocol specified.
*
* @param string $url
* The url entered by the user.
* @param string $protocol
- * The protocol to be prepended to the url if one is not specified
+ * The protocol to be prepended to the url if one is not specified.
*/
function link_cleanup_url($url, $protocol = 'http') {
$url = trim($url);
- $type = link_validate_url($url);
+ $type = link_url_type($url);
if ($type === LINK_EXTERNAL) {
// Check if there is no protocol specified.
$protocol_match = preg_match("/^([a-z0-9][a-z0-9\.\-_]*:\/\/)/i", $url);
if (empty($protocol_match)) {
- // But should there be? Add an automatic http:// if it starts with a domain name.
- $LINK_DOMAINS = _link_domains();
- $domain_match = preg_match('/^(([a-z0-9]([a-z0-9\-_]*\.)+)(' . $LINK_DOMAINS . '|[a-z]{2}))/i', $url);
+ // But should there be? Add an automatic http:// if it starts with a
+ // domain name.
+ $link_domains = _link_domains();
+ $domain_match = preg_match('/^(([a-z0-9]([a-z0-9\-_]*\.)+)(' . $link_domains . '|[a-z]{2}))/i', $url);
if (!empty($domain_match)) {
$url = $protocol . "://" . $url;
}
@@ -1173,109 +1349,207 @@ function link_cleanup_url($url, $protocol = 'http') {
/**
* Validates a URL.
- *
+ *
+ * @param string $text
+ * Url to be validated.
+ * @param string $langcode
+ * An optional language code to look up the path in.
+ *
+ * @return bool
+ * True if a valid link, FALSE otherwise.
+ */
+function link_validate_url($text, $langcode = NULL) {
+
+ $text = _link_clean_relative($text);
+ $text = link_cleanup_url($text);
+ $type = link_url_type($text);
+
+ if ($type && ($type == LINK_INTERNAL || $type == LINK_EXTERNAL)) {
+ $flag = valid_url($text, TRUE);
+ if (!$flag) {
+ $normal_path = drupal_get_normal_path($text, $langcode);
+ $parsed_link = parse_url($normal_path, PHP_URL_PATH);
+ if ($normal_path != $parsed_link) {
+ $normal_path = $parsed_link;
+ }
+ $flag = drupal_valid_path($normal_path);
+ }
+ if (!$flag) {
+ $flag = file_exists($normal_path);
+ }
+ if (!$flag) {
+ $uri = file_build_uri($normal_path);
+ $flag = file_exists($uri);
+ }
+ }
+ else {
+ $flag = (bool) $type;
+ }
+
+ return $flag;
+}
+
+/**
+ * Cleaner of relatives urls.
+ *
+ * @param string $url
+ * The url to clean up the relative protocol.
+ */
+function _link_clean_relative($url) {
+ $check = substr($url, 0, 2);
+ if (isset($_SERVER['HTTPS']) &&
+ ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
+ isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
+ $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
+ $protocol = 'https://';
+ }
+ else {
+ $protocol = 'http://';
+ }
+
+ if ($check == '//') {
+ $url = str_replace('//', $protocol, $url);
+ }
+
+ return $url;
+}
+
+/**
+ * Type check a URL.
+ *
* Accepts all URLs following RFC 1738 standard for URL formation and all e-mail
* addresses following the RFC 2368 standard for mailto address formation.
*
* @param string $text
- * Url to be validated.
- *
+ * Url to be checked.
+ *
* @return mixed
* Returns boolean FALSE if the URL is not valid. On success, returns one of
* the LINK_(linktype) constants.
*/
-function link_validate_url($text) {
+function link_url_type($text) {
// @TODO Complete letters.
- $LINK_ICHARS_DOMAIN = (string) html_entity_decode(implode("", array(
- "æ", // æ
- "Æ", // Æ
+ // @codingStandardsIgnoreStart
+ $link_ichars_domain = (string) html_entity_decode(implode("", array(
+ "¿", // ¿
"À", // À
- "à", // à
"Á", // Á
- "á", // á
"Â", // Â
- "â", // â
- "å", // å
- "Å", // Å
- "ä", // ä
+ "Ã", // Ã
"Ä", // Ä
+ "Å", // Å
+ "Æ", // Æ
"Ç", // Ç
- "ç", // ç
- "Ð", // Ð
- "ð", // ð
"È", // È
- "è", // è
"É", // É
- "é", // é
"Ê", // Ê
- "ê", // ê
"Ë", // Ë
- "ë", // ë
+ "Ì", // Ì
+ "Í", // Í
"Î", // Î
- "î", // î
"Ï", // Ï
- "ï", // ï
- "ø", // ø
- "Ø", // Ø
- "ö", // ö
- "Ö", // Ö
+ "Ð", // Ð
+ "Ñ", // Ñ
+ "Ò", // Ò
+ "Ó", // Ó
"Ô", // Ô
- "ô", // ô
"Õ", // Õ
+ "Ö", // Ö
+ // ×
+ "Ø", // Ø
+ "Ù", // Ù
+ "Ú", // Ú
+ "Û", // Û
+ "Ü", // Ü
+ "Ý", // Ý
+ "Þ", // Þ
+ // ß (see LINK_ICHARS)
+ "à", // à
+ "á", // á
+ "â", // â
+ "ã", // ã
+ "ä", // ä
+ "å", // å
+ "æ", // æ
+ "ç", // ç
+ "è", // è
+ "é", // é
+ "ê", // ê
+ "ë", // ë
+ "ì", // ì
+ "í", // í
+ "î", // î
+ "ï", // ï
+ "ð", // ð
+ "ñ", // ñ
+ "ò", // ò
+ "ó", // ó
+ "ô", // ô
"õ", // õ
+ "ö", // ö
+ // ÷
+ "ø", // ø
+ "ù", // ù
+ "ú", // ú
+ "û", // û
+ "ü", // ü
+ "ý", // ý
+ "þ", // þ
+ "ÿ", // ÿ
"Œ", // Œ
"œ", // œ
- "ü", // ü
- "Ü", // Ü
- "Ù", // Ù
- "ù", // ù
- "Û", // Û
- "û", // û
"Ÿ", // Ÿ
- "ÿ", // ÿ
- "Ñ", // Ñ
- "ñ", // ñ
- "þ", // þ
- "Þ", // Þ
- "ý", // ý
- "Ý", // Ý
- "¿", // ¿
)), ENT_QUOTES, 'UTF-8');
+ // @codingStandardsIgnoreEnd
- $LINK_ICHARS = $LINK_ICHARS_DOMAIN . (string) html_entity_decode(implode("", array(
- "ß", // ß
- )), ENT_QUOTES, 'UTF-8');
- $allowed_protocols = variable_get('filter_allowed_protocols', array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal'));
- $LINK_DOMAINS = _link_domains();
+ $link_ichars = $link_ichars_domain . (string) html_entity_decode(implode("", array(
+ // ß.
+ "ß",
+ )), ENT_QUOTES, 'UTF-8');
+ $allowed_protocols = variable_get('filter_allowed_protocols', array(
+ 'http',
+ 'https',
+ 'ftp',
+ 'news',
+ 'nntp',
+ 'telnet',
+ 'mailto',
+ 'irc',
+ 'ssh',
+ 'sftp',
+ 'webcal',
+ ));
+ $link_domains = _link_domains();
- // Starting a parenthesis group with (?: means that it is grouped, but is not captured.
+ // Starting a parenthesis group with (?: means that it is grouped, but is not
+ // captured.
$protocol = '((?:' . implode("|", $allowed_protocols) . '):\/\/)';
- $authentication = "(?:(?:(?:[\w\.\-\+!$&'\(\)*\+,;=" . $LINK_ICHARS . "]|%[0-9a-f]{2})+(?::(?:[\w" . $LINK_ICHARS . "\.\-\+%!$&'\(\)*\+,;=]|%[0-9a-f]{2})*)?)?@)";
- $domain = '(?:(?:[a-z0-9' . $LINK_ICHARS_DOMAIN . ']([a-z0-9' . $LINK_ICHARS_DOMAIN . '\-_\[\]])*)(\.(([a-z0-9' . $LINK_ICHARS_DOMAIN . '\-_\[\]])+\.)*(' . $LINK_DOMAINS . '|[a-z]{2}))?)';
+ $authentication = "(?:(?:(?:[\w\.\-\+!$&'\(\)*\+,;=" . $link_ichars . "]|%[0-9a-f]{2})+(?::(?:[\w" . $link_ichars . "\.\-\+%!$&'\(\)*\+,;=]|%[0-9a-f]{2})*)?)?@)";
+ $domain = '(?:(?:[a-z0-9' . $link_ichars_domain . ']([a-z0-9' . $link_ichars_domain . '\-_\[\]])*)(\.(([a-z0-9' . $link_ichars_domain . '\-_\[\]])+\.)*(' . $link_domains . '|[a-z]{2}))?)';
$ipv4 = '(?:[0-9]{1,3}(\.[0-9]{1,3}){3})';
$ipv6 = '(?:[0-9a-fA-F]{1,4}(\:[0-9a-fA-F]{1,4}){7})';
$port = '(?::([0-9]{1,5}))';
-
// Pattern specific to external links.
$external_pattern = '/^' . $protocol . '?' . $authentication . '?(' . $domain . '|' . $ipv4 . '|' . $ipv6 . ' |localhost)' . $port . '?';
// Pattern specific to internal links.
- $internal_pattern = "/^(?:[a-z0-9" . $LINK_ICHARS . "_\-+\[\] ]+)";
- $internal_pattern_file = "/^(?:[a-z0-9" . $LINK_ICHARS . "_\-+\[\]\. \/\(\)][a-z0-9" . $LINK_ICHARS . "_\-+\[\]\. \(\)][a-z0-9" . $LINK_ICHARS . "_\-+\[\]\. \/\(\)]+)$/i";
+ $internal_pattern = "/^(?:[a-z0-9" . $link_ichars . "_\-+\[\] ]+)";
+ $internal_pattern_file = "/^(?:[a-z0-9" . $link_ichars . "_\-+\[\]\. \/\(\)][a-z0-9" . $link_ichars . "_\-+\[\]\. \(\)][a-z0-9" . $link_ichars . "_\-+\[\]\. \/\(\)]+)$/i";
- $directories = "(?:\/[a-z0-9" . $LINK_ICHARS . "_\-\.~+%=&,$'#!():;*@\[\]]*)*";
+ $directories = "(?:\/[a-z0-9" . $link_ichars . "_\-\.~+%=&,$'#!():;*@\[\]]*)*";
// Yes, four backslashes == a single backslash.
- $query = "(?:\/?\?([?a-z0-9" . $LINK_ICHARS . "+_|\-\.~\/\\\\%=&,$'!():;*@\[\]{} ]*))";
- $anchor = "(?:#[a-z0-9" . $LINK_ICHARS . "_\-\.~+%=&,$'():;*@\[\]\/\?]*)";
+ $query = "(?:\/?\?([?a-z0-9" . $link_ichars . "+_|\-\.~\/\\\\%=&,$'!():;*@\[\]{} ]*))";
+ $anchor = "(?:#[a-z0-9" . $link_ichars . "_\-\.~+%=&,$'():;*@\[\]\/\?]*)";
// The rest of the path for a standard URL.
+ // @codingStandardsIgnoreLine
$end = $directories . '?' . $query . '?' . $anchor . '?' . '$/i';
$message_id = '[^@].*@' . $domain;
$newsgroup_name = '(?:[0-9a-z+-]*\.)*[0-9a-z+-]*';
$news_pattern = '/^news:(' . $newsgroup_name . '|' . $message_id . ')$/i';
- $user = '[a-zA-Z0-9' . $LINK_ICHARS . '_\-\.\+\^!#\$%&*+\/\=\?\`\|\{\}~\'\[\]]+';
+ $user = '[a-zA-Z0-9' . $link_ichars . '_\-\.\+\^!#\$%&*+\/\=\?\`\|\{\}~\'\[\]]+';
$email_pattern = '/^mailto:' . $user . '@' . '(?:' . $domain . '|' . $ipv4 . '|' . $ipv6 . '|localhost)' . $query . '?$/';
if (strpos($text, '') === 0) {
@@ -1290,6 +1564,9 @@ function link_validate_url($text) {
if (preg_match($internal_pattern . $end, $text)) {
return LINK_INTERNAL;
}
+ if (drupal_valid_path($text) && url_is_external($text) == FALSE) {
+ return LINK_INTERNAL;
+ }
if (preg_match($external_pattern . $end, $text)) {
return LINK_EXTERNAL;
}
@@ -1301,11 +1578,16 @@ function link_validate_url($text) {
}
/**
- * Returns the list of allowed domains, including domains added by admins via variable_set/$config.
+ * Returns the list of allowed domains.
+ *
+ * If the variable link_allowed_domains is set, restrict allowed domains to the
+ * strings in that array. If the variable link_allowed_domains is not set, allow
+ * all domains between 2 and 63 characters in length.
+ * See https://tools.ietf.org/html/rfc1034.
*/
function _link_domains() {
- $link_extra_domains = variable_get('link_extra_domains', array());
- return empty($link_extra_domains) ? LINK_DOMAINS : LINK_DOMAINS . '|' . implode('|', $link_extra_domains);
+ $link_allowed_domains = variable_get('link_allowed_domains', array());
+ return empty($link_allowed_domains) ? '[a-z][a-z0-9-]{1,62}' : implode('|', $link_allowed_domains);
}
/**
@@ -1316,7 +1598,15 @@ function link_content_migrate_field_alter(&$field_value, $instance_value) {
// Adjust the field type.
$field_value['type'] = 'link_field';
// Remove settings that are now on the instance.
- foreach (array('attributes', 'display', 'url', 'title', 'title_value', 'enable_tokens', 'validate_url') as $setting) {
+ foreach (array(
+ 'attributes',
+ 'display',
+ 'url',
+ 'title',
+ 'title_value',
+ 'enable_tokens',
+ 'validate_url',
+ ) as $setting) {
unset($field_value['settings'][$setting]);
}
}
@@ -1330,7 +1620,15 @@ function link_content_migrate_field_alter(&$field_value, $instance_value) {
function link_content_migrate_instance_alter(&$instance_value, $field_value) {
if ($field_value['type'] == 'link') {
// Grab settings that were previously on the field.
- foreach (array('attributes', 'display', 'url', 'title', 'title_value', 'enable_tokens', 'validate_url') as $setting) {
+ foreach (array(
+ 'attributes',
+ 'display',
+ 'url',
+ 'title',
+ 'title_value',
+ 'enable_tokens',
+ 'validate_url',
+ ) as $setting) {
if (isset($field_value['settings'][$setting])) {
$instance_value['settings'][$setting] = $field_value['settings'][$setting];
}
@@ -1341,7 +1639,15 @@ function link_content_migrate_instance_alter(&$instance_value, $field_value) {
}
// Adjust formatter types.
foreach ($instance_value['display'] as $context => $settings) {
- if (in_array($settings['type'], array('default', 'title_plain', 'url', 'plain', 'short', 'label', 'separate'))) {
+ if (in_array($settings['type'], array(
+ 'default',
+ 'title_plain',
+ 'url',
+ 'plain',
+ 'short',
+ 'label',
+ 'separate',
+ ))) {
$instance_value['display'][$context]['type'] = 'link_' . $settings['type'];
}
}
@@ -1357,7 +1663,7 @@ function link_field_settings_form() {
/**
* Additional callback to adapt the property info of link fields.
- *
+ *
* @see entity_metadata_field_entity_property_info()
*/
function link_field_property_info_callback(&$info, $entity_type, $field, $instance, $field_type) {
@@ -1385,7 +1691,7 @@ function link_field_property_info_callback(&$info, $entity_type, $field, $instan
* @see link_field_property_info_callback()
*/
function link_field_item_create() {
- return array('title' => NULL, 'url' => NULL);
+ return array('title' => NULL, 'url' => NULL, 'display_url' => NULL);
}
/**
@@ -1398,7 +1704,7 @@ function link_field_item_property_info() {
'setter callback' => 'entity_property_verbatim_set',
);
$properties['url'] = array(
- 'type' => 'uri',
+ 'type' => 'text',
'label' => t('The URL of the link.'),
'setter callback' => 'entity_property_verbatim_set',
);
@@ -1408,6 +1714,11 @@ function link_field_item_property_info() {
'setter callback' => 'entity_property_verbatim_set',
'getter callback' => 'link_attribute_property_get',
);
+ $properties['display_url'] = array(
+ 'type' => 'uri',
+ 'label' => t('The full URL of the link.'),
+ 'setter callback' => 'entity_property_verbatim_set',
+ );
return $properties;
}
@@ -1422,7 +1733,7 @@ function link_attribute_property_get($data, array $options, $name, $type, $info)
* Implements hook_field_update_instance().
*/
function link_field_update_instance($instance, $prior_instance) {
- if (function_exists('i18n_string_update') && $instance['widget']['type'] == 'link_field' && $prior_instance['settings']['title_value'] != $instance['settings']['title_value']) {
+ if (function_exists('i18n_string_update') && isset($instance['widget']) && $instance['widget']['type'] == 'link_field' && $prior_instance['settings']['title_value'] != $instance['settings']['title_value']) {
$i18n_string_name = "field:{$instance['field_name']}:{$instance['bundle']}:title_value";
i18n_string_update($i18n_string_name, $instance['settings']['title_value']);
}
diff --git a/sites/all/modules/contrib/fields/link/tests/link.attribute.test b/sites/all/modules/contrib/fields/link/tests/link.attribute.test
index 603847e..f66a0e6 100644
--- a/sites/all/modules/contrib/fields/link/tests/link.attribute.test
+++ b/sites/all/modules/contrib/fields/link/tests/link.attribute.test
@@ -5,7 +5,11 @@
* Basic simpletests to test options on link module.
*/
+/**
+ * Attribute Crud Test.
+ */
class LinkAttributeCrudTest extends DrupalWebTestCase {
+
private $zebra;
protected $permissions = array(
@@ -19,6 +23,9 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'access administration pages',
);
+ /**
+ * Get Info.
+ */
public static function getInfo() {
return array(
'name' => 'Link Attribute Tests',
@@ -27,14 +34,23 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
);
}
- function setup() {
+ /**
+ * Setup.
+ */
+ public function setup() {
parent::setup('field_ui', 'link');
$this->zebra = 0;
// Create and login user.
- $this->web_user = $this->drupalCreateUser(array('administer content types'));
+ $this->web_user = $this->drupalCreateUser(array(
+ 'administer content types',
+ 'administer fields',
+ ));
$this->drupalLogin($this->web_user);
}
+ /**
+ * Create Link.
+ */
protected function createLink($url, $title, $attributes = array()) {
return array(
'url' => $url,
@@ -43,20 +59,26 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
);
}
+ /**
+ * Assert Link On Node.
+ */
protected function assertLinkOnNode($field_name, $link_value, $message = '', $group = 'Other') {
$this->zebra++;
$zebra_string = ($this->zebra % 2 == 0) ? 'even' : 'odd';
$cssFieldLocator = 'field-' . str_replace('_', '-', $field_name);
$this->assertPattern('@
\s*' . $link_value . '\s*
@is',
- $message,
- $group);
+ $message,
+ $group);
}
/**
- * A simple test that just creates a new node type, adds a link field to it, creates a new node of that type, and makes sure
- * that the node is being displayed.
+ * Test Basic.
+ *
+ * A simple test that just creates a new node type, adds a link field to it,
+ * creates a new node of that type, and makes sure that the node is being
+ * displayed.
*/
- function testBasic() {
+ public function testBasic() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
$title = $this->randomName(20);
@@ -76,7 +98,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
- $single_field_name = 'field_' . $single_field_name_machine;
+
$edit = array(
'fields[_add_new_field][label]' => $single_field_name_friendly,
'fields[_add_new_field][field_name]' => $single_field_name_machine,
@@ -101,7 +123,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->assertTrue($type_exists, 'The new content type has been created in the database.');
$permission = 'create ' . $content_type_machine . ' content';
- $permission_edit = 'edit ' . $content_type_machine . ' content';
+
// Reset the permissions cache.
$this->checkPermissions(array($permission), TRUE);
@@ -122,7 +144,10 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
);
$this->drupalPost(NULL, $edit, t('Save'));
- $this->assertText(t('@content_type_friendly @title has been created', array('@content_type_friendly' => $content_type_friendly, '@title' => $title)));
+ $this->assertText(t('@content_type_friendly @title has been created', array(
+ '@content_type_friendly' => $content_type_friendly,
+ '@title' => $title,
+ )));
$this->drupalGet('node/add/' . $content_type_machine);
@@ -135,12 +160,18 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
// Now we can fill in the second item in the multivalue field and save.
$this->drupalPost(NULL, $edit, t('Save'));
- $this->assertText(t('@content_type_friendly @title has been created', array('@content_type_friendly' => $content_type_friendly, '@title' => $title)));
+ $this->assertText(t('@content_type_friendly @title has been created', array(
+ '@content_type_friendly' => $content_type_friendly,
+ '@title' => $title,
+ )));
$this->assertText('Display');
$this->assertLinkByHref('http://www.example.com');
}
+ /**
+ * Create Simple Link Field.
+ */
protected function createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine) {
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/fields');
$edit = array(
@@ -166,9 +197,11 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->assertTrue($type_exists, 'The new content type has been created in the database.');
}
+ /**
+ * Create Node Type User.
+ */
protected function createNodeTypeUser($content_type_machine) {
$permission = 'create ' . $content_type_machine . ' content';
- $permission_edit = 'edit ' . $content_type_machine . ' content';
// Reset the permissions cache.
$this->checkPermissions(array($permission), TRUE);
@@ -179,6 +212,9 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalLogin($this->web_user);
}
+ /**
+ * Create Node For Testing.
+ */
protected function createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $title, $url, $node_title = '') {
$this->drupalGet('node/add/' . $content_type_machine);
@@ -196,14 +232,17 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
}
$this->drupalPost(NULL, $edit, t('Save'));
- $this->assertText(t('@content_type_friendly @title has been created', array('@content_type_friendly' => $content_type_friendly, '@title' => $node_title)));
+ $this->assertText(t('@content_type_friendly @title has been created', array(
+ '@content_type_friendly' => $content_type_friendly,
+ '@title' => $node_title,
+ )));
}
/**
* Test the link_plain formatter and it's output.
*/
- function testFormatterPlain() {
+ public function testFormatterPlain() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
@@ -215,7 +254,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
- //$single_field_name = 'field_'. $single_field_name_machine;
+ // $single_field_name = 'field_'. $single_field_name_machine;.
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
// Okay, now we want to make sure this display is changed:
@@ -227,7 +266,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalPost(NULL, $edit, t('Save'));
$this->createNodeTypeUser($content_type_machine);
-
+
$link_tests = array(
'plain' => array(
'text' => 'Display',
@@ -243,18 +282,21 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
),
);
- foreach ($link_tests as $key => $link_test) {
+ foreach ($link_tests as $link_test) {
$link_text = $link_test['text'];
$link_url = $link_test['url'];
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertText($link_url);
$this->assertNoText($link_text);
$this->assertNoLinkByHref($link_url);
}
}
- function testFormatterURL() {
+ /**
+ * Formatter Host.
+ */
+ public function testFormatterHost() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
@@ -266,7 +308,47 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
- //$single_field_name = 'field_'. $single_field_name_machine;
+ // $single_field_name = 'field_'. $single_field_name_machine;.
+ $this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
+
+ // Okay, now we want to make sure this display is changed:
+ $this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
+ $edit = array(
+ 'fields[field_' . $single_field_name_machine . '][label]' => 'above',
+ 'fields[field_' . $single_field_name_machine . '][type]' => 'link_host',
+ );
+ $this->drupalPost(NULL, $edit, t('Save'));
+
+ $this->createNodeTypeUser($content_type_machine);
+
+ $link_text = 'Display';
+ $link_url = 'http://www.example.com/';
+ $this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
+
+ $this->assertText('www.example.com');
+ $this->assertNoText($link_text);
+ $this->assertNoLinkByHref($link_url);
+ }
+
+ /**
+ * Formatter URL.
+ *
+ * @codingStandardsIgnoreStart
+ */
+ public function testFormatterURL() {
+ // @codingStandardsIgnoreEnd
+ $content_type_friendly = $this->randomName(20);
+ $content_type_machine = strtolower($this->randomName(10));
+
+ $this->drupalCreateContentType(array(
+ 'type' => $content_type_machine,
+ 'name' => $content_type_friendly,
+ ));
+
+ // Now add a singleton field.
+ $single_field_name_friendly = $this->randomName(20);
+ $single_field_name_machine = strtolower($this->randomName(10));
+ // $single_field_name = 'field_'. $single_field_name_machine;.
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
// Okay, now we want to make sure this display is changed:
@@ -278,7 +360,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalPost(NULL, $edit, t('Save'));
$this->createNodeTypeUser($content_type_machine);
-
+
$link_tests = array(
'plain' => array(
'text' => 'Display',
@@ -294,17 +376,20 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
),
);
- foreach ($link_tests as $key => $link_test) {
+ foreach ($link_tests as $link_test) {
$link_text = $link_test['text'];
$link_url = $link_test['url'];
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertNoText($link_text);
$this->assertLinkByHref($link_url);
}
}
- function testFormatterShort() {
+ /**
+ * Formatter Short.
+ */
+ public function testFormatterShort() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
@@ -316,7 +401,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
- //$single_field_name = 'field_'. $single_field_name_machine;
+ // $single_field_name = 'field_'. $single_field_name_machine;.
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
// Okay, now we want to make sure this display is changed:
@@ -344,18 +429,21 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
),
);
- foreach ($link_tests as $key => $link_test) {
+ foreach ($link_tests as $link_test) {
$link_text = $link_test['text'];
$link_url = $link_test['url'];
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertText('Link');
$this->assertNoText($link_text);
$this->assertLinkByHref($link_url);
}
}
- function testFormatterLabel() {
+ /**
+ * Formatter Label.
+ */
+ public function testFormatterLabel() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
@@ -367,7 +455,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
- //$single_field_name = 'field_'. $single_field_name_machine;
+ // $single_field_name = 'field_'. $single_field_name_machine;.
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
// Okay, now we want to make sure this display is changed:
@@ -395,18 +483,21 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
),
);
- foreach ($link_tests as $key => $link_test) {
+ foreach ($link_tests as $link_test) {
$link_text = $link_test['text'];
- $link_url = $link_test['url'];
+ $link_url = $link_test['url'];
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertNoText($link_text);
$this->assertText($single_field_name_friendly);
$this->assertLinkByHref($link_url);
}
}
- function testFormatterSeparate() {
+ /**
+ * Formatter Separate.
+ */
+ public function testFormatterSeparate() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
@@ -418,7 +509,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
- //$single_field_name = 'field_'. $single_field_name_machine;
+ // $single_field_name = 'field_'. $single_field_name_machine;.
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
// Okay, now we want to make sure this display is changed:
@@ -447,32 +538,35 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
),
);
- foreach ($link_tests as $key => $link_test) {
+ foreach ($link_tests as $link_test) {
$link_text = $link_test['text'];
$link_url = $link_test['url'];
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertText($link_text);
$this->assertLink($plain_url);
$this->assertLinkByHref($link_url);
}
}
-
- function testFormatterPlainTitle() {
+
+ /**
+ * Formatter Plain Title.
+ */
+ public function testFormatterPlainTitle() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
-
+
$this->drupalCreateContentType(array(
'type' => $content_type_machine,
'name' => $content_type_friendly,
));
-
+
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
- //$single_field_name = 'field_'. $single_field_name_machine;
+ // $single_field_name = 'field_'. $single_field_name_machine;.
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
-
+
// Okay, now we want to make sure this display is changed:
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
$edit = array(
@@ -480,15 +574,16 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'fields[field_' . $single_field_name_machine . '][type]' => 'link_title_plain',
);
$this->drupalPost(NULL, $edit, t('Save'));
-
+
$this->createNodeTypeUser($content_type_machine);
-
+
$link_text = 'Display';
$link_url = 'http://www.example.com/';
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertText($link_text);
$this->assertNoText($link_url);
$this->assertNoLinkByHref($link_url);
}
+
}
diff --git a/sites/all/modules/contrib/fields/link/tests/link.crud.test b/sites/all/modules/contrib/fields/link/tests/link.crud.test
index e9b7db4..6bc3867 100644
--- a/sites/all/modules/contrib/fields/link/tests/link.crud.test
+++ b/sites/all/modules/contrib/fields/link/tests/link.crud.test
@@ -2,11 +2,20 @@
/**
* @file
- * Basic CRUD simpletests for the link module, based off of content.crud.test in CCK.
+ * File for Crud Tests.
+ *
+ * Basic CRUD simpletests for the link module, based off of content.crud.test in
+ * CCK.
*/
+/**
+ * Content Crud.
+ */
class LinkContentCrudTest extends DrupalWebTestCase {
+ /**
+ * Get Info.
+ */
public static function getInfo() {
return array(
'name' => 'Link CRUD - Basic API tests',
@@ -15,21 +24,31 @@ class LinkContentCrudTest extends DrupalWebTestCase {
);
}
- function setUp() {
+ /**
+ * Setup.
+ */
+ public function setUp() {
parent::setUp('field_ui', 'link');
}
/**
- * All we're doing here is creating a content type, creating a simple link field
- * on that content type.
+ * Create Field API.
+ *
+ * All we're doing here is creating a content type, creating a simple link
+ * field on that content type.
+ *
+ * @codingStandardsIgnoreStart
*/
- function testLinkCreateFieldAPI() {
+ public function testLinkCreateFieldAPI() {
+ // @codingStandardsIgnoreEnd
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
- $title = $this->randomName(20);
// Create and login user.
- $this->web_user = $this->drupalCreateUser(array('administer content types'));
+ $this->web_user = $this->drupalCreateUser(array(
+ 'administer content types',
+ 'administer fields',
+ ));
$this->drupalLogin($this->web_user);
$this->drupalGet('admin/structure/types');
@@ -69,4 +88,5 @@ class LinkContentCrudTest extends DrupalWebTestCase {
$type_exists = db_query('SELECT 1 FROM {node_type} WHERE type = :type', array(':type' => $content_type_machine))->fetchField();
$this->assertTrue($type_exists, 'The new content type has been created in the database.');
}
+
}
diff --git a/sites/all/modules/contrib/fields/link/tests/link.crud_browser.test b/sites/all/modules/contrib/fields/link/tests/link.crud_browser.test
index c90e86d..dc21857 100644
--- a/sites/all/modules/contrib/fields/link/tests/link.crud_browser.test
+++ b/sites/all/modules/contrib/fields/link/tests/link.crud_browser.test
@@ -6,25 +6,28 @@
*/
/**
- * Testing that users can not input bad URLs or labels
+ * Testing that users can not input bad URLs or labels.
*/
class LinkUITest extends DrupalWebTestcase {
/**
- * Link supposed to be good
+ * Link supposed to be good.
*/
const LINK_INPUT_TYPE_GOOD = 0;
/**
- * Link supposed to have a bad title
+ * Link supposed to have a bad title.
*/
const LINK_INPUT_TYPE_BAD_TITLE = 1;
/**
- * Link supposed to have a bad URL
+ * Link supposed to have a bad URL.
*/
const LINK_INPUT_TYPE_BAD_URL = 2;
+ /**
+ * Get Info.
+ */
public static function getInfo() {
return array(
'name' => 'Link CRUD - browser test',
@@ -33,26 +36,30 @@ class LinkUITest extends DrupalWebTestcase {
);
}
- function setUp() {
+ /**
+ * Setup.
+ */
+ public function setUp() {
parent::setUp('field_ui', 'link');
}
/**
* Creates a link field for the "page" type and creates a page with a link.
*/
- function testLinkCreate() {
- //libxml_use_internal_errors(true);
+ public function testLinkCreate() {
+ // libxml_use_internal_errors(true);
$this->web_user = $this->drupalCreateUser(array(
'administer content types',
+ 'administer fields',
'administer nodes',
'administer filters',
'access content',
'create page content',
- 'access administration pages'
+ 'access administration pages',
));
$this->drupalLogin($this->web_user);
- // create field
+ // Create field.
$name = strtolower($this->randomName());
$edit = array(
'fields[_add_new_field][label]' => $name,
@@ -72,8 +79,8 @@ class LinkUITest extends DrupalWebTestcase {
$permission = 'create page content';
$this->checkPermissions(array($permission), TRUE);
- // create page form
- //$this->drupalGet('node/add');
+ // Create page form
+ // $this->drupalGet('node/add');.
$this->drupalGet('node/add/page');
$field_name = 'field_' . $name;
$this->assertField('edit-field-' . $name . '-und-0-title', 'Title found');
@@ -84,37 +91,37 @@ class LinkUITest extends DrupalWebTestcase {
'href' => 'http://example.com/' . $this->randomName(),
'label' => $this->randomName(),
'msg' => 'Link found',
- 'type' => self::LINK_INPUT_TYPE_GOOD
+ 'type' => self::LINK_INPUT_TYPE_GOOD,
),
array(
'href' => 'http://example.com/' . $this->randomName(),
'label' => $this->randomName() . '',
'msg' => 'js label',
- 'type' => self::LINK_INPUT_TYPE_BAD_TITLE
+ 'type' => self::LINK_INPUT_TYPE_BAD_TITLE,
),
array(
'href' => 'http://example.com/' . $this->randomName(),
'label' => $this->randomName() . '',
'msg' => 'js label',
- 'type' => self::LINK_INPUT_TYPE_BAD_TITLE
+ 'type' => self::LINK_INPUT_TYPE_BAD_TITLE,
),
array(
'href' => 'http://example.com/' . $this->randomName(),
'label' => $this->randomName() . '" onmouseover="alert(\'hi\')',
'msg' => 'js label',
- 'type' => self::LINK_INPUT_TYPE_BAD_TITLE
+ 'type' => self::LINK_INPUT_TYPE_BAD_TITLE,
),
array(
'href' => 'http://example.com/' . $this->randomName(),
'label' => $this->randomName() . '\' onmouseover="alert(\'hi\')',
'msg' => 'js label',
- 'type' => self::LINK_INPUT_TYPE_BAD_TITLE
+ 'type' => self::LINK_INPUT_TYPE_BAD_TITLE,
),
array(
'href' => 'javascript:alert("http://example.com/' . $this->randomName() . '")',
'label' => $this->randomName(),
'msg' => 'js url',
- 'type' => self::LINK_INPUT_TYPE_BAD_URL
+ 'type' => self::LINK_INPUT_TYPE_BAD_URL,
),
array(
'href' => 'http://ecs-es.kelkoo.es/ctl/go/sitesearchGo?.ts=1338833010331&.sig=qP9GXeEFH6syBzwmzYkxmsvp1EI-',
@@ -143,23 +150,26 @@ class LinkUITest extends DrupalWebTestcase {
);
$this->drupalPost(NULL, $edit, t('Save'));
if ($input['type'] == self::LINK_INPUT_TYPE_BAD_URL) {
- $this->assertRaw(t('The value %value provided for %field is not a valid URL.', array('%field' => $name, '%value' => trim($input['href']))), 'Not a valid URL: ' . $input['href']);
+ $this->assertRaw(t('The value %value provided for %field is not a valid URL.', array(
+ '%field' => $name,
+ '%value' => trim($input['href']),
+ )), 'Not a valid URL: ' . $input['href']);
continue;
}
else {
$this->assertRaw(' ' . t('has been created.',
- array('@type' => 'Basic Page', '%title' => $edit['title'])),
- 'Page created: ' . $input['href']);
+ array('@type' => 'Basic Page', '%title' => $edit['title'])),
+ 'Page created: ' . $input['href']);
}
$url = $this->getUrl();
- // change to Anonymous user.
+ // Change to Anonymous user.
$this->drupalLogout();
$this->drupalGet($url);
- //debug($this);
- // If simpletest starts using something to override the error system, this will flag
- // us and let us know it's broken.
+ // debug($this);
+ // If simpletest starts using something to override the error system, this
+ // will flag us and let us know it's broken.
$this->assertFalse(libxml_use_internal_errors(TRUE));
if (isset($input['expected_href'])) {
$path = '//a[@href="' . $input['expected_href'] . '" and text()="' . $input['label'] . '"]';
@@ -171,18 +181,27 @@ class LinkUITest extends DrupalWebTestcase {
libxml_use_internal_errors(FALSE);
$this->assertIdentical(isset($elements[0]), $input['type'] == self::LINK_INPUT_TYPE_GOOD, $input['msg']);
}
- //libxml_use_internal_errors(FALSE);
+ // libxml_use_internal_errors(FALSE);
}
/**
+ * Static Link Create.
+ *
* Testing that if you use in a static title for your link, that the
* title actually displays .
*/
- function testStaticLinkCreate() {
- $this->web_user = $this->drupalCreateUser(array('administer content types', 'access content', 'create page content'));
+ public function testStaticLinkCreate() {
+
+ $this->web_user = $this->drupalCreateUser(array(
+ 'administer content types',
+ 'administer fields',
+ 'access content',
+ 'create page content',
+ ));
+
$this->drupalLogin($this->web_user);
- // create field
+ // Create field.
$name = strtolower($this->randomName());
$field_name = 'field_' . $name;
$edit = array(
@@ -195,17 +214,18 @@ class LinkUITest extends DrupalWebTestcase {
$this->drupalPost(NULL, array(), t('Save field settings'));
$this->drupalPost(NULL, array(
'instance[settings][title]' => 'value',
- 'instance[settings][title_value]' => '' . $name . ''), t('Save settings'));
+ 'instance[settings][title_value]' => '' . $name . '',
+ ), t('Save settings'));
// Is field created?
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
- // create page form
+ // Create page form.
$this->drupalGet('node/add/page');
$this->assertField($field_name . '[und][0][url]', 'URL found');
$input = array(
- 'href' => 'http://example.com/' . $this->randomName()
+ 'href' => 'http://example.com/' . $this->randomName(),
);
$edit = array(
@@ -216,21 +236,32 @@ class LinkUITest extends DrupalWebTestcase {
$url = $this->getUrl();
- // change to anonymous user
+ // Change to anonymous user.
$this->drupalLogout();
$this->drupalGet($url);
$this->assertRaw(l('' . $name . '', $input['href'], array('html' => TRUE)));
}
-
+
/**
- * Testing that if you have the title but no url, the title is not sanitized twice.
+ * CRUD Title Only Title No Link.
+ *
+ * Testing that if you have the title but no url, the title is not sanitized
+ * twice.
+ *
+ * @codingStandardsIgnoreStart
*/
- function testCRUDTitleOnlyTitleNoLink() {
- $this->web_user = $this->drupalCreateUser(array('administer content types', 'access content', 'create page content'));
+ public function testCRUDTitleOnlyTitleNoLink() {
+ // @codingStandardsIgnoreEnd
+ $this->web_user = $this->drupalCreateUser(array(
+ 'administer content types',
+ 'administer fields',
+ 'access content',
+ 'create page content',
+ ));
$this->drupalLogin($this->web_user);
- // create field
+ // Create field.
$name = strtolower($this->randomName());
$field_name = 'field_' . $name;
$edit = array(
@@ -247,8 +278,8 @@ class LinkUITest extends DrupalWebTestcase {
// Is field created?
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
-
- // create page form
+
+ // Create page form.
$this->drupalGet('node/add/page');
$this->assertField($field_name . '[und][0][url]', 'URL found');
@@ -265,8 +296,8 @@ class LinkUITest extends DrupalWebTestcase {
$this->drupalPost(NULL, $edit, t('Save'));
$url = $this->getUrl();
-
- // change to anonymous user
+
+ // Change to anonymous user.
$this->drupalLogout();
$this->drupalGet($url);
@@ -274,14 +305,26 @@ class LinkUITest extends DrupalWebTestcase {
}
/**
- * If we're creating a new field and just hit 'save' on the default options, we want to make
- * sure they are set to the expected results.
+ * CRUD Create Field Defaults.
+ *
+ * If we're creating a new field and just hit 'save' on the default options,
+ * we want to make sure they are set to the expected results.
+ *
+ * @codingStandardsIgnoreStart
*/
- function testCRUDCreateFieldDefaults() {
- $this->web_user = $this->drupalCreateUser(array('administer content types', 'access content', 'create page content'));
+ public function testCRUDCreateFieldDefaults() {
+ // @codingStandardsIgnoreEnd
+
+ $this->web_user = $this->drupalCreateUser(array(
+ 'administer content types',
+ 'administer fields',
+ 'access content',
+ 'create page content',
+ ));
+
$this->drupalLogin($this->web_user);
- // create field
+ // Create field.
$name = strtolower($this->randomName());
$edit = array(
'fields[_add_new_field][label]' => $name,
@@ -312,4 +355,169 @@ class LinkUITest extends DrupalWebTestcase {
$this->assertFalse($instance['settings']['attributes']['class'], 'By default, no class should be set.');
$this->assertFalse($instance['settings']['title_value'], 'By default, no title should be set.');
}
+
+ /**
+ * CRUD Create Field With Class.
+ *
+ * If we're creating a new field and just hit 'save' on the default options,
+ * we want to make sure they are set to the expected results.
+ *
+ * @codingStandardsIgnoreStart
+ */
+ public function testCRUDCreateFieldWithClass() {
+ // @codingStandardsIgnoreEnd
+ $this->web_user = $this->drupalCreateUser(array(
+ 'administer content types',
+ 'administer fields',
+ 'access content',
+ 'create page content',
+ ));
+ $this->drupalLogin($this->web_user);
+
+ // Create field.
+ $name = strtolower($this->randomName());
+ $edit = array(
+ 'fields[_add_new_field][label]' => $name,
+ 'fields[_add_new_field][field_name]' => $name,
+ 'fields[_add_new_field][type]' => 'link_field',
+ 'fields[_add_new_field][widget_type]' => 'link_field',
+ );
+ $this->drupalPost('admin/structure/types/manage/page/fields', $edit, t('Save'));
+
+ $this->drupalPost(NULL, array(), t('Save field settings'));
+ $link_class_name = 'basic-link-' . strtolower($this->randomName());
+ $edit = array(
+ 'instance[settings][attributes][class]' => $link_class_name,
+ );
+ $this->drupalPost(NULL, $edit, t('Save settings'));
+
+ // Is field created?
+ $this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
+ node_types_rebuild();
+ menu_rebuild();
+
+ _field_info_collate_fields(TRUE);
+ $instances = field_info_instances('node', 'page');
+
+ $instance = $instances['field_' . $name];
+ $this->assertFalse($instance['required'], 'Make sure field is not required.');
+ $this->assertEqual($instance['settings']['title'], 'optional', 'Title should be optional by default.');
+ $this->assertTrue($instance['settings']['validate_url'], 'Make sure validation is on.');
+ $this->assertTrue($instance['settings']['enable_tokens'], 'Enable Tokens should be on by default.');
+ $this->assertEqual($instance['settings']['display']['url_cutoff'], 80, 'Url cutoff should be at 80 characters.');
+ $this->assertEqual($instance['settings']['attributes']['target'], 'default', 'Target should be "default"');
+ $this->assertFalse($instance['settings']['attributes']['rel'], 'Rel should be blank by default.');
+ $this->assertEqual($instance['settings']['attributes']['class'], $link_class_name, 'One class should be set.');
+ $this->assertFalse($instance['settings']['title_value'], 'By default, no title should be set.');
+
+ // Now, let's create a node with this field and make sure the link shows up:
+ // create page form.
+ $field_name = 'field_' . $name;
+ $this->drupalGet('node/add/page');
+ $this->assertField($field_name . '[und][0][url]', 'URL found');
+
+ $input = array(
+ 'title' => 'This & That',
+ 'href' => 'http://www.example.com/',
+ );
+
+ $edit = array(
+ 'title' => $field_name,
+ $field_name . '[und][0][title]' => $input['title'],
+ $field_name . '[und][0][url]' => $input['href'],
+ );
+ $this->drupalPost(NULL, $edit, t('Save'));
+
+ $url = $this->getUrl();
+
+ // Change to anonymous user.
+ $this->drupalLogout();
+ $this->drupalGet($url);
+
+ $this->assertRaw('This & That');
+ $this->assertPattern('|class\s?=\s?"' . $link_class_name . '"|', "Class $link_class_name exists on page.");
+ }
+
+ /**
+ * CRUD Create Field With Two Classes.
+ *
+ * If we're creating a new field and just hit 'save' on the default options,
+ * we want to make sure they are set to the expected results.
+ *
+ * @codingStandardsIgnoreStart
+ */
+ public function testCRUDCreateFieldWithTwoClasses() {
+ // @codingStandardsIgnoreEnd
+ $this->web_user = $this->drupalCreateUser(array(
+ 'administer content types',
+ 'administer fields',
+ 'access content',
+ 'create page content',
+ ));
+ $this->drupalLogin($this->web_user);
+
+ // Create field.
+ $name = strtolower($this->randomName());
+ $edit = array(
+ 'fields[_add_new_field][label]' => $name,
+ 'fields[_add_new_field][field_name]' => $name,
+ 'fields[_add_new_field][type]' => 'link_field',
+ 'fields[_add_new_field][widget_type]' => 'link_field',
+ );
+ $this->drupalPost('admin/structure/types/manage/page/fields', $edit, t('Save'));
+
+ $this->drupalPost(NULL, array(), t('Save field settings'));
+ $link_class_name = 'basic-link ' . strtoupper($this->randomName());
+ $edit = array(
+ 'instance[settings][attributes][class]' => $link_class_name,
+ );
+ $this->drupalPost(NULL, $edit, t('Save settings'));
+
+ // Is field created?
+ $this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
+ node_types_rebuild();
+ menu_rebuild();
+
+ _field_info_collate_fields(TRUE);
+ $instances = field_info_instances('node', 'page');
+
+ $instance = $instances['field_' . $name];
+ $this->assertFalse($instance['required'], 'Make sure field is not required.');
+ $this->assertEqual($instance['settings']['title'], 'optional', 'Title should be optional by default.');
+ $this->assertTrue($instance['settings']['validate_url'], 'Make sure validation is on.');
+ $this->assertTrue($instance['settings']['enable_tokens'], 'Enable Tokens should be on by default.');
+ $this->assertEqual($instance['settings']['display']['url_cutoff'], 80, 'Url cutoff should be at 80 characters.');
+ $this->assertEqual($instance['settings']['attributes']['target'], 'default', 'Target should be "default"');
+ $this->assertFalse($instance['settings']['attributes']['rel'], 'Rel should be blank by default.');
+ $this->assertEqual($instance['settings']['attributes']['class'], $link_class_name, 'Two classes should be set.');
+ $this->assertFalse($instance['settings']['title_value'], 'By default, no title should be set.');
+
+ // Now, let's create a node with this field and make sure the link shows up:
+ // create page form.
+ $field_name = 'field_' . $name;
+ $this->drupalGet('node/add/page');
+ $this->assertField($field_name . '[und][0][url]', 'URL found');
+
+ $input = array(
+ 'title' => 'This & That',
+ 'href' => 'http://www.example.com/',
+ );
+
+ $edit = array(
+ 'title' => $field_name,
+ $field_name . '[und][0][title]' => $input['title'],
+ $field_name . '[und][0][url]' => $input['href'],
+ );
+ $this->drupalPost(NULL, $edit, t('Save'));
+
+ $url = $this->getUrl();
+
+ // Change to anonymous user.
+ $this->drupalLogout();
+ $this->drupalGet($url);
+
+ $this->assertRaw('This & That');
+ $this->assertPattern('|class\s?=\s?"' . $link_class_name . '"|', "Classes $link_class_name exist on page.");
+ }
+
}
diff --git a/sites/all/modules/contrib/fields/link/tests/link.entity_token.test b/sites/all/modules/contrib/fields/link/tests/link.entity_token.test
new file mode 100644
index 0000000..6c42655
--- /dev/null
+++ b/sites/all/modules/contrib/fields/link/tests/link.entity_token.test
@@ -0,0 +1,164 @@
+ 'Link entity tokens test',
+ 'description' => 'Tests that a link field appears properly in entity tokens',
+ 'group' => 'Link',
+ 'dependencies' => array('token', 'entity', 'entity_token'),
+ );
+ }
+
+ /**
+ * Setup.
+ */
+ public function setUp($modules = array()) {
+ parent::setUp(array('token', 'entity', 'entity_token'));
+ }
+
+ /**
+ * Creates a link field, fills it, then uses a loaded node to test tokens.
+ */
+ public function testFieldTokenNodeLoaded() {
+ // Create field.
+ $settings = array(
+ 'instance[settings][enable_tokens]' => 0,
+ );
+ $field_name = $this->createLinkField('page',
+ $settings);
+
+ // Create page form.
+ $this->drupalGet('node/add/page');
+ // $field_name = 'field_' . $name;.
+ $this->assertField($field_name . '[und][0][title]', 'Title found');
+ $this->assertField($field_name . '[und][0][url]', 'URL found');
+
+ $token_url_tests = array(
+ 1 => array(
+ 'href' => 'http://example.com/' . $this->randomName(),
+ 'label' => $this->randomName(),
+ ),
+ 2 => array(
+ 'href' => 'http://example.com/' . $this->randomName() . '?property=value',
+ 'label' => $this->randomName(),
+ ),
+ 3 => array(
+ 'href' => 'http://example.com/' . $this->randomName() . '#position',
+ 'label' => $this->randomName(),
+ ),
+ 4 => array(
+ 'href' => 'http://example.com/' . $this->randomName() . '#lower?property=value2',
+ 'label' => $this->randomName(),
+ ),
+ );
+ // @codingStandardsIgnoreLine
+ // $this->assert('pass', '
');*/
@@ -182,51 +226,62 @@ class LinkValidateTest extends LinkValidateTestCase {
node_types_rebuild();
menu_rebuild();
- // create page form
+ // Create page form.
$this->drupalGet('node/add/page');
$field_name = 'field_' . $name;
$this->assertField('edit-field-' . $name . '-und-0-title', 'Title found');
$this->assertField('edit-field-' . $name . '-und-0-url', 'URL found');
-
$edit = array(
'title' => 'Simple Title',
$field_name . '[und][0][url]' => 'edik:naw',
);
$this->drupalPost(NULL, $edit, t('Save'));
- $this->assertNoText(t('The value %value provided for %field is not a valid URL.', array('%field' => $name, '%value' => 'edik:naw')));
+ $this->assertNoText(t('The value %value provided for %field is not a valid URL.', array(
+ '%field' => $name,
+ '%value' => 'edik:naw',
+ )));
}
/**
- * Test if a bad url can sneak through un-filtered if we play with the validation...
+ * Validate switching between validation status.
+ *
+ * Test if a bad url can sneak through un-filtered if we play with the
+ * validation...
+ *
+ * @codingStandardsIgnoreStart
*/
- function x_test_link_validate_switching_between_validation_status() {
+ public function x_test_link_validate_switching_between_validation_status() {
+ // @codingStandardsIgnoreEnd
$this->acquireContentTypes(1);
- $this->web_user = $this->drupalCreateUser(array('administer content types',
- 'administer nodes',
- 'access administration pages',
- 'access content',
- 'create ' . $this->content_types[0]->type . ' content',
- 'edit any ' . $this->content_types[0]->type . ' content'));
+ $this->web_user = $this->drupalCreateUser(array(
+ 'administer content types',
+ 'administer fields',
+ 'administer nodes',
+ 'access administration pages',
+ 'access content',
+ 'create ' . $this->content_types[0]->type . ' content',
+ 'edit any ' . $this->content_types[0]->type . ' content',
+ ));
$this->drupalLogin($this->web_user);
- variable_set('node_options_' . $this->content_types[0]->name, array('status', 'promote'));
+ variable_set('node_options_' . $this->content_types[0]->name, array(
+ 'status',
+ 'promote',
+ ));
$field_settings = array(
'type' => 'link',
'widget_type' => 'link',
'type_name' => $this->content_types[0]->name,
- 'attributes' => array(), // <-- This is needed or we have an error
+ // <-- This is needed or we have an error.
+ 'attributes' => array(),
'validate_url' => 0,
);
$field = $this->createField($field_settings, 0);
- //$this->fail('
'. print_r($field, TRUE) .'
');
- $field_db_info = content_database_info($field);
$this->acquireNodes(2);
- $node = node_load($this->nodes[0]->nid);
-
$this->drupalGet('node/' . $this->nodes[0]->nid);
$edit = array();
@@ -236,8 +291,12 @@ class LinkValidateTest extends LinkValidateTestCase {
$edit[$field['field_name'] . '[0][title]'] = $title;
$this->drupalPost('node/' . $this->nodes[0]->nid . '/edit', $edit, t('Save'));
- //$this->pass($this->content);
- $this->assertNoText(t('The value %value provided for %field is not a valid URL.', array('%field' => $name, '%value' => trim($url))));
+ // $this->pass($this->content);.
+ // @codingStandardsIgnoreLine
+ $this->assertNoText(t('The value %value provided for %field is not a valid URL.', array(
+ '%field' => $name,
+ '%value' => trim($url),
+ )));
// Make sure we get a new version!
$node = node_load($this->nodes[0]->nid, NULL, TRUE);
@@ -249,8 +308,9 @@ class LinkValidateTest extends LinkValidateTestCase {
// Turn the array validation back _on_.
$edit = array('validate_url' => TRUE);
$node_type_link = str_replace('_', '-', $node->type);
- //$this->drupalGet('admin/content/node-type/'. $node_type_link .'/fields'); ///'. $field['field_name']);
- //$this->fail($this->content);
+ // @codingStandardsIgnoreLine
+ // $this->drupalGet('admin/content/node-type/'. $node_type_link .'/fields'); ///'. $field['field_name']);
+ // $this->fail($this->content);.
$this->drupalPost('admin/content/node-type/' . $node_type_link . '/fields/' . $field['field_name'], $edit, t('Save field settings'));
$this->drupalGet('node/' . $node->nid);
@@ -258,36 +318,75 @@ class LinkValidateTest extends LinkValidateTestCase {
// url() function. But we should have a test that makes sure it continues
// to work.
$this->assertNoRaw($url, 'Make sure Javascript does not display.');
- //$this->fail($this->content);
-
+ // $this->fail($this->content);.
}
- // Validate that '' is a valid url.
- function test_link_front_url() {
+ /**
+ * Validate that '' is a valid url.
+ *
+ * @codingStandardsIgnoreStart
+ */
+ public function test_link_front_url() {
+ // @codingStandardsIgnoreEnd
$this->link_test_validate_url('');
}
- // Validate that an internal url would be accepted.
- function test_link_internal_url() {
- $this->link_test_validate_url('node/32');
+ /**
+ * Validate that an internal url would be accepted.
+ *
+ * @codingStandardsIgnoreStart
+ */
+ public function test_link_internal_url() {
+ // @codingStandardsIgnoreEnd
+ // Create the content first.
+ $node = $this->drupalCreateNode();
+
+ $link = 'node/' . $node->nid;
+ $this->link_test_validate_url($link);
+ $type = link_url_type($link);
+ $this->assertEqual(LINK_INTERNAL, $type, 'Test ' . $link . ' is an internal link.');
}
- // Validate a simple mailto.
- function test_link_mailto() {
+ /**
+ * Validate a simple mailto.
+ *
+ * @codingStandardsIgnoreStart
+ */
+ public function test_link_mailto() {
+ // @codingStandardsIgnoreEnd
$this->link_test_validate_url('mailto:jcfiala@gmail.com');
}
- function test_link_external_https() {
+ /**
+ * Check link external https.
+ *
+ * @codingStandardsIgnoreStart
+ */
+ public function test_link_external_https() {
+ // @codingStandardsIgnoreEnd
$this->link_test_validate_url('https://www.example.com/');
}
- function test_link_ftp() {
+ /**
+ * Check link FTP.
+ *
+ * @codingStandardsIgnoreStart
+ */
+ public function test_link_ftp() {
+ // @codingStandardsIgnoreEnd
$this->link_test_validate_url('ftp://www.example.com/');
}
+
}
+/**
+ * Validate Test News.
+ */
class LinkValidateTestNews extends LinkValidateTestCase {
+ /**
+ * Get Info.
+ */
public static function getInfo() {
return array(
'name' => 'Link News Validation Tests',
@@ -296,18 +395,36 @@ class LinkValidateTestNews extends LinkValidateTestCase {
);
}
- // Validate a news link to a message group
- function test_link_news() {
+ /**
+ * Validate a news link to a message group.
+ *
+ * @codingStandardsIgnoreStart
+ */
+ public function test_link_news() {
+ // @codingStandardsIgnoreEnd
$this->link_test_validate_url('news:comp.infosystems.www.misc');
}
- // Validate a news link to a message id. Said ID copied off of google groups.
- function test_link_news_message() {
+ /**
+ * Validate a news link to a message id. Said ID copied off of google groups.
+ *
+ * @codingStandardsIgnoreStart
+ */
+ public function test_link_news_message() {
+ // @codingStandardsIgnoreEnd
$this->link_test_validate_url('news:hj0db8$vrm$1@news.eternal-september.org');
}
+
}
+/**
+ * Validate Specific URL.
+ */
class LinkValidateSpecificURL extends LinkValidateTestCase {
+
+ /**
+ * Get Info.
+ */
public static function getInfo() {
return array(
'name' => 'Link Specific URL Validation Tests',
@@ -316,33 +433,65 @@ class LinkValidateSpecificURL extends LinkValidateTestCase {
);
}
- // Lets throw in a lot of umlouts for testing!
- function test_umlout_url() {
+ /**
+ * Lets throw in a lot of umlouts for testing!
+ *
+ * @codingStandardsIgnoreStart
+ */
+ public function test_umlout_url() {
+ // @codingStandardsIgnoreEnd
$this->link_test_validate_url('http://üÜü.exämple.com/nöde');
}
- function test_umlout_mailto() {
+ /**
+ * Check umlout mailto.
+ *
+ * @codingStandardsIgnoreStart
+ */
+ public function test_umlout_mailto() {
+ // @codingStandardsIgnoreEnd
$this->link_test_validate_url('mailto:Üser@exÅmple.com');
}
- function test_german_b_url() {
+ /**
+ * Check german b in url.
+ *
+ * @codingStandardsIgnoreStart
+ */
+ public function test_german_b_url() {
+ // @codingStandardsIgnoreEnd
$this->link_test_validate_url('http://www.test.com/ßstuff');
}
- function test_special_n_url() {
+ /**
+ * Check Special in url.
+ *
+ * @codingStandardsIgnoreStart
+ */
+ public function test_special_n_url() {
+ // @codingStandardsIgnoreEnd
$this->link_test_validate_url('http://www.testÑñ.com/');
}
- function test_curly_brackets_in_query() {
+ /**
+ * Curly Brackets in query.
+ *
+ * @codingStandardsIgnoreStart
+ */
+ public function test_curly_brackets_in_query() {
+ // @codingStandardsIgnoreEnd
$this->link_test_validate_url('http://www.healthyteennetwork.org/index.asp?Type=B_PR&SEC={2AE1D600-4FC6-4B4D-8822-F1D5F072ED7B}&DE={235FD1E7-208D-4363-9854-4E6775EB8A4C}');
}
/**
* Here, we're testing that a very long url is stored properly in the db.
*
- * Basicly, trying to test http://drupal.org/node/376818
+ * Basically, trying to test http://drupal.org/node/376818
+ *
+ * @codingStandardsIgnoreStart
*/
- function testLinkURLFieldIsBig() {
+ public function testLinkURLFieldIsBig() {
+ // @codingStandardsIgnoreEnd
$long_url = 'http://th.wikipedia.org/wiki/%E0%B9%82%E0%B8%A3%E0%B8%87%E0%B9%80%E0%B8%A3%E0%B8%B5%E0%B8%A2%E0%B8%99%E0%B9%80%E0%B8%9A%E0%B8%8D%E0%B8%88%E0%B8%A1%E0%B8%A3%E0%B8%B2%E0%B8%8A%E0%B8%B9%E0%B8%97%E0%B8%B4%E0%B8%A8_%E0%B8%99%E0%B8%84%E0%B8%A3%E0%B8%A8%E0%B8%A3%E0%B8%B5%E0%B8%98%E0%B8%A3%E0%B8%A3%E0%B8%A1%E0%B8%A3%E0%B8%B2%E0%B8%8A';
$this->link_test_validate_url($long_url);
}
@@ -350,12 +499,18 @@ class LinkValidateSpecificURL extends LinkValidateTestCase {
}
/**
- * A series of tests of links, only going against the link_validate_url function in link.module.
+ * Validate Url Light.
+ *
+ * A series of tests of links, only going against the link_validate_url function
+ * in link.module.
*
* Validation is guided by the rules in http://tools.ietf.org/html/rfc1738 !
*/
class LinkValidateUrlLight extends DrupalWebTestCase {
+ /**
+ * Get Info.
+ */
public static function getInfo() {
return array(
'name' => 'Link Light Validation Tests',
@@ -365,73 +520,117 @@ class LinkValidateUrlLight extends DrupalWebTestCase {
}
/**
- * Translates the LINK type constants to english for display and debugging of tests
+ * Setup.
*/
- function name_Link_Type($type) {
+ public function setUp() {
+ parent::setUp('link');
+ }
+
+ /**
+ * Name Link Type.
+ *
+ * Translates the LINK type constants to english for display and debugging of
+ * tests.
+ *
+ * @codingStandardsIgnoreStart
+ */
+ public function name_Link_Type($type) {
+ // @codingStandardsIgnoreEnd
switch ($type) {
case LINK_FRONT:
return "Front";
+
case LINK_EMAIL:
return "Email";
+
case LINK_NEWS:
return "Newsgroup";
+
case LINK_INTERNAL:
return "Internal Link";
+
case LINK_EXTERNAL:
return "External Link";
+
case FALSE:
return "Invalid Link";
+
default:
return "Bad Value:" . $type;
}
}
- // Make sure that a link labelled works.
- function testValidateFrontLink() {
+ /**
+ * Make sure that a link labeled works.
+ */
+ public function testValidateFrontLink() {
$valid = link_validate_url('');
- $this->assertEqual(LINK_FRONT, $valid, 'Make sure that front link is verfied and identified');
+ $this->assertEqual(LINK_FRONT, $valid, 'Make sure that front link is verified and identified');
}
- function testValidateEmailLink() {
+ /**
+ * Validate Email Link.
+ */
+ public function testValidateEmailLink() {
$valid = link_validate_url('mailto:bob@example.com');
$this->assertEqual(LINK_EMAIL, $valid, "Make sure a basic mailto is verified and identified");
}
- function testValidateEmailLinkBad() {
+ /**
+ * Validate Email Link Bad.
+ */
+ public function testValidateEmailLinkBad() {
$valid = link_validate_url(':bob@example.com');
$this->assertEqual(FALSE, $valid, 'Make sure just a bad address is correctly failed');
}
- function testValidateNewsgroupLink() {
+ /**
+ * Validate Newsgroup Link.
+ */
+ public function testValidateNewsgroupLink() {
$valid = link_validate_url('news:comp.infosystems.www.misc');
$this->assertEqual(LINK_NEWS, $valid, 'Make sure link to newsgroup validates as news.');
}
- function testValidateNewsArticleLink() {
+ /**
+ * Validate News Article Link.
+ */
+ public function testValidateNewsArticleLink() {
$valid = link_validate_url('news:hj0db8$vrm$1@news.eternal-september.org');
- $this->assertEqual(LINK_NEWS, $valid, 'Make sure link to specific article valiates as news.');
+ $this->assertEqual(LINK_NEWS, $valid, 'Make sure link to specific article validates as news.');
}
- function testValidateBadNewsgroupLink() {
+ /**
+ * Validate Bad Newsgroup Link.
+ */
+ public function testValidateBadNewsgroupLink() {
$valid = link_validate_url('news:comp.bad_name.misc');
$this->assertEqual(FALSE, $valid, 'newsgroup names can\'t contain underscores, so it should come back as invalid.');
}
- function testValidateInternalLinks() {
+ /**
+ * Validate Internal Links.
+ */
+ public function testValidateInternalLinks() {
+ $tempfile = drupal_tempnam('public://files', 'test');
$links = array(
- 'node/5',
'rss.xml',
- 'files/test.jpg',
- '/var/www/test',
+ file_uri_target($tempfile),
+ drupal_realpath($tempfile),
);
-
+
foreach ($links as $link) {
+ $type = link_url_type($link);
+ $this->assertEqual(LINK_INTERNAL, $type, 'Test ' . $link . ' is an internal link.');
$valid = link_validate_url($link);
- $this->assertEqual(LINK_INTERNAL, $valid, 'Test ' . $link . ' internal link.');
+ $this->assertTrue($valid, 'Test ' . $link . ' is valid internal link.');
}
}
- function testValidateExternalLinks() {
+ /**
+ * Validate External Links.
+ */
+ public function testValidateExternalLinks() {
$links = array(
'http://localhost:8080/',
'www.example.com',
@@ -446,9 +645,8 @@ class LinkValidateUrlLight extends DrupalWebTestCase {
'http://255.255.255.255:4823/',
'www.test-site.com',
'http://example.com/index.php?q=node/123',
- 'http://example.com/index.php?page=this\that',
'http://example.com/?first_name=Joe Bob&last_name=Smith',
- // Anchors
+ // Anchors.
'http://www.example.com/index.php#test',
'http://www.example.com/index.php#this@that.',
'http://www.example.com/index.php#',
@@ -456,39 +654,61 @@ class LinkValidateUrlLight extends DrupalWebTestCase {
'http://www.archive.org/stream/aesopsfables00aesorich#page/n7/mode/2up',
'http://www.example.com/blah/#this@that?',
);
+
// Test all of the protocols.
- $allowed_protocols = variable_get('filter_allowed_protocols', array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal'));
+ $allowed_protocols = variable_get('filter_allowed_protocols', array(
+ 'http',
+ 'https',
+ 'ftp',
+ 'news',
+ 'nntp',
+ 'telnet',
+ 'mailto',
+ 'irc',
+ 'ssh',
+ 'sftp',
+ 'webcal',
+ ));
+
foreach ($allowed_protocols as $protocol) {
if ($protocol !== 'news' && $protocol !== 'mailto') {
$links[] = $protocol . '://www.example.com';
}
}
foreach ($links as $link) {
+ $type = link_url_type($link);
+ $this->assertEqual(LINK_EXTERNAL, $type, 'Testing that ' . $link . ' is an external link.');
$valid = link_validate_url($link);
- $this->assertEqual(LINK_EXTERNAL, $valid, 'Testing that ' . $link . ' is a valid external link.');
- // The following two lines are commented out and only used for comparisons.
- //$valid2 = valid_url($link, TRUE);
- //$this->assertEqual(TRUE, $valid2, "Using valid_url() on $link.");
+ $this->assertTrue($valid, 'Test ' . $link . ' is valid external link.');
+ // The following two lines are commented out and only used for
+ // comparisons.
+ // $valid2 = valid_url($link, TRUE);
+ // $this->assertEqual(TRUE, $valid2, "Using valid_url() on $link.");.
}
- // Test if we can make a tld valid:
- variable_set('link_extra_domains', array('frog'));
- $valid = link_validate_url('http://www.example.frog');
- $this->assertEqual(LINK_EXTERNAL, $valid, "Testing that http://www.example.frog is a valid external link if we've added 'frog' to the list of valid domains.");
}
- function testInvalidExternalLinks() {
+ /**
+ * Check Invalid External Links.
+ */
+ public function testInvalidExternalLinks() {
$links = array(
'http://www.ex ample.com/',
- 'http://25.0.0/', // bad ip!
+ // Bad ip!
+ 'http://25.0.0/',
'http://4827.0.0.2/',
- '//www.example.com/',
- 'http://www.testß.com/', // ß not allowed in domain names!
- 'http://www.example.frog/', // Bad TLD
- //'http://www.-fudge.com/', // domains can't have sections starting with a dash.
+ // ß not allowed in domain names!
+ 'http://www.testß.com/',
+ // Bad TLD.
+ 'http://.www.foo.bar./',
+ // Domains can't have sections starting with a dash.
+ // 'http://www.-fudge.com/',
+ 'http://example.com/index.php?page=this\that',
+ 'example@example.com',
);
foreach ($links as $link) {
$valid = link_validate_url($link);
$this->assertEqual(FALSE, $valid, 'Testing that ' . $link . ' is not a valid link.');
}
}
+
}
diff --git a/sites/all/modules/contrib/fields/link/views/link.views.inc b/sites/all/modules/contrib/fields/link/views/link.views.inc
index 27d5182..8c080ad 100644
--- a/sites/all/modules/contrib/fields/link/views/link.views.inc
+++ b/sites/all/modules/contrib/fields/link/views/link.views.inc
@@ -1,4 +1,7 @@
default_actions();
$form['title'] = array(
@@ -52,7 +58,7 @@ class link_views_handler_argument_target extends views_handler_argument {
$form['wildcard'] = array(
'#prefix' => '
',
- // prefix and no suffix means these two items will be grouped together.
+ // Prefix and no suffix means these two items will be grouped together.
'#type' => 'textfield',
'#title' => t('Wildcard'),
'#size' => 20,
@@ -125,8 +131,8 @@ class link_views_handler_argument_target extends views_handler_argument {
asort($validate_types);
$form['validate_type']['#options'] = $validate_types;
- // Show this gadget if *anything* but 'none' is selected
+ // Show this gadget if *anything* but 'none' is selected.
$form['validate_fail'] = array(
'#type' => 'select',
'#title' => t('Action to take if argument does not validate'),
@@ -140,10 +146,11 @@ class link_views_handler_argument_target extends views_handler_argument {
*
* The argument sent may be found at $this->argument.
*/
- function query($group_by = FALSE) {
+ public function query($group_by = FALSE) {
$this->ensure_my_table();
// Because attributes are stored serialized, our only option is to also
// serialize the data we're searching for and use LIKE to find similar data.
$this->query->add_where(0, $this->table_alias . ' . ' . $this->real_field . " LIKE '%%%s%'", serialize(array('target' => $this->argument)));
}
+
}
diff --git a/sites/all/modules/contrib/fields/link/views/link_views_handler_filter_protocol.inc b/sites/all/modules/contrib/fields/link/views/link_views_handler_filter_protocol.inc
index a020b4e..ae00c17 100644
--- a/sites/all/modules/contrib/fields/link/views/link_views_handler_filter_protocol.inc
+++ b/sites/all/modules/contrib/fields/link/views/link_views_handler_filter_protocol.inc
@@ -7,22 +7,30 @@
/**
* Filter handler for limiting a view to URLs of a certain protocol.
+ *
+ * @codingStandardsIgnoreStart
*/
class link_views_handler_filter_protocol extends views_handler_filter_string {
+
/**
* Set defaults for the filter options.
+ *
+ * @codingStandardsIgnoreEnd
*/
- function options(&$options) {
- parent::options($options);
+ function option_definition() {
+ $options = parent::option_definition();
+
$options['operator'] = 'OR';
$options['value'] = 'http';
$options['case'] = 0;
+
+ return $options;
}
/**
* Define the operators supported for protocols.
*/
- function operators() {
+ public function operators() {
$operators = array(
'OR' => array(
'title' => t('Is one of'),
@@ -35,7 +43,13 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
return $operators;
}
- function options_form(&$form, &$form_state) {
+ /**
+ * Options form.
+ *
+ * @codingStandardsIgnoreStart
+ */
+ public function options_form(&$form, &$form_state) {
+ //@codingStandardsIgnoreEnd
parent::options_form($form, $form_state);
$form['case'] = array(
'#type' => 'value',
@@ -45,8 +59,11 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
/**
* Provide a select list to choose the desired protocols.
+ *
+ * @codingStandardsIgnoreStart
*/
- function value_form(&$form, &$form_state) {
+ public function value_form(&$form, &$form_state) {
+ // @codingStandardsIgnoreEnd
// We have to make some choices when creating this as an exposed
// filter form. For example, if the operator is locked and thus
// not rendered, we can't render dependencies; instead we only
@@ -61,7 +78,19 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
'#type' => 'select',
'#title' => t('Protocol'),
'#default_value' => $this->value,
- '#options' => drupal_map_assoc(variable_get('filter_allowed_protocols', array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal'))),
+ '#options' => drupal_map_assoc(variable_get('filter_allowed_protocols', array(
+ 'http',
+ 'https',
+ 'ftp',
+ 'news',
+ 'nntp',
+ 'telnet',
+ 'mailto',
+ 'irc',
+ 'ssh',
+ 'sftp',
+ 'webcal',
+ ))),
'#multiple' => 1,
'#size' => 4,
'#description' => t('The protocols displayed here are those globally available. You may add more protocols by modifying the filter_allowed_protocols variable in your installation.'),
@@ -71,8 +100,11 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
/**
* Filter down the query to include only the selected protocols.
+ *
+ * @codingStandardsIgnoreStart
*/
- function op_protocol($field, $upper) {
+ public function op_protocol($field, $upper) {
+ // @codingStandardsIgnoreEnd
$db_type = db_driver();
$protocols = $this->value;
@@ -82,20 +114,25 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
// Simple case, the URL begins with the specified protocol.
$condition = $field . ' LIKE \'' . $protocol . '%\'';
- // More complex case, no protocol specified but is automatically cleaned up
- // by link_cleanup_url(). RegEx is required for this search operation.
+ // More complex case, no protocol specified but is automatically cleaned
+ // up by link_cleanup_url(). RegEx is required for this search operation.
if ($protocol == 'http') {
- $LINK_DOMAINS = _link_domains();
+ $link_domains = _link_domains();
if ($db_type == 'pgsql') {
- // PostGreSQL code has NOT been tested. Please report any problems to the link issue queue.
- // pgSQL requires all slashes to be double escaped in regular expressions.
+ // PostGreSQL code has NOT been tested. Please report any problems to
+ // the link issue queue.
+ // pgSQL requires all slashes to be double escaped in regular
+ // expressions.
+ // @codingStandardsIgnoreLine
// See http://www.postgresql.org/docs/8.1/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP
- $condition .= ' OR ' . $field . ' ~* \'' . '^(([a-z0-9]([a-z0-9\\-_]*\\.)+)(' . $LINK_DOMAINS . '|[a-z][a-z]))' . '\'';
+ $condition .= ' OR ' . $field . ' ~* \'' . '^(([a-z0-9]([a-z0-9\\-_]*\\.)+)(' . $link_domains . '|[a-z][a-z]))' . '\'';
}
else {
- // mySQL requires backslashes to be double (triple?) escaped within character classes.
+ // mySQL requires backslashes to be double (triple?) escaped within
+ // character classes.
+ // @codingStandardsIgnoreLine
// See http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html#operator_regexp
- $condition .= ' OR ' . $field . ' REGEXP \'' . '^(([a-z0-9]([a-z0-9\\\-_]*\.)+)(' . $LINK_DOMAINS . '|[a-z][a-z]))' . '\'';
+ $condition .= ' OR ' . $field . ' REGEXP \'' . '^(([a-z0-9]([a-z0-9\\\-_]*\.)+)(' . $link_domains . '|[a-z][a-z]))' . '\'';
}
}
@@ -104,4 +141,5 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
$this->query->add_where($this->options['group'], implode(' ' . $this->operator . ' ', $where_conditions));
}
+
}
diff --git a/sites/all/modules/contrib/fields/title/CHANGELOG.txt b/sites/all/modules/contrib/fields/title/CHANGELOG.txt
index 3ccce43..c34f12d 100644
--- a/sites/all/modules/contrib/fields/title/CHANGELOG.txt
+++ b/sites/all/modules/contrib/fields/title/CHANGELOG.txt
@@ -3,6 +3,46 @@ Title 7.x-1.x, xxxx-xx-xx
-------------------------
+Title 7.x-1.0-alpha9, 2017-01-13
+--------------------------------
+#2757739 by dewalt, Pol: Token value is not sanitized, when replaced from title field.
+#2813673 by plach, czigor, Stevel: Tests broken since new permission in drupal core.
+
+
+Title 7.x-1.0-alpha8, 2016-03-28
+--------------------------------
+#2465141 by DuaelFr, Matthijs, jfrederick: Used entity_uri() options if given.
+#2602568 by sdstyles: Fixed title_entity_label() should be documented as
+ callback implementation.
+#2605040 by ShaxA, joelpittet, sylus: Removed recursive call to
+ entity_get_info().
+#2040055 by flux423, cs_shadow, visabhishek, plach, OlyN: Fixed Notice:
+ Undefined index: safe_value in title_field_formatter_view().
+#2426105 by Peacog, jcisio: Fixed Views "Link this field to the original entity"
+ doesn't work when using relationship.
+#2286147 by plach: Language fallback does not work when an entity translation is
+ unpublished.
+#2286145 by plach: Prevent empty translations from being synced into the legacy
+ field.
+#1772116 by duellj, GaëlG | f4o: Fixed Menu link title is not getting node title
+ by default.
+#1779268 by ndobromirov | brycesenz: Undefined index: field_name in
+ title_field_views_data_alter().
+#1441224 by MiroslavBanov | OPIN: Fieldgroup and Title break Manage Fields UI.
+#1980520 by StoraH, pbz1912: Fixed Empty wrapper tags.
+#1920096 by Johnny vd Laar | GiorgosK: Fixed Title incompatibility with the Term
+ reference widget
+#1991712 by milesw: Fixed Title displays wrong revision using Revisioning
+ module.
+#1907078 by sylus: Fixed Undefined index: field_name() in
+ title_field_replacement_enabled().
+#1961810 by peximo | fcortez: Fixed Wrap tag classes are not being inserted.
+#1850866 by B-Prod: Fixed Undefined index 'format' in
+ title_field_text_with_summary_sync_set().
+#1269076 by plach, das-peter, danielnolde | renat: Fixed Translated
+ title_field replaces node->title with translated value.
+
+
Title 7.x-1.0-alpha7, 2013-03-18
--------------------------------
#1919640 by peximo: Fixed Empty tag shown when the title field is displayed.
diff --git a/sites/all/modules/contrib/fields/title/MAINTAINERS.txt b/sites/all/modules/contrib/fields/title/MAINTAINERS.txt
new file mode 100644
index 0000000..f20ad65
--- /dev/null
+++ b/sites/all/modules/contrib/fields/title/MAINTAINERS.txt
@@ -0,0 +1,13 @@
+
+Title is built and maintained by the Drupal project community.
+Everyone is encouraged to submit issues and changes (patches) to improve it, and
+to contribute in other ways -- see http://drupal.org/contribute to find out how.
+
+Project maintainers
+-------------------
+
+The Title maintainers oversee the development of the project as a whole. The project
+maintainers for Title are:
+
+- Francesco Placella 'plach' , branch 7.x-1.x
+- Sam Becker 'Sam152' , branch 8.x-2.x
diff --git a/sites/all/modules/contrib/fields/title/tests/title.test b/sites/all/modules/contrib/fields/title/tests/title.test
index e88eb52..e66d095 100644
--- a/sites/all/modules/contrib/fields/title/tests/title.test
+++ b/sites/all/modules/contrib/fields/title/tests/title.test
@@ -9,6 +9,7 @@
* Tests for legacy field replacement.
*/
class TitleFieldReplacementTestCase extends DrupalWebTestCase {
+
public static function getInfo() {
return array(
'name' => 'Field replacement',
@@ -17,14 +18,17 @@ class TitleFieldReplacementTestCase extends DrupalWebTestCase {
);
}
- function setUp() {
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
parent::setUp('entity', 'field_test', 'title', 'title_test');
}
/**
* Test field replacement API and workflow.
*/
- function testFieldReplacementWorkflow() {
+ public function testFieldReplacementWorkflow() {
$info = entity_get_info('test_entity');
$label_key = $info['entity keys']['label'];
$field_name = $label_key . '_field';
@@ -72,12 +76,13 @@ class TitleFieldReplacementTestCase extends DrupalWebTestCase {
// Clear field cache so synchronization can be performed on field attach
// load.
cache_clear_all('*', 'cache_field');
+ drupal_static_reset();
// Check that the replacing field value is correctly synchronized on load
// and view.
$entity = title_test_entity_test_load($entity);
title_test_phase_check('after_load', $entity);
- $build = entity_view('test_entity', array($entity->ftid => $entity));
+ entity_view('test_entity', array($entity->ftid => $entity));
foreach (title_test_phase_store() as $phase => $value) {
$this->assertTrue($value, t('Field synchronization is correctly performed on %phase.', array('%phase' => $phase)));
@@ -94,8 +99,16 @@ class TitleFieldReplacementTestCase extends DrupalWebTestCase {
/**
* Test field replacement UI.
*/
- function testFieldReplacementUI() {
- $admin_user = $this->drupalCreateUser(array('access administration pages', 'view the administration theme', 'administer content types', 'administer taxonomy', 'administer comments'));
+ public function testFieldReplacementUI() {
+ $permissions = array(
+ 'access administration pages',
+ 'view the administration theme',
+ 'administer content types',
+ 'administer taxonomy',
+ 'administer comments',
+ 'administer fields',
+ );
+ $admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($admin_user);
foreach (entity_get_info() as $entity_type => $entity_info) {
@@ -146,12 +159,14 @@ class TitleFieldReplacementTestCase extends DrupalWebTestCase {
}
}
}
+
}
/**
* Tests for legacy field replacement.
*/
class TitleAdminSettingsTestCase extends DrupalWebTestCase {
+
public static function getInfo() {
return array(
'name' => 'Admin settings',
@@ -160,7 +175,10 @@ class TitleAdminSettingsTestCase extends DrupalWebTestCase {
);
}
- function setUp() {
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
parent::setUp('field_test', 'title', 'title_test');
$admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer taxonomy'));
$this->drupalLogin($admin_user);
@@ -169,15 +187,18 @@ class TitleAdminSettingsTestCase extends DrupalWebTestCase {
/**
* Check for automated title_field attachment.
*/
- function testAutomatedFieldAttachement() {
- $this->assertAutomatedFieldAttachement(TRUE);
- $this->assertAutomatedFieldAttachement(FALSE);
+ public function testAutomatedFieldAttachment() {
+ $this->doTestAutomatedFieldAttachment(TRUE);
+ $this->doTestAutomatedFieldAttachment(FALSE);
}
/**
- * Check that the fields are replaced or skipped depdening on the given value.
+ * Check that the fields are replaced or skipped depending on the given value.
+ *
+ * @param bool $enabled
+ * Whether replacement is enabled or not.
*/
- function assertAutomatedFieldAttachement($enabled) {
+ public function doTestAutomatedFieldAttachment($enabled) {
$edit = array(
'title_taxonomy_term[auto_attach][name]' => $enabled,
'title_taxonomy_term[auto_attach][description]' => $enabled,
@@ -197,12 +218,14 @@ class TitleAdminSettingsTestCase extends DrupalWebTestCase {
$this->assertTrue(title_field_replacement_enabled($entity_type, $bundle, 'name') == $enabled, 'Name field correctly processed.');
$this->assertTrue(title_field_replacement_enabled($entity_type, $bundle, 'description') == $enabled, 'Description field correctly processed.');
}
+
}
/**
* Tests for legacy field replacement.
*/
class TitleTranslationTestCase extends DrupalWebTestCase {
+
public static function getInfo() {
return array(
'name' => 'Replaced fields translation',
@@ -211,11 +234,22 @@ class TitleTranslationTestCase extends DrupalWebTestCase {
);
}
- function setUp() {
- parent::setUp('locale', 'entity_translation', 'title');
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp('locale', 'entity_translation', 'title', 'field_test', 'title_test');
// Create a power user.
- $admin_user = $this->drupalCreateUser(array('administer modules', 'view the administration theme', 'administer languages', 'administer taxonomy', 'administer entity translation', 'translate any entity'));
+ $permissions = array(
+ 'administer modules',
+ 'view the administration theme',
+ 'administer languages',
+ 'administer taxonomy',
+ 'administer entity translation',
+ 'translate any entity',
+ );
+ $admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($admin_user);
// Enable a translation language.
@@ -240,6 +274,7 @@ class TitleTranslationTestCase extends DrupalWebTestCase {
$edit = array(
'name' => $this->randomString(),
'machine_name' => $name,
+ 'entity_translation_taxonomy' => 1,
);
$this->drupalPost('admin/structure/taxonomy/add', $edit, t('Save'));
$this->vocabulary = taxonomy_vocabulary_machine_name_load($name);
@@ -252,19 +287,118 @@ class TitleTranslationTestCase extends DrupalWebTestCase {
$t_args = array('%legacy_field' => $legacy_field);
$this->assertTrue(field_info_instance($entity_type, $info['field']['field_name'], $name), t('The %legacy_field field has been correctly replaced.', $t_args));
}
+
+ // Ensure static caches do not interfere with API calls.
+ drupal_static_reset();
}
/**
- * Test taxonomy translation workflow.
+ * Tests taxonomy programmatic translation workflow.
*/
- function testTranslationWorkflow() {
+ public function testProgrammaticTranslationWorkflow() {
+ // Create a taxonomy term and assign it an original language different from
+ // the default language.
+ $langcode = 'it';
+ $original_values = array(
+ 'name' => $langcode . '_' . $this->randomName(),
+ 'description' => $langcode . '_' . $this->randomName(),
+ );
+ $term = (object) ($original_values + array(
+ 'format' => 'filtered_html',
+ 'vocabulary_machine_name' => $this->vocabulary->machine_name,
+ 'vid' => $this->vocabulary->vid,
+ ));
+ entity_translation_get_handler('taxonomy_term', $term)->setOriginalLanguage($langcode);
+ taxonomy_term_save($term);
+ $this->assertTrue($this->checkLegacyValues($term, $original_values), 'Legacy field values correctly stored.');
+ $term = $this->termLoad($term->tid);
+ $this->assertTrue($this->checkFieldValues($term, $original_values, $langcode), 'Replacing field values correctly created from the legacy field values.');
+
+ // Pollute synchronization cache to ensure the expected values are stored
+ // anyway.
+ title_entity_sync('taxonomy_term', $term, $langcode);
+
+ // Create a translation using the default language.
+ $translation_langcode = language_default()->language;
+ $translated_values = array(
+ 'name' => $translation_langcode . '_' . $this->randomName(),
+ 'description' => $translation_langcode . '_' . $this->randomName(),
+ );
+ foreach ($translated_values as $name => $value) {
+ $term->{$name} = $value;
+ }
+ $translation = array(
+ 'language' => $translation_langcode,
+ 'source' => $langcode,
+ 'uid' => $this->loggedInUser->uid,
+ 'status' => 1,
+ 'translate' => 0,
+ 'created' => REQUEST_TIME,
+ 'changed' => REQUEST_TIME,
+ );
+ entity_translation_get_handler('taxonomy_term', $term)->setTranslation($translation);
+ taxonomy_term_save($term);
+ $this->assertTrue($this->checkLegacyValues($term, $original_values), 'Legacy field values correctly stored.');
+ $term = $this->termLoad($term->tid, $translation_langcode);
+ $this->assertTrue($this->checkFieldValues($term, $translated_values, $translation_langcode), 'Replacing field translations correctly created.');
+ $this->assertTrue($this->checkFieldValues($term, $original_values, $langcode, FALSE), 'Replacing field original values correctly preserved.');
+
+ // Delete the translation.
+ entity_translation_get_handler('taxonomy_term', $term)->removeTranslation($translation_langcode);
+ taxonomy_term_save($term);
+ $this->assertTrue($this->checkLegacyValues($term, $original_values), 'Legacy field values correctly stored.');
+ $term = $this->termLoad($term->tid, $langcode);
+ $this->assertTrue($this->checkFieldValues($term, $original_values, $langcode), 'Replacing field translations correctly deleted.');
+
+ // Make the term language neutral.
+ entity_translation_get_handler('taxonomy_term', $term)->setOriginalLanguage(LANGUAGE_NONE);
+ foreach ($original_values as $name => $value) {
+ $field_name = $name . '_field';
+ $term->{$field_name}[LANGUAGE_NONE] = $term->{$field_name}[$langcode];
+ $term->{$field_name}[$langcode] = array();
+ }
+ taxonomy_term_save($term);
+ $this->assertTrue($this->checkLegacyValues($term, $original_values), 'Legacy field values correctly stored.');
+ $term = $this->termLoad($term->tid);
+ $this->assertTrue($this->checkFieldValues($term, $original_values, LANGUAGE_NONE), 'Term original language correctly changed to the former translation language.');
+
+ // Change the term language to the former translation language.
+ entity_translation_get_handler('taxonomy_term', $term)->setOriginalLanguage($translation_langcode);
+ foreach ($original_values as $name => $value) {
+ $field_name = $name . '_field';
+ $term->{$field_name}[$translation_langcode] = $term->{$field_name}[LANGUAGE_NONE];
+ $term->{$field_name}[LANGUAGE_NONE] = array();
+ }
+ taxonomy_term_save($term);
+ $this->assertTrue($this->checkLegacyValues($term, $original_values), 'Legacy field values correctly stored.');
+ $term = $this->termLoad($term->tid, $translation_langcode);
+ $this->assertTrue($this->checkFieldValues($term, $original_values, $translation_langcode), 'Term original language correctly changed to language neutral.');
+
+ // Make a replacing field untranslatable and change its value.
+ $field_name = 'name_field';
+ $field = field_info_field($field_name);
+ $field['translatable'] = FALSE;
+ field_update_field($field);
+ $original_values['name'] = LANGUAGE_NONE . '_' . $this->randomName();
+ $term->name = $original_values['name'];
+ taxonomy_term_save($term);
+ $this->assertTrue($this->checkLegacyValues($term, $original_values), 'Legacy field values correctly stored.');
+ $term = $this->termLoad($term->tid);
+ $this->assertEqual($term->{$field_name}[LANGUAGE_NONE][0]['value'], $original_values['name'], 'Untranslatable replacing field on translatable entity correctly handled.');
+ }
+
+ /**
+ * Tests taxonomy form translation workflow.
+ */
+ public function testFormTranslationWorkflow() {
// Create a taxonomy term and check that legacy fields are properly
// populated.
$original_values = array(
'name' => $this->randomName(),
'description' => $this->randomName(),
);
- $edit = $this->editValues($original_values, 'en');
+ $langcode = 'en';
+ $edit = $this->editValues($original_values, $langcode);
$this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/add', $edit, t('Save'));
$term = current(entity_load('taxonomy_term', FALSE, array('name' => $original_values['name']), TRUE));
$this->assertEqual($term->description, $original_values['description'], t('Taxonomy term created.'));
@@ -275,11 +409,12 @@ class TitleTranslationTestCase extends DrupalWebTestCase {
'name' => $this->randomName(),
'description' => $this->randomName(),
);
+ $translation_langcode = 'it';
$edit = $this->editValues($translated_values, 'it');
- $this->drupalPost('it/taxonomy/term/' . $term->tid . '/edit/add/en/it', $edit, t('Save'));
- $term = current(entity_load('taxonomy_term', array($term->tid), array(), TRUE));
- $this->assertTrue($this->checkFieldValues($term, $translated_values, 'it'), t('Taxonomy term translation created.'));
- $this->assertTrue($this->checkFieldValues($term, $original_values, 'en'), t('Taxonomy term original values preserved.'));
+ $this->drupalPost($translation_langcode . '/taxonomy/term/' . $term->tid . '/edit/add/' . $langcode . '/' . $translation_langcode, $edit, t('Save'));
+ $term = $this->termLoad($term->tid);
+ $this->assertTrue($this->checkFieldValues($term, $translated_values, $translation_langcode, FALSE), t('Taxonomy term translation created.'));
+ $this->assertTrue($this->checkFieldValues($term, $original_values, $langcode), t('Taxonomy term original values preserved.'));
// Check that legacy fields have the correct values.
$this->assertEqual($term->name, $original_values['name'], t('Taxonomy term name correctly stored.'));
@@ -291,31 +426,69 @@ class TitleTranslationTestCase extends DrupalWebTestCase {
'name' => $this->randomName(),
'description' => $this->randomName(),
);
- $edit = $this->editValues($translated_values, 'it');
- $this->drupalPost('it/taxonomy/term/' . $term->tid . '/edit/it', $edit, t('Save'));
- $term = current(entity_load('taxonomy_term', array($term->tid), array(), TRUE));
- $this->assertTrue($this->checkFieldValues($term, $translated_values, 'it'), t('Taxonomy term translation updated.'));
- $this->assertTrue($this->checkFieldValues($term, $original_values, 'en'), t('Taxonomy term original values preserved.'));
+ $edit = $this->editValues($translated_values, $translation_langcode);
+ $this->drupalPost($translation_langcode . '/taxonomy/term/' . $term->tid . '/edit/' . $translation_langcode, $edit, t('Save'));
+ $term = $this->termLoad($term->tid);
+ $this->assertTrue($this->checkFieldValues($term, $translated_values, $translation_langcode, FALSE), t('Taxonomy term translation updated.'));
+ $this->assertTrue($this->checkFieldValues($term, $original_values, $langcode), t('Taxonomy term original values preserved.'));
// Check that legacy fields have the correct values.
$this->assertEqual($term->name, $original_values['name'], t('Taxonomy term name correctly stored.'));
$this->assertEqual($term->description, $original_values['description'], t('Taxonomy term description correctly stored.'));
}
+ /**
+ * Loads a term using the given language as active language.
+ *
+ * @param int $tid
+ * The term identifier.
+ * @param string|null $langcode
+ * (optional) The active language to be set. Defaults to none.
+ *
+ * @return object|bool
+ * A term object.
+ */
+ protected function termLoad($tid, $langcode = NULL) {
+ drupal_static_reset();
+ title_active_language($langcode);
+ return current(entity_load('taxonomy_term', array($tid), array(), TRUE));
+ }
+
+ /**
+ * Returns the drupalPost() $edit array corresponding to the given values.
+ */
protected function editValues($values, $langcode) {
$edit = array();
- foreach ($values as $key => $value) {
- $edit["{$key}_field[{$langcode}][0][value]"] = $value;
+ foreach ($values as $name => $value) {
+ $edit["{$name}_field[{$langcode}][0][value]"] = $value;
}
return $edit;
}
- protected function checkFieldValues($term, $values, $langcode) {
- foreach ($values as $key => $value) {
- if ($term->{$key . '_field'}[$langcode][0]['value'] != $value) {
+ /**
+ * Checks that the field values and optionally the legacy ones match the given values.
+ */
+ protected function checkFieldValues($term, $values, $langcode, $legacy_match = TRUE) {
+ foreach ($values as $name => $value) {
+ $field_value = $term->{$name . '_field'}[$langcode][0]['value'];
+ if ($field_value != $value || ($legacy_match !== ($field_value == $term->{$name}))) {
return FALSE;
}
}
return TRUE;
}
+
+ /**
+ * Checks that the legacy field values stored in the database match the given values.
+ */
+ protected function checkLegacyValues($term, $values) {
+ $record = db_query('SELECT * FROM {taxonomy_term_data} t WHERE t.tid = :tid', array(':tid' => $term->tid))->fetchAssoc();
+ foreach ($values as $name => $value) {
+ if ($record[$name] != $value) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+ }
+
}
diff --git a/sites/all/modules/contrib/fields/title/tests/title_test.info b/sites/all/modules/contrib/fields/title/tests/title_test.info
index 45846d3..1e5d2e5 100644
--- a/sites/all/modules/contrib/fields/title/tests/title_test.info
+++ b/sites/all/modules/contrib/fields/title/tests/title_test.info
@@ -7,9 +7,9 @@ dependencies[] = title
dependencies[] = entity
dependencies[] = entity_translation
-; Information added by drupal.org packaging script on 2013-03-18
-version = "7.x-1.0-alpha7"
+; Information added by Drupal.org packaging script on 2017-01-13
+version = "7.x-1.0-alpha9"
core = "7.x"
project = "title"
-datestamp = "1363626024"
+datestamp = "1484302985"
diff --git a/sites/all/modules/contrib/fields/title/title.admin.inc b/sites/all/modules/contrib/fields/title/title.admin.inc
index 9cb0065..380cabe 100644
--- a/sites/all/modules/contrib/fields/title/title.admin.inc
+++ b/sites/all/modules/contrib/fields/title/title.admin.inc
@@ -14,20 +14,16 @@ function title_form_field_ui_overview(&$form, &$form_state) {
if (!empty($entity_info['field replacement'])) {
$field_replacement_info = $entity_info['field replacement'];
$admin_path = _field_ui_bundle_admin_path($form['#entity_type'], $form['#bundle']);
- $form['fields']['#header'][6]['colspan'] += 1;
foreach (element_children($form['fields']) as $field_name) {
if (isset($field_replacement_info[$field_name])) {
- $form['fields'][$field_name]['field_replacement'] = array(
+ $form['fields'][$field_name]['delete'] = array(
'#type' => 'link',
'#title' => t('replace'),
'#href' => $admin_path . '/fields/replace/' . $field_name,
'#options' => array('attributes' => array('title' => t('Replace %field with a customizable field instance that can be translated.', array('%field' => $field_name)))),
);
}
- else {
- $form['fields'][$field_name]['field_replacement'] = array();
- }
}
}
}
diff --git a/sites/all/modules/contrib/fields/title/title.core.inc b/sites/all/modules/contrib/fields/title/title.core.inc
index d75e656..2af63f9 100644
--- a/sites/all/modules/contrib/fields/title/title.core.inc
+++ b/sites/all/modules/contrib/fields/title/title.core.inc
@@ -127,7 +127,7 @@ function title_field_text_sync_get($entity_type, $entity, $legacy_field, $info,
$items = $entity->{$field_name}[$langcode];
$value = !empty($items[0]['value']) ? $items[0]['value'] : NULL;
}
- return $value;
+ return array($legacy_field => $value);
}
/**
@@ -142,25 +142,31 @@ function title_field_text_sync_set($entity_type, $entity, $legacy_field, $info,
*/
function title_field_text_with_summary_sync_get($entity_type, $entity, $legacy_field, $info, $langcode) {
$value = NULL;
+ $format = NULL;
$format_key = $info['additional keys']['format'];
$field_name = $info['field']['field_name'];
// Return values only if there is any available to process for the current
// language.
if (!empty($entity->{$field_name}[$langcode]) && is_array($entity->{$field_name}[$langcode])) {
- $entity->{$format_key} = $entity->{$field_name}[$langcode][0]['format'];
$items = $entity->{$field_name}[$langcode];
$value = !empty($items[0]['value']) ? $items[0]['value'] : NULL;
+ $format = $entity->{$field_name}[$langcode][0]['format'];
}
- return $value;
+ return array(
+ $legacy_field => $value,
+ $format_key => $format,
+ );
}
/**
* Sync back callback for the text with summary field type.
*/
function title_field_text_with_summary_sync_set($entity_type, $entity, $legacy_field, $info, $langcode) {
- $format_key = $info['additional keys']['format'];
- $entity->{$info['field']['field_name']}[$langcode][0]['value'] = $entity->{$legacy_field};
- $entity->{$info['field']['field_name']}[$langcode][0]['format'] = $entity->{$format_key};
+ foreach (array('value' => $legacy_field, 'format' => $info['additional keys']['format']) as $column => $name) {
+ if (isset($entity->{$name})) {
+ $entity->{$info['field']['field_name']}[$langcode][0][$column] = $entity->{$name};
+ }
+ }
}
/**
diff --git a/sites/all/modules/contrib/fields/title/title.field.inc b/sites/all/modules/contrib/fields/title/title.field.inc
index d94905b..1523fc1 100644
--- a/sites/all/modules/contrib/fields/title/title.field.inc
+++ b/sites/all/modules/contrib/fields/title/title.field.inc
@@ -97,36 +97,48 @@ function title_field_formatter_settings_summary($field, $instance, $view_mode) {
*/
function title_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$settings = $display['settings'];
- $output = isset($items[0]) ? $items[0]['safe_value'] : '';
-
- if (!empty($output) && $settings['title_link'] == 'content') {
- $uri = entity_uri($entity_type, $entity);
- $output = l($output, $uri['path'], array('html' => TRUE));
+ $output = '';
+ if (isset($items[0]['safe_value'])) {
+ $output = $items[0]['safe_value'];
}
+ elseif (isset($items[0]['value'])) {
+ $output = _text_sanitize($instance, $langcode, $items[0], 'value');
+ }
+ $element = array();
- $wrap_tag = empty($settings['title_style']) ? '_none' : $settings['title_style'];
-
- if ($wrap_tag != '_none') {
- $element = array(
- 'element' => array(
- '#tag' => $wrap_tag,
- '#value' => $output,
- ),
- );
-
- if (!empty($settings['title_class'])) {
- $element['#attributes'] = array('class' => $settings['title_class']);
+ if (!empty($output)) {
+ if ($settings['title_link'] == 'content') {
+ $uri = entity_uri($entity_type, $entity);
+ $options = array('html' => TRUE);
+ if (!empty($uri['options'])) {
+ $options = array_merge($options, $uri['options']);
+ }
+ $output = l($output, $uri['path'], $options);
}
- $output = theme('html_tag', $element);
+ $wrap_tag = empty($settings['title_style']) ? '_none' : $settings['title_style'];
+
+ if ($wrap_tag != '_none') {
+ $variables = array(
+ 'element' => array(
+ '#tag' => $wrap_tag,
+ '#value' => $output,
+ ),
+ );
+
+ if (!empty($settings['title_class'])) {
+ $variables['element']['#attributes'] = array('class' => $settings['title_class']);
+ }
+
+ $output = theme('html_tag', $variables);
+ }
+
+ $element = array(
+ array(
+ '#markup' => $output,
+ ),
+ );
}
-
- $element = array(
- array(
- '#markup' => $output,
- ),
- );
-
return $element;
}
diff --git a/sites/all/modules/contrib/fields/title/title.info b/sites/all/modules/contrib/fields/title/title.info
index a331e8f..78153e3 100644
--- a/sites/all/modules/contrib/fields/title/title.info
+++ b/sites/all/modules/contrib/fields/title/title.info
@@ -9,9 +9,9 @@ files[] = title.module
files[] = views/views_handler_title_field.inc
files[] = tests/title.test
-; Information added by drupal.org packaging script on 2013-03-18
-version = "7.x-1.0-alpha7"
+; Information added by Drupal.org packaging script on 2017-01-13
+version = "7.x-1.0-alpha9"
core = "7.x"
project = "title"
-datestamp = "1363626024"
+datestamp = "1484302985"
diff --git a/sites/all/modules/contrib/fields/title/title.module b/sites/all/modules/contrib/fields/title/title.module
index 06b6b3a..2342f81 100644
--- a/sites/all/modules/contrib/fields/title/title.module
+++ b/sites/all/modules/contrib/fields/title/title.module
@@ -33,6 +33,7 @@ function title_module_implements_alter(&$implementations, $hook) {
// The following hook implementations should be executed as last ones.
case 'entity_info_alter':
case 'entity_presave':
+ case 'field_attach_presave':
$implementations['title'] = $group;
break;
@@ -104,17 +105,7 @@ function title_field_replacement_info($entity_type, $legacy_field = NULL) {
}
/**
- * Return an entity label value.
- *
- * @param $entity
- * The entity whose label has to be displayed.
- * @param $type
- * The name of the entity type.
- * @param $langcode
- * (Optional) The language the entity label has to be displayed in.
- *
- * @return
- * The entity label as a string value.
+ * Implements callback_entity_info_label().
*/
function title_entity_label($entity, $type, $langcode = NULL) {
$entity_info = entity_get_info($type);
@@ -125,7 +116,8 @@ function title_entity_label($entity, $type, $langcode = NULL) {
// If field replacement is enabled we use the replacing field value.
if (title_field_replacement_enabled($type, $bundle, $legacy_field)) {
$langcode = field_language($type, $entity, $info['field']['field_name'], $langcode);
- return $info['callbacks']['sync_get']($type, $entity, $legacy_field, $info, $langcode);
+ $values = $info['callbacks']['sync_get']($type, $entity, $legacy_field, $info, $langcode);
+ return $values[$legacy_field];
}
// Otherwise if we have a fallback defined we use the original label callback.
elseif (isset($entity_info['label fallback']['title']) && function_exists($entity_info['label fallback']['title'])) {
@@ -139,8 +131,57 @@ function title_entity_label($entity, $type, $langcode = NULL) {
/**
* Implements hook_entity_presave().
*/
-function title_entity_presave($entity, $type) {
- title_entity_sync($type, $entity, NULL, TRUE);
+function title_entity_presave($entity, $entity_type) {
+ $entity_langcode = title_entity_language($entity_type, $entity);
+ $langcode = $entity_langcode;
+
+ // If Entity Translation is enabled and the entity type is transltable,we need
+ // to check if we have a translation for the current active language. If so we
+ // need to synchronize the legacy field values into the replacing field
+ // translations in the active language.
+ if (module_invoke('entity_translation', 'enabled', $entity_type)) {
+ $langcode = title_active_language();
+ $translations = entity_translation_get_handler($entity_type, $entity)->getTranslations();
+ // If we are removing a translation for the active language we need to skip
+ // reverse synchronization, as we would store empty values in the original
+ // replacing fields immediately afterwards.
+ if (!isset($translations->data[$langcode])) {
+ $langcode = isset($translations->hook[$langcode]['hook']) && $translations->hook[$langcode]['hook'] == 'delete' ? FALSE : $entity_langcode;
+ }
+ }
+
+ // Perform reverse synchronization to retain any change in the legacy field
+ // values. We must avoid doing this twice as we might overwrite the already
+ // synchronized values, if we are updating an existing entity.
+ if ($langcode) {
+ title_entity_sync($entity_type, $entity, $langcode, TRUE);
+ }
+
+ // If we are not dealing with the entity language, we need to synchronize the
+ // original values into the legacy fields to ensure they are always stored in
+ // the entity table.
+ if ($entity_langcode != $langcode) {
+ list($id, , ) = entity_extract_ids($entity_type, $entity);
+ $sync = &drupal_static('title_entity_sync', array());
+ unset($sync[$entity_type][$id]);
+ title_entity_sync($entity_type, $entity, $entity_langcode);
+ }
+}
+
+/**
+ * Implements hook_field_attach_update().
+ */
+function title_field_attach_update($entity_type, $entity) {
+ // Reset the field_attach_presave static cache so that subsequent saves work
+ // correctly.
+ $sync = &drupal_static('title_field_attach_presave', array());
+ list($id, , ) = entity_extract_ids($entity_type, $entity);
+ unset($sync[$entity_type][$id]);
+
+ // Immediately after saving the entity we need to ensure that the legacy field
+ // holds a value corresponding to the current active language, as it were
+ // just loaded.
+ title_entity_sync($entity_type, $entity);
}
/**
@@ -152,7 +193,10 @@ function title_entity_presave($entity, $type) {
* @see title_entity_load()
*/
function title_field_attach_load($entity_type, $entities, $age, $options) {
- // @todo: Do we need to handle revisions here?
+ // Allow values to re-sync when field_attach_load_revision() is called.
+ if ($age == FIELD_LOAD_REVISION) {
+ title_entity_sync_static_reset($entity_type, array_keys($entities));
+ }
title_entity_load($entities, $entity_type);
}
@@ -164,6 +208,9 @@ function title_field_attach_load($entity_type, $entities, $age, $options) {
* replaced fields.
*/
function title_entity_load($entities, $type) {
+ // Load entity translations otherwise field language will not be computed
+ // correctly.
+ module_invoke('entity_translation', 'entity_load', $entities, $type);
foreach ($entities as &$entity) {
// Synchronize values from the regular field unless we are intializing it.
title_entity_sync($type, $entity, NULL, !empty($GLOBALS['title_field_replacement_init']));
@@ -183,20 +230,10 @@ function title_entitycache_load($entities, $type) {
/**
* Implements hook_entitycache_reset().
*
- * If the entity cache is reseted the field sync has to be done again.
+ * When the entity cache is reset the field sync has to be done again.
*/
function title_entitycache_reset($ids, $entity_type) {
- $sync = &drupal_static('title_entity_sync', array());
- if (!empty($ids)) {
- // Clear specific ids.
- foreach ($ids as $id) {
- unset($sync[$entity_type][$id]);
- }
- }
- elseif (!empty($sync[$entity_type])) {
- // Reset cache for an entity_type.
- $sync[$entity_type] = array();
- }
+ title_entity_sync_static_reset($entity_type, $ids);
}
/**
@@ -227,7 +264,9 @@ function title_entity_prepare_view($entities, $type, $langcode) {
*/
function title_field_replacement_enabled($entity_type, $bundle, $legacy_field) {
$info = title_field_replacement_info($entity_type, $legacy_field);
- $instance = field_info_instance($entity_type, $info['field']['field_name'], $bundle);
+ if (!empty($info['field']['field_name'])) {
+ $instance = field_info_instance($entity_type, $info['field']['field_name'], $bundle);
+ }
return !empty($instance);
}
@@ -374,10 +413,13 @@ function title_field_replacement_init($entity_type, $bundle, $legacy_field, $ids
function title_entity_sync($entity_type, &$entity, $langcode = NULL, $set = FALSE) {
$sync = &drupal_static(__FUNCTION__, array());
list($id, , $bundle) = entity_extract_ids($entity_type, $entity);
- $langcode = field_valid_language($langcode, FALSE);
- // We do not need to perform this more than once.
- if (!empty($id) && !empty($sync[$entity_type][$id][$langcode][$set])) {
+ if (!isset($langcode)) {
+ $langcode = $set ? title_entity_language($entity_type, $entity) : title_active_language();
+ }
+
+ // We do not need to perform synchronization more than once.
+ if (!$set && !empty($id) && !empty($sync[$entity_type][$id][$langcode][$set])) {
return;
}
@@ -394,6 +436,26 @@ function title_entity_sync($entity_type, &$entity, $langcode = NULL, $set = FALS
}
}
+/**
+ * Reset the list of entities whose fields have already been synchronized.
+ *
+ * @param $entity_type
+ * The name of the entity type.
+ * @param $entity_ids
+ * Either an array of entity IDs to reset or NULL to reset all.
+ */
+function title_entity_sync_static_reset($entity_type, $entity_ids = NULL) {
+ $sync = &drupal_static('title_entity_sync', array());
+ if (is_array($entity_ids)) {
+ foreach ($entity_ids as $id) {
+ unset($sync[$entity_type][$id]);
+ }
+ }
+ else {
+ unset($sync[$entity_type]);
+ }
+}
+
/**
* Synchronize a single legacy field with its regular field value.
*
@@ -405,8 +467,8 @@ function title_entity_sync($entity_type, &$entity, $langcode = NULL, $set = FALS
* The name of the legacy field to be replaced.
* @param $field_name
* The regular field to use as source value.
- * @param $display
- * Specifies if synchronization is being performed on display or on save.
+ * @param $info
+ * Field replacement information for the given entity.
* @param $langcode
* The field language to use for the source value.
*/
@@ -416,7 +478,16 @@ function title_field_sync_get($entity_type, $entity, $legacy_field, $info, $lang
$entity->{$legacy_field . '_original'} = $entity->{$legacy_field};
// Find out the actual language to use (field might be untranslatable).
$langcode = field_language($entity_type, $entity, $info['field']['field_name'], $langcode);
- $entity->{$legacy_field} = $info['callbacks']['sync_get']($entity_type, $entity, $legacy_field, $info, $langcode);
+ $values = $info['callbacks']['sync_get']($entity_type, $entity, $legacy_field, $info, $langcode);
+ foreach ($values as $name => $value) {
+ if ($value !== NULL) {
+ $entity->{$name} = $value;
+ }
+ }
+ // Ensure we do not pollute field language static cache.
+ $cache = &drupal_static('field_language');
+ list($id, ,) = entity_extract_ids($entity_type, $entity);
+ unset($cache[$entity_type][$id]);
}
}
@@ -431,18 +502,45 @@ function title_field_sync_get($entity_type, $entity, $legacy_field, $info, $lang
* The name of the legacy field to be replaced.
* @param $field_name
* The regular field to use as source value.
- * @param $display
- * Specifies if synchronization is being performed on display or on save.
+ * @param $info
+ * Field replacement information for the given entity.
* @param $langcode
- * The field language to use for the source value.
+ * The field language to use for the target value.
*/
-function title_field_sync_set($entity_type, $entity, $legacy_field, $info) {
+function title_field_sync_set($entity_type, $entity, $legacy_field, $info, $langcode) {
if (property_exists($entity, $legacy_field)) {
- $langcode = title_entity_language($entity_type, $entity);
+ // Find out the actual language to use (field might be untranslatable).
+ $field = field_info_field($info['field']['field_name']);
+ $langcode = field_is_translatable($entity_type, $field) ? $langcode : LANGUAGE_NONE;
$info['callbacks']['sync_set']($entity_type, $entity, $legacy_field, $info, $langcode);
}
}
+/**
+ * Returns and optionally stores the active language.
+ *
+ * @param string $langcode
+ * (optional) The active language to be set. If none is provided the active
+ * language is just returned.
+ *
+ * @return string
+ * The active language code. Defaults to the current content language.
+ */
+function title_active_language($langcode = NULL) {
+ static $drupal_static_fast;
+ if (!isset($drupal_static_fast)) {
+ $drupal_static_fast['active_language'] = &drupal_static(__FUNCTION__);
+ }
+ $active_langcode = &$drupal_static_fast['active_language'];
+ if (isset($langcode)) {
+ $active_langcode = $langcode;
+ }
+ if (empty($active_langcode)) {
+ $active_langcode = $GLOBALS['language_content']->language;
+ }
+ return $active_langcode;
+}
+
/**
* Provide the original entity language.
*
@@ -485,6 +583,11 @@ function title_field_attach_form($entity_type, $entity, &$form, &$form_state, $l
if (isset($form[$legacy_field]['#access'])) {
$form[$info['field']['field_name']]['#access'] = $form[$legacy_field]['#access'];
}
+
+ // Add class from legacy field so behaviors can still be applied on
+ // title widget.
+ $form[$info['field']['field_name']]['#attributes']['class'] = array('form-item-' . $legacy_field);
+
// Restrict access to the legacy field form element and mark it as
// replaced.
$form[$legacy_field]['#access'] = FALSE;
@@ -510,7 +613,7 @@ function title_field_attach_submit($entity_type, $entity, $form, &$form_state) {
// drupal_array_set_nested_value().
$values = $form_state['values'];
$values = drupal_array_get_nested_value($values, $form['#parents']);
- $langcode = title_entity_language($entity_type, $entity);
+ $langcode = entity_language($entity_type, $entity);
foreach ($fr_info as $legacy_field => $info) {
if (!empty($form[$legacy_field]['#field_replacement'])) {
@@ -641,23 +744,26 @@ function title_tokens_alter(array &$replacements, array $context) {
$entity = $context['data'][$context['type']];
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
$options = $context['options'];
+ $sanitize = !empty($options['sanitize']);
- $langcode = NULL;
- if (isset($options['language'])) {
- $langcode = $options['language']->language;
- }
+ // Since Title tokens are mostly used in storage contexts we default to
+ // the current working language, that is the entity language. Modules
+ // using Title tokens in display contexts need to specify the current
+ // display language.
+ $langcode = isset($options['language']) ? $options['language']->language : entity_language($entity_type, $entity);
if ($fr_info) {
foreach ($fr_info as $legacy_field => $info) {
if (title_field_replacement_enabled($entity_type, $bundle, $legacy_field)) {
if (isset($context['tokens'][$legacy_field])) {
- title_field_sync_get($entity_type, $entity, $legacy_field, $info, $langcode);
- $item = $entity->{$legacy_field};
+ $langcode = field_language($entity_type, $entity, $info['field']['field_name'], $langcode);
+ $values = $info['callbacks']['sync_get']($entity_type, $entity, $legacy_field, $info, $langcode);
+ $item = $values[$legacy_field];
if (!empty($item)) {
if (is_array($item)) {
$item = reset($item);
}
- $replacements[$context['tokens'][$legacy_field]] = $item;
+ $replacements[$context['tokens'][$legacy_field]] = $sanitize ? check_plain($item) : $item;
}
}
}
@@ -851,3 +957,38 @@ function title_field_attach_create_bundle($entity_type, $bundle) {
}
}
}
+
+/**
+ * Implements hook_field_info_alter().
+ */
+function title_field_info_alter(&$info) {
+ $supported_types = array('taxonomy_term_reference' => TRUE);
+ foreach ($info as $field_type => &$field_type_info) {
+ if (isset($supported_types[$field_type])) {
+ if (!isset($field_type_info['settings'])) {
+ $field_type_info['settings'] = array();
+ }
+ $field_type_info['settings'] += array('options_list_callback' => 'title_taxonomy_allowed_values');
+ }
+ }
+}
+
+/**
+ * Return taxonomy term values for taxonomy reference fields.
+ */
+function title_taxonomy_allowed_values($field) {
+ $bundle = !empty($field['settings']['allowed_values'][0]['vocabulary']) ? $field['settings']['allowed_values'][0]['vocabulary'] : NULL;
+ if ($bundle && ($label = title_field_replacement_get_label_field('taxonomy_term', $bundle))) {
+ $options = array();
+ foreach ($field['settings']['allowed_values'] as $tree) {
+ $vocabulary = taxonomy_vocabulary_machine_name_load($tree['vocabulary']);
+ if ($vocabulary && ($terms = taxonomy_get_tree($vocabulary->vid, $tree['parent'], NULL, TRUE))) {
+ foreach ($terms as $term) {
+ $options[$term->tid] = str_repeat('-', $term->depth) . entity_label('taxonomy_term', $term);
+ }
+ }
+ }
+ return $options;
+ }
+ return taxonomy_allowed_values($field);
+}
diff --git a/sites/all/modules/contrib/fields/title/views/title.views.inc b/sites/all/modules/contrib/fields/title/views/title.views.inc
index f973d9f..9ae50c8 100644
--- a/sites/all/modules/contrib/fields/title/views/title.views.inc
+++ b/sites/all/modules/contrib/fields/title/views/title.views.inc
@@ -6,13 +6,14 @@
*/
function title_field_views_data_alter(&$data) {
foreach (entity_get_info() as $entity_type => $entity_info) {
- $replacements = title_field_replacement_info($entity_type);
- if ($replacements) {
- foreach ($replacements as $replacement) {
- $field = field_info_field($replacement['field']['field_name']);
- $table = _field_sql_storage_tablename($field);
- if (isset($data[$table][$field['field_name']])) {
- $data[$table][$field['field_name']]['field']['handler'] = 'views_handler_title_field';
+ if (!empty($entity_info['field replacement'])) {
+ foreach ($entity_info['field replacement'] as $replacement) {
+ if (isset($replacement['field']['field_name'])) {
+ $field = field_info_field($replacement['field']['field_name']);
+ $table = _field_sql_storage_tablename($field);
+ if (isset($data[$table][$field['field_name']])) {
+ $data[$table][$field['field_name']]['field']['handler'] = 'views_handler_title_field';
+ }
}
}
}
diff --git a/sites/all/modules/contrib/fields/title/views/views_handler_title_field.inc b/sites/all/modules/contrib/fields/title/views/views_handler_title_field.inc
index 03516e9..3a11ad1 100644
--- a/sites/all/modules/contrib/fields/title/views/views_handler_title_field.inc
+++ b/sites/all/modules/contrib/fields/title/views/views_handler_title_field.inc
@@ -36,13 +36,13 @@ class views_handler_title_field extends views_handler_field_field {
if (!empty($this->options['link_to_entity'])) {
$values = $this->original_values;
$entity_type = $this->definition['entity_tables'][$this->base_table];
- $entity_info = entity_get_info($entity_type);
- $key = $entity_info['entity keys']['id'];
+ $key = $this->field_alias;
if (!empty($values->_field_data[$key]['entity'])) {
$entity = $values->_field_data[$key]['entity'];
$uri = entity_uri($entity_type, $entity);
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = $uri['path'];
+ $this->options['alter']['options'] = !empty($uri['options']) ? $uri['options'] : array();
}
}
return parent::render_item($count, $item);
diff --git a/sites/all/modules/contrib/fields/video_embed_field/img/vimeo.jpg b/sites/all/modules/contrib/fields/video_embed_field/img/vimeo.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..dd7056584b19eb7866eb63fa5b4c2880545d02b2
GIT binary patch
literal 14783
zcmeHtXIxX+)^{9x0YwEA1g;_?U3w=oDky!V_Y7T12)#obEGR8Q??kCmBY_ZFk^zJm
zLSP_5fB=yaS_m!lP~ObF&-2{(+k3yf-=39UPIk`T=j?UXS?j;|{;z#9dh!Es%|K6I
z4{+)y0Kkp&0i3J=c%Fv1`a}Ru0nPvb04>g`RRH%dZV(rDfZLy(GpA0dfH#11XU?2C
zd*TOVxFaYict_-a
z=<@DtCe(>$k6z5*~DwSW5Q
z^eK*>|1IavpE-N#^o5^JacWL;4*!<3=T4tF|I?{!oGVWKbo$KMi)YWAKYNi=|Mx$h
zvv;qblmF$#dFO!N@7+lKRIl*ZC9e3USs+rBw&
zled^JE)Ds_{Jzr3IN%CL^PhN5^8kQ=?dShi^nXkLYk~jR0(T7j-$Yc1-P%JJ>wNXz
zSLEp?Y;66{(
zoXrZBKy_sn%+bY}Ze>0^0#9GQ!Z5u?$Teso#o@N{uI!6sx0hbS(W=`%uK*__oDx`3WMxhb@mIe
zk*4uqj6Kx4m=JsaLXcfi5o{Nt-vTK0o7E%jT3;(!GJD1Voo_7ssyX#%k
z7rX5rd(AN|wrIdsxq)sD$rpbbDmg*!lQ;H?FQ*Z!v>mZ)cJ-tQ#fH_ed60)Lf;lEG
zzCx+LF}g95TITxPoaKqt-*ECEFM&0Js?jkp$rf^O%~#`S2Yo^-UHIt60ivVi+=8c3
zJy}S*mK3i@L^m3lpcn|V?T)?@Rqlemh#>RS3uE?cLxxT|X(egthW~`PJO2Z5w|Qdg
z88tF-XkC3bzaYELeM~5BCJkR`%&9nwSJxgfsFgd6%h#xb?^7ei#s^@Z-?8T*rc7j}+W6{i`5&`}291Y8Fw3Lw1Z|uYAvSm4mAw87
zM62WVl_gNoREjX|-RD?HevEE#UQbn$O_&$I+fkiq_GVh}++Imi-$%uW`~XO~l+y_S
zU;kD_v9;SYm)>a@-@1e_5&m59m3RV3>=>iTgtN}AfvU9sNZVS-zr>zS#*i;rj3*GQ
zEzi)H-RR=2iWMbQt&-=IJB&pmUoGNHqqWjgXt4j`h=x}wd00oHn9KJAfE;q(+Bg3u
zaMo{R2lY-Sb{jD^fl>HtoVv2b>o*^IhDxxyQsI0HkP|e
zSm`4qylr3K*P(fAJ`zwrs6ph$9FVxMI}1EaJ7DbGPAvP%n&Tq>g=G2-_gpEHYOlK1sINb
zG9b~I6F|t}oG>ffo}VP7yem_HC^8Syx%@0%Joo^6F+iXYaH^UXneQ>Ww3oa4x!=%k
z5r*+S0fYj__XGuFYB&2cVXqA%`W`W7?FZ--$%P0OBou4*j$-s^dBut(C9}P;%m0ng
zey1pPdmtey)0mQrq?X*|7yx+2RP}S%#Qc;~%uWS9bxaoIW=;p)6@!6O;KnZ3BG6;V
z80*Gka6oPqUBA16zr-;)G)@dNt}$B~+JbnUt6AmP=rsAor)z3fq;s$`-#JnI)=-Sl
zMHz(ZgmY1%5#DVJKl>e}VOSTs`Z2!4XN&sAs-Y*Hk}ErAwdaiy`iy|6@O6=UFgRXH
zR!~yZXYvwZY+c{@O!L1+jnnqH?Q@g$KZu<78Cq2Zaw5d`SsyhjGIw@}5H7p?$yIHP
zRv6qOq&IEZ@AE|1AtlzL#p_+Qh=ANgo!nBaG>RFD>T(o?IkeCo&8w?gZ`j9MgvM&x
z1-XAbHTfakPu5ah32Xndz_)hK;Hu@8FvOu#R;G3)MTrtI%R()
zr*7+eC+JpB=ceFo@Zl(zL5e`zRXK0NKH2gj7RDs6qVC*{kiXKWCB#ctcCZ7#_|T~!
z6wLOZc5kqs(|ci$*ZTvBL6Mqcja0K=t^iIq2(uqz+Zd6y7A0!H^ZZphcJ=b|+7OHO
zk-?X<7x4}eiQ3(!e&b@2>!8a>wVu$U;pwXt-=D6iLtfA0hQ~(hS+P;-P<&!>VGsp~
z#+()#{s`cQWU2N~{n3-ue0ZDcU_aYcNIcZF&a*aREe-y4h>2(#YTY)%NAcH19v2oV
z{z)wp413lY$V`^l#V*L5-8=~NRS%}`*KS3PM&LD)cz)o?=_i1S-9v+qtqeqKn4_wD
zld6<-`iNQj4AmDoQqNQB|La;rV_zRbfuVy1IAVA)v-nRNK|ytv!yhhMg43dJdZ#B@
z??za?HIIpdt{D5=fm%PMYqs|EqT82vlf^fuCyQ|mZrs4sN|B0GmdZ#`Lg`jvVowh)
zzG1}Jw4$Br(YptnAZ!2?uy75>S|E_a2|$E4QCZi@U=~tLtf;Q@h3S4~=`les|lF!`=qltV5z)3ug^9(0jPKJylfBIl8v>V=o=ZW
zIEZv*&D3AetvSsfII$kur>Uq2wwR?*#i!V5ji=LHk~|)0JP>}p#2oZ%dmudBVQ@gM
zm+e+wCCPowHJX@VM?Ao!E!zv>r@9>Ay_yGX>gm(q%M92f@3H+aDy#NkDwuujqY4l&
zjpH?Y*W0)q)nk2v&8HASv0=A>cvyva2sA`DJ3BKsRjZ)dJ!D7Q(`~92NifiLeV%+*
zmzXssqteLm3N9+*#5pGrvr|8$JDDh_R4=6!hCV|nMPTj?%4>1Rh^BR+h`w_~B248CtSElZhFm!?X1B|0ng%Q1NbYePjdmV1??~VTRZ}d3V_Bjl;
z$kx-FUKdYY=fiOeXBUHab;BBTs8=W3tsRxUA!v~6%{g*+@rS8h5v@~!9~YFigS9XF|4nB3b9aHdhy|ST80>ZjX3|<
zL+tjSsU1ZvJ~LHUBN_;3T-*kE&8Ls_8$c*?cFz7{e^rH=6$<$x(Oas=I8@}p;2rnn
z#>TIGdaW7*h<^a2rCJk#<*njA9bM&?bE~`tyLrbomg#{*BG6343ob`g(5j4&sjjCn
zP{`1Dmoo0VF_c<{5ZJ>64KI;LU#Wsen)Yj&2;Q{Y24)aCI9-TG_${cMOjX#=aKEia
zP`z$r)w18DXGQ!Y7O;{>6|i^am69!|3iN(pQK6y1(zkCaiG+Hva@bg|hBFVZrxiDF@P1)+c~G
z8uQ56H?w;>xp`GBDwMaSB};N+$$^}{pXSKiy)EyGV)7zxI}a4)RI0Ww*}TA54@XQs
zDck^$wA)c_MhWY28?g#8D@|aP%zuqVc!hcENs#SgjXw-;uLmx9r4l7#;>Vs`t;NQ>
z!1l93j;0CKmZuApHS9xlG>nUVz#1h^a}P7DUjZDaY=fYKqmhgX?TOaCXxmU;
z6R#71*0IyV)6EmW34j0^pvfX0X%KvKd~RIVUyYEDE<6ETx*D&!bxdGn`(l~xRtKV(
z*+LfRU~Ap{*f8uFq{GN0sDQ3c=neEU%P6Yl*mBJ4{op{kho^1ytDoG5itJYfyMOKL
z%kTUXE-;lxb=gP)xoqM7NSb76%)q%~eZs`|A$JKy_jciDHR&4o&90K=>a_3?kc`q^
zmc2_hV!|KR_tZXbA$PW74rxxLK2Ltopwj{;>w+ml(yh>tWQ$(&&Tp`<_>49ynEo%=
zU6GH4qkhNR%J3?+DlJ+zbeLEg!?y&BQ}Zi+C0_JmHLWBP2g$%?=9*`?9uL(?ZMN{-
zndNJqq4mTtaJtr8e4+Z@yV8Yo4BLS*d0L4+MGD&7S~RdP3Z@J6SO
z4BTRCM}^%;jrTT~E2sy@e5sec`kgKEkuvV*$u%?BRg3NmRi2p1GZn5}$vg|Tvh-a>
z%Bon4-|pV26fe>3dGJ6vULNJqAg|@T9uo~{ZZ9Y9O)6>#?$#s4Z(>(6Jg^Z84Wy-V
z$0+BR%@Gjal+Pg;c=LOL&CilFb#ZeN^&gFURc#K35e_9pR=JJ3wCTIayw2SDN|=x+
zLf`u7_~%pYi&Jp>RkoE-0Z~BGYOeQ=z?*1cSd+1+c~lEqZGI46Dcaiv+zHYZUz*h^
zqobKQg0c4l9({g$Yvb?0qt4K0Xo->$3gbH)b|Kl%y3pm4dlCYc3(V#A$lauajYgZl
zzBMV8jeRTs9_z9Y=iy~rr12!%k6}X$N04U)p|gPT3*V{`nDMPblG
z!|E{AGiiI{FWW85AmhXboxm=TS#tja@sM9}m7YO!yNjuH@idWC%2S4jxxz@tiyl1!f?#CF?omBXSL;c3m!C9`qjJc}@VqbRq
z$XfFX2^Rz_HMNgJ!fR(VqOMa<0J7G?5?DANN^q&D|Gv}tH7A7|Heq>te
z9_*LNeY)nbd;&0v99ff`T_Qj%qDH)aYL-CAA0X|U=GNsaINEllCk(D5hda%;Wxt&O
zN*e=771WA^*y^Z)697C&Vj#W4_5>iLxq$xhF74$tF1+E^ywwSywTl}bShhAdSzg6k
zM`6T#5TIiEoGTKb4|ZiosXhZzcF(xr>8Bdic!UeDD1xeE_$jr#i5A+
z;jOR@uEkE}c-<`ZvWZ?3OcwN`WEMt&xD)6yB5p-RE6^K1V!Bcw;WZ)cs|^%BDW?gk
zs~Y^C5`Yza@k%12IHzUOH$y6p8JIpOO0VTj_I#slmhPkLTJ9d>ioa2=VRvbv);>mH
zlrj$YA@9!bMfS#&QKekIws4S2q#FOG2BY#QFKR@}fJHJ0NDJ
z>GoZ%r3Wz^#e0(6S$_i@M^5SQXQQNrD_g(GNRpBQMcG3miid-cal3sdknk|YD9
zzfof_eSQ8o(#D$Z#WN4jCeO`#r#Q{V(e^Vt7v(1W6poc12USI*&~vDLdzCDVri=L4
zarIL~ouAml9$7OlT^al6>(6zJ7C%J}L?5HR-&XgJob5i8hV1(PfX_q{#~ng#bVeQ`
zK=!#T$AzP$o%R?l(P5EfJ4LTMrvf8Dd;I&gc-f_|T3O{nj;aH9A5|
zz7xC6CQ?OE@pwqp@hT$05W9NWZ>%8*H8@LF?{eB-T1EIaDuwPHM%=?7v!^`SHel%N
z4Yt-Q72LE9L1kM@`k$LES?7S)ceXp1HnrY*v7#xnJx9flPOKZK<|6$qCPA9xtvg
zf#}NL0a|M~x8v%l35Aeh$5dZRB?-mi2V~@gXeQj!5ig4+7O+;8ad0VgRvS45mMyFwBSR7-Km%m$8n)-9<${InyZjQ7X~R1?F3MS?
z@_P^5=Zm-IegnutB)>QT4fS>~D{VEX@J+k{WnBS5LWVbZjfu3L0O)->Tur!MGO%K?
zpK-Kf|I7rWQAW(c6uw4scdqnmQtra^!{9)VT
zhi5)ZpjqrbbYSJjuwz=Gc&Gin(7SHM*i+sSUW4X6zfSGm@`|3V<5h5QzAeYP-)^_E
z#e3|9-GHXFYaCy$_y=9ll;xHJUrHG;gsG|8TF1wuI+ix()>>jl{o}S(s5{)o@%F}S
z4H2!umZ8jUp%}$||HDXL=ikf$I@NWdCdwV^CSW~z$6D;gi-j5>pBsv$+ULpn%JwRx
zWHhB5^~~N4JDfJF9$h9ER1`RuZ&>LYTK}3W0BM2NeCIE~02dFg%5dZ?)KWe*sX%aDl!qPa-vZ%6jd9tp&I*-)a3h;AQ>5
zNJcB30n*hb{|gxa0I4-Km9-B|(|$ZoJKA-XxHj)$)n)&ELY;B8At}mrqB^4FTr(qm
zufK@4WhwU70Px2a-+a??RVNZ+P?ugjU|F3Roi>;k-Ng^%Dru+~&6sP0p;~GNE-vmI
zGe$pam|dQax2U;ub?H_EhXCz^vBsHiGq~V?Lk`<8e7WAc^>Eo_ikX>
z!-|2>z+&lyM`zMMMY`CpZrq~sA6x-T_htuyJaAu+!Nx+zj1_Xpa?wRUQx2)RLSH(N
zA_K3IB1+TrWv>57lQc=a_Ie-H5(}?b?o1qtXsUCcy@c7_Z_)QNO>{_y%nEM@^-*Em
z7b;jqi%YwUpD#1fWyLFRud{8=b7Igwh_K5j|l^Yfq1^_f1
zej2;!)jI`-VN?&IJ=n#Kq56?iiKE}RgW%=z_&RG5X|PhF2izjI`X8_DU(g;YW{K!~
z5*@{ZEw4ENc|Q|3m;E+ZVx@<-g4sL{YpT?78hMa;l<~qZ=r;f#JY!O$s;40u3+%($
z)hn;YMVf#T3{5>t5v-X0hFi1M2@CYvl+1#WS#93!kebIlKHeHQW#`}?dMZN7!h|RG
zdc%Ie;gCvb@P>O$q}?5|9F^)sqpmGR9JZ*x0$hFSs|Nfy=I_5XWbxvHam=bEX&)tF
zpH!rkh4yW&BVHZvG6=Qe#TTe=7A?GvgSY6)&SSTc^aCkzbro$1pV0oIZbQ;-6u}@=
z4@=v!{@Po2>dUD7-CQhqufeW!CE=6O3Ba8c6x}1#eW=FNPL(OldPvC2EV}V>7m++0
zJ02Phg*ChBW$xUis^czn2e?1sp4#^`=&8$Yoto(Y@#&Lkz_c>XH0DvzZojXQ#YQM8
zoPxl4!1t2FVuo2+#&Fp>xx7fo>h{A!av?2XlS44kbZ~L^o`0l;Sb|6Nsy?nD!Ftyc
z{EV?*({zl!>LJ;7q>ATDnI(h5_R_Z2Es$T$zS$WhiI*ga1lOzvt~-7`$Ijiu8bxcy
zUWPxM)47*E@xn4-TWR4~f!ym;E)?a#p_}@`C?WD=
zHZaQe6T;FQHau2pXme--=&b)+QJRK^ZnDvte(2YI>7jW*WM&|7BFgUuUmb!x{sBTyhd
z68pf?|6+EgjmdFk@fA>Hiw_a{Q^BQ7;)R#VC)23c8GYcU0(`GTa=?Q$lsdpe|cC
zk49#KoWQ{J^39{n(9z;ld|i|~N|{;(B^7qizFW?SuR4=&QfLh{Xm&3`@=2bh
z!^g=oDgJ=de-$b>)uMmv=p<)ZT8g~KjT=tE=Y7jokw<-5=(6uEv9y&RWtyTm1g7DU
zDlerVqK?B>T#uGP63cOuWw%ZM8@E*nUMxFWTIGB}t62s!7w&mbHS}jW!0k6@YJMRs
z-gLi(Pw#W&{MPr4v<(ANMP)j-1R=aMpmA|ak6Y-LjfL}HEnfIHK5<*RFU^on5U<9K
zY^$yW`5_4>-ejSLcTWXLq^=(;Y8;x