Example #1
0
 public function view(SymphonyDOMElement $wrapper, MessageStack $errors)
 {
     $page = Administration::instance()->Page;
     $layout = new Layout();
     $left = $layout->createColumn(Layout::SMALL);
     $right = $layout->createColumn(Layout::LARGE);
     //	Essentials --------------------------------------------------------
     $fieldset = Widget::Fieldset(__('Essentials'));
     // Name:
     $label = Widget::Label(__('Name'));
     $input = Widget::Input('fields[about][name]', General::sanitize($this->about()->name));
     $label->appendChild($input);
     if (isset($errors->{'about::name'})) {
         $label = Widget::wrapFormElementWithError($label, $errors->{'about::name'});
     }
     $fieldset->appendChild($label);
     $left->appendChild($fieldset);
     //	Filtering ---------------------------------------------------------
     $p = $page->createElement('p');
     $p->setAttribute('class', 'help');
     $p->appendChild($page->createElement('code', '{$param}'));
     $p->setValue(' or ');
     $p->appendChild($page->createElement('code', 'Value'));
     $fieldset = Widget::Fieldset(__('Filtering'), $p);
     // Parent View:
     $label = Widget::Label(__('Parent View'));
     $input = Widget::Input('fields[parent]', General::sanitize($this->parameters()->parent));
     $label->appendChild($input);
     if (isset($errors->{'parent'})) {
         $label = Widget::wrapFormElementWithError($label, $errors->{'parent'});
     }
     $fieldset->appendChild($label);
     $ul = $page->createElement('ul');
     $ul->setAttribute('class', 'tags');
     foreach (new ViewIterator() as $view) {
         $ul->appendChild($page->createElement('li', $view->path));
     }
     $fieldset->appendChild($ul);
     // View Type:
     $label = Widget::Label(__('View Type'));
     $input = Widget::Input('fields[type]', General::sanitize($this->parameters()->type));
     $label->appendChild($input);
     if (isset($errors->{'type'})) {
         $label = Widget::wrapFormElementWithError($label, $errors->{'type'});
     }
     $fieldset->appendChild($label);
     $ul = $page->createElement('ul');
     $ul->setAttribute('class', 'tags');
     foreach (View::fetchUsedTypes() as $type) {
         $ul->appendChild($page->createElement('li', $type));
     }
     $fieldset->appendChild($ul);
     /*
     			if (isset($this->parameters()->parent) && !is_null($this->parameters()->parent)){
     				$li = new XMLElement('li');
     				$li->setAttribute('class', 'unique');
     				$li->appendChild(new XMLElement('h4', __('Parent View')));
     				$label = Widget::Label(__('Value'));
     				$label->appendChild(Widget::Input(
     					'fields[parent]', General::sanitize($this->parameters()->parent)
     				));
     				$li->appendChild($label);
     				$li->appendChild($ul);
     				$ol->appendChild($li);
     			}
     
     			$li = new XMLElement('li');
     			$li->setAttribute('class', 'unique template');
     			$li->appendChild(new XMLElement('h4', __('Parent View')));
     			$label = Widget::Label(__('Value'));
     			$label->appendChild(Widget::Input('fields[parent]'));
     			$li->appendChild($label);
     			$li->appendChild($ul);
     			$ol->appendChild($li);
     
     			$ul = new XMLElement('ul');
     			$ul->setAttribute('class', 'tags');
     			foreach(View::fetchUsedTypes() as $type) $ul->appendChild(new XMLElement('li', $type));
     
     			if (isset($this->parameters()->type) && !is_null($this->parameters()->type)){
     				$li = new XMLElement('li');
     				$li->setAttribute('class', 'unique');
     				$li->appendChild(new XMLElement('h4', __('View Type')));
     				$label = Widget::Label(__('Value'));
     				$label->appendChild(Widget::Input(
     					'fields[type]',
     					General::sanitize($this->parameters()->type)
     				));
     				$li->appendChild($label);
     				$li->appendChild($ul);
     				$ol->appendChild($li);
     			}
     
     			$li = new XMLElement('li');
     			$li->setAttribute('class', 'unique template');
     			$li->appendChild(new XMLElement('h4', __('View Type')));
     			$label = Widget::Label(__('Value'));
     			$label->appendChild(Widget::Input('fields[type]'));
     			$li->appendChild($label);
     			$li->appendChild($ul);
     			$ol->appendChild($li);
     */
     $right->appendChild($fieldset);
     $layout->appendTo($wrapper);
 }
 private static function __fetchAvailableViewTypes()
 {
     // TODO: Delegate here so extensions can add custom view types?
     $types = array('index', 'XML', 'admin', '404', '403');
     foreach (View::fetchUsedTypes() as $t) {
         $types[] = $t;
     }
     return General::array_remove_duplicates($types);
 }