You are here

abstract class DevelImagesProviderBase in Devel images provider 8

Same name and namespace in other branches
  1. 7 plugins/devel_image_provider/provider/base.inc \DevelImagesProviderBase

An abstract implementation of DevelImagesProviderInterface.

Hierarchy

Expanded class hierarchy of DevelImagesProviderBase

File

plugins/devel_image_provider/provider/base.inc, line 41
Base devel image providers plugin class.

View source
abstract class DevelImagesProviderBase implements DevelImagesProviderInterface {

  /**
   * The provider url.
   *
   * @var string
   */
  protected $provider_base_url;

  /**
   * Defined settings for the method.
   *
   * @var string
   */
  protected $settings;
  public function __construct($plugin) {
    $this->plugin = $plugin;
    $this->settings = variable_get('devel_image_provider_settings_' . $this->plugin['name'], array());
  }
  public function availableMethods() {
    return drupal_map_assoc(array(
      'curl',
      'gd',
      'file_get_contents',
    ));
  }
  public function settingsForm() {
    $form['devel_image_provider_' . $this->plugin['name']] = array(
      '#type' => 'fieldset',
      '#title' => t('Provider settings'),
      '#states' => array(
        'visible' => array(
          ':input[name="available_providers[devel_image_provider_method_selected]"]' => array(
            'value' => $this->plugin['name'],
          ),
        ),
      ),
    );
    $methods = $this
      ->availableMethods();
    if (!empty($methods)) {
      $form['devel_image_provider_' . $this->plugin['name']]['devel_image_provider_get_method'] = array(
        '#type' => 'radios',
        '#title' => t('Method to get files'),
        '#default_value' => isset($this->settings['devel_image_provider_get_method']) ? $this->settings['devel_image_provider_get_method'] : 'file_get_contents',
        '#options' => $this
          ->availableMethods(),
      );
    }
    $form['devel_image_provider_' . $this->plugin['name']]['devel_image_provider_gray'] = array(
      '#type' => 'checkbox',
      '#title' => t('Gray version'),
      '#default_value' => isset($this->settings['devel_image_provider_gray']) ? $this->settings['devel_image_provider_gray'] : NULL,
    );
    return $form;
  }
  public function settingsFormValidate(&$form, &$form_state) {
  }
  public function settingsFormSubmit(&$form, &$form_state) {
    $values = $form_state['values']['config_providers']['devel_image_provider_' . $this->plugin['name']];
    variable_set('devel_image_provider_settings_' . $this->plugin['name'], $values);
  }
  public function generateImage($object, $field, $instance, $bundle) {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DevelImagesProviderBase::$provider_base_url protected property The provider url.
DevelImagesProviderBase::$settings protected property Defined settings for the method.
DevelImagesProviderBase::availableMethods public function Sets the available methods to get the images from this provider. Overrides DevelImagesProviderInterface::availableMethods 2
DevelImagesProviderBase::generateImage public function Image generation handler. Overrides DevelImagesProviderInterface::generateImage 8
DevelImagesProviderBase::settingsForm public function Generates a settings form for this handler. Overrides DevelImagesProviderInterface::settingsForm 6
DevelImagesProviderBase::settingsFormSubmit public function Generates a settings form submit function for this handler. Overrides DevelImagesProviderInterface::settingsFormSubmit
DevelImagesProviderBase::settingsFormValidate public function Generates a settings form validate function for this handler. Overrides DevelImagesProviderInterface::settingsFormValidate 1
DevelImagesProviderBase::__construct public function 7