Example #1
0
 /**
  * Class constructor. Accepts id value and array of parameters:
  * <ul>
  * <li>pos_x: X position of the object in the view. Unit depends on view type</li>
  * <li>pos_y: Y position of the object in the view. Unit depends on view type</li></ul>
  * 
  * @param string $id
  * @param array $params
  */
 public function __construct($id = null, array $params = null)
 {
     $this->_setParameterObjects(array('pos_x' => new Parameter(Parameter::INTEGER), 'pos_y' => new Parameter(Parameter::INTEGER)));
     parent::__construct($id, $params);
 }
Example #2
0
 /**
  * Parse given object properties to return a string version
  * @param ObjectModelAbstract $object
  * @param string $display
  * @return mixed|string
  */
 public static function parseDisplayProperty(ObjectModelAbstract $object, $display = null)
 {
     if (is_null($display) && $object instanceof BaseObject) {
         return $object->__toString();
     }
     if (substr($display, 0, 1) == '[') {
         // mask
         Tag\ObjectTag::$object = $object;
         return Tag::parse(substr($display, 1, strlen($display) - 2));
     } else {
         $displayProps = explode(',', $display);
         if (count($displayProps) == 1 && $displayProps[0] == '') {
             return $object instanceof BaseObject ? $object->__toString() : null;
             //self::UNDEFINED_LABEL;
         } else {
             $displayValue = array();
             foreach ($displayProps as $disProp) {
                 // display the identifier part of an uri
                 if ($disProp == ObjectUri::IDENTIFIER) {
                     $displayValue[] = $object->getUri() ? $object->getUri()->getIdentifier() : '';
                 } else {
                     // display property value, if property exists!
                     if (($prop = $object->getProperty($disProp)) !== false) {
                         $displayValue[] = $prop->getDisplayValue();
                     }
                 }
             }
             return implode(' ', $displayValue);
         }
     }
 }
Example #3
0
 /**
  * (non-PHPdoc)
  * @see t41\ObjectModel.ObjectModelAbstract::reduce()
  */
 public function reduce(array $params = array(), $cache = true)
 {
     $class = get_class($this);
     $type = str_replace('Property', '', substr($class, strrpos($class, '\\') + 1));
     return array_merge(parent::reduce($params, $cache), array('value' => $this->getValue(), 'type' => $type, 'label' => $this->getLabel()));
 }
Example #4
0
 public function __construct($id, array $params = array())
 {
     parent::__construct($id, $params);
     $this->setPrivileges(Acl::getGrantedResources($this->getId()));
 }
Example #5
0
 /**
  * (non-PHPdoc)
  * @see t41\ObjectModel.ObjectModelAbstract::reduce()
  */
 public function reduce(array $params = array(), $cache = true)
 {
     $data = array();
     // populate only collections if params is set
     if (isset($params['collections']) && $params['collections'] > 0) {
         $params['collections']--;
         foreach ($this->getMembers() as $member) {
             // but prevent too-costly any deeper recursion
             $data[] = $member->reduce($params, $cache);
         }
     }
     return array_merge(parent::reduce($params), array('collection' => $data));
 }
Example #6
0
 /**
  * (non-PHPdoc)
  * @see t41\ObjectModel.ObjectModelAbstract::reduce()
  */
 public function reduce(array $params = array(), $cache = true)
 {
     //$uuid = ($this->_uri instanceof ObjectUri) ? $this->_uri->reduce($params) : null;
     $uuid = $cache ? Registry::set($this) : null;
     $props = array();
     foreach ($this->_data as $key => $property) {
         if (isset($params['props']) && !in_array($key, $params['props'])) {
             continue;
         }
         $constraints = $property->getParameter('constraints');
         // ignore stricly server-side properties
         if (isset($constraints['serverside'])) {
             continue;
         }
         $props[$key] = $property->reduce($params, $cache);
     }
     return array_merge(parent::reduce($params), array('uuid' => $uuid, 'props' => $props));
 }