Exemple #1
0
 /**
  * Class constructor
  *
  * @param     string    $elementLabel   (optional)Label
  * @param     string    $text           (optional)Display text
  * @access    public
  * @return    void
  */
 public function __construct($elementName = null, $elementLabel = null, $text = null, $attributes = null)
 {
     parent::__construct($elementName, $elementLabel, $attributes);
     $this->_persistantFreeze = false;
     $this->_type = 'static';
     $this->_text = $text;
 }
Exemple #2
0
 /**
  * Constructor
  *
  * @param string $elementName (optional) name of the editor
  * @param string $elementLabel (optional) editor label
  * @param array $attributes (optional) Either a typical HTML attribute string
  *              or an associative array
  * @param array $options set of options to initalize filepicker
  */
 public function __construct($elementName = null, $elementLabel = null, $attributes = null, $options = null)
 {
     global $CFG, $PAGE;
     $options = (array) $options;
     foreach ($options as $name => $value) {
         if (array_key_exists($name, $this->_options)) {
             $this->_options[$name] = $value;
         }
     }
     if (!empty($options['maxbytes'])) {
         $this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $options['maxbytes']);
     }
     if (!$this->_options['context']) {
         // trying to set context to the current page context to make legacy files show in filepicker (e.g. forum post)
         if (!empty($PAGE->context->id)) {
             $this->_options['context'] = $PAGE->context;
         } else {
             $this->_options['context'] = context_system::instance();
         }
     }
     $this->_options['trusted'] = trusttext_trusted($this->_options['context']);
     parent::__construct($elementName, $elementLabel, $attributes);
     // Note: for some reason the code using this setting does not like bools.
     $this->_options['subdirs'] = (int) ($this->_options['subdirs'] == 1);
     editors_head_setup();
 }
Exemple #3
0
 /**
  * Class constructor
  *
  * @param     string    Input field name attribute
  * @param     mixed     Label(s) for a field
  * @param     mixed     Either a typical HTML attribute string or an associative array
  * @since     1.0
  * @access    public
  * @return    void
  */
 public function __construct($elementName = null, $elementLabel = null, $attributes = null)
 {
     $attributes['class'] = isset($attributes['class']) ? $attributes['class'] : 'form-control';
     parent::__construct($elementName, $elementLabel, $attributes);
     $this->_persistantFreeze = true;
     $this->_type = 'textarea';
 }
Exemple #4
0
 /**
  * Constructor
  *
  * @param string $elementname Element's name
  * @param mixed $elementlabel Label(s) for an element
  * @param array $options Options to control the element's display. Required - must contain the following options:
  *              'isupdate' - is this a new module or are we editing an existing one?
  *              'currentgrade' - the current grademax in the database for this gradeitem
  *              'hasgrades' - whether or not the grade_item has existing grade_grades
  *              'canrescale' - whether or not the activity supports rescaling grades
  * @param mixed $attributes Either a typical HTML attribute string or an associative array
  */
 public function __construct($elementname = null, $elementlabel = null, $options = array(), $attributes = null)
 {
     // TODO MDL-52313 Replace with the call to parent::__construct().
     HTML_QuickForm_element::__construct($elementname, $elementlabel, $attributes);
     $this->_persistantFreeze = true;
     $this->_appendName = true;
     $this->_type = 'modgrade';
     $this->isupdate = !empty($options['isupdate']);
     if (isset($options['currentgrade'])) {
         $this->currentgrade = $options['currentgrade'];
     }
     if (isset($options['currentgradetype'])) {
         $gradetype = $options['currentgradetype'];
         switch ($gradetype) {
             case GRADE_TYPE_NONE:
                 $this->currentgradetype = 'none';
                 break;
             case GRADE_TYPE_SCALE:
                 $this->currentgradetype = 'scale';
                 break;
             case GRADE_TYPE_VALUE:
                 $this->currentgradetype = 'point';
                 break;
         }
     }
     if (isset($options['currentscaleid'])) {
         $this->currentscaleid = $options['currentscaleid'];
     }
     $this->hasgrades = !empty($options['hasgrades']);
     $this->canrescale = !empty($options['canrescale']);
     $this->useratings = !empty($options['useratings']);
 }
