Exemple #1
0
 /**
  * Class constructor
  * 
  * @param    string     Name of the element
  * @param    mixed      Label(s) for the element
  * @param    mixed      Associative array of tag attributes or HTML attributes name="value" pairs
  * @since     1.0
  * @access    public
  * @return    void
  */
 public function __construct($elementName = null, $elementLabel = null, $attributes = null)
 {
     parent::__construct($attributes);
     if (isset($elementName)) {
         $this->setName($elementName);
     }
     if (isset($elementLabel)) {
         $this->setLabel($elementLabel);
     }
 }
Exemple #2
0
 /**
  * Class constructor
  * @param    array    $attributes        Associative array of table tag
  *                                       attributes
  * @param    int      $tabOffset         Tab offset of the table
  * @param    bool     $useTGroups        Whether to use <thead>, <tfoot> and
  *                                       <tbody> or not
  * @access   public
  */
 function HTML_Table($attributes = null, $tabOffset = 0, $useTGroups = false)
 {
     parent::__construct($attributes, (int) $tabOffset);
     $this->_useTGroups = (bool) $useTGroups;
     $this->addBody();
     if ($this->_useTGroups) {
         $this->_thead = new HTML_Table_Storage($tabOffset, $this->_useTGroups);
         $this->_tfoot = new HTML_Table_Storage($tabOffset, $this->_useTGroups);
     }
 }
Exemple #3
0
 /**
  * Class constructor - same parameters as HTML_QuickForm_DHTMLRulesTableless
  *
  * @staticvar int $formcounter counts number of forms
  * @param string $formName Form's name.
  * @param string $method Form's method defaults to 'POST'
  * @param string|moodle_url $action Form's action
  * @param string $target (optional)Form's target defaults to none
  * @param mixed $attributes (optional)Extra attributes for <form> tag
  */
 public function __construct($formName, $method, $action, $target = '', $attributes = null)
 {
     global $CFG, $OUTPUT;
     static $formcounter = 1;
     // TODO MDL-52313 Replace with the call to parent::__construct().
     HTML_Common::__construct($attributes);
     $target = empty($target) ? array() : array('target' => $target);
     $this->_formName = $formName;
     if (is_a($action, 'moodle_url')) {
         $this->_pageparams = html_writer::input_hidden_params($action);
         $action = $action->out_omit_querystring();
     } else {
         $this->_pageparams = '';
     }
     // No 'name' atttribute for form in xhtml strict :
     $attributes = array('action' => $action, 'method' => $method, 'accept-charset' => 'utf-8') + $target;
     if (is_null($this->getAttribute('id'))) {
         $attributes['id'] = 'mform' . $formcounter;
     }
     $formcounter++;
     $this->updateAttributes($attributes);
     // This is custom stuff for Moodle :
     $oldclass = $this->getAttribute('class');
     if (!empty($oldclass)) {
         $this->updateAttributes(array('class' => $oldclass . ' mform'));
     } else {
         $this->updateAttributes(array('class' => 'mform'));
     }
     $this->_reqHTML = '<img class="req" title="' . get_string('requiredelement', 'form') . '" alt="' . get_string('requiredelement', 'form') . '" src="' . $OUTPUT->pix_url('req') . '" />';
     $this->_advancedHTML = '<img class="adv" title="' . get_string('advancedelement', 'form') . '" alt="' . get_string('advancedelement', 'form') . '" src="' . $OUTPUT->pix_url('adv') . '" />';
     $this->setRequiredNote(get_string('somefieldsrequired', 'form', '<img alt="' . get_string('requiredelement', 'form') . '" src="' . $OUTPUT->pix_url('req') . '" />'));
 }
Exemple #4
0
 /**
  * Class constructor
  * @param    string      $formName          Form's name.
  * @param    string      $method            (optional)Form's method defaults to 'POST'
  * @param    string      $action            (optional)Form's action
  * @param    string      $target            (optional)Form's target defaults to '_self'
  * @param    mixed       $attributes        (optional)Extra attributes for <form> tag
  * @param    bool        $trackSubmit       (optional)Whether to track if the form was submitted by adding a special hidden field
  * @access   public
  */
 public function __construct($formName = '', $method = 'post', $action = '', $target = '', $attributes = null, $trackSubmit = false)
 {
     parent::__construct($attributes);
     $method = strtoupper($method) == 'GET' ? 'get' : 'post';
     $action = $action == '' ? api_get_self() : $action;
     $target = empty($target) ? array() : array('target' => $target);
     $form_id = $formName;
     if (isset($attributes['id']) && !empty($attributes['id'])) {
         $form_id = Security::remove_XSS($attributes['id']);
     }
     $attributes = array('action' => $action, 'method' => $method, 'name' => $formName, 'id' => $form_id) + $target;
     $this->updateAttributes($attributes);
     if (!$trackSubmit || isset($_REQUEST['_qf__' . $formName])) {
         if (1 == get_magic_quotes_gpc()) {
             $this->_submitValues = $this->_recursiveFilter('stripslashes', 'get' == $method ? $_GET : $_POST);
             foreach ($_FILES as $keyFirst => $valFirst) {
                 foreach ($valFirst as $keySecond => $valSecond) {
                     if ('name' == $keySecond) {
                         $this->_submitFiles[$keyFirst][$keySecond] = $this->_recursiveFilter('stripslashes', $valSecond);
                     } else {
                         $this->_submitFiles[$keyFirst][$keySecond] = $valSecond;
                     }
                 }
             }
         } else {
             $this->_submitValues = 'get' == $method ? $_GET : $_POST;
             $this->_submitFiles = $_FILES;
         }
         $this->_flagSubmitted = count($this->_submitValues) > 0 || count($this->_submitFiles) > 0;
     }
     if ($trackSubmit) {
         unset($this->_submitValues['_qf__' . $formName]);
         $this->addElement('hidden', '_qf__' . $formName, null);
     }
     if (preg_match('/^([0-9]+)([a-zA-Z]*)$/', ini_get('upload_max_filesize'), $matches)) {
         // see http://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes
         switch (strtoupper($matches['2'])) {
             case 'G':
                 $this->_maxFileSize = $matches['1'] * 1073741824;
                 break;
             case 'M':
                 $this->_maxFileSize = $matches['1'] * 1048576;
                 break;
             case 'K':
                 $this->_maxFileSize = $matches['1'] * 1024;
                 break;
             default:
                 $this->_maxFileSize = $matches['1'];
         }
     }
     //        $course_id = api_get_course_int_id();
     //        //If I'm in a course replace the default max filesize with the course limits
     //        if (!empty($course_id)) {
     //            $free_course_quota = DocumentManager::get_course_quota() - DocumentManager::documents_total_space();
     //            if (empty($this->_maxFileSize) || $free_course_quota <= $this->_maxFileSize) {
     //                $this->_maxFileSize = intval($free_course_quota);
     //            }
     //        }
 }
