PageRenderTime 60ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/user/profile/field/text/define.class.php

http://github.com/moodle/moodle
PHP | 71 lines | 26 code | 8 blank | 37 comment | 0 complexity | cce4887af29b2b6656be9ab374774b8f MD5 | raw file
Possible License(s): MIT, AGPL-3.0, MPL-2.0-no-copyleft-exception, LGPL-3.0, GPL-3.0, Apache-2.0, LGPL-2.1, BSD-3-Clause
  1. <?php
  2. // This file is part of Moodle - http://moodle.org/
  3. //
  4. // Moodle is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // Moodle is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * Text profile field definition.
  18. *
  19. * @package profilefield_text
  20. * @copyright 2007 onwards Shane Elliot {@link http://pukunui.com}
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22. */
  23. /**
  24. * Class profile_define_text
  25. *
  26. * @copyright 2007 onwards Shane Elliot {@link http://pukunui.com}
  27. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  28. */
  29. class profile_define_text extends profile_define_base {
  30. /**
  31. * Add elements for creating/editing a text profile field.
  32. * @param moodleform $form
  33. */
  34. public function define_form_specific($form) {
  35. // Default data.
  36. $form->addElement('text', 'defaultdata', get_string('profiledefaultdata', 'admin'), 'size="50"');
  37. $form->setType('defaultdata', PARAM_TEXT);
  38. // Param 1 for text type is the size of the field.
  39. $form->addElement('text', 'param1', get_string('profilefieldsize', 'admin'), 'size="6"');
  40. $form->setDefault('param1', 30);
  41. $form->setType('param1', PARAM_INT);
  42. // Param 2 for text type is the maxlength of the field.
  43. $form->addElement('text', 'param2', get_string('profilefieldmaxlength', 'admin'), 'size="6"');
  44. $form->setDefault('param2', 2048);
  45. $form->setType('param2', PARAM_INT);
  46. // Param 3 for text type detemines if this is a password field or not.
  47. $form->addElement('selectyesno', 'param3', get_string('profilefieldispassword', 'admin'));
  48. $form->setDefault('param3', 0); // Defaults to 'no'.
  49. $form->setType('param3', PARAM_INT);
  50. // Param 4 for text type contains a link.
  51. $form->addElement('text', 'param4', get_string('profilefieldlink', 'admin'));
  52. $form->setType('param4', PARAM_URL);
  53. $form->addHelpButton('param4', 'profilefieldlink', 'admin');
  54. // Param 5 for text type contains link target.
  55. $targetoptions = array( '' => get_string('linktargetnone', 'editor'),
  56. '_blank' => get_string('linktargetblank', 'editor'),
  57. '_self' => get_string('linktargetself', 'editor'),
  58. '_top' => get_string('linktargettop', 'editor')
  59. );
  60. $form->addElement('select', 'param5', get_string('profilefieldlinktarget', 'admin'), $targetoptions);
  61. $form->setType('param5', PARAM_RAW);
  62. }
  63. }