Exemple #5
0
 /**
  * constructor
  *
  * @param string $elementName Element's name
  * @param mixed $elementLabel Label(s) for an element
  * @param array $options Options to control the element's display
  * @param mixed $attributes Either a typical HTML attribute string or an associative array
  */
 public function __construct($elementName = null, $elementLabel = null, $options = array(), $attributes = null)
 {
     // Get the calendar type used - see MDL-18375.
     $calendartype = \core_calendar\type_factory::get_calendar_instance();
     $this->_options = array('startyear' => $calendartype->get_min_year(), 'stopyear' => $calendartype->get_max_year(), 'defaulttime' => 0, 'timezone' => 99, 'step' => 5, 'optional' => false);
     // TODO MDL-52313 Replace with the call to parent::__construct().
     HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes);
     $this->_persistantFreeze = true;
     $this->_appendName = true;
     $this->_type = 'date_selector';
     // set the options, do not bother setting bogus ones
     if (is_array($options)) {
         foreach ($options as $name => $value) {
             if (isset($this->_options[$name])) {
                 if (is_array($value) && is_array($this->_options[$name])) {
                     $this->_options[$name] = @array_merge($this->_options[$name], $value);
                 } else {
                     $this->_options[$name] = $value;
                 }
             }
         }
     }
     // The YUI2 calendar only supports the gregorian calendar type.
     if ($calendartype->get_name() === 'gregorian') {
         form_init_date_js();
     }
 }
 /**
  * Class constructor
  *
  * @param    string  Button name
  * @param    string  Button content (HTML to add between <button></button> tags)
  * @param    mixed   Either a typical HTML attribute string or an associative array
  * @access   public
  */
 function __construct($elementName = null, $elementContent = null, $attributes = null)
 {
     parent::__construct($elementName, null, $attributes);
     $this->setContent($elementContent);
     $this->setPersistantFreeze(false);
     $this->_type = 'xbutton';
 }
 /**
  * Class constructor
  *
  * @param string $elementName Select name attribute
  * @param mixed $elementLabel Label(s) for the select
  * @param mixed $attributes Either a typical HTML attribute string or an associative array
  * @param mixed $options ignored, not used.
  */
 public function __construct($elementName = null, $elementLabel = null, $attributes = null, $options = null)
 {
     // TODO MDL-52313 Replace with the call to parent::__construct().
     HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes, null);
     $this->_type = 'selectyesno';
     $this->_persistantFreeze = true;
 }
Exemple #8
0
 /**
  * Constructor
  *
  * @param string $elementname Element's name
  * @param mixed $elementlabel Label(s) for an element
  * @param array $options Options to control the element's display. Not used.
  * @param mixed $attributes Either a typical HTML attribute string or an associative array
  */
 public function __construct($elementname = null, $elementlabel = null, $options = array(), $attributes = null)
 {
     // TODO MDL-52313 Replace with the call to parent::__construct().
     HTML_QuickForm_element::__construct($elementname, $elementlabel, $attributes);
     $this->_persistantFreeze = true;
     $this->_appendName = true;
     $this->_type = 'modgrade';
 }
Exemple #9
0
 /**
  * Class constructor
  * 
  * @param     string    $elementLabel   (optional)Link label
  * @param     string    $href           (optional)Link href
  * @param     string    $text           (optional)Link display text
  * @param     mixed     $attributes     (optional)Either a typical HTML attribute string 
  *                                      or an associative array
  * @since     1.0
  * @access    public
  * @return    void
  * @throws    
  */
 public function __construct($elementName = null, $elementLabel = null, $href = null, $text = null, $attributes = null)
 {
     // TODO MDL-52313 Replace with the call to parent::__construct().
     HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes);
     $this->_persistantFreeze = false;
     $this->_type = 'link';
     $this->setHref($href);
     $this->_text = $text;
 }
 /**
  * Class constructor
  *
  * @param     string    Select name attribute
  * @param     mixed     Label(s) for the select
  * @param     mixed     Data to be used to populate options
  * @param     mixed     Either a typical HTML attribute string or an associative array
  * @since     1.0
  * @access    public
  * @return    void
  */
 function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null)
 {
     parent::__construct($elementName, $elementLabel, $attributes);
     $this->_persistantFreeze = true;
     $this->_type = 'select';
     if (isset($options)) {
         $this->load($options);
     }
 }
 /**
  * Class constructor
  *
  * @param     string    Select name attribute
  * @param     mixed     Label(s) for the select (not used)
  * @param     mixed     Data to be used to populate options
  * @param     mixed     Either a typical HTML attribute string or an associative array (not used)
  * @since     1.0
  * @access    public
  * @return    void
  */
 public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null)
 {
     // TODO MDL-52313 Replace with the call to parent::__construct().
     HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes);
     $this->_persistantFreeze = true;
     $this->_type = 'hiddenselect';
     if (isset($options)) {
         $this->load($options);
     }
 }
Exemple #12
0
 /**
  * Class constructor
  *
  * @param string $elementName Select name attribute
  * @param mixed $elementLabel Label(s) for the select
  * @param array $optgrps Data to be used to populate options
  * @param mixed $attributes Either a typical HTML attribute string or an associative array
  * @param bool $showchoose add standard moodle "Choose..." option as first item
  */
 public function __construct($elementName = null, $elementLabel = null, $optgrps = null, $attributes = null, $showchoose = false)
 {
     $this->showchoose = $showchoose;
     parent::__construct($elementName, $elementLabel, $attributes);
     $this->_persistantFreeze = true;
     $this->_type = 'selectgroups';
     if (isset($optgrps)) {
         $this->loadArrayOptGroups($optgrps);
     }
 }
