Source for file Button.php
Documentation is available at Button.php
* A Framework for Creating and Using Complex Web Elements
* The purpose of this framework is to provide a library of high-level objects
* to facilitate common HTML coding tasks, such as menus, tables, and forms.
* The intent is to reduce repetitive HTML coding as much as possible, replacing
* it with a combination of configuration files and style sheets with
* standardized naming conventions.
* This framework is built on and requires the
* {@link http://framework.zend.com/ Zend Framework}.
* @author Lyle Frost <lfrost@cnz.com>
* @copyright Copyright (c) 2006-2007 Citadel Network <{@link http://www.citadelnetwork.com/}>
* @license http://www.citadelnetwork.com/license/cnzframework New BSD License
* @version $Id: Button.php 27 2007-07-19 18:47:54Z lfrost $
* HTML Table Button class
* This class is probably not useful directly. It could be an inner class
* of Html_Table, if PHP supported inner classes.
private $paramArray = array();
private $method = self::DEFAULT_METHOD;
/* Getters/Setters ===================================================*/
/** @return string Name */
* @param array $row Row of data
public function setRow(array $row)
/* Methods ===========================================================*/
* action Form action for button press
* method Form method for button press
* param Parameter to pass with button press
* @param array $options Options
* @param Zend_Config $config Configuration
public function __construct(array $options = array(), Zend_Config $config = NULL)
// Process configuration.
if (isset ($config->action)) $this->action = $config->action;
if (isset ($config->label)) $this->label = $config->label;
if (isset ($config->method)) $this->method = $config->method;
* @param string $style Value for outermost style attribute
public function display($style = NULL)
if ($this->action[0] == ':')
$column = substr($this->action, 1);
if (empty($this->row[$column]))
$action = $this->row[$column];
if ($this->method == 'post')
echo $indent, $is, $is, '<form action = "', $action, '" class = "', $this->genStyles('button'), '" method = "', $this->method, '">';
foreach ($this->paramArray as $src => $target)
if (empty($target)) $target = $src;
echo '<input name = "', $target, '" type = "hidden" value = "', $this->row[$src], '"/>';
echo '<button class = "', $this->genStyles(), '" type = "submit">', $this->label, '</button>';
echo $indent, '<a href = "', $action;
foreach ($this->paramArray as $src => $target)
if (empty($target)) $target = $src;
echo $count == 0 ? '?' : '&';
echo $target, '=', $this->row[$src];
echo '<button class = "', $this->genStyles(), '" type = "submit">', $this->label, '</button>';
|