/** * Short description of method getPropertyValues * * @access public * @author Joel Bout, <*****@*****.**> * @param Resource resource * @param Property property * @param array options * @return array */ public function getPropertyValues(core_kernel_classes_Resource $resource, core_kernel_classes_Property $property, $options = array()) { $returnValue = array(); $one = isset($options['one']) && $options['one'] == true ? true : false; if (isset($options['last'])) { throw new core_kernel_persistence_Exception('Option \'last\' no longer supported'); } $platform = $this->getPersistence()->getPlatForm(); // Define language if required $lang = ''; $defaultLg = ''; if (isset($options['lg'])) { $lang = $options['lg']; } else { $lang = \common_session_SessionManager::getSession()->getDataLanguage(); $defaultLg = ' OR l_language = ' . $this->getPersistence()->quote(DEFAULT_LANG) . ' '; } $query = 'SELECT object, l_language FROM statements WHERE subject = ? AND predicate = ? AND ( l_language = ? OR ' . $platform->isNullCondition('l_language') . $defaultLg . ') AND ' . $this->getModelReadSqlCondition(); // Select first if ($one) { $query .= ' ORDER BY id DESC'; $query = $platform->limitStatement($query, 1, 0); $result = $this->getPersistence()->query($query, array($resource->getUri(), $property->getUri(), $lang)); } else { $result = $this->getPersistence()->query($query, array($resource->getUri(), $property->getUri(), $lang)); } // Treat the query result if ($result == true) { // If a language has been defined, do not filter result by language if (isset($options['lg'])) { while ($row = $result->fetch()) { $returnValue[] = $this->getPersistence()->getPlatForm()->getPhpTextValue($row['object']); } } else { $returnValue = Utils::filterByLanguage($this->getPersistence(), $result->fetchAll(), 'l_language'); } } return (array) $returnValue; }