Example #1
0
 /**
  * @return LParameter
  */
 public function getParameter($name)
 {
     if (!$this->hasParameter($name)) {
         throw new \Psc\Exception(sprintf("LParameters beeinhaltet keinen Parameter mit dem Namen '%s'. Es sind vorhanden: %s", $name, \Psc\FE\Helper::listObjects($this->parameters->toArray(), ',', 'name')));
     }
     return $this->parameters->get($name);
 }
Example #2
0
 /**
  * @param mixed $value
  */
 public function toString($value, Type $type = NULL)
 {
     if (isset($type)) {
         // wenn wir den typ checken statt der value geht auch (int) $timestamp, new DateTimeType()
         // das ist cooler
         if ($type instanceof Types\DateTimeType) {
             if ($value) {
                 return $value->i18n_format($this->dateTimeFormat);
             }
         }
         if ($type instanceof Types\DateType) {
             if ($value) {
                 return $value->i18n_format($this->dateFormat);
             }
         }
         if ($type instanceof Types\EntityType && $value != NULL) {
             return $value->getContextLabel();
         }
         $that = $this;
         if ($type instanceof Types\CollectionType) {
             return \Psc\FE\Helper::listObjects($value, ', ', function ($innerValue) use($that, $type) {
                 // ersetzt den getter
                 try {
                     return $that->toString($innerValue, $type->getType());
                 } catch (NotTypedException $e) {
                     // was tun wenn wir den inner type nicht kennen?
                     return $that->toString($innerValue);
                 }
             });
         }
         if ($type instanceof Types\I18nType) {
             return \Psc\FE\Helper::listObjects($value, "<br />", function ($innerValue, $key) use($that, $type) {
                 // ersetzt den getter
                 try {
                     return '[' . $key . '] ' . $that->toString($innerValue, $type->getType());
                 } catch (NotTypedException $e) {
                     // was tun wenn wir den inner type nicht kennen?
                     return $that->toString($innerValue);
                 }
             });
         }
         if ($type instanceof Types\BooleanType) {
             if ($value == TRUE) {
                 return '<span class="ui-icon ui-icon-check"></span>';
             } else {
                 return '';
             }
         }
         if ($type instanceof Types\MarkupTextType) {
             return TPL::MiniMarkup($value);
         }
     }
     return (string) $value;
 }
Example #3
0
 public function __construct(EntityMeta $entityMeta, $maxResults = 15)
 {
     $acRequest = $entityMeta->getAutoCompleteRequestMeta(array('term' => NULL));
     $item = new stdClass();
     $item->genitiv = $entityMeta->getGenitiv();
     $item->fields = \Psc\FE\Helper::listStrings($entityMeta->getAutoCompleteFields(), ', ', ' oder ');
     $item->type = $entityMeta->getEntityName();
     $item->url = $acRequest->getUrl();
     $item->label = $entityMeta->getLabel(EntityMeta::CONTEXT_AUTOCOMPLETE);
     $item->data = array();
     parent::__construct($item);
     $this->maxResults = $maxResults;
     // copy from meta
     // (hier die setter nehmen falls wir mal den search panel schön bauen sollten ;))
     $this->setLabel($entityMeta->getAutoCompleteHeadline());
     $this->setAutoCompleteDelay($entityMeta->getAutoCompleteDelay());
     $this->setAutoCompleteBody($acRequest->getBody());
     $this->setAutoCompleteMinLength($entityMeta->getAutoCompleteMinLength());
 }
Example #4
0
 /**
  * Gibt das HTML für die AssociationList zurück
  *
  * ist $assoc->limit angegeben und ist die anzahl der entities größer als diess wird $assoc->limitMessage zurückgegeben
  * sind keine Entities zu finden, wird $assoc->emptyText zurückgegeben
  * ansonsten wird für jedes Entities $assoc.withLabel oder ein button erzeugt (withButton(TRUE))
  */
 public function getHTMLForList(AssociationList $assoc)
 {
     if (!isset($this->entity)) {
         throw new \RuntimeException('Entity muss gesetzt sein, wenn html() oder init() aufgerufen wird');
     }
     $entities = $this->getAssocEntities($assoc);
     // die collection, ist klar
     if (($sorter = $assoc->getSortBy()) != NULL) {
         $entities = $sorter($entities);
     }
     $cnt = count($entities);
     if ($cnt > 0) {
         if ($assoc->hasLimit() && $cnt > $assoc->getLimit()) {
             return sprintf($assoc->getLimitMessage(), $cnt);
         } else {
             $html = h::listObjects($entities, $assoc->getJoinedWith(), $assoc->getWithButton() ? $this->getHTMLButtonClosure() : $assoc->getWithLabel(), $assoc->getAndJoiner());
         }
         return \Psc\TPL\TPL::miniTemplate($assoc->getFormat(), array('list' => $html));
     } else {
         return $assoc->getEmptyText();
     }
 }
Example #5
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function testListObjects_InvalidGetterParam()
 {
     \Psc\FE\Helper::listObjects(new \Psc\Data\ArrayCollection(array(new TestCollectionObject(2, 'test'))), ', ', array('label'));
 }