You are here

class PatternViewDisplay in Patterns 6.2

Hierarchy

Expanded class hierarchy of PatternViewDisplay

File

./pattern.class.php, line 118

View source
class PatternViewDisplay {
  private $name;
  private $display_id;
  private $sections = array();
  private $items = array();
  function __construct($name, $title, $display_id) {
    $this->name = $name;
    $this->display_title = $title;
    $this->display_id = $display_id;
    if ($title) {
      $this
        ->section('title', $title);
    }
  }
  public function section($name, $value, $data = array()) {
    $this->sections[] = array(
      'section' => $name,
      'value' => $value,
      // 'data' => $data,
      'override' => true,
    );
  }
  public function item($type, $name, $data) {
    $this->items[] = array(
      'type' => $type,
      'name' => $name,
      'data' => $data,
      'override' => true,
    );
  }
  public function filter($name, $operator, $value) {
    $this
      ->item('filter', $name, array(
      'operator' => $operator,
      'value' => $value,
    ));
  }
  public function sort($name, $order, $extra = array()) {
    $this
      ->item('sort', $name, array_merge(array(
      'order' => strtoupper($order),
    ), $extra));
  }
  public function export() {
    $array = array(
      'name' => $this->name,
      'display_title' => $this->display_title,
      'display_id' => $this->display_id,
      'section' => $this->sections,
    );

    // Avoiding an error from an empty item array
    if ($this->items) {
      $array = array_merge($array, array(
        'item' => $this->items,
      ));
    }
    return $array;
  }

}

Members