/**
  * Short description of method toTree
  *
  * @access public
  * @author Jerome Bogaerts, <*****@*****.**>
  * @param  Class clazz
  * @param  array options
  * @return array
  */
 public function toTree(core_kernel_classes_Class $clazz, $options)
 {
     $returnValue = array();
     $users = $this->getAllUsers(array('order' => PROPERTY_USER_LOGIN));
     foreach ($users as $user) {
         $login = (string) $user->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_USER_LOGIN));
         $returnValue[] = array('data' => tao_helpers_Display::textCutter($login, 16), 'attributes' => array('id' => tao_helpers_Uri::encode($user->getUri()), 'class' => 'node-instance'));
     }
     return (array) $returnValue;
 }
Esempio n. 2
0
 /**
  * Get property values for a sub set of filtered instances
  * @param {RequestParameter|string} propertyUri Uri of the target property
  * @param {RequestParameter|string} classUri Uri of the target class
  * @param {RequestParameter|array} filter Array of propertyUri/propertyValue used to filter instances of the target class
  * @param {RequestParameter|array} filterNodesOptions Array of options used by other filter nodes
  * @return {array} formated for tree
  */
 public function getFilteredInstancesPropertiesValues()
 {
     $data = array();
     // The filter nodes options
     $filterNodesOptions = array();
     // The filter
     $filter = array();
     // Filter itself ?
     $filterItself = $this->hasRequestParameter('filterItself') ? $this->getRequestParameter('filterItself') == 'false' ? false : true : false;
     if (!tao_helpers_Request::isAjax()) {
         throw new Exception("wrong request mode");
     }
     // Get the target property
     if ($this->hasRequestParameter('propertyUri')) {
         $propertyUri = $this->getRequestParameter('propertyUri');
     } else {
         $propertyUri = RDFS_LABEL;
     }
     $property = new core_kernel_classes_Property($propertyUri);
     // Get the class paramater
     if ($this->hasRequestParameter('classUri')) {
         $clazz = $this->getCurrentClass();
     } else {
         $clazz = $this->getRootClass();
     }
     // Get filter nodes parameters
     if ($this->hasRequestParameter('filterNodesOptions')) {
         $filterNodesOptions = $this->getRequestParameter('filterNodesOptions');
     }
     // Get filter parameter
     if ($this->hasRequestParameter('filter')) {
         $filter = $this->getFilterState('filter');
     }
     // Get used property values for a class functions of the given filter
     $propertyValues = $clazz->getInstancesPropertyValues($property, $filter, array("distinct" => true, "recursive" => true));
     $propertyValuesFormated = array();
     foreach ($propertyValues as $propertyValue) {
         $value = "";
         $id = "";
         if ($propertyValue instanceof core_kernel_classes_Resource) {
             $value = $propertyValue->getLabel();
             $id = tao_helpers_Uri::encode($propertyValue->getUri());
         } else {
             $value = (string) $propertyValue;
             $id = $value;
         }
         $propertyValueFormated = array('data' => $value, 'type' => 'instance', 'attributes' => array('id' => $id, 'class' => 'node-instance'));
         $propertyValuesFormated[] = $propertyValueFormated;
     }
     $data = array('data' => $this->hasRequestParameter('rootNodeName') ? $this->getRequestParameter('rootNodeName') : tao_helpers_Display::textCutter($property->getLabel(), 16), 'type' => 'class', 'count' => count($propertyValuesFormated), 'attributes' => array('id' => tao_helpers_Uri::encode($property->getUri()), 'class' => 'node-class'), 'children' => $propertyValuesFormated);
     echo json_encode($data);
 }