Source for file StandardWidgets.php

Documentation is available at StandardWidgets.php

  1. <?php
  2.     /**
  3.      * The standard widgets
  4.      * @copyright Copyright (c) 2006,2007 Mirchev Ideas Ltd. All rights reserved.
  5.      * @package MIPHPF
  6.      */
  7.  
  8.     /**
  9.      * Standard text widget
  10.      * Use it with input type="text" and with textarea
  11.      * @copyright Copyright (c) 2006,2007 Mirchev Ideas Ltd. All rights reserved.
  12.      * @package MIPHPF
  13.      */
  14.     class miTextWidget extends miBaseTextWidget {
  15.         /**
  16.          * Returns the text widget contents to be displayed
  17.          * 
  18.          * @return array 
  19.          */
  20.         function getEditableControl()
  21.         {
  22.             $id = isset($this->_properties['id']) ? ' id="' . $this->_properties['id'] . '"' : '';
  23.             $widget = '<input type="text" name="' . $this->_fieldName . '" value="' . miI18N::htmlEscape($this->_webForm->getFormData($this->_fieldName)) . '"' . $id . '/>';
  24.             return array($this->_fieldName => $widget);
  25.         }
  26.     }
  27.     
  28.     
  29.     /**
  30.      * Standard checkbox widget
  31.      * Use it with input type="checkbox"
  32.      * @copyright Copyright (c) 2006,2007 Mirchev Ideas Ltd. All rights reserved.
  33.      * @package MIPHPF
  34.      */
  35.     class miCheckboxWidget extends miBaseCheckboxWidget {
  36.         /**
  37.          * Returns the checkbox widget contents to be displayed
  38.          * 
  39.          * @return array 
  40.          */
  41.         function getEditableControl()
  42.         {
  43.             $id = isset($this->_properties['id']) ? ' id="' . $this->_properties['id'] . '"' : '';
  44.             $checked = $this->getValue() ? ' checked="checked"' : '';
  45.             $widget = '<input type="checkbox" name="' . $this->_fieldName . '"' . $checked . $id . '/>';
  46.             return array($this->_fieldName => $widget);
  47.         }
  48.     }
  49.     
  50.     /**
  51.      * Standard radio buttons widget
  52.      * Use it with input type="radio"
  53.      * 
  54.      * This class supports a group of radio buttons
  55.      * @copyright Copyright (c) 2006,2007 Mirchev Ideas Ltd. All rights reserved.
  56.      * @package MIPHPF
  57.      */
  58.     class miRadioWidget extends miBaseRadioWidget {
  59.         
  60.         /**
  61.          * Returns the widget contents to be displayed
  62.          * 
  63.          * @return array 
  64.          */
  65.         public function getEditableControl()
  66.         {
  67.             $value = $this->getValue();
  68.             
  69.             $widget = '';
  70.             foreach ($this->_radioButtons as $key => $option) {
  71.                 $checked = ($value == $key) ? ' checked="checked"' : '';
  72.                 $widget .= '<label><input type="radio" name="' . $this->_fieldName . '" value="' . $key . '"' . $checked . '/>' . miI18N::htmlEscape($option) . '</label>';
  73.             }
  74.             return array($this->_fieldName => $widget);
  75.         }
  76.     }
  77.     
  78.     /**
  79.      * Standard select widget
  80.      * Use it with select tag
  81.      * @copyright Copyright (c) 2006,2007 Mirchev Ideas Ltd. All rights reserved.
  82.      * @package MIPHPF
  83.      */
  84.     class miSelectWidget extends miBaseSelectWidget {
  85.         
  86.         /**
  87.          * Returns the widget contents to be displayed
  88.          * 
  89.          * @return array 
  90.          */
  91.         public function getEditableControl()
  92.         {
  93.             $value = $this->getValue();
  94.             
  95.             $id = isset($this->_properties['id']) ? ' id="' . $this->_properties['id'] . '"' : '';
  96.             $class = isset($this->_properties['class']) ? ' class="' . $this->_properties['class'] . '"' : '';
  97.             $html = '<select name="' . $this->_fieldName . '"' . $id . $class . '>';
  98.             foreach ($this->_options as $key => $option)
  99.                 $html .= '<option value="' . miI18N::htmlEscape($key) . '"' . ($key == $value?' selected="selected"':'') . '>' . miI18N::htmlEscape($option) . '</option>';
  100.             $html .= '</select>';
  101.             return array($this->_fieldName => $html);
  102.         }
  103.     }
  104. ?>

Documentation generated on Thu, 08 May 2008 16:57:39 +0300 by phpDocumentor 1.4.1