Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Php7 migration #9

Open
wants to merge 27 commits into
base: php7-migration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
364 changes: 161 additions & 203 deletions HTML/QuickForm.php

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions HTML/QuickForm/Error.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* Class for errors thrown by HTML_QuickForm package
*
* @category HTML
* @package HTML_QuickForm
* @author Adam Daniel <[email protected]>
* @author Bertrand Mansion <[email protected]>
* @version Release: @package_version@
*/
class HTML_QuickForm_Error extends PEAR_Error
{

// {{{ properties

/**
* Prefix for all error messages
* @var string
*/
public $error_message_prefix = 'QuickForm Error: ';

// }}}
// {{{ constructor

/**
* Creates a quickform error object, extending the PEAR_Error class
*
* @param int $code the error code
* @param int $mode the reaction to the error, either return, die or trigger/callback
* @param int $level intensity of the error (PHP error code)
* @param mixed $debuginfo any information that can inform user as to nature of the error
*/
public function __construct(
$code = QUICKFORM_ERROR,
$mode = PEAR_ERROR_RETURN,
$level = E_USER_NOTICE,
$debuginfo = null
) {
if (is_int($code)) {
parent::__construct(HTML_QuickForm::errorMessage($code), $code, $mode, $level, $debuginfo);
} else {
parent::__construct("Invalid error code: $code", QUICKFORM_ERROR, $mode, $level, $debuginfo);
}
}

// }}}
} // end class HTML_QuickForm_Error
22 changes: 11 additions & 11 deletions HTML/QuickForm/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
* @since 3.0
* @abstract
*/
class HTML_QuickForm_Renderer
abstract class HTML_QuickForm_Renderer
{
/**
* Constructor
*
* @access public
*/
function HTML_QuickForm_Renderer()
public function __construct()
{
} // end constructor

Expand All @@ -52,7 +52,7 @@ function HTML_QuickForm_Renderer()
* @return void
* @abstract
*/
function startForm($form)
public function startForm($form)
{
return;
} // end func startForm
Expand All @@ -65,7 +65,7 @@ function startForm($form)
* @return void
* @abstract
*/
function finishForm($form)
public function finishForm($form)
{
return;
} // end func finishForm
Expand All @@ -78,7 +78,7 @@ function finishForm($form)
* @return void
* @abstract
*/
function renderHeader($header)
public function renderHeader($header)
{
return;
} // end func renderHeader
Expand All @@ -93,7 +93,7 @@ function renderHeader($header)
* @return void
* @abstract
*/
function renderElement($element, $required, $error)
public function renderElement($element, $required, $error)
{
return;
} // end func renderElement
Expand All @@ -106,7 +106,7 @@ function renderElement($element, $required, $error)
* @return void
* @abstract
*/
function renderHidden($element)
public function renderHidden($element)
{
return;
} // end func renderHidden
Expand All @@ -122,7 +122,7 @@ function renderHidden($element)
* @return void
* @abstract
*/
function renderHtml($data)
public function renderHtml($data)
{
return;
} // end func renderHtml
Expand All @@ -137,7 +137,7 @@ function renderHtml($data)
* @return void
* @abstract
*/
function startGroup($group, $required, $error)
public function startGroup($group, $required, $error)
{
return;
} // end func startGroup
Expand All @@ -150,9 +150,9 @@ function startGroup($group, $required, $error)
* @return void
* @abstract
*/
function finishGroup($group)
public function finishGroup($group)
{
return;
} // end func finishGroup
} // end class HTML_QuickForm_Renderer
?>

52 changes: 27 additions & 25 deletions HTML/QuickForm/Renderer/Array.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
* @link http://pear.php.net/package/HTML_QuickForm
*/

/**
* An abstract base class for QuickForm renderers
*/
require_once 'HTML/QuickForm/Renderer.php';

/**
* A concrete renderer for HTML_QuickForm, makes an array of form contents
*
Expand Down Expand Up @@ -121,44 +116,51 @@ class HTML_QuickForm_Renderer_Array extends HTML_QuickForm_Renderer
* An array being generated
* @var array
*/
var $_ary;
protected $_ary;

/**
* Number of sections in the form (i.e. number of headers in it)
* @var integer
*/
var $_sectionCount;
protected $_sectionCount;

