本文整理汇总了PHP中core_kernel_classes_Class::getUri方法的典型用法代码示例。如果您正苦于以下问题:PHP core_kernel_classes_Class::getUri方法的具体用法?PHP core_kernel_classes_Class::getUri怎么用?PHP core_kernel_classes_Class::getUri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_kernel_classes_Class
的用法示例。
在下文中一共展示了core_kernel_classes_Class::getUri方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPropertiesByClass
protected function getPropertiesByClass(\core_kernel_classes_Class $type)
{
if (!isset($this->propertyCache[$type->getUri()])) {
$this->propertyCache[$type->getUri()] = $type->getProperties(true);
// alternativly use non recursiv and union with getPropertiesByClass of parentclasses
}
return $this->propertyCache[$type->getUri()];
}
示例2: isSubjectClass
/**
* Check if the Class in parameter is a subclass of Subject
*
* @access public
* @author Joel Bout, <joel.bout@tudor.lu>
* @param \core_kernel_classes_Class $clazz
* @return boolean
*/
public function isSubjectClass(\core_kernel_classes_Class $clazz)
{
$returnValue = (bool) false;
if ($clazz->getUri() == $this->subjectClass->getUri()) {
$returnValue = true;
} else {
foreach ($this->subjectClass->getSubClasses(true) as $subclass) {
if ($clazz->getUri() == $subclass->getUri()) {
$returnValue = true;
break;
}
}
}
return (bool) $returnValue;
}
示例3: import
/**
* Starts the import based on the form
*
* @param \core_kernel_classes_Class $class
* @param \tao_helpers_form_Form $form
* @return \common_report_Report $report
*/
public function import($class, $form)
{
//as upload may be called multiple times, we remove the session lock as soon as possible
session_write_close();
try {
$file = $form->getValue('source');
$service = MediaService::singleton();
$classUri = $class->getUri();
if (is_null($this->instanceUri) || $this->instanceUri === $classUri) {
//if the file is a zip do a zip import
if ($file['type'] !== 'application/zip') {
if (!$service->createMediaInstance($file["uploaded_file"], $classUri, \tao_helpers_Uri::decode($form->getValue('lang')), $file["name"])) {
$report = \common_report_Report::createFailure(__('Fail to import media'));
} else {
$report = \common_report_Report::createSuccess(__('Media imported successfully'));
}
} else {
$zipImporter = new ZipImporter();
$report = $zipImporter->import($class, $form);
}
} else {
if ($file['type'] !== 'application/zip') {
$service->editMediaInstance($file["uploaded_file"], $this->instanceUri, \tao_helpers_Uri::decode($form->getValue('lang')));
$report = \common_report_Report::createSuccess(__('Media imported successfully'));
} else {
$report = \common_report_Report::createFailure(__('You can\'t upload a zip file as a media'));
}
}
return $report;
} catch (\Exception $e) {
$report = \common_report_Report::createFailure($e->getMessage());
return $report;
}
}
示例4: getTreeData
/**
* Get the list of items to populate the checkbox tree of related items.
* It prints to the HTTP response the tree data formated using json.
* @return void
*/
public function getTreeData()
{
if ($this->hasRequestParameter('classUri')) {
$classUri = tao_helpers_Uri::decode($this->getRequestParameter('classUri'));
$class = new core_kernel_classes_Class($classUri);
$hideNode = true;
} elseif ($this->hasRequestParameter('rootNode')) {
$class = new core_kernel_classes_Class($this->getRequestParameter('rootNode'));
$hideNode = false;
} else {
throw new common_Exception('Missing node information for ' . __FUNCTION__);
}
$openNodes = array($class->getUri());
if ($this->hasRequestParameter('openNodes') && is_array($this->getRequestParameter('openNodes'))) {
$openNodes = array_merge($openNodes, $this->getRequestParameter('openNodes'));
}
$limit = $this->hasRequestParameter('limit') ? $this->getRequestParameter('limit') : 10;
$offset = $this->hasRequestParameter('offset') ? $this->getRequestParameter('offset') : 0;
$showInst = $this->hasRequestParameter('hideInstances') ? !$this->getRequestParameter('hideInstances') : true;
$propertyFilter = $this->getTreeFilter();
$factory = new tao_models_classes_GenerisTreeFactory();
$array = $factory->buildTree($class, $showInst, $openNodes, $limit, $offset, $propertyFilter);
if ($hideNode) {
$array = isset($array['children']) ? $array['children'] : array();
}
header('Content-Type : application/json');
echo json_encode($array);
}
示例5: testHardModel
public function testHardModel()
{
$this->hardify();
$referencer = ResourceReferencer::singleton();
$propertyProxy = PropertyProxy::singleton();
$proxy = ResourceProxy::singleton();
$domainProperty = new core_kernel_classes_Property(RDFS_DOMAIN);
$rangeProperty = new core_kernel_classes_Property(RDFS_RANGE);
$literalClass = new core_kernel_classes_Class(RDFS_LITERAL);
$subClassOfProperty = new core_kernel_classes_Property(RDFS_SUBCLASSOF);
$this->assertTrue($this->targetActorsProperty->exists());
$this->assertTrue($this->targetMovieClass->exists());
$this->assertTrue($this->targetWorkClass->isSubclassOf($this->taoClass));
$this->assertTrue($this->targetWorkClass->getOnePropertyValue($subClassOfProperty)->getUri() == $this->taoClass->getUri());
$this->assertTrue($referencer->isClassReferenced($this->targetWorkClass));
$this->assertFalse(is_a($proxy->getImpToDelegateTo($this->targetWorkClass), 'core_kernel_persistence_smoothsql_Class'));
$this->assertFalse(is_a($proxy->getImpToDelegateTo($this->targetMovieClass), 'core_kernel_persistence_smoothsql_Class'));
$this->assertTrue($this->targetAuthorProperty->getOnePropertyValue($domainProperty)->getUri() == $this->targetWorkClass->getUri());
$this->assertTrue($this->targetAuthorProperty->getOnePropertyValue($rangeProperty)->getUri() == RDFS_LITERAL);
$this->assertTrue($this->targetMovieClass->isSubclassOf($this->targetWorkClass));
$this->assertTrue($this->targetMovieClass->getOnePropertyValue($subClassOfProperty)->getUri() == $this->targetWorkClass->getUri());
$this->assertTrue($referencer->isClassReferenced($this->targetMovieClass));
$this->assertTrue($this->targetProducerProperty->getOnePropertyValue($domainProperty)->getUri() == $this->targetMovieClass->getUri());
$this->assertTrue($this->targetProducerProperty->getOnePropertyValue($rangeProperty)->getUri() == RDFS_LITERAL);
$this->assertTrue($this->targetActorsProperty->getOnePropertyValue($domainProperty)->getUri() == $this->targetMovieClass->getUri());
$this->assertTrue($this->targetActorsProperty->getOnePropertyValue($rangeProperty)->getUri() == RDFS_LITERAL);
$this->assertTrue($this->targetRelatedMoviesProperty->getOnePropertyValue($domainProperty)->getUri() == $this->targetMovieClass->getUri());
$this->assertTrue($this->targetRelatedMoviesProperty->getOnePropertyValue($rangeProperty)->getUri() == $this->targetMovieClass->getUri());
$parentClasses = $this->targetMovieClass->getParentClasses();
$this->assertEquals(1, count($parentClasses));
$this->assertTrue(array_key_exists($this->targetWorkClass->getUri(), $parentClasses));
$prop = new core_kernel_classes_Property($this->targetRelatedMoviesProperty);
$this->assertTrue($prop->isMultiple());
}
示例6: getData
public function getData()
{
if (!tao_helpers_Request::isAjax()) {
throw new common_exception_IsAjaxAction(__FUNCTION__);
}
if ($this->hasRequestParameter('classUri')) {
$classUri = tao_helpers_Uri::decode($this->getRequestParameter('classUri'));
$class = new core_kernel_classes_Class($classUri);
$hideNode = true;
} elseif ($this->hasRequestParameter('rootNode')) {
$class = new core_kernel_classes_Class($this->getRequestParameter('rootNode'));
$hideNode = false;
} else {
throw new common_Exception('Missing node information for ' . __FUNCTION__);
}
$openNodes = array($class->getUri());
if ($this->hasRequestParameter('openNodes') && is_array($this->getRequestParameter('openNodes'))) {
$openNodes = array_merge($openNodes, $this->getRequestParameter('openNodes'));
}
$limit = $this->hasRequestParameter('limit') ? $this->getRequestParameter('limit') : self::DEFAULT_LIMIT;
$offset = $this->hasRequestParameter('offset') ? $this->getRequestParameter('offset') : 0;
$showInst = $this->hasRequestParameter('hideInstances') ? !$this->getRequestParameter('hideInstances') : true;
$factory = new tao_models_classes_GenerisTreeFactory();
$array = $factory->buildTree($class, $showInst, $openNodes, $limit, $offset);
if ($hideNode) {
$array = isset($array['children']) ? $array['children'] : array();
}
echo json_encode($array);
}
示例7: getDirectory
/**
* (non-PHPdoc)
*
* @see \oat\tao\model\media\MediaBrowser::getDirectory
*/
public function getDirectory($parentLink = '', $acceptableMime = array(), $depth = 1)
{
if ($parentLink == '') {
$class = new \core_kernel_classes_Class($this->rootClassUri);
} else {
$class = new \core_kernel_classes_Class(\tao_helpers_Uri::decode($parentLink));
}
$data = array('path' => 'taomedia://mediamanager/' . \tao_helpers_Uri::encode($class->getUri()), 'label' => $class->getLabel());
if ($depth > 0) {
$children = array();
foreach ($class->getSubClasses() as $subclass) {
$children[] = $this->getDirectory($subclass->getUri(), $acceptableMime, $depth - 1);
}
// add a filter for example on language (not for now)
$filter = array();
foreach ($class->searchInstances($filter) as $instance) {
try {
$file = $this->getFileInfo($instance->getUri());
if (count($acceptableMime) == 0 || in_array($file['mime'], $acceptableMime)) {
$children[] = $file;
}
} catch (\tao_models_classes_FileNotFoundException $e) {
\common_Logger::e($e->getMessage());
}
}
$data['children'] = $children;
} else {
$data['parent'] = $parentLink;
}
return $data;
}
示例8: deleteCampaignClass
/**
* remove a campaign class
*
* @access public
* @author Joel Bout, <joel@taotesting.com>
* @param Class clazz
* @return boolean
*/
public function deleteCampaignClass(core_kernel_classes_Class $clazz)
{
$returnValue = (bool) false;
if (!is_null($clazz)) {
if ($this->isCampaignClass($clazz) && $clazz->getUri() != $this->campaignClass->getUri()) {
$returnValue = $clazz->delete();
}
}
return (bool) $returnValue;
}
示例9: deleteClass
/**
* Delete a subclass
*
* @access public
* @author Joel Bout, <joel@taotesting.com>
* @param Class clazz
* @return boolean
*/
public function deleteClass(core_kernel_classes_Class $clazz)
{
$returnValue = (bool) false;
if ($clazz->isSubClassOf($this->getRootClass()) && !$clazz->equals($this->getRootClass())) {
$returnValue = $clazz->delete();
} else {
common_Logger::w('Tried to delete class ' . $clazz->getUri() . ' as if it were a subclass of ' . $this->getRootClass()->getUri());
}
return (bool) $returnValue;
}
示例10: addPermissionToClass
/**
* recursivly add permissions to a class and all instances
*/
public static function addPermissionToClass(\core_kernel_classes_Class $class, $userUri, $rights)
{
$dbAccess = new DataBaseAccess();
$dbAccess->addPermissions($userUri, $class->getUri(), $rights);
foreach ($class->getInstances(false) as $instance) {
$dbAccess->addPermissions($userUri, $instance->getUri(), $rights);
}
foreach ($class->getSubClasses(false) as $subclass) {
self::addPermissionToClass($subclass, $userUri, $rights);
}
}
示例11: import
/**
* Starts the import based on the form
*
* @param \core_kernel_classes_Class $class
* @param \tao_helpers_form_Form $form
* @return \common_report_Report $report
*/
public function import($class, $form)
{
//as upload may be called multiple times, we remove the session lock as soon as possible
session_write_close();
try {
$file = $form->getValue('source');
$service = MediaService::singleton();
$classUri = $class->getUri();
if (is_null($this->instanceUri) || $this->instanceUri === $classUri) {
//if the file is a zip do a zip import
if ($file['type'] !== 'application/zip') {
try {
self::isValidSharedStimulus($file['uploaded_file']);
$filepath = $file['uploaded_file'];
$name = $file['name'];
if (!$service->createMediaInstance($filepath, $classUri, \tao_helpers_Uri::decode($form->getValue('lang')), $name, 'application/qti+xml')) {
$report = \common_report_Report::createFailure(__('Fail to import Shared Stimulus'));
} else {
$report = \common_report_Report::createSuccess(__('Shared Stimulus imported successfully'));
}
} catch (XmlStorageException $e) {
// The shared stimulus is not qti compliant, display error
$report = \common_report_Report::createFailure($e->getMessage());
}
} else {
$report = $this->zipImporter->import($class, $form);
}
} else {
if ($file['type'] !== 'application/zip') {
self::isValidSharedStimulus($file['uploaded_file']);
$filepath = $file['uploaded_file'];
if (in_array($file['type'], array('application/xml', 'text/xml'))) {
$name = basename($file['name'], 'xml');
$name .= 'xhtml';
$filepath = dirname($file['name']) . '/' . $name;
\tao_helpers_File::copy($file['uploaded_file'], $filepath);
}
if (!$service->editMediaInstance($filepath, $this->instanceUri, \tao_helpers_Uri::decode($form->getValue('lang')))) {
$report = \common_report_Report::createFailure(__('Fail to edit shared stimulus'));
} else {
$report = \common_report_Report::createSuccess(__('Shared Stimulus edited successfully'));
}
} else {
$report = $this->zipImporter->edit(new \core_kernel_classes_Resource($this->instanceUri), $form);
}
}
return $report;
} catch (\Exception $e) {
$report = \common_report_Report::createFailure($e->getMessage());
return $report;
}
}
示例12: createInstance
/**
* Short description of method createInstance
*
* @access public
* @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
* @param Class clazz
* @param string label
* @param string comment
* @param string uri
* @return core_kernel_classes_Resource
*/
public static function createInstance(core_kernel_classes_Class $clazz, $label = '', $comment = '', $uri = '')
{
$returnValue = null;
$newUri = !empty($uri) ? self::checkProvidedUri($uri) : common_Utils::getNewUri();
$newResource = new core_kernel_classes_Class($newUri);
$propertiesValues = array(RDF_TYPE => $clazz->getUri());
if (!empty($label)) {
$propertiesValues[RDFS_LABEL] = $label;
}
if (!empty($comment)) {
$propertiesValues[RDFS_COMMENT] = $comment;
}
$check = $newResource->setPropertiesValues($propertiesValues);
if ($check) {
$returnValue = $newResource;
} else {
$msg = "Failed to create an instance of class '" . $clazz->getUri() . "'.";
throw new common_Exception($msg);
common_Logger::e($msg);
}
return $returnValue;
}
示例13: indexTypes
public function indexTypes()
{
$toDo = array();
foreach ($this->resource->getTypes() as $class) {
$toDo[] = $class->getUri();
// $document->addField(Document\Field::Text('class', $class->getLabel()));
}
$done = array(RDFS_RESOURCE, TAO_OBJECT_CLASS);
$toDo = array_diff($toDo, $done);
$classes = array();
while (!empty($toDo)) {
$class = new \core_kernel_classes_Class(array_pop($toDo));
$classes[] = $class->getUri();
foreach ($class->getParentClasses() as $parent) {
if (!in_array($parent->getUri(), $done)) {
$toDo[] = $parent->getUri();
}
}
$done[] = $class->getUri();
}
$this->document->type_r = $classes;
}
示例14: testClassIterator
public function testClassIterator()
{
$expected = array($this->topClass->getUri());
foreach ($this->topClass->getSubClasses(true) as $resource) {
$expected[] = $resource->getUri();
}
sort($expected);
$iterator = new core_kernel_classes_ClassIterator($this->topClass);
$found1 = array();
foreach ($iterator as $resource) {
$this->assertIsA($resource, 'core_kernel_classes_Class');
$found1[] = $resource->getUri();
}
sort($found1);
$this->assertEquals($expected, $found1);
$iterator = new core_kernel_classes_ClassIterator($this->emptyClass);
$found2 = array();
foreach ($iterator as $instance) {
$found2[] = $instance->getUri();
}
$this->assertEquals(1, $iterator->key());
$this->assertEquals(array($this->emptyClass->getUri()), $found2);
}
示例15: testCreateMediaInstance
public function testCreateMediaInstance()
{
$fileTmp = dirname(__DIR__) . '/sample/Brazil.png';
$this->initializeMock($fileTmp);
$lang = 'EN-en';
$classUri = $this->testClass->getUri();
//clear previous tests
$root = new \core_kernel_classes_Class($classUri);
$link = $this->mediaService->createMediaInstance($fileTmp, $classUri, $lang);
$root = new \core_kernel_classes_Class($classUri);
$instances = $root->getInstances();
/** @var \core_kernel_classes_Resource $instance */
$instance = array_pop($instances);
$thing = $instance->getUniquePropertyValue(new \core_kernel_classes_Property(MEDIA_LINK));
$linkResult = $thing instanceof \core_kernel_classes_Resource ? $thing->getUri() : (string) $thing;
$this->assertInstanceOf('\\core_kernel_classes_Resource', $instance, 'It should create an instance under the class in parameter');
$this->assertEquals('Brazil.png', $instance->getLabel(), 'The instance label is wrong');
$this->assertInternalType('string', $link, 'The method return should be a string');
$this->assertEquals($instance->getUri(), $link, 'The instance link is wrong');
$this->assertEquals($linkResult, 'MyGreatLink', 'The returned link is wrong');
$this->assertEquals($lang, $instance->getUniquePropertyValue(new \core_kernel_classes_Property(MEDIA_LANGUAGE)), 'The instance language is wrong');
$root->delete(true);
$root->setSubClassOf($this->mediaService->getRootClass());
}