当前位置: 首页>>代码示例>>PHP>>正文


PHP core_kernel_classes_Class::getSubClasses方法代码示例

本文整理汇总了PHP中core_kernel_classes_Class::getSubClasses方法的典型用法代码示例。如果您正苦于以下问题:PHP core_kernel_classes_Class::getSubClasses方法的具体用法?PHP core_kernel_classes_Class::getSubClasses怎么用?PHP core_kernel_classes_Class::getSubClasses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core_kernel_classes_Class的用法示例。


在下文中一共展示了core_kernel_classes_Class::getSubClasses方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:oat-sa,项目名称:extension-tao-mediamanager,代码行数:36,代码来源:MediaSource.php

示例2: 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);
     }
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:14,代码来源:AdminService.php

示例3: testContext

 public function testContext()
 {
     $this->assertEquals(count($this->targetSubjectClass->getInstances()), 1);
     $this->assertEquals(count($this->targetSubjectSubClass->getInstances()), 1);
     $this->assertEquals(count($this->targetSubjectClass->getInstances()), 1);
     // If get instances in the sub classes of the targetSubjectClass, we should get 2 instances
     $this->assertEquals(count($this->targetSubjectClass->getInstances(true)), 2);
     $this->assertTrue($this->targetMovieClass->isSubClassOf($this->targetWorkClass));
     $this->assertEquals(count($this->targetWorkClass->getSubClasses()), 1);
     $this->assertTrue($this->targetProducerProperty->isMultiple());
 }
开发者ID:nagyist,项目名称:extension-generis-hard,代码行数:11,代码来源:HardImplTest.php

示例4: next

 /**
  * (non-PHPdoc)
  * @see Iterator::next()
  */
 function next()
 {
     $this->currentId++;
     if (!isset($this->classes[$this->currentId]) && !empty($this->todoClasses)) {
         $newUri = array_shift($this->todoClasses);
         $this->classes[] = $newUri;
         $class = new \core_kernel_classes_Class($newUri);
         foreach ($class->getSubClasses(false) as $subClass) {
             if (!in_array($subClass->getUri(), $this->classes) && !in_array($subClass->getUri(), $this->todoClasses)) {
                 $this->todoClasses[] = $subClass->getUri();
             }
         }
     }
 }
开发者ID:nagyist,项目名称:generis,代码行数:18,代码来源:class.ClassIterator.php

示例5: 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);
 }
开发者ID:nagyist,项目名称:generis,代码行数:23,代码来源:GenerisIteratorTest.php

示例6: deleteClass

 /**
  * Delete a subclass
  *
  * @access public
  * @author Joel Bout, <joel@taotesting.com>
  * @param core_kernel_classes_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 = true;
         $subclasses = $clazz->getSubClasses(false);
         foreach ($subclasses as $subclass) {
             $returnValue = $returnValue && $this->deleteClass($subclass);
         }
         foreach ($clazz->getProperties() as $classProperty) {
             $returnValue = $returnValue && $this->deleteClassProperty($classProperty);
         }
         $returnValue = $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;
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:26,代码来源:class.ClassService.php

示例7: rangeToTree

 /**
  * @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
  * @param  core_kernel_classes_Class $range
  * @param  boolean $recursive
  * @return array
  */
 public function rangeToTree(core_kernel_classes_Class $range, $recursive = false)
 {
     $data = array();
     foreach ($range->getSubClasses(false) as $rangeClass) {
         $classData = array('data' => $rangeClass->getLabel(), 'attributes' => array('id' => tao_helpers_Uri::encode($rangeClass->getUri()), 'class' => 'node-instance'));
         $children = $this->rangeToTree($rangeClass, true);
         if (count($children) > 0) {
             $classData['state'] = 'closed';
             $classData['children'] = $children;
         }
         $data[] = $classData;
     }
     if (!$recursive) {
         $returnValue = array('data' => $range->getLabel(), 'attributes' => array('id' => tao_helpers_Uri::encode($range->getUri()), 'class' => 'node-class'), 'children' => $data);
     } else {
         $returnValue = $data;
     }
     return $returnValue;
 }
开发者ID:oat-sa,项目名称:tao-core,代码行数:25,代码来源:class.Treeview.php