Exemple #5
0
 /**
  * Class constructor
  *
  * @param    string     Name of the element
  * @param    mixed      Label(s) for the element
  * @param    mixed      Associative array of tag attributes or HTML attributes name="value" pairs
  * @since     1.0
  * @access    public
  * @return    void
  */
 public function __construct($elementName = null, $elementLabel = null, $attributes = null)
 {
     parent::__construct($attributes);
     if (isset($elementName)) {
         $this->setName($elementName);
     }
     if (isset($elementLabel)) {
         $labelFor = "";
         // Default Inputs generate this
         if (!empty($attributes['id'])) {
             $labelFor = $attributes['id'];
         }
         // Default Labels generate this
         if (!empty($attributes['for'])) {
             $labelFor = $attributes['for'];
         }
         $this->setLabel($elementLabel, $labelFor);
     }
 }
Exemple #6
0
 /**
  * Class constructor
  * @param    string      $formName          Form's name.
  * @param    string      $method            (optional)Form's method defaults to 'POST'
  * @param    string      $action            (optional)Form's action
  * @param    string      $target            (optional)Form's target defaults to '_self'
  * @param    mixed       $attributes        (optional)Extra attributes for <form> tag
  * @param    bool        $trackSubmit       (optional)Whether to track if the form was submitted by adding a special hidden field
  * @access   public
  */
 public function __construct($formName = '', $method = 'post', $action = '', $target = '', $attributes = null, $trackSubmit = false)
 {
     parent::__construct($attributes);
     $method = strtoupper($method) == 'GET' ? 'get' : 'post';
     $action = $action == '' ? $_SERVER['PHP_SELF'] : $action;
     $target = empty($target) ? array() : array('target' => $target);
     $attributes = array('action' => $action, 'method' => $method, 'name' => $formName, 'id' => $formName) + $target;
     $this->updateAttributes($attributes);
     if (!$trackSubmit || isset($_REQUEST['_qf__' . $formName])) {
         if (1 == get_magic_quotes_gpc()) {
             $this->_submitValues = 'get' == $method ? $_GET : $_POST;
             // we already eliminated magic quotes in moodle setup.php
             foreach ($_FILES as $keyFirst => $valFirst) {
                 foreach ($valFirst as $keySecond => $valSecond) {
                     if ('name' == $keySecond) {
                         $this->_submitFiles[$keyFirst][$keySecond] = $valSecond;
                         // we already eliminated magic quotes in moodle setup.php
                     } else {
                         $this->_submitFiles[$keyFirst][$keySecond] = $valSecond;
                     }
                 }
             }
         } else {
             $this->_submitValues = 'get' == $method ? $_GET : $_POST;
             $this->_submitFiles = $_FILES;
         }
         $this->_flagSubmitted = count($this->_submitValues) > 0 || count($this->_submitFiles) > 0;
     }
     if ($trackSubmit) {
         unset($this->_submitValues['_qf__' . $formName]);
         $this->addElement('hidden', '_qf__' . $formName, null);
     }
     if (preg_match('/^([0-9]+)([a-zA-Z]*)$/', ini_get('upload_max_filesize'), $matches)) {
         // see http://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes
         switch (strtoupper($matches['2'])) {
             case 'G':
                 $this->_maxFileSize = $matches['1'] * 1073741824;
                 break;
             case 'M':
                 $this->_maxFileSize = $matches['1'] * 1048576;
                 break;
             case 'K':
                 $this->_maxFileSize = $matches['1'] * 1024;
                 break;
             default:
                 $this->_maxFileSize = $matches['1'];
         }
     }
 }
Exemple #7
0
 /**
  * Class constructor
  * @param    int      $tabOffset
  * @param    bool     $useTGroups        Whether to use <thead>, <tfoot> and
  *                                       <tbody> or not
  * @access   public
  */
 public function __construct($tabOffset = 0, $useTGroups = false)
 {
     parent::__construct(null, (int) $tabOffset);
     $this->_useTGroups = (bool) $useTGroups;
 }
Exemple #8
0
 /**
  * Class constructor
  * @param    int      $tabOffset
  * @param    bool     $useTGroups        Whether to use <thead>, <tfoot> and
  *                                       <tbody> or not
  * @access   public
  */
 function HTML_Table_Storage($tabOffset = 0, $useTGroups = false)
 {
     parent::__construct(null, (int) $tabOffset);
     $this->_useTGroups = (bool) $useTGroups;
 }