本文整理汇总了PHP中core_kernel_classes_Resource::getPropertiesValues方法的典型用法代码示例。如果您正苦于以下问题:PHP core_kernel_classes_Resource::getPropertiesValues方法的具体用法?PHP core_kernel_classes_Resource::getPropertiesValues怎么用?PHP core_kernel_classes_Resource::getPropertiesValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_kernel_classes_Resource
的用法示例。
在下文中一共展示了core_kernel_classes_Resource::getPropertiesValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getResourceDescription
public function getResourceDescription(core_kernel_classes_Resource $resource, $fromDefinition = true)
{
$returnValue = new stdClass();
$properties = array();
if ($fromDefinition) {
$types = $resource->getTypes();
foreach ($types as $type) {
foreach ($type->getProperties(true) as $property) {
//$this->$$property->getUri() = array($property->getLabel(),$this->getPropertyValues());
$properties[$property->getUri()] = $property;
}
}
//var_dump($properties);
$properties = array_unique($properties);
$propertiesValues = $resource->getPropertiesValues($properties);
if (count($propertiesValues) == 0) {
throw new common_exception_NoContent();
}
$propertiesValuesStdClasses = $this->propertiesValuestoStdClasses($propertiesValues);
} else {
$triples = $resource->getRdfTriples();
if (count($triples) == 0) {
throw new common_exception_NoContent();
}
foreach ($triples as $triple) {
$properties[$triple->predicate][] = common_Utils::isUri($triple->object) ? new core_kernel_classes_Resource($triple->object) : new core_kernel_classes_Literal($triple->object);
}
$propertiesValuesStdClasses = $this->propertiesValuestoStdClasses($properties);
}
$returnValue->uri = $resource->getUri();
$returnValue->properties = $propertiesValuesStdClasses;
return $returnValue;
}
示例2: getValue
/**
* Short description of method getValue
*
* @access public
* @author Somsack Sipasseuth, <somsack.sipasseuth@tudor.lu>
* @param string rowId
* @param string columnId
* @param string data
* @return mixed
*/
public function getValue($rowId, $columnId, $data = null)
{
$returnValue = null;
//@TODO : to be delegated to the LazyAdapter : columnNames, adapterOptions, excludedProperties
if (isset($this->data[$rowId])) {
//return values:
if (isset($this->data[$rowId][$columnId])) {
$returnValue = $this->data[$rowId][$columnId];
}
} else {
if (common_Utils::isUri($rowId)) {
$user = new core_kernel_classes_Resource($rowId);
$this->data[$rowId] = array();
$fastProperty = array(RDFS_LABEL, PROPERTY_USER_LOGIN, PROPERTY_USER_FIRSTNAME, PROPERTY_USER_LASTNAME, PROPERTY_USER_MAIL, PROPERTY_USER_UILG, PROPERTY_USER_DEFLG);
$properties = array();
$propertyUris = array_diff($fastProperty, $this->excludedProperties);
foreach ($propertyUris as $activityExecutionPropertyUri) {
$properties[] = new core_kernel_classes_Property($activityExecutionPropertyUri);
}
$propertiesValues = $user->getPropertiesValues($properties);
foreach ($propertyUris as $propertyUri) {
$value = null;
if (isset($propertiesValues[$propertyUri]) && count($propertiesValues[$propertyUri])) {
$value = reset($propertiesValues[$propertyUri]);
}
switch ($propertyUri) {
case RDFS_LABEL:
case PROPERTY_USER_LOGIN:
case PROPERTY_USER_FIRSTNAME:
case PROPERTY_USER_LASTNAME:
case PROPERTY_USER_MAIL:
case PROPERTY_USER_LOGIN:
case PROPERTY_USER_UILG:
case PROPERTY_USER_DEFLG:
$this->data[$rowId][$propertyUri] = $value instanceof core_kernel_classes_Resource ? $value->getLabel() : (string) $value;
break;
}
}
//get roles:
if (!in_array('roles', $this->excludedProperties)) {
$i = 0;
foreach ($user->getTypes() as $role) {
if ($role instanceof core_kernel_classes_Resource) {
if ($i) {
$this->data[$rowId]['roles'] .= ', ';
} else {
$this->data[$rowId]['roles'] = '';
}
$this->data[$rowId]['roles'] .= $role->getLabel();
}
$i++;
}
}
if (isset($this->data[$rowId][$columnId])) {
$returnValue = $this->data[$rowId][$columnId];
}
}
}
return $returnValue;
}
示例3: getDeliverySettings
public function getDeliverySettings(core_kernel_classes_Resource $delivery)
{
$deliveryProps = $delivery->getPropertiesValues(array(new core_kernel_classes_Property(TAO_DELIVERY_MAXEXEC_PROP), new core_kernel_classes_Property(TAO_DELIVERY_START_PROP), new core_kernel_classes_Property(TAO_DELIVERY_END_PROP)));
$propMaxExec = current($deliveryProps[TAO_DELIVERY_MAXEXEC_PROP]);
$propStartExec = current($deliveryProps[TAO_DELIVERY_START_PROP]);
$propEndExec = current($deliveryProps[TAO_DELIVERY_END_PROP]);
$settings[TAO_DELIVERY_MAXEXEC_PROP] = (!is_object($propMaxExec) or $propMaxExec == "") ? 0 : $propMaxExec->literal;
$settings[TAO_DELIVERY_START_PROP] = (!is_object($propStartExec) or $propStartExec == "") ? null : $propStartExec->literal;
$settings[TAO_DELIVERY_END_PROP] = (!is_object($propEndExec) or $propEndExec == "") ? null : $propEndExec->literal;
return $settings;
}
示例4: getTestData
/**
* Get test data as associative array
* @param \taoDelivery_models_classes_execution_DeliveryExecution $deliveryExecution
* @return array
*/
public function getTestData(\taoDelivery_models_classes_execution_DeliveryExecution $deliveryExecution)
{
$resultService = $this->getResultService($deliveryExecution->getDelivery());
$testUri = $resultService->getTestsFromDeliveryResult($deliveryExecution->getIdentifier());
$testResource = new \core_kernel_classes_Resource($testUri[0]);
$propValues = $testResource->getPropertiesValues(array(RDFS_LABEL));
$result = $this->propertiesToArray($propValues);
$deliveryVariables = $resultService->getVariableDataFromDeliveryResult($deliveryExecution->getIdentifier());
$result = array_merge($result, $this->variablesToArray($deliveryVariables));
return $result;
}
示例5: fromResource
/**
* Builds a service call parameter from it's serialized form
*
* @param core_kernel_classes_Resource $resource
* @return tao_models_classes_service_Parameter
*/
public static function fromResource(core_kernel_classes_Resource $resource)
{
$values = $resource->getPropertiesValues(array(PROPERTY_ACTUALPARAMETER_FORMALPARAMETER, PROPERTY_ACTUALPARAMETER_CONSTANTVALUE, PROPERTY_ACTUALPARAMETER_PROCESSVARIABLE));
if (count($values[PROPERTY_ACTUALPARAMETER_FORMALPARAMETER]) != 1) {
throw new common_exception_InconsistentData('Actual variable ' . $resource->getUri() . ' missing formal parameter');
}
if (count($values[PROPERTY_ACTUALPARAMETER_CONSTANTVALUE]) + count($values[PROPERTY_ACTUALPARAMETER_PROCESSVARIABLE]) != 1) {
throw new common_exception_InconsistentData('Actual variable ' . $resource->getUri() . ' invalid, ' . count($values[PROPERTY_ACTUALPARAMETER_CONSTANTVALUE]) . ' constant values and ' . count($values[PROPERTY_ACTUALPARAMETER_PROCESSVARIABLE]) . ' process variables');
}
if (count($values[PROPERTY_ACTUALPARAMETER_CONSTANTVALUE]) > 0) {
$param = new tao_models_classes_service_ConstantParameter(current($values[PROPERTY_ACTUALPARAMETER_FORMALPARAMETER]), current($values[PROPERTY_ACTUALPARAMETER_CONSTANTVALUE]));
} else {
$param = new tao_models_classes_service_VariableParameter(current($values[PROPERTY_ACTUALPARAMETER_FORMALPARAMETER]), current($values[PROPERTY_ACTUALPARAMETER_PROCESSVARIABLE]));
}
return $param;
}
示例6: getOauthConsumer
public function getOauthConsumer(core_kernel_classes_Resource $consumer)
{
$values = $consumer->getPropertiesValues(array(PROPERTY_OAUTH_KEY, PROPERTY_OAUTH_SECRET, PROPERTY_OAUTH_CALLBACK));
if (empty($values[PROPERTY_OAUTH_KEY]) || empty($values[PROPERTY_OAUTH_SECRET])) {
throw new tao_models_classes_oauth_Exception('Incomplete oauth consumer definition for ' . $consumer->getUri());
}
$consumer_key = (string) current($values[PROPERTY_OAUTH_KEY]);
$secret = (string) current($values[PROPERTY_OAUTH_SECRET]);
if (!empty($values[PROPERTY_OAUTH_CALLBACK])) {
$callbackUrl = (string) current($values[PROPERTY_OAUTH_CALLBACK]);
if (empty($callbackUrl)) {
$callbackUrl = null;
}
} else {
$callbackUrl = null;
}
return new OAuthConsumer($consumer_key, $secret, $callbackUrl);
}
示例7: getItemCategories
/**
* Get the categories of an item
*
* @param RdfResource $item the item
*
* @return string[] the list of categories
*/
public function getItemCategories(RdfResource $item)
{
$categories = [];
foreach ($item->getTypes() as $class) {
$eligibleProperties = $this->getElligibleProperties($class);
$propertiesValues = $item->getPropertiesValues(array_keys($eligibleProperties));
foreach ($propertiesValues as $property => $propertyValues) {
foreach ($propertyValues as $value) {
if ($value instanceof RdfResource) {
$sanitizedIdentifier = self::sanitizeCategoryName($value->getLabel());
} else {
$sanitizedIdentifier = self::sanitizeCategoryName((string) $value);
}
if (Format::isIdentifier($sanitizedIdentifier)) {
$categories[] = $sanitizedIdentifier;
}
}
}
}
return $categories;
}
示例8: run
/**
* Get ontology values of requested item properties
*
* @return $this
* @throws \Exception
*/
public function run()
{
$this->data = [];
if (empty($this->item) || !$this->item instanceof \core_kernel_classes_Resource) {
throw new ExtractorException('Export item not set.');
}
$properties = [];
foreach ($this->columns as $config) {
$properties[] = $config['property'];
}
$values = $this->item->getPropertiesValues($properties);
foreach ($this->columns as $column => $config) {
try {
$data = [];
foreach ($values[$config['property']->getUri()] as $itemValue) {
if (is_array($itemValue)) {
array_walk($itemValue, function (&$value) {
$resource = new \core_kernel_classes_Resource($value);
$value = $resource->getLabel();
});
if (isset($config['delimiter'])) {
$delimiter = $config['delimiter'];
} else {
$delimiter = self::DEFAULT_PROPERTY_DELIMITER;
}
$data[] = explode($delimiter, $itemValue);
continue;
}
$data[] = $itemValue instanceof \core_kernel_classes_Resource ? $itemValue->getLabel() : (string) $itemValue;
}
} catch (\Exception $e) {
\common_Logger::e('ERROR on column ' . $column . ' : ' . $e->getMessage());
$data = ['N/A'];
}
$this->data[$column] = implode(self::DEFAULT_PROPERTY_DELIMITER, $data);
}
$this->columns = [];
return $this;
}
示例9: getVariableData
/**
* Retrieves information about the variable, including or not the related item $getItem (slower)
*
* @access public
* @author Patrick Plichart, <patrick.plichart@taotesting.com>
* @param Resource variable
* @param bool getItem retireve associated item reference
* @return array simple associative
*/
public function getVariableData(core_kernel_classes_Resource $variable, $getItem = false)
{
$returnValue = array();
$baseTypes = $variable->getPropertyValues(new core_kernel_classes_Property(PROPERTY_VARIABLE_BASETYPE));
$baseType = current($baseTypes);
if ($baseType != "file") {
$propValues = $variable->getPropertiesValues(array(PROPERTY_IDENTIFIER, PROPERTY_VARIABLE_EPOCH, RDF_VALUE, PROPERTY_VARIABLE_CARDINALITY, PROPERTY_VARIABLE_BASETYPE));
$returnValue["value"] = (string) base64_decode(current($propValues[RDF_VALUE]));
} else {
$propValues = $variable->getPropertiesValues(array(PROPERTY_IDENTIFIER, PROPERTY_VARIABLE_EPOCH, PROPERTY_VARIABLE_CARDINALITY, PROPERTY_VARIABLE_BASETYPE));
$returnValue["value"] = "";
}
$returnValue["identifier"] = current($propValues[PROPERTY_IDENTIFIER])->__toString();
$class = current($variable->getTypes());
$returnValue["type"] = $class;
$returnValue["epoch"] = current($propValues[PROPERTY_VARIABLE_EPOCH])->__toString();
if (count($propValues[PROPERTY_VARIABLE_CARDINALITY]) > 0) {
$returnValue["cardinality"] = current($propValues[PROPERTY_VARIABLE_CARDINALITY])->__toString();
}
if (count($propValues[PROPERTY_VARIABLE_BASETYPE]) > 0) {
$returnValue["basetype"] = current($propValues[PROPERTY_VARIABLE_BASETYPE])->__toString();
}
if ($getItem) {
$returnValue["item"] = $this->getItemFromVariable($variable);
}
return (array) $returnValue;
}
示例10: getDeliverySettings
protected function getDeliverySettings(core_kernel_classes_Resource $delivery, User $user)
{
$deliveryProps = $delivery->getPropertiesValues(array(new core_kernel_classes_Property(TAO_DELIVERY_MAXEXEC_PROP), new core_kernel_classes_Property(TAO_DELIVERY_START_PROP), new core_kernel_classes_Property(TAO_DELIVERY_END_PROP)));
$propMaxExec = current($deliveryProps[TAO_DELIVERY_MAXEXEC_PROP]);
$propStartExec = current($deliveryProps[TAO_DELIVERY_START_PROP]);
$propEndExec = current($deliveryProps[TAO_DELIVERY_END_PROP]);
$executions = taoDelivery_models_classes_execution_ServiceProxy::singleton()->getUserExecutions($delivery, $user->getIdentifier());
$allowed = $this->service->isDeliveryExecutionAllowed($delivery, $user);
return array("compiledDelivery" => $delivery, "settingsDelivery" => array(TAO_DELIVERY_MAXEXEC_PROP => (!is_object($propMaxExec) or $propMaxExec == "") ? 0 : $propMaxExec->literal, TAO_DELIVERY_START_PROP => (!is_object($propStartExec) or $propStartExec == "") ? null : $propStartExec->literal, TAO_DELIVERY_END_PROP => (!is_object($propEndExec) or $propEndExec == "") ? null : $propEndExec->literal, "TAO_DELIVERY_USED_TOKENS" => count($executions), "TAO_DELIVERY_TAKABLE" => $allowed));
}
示例11: buildInfo
/**
* Returns an array of the information
* a remote system might require
*
* @param core_kernel_classes_Resource $user
*/
public static function buildInfo(core_kernel_classes_Resource $user)
{
$props = $user->getPropertiesValues(array(new core_kernel_classes_Property(PROPERTY_USER_FIRSTNAME), new core_kernel_classes_Property(PROPERTY_USER_LASTNAME), new core_kernel_classes_Property(PROPERTY_USER_LOGIN), new core_kernel_classes_Property(PROPERTY_USER_MAIL), new core_kernel_classes_Property(PROPERTY_USER_UILG)));
$roles = array();
$roleRes = tao_models_classes_UserService::singleton()->getUserRoles($user);
foreach ($roleRes as $role) {
$roles[$role->getUri()] = $role->getLabel();
}
if (isset($props[PROPERTY_USER_UILG]) && is_array($props[PROPERTY_USER_UILG])) {
$langRes = array_pop($props[PROPERTY_USER_UILG]);
$lang = (string) $langRes->getUniquePropertyValue(new core_kernel_classes_Property(RDF_VALUE));
} else {
$lang = DEFAULT_LANG;
}
return array('id' => $user->getUri(), 'login' => !empty($props[PROPERTY_USER_LOGIN]) ? (string) array_pop($props[PROPERTY_USER_LOGIN]) : '', 'first_name' => !empty($props[PROPERTY_USER_FIRSTNAME]) ? (string) array_pop($props[PROPERTY_USER_FIRSTNAME]) : '', 'last_name' => !empty($props[PROPERTY_USER_LASTNAME]) ? (string) array_pop($props[PROPERTY_USER_LASTNAME]) : '', 'email' => !empty($props[PROPERTY_USER_MAIL]) ? (string) array_pop($props[PROPERTY_USER_MAIL]) : '', 'lang' => $lang, 'roles' => $roles);
}
示例12: copyPropertyValuesFromTemplateToAssembly
/**
*
* @author Lionel Lecaque, lionel@taotesting.com
* @param core_kernel_classes_Resource $template
* @param core_kernel_classes_Resource $assembly
*/
private function copyPropertyValuesFromTemplateToAssembly(core_kernel_classes_Resource $template, core_kernel_classes_Resource $assembly)
{
$resultServProps = array(TAO_DELIVERY_RESULTSERVER_PROP, TAO_DELIVERY_MAXEXEC_PROP, TAO_DELIVERY_START_PROP, TAO_DELIVERY_END_PROP);
$templatePropsValues = $template->getPropertiesValues($resultServProps);
$allEmpty = true;
foreach ($templatePropsValues as $key => $value) {
if (!empty($value)) {
$allEmpty = false;
break;
}
}
if ($allEmpty == false) {
$assembly->setPropertiesValues($templatePropsValues);
}
}
示例13: getRecurrenceCollection
/**
* Get list of events.
* @param \core_kernel_classes_Resource $delivery - main delivery instance
* @return \Recurr\RecurrenceCollection
*/
public function getRecurrenceCollection(\core_kernel_classes_Resource $delivery)
{
$deliveryProps = $delivery->getPropertiesValues(array(new \core_kernel_classes_Property(TAO_DELIVERY_START_PROP), new \core_kernel_classes_Property(TAO_DELIVERY_END_PROP), new \core_kernel_classes_Property(DeliveryScheduleService::TAO_DELIVERY_RRULE_PROP)));
$propStartExec = current($deliveryProps[TAO_DELIVERY_START_PROP]);
$propEndExec = current($deliveryProps[TAO_DELIVERY_END_PROP]);
$rrule = !empty($deliveryProps[DeliveryScheduleService::TAO_DELIVERY_RRULE_PROP]) ? current($deliveryProps[DeliveryScheduleService::TAO_DELIVERY_RRULE_PROP])->literal : false;
if (!empty($rrule)) {
$startDate = date_create('@' . $propStartExec->literal);
$endDate = date_create('@' . $propEndExec->literal);
$diff = date_diff($startDate, $endDate);
$rule = new \Recurr\Rule((string) $rrule);
$transformer = new \Recurr\Transformer\ArrayTransformer();
$rEvents = $transformer->transform($rule);
unset($rEvents[0]);
//the first recurrence has the same time as the main delivery
foreach ($rEvents as $rEvent) {
$end = clone $rEvent->getStart();
$end->add($diff);
$rEvent->setEnd($end);
}
} else {
$rEvents = array();
}
return $rEvents;
}
示例14: fromResource
/**
* Builds a service call from it's serialized form
*
* @param core_kernel_classes_Resource $resource
* @return tao_models_classes_service_ServiceCall
*/
public static function fromResource(core_kernel_classes_Resource $resource)
{
$values = $resource->getPropertiesValues(array(PROPERTY_CALLOFSERVICES_SERVICEDEFINITION, PROPERTY_CALLOFSERVICES_ACTUALPARAMETERIN, PROPERTY_CALLOFSERVICES_ACTUALPARAMETEROUT));
$serviceDefUri = current($values[PROPERTY_CALLOFSERVICES_SERVICEDEFINITION]);
$serviceCall = new self(new core_kernel_classes_Resource($serviceDefUri));
foreach ($values[PROPERTY_CALLOFSERVICES_ACTUALPARAMETERIN] as $inRes) {
$param = tao_models_classes_service_Parameter::fromResource($inRes);
$serviceCall->addInParameter($param);
}
if (!empty($values[PROPERTY_CALLOFSERVICES_ACTUALPARAMETEROUT])) {
$param = tao_models_classes_service_Parameter::fromResource(current($values[PROPERTY_CALLOFSERVICES_ACTUALPARAMETEROUT]));
$serviceCall->setOutParameter($param);
}
return $serviceCall;
}
示例15: fetchPropertyValues
/**
* Fetch all the values of properties listed in properties map
*
* @param $payload
* @return mixed
* @throws \common_exception_InvalidArgumentType
*/
protected function fetchPropertyValues($payload)
{
$propertyMap = $this->getPropertiesMap();
$data = [];
foreach ($payload['data'] as $resource) {
$resource = new \core_kernel_classes_Resource($resource->subject);
$resourceData = $resource->getPropertiesValues($propertyMap);
$studentInfo = array_map(function ($row) use($resourceData) {
return join(',', $resourceData[$row]);
}, $propertyMap);
$studentInfo['uri'] = $resource->getUri();
$studentInfo['id'] = \tao_helpers_Uri::encode($resource->getUri());
$data[] = $studentInfo;
}
$payload['data'] = $data;
return $payload;
}