示例8: testGetDirectory

 public function testGetDirectory()
 {
     $root = new \core_kernel_classes_Class($this->rootClass);
     //Remove what has been done
     $subclasses = $root->getSubClasses();
     foreach ($subclasses as $subclass) {
         $subclass->delete(true);
     }
     $root->delete();
     $root->setLabel('myRootClass');
     $acceptableMime = array();
     $depth = 1;
     $directory = $this->mediaManagerManagement->getDirectory($this->rootClass, $acceptableMime, $depth);
     $this->assertInternalType('array', $directory, 'The result should be an array');
     $this->assertArrayHasKey('label', $directory, 'The result should contain "label"');
     $this->assertArrayHasKey('path', $directory, 'The result should contain "path"');
     $this->assertArrayHasKey('children', $directory, 'The result should contain "children"');
     $this->assertInternalType('array', $directory['children'], 'Children should be an array');
     $this->assertEmpty($directory['children'], 'Children should be empty');
     $this->assertEquals('myRootClass', $directory['label'], 'The label is not correct');
     $this->assertEquals('taomedia://mediamanager/' . \tao_helpers_Uri::encode($this->rootClass), $directory['path'], 'The path is not correct');
     $root->createSubClass('mySubClass1');
     $root->createSubClass('mySubClass0');
     $newDirectory = $this->mediaManagerManagement->getDirectory($this->rootClass, $acceptableMime, $depth);
     $this->assertInternalType('array', $newDirectory['children'], 'Children should be an array');
     $this->assertNotEmpty($newDirectory['children'], 'Children should not be empty');
     $labels = array();
     foreach ($newDirectory['children'] as $i => $child) {
         $this->assertInternalType('array', $child, 'The result should be an array');
         $this->assertArrayHasKey('label', $child, 'The result should contain "label"');
         $this->assertArrayHasKey('path', $child, 'The result should contain "path"');
         $labels[] = $child['label'];
     }
     $this->assertEquals(2, count($labels));
     $this->assertContains('mySubClass0', $labels);
     $this->assertContains('mySubClass1', $labels);
     //Remove what has been done
     $subclasses = $root->getSubClasses();
     foreach ($subclasses as $subclass) {
         $subclass->delete();
     }
     $root->delete();
 }
开发者ID:nagyist,项目名称:extension-tao-mediamanager,代码行数:43,代码来源:MediaManagerBrowserTest.php

示例9: isSubClassOf

 /**
  * (non-PHPdoc)
  * @see core_kernel_persistence_ClassInterface::isSubClassOf()
  */
 public function isSubClassOf(core_kernel_classes_Class $resource, core_kernel_classes_Class $parentClass)
 {
     $returnValue = false;
     $query = 'SELECT object FROM statements WHERE subject = ? AND predicate = ? AND ' . $this->getPersistence()->getPlatForm()->getObjectTypeCondition() . ' = ?';
     $result = $this->getPersistence()->query($query, array($resource->getUri(), RDFS_SUBCLASSOF, $parentClass->getUri()));
     while ($row = $result->fetch()) {
         $returnValue = true;
         break;
     }
     if (!$returnValue) {
         $parentSubClasses = $parentClass->getSubClasses(true);
         foreach ($parentSubClasses as $subClass) {
             if ($subClass->getUri() == $resource->getUri()) {
                 $returnValue = true;
                 break;
             }
         }
     }
     return $returnValue;
 }
开发者ID:nagyist,项目名称:generis,代码行数:24,代码来源:class.Class.php

示例10: index

 public function index()
 {
     // load all extensions
     \common_ext_ExtensionsManager::singleton()->getInstalledExtensions();
     $res = $this->getCurrentResource();
     $this->setData('res', $res);
     $this->setData('types', $res->getTypes());
     //restricted on the currently selected language
     //$this->setData('triples', $res->getRdfTriples()->getIterator());
     $this->setData('triples', $this->getRdfTriples($res, 'subject')->getIterator());
     $this->setData('otriples', $this->getRdfTriples($res, 'object')->getIterator());
     $this->setData('ptriples', $this->getRdfTriples($res, 'predicate')->getIterator());
     if ($res->isClass()) {
         $class = new \core_kernel_classes_Class($res->getUri());
         $this->setData('subclassOf', $class->getParentClasses(false));
         $this->setData('subclasses', $class->getSubClasses());
         $this->setData('instances', $class->getInstances());
     }
     $this->setData('userLg', $dataLang = \common_session_SessionManager::getSession()->getDataLanguage());
     $this->setView('browse.tpl');
 }
开发者ID:nagyist,项目名称:extension-tao-ontobrowser,代码行数:21,代码来源:Browse.php

