本文整理汇总了PHP中ilPropertyFormGUI::getItemByPostVar方法的典型用法代码示例。如果您正苦于以下问题:PHP ilPropertyFormGUI::getItemByPostVar方法的具体用法?PHP ilPropertyFormGUI::getItemByPostVar怎么用?PHP ilPropertyFormGUI::getItemByPostVar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilPropertyFormGUI
的用法示例。
在下文中一共展示了ilPropertyFormGUI::getItemByPostVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setFormValues
public function setFormValues(ilPropertyFormGUI $form)
{
$form->getItemByPostVar('registration_type')->setValue($this->getCurrentObject()->getRegistrationType());
$form->getItemByPostVar('registration_membership_limited')->setChecked($this->getCurrentObject()->isRegistrationUserLimitEnabled());
$form->getItemByPostVar('registration_max_members')->setValue($this->getCurrentObject()->getRegistrationMaxUsers());
$form->getItemByPostVar('waiting_list')->setChecked($this->getCurrentObject()->isRegistrationWaitingListEnabled());
}
示例2: initPluginSettings
protected function initPluginSettings()
{
$n = new ilNonEditableValueGUI($this->getPluginHookObject()->txt('info_token_expires'));
$n->setValue(date(DATE_ISO8601, $this->getPluginObject()->getValidThrough()));
$this->form->addItem($n);
$this->form->getItemByPostVar('root_folder')->setDisabled(true);
}
示例3: initSpecificFormProperties
/**
* initialises a given form object's specific form properties
* relating to this question type
*
* (overwrites the method from ilAssMultiOptionQuestionFeedback, because of individual setting)
*
* @access public
* @param ilPropertyFormGUI $form
*/
public function initSpecificFormProperties(ilPropertyFormGUI $form)
{
if (!$this->questionOBJ->getSelfAssessmentEditingMode()) {
$form->getItemByPostVar('feedback_setting')->setValue($this->questionOBJ->getSpecificFeedbackSetting());
foreach ($this->getAnswerOptionsByAnswerIndex() as $index => $answer) {
if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
$value = $this->getPageObjectNonEditableValueHTML($this->getSpecificAnswerFeedbackPageObjectType(), $this->getSpecificAnswerFeedbackPageObjectId($this->questionOBJ->getId(), $index));
} else {
$value = $this->questionOBJ->prepareTextareaOutput($this->getSpecificAnswerFeedbackContent($this->questionOBJ->getId(), $index));
}
$form->getItemByPostVar("feedback_answer_{$index}")->setValue($value);
}
}
}
示例4: checkInput
/**
* Check input of form
*
* @param $a_mode 'create' | 'update'
*
* @return bool
*/
protected function checkInput($a_mode)
{
global $lng;
$return = $this->form->checkInput();
// Additional check for text fields: The length property should be max 200 if the textarea option is not set
if ($this->form->getInput('datatype') == ilDataCollectionDatatype::INPUTFORMAT_TEXT && (int) $this->form->getInput('prop_' . ilDataCollectionField::PROPERTYID_LENGTH) > 200 && !$this->form->getInput('prop_' . ilDataCollectionField::PROPERTYID_TEXTAREA)) {
$inputObj = $this->form->getItemByPostVar('prop_' . ilDataCollectionField::PROPERTYID_LENGTH);
$inputObj->setAlert($lng->txt("form_msg_value_too_high"));
$return = false;
}
// Don't allow multiple fields with the same title in this table
if ($a_mode == 'create') {
if ($title = $this->form->getInput('title')) {
if (ilDataCollectionTable::_hasFieldByTitle($title, $this->table_id)) {
$inputObj = $this->form->getItemByPostVar('title');
$inputObj->setAlert($lng->txt("dcl_field_title_unique"));
$return = false;
}
}
}
if (!$return) {
ilUtil::sendFailure($lng->txt("form_input_not_valid"));
}
return $return;
}
示例5: applyValues
/**
* Applies given values to field in given form.
* @param ilPropertyFormGUI $form
* @param array $values
*/
public static function applyValues(ilPropertyFormGUI $form, array $values)
{
foreach ($values as $key => $value) {
$field = $form->getItemByPostVar($key);
if (!$field) {
continue;
}
switch (strtolower(get_class($field))) {
case 'ilcheckboxinputgui':
if ($value) {
$field->setChecked(true);
}
break;
default:
$field->setValue($value);
}
}
}
示例6: saveCategory
/**
*
*/
protected function saveCategory()
{
if (!$this->isCRUDContext()) {
$this->{$this->getDefaultCommand()}();
return;
}
$category = $this->getCategoryById((int) $_GET['category_id']);
$this->initUnitCategoryForm($category);
if ($this->unit_cat_form->checkInput()) {
try {
$category->setCategory($this->unit_cat_form->getInput('category_name'));
$this->repository->saveCategory($category);
ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
$this->{$this->getUnitCategoryOverviewCommand()}();
return;
} catch (ilException $e) {
$this->unit_cat_form->getItemByPostVar('category_name')->setAlert($this->lng->txt($e->getMessage()));
ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
}
}
$this->unit_cat_form->setValuesByPost();
$this->tpl->setContent($this->unit_cat_form->getHtml());
}
示例7: save
/**
* Save record
*/
public function save()
{
$this->initForm();
if ($this->form->checkInput()) {
$record_obj = ilDataCollectionCache::getRecordCache($this->record_id);
$date_obj = new ilDateTime(time(), IL_CAL_UNIX);
$record_obj->setTableId($this->table_id);
$record_obj->setLastUpdate($date_obj->get(IL_CAL_DATETIME));
$record_obj->setLastEditBy($this->user->getId());
$create_mode = false;
if (ilObjDataCollection::_hasWriteAccess($this->parent_obj->ref_id)) {
$all_fields = $this->table->getRecordFields();
} else {
$all_fields = $this->table->getEditableFields();
}
$fail = "";
//Check if we can create this record.
foreach ($all_fields as $field) {
try {
$value = $this->form->getInput("field_" . $field->getId());
$field->checkValidity($value, $this->record_id);
} catch (ilDataCollectionInputException $e) {
$fail .= $field->getTitle() . ": " . $e . "<br>";
}
}
if ($fail) {
$this->sendFailure($fail);
return;
}
if (!isset($this->record_id)) {
if (!$this->table->hasPermissionToAddRecord($this->parent_obj->ref_id)) {
$this->accessDenied();
return;
}
$record_obj->setOwner($this->user->getId());
$record_obj->setCreateDate($date_obj->get(IL_CAL_DATETIME));
$record_obj->setTableId($this->table_id);
$record_obj->doCreate();
$this->record_id = $record_obj->getId();
$create_mode = true;
} else {
if (!$record_obj->hasPermissionToEdit($this->parent_obj->ref_id)) {
$this->accessDenied();
return;
}
}
//edit values, they are valid we already checked them above
foreach ($all_fields as $field) {
$value = $this->form->getInput("field_" . $field->getId());
//deletion flag on MOB inputs.
if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_MOB && $this->form->getItemByPostVar("field_" . $field->getId())->getDeletionFlag()) {
$value = -1;
}
$record_obj->setRecordFieldValue($field->getId(), $value);
}
// Do we need to set a new owner for this record?
if (!$create_mode) {
$owner_id = ilObjUser::_lookupId($_POST['field_owner']);
if (!$owner_id) {
$this->sendFailure($this->lng->txt('user_not_known'));
return;
}
$record_obj->setOwner($owner_id);
}
if ($create_mode) {
ilObjDataCollection::sendNotification("new_record", $this->table_id, $record_obj->getId());
}
$record_obj->doUpdate();
$this->ctrl->setParameter($this, "table_id", $this->table_id);
$this->ctrl->setParameter($this, "record_id", $this->record_id);
if (!$this->ctrl->isAsynch()) {
ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
}
$this->checkAndPerformRedirect();
if ($this->ctrl->isAsynch()) {
// If ajax request, return the form in edit mode again
$this->record_id = $record_obj->getId();
$this->initForm();
$this->setFormValues();
echo $this->tpl->getMessageHTML($this->lng->txt('msg_obj_modified'), 'success') . $this->form->getHTML();
exit;
} else {
$this->ctrl->redirectByClass("ildatacollectionrecordlistgui", "listRecords");
}
} else {
// Form not valid...
$this->form->setValuesByPost();
if ($this->ctrl->isAsynch()) {
echo $this->form->getHTML();
exit;
} else {
$this->tpl->setContent($this->form->getHTML());
}
}
}
示例8: formPropertyExists
protected function formPropertyExists(ilPropertyFormGUI $form, $propertyId)
{
return $form->getItemByPostVar($propertyId) instanceof ilFormPropertyGUI;
}
示例9: updateCustom
public function updateCustom(ilPropertyFormGUI $a_form)
{
$this->object->setOnline($a_form->getInput("online"));
// activation
if ($a_form->getInput("access_type") == ilObjectActivation::TIMINGS_ACTIVATION) {
$this->object->setActivationLimited(true);
$this->object->setActivationVisibility($a_form->getInput("access_visiblity"));
$period = $a_form->getItemByPostVar("access_period");
$this->object->setActivationStartDate($period->getStart()->get(IL_CAL_UNIX));
$this->object->setActivationEndDate($period->getEnd()->get(IL_CAL_UNIX));
} else {
$this->object->setActivationLimited(false);
}
parent::updateCustom($a_form);
}
示例10: validateForm
/**
* Validate field form
*
* @param ilPropertyFormGUI $form
* @param ilUserDefinedFields $user_field_definitions
* @param array $access
* @param array $a_field_permissions
* @return bool
*/
protected function validateForm($form, $user_field_definitions, array &$access, array $a_field_permissions = null)
{
global $lng;
if ($form->checkInput()) {
$valid = true;
$incoming = (array) $form->getInput("access");
if ($a_field_permissions) {
$perm_map = self::getAccessPermissions();
}
$access = array();
foreach (array_keys($this->getAccessOptions()) as $id) {
$access[$id] = in_array($id, $incoming);
// disabled fields
if ($a_field_permissions && !$a_field_permissions[ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS][$perm_map[$id]]) {
$access[$id] = $this->field_definition[$id];
}
}
if ($access['required'] && !$access['visib_reg']) {
$this->confirm_change = true;
$form->getItemByPostVar("access")->setAlert($lng->txt('udf_required_requires_visib_reg'));
$valid = false;
}
if (!$this->field_id && $user_field_definitions->nameExists($form->getInput("name"))) {
$form->getItemByPostVar("name")->setAlert($lng->txt('udf_name_already_exists'));
$valid = false;
}
if ($form->getInput("field_type") == UDF_TYPE_SELECT && (!$a_field_permissions || $a_field_permissions[ilUDFPermissionHelper::ACTION_FIELD_EDIT_PROPERTY][ilUDFPermissionHelper::SUBACTION_FIELD_PROPERTIES])) {
$user_field_definitions->setFieldValues($form->getInput("selvalue"));
if ($error = $user_field_definitions->validateValues()) {
switch ($error) {
case UDF_DUPLICATE_VALUES:
$form->getItemByPostVar("selvalue")->setAlert($lng->txt('udf_duplicate_entries'));
$valid = false;
break;
}
}
}
if (!$valid) {
ilUtil::sendFailure($lng->txt("form_input_not_valid"));
}
return $valid;
}
return false;
}
示例11: writeAnswerSpecificPostData
/**
* @param ilPropertyFormGUI $form
*/
public function writeAnswerSpecificPostData(ilPropertyFormGUI $form)
{
$answers = $form->getItemByPostVar('kprim_answers')->getValues();
$files = $form->getItemByPostVar('kprim_answers')->getFiles();
$this->object->handleFileUploads($answers, $files);
$this->object->setAnswers($answers);
}
示例12: updateCustom
protected function updateCustom(ilPropertyFormGUI $a_form)
{
$this->object->setViewResults($a_form->getInput("results"));
$this->object->setOnline($a_form->getInput("online"));
$this->object->setSortResultByVotes($a_form->getInput("sort"));
$this->object->setShowComments($a_form->getInput("comment"));
$this->object->setShowResultsAs($a_form->getInput("show_results_as"));
include_once "Services/Object/classes/class.ilObjectActivation.php";
if ($a_form->getInput("access_type")) {
$this->object->setAccessType(ilObjectActivation::TIMINGS_ACTIVATION);
$period = $a_form->getItemByPostVar("access_period");
$this->object->setAccessBegin($period->getStart()->get(IL_CAL_UNIX));
$this->object->setAccessEnd($period->getEnd()->get(IL_CAL_UNIX));
} else {
$this->object->setAccessType(ilObjectActivation::TIMINGS_DEACTIVATED);
}
if ($a_form->getInput("period")) {
$this->object->setVotingPeriod(1);
$period = $a_form->getItemByPostVar("voting_period");
$this->object->setVotingPeriodBegin($period->getStart()->get(IL_CAL_UNIX));
$this->object->setVotingPeriodEnd($period->getEnd()->get(IL_CAL_UNIX));
} else {
$this->object->setVotingPeriod(0);
}
}
示例13: validateForm
/**
* Validate field form
*
* @param ilPropertyFormGUI $form
* @param ilUserDefinedFields $user_field_definitions
* @param array $access
* @return bool
*/
protected function validateForm($form, $user_field_definitions, array &$access)
{
global $lng;
if ($form->checkInput()) {
$valid = true;
$incoming = (array) $form->getInput("access");
$access = array();
foreach (array_keys($this->getAccessOptions()) as $id) {
$access[$id] = in_array($id, $incoming);
}
if ($access['required'] && !$access['visib_reg']) {
$this->confirm_change = true;
$form->getItemByPostVar("access")->setAlert($lng->txt('udf_required_requires_visib_reg'));
$valid = false;
}
if (!$this->field_id && $user_field_definitions->nameExists($form->getInput("name"))) {
$form->getItemByPostVar("name")->setAlert($lng->txt('udf_name_already_exists'));
$valid = false;
}
if ($form->getInput("field_type") == UDF_TYPE_SELECT) {
$user_field_definitions->setFieldValues($form->getInput("selvalue"));
if ($error = $user_field_definitions->validateValues()) {
switch ($error) {
case UDF_DUPLICATE_VALUES:
$form->getItemByPostVar("selvalue")->setAlert($lng->txt('udf_duplicate_entries'));
$valid = false;
break;
}
}
}
if (!$valid) {
ilUtil::sendFailure($lng->txt("form_input_not_valid"));
}
return $valid;
}
return false;
}
示例14: isValidTermAndDefinitionAmount
/**
* for mode 1:1 terms count must not be less than definitions count
* for mode n:n this limitation is cancelled
*
* @param ilPropertyFormGUI $form
* @return bool
*/
private function isValidTermAndDefinitionAmount(ilPropertyFormGUI $form)
{
$matchingMode = $form->getItemByPostVar('matching_mode')->getValue();
if ($matchingMode == assMatchingQuestion::MATCHING_MODE_N_ON_N) {
return true;
}
$numTerms = count($form->getItemByPostVar('terms')->getValues());
$numDefinitions = count($form->getItemByPostVar('definitions')->getValues());
if ($numTerms >= $numDefinitions) {
return true;
}
return false;
}
示例15: validateForm
/**
* {@inheritdoc}
*/
public function validateForm(ilPropertyFormGUI $form)
{
/**
* @var $lng ilLanguage
*/
global $lng;
if (!strlen(trim($this->getClientSalt())) || !preg_match('/^.{' . self::MIN_SALT_SIZE . ',}$/', $this->getClientSalt())) {
$form->getItemByPostVar('bcrypt_salt')->setAlert($lng->txt('passwd_encoder_bcrypt_client_salt_invalid'));
return false;
}
return true;
}