Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.
   1  <?php
   2  /* vim: set expandtab tabstop=4 shiftwidth=4: */
   3  // +----------------------------------------------------------------------+
   4  // | PHP version 4.0                                                      |
   5  // +----------------------------------------------------------------------+
   6  // | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group             |
   7  // +----------------------------------------------------------------------+
   8  // | This source file is subject to version 2.0 of the PHP license,       |
   9  // | that is bundled with this package in the file LICENSE, and is        |
  10  // | available at through the world-wide-web at                           |
  11  // | http://www.php.net/license/2_02.txt.                                 |
  12  // | If you did not receive a copy of the PHP license and are unable to   |
  13  // | obtain it through the world-wide-web, please send a note to          |
  14  // | license@php.net so we can mail you a copy immediately.               |
  15  // +----------------------------------------------------------------------+
  16  // | Authors: Adam Daniel <adaniel1@eesus.jnj.com>                        |
  17  // |          Bertrand Mansion <bmansion@mamasam.com>                     |
  18  // +----------------------------------------------------------------------+
  19  //
  20  
  21  require_once 'HTML/QuickForm/static.php';
  22  
  23  /**
  24   * HTML class for a link type field
  25   * 
  26   * @author       Adam Daniel <adaniel1@eesus.jnj.com>
  27   * @author       Bertrand Mansion <bmansion@mamasam.com>
  28   * @version      1.0
  29   * @since        PHP4.04pl1
  30   * @access       public
  31   */
  32  class HTML_QuickForm_link extends HTML_QuickForm_static
  33  {
  34      // {{{ properties
  35  
  36      /**
  37       * Link display text
  38       * @var       string
  39       * @since     1.0
  40       * @access    private
  41       */
  42      var $_text = "";
  43  
  44      // }}}
  45      // {{{ constructor
  46      
  47      /**
  48       * Class constructor
  49       * 
  50       * @param     string    $elementLabel   (optional)Link label
  51       * @param     string    $href           (optional)Link href
  52       * @param     string    $text           (optional)Link display text
  53       * @param     mixed     $attributes     (optional)Either a typical HTML attribute string 
  54       *                                      or an associative array
  55       * @since     1.0
  56       * @access    public
  57       * @return    void
  58       * @throws    
  59       */
  60      public function __construct($elementName=null, $elementLabel=null, $href=null, $text=null, $attributes=null) {
  61          // TODO MDL-52313 Replace with the call to parent::__construct().
  62          HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes);
  63          $this->_persistantFreeze = false;
  64          $this->_type = 'link';
  65          $this->setHref($href);
  66          $this->_text = $text;
  67      } //end constructor
  68  
  69      /**
  70       * Old syntax of class constructor. Deprecated in PHP7.
  71       *
  72       * @deprecated since Moodle 3.1
  73       */
  74      public function HTML_QuickForm_link($elementName=null, $elementLabel=null, $href=null, $text=null, $attributes=null) {
  75          debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
  76          self::__construct($elementName, $elementLabel, $href, $text, $attributes);
  77      }
  78  
  79      // }}}
  80      // {{{ setName()
  81  
  82      /**
  83       * Sets the input field name
  84       * 
  85       * @param     string    $name   Input field name attribute
  86       * @since     1.0
  87       * @access    public
  88       * @return    void
  89       * @throws    
  90       */
  91      function setName($name)
  92      {
  93          $this->updateAttributes(array('name'=>$name));
  94      } //end func setName
  95      
  96      // }}}
  97      // {{{ getName()
  98  
  99      /**
 100       * Returns the element name
 101       * 
 102       * @since     1.0
 103       * @access    public
 104       * @return    string
 105       * @throws    
 106       */
 107      function getName()
 108      {
 109          return $this->getAttribute('name');
 110      } //end func getName
 111  
 112      // }}}
 113      // {{{ setValue()
 114  
 115      /**
 116       * Sets value for textarea element
 117       * 
 118       * @param     string    $value  Value for password element
 119       * @since     1.0
 120       * @access    public
 121       * @return    void
 122       * @throws    
 123       */
 124      function setValue($value)
 125      {
 126          return;
 127      } //end func setValue
 128      
 129      // }}}
 130      // {{{ getValue()
 131  
 132      /**
 133       * Returns the value of the form element
 134       *
 135       * @since     1.0
 136       * @access    public
 137       * @return    void
 138       * @throws    
 139       */
 140      function getValue()
 141      {
 142          return;
 143      } // end func getValue
 144  
 145      
 146      // }}}
 147      // {{{ setHref()
 148  
 149      /**
 150       * Sets the links href
 151       *
 152       * @param     string    $href
 153       * @since     1.0
 154       * @access    public
 155       * @return    void
 156       * @throws    
 157       */
 158      function setHref($href)
 159      {
 160          $this->updateAttributes(array('href'=>$href));
 161      } // end func setHref
 162  
 163      // }}}
 164      // {{{ toHtml()
 165  
 166      /**
 167       * Returns the textarea element in HTML
 168       * 
 169       * @since     1.0
 170       * @access    public
 171       * @return    string
 172       * @throws    
 173       */
 174      function toHtml()
 175      {
 176          $tabs = $this->_getTabs();
 177          $html = "$tabs<a".$this->_getAttrString($this->_attributes).">";
 178          $html .= $this->_text;
 179          $html .= "</a>";
 180          return $html;
 181      } //end func toHtml
 182      
 183      // }}}
 184      // {{{ getFrozenHtml()
 185  
 186      /**
 187       * Returns the value of field without HTML tags (in this case, value is changed to a mask)
 188       * 
 189       * @since     1.0
 190       * @access    public
 191       * @return    string
 192       * @throws    
 193       */
 194      function getFrozenHtml()
 195      {
 196          return;
 197      } //end func getFrozenHtml
 198  
 199      // }}}
 200  
 201  } //end class HTML_QuickForm_textarea
 202  ?>