示例11: buildChildNodes

 /**
  * Builds the content of a class node including it's content
  * 
  * @param core_kernel_classes_Class $class
  * @param boolean $showResources
  * @param int $limit
  * @param int $offset
  * @param array $openNodes
  * @param array $propertyFilter filter resources based on properties uri => value
  * @return array
  */
 private function buildChildNodes(core_kernel_classes_Class $class, $showResources, $limit, $offset, $openNodes, $propertyFilter)
 {
     $childs = array();
     // subclasses
     foreach ($class->getSubClasses(false) as $subclass) {
         $childs[] = $this->classToNode($subclass, $class, $showResources, $limit, $offset, $openNodes, $propertyFilter);
     }
     // resources
     if ($showResources) {
         $searchResult = $class->searchInstances($propertyFilter, array('limit' => $limit, 'offset' => $offset, 'recursive' => false));
         foreach ($searchResult as $instance) {
             $childs[] = $this->buildResourceNode($instance, $class);
         }
     }
     return $childs;
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:27,代码来源:class.GenerisTreeFactory.php

示例12: createUniqueLabel

 /**
  * Short description of method createUniqueLabel
  *
  * @access public
  * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
  * @param  Class clazz
  * @param  boolean subClassing
  * @return string
  */
 public function createUniqueLabel(core_kernel_classes_Class $clazz, $subClassing = false)
 {
     $returnValue = (string) '';
     if ($subClassing) {
         $labelBase = $clazz->getLabel() . '_';
         $count = count($clazz->getSubClasses()) + 1;
     } else {
         $labelBase = $clazz->getLabel() . ' ';
         $count = count($clazz->getInstances()) + 1;
     }
     $options = array('lang' => \common_session_SessionManager::getSession()->getDataLanguage(), 'like' => false, 'recursive' => false);
     do {
         $exist = false;
         $label = $labelBase . $count;
         $result = $clazz->searchInstances(array(RDFS_LABEL => $label), $options);
         if (count($result) > 0) {
             $exist = true;
             $count++;
         }
     } while ($exist);
     $returnValue = $label;
     return (string) $returnValue;
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:32,代码来源:class.GenerisService.php

示例13: searchType

 /**
  * return a preset query builder with types
  * @param QueryBuilderInterface $query
  * @param string $class_uri
  * @param boolean $recursive
  * @return QueryBuilderInterface
  */
 public function searchType(QueryBuilderInterface $query, $class_uri, $recursive = false)
 {
     $Class = new \core_kernel_classes_Class($class_uri);
     $rdftypes = [];
     foreach ($Class->getSubClasses($recursive) as $subClass) {
         $rdftypes[] = $subClass->getUri();
     }
     $rdftypes[] = $class_uri;
     $criteria = $query->newQuery()->add('http://www.w3.org/1999/02/22-rdf-syntax-ns#type')->in($rdftypes);
     return $criteria;
 }
开发者ID:oat-sa,项目名称:generis,代码行数:18,代码来源:ComplexSearchService.php

示例14: savePermissions

 /**
  * add privileges for a group of users on resources. It works for add or modify privileges
  * @return bool
  */
 public function savePermissions()
 {
     $users = $this->getRequest()->getParameter('users');
     $resourceIds = (array) $this->getRequest()->getParameter('resource_id');
     $recursive = $this->getRequest()->getParameter('recursive') === "1";
     // cleanup uri param
     if ($this->hasRequestParameter('uri')) {
         $resourceId = $this->getRequest()->getParameter('uri');
     } else {
         $resourceId = (string) $this->getRequest()->getParameter('resource_id');
     }
     // cleanup privilege param
     if ($this->hasRequestParameter('privileges')) {
         $privileges = $this->getRequestParameter('privileges');
     } else {
         $privileges = array();
         foreach ($this->getRequest()->getParameter('users') as $userId => $data) {
             unset($data['type']);
             $privileges[$userId] = array_keys($data);
         }
     }
     // Check if there is still a owner on this resource
     if (!$this->validatePermissions($privileges)) {
         \common_Logger::e('Cannot save a list without a fully privileged user');
         return $this->returnJson(array('success' => false), 500);
     }
     //get resource
     $clazz = new \core_kernel_classes_Class($resourceId);
     $resources = array($clazz);
     if ($recursive) {
         $resources = array_merge($resources, $clazz->getSubClasses(true));
         $resources = array_merge($resources, $clazz->getInstances(true));
     }
     foreach ($resources as $resource) {
         $permissions = $this->dataAccess->getDeltaPermissions($resource->getUri(), $privileges);
         // add permissions
         foreach ($permissions['add'] as $userId => $privilegeIds) {
             if (count($privilegeIds) > 0) {
                 $this->dataAccess->addPermissions($userId, $resource->getUri(), $privilegeIds);
             }
         }
         // remove permissions
         foreach ($permissions['remove'] as $userId => $privilegeIds) {
             if (count($privilegeIds) > 0) {
                 $this->dataAccess->removePermissions($userId, $resource->getUri(), $privilegeIds);
             }
         }
     }
     return $this->returnJson(array('success' => true));
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:54,代码来源:AdminAccessController.php

示例15: rangeToTree

 public function rangeToTree(core_kernel_classes_Class $range, $recursive = true)
 {
     $openNodes = array_reduce($range->getSubClasses(true), function ($carry, $item) {
         if (!$carry) {
             $carry = [];
         }
         $carry[] = $item->getUri();
         return $carry;
     });
     $openNodes[] = $range->getUri();
     $factory = new GenerisTreeFactory(true, $openNodes, 10, 0);
     $array = $factory->buildTree($range);
     return $array;
 }
开发者ID:oat-sa,项目名称:tao-core,代码行数:14,代码来源:class.Treeview.php


注:本文中的core_kernel_classes_Class::getSubClasses方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。