You are here

class UltimateCronPluginMultiple in Ultimate Cron 7.2

Class for handling multiple plugins.

Hierarchy

Expanded class hierarchy of UltimateCronPluginMultiple

File

./ultimate_cron.plugin.inc, line 711
Plugin framework for Ultimate Cron.

View source
class UltimateCronPluginMultiple extends UltimateCronPlugin {
  public static $multiple = TRUE;

  /**
   * Default settings form.
   */
  public static function defaultSettingsForm(&$form, &$form_state, $plugin_info) {
    $plugin_type = $plugin_info['type'];
    foreach (_ultimate_cron_plugin_load_all($plugin_type) as $name => $plugin) {
      if ($plugin
        ->isValid()) {
        $plugins[] = l($plugin->title, "admin/config/system/cron/{$plugin_type}/{$name}");
      }
    }
    $form['available'] = array(
      '#markup' => theme('item_list', array(
        'title' => $plugin_info['defaults']['static']['title plural proper'] . ' available',
        'items' => $plugins,
      )),
    );
  }

  /**
   * Job settings form.
   */
  public static function jobSettingsForm(&$form, &$form_state, $plugin_type, $job) {

    // Check valid plugins.
    $plugins = _ultimate_cron_plugin_load_all($plugin_type);
    foreach ($plugins as $name => $plugin) {
      if (!$plugin
        ->isValid($job)) {
        unset($plugins[$name]);
      }
    }

    // No plugins = no settings = no vertical tabs for you mister!
    if (empty($plugins)) {
      return;
    }
    $weight = 10;
    $form_state['default_values']['settings'][$plugin_type] = array();
    $form['settings'][$plugin_type]['#tree'] = TRUE;
    foreach ($plugins as $name => $plugin) {
      $form_state['default_values']['settings'][$plugin_type][$name] = array();
      if (empty($form_state['values']['settings'][$plugin_type][$name])) {
        $form_state['values']['settings'][$plugin_type][$name] = array();
      }
      $form['settings'][$plugin_type][$name] = array(
        '#title' => $plugin->title,
        '#group' => 'settings_tabs',
        '#type' => 'fieldset',
        '#tree' => TRUE,
        '#visible' => TRUE,
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#weight' => $weight++,
      );
      $defaults = $plugin
        ->getDefaultSettings($job);
      $form_state['default_values']['settings'][$plugin_type][$name] += $defaults;
      $form_state['values']['settings'][$plugin_type][$name] += ultimate_cron_blank_values($defaults);
      $plugin
        ->settingsForm($form, $form_state, $job);
      if (empty($form['settings'][$plugin_type][$name]['no_settings'])) {
        $plugin
          ->fallbackalize($form['settings'][$plugin_type][$name], $form_state['values']['settings'][$plugin_type][$name], $form_state['default_values']['settings'][$plugin_type][$name], FALSE);
      }
      else {
        unset($form['settings'][$plugin_type][$name]);
      }
    }
  }

  /**
   * Job settings form validate handler.
   */
  public static function jobSettingsFormValidate($form, &$form_state, $plugin_type, $job = NULL) {
    $plugins = _ultimate_cron_plugin_load_all($plugin_type);
    foreach ($plugins as $plugin) {
      if ($plugin
        ->isValid($job)) {
        $plugin
          ->settingsFormValidate($form, $form_state, $job);
      }
    }
  }