Exemple #13
0
 /**
  * Class constructor
  * 
  * @param     string    Input field name attribute
  * @param     mixed     Label(s) for a field
  * @param     string    Text to display near the radio
  * @param     string    Input field value
  * @param     mixed     Either a typical HTML attribute string or an associative array
  * @since     1.0
  * @access    public
  * @return    void
  */
 public function __construct($elementName = null, $elementLabel = null, $text = null, $value = null, $attributes = null)
 {
     // TODO MDL-52313 Replace with the call to parent::__construct().
     HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes);
     if (isset($value)) {
         $this->setValue($value);
     }
     $this->_persistantFreeze = true;
     $this->setType('radio');
     $this->_text = $text;
 }
Exemple #14
0
 /**
  * Class constructor
  *
  * @param     string    Input field name attribute
  * @param     mixed     Label(s) for a field
  * @param     mixed     Either a typical HTML attribute string or an associative array
  * @since     1.0
  * @access    public
  * @return    void
  */
 public function __construct($elementName = null, $elementLabel = null, $attributes = [])
 {
     if (empty($attributes) || isset($attributes) && !is_array($attributes)) {
         $attributes = [];
     }
     $attributes['class'] = isset($attributes['class']) ? $attributes['class'] : 'form-control';
     $columnsSize = isset($attributes['cols-size']) ? $attributes['cols-size'] : null;
     $this->setColumnsSize($columnsSize);
     parent::__construct($elementName, $elementLabel, $attributes);
     $this->_persistantFreeze = true;
     $this->_type = 'textarea';
 }
Exemple #15
0
 /**
  * Class constructor
  *
  * @param     string    Select name attribute
  * @param     mixed     Label(s) for the select
  * @param     mixed     Data to be used to populate options
  * @param     mixed     Either a typical HTML attribute string or an associative array
  * @since     1.0
  * @access    public
  * @return    void
  */
 public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null)
 {
     if (is_array($attributes) || empty($attributes)) {
         $oldClass = '';
         if (!empty($attributes['class'])) {
             $oldClass = $attributes['class'];
         }
         $attributes['class'] = $oldClass . ' form-control';
     }
     $columnsSize = isset($attributes['cols-size']) ? $attributes['cols-size'] : null;
     $this->setColumnsSize($columnsSize);
     parent::__construct($elementName, $elementLabel, $attributes);
     $this->_persistantFreeze = true;
     $this->_type = 'select';
     if (isset($options)) {
         $this->load($options);
     }
 }
Exemple #16
0
 /**
  * Constructor
  *
  * @param string $elementName (optional) name of the filemanager
  * @param string $elementLabel (optional) filemanager label
  * @param array $attributes (optional) Either a typical HTML attribute string
  *              or an associative array
  * @param array $options set of options to initalize filemanager
  */
 public function __construct($elementName = null, $elementLabel = null, $attributes = null, $options = null)
 {
     global $CFG, $PAGE;
     $options = (array) $options;
     foreach ($options as $name => $value) {
         if (array_key_exists($name, $this->_options)) {
             $this->_options[$name] = $value;
         }
     }
     if (!empty($options['maxbytes'])) {
         $this->_options['maxbytes'] = get_user_max_upload_file_size($PAGE->context, $CFG->maxbytes, $options['maxbytes']);
     }
     if (empty($options['return_types'])) {
         $this->_options['return_types'] = FILE_INTERNAL | FILE_REFERENCE;
     }
     $this->_type = 'filemanager';
     parent::__construct($elementName, $elementLabel, $attributes);
 }
Exemple #17
0
 /**
  * constructor
  *
  * @param string $elementName Element's name
  * @param mixed $elementLabel Label(s) for an element
  * @param array $options Options to control the element's display. Recognised values are
  *              'optional' => true/false - whether to display an 'enabled' checkbox next to the element.
  *              'defaultunit' => 1|60|3600|86400|604800 - the default unit to display when the time is blank.
  *              If not specified, minutes is used.
  * @param mixed $attributes Either a typical HTML attribute string or an associative array
  */
 public function __construct($elementName = null, $elementLabel = null, $options = array(), $attributes = null)
 {
     // TODO MDL-52313 Replace with the call to parent::__construct().
     HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes);
     $this->_persistantFreeze = true;
     $this->_appendName = true;
     $this->_type = 'duration';
     // Set the options, do not bother setting bogus ones
     if (!is_array($options)) {
         $options = array();
     }
     $this->_options['optional'] = !empty($options['optional']);
     if (isset($options['defaultunit'])) {
         if (!array_key_exists($options['defaultunit'], $this->get_units())) {
             throw new coding_exception($options['defaultunit'] . ' is not a recognised unit in MoodleQuickForm_duration.');
         }
         $this->_options['defaultunit'] = $options['defaultunit'];
     }
 }
