本文整理汇总了PHP中tao_helpers_Uri::encodeArray方法的典型用法代码示例。如果您正苦于以下问题:PHP tao_helpers_Uri::encodeArray方法的具体用法?PHP tao_helpers_Uri::encodeArray怎么用?PHP tao_helpers_Uri::encodeArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tao_helpers_Uri
的用法示例。
在下文中一共展示了tao_helpers_Uri::encodeArray方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: index
/**
* Renders the auhtoring for simple tests
*/
public function index()
{
$test = $this->getCurrentInstance();
$itemSequence = array();
$itemUris = array();
$counter = 1;
foreach ($this->service->getTestItems($test) as $item) {
$itemUris[] = $item->getUri();
$itemSequence[$counter] = array('uri' => tao_helpers_Uri::encode($item->getUri()), 'label' => $item->getLabel());
$counter++;
}
// data for item sequence, terrible solution
// @todo implement an ajax request for labels or pass from tree to sequence
$allItems = array();
foreach ($this->service->getAllItems() as $itemUri => $itemLabel) {
$allItems['item_' . tao_helpers_Uri::encode($itemUri)] = $itemLabel;
}
$this->setData('uri', $test->getUri());
$this->setData('allItems', json_encode($allItems));
$this->setData('itemSequence', $itemSequence);
// data for generis tree form
$this->setData('relatedItems', json_encode(tao_helpers_Uri::encodeArray($itemUris)));
$openNodes = tao_models_classes_GenerisTreeFactory::getNodesToOpen($itemUris, new core_kernel_classes_Class(TAO_ITEM_CLASS));
$this->setData('itemRootNode', TAO_ITEM_CLASS);
$this->setData('itemOpenNodes', $openNodes);
$this->setData('saveUrl', _url('saveItems', 'Authoring', 'taoWfTest'));
$this->setView('authoring.tpl');
}
示例3: 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();
}
示例4: index
/**
* Render the creator base view
*/
public function index()
{
$labels = array();
$testUri = $this->getRequestParameter('uri');
$testModel = new taoQtiTest_models_classes_TestModel();
$items = $testModel->getItems(new core_kernel_classes_Resource(tao_helpers_Uri::decode($testUri)));
foreach ($items as $item) {
$labels[$item->getUri()] = $item->getLabel();
}
$this->setData('labels', json_encode(tao_helpers_Uri::encodeArray($labels, tao_helpers_Uri::ENCODE_ARRAY_KEYS)));
$this->setData('loadUrl', _url('getTest', null, null, array('uri' => $testUri)));
$this->setData('saveUrl', _url('saveTest', null, null, array('uri' => $testUri)));
$this->setData('itemsUrl', _url('get', 'Items'));
$this->setData('identifierUrl', _url('getIdentifier', null, null, array('uri' => $testUri)));
$this->setView('creator.tpl');
}
示例5: testMapping
public function testMapping()
{
$csv_column = array('login', 'password', 'title', 'last-name', 'firstname', 'gender', 'mail', 'token', 'abelabel');
$properties = tao_helpers_Uri::encodeArray(array(RDFS_LABEL => 'Label', PROPERTY_USER_FIRSTNAME => 'First Name', PROPERTY_USER_LASTNAME => 'Last Name', PROPERTY_USER_LOGIN => 'Login', PROPERTY_USER_PASSWORD => 'Password', PROPERTY_USER_MAIL => 'Mail', PROPERTY_USER_UILG => 'Interface Language', PasswordRecoveryService::PROPERTY_PASSWORD_RECOVERY_TOKEN => 'Password recovery token'), tao_helpers_Uri::ENCODE_ARRAY_KEYS);
$data = array();
$options = array('class_properties' => $properties, 'ranged_properties' => array(), 'csv_column' => $csv_column, tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES => true);
$formContainer = new tao_models_classes_import_CSVMappingForm($data, $options);
$form = $formContainer->getForm();
$this->assertEquals('csv_select', $form->getElement('http_2_www_0_w3_0_org_1_2000_1_01_1_rdf-schema_3_label')->getEvaluatedValue());
$this->assertEquals('4_O', $form->getElement('http_2_www_0_tao_0_lu_1_Ontologies_1_generis_0_rdf_3_userFirstName')->getEvaluatedValue());
$this->assertEquals('3_O', $form->getElement('http_2_www_0_tao_0_lu_1_Ontologies_1_generis_0_rdf_3_userLastName')->getEvaluatedValue());
$this->assertEquals('0_O', $form->getElement('http_2_www_0_tao_0_lu_1_Ontologies_1_generis_0_rdf_3_login')->getEvaluatedValue());
$this->assertEquals('1_O', $form->getElement('http_2_www_0_tao_0_lu_1_Ontologies_1_generis_0_rdf_3_password')->getEvaluatedValue());
$this->assertEquals('6_O', $form->getElement('http_2_www_0_tao_0_lu_1_Ontologies_1_generis_0_rdf_3_userMail')->getEvaluatedValue());
$this->assertEquals('csv_select', $form->getElement('http_2_www_0_tao_0_lu_1_Ontologies_1_generis_0_rdf_3_userUILg')->getEvaluatedValue());
$this->assertEquals('csv_select', $form->getElement('http_2_www_0_tao_0_lu_1_Ontologies_1_generis_0_rdf_3_passwordRecoveryToken')->getEvaluatedValue());
}
示例6: selectItems
/**
* Render the tree and the list to select and order the test related items
* @return void
*/
public function selectItems()
{
$this->setData('uri', $this->getRequestParameter('uri'));
$this->setData('classUri', $this->getRequestParameter('classUri'));
$test = $this->getCurrentInstance();
$allItems = array();
foreach ($this->service->getAllItems() as $itemUri => $itemLabel) {
$allItems['item_' . tao_helpers_Uri::encode($itemUri)] = $itemLabel;
}
$this->setData('allItems', json_encode($allItems));
$relatedItems = tao_helpers_Uri::encodeArray($this->service->getTestItems($test, true), tao_helpers_Uri::ENCODE_ARRAY_VALUES);
$this->setData('relatedItems', json_encode($relatedItems));
$itemSequence = array();
foreach ($relatedItems as $index => $itemUri) {
$item = new core_kernel_classes_Resource($itemUri);
$itemSequence[$index] = array('uri' => tao_helpers_Uri::encode($itemUri), 'label' => $item->getLabel());
}
$this->setData('itemSequence', $itemSequence);
$this->setView('items.tpl');
}
示例7: initElements
/**
* overriden
*
* @access public
* @author Joel Bout, <joel.bout@tudor.lu>
* @return mixed
*/
public function initElements()
{
$fileName = '';
$instances = array();
if (isset($this->data['instance'])) {
$resource = $this->data['instance'];
} elseif (isset($this->data['class'])) {
$resource = $this->data['class'];
} else {
throw new common_Exception('No class nor instance specified for export');
}
$fileName = strtolower(tao_helpers_Display::textCleaner($resource->getLabel(), '*'));
$hiddenElt = tao_helpers_form_FormFactory::getElement('resource', 'Hidden');
$hiddenElt->setValue($resource->getUri());
$this->form->addElement($hiddenElt);
$nameElt = tao_helpers_form_FormFactory::getElement('filename', 'Textbox');
$nameElt->setDescription(__('File name'));
$nameElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
$nameElt->setValue($fileName);
$nameElt->setUnit(".rdf");
$this->form->addElement($nameElt);
$instances = tao_helpers_Uri::encodeArray($instances, tao_helpers_Uri::ENCODE_ARRAY_KEYS);
$this->form->createGroup('options', __('Export Metadata as RDF/XML file'), array('rdf_desc', 'filename', 'rdftpl'));
}
示例8: getFullDeliveryData
/**
* Function returns extended delivery data (e.g. groups, number of executions etc.)
* @param \core_kernel_classes_Resource $delivery
* @return void
*/
private function getFullDeliveryData(\core_kernel_classes_Resource $delivery)
{
$result = array();
if (\taoDelivery_models_classes_execution_ServiceProxy::singleton()->implementsMonitoring()) {
$execs = \taoDelivery_models_classes_execution_ServiceProxy::singleton()->getExecutionsByDelivery($delivery);
$result['executions'] = count($execs);
}
$result['published'] = $this->service->getCompilationDate($delivery);
//groups
$groups = array_keys($this->getServiceManager()->get('taoDeliverySchedule/DeliveryGroupsService')->getGroups($delivery));
$result['groups'] = \tao_helpers_Uri::encodeArray($groups);
//Test takers
$result = $result + DeliveryTestTakersService::singleton()->getDeliveryTestTakers($delivery);
//Max. number of executions
$deliveryMaxexecProperty = new \core_kernel_classes_Property(TAO_DELIVERY_MAXEXEC_PROP);
$result['maxexec'] = (string) $delivery->getOnePropertyValue($deliveryMaxexecProperty);
//Result server
$resultServerProp = new \core_kernel_classes_Property(TAO_DELIVERY_RESULTSERVER_PROP);
$result['resultserver'] = $delivery->getOnePropertyValue($resultServerProp)->getUri();
$result['resultserver'] = \tao_helpers_Uri::encode($result['resultserver']);
$result['repeatedDeliveries'] = $this->getServiceManager()->get(RepeatedDeliveryService::CONFIG_ID)->getRepeatedDeliveriesData($delivery);
return $result;
}
示例9: getTranslatedData
/**
* load the translated data of an instance regarding the given lang
* @return void
*/
public function getTranslatedData()
{
if (!tao_helpers_Request::isAjax()) {
throw new Exception("wrong request mode");
}
$data = array();
if ($this->hasRequestParameter('lang')) {
$data = tao_helpers_Uri::encodeArray($this->getClassService()->getTranslatedProperties($this->getCurrentInstance(), $this->getRequestParameter('lang')), tao_helpers_Uri::ENCODE_ARRAY_KEYS);
}
echo json_encode($data);
}
示例10: initElements
/**
* overriden
*
* @access public
* @author Joel Bout, <joel.bout@tudor.lu>
* @return mixed
*/
public function initElements()
{
$testService = taoTests_models_classes_TestsService::singleton();
$testModel = new core_kernel_classes_Resource(INSTANCE_TEST_MODEL_QTI);
$fileName = '';
$options = array();
if (isset($this->data['instance'])) {
$test = $this->data['instance'];
if ($test instanceof core_kernel_classes_Resource) {
if ($testModel->equals($testService->getTestModel($test))) {
$fileName = strtolower(tao_helpers_Display::textCleaner($test->getLabel()));
$options[$test->getUri()] = $test->getLabel();
}
}
} else {
if (isset($this->data['class'])) {
$class = $this->data['class'];
} else {
$class = $itemService->getRootClass();
}
if ($class instanceof core_kernel_classes_Class) {
$fileName = strtolower(tao_helpers_Display::textCleaner($class->getLabel(), '*'));
foreach ($class->getInstances() as $instance) {
if ($testModel->equals($testService->getTestModel($instance))) {
$options[$instance->getUri()] = $instance->getLabel();
}
}
}
}
$nameElt = tao_helpers_form_FormFactory::getElement('filename', 'Textbox');
$nameElt->setDescription(__('File name'));
$nameElt->setValue($fileName);
$nameElt->setUnit(".zip");
$nameElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
$this->form->addElement($nameElt);
$instanceElt = tao_helpers_form_FormFactory::getElement('instances', 'Checkbox');
$instanceElt->setDescription(__('Test'));
//$instanceElt->setAttribute('checkAll', true);
$instanceElt->setOptions(tao_helpers_Uri::encodeArray($options, tao_helpers_Uri::ENCODE_ARRAY_KEYS));
foreach (array_keys($options) as $value) {
$instanceElt->setValue($value);
}
$this->form->addElement($instanceElt);
$this->form->createGroup('options', __('Export QTI 2.1 Test Package'), array('filename', 'instances'));
}
示例11: connectorEditor
public static function connectorEditor(core_kernel_classes_Resource $connector, core_kernel_classes_Resource $connectorType = null, $formName = '', core_kernel_classes_Resource $activity)
{
if (empty($formName)) {
$formName = 'connectorForm';
}
$myForm = null;
$myForm = tao_helpers_form_FormFactory::getForm($formName, array());
$myForm->setActions(array(), 'bottom');
//delete the default 'save' and 'revert' buttons
//add a hidden input to post the uri of the connector that is being edited
$elementConnectorUri = tao_helpers_form_FormFactory::getElement('connectorUri', 'Hidden');
$elementConnectorUri->setValue(tao_helpers_Uri::encode($connector->getUri()));
$myForm->addElement($elementConnectorUri);
//add a hidden input to post the uri of the activity of the connector that is being edited
$elementActivityUri = tao_helpers_form_FormFactory::getElement('activityUri', 'Hidden');
$elementActivityUri->setValue(tao_helpers_Uri::encode($activity->getUri()));
$myForm->addElement($elementActivityUri);
//add label input: authorize connector label editing or not?
$elementLabel = tao_helpers_form_FormFactory::getElement('label', 'Textbox');
$elementLabel->setDescription(__('Label'));
$elementLabel->setValue($connector->getLabel());
$myForm->addElement($elementLabel);
//add a drop down select input to allow selecting Type of Connector
$elementConnectorType = tao_helpers_form_FormFactory::getElement(tao_helpers_Uri::encode(PROPERTY_CONNECTORS_TYPE), 'Combobox');
$elementConnectorType->setDescription(__('Connector Type'));
$range = new core_kernel_classes_Class(CLASS_TYPEOFCONNECTORS);
if ($range != null) {
$options = array();
foreach ($range->getInstances(true) as $rangeInstance) {
$options[tao_helpers_Uri::encode($rangeInstance->getUri())] = $rangeInstance->getLabel();
}
$elementConnectorType->setOptions($options);
}
//TODO: check if the parent of the current connector is a connector as well: if so, only allow the split type connector, since there will be no use of a sequential one
//check if the property value "type of connector" of the current connector exists
if (empty($connectorType)) {
//get the type of connector of the current connector
$collection = $connector->getPropertyValuesCollection(new core_kernel_classes_Property(PROPERTY_CONNECTORS_TYPE));
if ($collection->isEmpty()) {
//if the type of connector is not set yet, simply return a dropdown menu of available type of connector
$myForm->addElement($elementConnectorType);
return $myForm;
} else {
foreach ($collection->getIterator() as $value) {
if ($value instanceof core_kernel_classes_Resource) {
//a connector type has been found!
$connectorType = $value;
$elementConnectorType->setValue($connectorType->getUri());
//no need to use tao_helpers_Uri::encode here: seems like that it would be done sw else
$myForm->addElement($elementConnectorType);
break;
//stop at the first occurence, which should be the unique one (use newly added getOnePropertyValue here instead)
}
}
}
}
//if the type of connector is still not set here,there is a problem
if (empty($connectorType)) {
throw new Exception("an empty value of service definition has been found for the call of service that is being edited");
return $myForm;
}
//continue building the form according the the type of connector:
$elementInputs = array();
if ($connectorType->getUri() == INSTANCE_TYPEOFCONNECTORS_SEQUENCE) {
$elementInputs = self::nextActivityElements($connector, 'next');
} else {
if ($connectorType->getUri() == INSTANCE_TYPEOFCONNECTORS_CONDITIONAL) {
$transitionRule = $connector->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_CONNECTORS_TRANSITIONRULE));
$elementInputs[] = self::getConditionElement($transitionRule);
$elementInputs = array_merge($elementInputs, self::nextActivityElements($connector, 'then'));
$elementInputs = array_merge($elementInputs, self::nextActivityElements($connector, 'else'));
} else {
if ($connectorType->getUri() == INSTANCE_TYPEOFCONNECTORS_PARALLEL) {
$elementInputs = self::nextActivityElements($connector, 'parallel', false, false, 'Checkbox');
} else {
if ($connectorType->getUri() == INSTANCE_TYPEOFCONNECTORS_JOIN) {
$elementInputs = self::nextActivityElements($connector, 'join', true, false, 'Combobox');
} else {
throw new Exception("the selected type of connector {$connectorType->getLabel()} is not supported");
}
}
}
}
foreach ($elementInputs as $elementInput) {
$myForm->addElement($elementInput);
}
//notification system
$myForm->addElement(tao_helpers_form_FormFactory::getElement('notify_set', 'Hidden'));
$notifyMsgProperty = new core_kernel_classes_Property(PROPERTY_CONNECTORS_NOTIFICATION_MESSAGE);
$notifyMsgElt = tao_helpers_form_GenerisFormFactory::elementMap($notifyMsgProperty);
$notifyMsgElt->setValue((string) $connector->getOnePropertyValue($notifyMsgProperty));
$myForm->addElement($notifyMsgElt);
$notifyProperty = new core_kernel_classes_Property(PROPERTY_CONNECTORS_NOTIFY);
$notifyElt = tao_helpers_form_GenerisFormFactory::elementMap($notifyProperty);
$notifyElt->addAttribute('class', 'notify-element');
$notifyElt->setValues(tao_helpers_Uri::encodeArray($connector->getPropertyValues($notifyProperty)));
$myForm->addElement($notifyElt);
$notifyUserProperty = new core_kernel_classes_Property(PROPERTY_CONNECTORS_USER_NOTIFIED);
$notifyUserElt = tao_helpers_form_GenerisFormFactory::elementMap($notifyUserProperty);
$notifyUserElt->addAttribute('class', 'notify-user');
//.........这里部分代码省略.........
示例12: getRepeatedDeliveriesData
/**
* Get repeated deliveries data
* @param \core_kernel_classes_Resource $delivery
* @return array
*/
public function getRepeatedDeliveriesData(\core_kernel_classes_Resource $delivery)
{
$result = array();
$repeatedDeliveryClass = new \core_kernel_classes_Class(self::CLASS_URI);
$repeatedDeliveries = $repeatedDeliveryClass->searchInstances(array(self::PROPERTY_REPETITION_OF => $delivery->getUri()), array('like' => false));
foreach ($repeatedDeliveries as $repeatedDelivery) {
$repetitionNumber = (string) $repeatedDelivery->getUniquePropertyValue(new \core_kernel_classes_Property(self::PROPERTY_NUMBER_OF_REPETITION));
$result[$repetitionNumber] = array();
//groups
$groups = array_keys($this->getServiceManager()->get('taoDeliverySchedule/DeliveryGroupsService')->getGroups($repeatedDelivery));
$result[$repetitionNumber]['groups'] = \tao_helpers_Uri::encodeArray($groups);
//Test takers
$result[$repetitionNumber] = array_merge($result[$repetitionNumber], DeliveryTestTakersService::singleton()->getDeliveryTestTakers($repeatedDelivery));
}
return $result;
}