Beispiel #1
0
 public function __construct($default = NULL, $validators = [], $filters = [], $context = NULL, Loops $loops = NULL)
 {
     parent::__construct($context, $loops);
     $this->default = $default;
     $this->setValue($default);
     $this->messages = new MessageList(Message::ERROR);
     foreach ($validators as $validator) {
         $this->addValidator($validator);
     }
     foreach ($filters as $filter) {
         $this->addFilter($filter);
     }
 }
Beispiel #2
0
 public function __construct(ElementInterface $context, $page_parameter = NULL, Loops $loops = NULL)
 {
     parent::__construct($context, $loops);
     $loops = $this->getLoops();
     $annotations = $loops->getService("annotations");
     if ($page_parameter === NULL) {
         $page_parameter = $loops->getService("web_core")->page_parameter;
     }
     $reflection = new ReflectionClass(get_class($context));
     $entries = [];
     do {
         $classname = $reflection->getName();
         $annotation_set = $annotations->getStrict($classname);
         $annotation = $annotation_set->findFirst("Navigation\\PageEntry");
         $breadcrumb_annotation = $annotation_set->findFirst("Navigation\\Breadcrumb");
         $annotation_title = $annotation_set->findFirst("Navigation\\Title");
         if ($breadcrumb_annotation && $breadcrumb_annotation->ignore) {
             continue;
         }
         if ($breadcrumb_annotation && $breadcrumb_annotation->title) {
             $title = $breadcrumb_annotation->title;
         } elseif ($annotation && $annotation->title) {
             $title = $annotation->title;
         } elseif ($annotation_title && $annotation_title->title) {
             $title = $annotation_title->title;
         } else {
             continue;
         }
         $entry = new PageEntry(substr($classname, 6), $page_parameter, $title, $loops);
         if ($annotation && $annotation->link) {
             $entry->link = WebCore::getPagePathFromClassname("Pages\\" . $annotation->link, $page_parameter);
         }
         $entries[] = $entry;
     } while ($reflection = $reflection->getParentClass());
     foreach (array_reverse($entries) as $key => $entry) {
         $this->addChild($key, $entry);
     }
 }
Beispiel #3
0
 public function __construct($entity, $limit = 10, $alias = NULL, $order = [], $context = NULL, Loops $loops = NULL)
 {
     //set alias automatically based on classname
     if (!$alias) {
         $alias = strtolower(substr($entity, 0, 1));
     }
     $this->alias = $alias;
     $this->entity = is_object($entity) ? get_class($entity) : $entity;
     $this->limit = $limit;
     parent::__construct($context, $loops);
     $loops = $this->getLoops();
     $doctrine = $loops->getService("doctrine");
     $this->builder = new QueryBuilder($doctrine->entity_manager);
     $this->builder->select($alias);
     $this->builder->from(is_object($entity) ? get_class($entity) : $entity, $alias);
     foreach ($order as $key => $value) {
         if (is_array($value) && is_numeric($key)) {
             $this->builder->addOrderBy($this->alias . "." . $value[0], $value[1]);
         } else {
             $this->builder->addOrderBy($this->alias . "." . $key, $value);
         }
     }
 }
Beispiel #4
0
 public function action($parameter)
 {
     $result = parent::action($parameter);
     if ($this->mode == "edit" && $this->edit->delegateRender() === $result) {
         return $this;
     }
     if ($this->mode == "add" && $this->persist === $result) {
         return $this;
     }
     if ($this->mode == "list" && $this->list === $result) {
         return $this;
     }
     return $result;
 }
Beispiel #5
0
 public function getCacheId()
 {
     return parent::getCacheId() . get_class($this->getLoops()->getService("core")->page);
 }
Beispiel #6
0
 public function offsetGet($offset)
 {
     if (parent::offsetExists($offset)) {
         return parent::offsetGet($offset);
     }
     if ($this->wrapped_object instanceof ArrayAccess) {
         return $this->wrapped_object->offsetGet($offset);
     }
 }
 public function testIsNotPage()
 {
     $this->assertFalse(Element::isPage());
 }
Beispiel #8
0
 /**
  * The Page constructor
  *
  * In most cases, the page is instantiated by the WebCore service.
  * If the Page class has underscore namespaces in its name or is called underscore, then for each found
  * underscore a parameter will be extracted from the accessed url. (see WebCore for details)
  * These parameters are passed to the constructor.
  *
  * @param array $parameter Page parameter for this page, these are typically extracted from the accessed url.
  * @param Loops The Loops context
  */
 public function __construct($parameter = [], Loops $loops = NULL)
 {
     parent::__construct(NULL, $loops);
     $this->parameter = $parameter;
 }
 public function offsetGet($offset)
 {
     if ($this->missing) {
         $intermediate_helper = new UpdateEntityAdminHelper($this->context, array_merge($this->parameter, [$offset]));
         return $this->initChild($offset, $intermediate_helper);
     }
     if ($this->offsetExists($offset) && array_key_exists($offset, $this->elements)) {
         return $this->initChild($offset, $this->elements[$offset]);
     }
     return parent::offsetGet($offset);
 }
Beispiel #10
0
 /**
  * Construct a form object
  *
  * Form elements will be added to the form based on annotations.
  * Loops will look for annotations of the type 'Loops\Annotations\Form\Element',
  * 'Loops\Annotations\Form\Validator' and 'Loops\Annotations\Form\Filter' on properties.
  *
  * Annotations are collected from two places.
  *
  * 1. The passed entity
  *     If the passed default value (entity) is an object, the properties of its class definition will be inspected for annotations.
  *     For every annotation found, a form element is added.
  *     If the object (entity) has listeners to form events, they will also be fired on the object in case an event is fired for this form.
  * 2. The form itself
  *     Properties of the class instances defining class will also be inspected for annotations.
  *     This is particulary useful when extending from this class.
  *     Otherwise no annotations will be found since this class itself does not define any.
  *
  * Annotations from all parent classes will be collected.
  * For further information, see the documentation of method addFromAnnotations.
  *
  * @param ArrayAccess $value The default value/entity. If set to NULL, an empty Loops\ArrayObject will be created.
  * @param array|string Only use annotations marked with the specified filter(s) to generate form elements.
  * @param Loops The loops context to which this object belongs to.
  */
 public function __construct(ArrayAccess $value = NULL, $filter = "", $context = NULL, Loops $loops = NULL)
 {
     parent::__construct($context, $loops);
     $this->messages = new MessageList(Message::ERROR);
     $this->value = $value ?: new ArrayObject();
     if ($value) {
         $this->addFromAnnotations($value, $filter);
     }
     $this->addFromAnnotations($this, $filter);
 }
Beispiel #11
0
 /**
  * @param string $link The link for this entry
  * @param string $title A displayable title for this entry
  * @param string|Loops\Page $highlightgroup If the current page inherits the page given in this parameter, $highlight will be set to TRUE
  */
 public function __construct($link, $title, $context = NULL, Loops $loops = NULL)
 {
     parent::__construct($context, $loops);
     $this->link = $link;
     $this->title = $title;
 }