本文整理汇总了PHP中core_kernel_classes_Resource::getPropertyValuesByLg方法的典型用法代码示例。如果您正苦于以下问题:PHP core_kernel_classes_Resource::getPropertyValuesByLg方法的具体用法?PHP core_kernel_classes_Resource::getPropertyValuesByLg怎么用?PHP core_kernel_classes_Resource::getPropertyValuesByLg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_kernel_classes_Resource
的用法示例。
在下文中一共展示了core_kernel_classes_Resource::getPropertyValuesByLg方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exists
private function exists($subject, $property, $object, $lg)
{
$subject = new core_kernel_classes_Resource($subject->getUri());
$values = $subject->getPropertyValuesByLg($property, $lg);
$found = false;
foreach ($values as $value) {
$raw = (string) ($value instanceof core_kernel_classes_Resource ? $value->getUri() : $value);
if ($raw == $object) {
$found = true;
break;
}
}
return $found;
}
示例2: getItemFolder
/**
* Short description of method getItemFolder
*
* @access public
* @author Joel Bout, <joel@taotesting.com>
* @param Resource item
* @param string lang
* @return string
*/
public function getItemFolder(core_kernel_classes_Resource $item, $lang = '')
{
$returnValue = (string) '';
if ($lang === '') {
$files = $item->getPropertyValues(new core_kernel_classes_Property(TAO_ITEM_CONTENT_PROPERTY));
} else {
$files = $item->getPropertyValuesByLg(new core_kernel_classes_Property(TAO_ITEM_CONTENT_PROPERTY), $lang)->toArray();
}
if (count($files) == 0) {
// no content found assign default
$returnValue = $this->getDefaultItemFolder($item, $lang);
} else {
if (count($files) > 1) {
throw new common_Exception(__METHOD__ . ': Item ' . $item->getUri() . ' has multiple.');
}
$content = new core_kernel_file_File(current($files));
$returnValue = dirname($content->getAbsolutePath()) . DIRECTORY_SEPARATOR;
}
return (string) $returnValue;
}
示例3: getTranslatedProperties
/**
* get the properties of an instance for a specific language
*
* @access public
* @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
* @param Resource instance
* @param string lang
* @return array
*/
public function getTranslatedProperties(core_kernel_classes_Resource $instance, $lang)
{
$returnValue = array();
try {
foreach ($instance->getTypes() as $clazz) {
foreach ($clazz->getProperties(true) as $property) {
if ($property->isLgDependent() || $property->getUri() == RDFS_LABEL) {
$collection = $instance->getPropertyValuesByLg($property, $lang);
if ($collection->count() > 0) {
if ($collection->count() == 1) {
$returnValue[$property->getUri()] = (string) $collection->get(0);
} else {
$propData = array();
foreach ($collection->getIterator() as $collectionItem) {
$propData[] = (string) $collectionItem;
}
$returnValue[$property->getUri()] = $propData;
}
}
}
}
}
} catch (Exception $e) {
print $e;
}
return (array) $returnValue;
}
示例4: getItemDirectory
/**
* Returns the items flysystem directory
*
* @param core_kernel_classes_Resource $item
* @param string $language
* @return \oat\oatbox\filesystem\Directory
* @throws Exception
* @throws common_Exception
* @throws core_kernel_persistence_Exception
*/
public function getItemDirectory(core_kernel_classes_Resource $item, $language = '')
{
// Get file by language
if ($language === '') {
$files = $item->getPropertyValues($this->itemContentProperty);
} else {
$files = $item->getPropertyValuesByLg($this->itemContentProperty, $language)->toArray();
}
// If multiple files then throw exception
if (count($files) > 1) {
common_Logger::i(print_r($files, true));
throw new common_Exception(__METHOD__ . ': Item ' . $item->getUri() . ' has multiple.');
}
// If there is one file then return directory
if (count($files) == 1) {
$file = reset($files);
$file = is_object($file) && $file instanceof core_kernel_classes_Resource ? $file->getUri() : (string) $file;
return $this->getFileReferenceSerializer()->unserializeDirectory($file);
}
// Otherwise there is no file, create one and return directory
$model = $this->getItemModel($item);
if (is_null($model)) {
throw new common_Exception('Call to ' . __FUNCTION__ . ' for item without model');
}
// File does not exist, let's create it
$actualLang = empty($language) ? $this->getSessionLg() : $language;
$filePath = tao_helpers_Uri::getUniqueId($item->getUri()) . DIRECTORY_SEPARATOR . 'itemContent' . DIRECTORY_SEPARATOR . $actualLang;
// Create item directory
$itemDirectory = $this->getDefaultItemDirectory()->getDirectory($filePath);
// Set uri file value as serial to item persistence
$serial = $this->getFileReferenceSerializer()->serialize($itemDirectory);
$item->setPropertyValueByLg($this->itemContentProperty, $serial, $actualLang);
// Store file into persistence, purpose of serializer ?
$dataFile = (string) $model->getOnePropertyValue($this->getProperty(TAO_ITEM_MODEL_DATAFILE_PROPERTY));
$this->getFileReferenceSerializer()->serialize($itemDirectory->getFile($dataFile));
return $itemDirectory;
}