/**
* Current section number
* @var integer
*/
var $_currentSection;
protected $_currentSection;

/**
* Array representing current group
* @var array
*/
var $_currentGroup = null;
protected $_currentGroup = null;

/**
* Additional style information for different elements
* @var array
*/
var $_elementStyles = array();
protected $_elementStyles = array();

/**
* true: collect all hidden elements into string; false: process them as usual form elements
* @var bool
*/
var $_collectHidden = false;
protected $_collectHidden = false;

/**
* true: render an array of labels to many labels, $key 0 named 'label', the rest "label_$key"
* false: leave labels as defined
* @var bool
*/
var $_staticLabels = false;
protected $_staticLabels = false;

/**
* Current element index
* @var integer
*/
protected $_elementIdx = 0;

/**#@-*/

/**
Expand All @@ -168,9 +170,9 @@ class HTML_QuickForm_Renderer_Array extends HTML_QuickForm_Renderer
* @param bool true: render an array of labels to many labels, $key 0 to 'label' and the oterh to "label_$key"
* @access public
*/
function HTML_QuickForm_Renderer_Array($collectHidden = false, $staticLabels = false)
public function __construct($collectHidden = false, $staticLabels = false)
{
$this->HTML_QuickForm_Renderer();
parent::__construct();
$this->_collectHidden = $collectHidden;
$this->_staticLabels = $staticLabels;
} // end constructor
Expand All @@ -182,13 +184,13 @@ function HTML_QuickForm_Renderer_Array($collectHidden = false, $staticLabels = f
* @access public
* @return array
*/
function toArray()
public function toArray()
{
return $this->_ary;
}


function startForm($form)
public function startForm($form)
{
$this->_ary = array(
'frozen' => $form->isFrozen(),
Expand All @@ -206,7 +208,7 @@ function startForm($form)
} // end func startForm


function renderHeader($header)
public function renderHeader($header)
{
$this->_ary['sections'][$this->_sectionCount] = array(
'header' => $header->toHtml(),
Expand All @@ -216,7 +218,7 @@ function renderHeader($header)
} // end func renderHeader


function renderElement($element, $required, $error)
public function renderElement($element, $required, $error)
{
$elAry = $this->_elementToArray($element, $required, $error);
if (!empty($error)) {
Expand All @@ -226,7 +228,7 @@ function renderElement($element, $required, $error)
} // end func renderElement


function renderHidden($element)
public function renderHidden($element)
{
if ($this->_collectHidden) {
$this->_ary['hidden'] .= $element->toHtml() . "\n";
Expand All @@ -236,7 +238,7 @@ function renderHidden($element)
} // end func renderHidden


function startGroup($group, $required, $error)
public function startGroup($group, $required, $error)
{
$this->_currentGroup = $this->_elementToArray($group, $required, $error);
if (!empty($error)) {
Expand All @@ -245,7 +247,7 @@ function startGroup($group, $required, $error)
} // end func startGroup


function finishGroup($group)
public function finishGroup($group)
{
$this->_storeArray($this->_currentGroup);
$this->_currentGroup = null;
Expand All @@ -261,7 +263,7 @@ function finishGroup($group)
* @param string Error associated with the element
* @return array
*/
function _elementToArray($element, $required, $error)
protected function _elementToArray($element, $required, $error)
{
$ret = array(
'name' => $element->getName(),
Expand Down Expand Up @@ -307,7 +309,7 @@ function _elementToArray($element, $required, $error)
* @param array Array representation of an element
* @return void
*/
function _storeArray($elAry)
protected function _storeArray($elAry)
{
// where should we put this element...
if (is_array($this->_currentGroup) && ('group' != $elAry['type'])) {
Expand All @@ -328,7 +330,7 @@ function _storeArray($elAry)
* @access public
* @return void
*/
function setElementStyle($elementName, $styleName = null)
public function setElementStyle($elementName, $styleName = null)
{
if (is_array($elementName)) {
$this->_elementStyles = array_merge($this->_elementStyles, $elementName);
Expand All @@ -337,4 +339,4 @@ function setElementStyle($elementName, $styleName = null)
}
}
}
?>

Loading