/** * Constructor. * @param $form Form the associated form * @param $field string the name of the associated field * @param $type string the type of check, either "required" or "optional" * @param $message string the error message for validation failures (i18n key) * @param $dateFormat int the ValidatorDate date format to allow * @param $dateScope string the minimum resolution of a date to allow * @param $dateScope string the maximum resolution of a date to allow */ function __construct(&$form, $field, $type, $message, $dateFormat = DATE_FORMAT_ISO, $dateScopeMin = VALIDATOR_DATE_SCOPE_YEAR, $dateScopeMax = VALIDATOR_DATE_SCOPE_DAY) { $validator = new ValidatorDate($dateFormat); $this->_scopeMin = $dateScopeMin; $this->_scopeMax = $dateScopeMax; parent::__construct($form, $field, $type, $message, $validator); }
/** * Constructor. * The user function is passed the form data as its first argument and $additionalArguments, if set, as the remaining arguments. This function must return a boolean value. * @param $form Form the associated form * @param $field string the name of the associated field * @param $type string the type of check, either "required" or "optional" * @param $message string the error message for validation failures (i18n key) * @param $userFunction callable function the user function to use for validation * @param $additionalArguments array optional, a list of additional arguments to pass to $userFunction * @param $complementReturn boolean optional, complement the value returned by $userFunction */ function __construct(&$form, $field, $type, $message, $userFunction, $additionalArguments = array(), $complementReturn = false) { parent::__construct($form, $field, $type, $message); $this->_userFunction = $userFunction; $this->_additionalArguments = $additionalArguments; $this->_complementReturn = $complementReturn; }
/** * Constructor. * @param $form Form the associated form * @param $field string the name of the associated field * @param $type string the type of check, either "required" or "optional" * @param $message string the error message for validation failures (i18n key) * @param $validator Validator the validator used to validate this form field (optional) * @param $requiredLocale The name of the required locale, i.e. en_US */ function __construct(&$form, $field, $type, $message, $requiredLocale = null, $validator = null) { parent::__construct($form, $field, $type, $message, $validator); if ($requiredLocale === null) { $requiredLocale = AppLocale::getPrimaryLocale(); } $this->_requiredLocale = $requiredLocale; }
/** * Builds a form containing form items based on a given parameter * @param int form_type 1 = user_info * @param user array * @param string form name * @param method * @param action */ public function UserForm($form_type, $user, $form_name, $method = 'post', $action = null) { parent::__construct($form_name, $method, $action); $this->form_type = $form_type; if (isset($user)) { $this->user_info = $user; } if (isset($result_object)) { $this->result_object = $result_object; } if ($this->form_type == self::TYPE_USER_INFO) { $this->build_user_info_form(); } elseif ($this->form_type == self::TYPE_SIMPLE_SEARCH) { $this->build_simple_search(); } $this->setDefaults(); }
/** * Builds a form containing form items based on a given parameter * @param int form_type 1=import, 2=export * @param obj cat_obj the category object * @param obj res_obj the result object * @param string form name * @param method * @param action */ public function DataForm($form_type, $form_name, $method = 'post', $action = null, $target = '', $locked_status) { parent::__construct($form_name, $method, $action, $target); $this->form_type = $form_type; if ($this->form_type == self::TYPE_IMPORT) { $this->build_import_form(); } elseif ($this->form_type == self::TYPE_EXPORT) { if ($locked_status == 0) { $this->build_export_form_option(false); } else { $this->build_export_form(); } } elseif ($this->form_type == self::TYPE_EXPORT_PDF) { $this->build_pdf_export_form(); } $this->setDefaults(); }
/** * Builds a form containing form items based on a given parameter * @param int form_type 1=add, 2=edit,3=move,4=browse * @param obj cat_obj the category object * @param string form name * @param method method */ public function CatForm($form_type, $category_object, $form_name, $method = 'post', $action = null) { parent::__construct($form_name, $method, $action); $this->form_type = $form_type; if (isset($category_object)) { $this->category_object = $category_object; } if ($this->form_type == self::TYPE_EDIT) { $this->build_editing_form(); } elseif ($this->form_type == self::TYPE_ADD) { $this->build_add_form(); } elseif ($this->form_type == self::TYPE_MOVE) { $this->build_move_form(); } elseif ($this->form_type == self::TYPE_SELECT_COURSE) { $this->build_select_course_form(); } $this->setDefaults(); }
/** * Builds a form containing form items based on a given parameter * @param int form_type 1=choose link * @param obj cat_obj the category object * @param string form name * @param method * @param action */ public function LinkForm($form_type, $category_object, $link_object, $form_name, $method = 'post', $action = null, $extra = null) { parent::__construct($form_name, $method, $action); if (isset($category_object)) { $this->category_object = $category_object; } else { if (isset($link_object)) { $this->link_object = $link_object; } } if (isset($extra)) { $this->extra = $extra; } if ($form_type == self::TYPE_CREATE) { $this->build_create(); } elseif ($form_type == self::TYPE_MOVE) { $this->build_move(); } }
/** * Builds a form containing form items based on a given parameter * @param int form_type 1=add, 2=edit,3=move,4=result_add * @param obj cat_obj the category object * @param obj res_obj the result object * @param string form name * @param method * @param action */ public function __construct($form_type, $evaluation_object, $result_object, $form_name, $method = 'post', $action = null, $extra1 = null, $extra2 = null) { parent::__construct($form_name, $method, $action); if (isset($evaluation_object)) { $this->evaluation_object = $evaluation_object; } if (isset($result_object)) { $this->result_object = $result_object; } if (isset($extra1)) { $this->extra = $extra1; } switch ($form_type) { case self::TYPE_EDIT: $this->build_editing_form(); break; case self::TYPE_ADD: $this->build_add_form(); break; case self::TYPE_MOVE: $this->build_editing_form(); break; case self::TYPE_RESULT_ADD: $this->build_result_add_form(); break; case self::TYPE_RESULT_EDIT: $this->build_result_edit_form(); break; case self::TYPE_ALL_RESULTS_EDIT: $this->build_all_results_edit_form(); break; case self::TYPE_ADD_USERS_TO_EVAL: $this->build_add_user_to_eval(); break; } $this->setDefaults(); }
function __construct($form_name = 'category', $method = 'post', $action = '', $target = '', $attributes = null, $track_submit = true) { parent::__construct($form_name, $method, $action, $target, $attributes, $track_submit); }
public function __construct() { parent::__construct(); $this->db_handler = new Database(); }
/** * Constructor. * @param $form Form the associated form * @param $field string the name of the associated field * @param $type string the type of check, either "required" or "optional" * @param $message string the error message for validation failures (i18n key) * @param $regExp string the regular expression (PCRE form) */ function __construct(&$form, $field, $type, $message, $regExp) { import('lib.pkp.classes.validation.ValidatorRegExp'); $validator = new ValidatorRegExp($regExp); parent::__construct($form, $field, $type, $message, $validator); }
/** * Constructor. * @param $form object * @param $userIp string IP address of user request * @param $message string Key of message to display on mismatch */ function __construct(&$form, $userIp, $message) { parent::__construct($form, RECAPTCHA_RESPONSE_FIELD, FORM_VALIDATOR_REQUIRED_VALUE, $message); $this->_userIp = $userIp; }
/** * @param $form_name * @param null $action */ public function __construct($form_name, $action = null) { parent::__construct($form_name, 'post', $action); $displayscore = ScoreDisplay::instance(); $customdisplays = $displayscore->get_custom_score_display_settings(); $nr_items = count($customdisplays) != '0' ? count($customdisplays) : '1'; $this->setDefaults(array('scorecolpercent' => $displayscore->get_color_split_value())); $this->addElement('hidden', 'maxvalue', '100'); $this->addElement('hidden', 'minvalue', '0'); $counter = 1; //setting the default values if (is_array($customdisplays)) { foreach ($customdisplays as $customdisplay) { $this->setDefaults(array('endscore[' . $counter . ']' => $customdisplay['score'], 'displaytext[' . $counter . ']' => $customdisplay['display'])); $counter++; } } $scorecol = array(); //settings for the colored score $this->addElement('header', get_lang('ScoreEdit')); if ($displayscore->is_coloring_enabled()) { $this->addElement('html', '<b>' . get_lang('ScoreColor') . '</b>'); $this->addElement('text', 'scorecolpercent', array(get_lang('Below'), get_lang('WillColorRed'), '%'), array('size' => 5, 'maxlength' => 5, 'input-size' => 2)); if (api_get_setting('gradebook.teachers_can_change_score_settings') != 'true') { $this->freeze('scorecolpercent'); } $this->addRule('scorecolpercent', get_lang('OnlyNumbers'), 'numeric'); $this->addRule(array('scorecolpercent', 'maxvalue'), get_lang('Over100'), 'compare', '<='); $this->addRule(array('scorecolpercent', 'minvalue'), get_lang('UnderMin'), 'compare', '>'); } //Settings for the scoring system if ($displayscore->is_custom()) { $this->addElement('html', '<br /><b>' . get_lang('ScoringSystem') . '</b>'); $this->addElement('static', null, null, get_lang('ScoreInfo')); $this->setDefaults(array('beginscore' => '0')); $this->addElement('text', 'beginscore', array(get_lang('Between'), null, '%'), array('size' => 5, 'maxlength' => 5, 'disabled' => 'disabled', 'input-size' => 2)); for ($counter = 1; $counter <= 20; $counter++) { $renderer =& $this->defaultRenderer(); $elementTemplateTwoLabel = '<div id=' . $counter . ' style="display: ' . ($counter <= $nr_items ? 'inline' : 'none') . ';"> <!-- BEGIN required --><span class="form_required">*</span> <!-- END required --> <label class="control-label">{label}</label> <div class="form-group"> <label class="col-sm-2 control-label"> </label> <div class="col-sm-1"> <!-- BEGIN error --><span class="form_error">{error}</span><br /> <!-- END error --> <b>' . get_lang('And') . '</b> </div> <div class="col-sm-2"> {element} </div> <div class="col-sm-1"> = </div> '; $elementTemplateTwoLabel2 = ' <div class="col-sm-2"> <!-- BEGIN error --><span class="form_error">{error}</span> <!-- END error --> {element} </div> <div class="col-sm-1"> <a href="javascript:plusItem(' . ($counter + 1) . ')"> <img style="display: ' . ($counter >= $nr_items ? 'inline' : 'none') . ';" id="plus-' . ($counter + 1) . '" src="' . Display::returnIconPath('add.png') . '" alt="' . get_lang('Add') . '" title="' . get_lang('Add') . '"></a> <a href="javascript:minItem(' . $counter . ')"> <img style="display: ' . ($counter >= $nr_items && $counter != 1 ? 'inline' : 'none') . ';" id="min-' . $counter . '" src="' . Display::returnIconPath('delete.png') . '" alt="' . get_lang('Delete') . '" title="' . get_lang('Delete') . '"></a> </div> </div> </div>'; $scorebetw = array(); $this->addElement('text', 'endscore[' . $counter . ']', null, array('size' => 5, 'maxlength' => 5, 'id' => 'txta-' . $counter, 'input-size' => 2)); $this->addElement('text', 'displaytext[' . $counter . ']', null, array('size' => 40, 'maxlength' => 40, 'id' => 'txtb-' . $counter)); $renderer->setElementTemplate($elementTemplateTwoLabel, 'endscore[' . $counter . ']'); $renderer->setElementTemplate($elementTemplateTwoLabel2, 'displaytext[' . $counter . ']'); $this->addRule('endscore[' . $counter . ']', get_lang('OnlyNumbers'), 'numeric'); $this->addRule(array('endscore[' . $counter . ']', 'maxvalue'), get_lang('Over100'), 'compare', '<='); $this->addRule(array('endscore[' . $counter . ']', 'minvalue'), get_lang('UnderMin'), 'compare', '>'); } } if ($displayscore->is_custom()) { $this->addButtonSave(get_lang('Ok')); } }
/** * Constructor. * @param $form Form the associated form * @param $field string the name of the associated field * @param $type string the type of check, either "required" or "optional" * @param $message string the error message for validation failures (i18n key) * @param $fields array all subfields for each item in the array, i.e. name[][foo]. If empty it is assumed that name[] is a data field */ function __construct(&$form, $field, $type, $message, $fields = array()) { parent::__construct($form, $field, $type, $message); $this->_fields = $fields; $this->_errorFields = array(); }
/** * Constructor. * @param $form Form * @param $message string the locale key to use (optional) */ function __construct(&$form, $message = 'form.postRequired') { parent::__construct($form, 'dummy', FORM_VALIDATOR_REQUIRED_VALUE, $message); }
/** * Constructor. * @param $form Form the associated form * @param $field string the name of the associated field * @param $type string the type of check, either "required" or "optional" * @param $message string the error message for validation failures (i18n key) * @param $acceptedValues array all possible accepted values */ function __construct(&$form, $field, $type, $message, $acceptedValues) { parent::__construct($form, $field, $type, $message); $this->_acceptedValues = $acceptedValues; }
/** * Constructor * To add link, define category_object and link_type * To edit link, define link_object */ function LinkAddEditForm($form_type, $category_object, $link_type, $link_object, $form_name, $action = null) { parent::__construct($form_name, 'post', $action); // set or create link object if (isset($link_object)) { $link = $link_object; } elseif (isset($link_type) && isset($category_object)) { $link = LinkFactory::create($link_type); $link->set_course_code(api_get_course_id()); } else { die('LinkAddEditForm error: define link_type/category_object or link_object'); } $defaults = array(); $this->addElement('hidden', 'zero', 0); if (!empty($_GET['editlink'])) { $this->addElement('header', '', get_lang('EditLink')); } // ELEMENT: name if ($form_type == self::TYPE_ADD || $link->is_allowed_to_change_name()) { if ($link->needs_name_and_description()) { $this->add_textfield('name', get_lang('Name'), true, array('size' => '40', 'maxlength' => '40')); } else { $select = $this->addElement('select', 'select_link', get_lang('ChooseItem')); foreach ($link->get_all_links() as $newlink) { $select->addoption($newlink[1], $newlink[0]); } } } else { $this->addElement('label', get_lang('Name'), '<span class="freeze">' . $link->get_name() . ' [' . $link->get_type_name() . ']</span>'); $this->addElement('hidden', 'name_link', $link->get_name(), array('id' => 'name_link')); } if (count($category_object) == 1) { $this->addElement('hidden', 'select_gradebook', $category_object[0]->get_id()); } else { $select_gradebook = $this->addElement('select', 'select_gradebook', get_lang('SelectGradebook'), array(), array('id' => 'hide_category_id')); $this->addRule('select_gradebook', get_lang('ThisFieldIsRequired'), 'nonzero'); $default_weight = 0; if (!empty($category_object)) { foreach ($category_object as $my_cat) { if ($my_cat->get_course_code() == api_get_course_id()) { $grade_model_id = $my_cat->get_grade_model_id(); if (empty($grade_model_id)) { if ($my_cat->get_parent_id() == 0) { $default_weight = $my_cat->get_weight(); $select_gradebook->addoption(get_lang('Default'), $my_cat->get_id()); } else { $select_gradebook->addoption($my_cat->get_name(), $my_cat->get_id()); } } else { $select_gradebook->addoption(get_lang('Select'), 0); } if ($link->get_category_id() == $my_cat->get_id()) { $default_weight = $my_cat->get_weight(); } } } } } $this->add_textfield('weight_mask', array(get_lang('Weight'), null, ' [0 .. ' . $category_object[0]->get_weight() . '] '), true, array('size' => '4', 'maxlength' => '5', 'class' => 'span1')); $this->addElement('hidden', 'weight'); /* // ELEMENT: weight $this->add_textfield('weight', array(get_lang('Weight'), null, '/ <span id="max_weight">'.$default_weight.'</span>'), true, array ( 'size' => '4', 'maxlength' => '5', 'class' => 'span1' ));*/ $this->addRule('weight_mask', get_lang('OnlyNumbers'), 'numeric'); $this->addRule(array('weight_mask', 'zero'), get_lang('NegativeValue'), 'compare', '>='); if ($form_type == self::TYPE_EDIT) { $parent_cat = Category::load($link->get_category_id()); if ($parent_cat[0]->get_parent_id() == 0) { $values['weight'] = $link->get_weight(); } else { $cat = Category::load($parent_cat[0]->get_parent_id()); //$global_weight = $cat[0]->get_weight(); //$values['weight'] = $link->get_weight()/$parent_cat[0]->get_weight()*$global_weight; //$weight = $parent_cat[0]->get_weight()* $link->get_weight() / $global_weight; //$values['weight'] = $weight; $values['weight'] = $link->get_weight(); } $defaults['weight_mask'] = $values['weight']; $defaults['select_gradebook'] = $link->get_category_id(); } // ELEMENT: max if ($link->needs_max()) { if ($form_type == self::TYPE_EDIT && $link->has_results()) { $this->add_textfield('max', get_lang('QualificationNumeric'), false, array('size' => '4', 'maxlength' => '5', 'disabled' => 'disabled')); } else { $this->add_textfield('max', get_lang('QualificationNumeric'), true, array('size' => '4', 'maxlength' => '5')); $this->addRule('max', get_lang('OnlyNumbers'), 'numeric'); $this->addRule(array('max', 'zero'), get_lang('NegativeValue'), 'compare', '>='); } if ($form_type == self::TYPE_EDIT) { $defaults['max'] = $link->get_max(); } } // ELEMENT: date //$this->add_datepicker('date',get_lang('Date')); //$defaults['date'] = ($form_type == self :: TYPE_EDIT ? $link->get_date() : time()); // ELEMENT: description if ($link->needs_name_and_description()) { $this->addElement('textarea', 'description', get_lang('Description'), array('rows' => '3', 'cols' => '34')); if ($form_type == self::TYPE_EDIT) { $defaults['description'] = $link->get_description(); } } // ELEMENT: visible $visible = $form_type == self::TYPE_EDIT && $link->is_visible() ? '1' : '0'; $this->addElement('checkbox', 'visible', null, get_lang('Visible'), $visible); if ($form_type == self::TYPE_EDIT) { $defaults['visible'] = $link->is_visible(); } // ELEMENT: add results if ($form_type == self::TYPE_ADD && $link->needs_results()) { $this->addElement('checkbox', 'addresult', get_lang('AddResult')); } // submit button if ($form_type == self::TYPE_ADD) { $this->addElement('style_submit_button', 'submit', get_lang('CreateLink'), 'class="save"'); } else { $this->addElement('style_submit_button', 'submit', get_lang('LinkMod'), 'class="save"'); } if ($form_type == self::TYPE_ADD) { $setting = api_get_setting('tool_visible_by_default_at_creation'); $visibility_default = 1; if (isset($setting['gradebook']) && $setting['gradebook'] == 'false') { $visibility_default = 0; } $defaults['visible'] = $visibility_default; } // set default values $this->setDefaults($defaults); }
/** * Constructor. * @param $form Form the associated form * @param $field string the name of the associated field * @param $type string the type of check, either "required" or "optional" * @param $message string the error message for validation failures (i18n key) */ function __construct(&$form, $field, $type, $message) { $validator = new ValidatorUrl(); parent::__construct($form, $field, $type, $message, $validator); array_push($form->cssValidation[$field], 'url'); }
/** * Constructor. * @param $form Form the associated form * @param $field string the name of the associated field * @param $message string the error message for validation failures (i18n key) */ function __construct(&$form, $field, $message) { parent::__construct($form, $field, FORM_VALIDATOR_OPTIONAL_VALUE, $message); }
/** * Constructor. * @param $form Form the associated form * @param $field string the name of the associated field * @param $type string the type of check, either "required" or "optional" * @param $message string the error message for validation failures (i18n key) * @param $symbolic string * @param $assocType int * @param $assocId int */ function __construct(&$form, $field, $type, $message, $symbolic, $assocType, $assocId) { import('lib.pkp.classes.validation.ValidatorControlledVocab'); $validator = new ValidatorControlledVocab($symbolic, $assocType, $assocId); parent::__construct($form, $field, $type, $message, $validator); }
/** * Constructor. * @param $form Form the associated form * @param $field string the name of the associated field * @param $type string the type of check, either "required" or "optional" * @param $message string the error message for validation failures (i18n key) * @param $comparator * @param $length */ function __construct(&$form, $field, $type, $message, $comparator, $length) { parent::__construct($form, $field, $type, $message); $this->_comparator = $comparator; $this->_length = $length; }
/** * Constructor. * @param $form Form the associated form * @param $field string the name of the associated field * @param $type string the type of check, either "required" or "optional" * @param $message string the error message for validation failures (i18n key) */ function __construct(&$form, $field, $type, $message) { import('lib.pkp.classes.validation.ValidatorRegExp'); parent::__construct($form, $field, $type, $message, new ValidatorRegExp('/^[a-z0-9]+([\\-_][a-z0-9]+)*$/')); }
/** * Constructor. * @param $form Form the associated form * @param $field string the name of the associated field * @param $type string the type of check, either "required" or "optional" * @param $message string the error message for validation failures (i18n key) */ function __construct($form, $field, $type, $message) { import('lib.pkp.classes.validation.ValidatorORCID'); $validator = new ValidatorORCID(); parent::__construct($form, $field, $type, $message, $validator); }
/** * Constructor. * @param $form Form the associated form * @param $field string the name of the associated field * @param $type string the type of check, either "required" or "optional" * @param $message string the error message for validation failures (i18n key) * @param $allowedSchemes array the allowed URI schemes */ function __construct(&$form, $field, $type, $message, $allowedSchemes = null) { import('lib.pkp.classes.validation.ValidatorUri'); $validator = new ValidatorUri($allowedSchemes); parent::__construct($form, $field, $type, $message, $validator); }
/** * Constructor. * @param $form Form * @param $message string the locale key to use (optional) */ function __construct(&$form, $message = 'form.csrfInvalid') { parent::__construct($form, 'dummy', FORM_VALIDATOR_REQUIRED_VALUE, $message); }
/** * Constructor. * @param $form Form the associated form * @param $field string the name of the associated field * @param $type string the type of check, either "required" or "optional" * @param $message string the error message for validation failures (i18n key) */ function __construct(&$form, $field, $type = 'optional', $message = 'email.invalid') { $validator = new ValidatorEmail(); parent::__construct($form, $field, $type, $message, $validator); array_push($form->cssValidation[$field], 'email'); }