/** * Short description of method getPropertiesValues * * @access public * @author Joel Bout, <*****@*****.**> * @param Resource resource * @param array properties * @return array */ public function getPropertiesValues(core_kernel_classes_Resource $resource, $properties) { $returnValue = array(); // check whenever or not properties is empty if (count($properties) == 0) { return array(); } /*foreach($properties as $property){ $returnValue[$property->getUri()] = $this->getPropertyValues($resource, $property); }*/ $predicatesQuery = ''; //build the predicate query //$predicatesQuery = implode(',', $properties); foreach ($properties as $property) { $uri = is_string($property) ? $property : $property->getUri(); $returnValue[$uri] = array(); $predicatesQuery .= ", " . $this->getPersistence()->quote($uri); } $predicatesQuery = substr($predicatesQuery, 1); $platform = $this->getPersistence()->getPlatForm(); //the unique sql query $query = 'SELECT predicate, object, l_language FROM statements WHERE subject = ' . $this->getPersistence()->quote($resource->getUri()) . ' AND predicate IN (' . $predicatesQuery . ') AND (' . $platform->isNullCondition('l_language') . ' OR l_language = ' . $this->getPersistence()->quote(DEFAULT_LANG) . ' OR l_language = ' . $this->getPersistence()->quote(\common_session_SessionManager::getSession()->getDataLanguage()) . ') AND ' . $this->getModelReadSqlCondition(); $result = $this->getPersistence()->query($query); $rows = $result->fetchAll(); $sortedByLg = Utils::sortByLanguage($this->getPersistence(), $rows, 'l_language'); $identifiedLg = Utils::identifyFirstLanguage($sortedByLg); foreach ($rows as $row) { $value = $platform->getPhpTextValue($row['object']); $returnValue[$row['predicate']][] = common_Utils::isUri($value) ? new core_kernel_classes_Resource($value) : new core_kernel_classes_Literal($value); } return (array) $returnValue; }