[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/form/ -> warning.php (source)

   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  
  18  /**
  19   * static warning element
  20   *
  21   * Contains class for static warning type element
  22   *
  23   * @package   core_form
  24   * @copyright 2008 Jamie Pratt <me@jamiep.org>
  25   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  26   */
  27  require_once("HTML/QuickForm/static.php");
  28  
  29  /**
  30   * static warning
  31   *
  32   * overrides {@link HTML_QuickForm_static} to display staic warning.
  33   *
  34   * @package   core_form
  35   * @category  form
  36   * @copyright 2008 Jamie Pratt <me@jamiep.org>
  37   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  38   */
  39  class MoodleQuickForm_warning extends HTML_QuickForm_static{
  40      /** @var string Form element type */
  41      var $_elementTemplateType='warning';
  42  
  43      /** @var string html for help button, if empty then no help */
  44      var $_helpbutton='';
  45  
  46      /** @var string class assigned to field, default is notifyproblem */
  47      var $_class='';
  48  
  49      /**
  50       * constructor
  51       *
  52       * @param string $elementName (optional) name of the field
  53       * @param string $elementClass (optional) show as warning or notification => 'notifyproblem'
  54       * @param string $text (optional) Text to put in warning field
  55       */
  56      public function __construct($elementName=null, $elementClass='notifyproblem', $text=null) {
  57          parent::__construct($elementName, null, $text);
  58          $this->_type = 'warning';
  59          if (is_null($elementClass)) {
  60              $elementClass = 'notifyproblem';
  61          }
  62          $this->_class = $elementClass;
  63      }
  64  
  65      /**
  66       * Old syntax of class constructor. Deprecated in PHP7.
  67       *
  68       * @deprecated since Moodle 3.1
  69       */
  70      public function MoodleQuickForm_warning($elementName=null, $elementClass='notifyproblem', $text=null) {
  71          debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
  72          self::__construct($elementName, $elementClass, $text);
  73      }
  74  
  75      /**
  76       * Returns HTML for this form element.
  77       *
  78       * @return string
  79       */
  80      function toHtml() {
  81          global $OUTPUT;
  82          return $OUTPUT->notification($this->_text, $this->_class);
  83      }
  84  
  85      /**
  86       * get html for help button
  87       *
  88       * @return string html for help button
  89       */
  90      function getHelpButton(){
  91          return $this->_helpbutton;
  92      }
  93  
  94      /**
  95       * Gets the type of form element
  96       *
  97       * @return string
  98       */
  99      function getElementTemplateType(){
 100          return $this->_elementTemplateType;
 101      }
 102  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1