  /**
   * Job settings form submit handler.
   */
  public static function jobSettingsFormSubmit($form, &$form_state, $plugin_type, $job = NULL) {
    $plugins = _ultimate_cron_plugin_load_all($plugin_type);
    foreach ($plugins as $name => $plugin) {
      if ($plugin
        ->isValid($job)) {
        $plugin
          ->settingsFormSubmit($form, $form_state, $job);

        // Weed out blank values that have fallbacks.
        $elements =& $form['settings'][$plugin_type][$name];
        $values =& $form_state['values']['settings'][$plugin_type][$name];
        $plugin
          ->cleanForm($elements, $values, array(
          'settings',
          $plugin_type,
          $name,
        ));
      }
      else {
        unset($form_state['values']['settings'][$plugin_type][$name]);
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
UltimateCronPlugin::$description public property
UltimateCronPlugin::$globalOptions public static property
UltimateCronPlugin::$instances public static property
UltimateCronPlugin::$name public property
UltimateCronPlugin::$plugin public property
UltimateCronPlugin::$settings public property
UltimateCronPlugin::$title public property
UltimateCronPlugin::$weight public property 1
UltimateCronPlugin::build_operations_alter public function Allow plugins to alter the allowed operations for a job. 2
UltimateCronPlugin::cleanForm public function Clean form of empty fallback values.
UltimateCronPlugin::cronapi public function A hook_cronapi() for plugins. 1
UltimateCronPlugin::cron_alter public function A hook_cron_alter() for plugins. 3
UltimateCronPlugin::cron_post_invoke public function A hook_cron_post_invoke() for plugins.
UltimateCronPlugin::cron_post_launch public function A hook_cron_post_launch() for plugins.
UltimateCronPlugin::cron_post_run public function A hook_cron_post_run() for plugins.
UltimateCronPlugin::cron_post_schedule public function A hook_cron_post_schedule() for plugins. 1
UltimateCronPlugin::cron_pre_invoke public function A hook_cron_pre_invoke() for plugins.
UltimateCronPlugin::cron_pre_launch public function A hook_cron_pre_launch() for plugins.
UltimateCronPlugin::cron_pre_run public function A hook_cron_pre_run() for plugins.
UltimateCronPlugin::cron_pre_schedule public function A hook_cron_pre_schedule() for plugins. 2
UltimateCronPlugin::defaultSettings public function Default settings. 7
UltimateCronPlugin::drupal_array_remove_nested_value public function Modified version drupal_array_get_nested_value().
UltimateCronPlugin::factory public static function Singleton factoryLogEntry.
UltimateCronPlugin::fallbackalize public function Process fallback form parameters.
UltimateCronPlugin::formatLabel public function Format label for the plugin. 1
UltimateCronPlugin::formatLabelVerbose public function Format verbose label for the plugin. 1
UltimateCronPlugin::getDefaultSettings public function Get default settings. 1
UltimateCronPlugin::getGlobalOption public static function Get global plugin option.
UltimateCronPlugin::getGlobalOptions public static function Get all global plugin options.
UltimateCronPlugin::hook_cron_alter final public static function Invoke hook_cron_alter() on plugins.
UltimateCronPlugin::hook_cron_post_invoke final public static function Invoke hook_cron_post_invoke() on plugins.
UltimateCronPlugin::hook_cron_post_launch final public static function Invoke hook_cron_post_launch() on plugins.
UltimateCronPlugin::hook_cron_post_run final public static function Invoke hook_cron_post_run() on plugins.
UltimateCronPlugin::hook_cron_post_schedule final public static function Invoke hook_cron_post_schedule() on plugins.
UltimateCronPlugin::hook_cron_pre_invoke final public static function Invoke hook_cron_pre_invoke() on plugins.
UltimateCronPlugin::hook_cron_pre_launch final public static function Invoke hook_cron_pre_launch() on plugins.
UltimateCronPlugin::hook_cron_pre_run final public static function Invoke hook_cron_pre_run() on plugins.
UltimateCronPlugin::hook_cron_pre_schedule final public static function Invoke hook_cron_pre_schedule() on plugins.
UltimateCronPlugin::isValid public function Default plugin valid for all jobs. 2
UltimateCronPlugin::setGlobalOption public static function Set global plugin option.
UltimateCronPlugin::setSettings public function Save settings to db.
UltimateCronPlugin::settingsForm public function Settings form. 8
UltimateCronPlugin::settingsFormSubmit public function Settings form submit handler. 3
UltimateCronPlugin::settingsFormValidate public function Settings form validate handler. 1
UltimateCronPlugin::settingsLabel public function Get label for a specific setting. 3
UltimateCronPlugin::signal public function Signal page for plugins. 2
UltimateCronPlugin::unsetGlobalOption public static function Remove a global plugin option.
UltimateCronPlugin::unsetGlobalOptions public static function Remove all global plugin options.
UltimateCronPlugin::__construct public function Constructor. 1
UltimateCronPluginMultiple::$multiple public static property Overrides UltimateCronPlugin::$multiple
UltimateCronPluginMultiple::defaultSettingsForm public static function Default settings form. Overrides UltimateCronPlugin::defaultSettingsForm
UltimateCronPluginMultiple::jobSettingsForm public static function Job settings form. Overrides UltimateCronPlugin::jobSettingsForm
UltimateCronPluginMultiple::jobSettingsFormSubmit public static function Job settings form submit handler. Overrides UltimateCronPlugin::jobSettingsFormSubmit
UltimateCronPluginMultiple::jobSettingsFormValidate public static function Job settings form validate handler. Overrides UltimateCronPlugin::jobSettingsFormValidate