本文整理汇总了PHP中core_kernel_classes_Resource类的典型用法代码示例。如果您正苦于以下问题:PHP core_kernel_classes_Resource类的具体用法?PHP core_kernel_classes_Resource怎么用?PHP core_kernel_classes_Resource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了core_kernel_classes_Resource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: properties
/**
* Action dedicated to change the settings of the user (language, ...)
*/
public function properties()
{
$myFormContainer = new tao_actions_form_UserSettings($this->getUserSettings());
$myForm = $myFormContainer->getForm();
if ($myForm->isSubmited()) {
if ($myForm->isValid()) {
$currentUser = $this->userService->getCurrentUser();
$userSettings = array(PROPERTY_USER_UILG => $myForm->getValue('ui_lang'), PROPERTY_USER_DEFLG => $myForm->getValue('data_lang'), PROPERTY_USER_TIMEZONE => $myForm->getValue('timezone'));
$uiLang = new core_kernel_classes_Resource($myForm->getValue('ui_lang'));
$dataLang = new core_kernel_classes_Resource($myForm->getValue('data_lang'));
$userSettings[PROPERTY_USER_UILG] = $uiLang->getUri();
$userSettings[PROPERTY_USER_DEFLG] = $dataLang->getUri();
$binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($currentUser);
if ($binder->bind($userSettings)) {
\common_session_SessionManager::getSession()->refresh();
$uiLangCode = tao_models_classes_LanguageService::singleton()->getCode($uiLang);
$extension = common_ext_ExtensionsManager::singleton()->getExtensionById('tao');
tao_helpers_I18n::init($extension, $uiLangCode);
$this->setData('message', __('Settings updated'));
$this->setData('reload', true);
}
}
}
$userLabel = $this->userService->getCurrentUser()->getLabel();
$this->setData('formTitle', sprintf(__("My settings (%s)"), __($userLabel)));
$this->setData('myForm', $myForm->render());
//$this->setView('form.tpl');
$this->setView('form/settings_user.tpl');
}
示例2: exec
/**
* Short description of method exec
*
* @access public
* @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu>
* @param Resource resource
* @param string command
* @return string
*/
public static function exec(core_kernel_classes_Resource $resource, $command)
{
$returnValue = (string) '';
$username = "";
$password = "";
$repository = null;
try {
if (empty($command)) {
throw new Exception(__CLASS__ . ' -> ' . __FUNCTION__ . '() : $command_ must be specified');
}
//get context variables
if ($resource instanceof core_kernel_versioning_File) {
$repository = $resource->getRepository();
} else {
if ($resource instanceof core_kernel_versioning_Repository) {
$repository = $resource;
} else {
throw new Exception('The first parameter (resource) should be a File or a Repository');
}
}
if (is_null($repository)) {
throw new Exception('Unable to find the repository to work with for the reference resource (' . $resource->getUri() . ')');
}
$username = $repository->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_GENERIS_VERSIONEDREPOSITORY_LOGIN));
$password = $repository->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_GENERIS_VERSIONEDREPOSITORY_PASSWORD));
$returnValue = shell_exec('svn --username ' . $username . ' --password ' . $password . ' ' . $command);
// var_dump('svn --username ' . $username . ' --password ' . $password . ' ' . $command);
// var_dump($returnValue);
} catch (Exception $e) {
die('Error code `svn_error_command` in ' . $e->getMessage());
}
return (string) $returnValue;
}
示例3: getExpression
/**
* Short description of method getExpression
*
* @access public
* @author Somsack Sipasseuth, <somsack.sipasseuth@tudor.lu>
* @param Resource rule
* @return mixed
*/
public function getExpression(core_kernel_classes_Resource $rule)
{
$returnValue = null;
$property = new core_kernel_classes_Property(PROPERTY_RULE_IF);
$returnValue = new core_kernel_rules_Expression($rule->getUniquePropertyValue($property)->getUri(), __METHOD__);
return $returnValue;
}
示例4: search
/**
* Search results
* The search is paginated and initiated by the datatable component.
*/
public function search()
{
$params = $this->getRequestParameter('params');
$query = $params['query'];
$class = new core_kernel_classes_Class($params['rootNode']);
$rows = $this->hasRequestParameter('rows') ? (int) $this->getRequestParameter('rows') : null;
$page = $this->hasRequestParameter('page') ? (int) $this->getRequestParameter('page') : 1;
$startRow = is_null($rows) ? 0 : $rows * ($page - 1);
try {
$results = SearchService::getSearchImplementation()->query($query, $class, $startRow, $rows);
$totalPages = is_null($rows) ? 1 : ceil($results->getTotalCount() / $rows);
$response = new StdClass();
if (count($results) > 0) {
foreach ($results as $uri) {
$instance = new core_kernel_classes_Resource($uri);
$instanceProperties = array('id' => $instance->getUri(), RDFS_LABEL => $instance->getLabel());
$response->data[] = $instanceProperties;
}
}
$response->success = true;
$response->page = empty($response->data) ? 0 : $page;
$response->total = $totalPages;
$response->records = count($results);
$this->returnJson($response, 200);
} catch (SyntaxException $e) {
$this->returnJson(array('success' => false, 'msg' => $e->getUserMessage()));
}
}
示例5: create
/**
* Creates a new delivery
*
* @param core_kernel_classes_Class $deliveryClass
* @param core_kernel_classes_Resource $test
* @param array $properties Array of properties of delivery
* @return common_report_Report
*/
public static function create(\core_kernel_classes_Class $deliveryClass, \core_kernel_classes_Resource $test, $properties = array())
{
\common_Logger::i('Creating delivery with ' . $test->getLabel() . ' under ' . $deliveryClass->getLabel());
$storage = new TrackedStorage();
$testCompilerClass = \taoTests_models_classes_TestsService::singleton()->getCompilerClass($test);
$compiler = new $testCompilerClass($test, $storage);
$report = $compiler->compile();
if ($report->getType() == \common_report_Report::TYPE_SUCCESS) {
//$tz = new \DateTimeZone(\common_session_SessionManager::getSession()->getTimeZone());
$tz = new \DateTimeZone('UTC');
if (!empty($properties[TAO_DELIVERY_START_PROP])) {
$dt = new \DateTime($properties[TAO_DELIVERY_START_PROP], $tz);
$properties[TAO_DELIVERY_START_PROP] = (string) $dt->getTimestamp();
}
if (!empty($properties[TAO_DELIVERY_END_PROP])) {
$dt = new \DateTime($properties[TAO_DELIVERY_END_PROP], $tz);
$properties[TAO_DELIVERY_END_PROP] = (string) $dt->getTimestamp();
}
$serviceCall = $report->getData();
$properties[PROPERTY_COMPILEDDELIVERY_DIRECTORY] = $storage->getSpawnedDirectoryIds();
$compilationInstance = DeliveryAssemblyService::singleton()->createAssemblyFromServiceCall($deliveryClass, $serviceCall, $properties);
$report->setData($compilationInstance);
}
return $report;
}
示例6: adminPermissions
/**
* Manage permissions
*/
protected function adminPermissions()
{
$resource = new \core_kernel_classes_Resource($this->getRequestParameter('id'));
$accessRights = AdminService::getUsersPermissions($resource->getUri());
$userList = $this->getUserList();
$roleList = $this->getRoleList();
$this->setData('privileges', PermissionProvider::getRightLabels());
$userData = array();
foreach (array_keys($accessRights) as $uri) {
if (isset($userList[$uri])) {
$userData[$uri] = array('label' => $userList[$uri], 'isRole' => false);
unset($userList[$uri]);
} elseif (isset($roleList[$uri])) {
$userData[$uri] = array('label' => $roleList[$uri], 'isRole' => true);
unset($roleList[$uri]);
} else {
\common_Logger::d('unknown user ' . $uri);
}
}
$this->setData('users', $userList);
$this->setData('roles', $roleList);
$this->setData('userPrivileges', $accessRights);
$this->setData('userData', $userData);
$this->setData('uri', $resource->getUri());
$this->setData('label', _dh($resource->getLabel()));
$this->setView('AdminAccessController/index.tpl');
}
示例7: testImport
public function testImport()
{
$endpoint = ROOT_URL . 'taoQtiTest/RestQtiTests/import';
$file = __DIR__ . '/samples/archives/QTI 2.1/basic/Basic.zip';
$this->assertFileExists($file);
$post_data = array('qtiPackage' => new \CURLFile($file));
$options = array(CURLOPT_POSTFIELDS => $post_data);
$content = $this->curl($endpoint, CURLOPT_POST, "data", $options);
$data = json_decode($content, true);
$this->assertTrue(is_array($data), 'Should return json encoded array');
$this->assertTrue($data['success']);
$this->assertTrue(isset($data['data']));
$this->assertTrue(is_array($data['data']));
$this->assertCount(1, $data['data']);
$testData = reset($data['data']);
$this->assertTrue(isset($testData['testId']));
$uri = $testData['testId'];
$test = new \core_kernel_classes_Resource($uri);
$this->assertTrue($test->exists());
$deletionCall = ROOT_URL . 'taoTests/RestTests?uri=' . urlencode($uri);
$content = $this->curl($deletionCall, 'DELETE', "data");
$data = json_decode($content, true);
$this->assertTrue(is_array($data), 'Should return json encoded array');
$this->assertTrue($data['success']);
$this->assertFalse($test->exists());
// should return an error, instance no longer exists
$content = $this->curl($deletionCall, 'DELETE', "data");
$data = json_decode($content, true);
$this->assertTrue(is_array($data), 'Should return json encoded array');
$this->assertFalse($data['success']);
}
示例8: 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;
}
示例9: getValue
/**
* Short description of method getValue
*
* @access public
* @author Joel Bout, <joel.bout@tudor.lu>
* @param Resource resource
* @param Column column
* @return string
*/
public function getValue(core_kernel_classes_Resource $resource, tao_models_classes_table_Column $column)
{
$returnValue = (string) '';
$result = $resource->getOnePropertyValue($column->getProperty());
$returnValue = $result instanceof core_kernel_classes_Resource ? $result->getLabel() : (string) $result;
return (string) $returnValue;
}
示例10: remove
/**
* Short description of method remove
*
* @access public
* @author Jehan Bihin, <jehan.bihin@tudor.lu>
* @param string $roleUri
* @param string $accessUri
* @return mixed
*/
public function remove($roleUri, $accessUri)
{
$module = new core_kernel_classes_Resource($accessUri);
$role = new core_kernel_classes_Class($roleUri);
$accessProperty = new core_kernel_classes_Property(funcAcl_models_classes_AccessService::PROPERTY_ACL_GRANTACCESS);
// Retrieve the module ID.
$uri = explode('#', $module->getUri());
list($type, $extId, $modId) = explode('_', $uri[1]);
// access via extension?
$extAccess = funcAcl_helpers_Cache::getExtensionAccess($extId);
if (in_array($roleUri, $extAccess)) {
// remove access to extension
$extUri = $this->makeEMAUri($extId);
funcAcl_models_classes_ExtensionAccessService::singleton()->remove($roleUri, $extUri);
// add access to all other controllers
foreach (funcAcl_helpers_Model::getModules($extId) as $eModule) {
if (!$module->equals($eModule)) {
$this->add($roleUri, $eModule->getUri());
$this->getEventManager()->trigger(new AccessRightRemovedEvent($roleUri, $eModule->getUri()));
//$role->setPropertyValue($accessProperty, $eModule->getUri());
}
}
//funcAcl_helpers_Cache::flushExtensionAccess($extId);
}
// Remove the access to the module for this role.
$role->removePropertyValue($accessProperty, $module->getUri());
$this->getEventManager()->trigger(new AccessRightRemovedEvent($roleUri, $accessUri));
funcAcl_helpers_Cache::cacheModule($module);
// Remove the access to the actions corresponding to the module for this role.
foreach (funcAcl_helpers_Model::getActions($module) as $actionResource) {
funcAcl_models_classes_ActionAccessService::singleton()->remove($role->getUri(), $actionResource->getUri());
}
funcAcl_helpers_Cache::cacheModule($module);
}
示例11: spawn
/**
*
* @param unknown $userId
* @param core_kernel_classes_Resource $assembly
* @return taoDelivery_models_classes_execution_KVDeliveryExecution
*/
public static function spawn(common_persistence_KeyValuePersistence $persistence, $userId, core_kernel_classes_Resource $assembly)
{
$identifier = self::DELIVERY_EXECUTION_PREFIX . common_Utils::getNewUri();
$de = new self($persistence, $identifier, array(RDFS_LABEL => $assembly->getLabel(), PROPERTY_DELVIERYEXECUTION_DELIVERY => $assembly->getUri(), PROPERTY_DELVIERYEXECUTION_SUBJECT => $userId, PROPERTY_DELVIERYEXECUTION_START => time(), PROPERTY_DELVIERYEXECUTION_STATUS => INSTANCE_DELIVERYEXEC_ACTIVE));
$de->save();
return $de;
}
示例12: remove
/**
* Short description of method remove
*
* @access public
* @author Jehan Bihin, <jehan.bihin@tudor.lu>
* @param string roleUri
* @param string accessUri
* @return mixed
*/
public function remove($roleUri, $accessUri)
{
$uri = explode('#', $accessUri);
list($type, $ext, $mod, $act) = explode('_', $uri[1]);
$role = new core_kernel_classes_Class($roleUri);
$actionAccessProperty = new core_kernel_classes_Property(funcAcl_models_classes_AccessService::PROPERTY_ACL_GRANTACCESS);
$module = new core_kernel_classes_Resource($this->makeEMAUri($ext, $mod));
$controllerClassName = funcAcl_helpers_Map::getControllerFromUri($module->getUri());
// access via controller?
$controllerAccess = funcAcl_helpers_Cache::getControllerAccess($controllerClassName);
if (in_array($roleUri, $controllerAccess['module'])) {
// remove access to controller
funcAcl_models_classes_ModuleAccessService::singleton()->remove($roleUri, $module->getUri());
// add access to all other actions
foreach (funcAcl_helpers_Model::getActions($module) as $action) {
if ($action->getUri() != $accessUri) {
$this->add($roleUri, $action->getUri());
$this->getEventManager()->trigger(new AccessRightAddedEvent($roleUri, $action->getUri()));
}
}
} elseif (isset($controllerAccess['actions'][$act]) && in_array($roleUri, $controllerAccess['actions'][$act])) {
// remove action only
$role->removePropertyValues($actionAccessProperty, array('pattern' => $accessUri));
$this->getEventManager()->trigger(new AccessRightRemovedEvent($roleUri, $accessUri));
funcAcl_helpers_Cache::flushControllerAccess($controllerClassName);
}
}
示例13: 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;
}
示例14: tearDown
public function tearDown()
{
// removes the created user
$user = new \core_kernel_classes_Resource($this->userUri);
$success = $user->delete();
$this->restoreCache();
}
示例15: getStrings
/**
* Get tokens as string[] extracted from a QTI file
* XML inside qti.xml is parsed and all text is tokenized
*
* @param \core_kernel_classes_Resource $resource
* @return array
*/
public function getStrings(\core_kernel_classes_Resource $resource)
{
try {
$ontologyFiles = $resource->getPropertyValues($this->getProperty(TAO_ITEM_CONTENT_PROPERTY));
if (empty($ontologyFiles)) {
return [];
}
} catch (\core_kernel_classes_EmptyProperty $e) {
return [];
}
$file = $this->getFileReferenceSerializer()->unserializeDirectory(reset($ontologyFiles))->getFile(Service::QTI_ITEM_FILE);
if (!$file->exists()) {
return [];
}
$content = $file->read();
if (empty($content)) {
return [];
}
$dom = new \DOMDocument();
$dom->loadXML($content);
$xpath = new \DOMXPath($dom);
$textNodes = $xpath->query('//text()');
unset($xpath);
$contentStrings = array();
foreach ($textNodes as $textNode) {
if (ctype_space($textNode->wholeText) === false) {
$contentStrings[] = trim($textNode->wholeText);
}
}
return $contentStrings;
}