本文整理汇总了PHP中tao_helpers_Uri类的典型用法代码示例。如果您正苦于以下问题:PHP tao_helpers_Uri类的具体用法?PHP tao_helpers_Uri怎么用?PHP tao_helpers_Uri使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了tao_helpers_Uri类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initElements
/**
* (non-PHPdoc)
* @see tao_helpers_form_FormContainer::initElements()
*/
public function initElements()
{
$fileName = '';
$instances = array();
if (isset($this->data['instance'])) {
$instance = $this->data['instance'];
if ($instance instanceof core_kernel_classes_Resource) {
$instances[$instance->getUri()] = $instance->getLabel();
}
} elseif (isset($this->data['class'])) {
$class = $this->data['class'];
if ($class instanceof core_kernel_classes_Class) {
foreach ($class->getInstances() as $instance) {
$instances[$instance->getUri()] = $instance->getLabel();
}
}
} else {
throw new common_Exception('No class nor instance specified for export');
}
$instances = tao_helpers_Uri::encodeArray($instances, tao_helpers_Uri::ENCODE_ARRAY_KEYS);
$descElt = tao_helpers_form_FormFactory::getElement('desc', 'Label');
$descElt->setValue(__('Enables you to export a published delivery'));
$this->form->addElement($descElt);
$instanceElt = tao_helpers_form_FormFactory::getElement('exportInstance', 'Radiobox');
$instanceElt->setDescription(__('Items'));
$instanceElt->setAttribute('checkAll', true);
$instanceElt->setOptions($instances);
$instanceElt->setValue(current(array_keys($instances)));
$this->form->addElement($instanceElt);
$this->form->createGroup('options', __('Export Options'), array('desc', 'filename', 'exportInstance'));
}
示例2: editCenter
/**
* Edit a Test Center instance
* @return void
*/
public function editCenter()
{
$clazz = $this->getCurrentClass();
$testcenter = $this->getCurrentInstance();
$formContainer = new \tao_actions_form_Instance($clazz, $testcenter);
$myForm = $formContainer->getForm();
if ($myForm->isSubmited()) {
if ($myForm->isValid()) {
$binder = new \tao_models_classes_dataBinding_GenerisFormDataBinder($testcenter);
$testcenter = $binder->bind($myForm->getValues());
$this->setData("selectNode", \tao_helpers_Uri::encode($testcenter->getUri()));
$this->setData('message', __('Test center saved'));
$this->setData('reload', true);
}
}
$memberProperty = new \core_kernel_classes_Property(TestCenterService::PROPERTY_MEMBERS_URI);
$memberForm = \tao_helpers_form_GenerisTreeForm::buildReverseTree($testcenter, $memberProperty);
$memberForm->setData('title', __('Select test takers for the test center'));
$this->setData('memberForm', $memberForm->render());
$groupProperty = new \core_kernel_classes_Property(TestCenterService::PROPERTY_DELIVERY_URI);
$groupForm = \tao_helpers_form_GenerisTreeForm::buildTree($testcenter, $groupProperty);
$groupForm->setData('title', __('Select deliveries available at the test center'));
$this->setData('groupForm', $groupForm->render());
$proctorProperty = new \core_kernel_classes_Property(TestCenterService::PROPERTY_PROCTORS_URI);
$proctorForm = \tao_helpers_form_GenerisTreeForm::buildReverseTree($testcenter, $proctorProperty);
$proctorForm->setData('title', __('Select proctors for the test center'));
$this->setData('proctorForm', $proctorForm->render());
$this->setData('formTitle', __('Edit test center'));
$this->setData('myForm', $myForm->render());
$this->setView('form_test_center.tpl');
}
示例3: editInstance
/**
* Show the form to edit an instance, show also a preview of the media
*/
public function editInstance()
{
$clazz = $this->getCurrentClass();
$instance = $this->getCurrentInstance();
$myFormContainer = new editInstanceForm($clazz, $instance);
$myForm = $myFormContainer->getForm();
if ($myForm->isSubmited()) {
if ($myForm->isValid()) {
$values = $myForm->getValues();
// save properties
$binder = new \tao_models_classes_dataBinding_GenerisFormDataBinder($instance);
$instance = $binder->bind($values);
$message = __('Instance saved');
$this->setData('message', $message);
$this->setData('reload', true);
}
}
$this->setData('formTitle', __('Edit Instance'));
$this->setData('myForm', $myForm->render());
$uri = $this->hasRequestParameter('id') ? $this->getRequestParameter('id') : $this->getRequestParameter('uri');
try {
$mediaSource = new MediaSource(array());
$fileInfo = $mediaSource->getFileInfo($uri);
$mimeType = $fileInfo['mime'];
$xml = in_array($mimeType, array('application/xml', 'text/xml'));
$url = \tao_helpers_Uri::url('getFile', 'MediaManager', 'taoMediaManager', array('uri' => $uri));
$this->setData('xml', $xml);
$this->setData('fileurl', $url);
$this->setData('mimeType', $mimeType);
} catch (\tao_models_classes_FileNotFoundException $e) {
$this->setData('error', __('No file found for this media'));
}
$this->setView('form.tpl');
}
示例4: initElements
protected function initElements()
{
parent::initElements();
$labelElt = $this->form->getElement(\tao_helpers_Uri::encode(RDFS_LABEL));
if ($labelElt !== null) {
$labelElt->addAttribute('noLabel', true);
$labelElt->addAttribute('class', 'full-width js-label');
$labelElt->addAttribute('value', '{{label}}');
$labelElt->setName('label');
$labelElt->addValidators(array(\tao_helpers_form_FormFactory::getValidator('NotEmpty')));
$this->form->addElement($labelElt);
}
$maxExecElt = $this->form->getElement(\tao_helpers_Uri::encode(TAO_DELIVERY_MAXEXEC_PROP));
if ($maxExecElt !== null) {
$maxExecElt->addValidators(array(\tao_helpers_form_FormFactory::getValidator('Integer', array('min' => 1))));
$maxExecElt->addAttribute('value', '{{maxexec}}');
$maxExecElt->addAttribute('noLabel', true);
$maxExecElt->setName('maxexec');
$maxExecElt->addAttribute('class', 'full-width js-maxexec');
$this->form->addElement($maxExecElt);
}
$resultServerElt = $this->form->getElement(\tao_helpers_Uri::encode(TAO_DELIVERY_RESULTSERVER_PROP));
if ($resultServerElt !== null) {
$resultServerElt->addAttribute('noLabel', true);
$resultServerElt->addAttribute('class', 'full-width');
$resultServerElt->setName('resultserver');
$resultServerElt->addValidators(array(\tao_helpers_form_FormFactory::getValidator('NotEmpty')));
$this->form->addElement($resultServerElt);
}
$recurrenceRuleElt = $this->form->getElement(\tao_helpers_Uri::encode(DeliveryScheduleService::TAO_DELIVERY_RRULE_PROP));
if ($recurrenceRuleElt !== null) {
$recurrenceRuleElt->setName('rrule');
$this->form->addElement($recurrenceRuleElt);
}
}
示例5: 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);
}
示例6: files
/**
* Returns a json encoded array describign a directory
*
* @throws common_exception_MissingParameter
* @return string
*/
public function files()
{
if (!$this->hasRequestParameter('uri')) {
throw new common_exception_MissingParameter('uri', __METHOD__);
}
$itemUri = $this->getRequestParameter('uri');
$item = new core_kernel_classes_Resource($itemUri);
if (!$this->hasRequestParameter('lang')) {
throw new common_exception_MissingParameter('lang', __METHOD__);
}
$itemLang = $this->getRequestParameter('lang');
//build filters
$filters = array();
if ($this->hasRequestParameter('filters')) {
$filterParameter = $this->getRequestParameter('filters');
if (!empty($filterParameter)) {
if (preg_match('/\\/\\*/', $filterParameter)) {
common_Logger::w('Stars mime type are not yet supported, filter "' . $filterParameter . '" will fail');
}
$filters = array_map('trim', explode(',', $filterParameter));
}
}
$depth = $this->hasRequestParameter('depth') ? $this->getRequestParameter('depth') : 1;
$resolver = new ItemMediaResolver($item, $itemLang);
$asset = $resolver->resolve($this->getRequestParameter('path'));
$data = $asset->getMediaSource()->getDirectory($asset->getMediaIdentifier(), $filters, $depth);
foreach ($data['children'] as &$child) {
if (isset($child['parent'])) {
$child['url'] = \tao_helpers_Uri::url('files', 'ItemContent', 'taoItems', array('uri' => $itemUri, 'lang' => $itemLang, '1' => $child['parent']));
unset($child['parent']);
}
}
$this->returnJson($data);
}
示例7: initElements
/**
* Short description of method initElements
*
* @access public
* @author Joel Bout, <joel.bout@tudor.lu>
* @return mixed
*/
public function initElements()
{
parent::initElements();
$codeElt = $this->form->getElement(tao_helpers_Uri::encode(PROPERTY_PROCESSVARIABLES_CODE));
$codeElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
$codeElt->addValidator(new wfAuthoring_actions_form_validators_VariableCode(array('uri' => $this->getInstance()->getUri())));
}
示例8: initElements
/**
* Short description of method initElements
*
* @access protected
* @author Joel Bout, <joel.bout@tudor.lu>
* @return mixed
*/
protected function initElements()
{
$langService = tao_models_classes_LanguageService::singleton();
// Retrieve languages available for a GUI usage.
$guiUsage = new core_kernel_classes_Resource(INSTANCE_LANGUAGE_USAGE_GUI);
$guiOptions = array();
foreach ($langService->getAvailableLanguagesByUsage($guiUsage) as $lang) {
$guiOptions[tao_helpers_Uri::encode($lang->getUri())] = $lang->getLabel();
}
// Retrieve languages available for a Data usage.
$dataUsage = new core_kernel_classes_Resource(INSTANCE_LANGUAGE_USAGE_DATA);
$dataOptions = array();
foreach ($langService->getAvailableLanguagesByUsage($dataUsage) as $lang) {
$dataOptions[tao_helpers_Uri::encode($lang->getUri())] = $lang->getLabel();
}
$uiLangElement = tao_helpers_form_FormFactory::getElement('ui_lang', 'Combobox');
$uiLangElement->setDescription(__('Interface language'));
$uiLangElement->setOptions($guiOptions);
$this->form->addElement($uiLangElement);
$dataLangElement = tao_helpers_form_FormFactory::getElement('data_lang', 'Combobox');
$dataLangElement->setDescription(__('Data language'));
$dataLangElement->setOptions($dataOptions);
$this->form->addElement($dataLangElement);
$tzElement = tao_helpers_form_FormFactory::getElement('timezone', 'Combobox');
$tzElement->setDescription(__('Time zone'));
$options = array();
foreach (DateTimeZone::listIdentifiers() as $id) {
$options[$id] = $id;
}
$tzElement->setOptions($options);
$this->form->addElement($tzElement);
}
示例9: editInstance
public function editInstance()
{
$clazz = $this->getCurrentClass();
$instance = $this->getCurrentInstance();
$myFormContainer = new \tao_actions_form_Instance($clazz, $instance);
$myForm = $myFormContainer->getForm();
$nameElement = $myForm->getElement(\tao_helpers_Uri::encode(WebBrowserService::PROPERTY_NAME));
$versionElement = $myForm->getElement(\tao_helpers_Uri::encode(WebBrowserService::PROPERTY_VERSION));
$nameElement->addClass('select2');
$versionElement->setHelp("<span class=\"icon-help tooltipstered\" data-tooltip=\".web-browser-form .browser-version-tooltip-content\" data-tooltip-theme=\"info\"></span>");
if ($myForm->isSubmited()) {
if ($myForm->isValid()) {
$values = $myForm->getValues();
// save properties
$binder = new \tao_models_classes_dataBinding_GenerisFormDataBinder($instance);
$instance = $binder->bind($values);
$message = __('Instance saved');
$this->setData('message', $message);
$this->setData('reload', true);
}
}
$this->setData('formTitle', __('Edit Authorized Web Browser'));
$this->setData('myForm', $myForm->render());
$this->setView('WebBrowsers/form.tpl');
}
示例10: getAuthoring
/**
* @deprecated
* @see taoTests_models_classes_TestModel::getAuthoring()
*/
public function getAuthoring(core_kernel_classes_Resource $test)
{
$ext = common_ext_ExtensionsManager::singleton()->getExtensionById('taoWfTest');
$testService = taoTests_models_classes_TestsService::singleton();
$itemSequence = array();
$itemUris = array();
$i = 1;
foreach ($testService->getTestItems($test) as $item) {
$itemUris[] = $item->getUri();
$itemSequence[$i] = array('uri' => tao_helpers_Uri::encode($item->getUri()), 'label' => $item->getLabel());
$i++;
}
// data for item sequence, terrible solution
// @todo implement an ajax request for labels or pass from tree to sequence
$allItems = array();
foreach ($testService->getAllItems() as $itemUri => $itemLabel) {
$allItems['item_' . tao_helpers_Uri::encode($itemUri)] = $itemLabel;
}
$widget = new Renderer($ext->getConstant('DIR_VIEWS') . 'templates' . DIRECTORY_SEPARATOR . 'authoring.tpl');
$widget->setData('uri', $test->getUri());
$widget->setData('allItems', json_encode($allItems));
$widget->setData('itemSequence', $itemSequence);
// data for generis tree form
$widget->setData('relatedItems', json_encode(tao_helpers_Uri::encodeArray($itemUris)));
$openNodes = tao_models_classes_GenerisTreeFactory::getNodesToOpen($itemUris, new core_kernel_classes_Class(TAO_ITEM_CLASS));
$widget->setData('itemRootNode', TAO_ITEM_CLASS);
$widget->setData('itemOpenNodes', $openNodes);
$widget->setData('saveUrl', _url('saveItems', 'Authoring', 'taoWfTest'));
return $widget->render();
}
示例11: initElements
protected function initElements()
{
$title = tao_helpers_form_FormFactory::getElement('title', 'Free');
$title->setValue('<h2>' . $this->convert('Create and authorize a proctor to the selected test sites') . '</h2>');
$this->form->addElement($title);
parent::initElements();
$this->form->removeElement(\tao_helpers_Uri::encode(PROPERTY_USER_ROLES));
}
示例12: save
/**
*
* @author Lionel Lecaque, lionel@taotesting.com
*/
public function save()
{
$saved = false;
$instance = $this->getCurrentInstance();
$testUri = tao_helpers_Uri::decode($this->getRequestParameter(tao_helpers_Uri::encode(PROPERTY_DELIVERYCONTENT_TEST)));
$saved = $this->contentModel->addTest($instance, new core_kernel_classes_Resource($testUri));
//$saved = $instance->editPropertyValues(new core_kernel_classes_Property(PROPERTY_DELIVERYCONTENT_TEST ), $testUri);
echo json_encode(array('saved' => $saved));
}
示例13: feed
/**
* Short description of method feed
*
* @access public
* @author Joel Bout, <joel.bout@tudor.lu>
* @return mixed
*/
public function feed()
{
$expression = "/^" . preg_quote($this->name, "/") . "(.)*[0-9]+\$/";
$this->setValues(array());
foreach ($_POST as $key => $value) {
if (preg_match($expression, $key)) {
$this->addValue(tao_helpers_Uri::decode($value));
}
}
}
示例14: initDeliveryExecution
public function initDeliveryExecution()
{
$compiledDelivery = new core_kernel_classes_Resource(tao_helpers_Uri::decode($this->getRequestParameter('uri')));
$user = common_session_SessionManager::getSession()->getUser();
if ($this->service->isDeliveryExecutionAllowed($compiledDelivery, $user)) {
$deliveryExecution = $this->executionService->initDeliveryExecution($compiledDelivery, $user->getIdentifier());
} else {
common_Logger::i('Testtaker ' . $user->getIdentifier() . ' not authorised to initialise delivery ' . $compiledDelivery->getUri());
return $this->returnError(__('You are no longer allowed to take the test %s', $compiledDelivery->getLabel()), true);
}
$this->redirect(_url('runDeliveryExecution', null, null, array('deliveryExecution' => $deliveryExecution->getIdentifier())));
}
示例15: getValues
/**
* Short description of method getValues
*
* @access public
* @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
* @param string groupName
* @return array
*/
public function getValues($groupName = '')
{
$returnValue = array();
foreach ($this->elements as $element) {
if (empty($groupName) || !isset($this->groups[$groupName]) || in_array($element->getName(), $this->groups[$groupName]['elements'])) {
$returnValue[tao_helpers_Uri::decode($element->getName())] = $element->getEvaluatedValue();
}
}
unset($returnValue['uri']);
unset($returnValue['classUri']);
return (array) $returnValue;
}