You are here

class ddblockConfigurationSettings in Dynamic display block 7

Hierarchy

Expanded class hierarchy of ddblockConfigurationSettings

File

./ddblock.class.php, line 2

View source
class ddblockConfigurationSettings {

  /**
   * @var array default configuration settings
   */
  protected $settings = array(
    'content_type' => array(
      'format' => '%s',
      'value' => 'none',
    ),
    'folder' => array(
      'format' => '%s',
      'value' => 'images/ddblock',
    ),
    'ignore_files' => array(
      'format' => '%s',
      'value' => '',
    ),
    'input_type' => array(
      'format' => '%s',
      'value' => 'images',
    ),
    'nodes' => array(
      'format' => '%s',
      'value' => '',
    ),
    'node_body_teaser' => array(
      'format' => '%s',
      'value' => 'body',
    ),
    'order' => array(
      'format' => '%s',
      'value' => 'asc',
    ),
    'output' => array(
      'format' => '%s',
      'value' => 'view_content',
    ),
    'widget' => array(
      'format' => '%s',
      'value' => 'cycle',
    ),
  );
  public function __construct(array $settings) {
    foreach ($settings as $key => $value) {
      $this
        ->__set($key, $value);
    }
  }

  /**
   * Use overload functions to get and set $settings
   *
   * Keys passed to the set function should be keys that already
   * exist in the settings array.
   */
  public function __set($key, $value) {
    if (!array_key_exists($key, $this->settings)) {
      return;
    }
    $this->settings[$key]['value'] = sprintf($this->settings[$key]['format'], $value);
  }

  /**
   * Use overload functions to get and set $settings
   */
  public function __get($key) {
    if (!array_key_exists($key, $this->settings)) {
      return null;
    }
    return $this->settings[$key]['value'];
  }

  /**
   * Alternate function to __get
   */
  public function get($key, $default) {
    return $this
      ->__get($key) !== NULL ? $this
      ->__get($key) : $default;
  }
  public function settings() {
    $settings = array();
    foreach ($this->settings as $key => $value) {
      $settings[$key] = $value['value'];
    }
    return $settings;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ddblockConfigurationSettings::$settings protected property
ddblockConfigurationSettings::get public function Alternate function to __get
ddblockConfigurationSettings::settings public function
ddblockConfigurationSettings::__construct public function
ddblockConfigurationSettings::__get public function Use overload functions to get and set $settings
ddblockConfigurationSettings::__set public function Use overload functions to get and set $settings