本文整理汇总了PHP中core_kernel_classes_Resource::editPropertyValues方法的典型用法代码示例。如果您正苦于以下问题:PHP core_kernel_classes_Resource::editPropertyValues方法的具体用法?PHP core_kernel_classes_Resource::editPropertyValues怎么用?PHP core_kernel_classes_Resource::editPropertyValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_kernel_classes_Resource
的用法示例。
在下文中一共展示了core_kernel_classes_Resource::editPropertyValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setValues
public function setValues()
{
if (!tao_helpers_Request::isAjax()) {
throw new common_exception_IsAjaxAction(__FUNCTION__);
}
$values = tao_helpers_form_GenerisTreeForm::getSelectedInstancesFromPost();
$resource = new core_kernel_classes_Resource($this->getRequestParameter('resourceUri'));
$property = new core_kernel_classes_Property($this->getRequestParameter('propertyUri'));
$success = $resource->editPropertyValues($property, $values);
echo json_encode(array('saved' => $success));
}
示例2: setFirstActivity
/**
* Short description of method setFirstActivity
*
* @access public
* @author Joel Bout, <joel.bout@tudor.lu>
* @param Resource process
* @param Resource activity
* @return boolean
*/
public function setFirstActivity(core_kernel_classes_Resource $process, core_kernel_classes_Resource $activity)
{
$returnValue = (bool) false;
//@TODO: to be moved to actiivty service:
$activities = $this->getActivitiesByProcess($process);
$propActivityInitial = new core_kernel_classes_Property(PROPERTY_ACTIVITIES_ISINITIAL);
foreach ($activities as $activityTemp) {
$activityTemp->editPropertyValues($propActivityInitial, GENERIS_FALSE);
}
$returnValue = $activity->editPropertyValues($propActivityInitial, GENERIS_TRUE);
return (bool) $returnValue;
}
示例3: forceMimeType
/**
* Force the mime-type of a resource
*
* @param string $link
* @param string $mimeType
* @return boolean
*/
public function forceMimeType($link, $mimeType)
{
$resource = new \core_kernel_classes_Resource(\tao_helpers_Uri::decode($link));
return $resource->editPropertyValues(new \core_kernel_classes_Property(MEDIA_MIME_TYPE), $mimeType);
}
示例4: createContent
/**
* Create the default content directory of a QTI test.
*
* @param core_kernel_classes_Resource $test
* @param boolean $createTestFile Whether or not create an empty QTI XML test file. Default is (boolean) true.
* @return Directory the content directory
* @throws taoQtiTest_models_classes_QtiTestServiceException If a runtime error occurs while creating the test content.
*/
public function createContent(core_kernel_classes_Resource $test, $createTestFile = true)
{
$dir = $this->getDefaultDir()->getDirectory(md5($test->getUri()));
if ($dir->exists()) {
throw new common_exception_InconsistentData('Data dir fir test ' . $test->getUri() . ' already exists');
}
$file = $dir->getFile(TAOQTITEST_FILENAME);
if ($createTestFile === true) {
$emptyTestXml = $this->getQtiTestTemplateFileAsString();
$doc = new DOMDocument('1.0', 'UTF-8');
$doc->loadXML($emptyTestXml);
// Set the test label as title.
$doc->documentElement->setAttribute('title', $test->getLabel());
//generate a valid qti identifier
$identifier = tao_helpers_Display::textCleaner($test->getLabel(), '*', 32);
$identifier = str_replace('_', '-', $identifier);
if (preg_match('/^[0-9]/', $identifier)) {
$identifier = '_' . $identifier;
}
$doc->documentElement->setAttribute('identifier', $identifier);
$doc->documentElement->setAttribute('toolVersion', TAO_VERSION);
if (!$file->write($doc->saveXML())) {
$msg = "Unable to write raw QTI Test template.";
throw new taoQtiTest_models_classes_QtiTestServiceException($msg, taoQtiTest_models_classes_QtiTestServiceException::TEST_WRITE_ERROR);
}
common_Logger::i("Created QTI Test content for test '" . $test->getUri() . "'.");
} else {
if ($file->exists()) {
$doc = new DOMDocument('1.0', 'UTF-8');
$doc->loadXML($file->read());
// Label update only.
$doc->documentElement->setAttribute('title', $test->getLabel());
if (!$file->update($doc->saveXML())) {
$msg = "Unable to update QTI Test file.";
throw new taoQtiTest_models_classes_QtiTestServiceException($msg, taoQtiTest_models_classes_QtiTestServiceException::TEST_WRITE_ERROR);
}
}
}
$directory = $this->getFileReferenceSerializer()->serialize($dir);
$test->editPropertyValues($this->getProperty(TEST_TESTCONTENT_PROP), $directory);
return $dir;
}
示例5: storeDelivery
/**
* @param string deliveryIdentifier (uri recommended)
*/
public function storeDelivery(core_kernel_classes_Resource $deliveryResult, $deliveryIdentifier)
{
$propResultOfDelivery = new core_kernel_classes_Property(PROPERTY_RESULT_OF_DELIVERY);
$deliveryResult->editPropertyValues($propResultOfDelivery, $deliveryIdentifier);
try {
//if the delviery information is provided, update to a more meaningful delvieryResult Label
$delivery = new core_kernel_classes_Resource($deliveryIdentifier);
$deliveryLabel = $delivery->getLabel();
$deliveryResult->setLabel(str_replace("-" . $deliveryLabel, "", $deliveryResult->getLabel()) . "-" . $deliveryLabel);
} catch (Exception $e) {
//the test taker to be referrd in the delivery Result does not exist (or the label is not stated)
}
}
示例6: setConnectorType
/**
* Short description of method setConnectorType
*
* @access public
* @author Joel Bout, <joel@taotesting.com>
* @param Resource connector
* @param Resource type
* @return boolean
*/
public function setConnectorType(core_kernel_classes_Resource $connector, core_kernel_classes_Resource $type)
{
$returnValue = (bool) false;
//@TODO: check range of type of connectors:
$returnValue = $connector->editPropertyValues(new core_kernel_classes_Property(PROPERTY_CONNECTORS_TYPE), $type->getUri());
return (bool) $returnValue;
}
示例7: createContent
/**
* Create the defautl content directory of a QTI test.
*
* @param core_kernel_classes_Resource $test
* @param boolean $createTestFile Whether or not create an empty QTI XML test file. Default is (boolean) true.
* @return core_kernel_file_File the content file
* @throws taoQtiTest_models_classes_QtiTestServiceException If a runtime error occurs while creating the test content.
*/
public function createContent(core_kernel_classes_Resource $test, $createTestFile = true)
{
$props = self::getQtiTestDirectory()->getPropertiesValues(array(PROPERTY_FILE_FILESYSTEM, PROPERTY_FILE_FILEPATH));
$repository = new core_kernel_versioning_Repository(current($props[PROPERTY_FILE_FILESYSTEM]));
$path = (string) current($props[PROPERTY_FILE_FILEPATH]);
// $directory is the directory where test related resources will be stored.
$directory = $repository->createFile('', $path . DIRECTORY_SEPARATOR . md5($test->getUri()) . DIRECTORY_SEPARATOR);
$dirPath = $directory->getAbsolutePath() . DIRECTORY_SEPARATOR;
if (!file_exists($dirPath)) {
mkdir($dirPath, 0770, true);
}
if ($createTestFile === true) {
$emptyTestXml = $this->getQtiTestTemplateFileAsString();
$doc = new DOMDocument();
$doc->loadXML($emptyTestXml);
// Set the test label as title.
$doc->documentElement->setAttribute('title', $test->getLabel());
//generate a valid qti identifier
$identifier = tao_helpers_Display::textCleaner($test->getLabel(), '*', 32);
$identifier = str_replace('_', '-', $identifier);
if (preg_match('/^[0-9]/', $identifier)) {
$identifier = '_' . $identifier;
}
$doc->documentElement->setAttribute('identifier', $identifier);
$doc->documentElement->setAttribute('toolVersion', TAO_VERSION);
$filePath = $dirPath . TAOQTITEST_FILENAME;
if ($doc->save($filePath) === false) {
$msg = "Unable to write raw QTI Test template at location '{$filePath}'.";
throw new taoQtiTest_models_classes_QtiTestServiceException($msg, taoQtiTest_models_classes_QtiTestServiceException::TEST_WRITE_ERROR);
}
common_Logger::i("Created QTI Test content at location '" . $filePath . "'.");
}
$test->editPropertyValues(new core_kernel_classes_Property(TEST_TESTCONTENT_PROP), $directory);
return $directory;
}
示例8: cloneContent
/**
* (non-PHPdoc)
* @see taoTests_models_classes_TestModel::cloneContent()
*/
public function cloneContent(core_kernel_classes_Resource $source, core_kernel_classes_Resource $destination)
{
//clone the process:
$propInstanceContent = new core_kernel_classes_Property(TEST_TESTCONTENT_PROP);
try {
$process = $source->getUniquePropertyValue($propInstanceContent);
$processCloner = new wfAuthoring_models_classes_ProcessCloner();
$processClone = $processCloner->cloneProcess($process);
$destination->editPropertyValues($propInstanceContent, $processClone->getUri());
} catch (Exception $e) {
throw new Exception("the test process cannot be found");
}
}
示例9: addTest
/**
*
* For now it is only one test
*
* @author Lionel Lecaque, lionel@taotesting.com
*/
public function addTest(core_kernel_classes_Resource $content, core_kernel_classes_Resource $test)
{
return $content->editPropertyValues(new core_kernel_classes_Property(PROPERTY_DELIVERYCONTENT_TEST), $test->getUri());
}
示例10: setPassword
/**
* Set the password of a specifc user.
*
* @access public
* @author Jerome Bogaerts, <jerome@taotesting.com>
* @param Resource user The user you want to set the password.
* @param string password The md5 hash of the password you want to set to the user.
*/
public function setPassword(core_kernel_classes_Resource $user, $password)
{
if (!is_string($password)) {
throw new core_kernel_users_Exception('The password must be of "string" type, got ' . gettype($password));
}
$user->editPropertyValues(new core_kernel_classes_Property(PROPERTY_USER_PASSWORD), core_kernel_users_Service::getPasswordHash()->encrypt($password));
}
示例11: setControls
/**
* Short description of method setControls
*
* @access public
* @author Joel Bout, <joel.bout@tudor.lu>
* @param Resource activity
* @param array controls
* @return boolean
*/
public function setControls(core_kernel_classes_Resource $activity, $controls)
{
$returnValue = (bool) false;
$possibleValues = $this->getAllControls();
if (is_array($controls)) {
$values = array();
foreach ($controls as $control) {
if (in_array($control, $possibleValues)) {
$values[] = $control;
}
}
$returnValue = $activity->editPropertyValues(new core_kernel_classes_Property(PROPERTY_ACTIVITIES_CONTROLS), $values);
}
return (bool) $returnValue;
}
示例12: update
/**
*
* @author Patrick Plichart, patrick@taotesting.com
* @param string $uri
* @param array $propertiesValues
* @throws common_exception_InvalidArgumentType
* @throws common_exception_PreConditionFailure
* @throws common_exception_NoContent
* @return core_kernel_classes_Resource
*/
public function update($uri, $propertiesValues = array())
{
if (!common_Utils::isUri($uri)) {
throw new common_exception_InvalidArgumentType();
}
if (!$this->isInScope($uri)) {
throw new common_exception_PreConditionFailure("The URI must be a valid resource under the root Class");
}
$resource = new core_kernel_classes_Resource($uri);
// if the resource does not exist, indicate a not found exception
if (count($resource->getRdfTriples()->sequence) == 0) {
throw new common_exception_NoContent();
}
foreach ($propertiesValues as $uri => $parameterValue) {
$resource->editPropertyValues(new core_kernel_classes_Property($uri), $parameterValue);
}
return $resource;
}
示例13: setHidden
/**
* Short description of method setHidden
*
* @access public
* @author Joel Bout, <joel.bout@tudor.lu>
* @param Resource activity
* @param boolean hidden
* @return boolean
*/
public function setHidden(core_kernel_classes_Resource $activity, $hidden = true)
{
$returnValue = (bool) false;
$propHidden = new core_kernel_classes_Property(PROPERTY_ACTIVITIES_ISHIDDEN);
$hidden = (bool) $hidden;
$returnValue = $activity->editPropertyValues($propHidden, $hidden ? GENERIS_TRUE : GENERIS_FALSE);
$this->setCache(__CLASS__ . '::isHidden', array($activity), $hidden);
return (bool) $returnValue;
}
示例14: saveExcludedTestTakers
/**
* Save excluded test takers
* @param \core_kernel_classes_Resource $delivery Delivery instance
* @param array $excluded List of excluded testakers (uri)
* @return boolean
*/
public function saveExcludedTestTakers(\core_kernel_classes_Resource $delivery, $excluded)
{
$success = $delivery->editPropertyValues(new \core_kernel_classes_Property(TAO_DELIVERY_EXCLUDEDSUBJECTS_PROP), $excluded);
return $success;
}
示例15: setByPassProctor
/**
* Set whether this Eligibility can by-pass the proctor authorization
* @param Resource $eligibility
* @param boolean $bypass true if the elligility can by-pass the proctor authorization
*/
public function setByPassProctor(Resource $eligibility, $bypass = false)
{
$eligibility->editPropertyValues(new Property(self::PROPERTY_BYPASSPROCTOR_URI), new Resource($bypass ? self::BOOLEAN_TRUE : self::BOOLEAN_FALSE));
}