Exemple #18
0
 /**
  * Class constructor
  * 
  * @param    string     Input field name attribute
  * @param    mixed      Label(s) for the input field
  * @param    mixed      Either a typical HTML attribute string or an associative array
  * @since     1.0
  * @access    public
  * @return    void
  */
 public function __construct($elementName = null, $elementLabel = null, $attributes = null)
 {
     parent::__construct($elementName, $elementLabel, $attributes);
 }
Exemple #19
0
 /**
  * Class constructor
  *
  * @param     string    $elementName    (optional)Group name
  * @param     array     $elementLabel   (optional)Group label
  * @param     array     $elements       (optional)Group elements
  * @param     mixed     $separator      (optional)Use a string for one separator,
  *                                      use an array to alternate the separators.
  * @param     bool      $appendName     (optional)whether to change elements' names to
  *                                      the form $groupName[$elementName] or leave
  *                                      them as is.
  * @since     1.0
  * @access    public
  * @return    void
  */
 public function __construct($elementName = null, $elementLabel = null, $elements = null, $separator = null, $appendName = true)
 {
     parent::__construct($elementName, $elementLabel);
     $this->_type = 'group';
     if (isset($elements) && is_array($elements)) {
         $this->setElements($elements);
     }
     if (isset($separator)) {
         $this->_separator = $separator;
     }
     if (isset($appendName)) {
         $this->_appendName = $appendName;
     }
 }
Exemple #20
0
 /**
  * Class constructor
  * 
  * @param     string    Input field name attribute
  * @param     mixed     Label(s) for a field
  * @param     mixed     Either a typical HTML attribute string or an associative array
  * @since     1.0
  * @access    public
  * @return    void
  */
 public function __construct($elementName = null, $elementLabel = null, $attributes = null)
 {
     parent::__construct($elementName, $elementLabel, $attributes);
     $this->_persistantFreeze = true;
     $this->_type = 'textarea';
 }
Exemple #21
0
 /**
  * Class constructor
  *
  * @param string $elementName Select name attribute
  * @param mixed $elementLabel Label(s) for the select
  * @param mixed $attributes Either a typical HTML attribute string or an associative array
  * @param array $options ignored
  */
 public function __construct($elementName = null, $elementLabel = null, $attributes = null, $options = null)
 {
     // TODO MDL-52313 Replace with the call to parent::__construct().
     HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes, null);
     $this->_type = 'modvisible';
 }
Exemple #22
0
 /**
  * Class constructor
  *
  * @access   public
  * @param    string  Element's name
  * @param    mixed   Label(s) for an element
  * @param    array   Options to control the element's display
  * @param    mixed   Either a typical HTML attribute string or an associative array
  */
 public function __construct($elementName = null, $elementLabel = null, $options = array(), $attributes = null)
 {
     // TODO MDL-52313 Replace with the call to parent::__construct().
     HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes);
     $this->_persistantFreeze = true;
     $this->_appendName = true;
     $this->_type = 'date';
     // set the options, do not bother setting bogus ones
     if (is_array($options)) {
         foreach ($options as $name => $value) {
             if ('language' == $name) {
                 $this->_options['language'] = isset($this->_locale[$value]) ? $value : 'en';
             } elseif (isset($this->_options[$name])) {
                 if (is_array($value) && is_array($this->_options[$name])) {
                     $this->_options[$name] = @array_merge($this->_options[$name], $value);
                 } else {
                     $this->_options[$name] = $value;
                 }
             }
         }
     }
 }
 public function __construct($elementName = null, $elementLabel = null, $attributes = null, $fileinfo = null, $format = null)
 {
     parent::__construct($elementName, $elementLabel, $attributes);
     $this->_fileinfo = $fileinfo;
     $this->_format = $format;
 }
Exemple #24
0
 /**
  * Class constructor
  *
  * @param     string    $elementName    (optional)Input field name attribute
  * @param     string    $elementLabel   (optional)Input field label in form
  * @param     mixed     $attributes     (optional)Either a typical HTML attribute string
  *                                      or an associative array. Date format is passed along the attributes.
  * @param     mixed     $separator      (optional)Use a string for one separator,
  *                                      use an array to alternate the separators.
  * @access    public
  * @return    void
  */
 public function __construct($elementName = null, $elementLabel = null, $attributes = null, $separator = null)
 {
     // TODO MDL-52313 Replace with the call to parent::__construct().
     HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes);
     $this->_persistantFreeze = true;
     if (isset($separator)) {
         $this->_separator = $separator;
     }
     $this->_type = 'hierselect';
     $this->_appendName = true;
 }