本文整理汇总了PHP中HTML_Common::_parseAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP HTML_Common::_parseAttributes方法的具体用法?PHP HTML_Common::_parseAttributes怎么用?PHP HTML_Common::_parseAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTML_Common
的用法示例。
在下文中一共展示了HTML_Common::_parseAttributes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createButtons
/**
* Adds all necessary buttons to the given page object.
*
* @param object $page Page where to put the button
* @param array $buttons Key/label of each button/event to handle
* @param mixed $attributes (optional) Either a typical HTML attribute string
* or an associative array.
* @return void
* @since 1.1
* @access public
* @throws HTML_PROGRESS_ERROR_INVALID_INPUT
*/
function createButtons(&$page, $buttons, $attributes = null)
{
if (!is_a($page, 'HTML_QuickForm_Page')) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$page', 'was' => gettype($page), 'expected' => 'HTML_QuickForm_Page object', 'paramnum' => 1));
} elseif (!is_array($buttons)) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$buttons', 'was' => gettype($buttons), 'expected' => 'array', 'paramnum' => 2));
} elseif (!is_array($attributes) && !is_string($attributes) && !is_null($attributes)) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$attributes', 'was' => gettype($attributes), 'expected' => 'array | string', 'paramnum' => 3));
}
$confirm = $attributes = HTML_Common::_parseAttributes($attributes);
$confirm['onClick'] = "return(confirm('Are you sure ?'));";
$prevnext = array();
foreach ($buttons as $event => $label) {
if ($event == 'cancel') {
$type = 'submit';
$attrs = $confirm;
} elseif ($event == 'reset') {
$type = 'reset';
$attrs = $confirm;
} else {
$type = 'submit';
$attrs = $attributes;
}
$prevnext[] = $page->createElement($type, $page->getButtonName($event), $label, HTML_Common::_getAttrString($attrs));
}
$page->addGroup($prevnext, 'buttons', '', ' ', false);
}
示例2: _getAttributes
/**
* DB_DataObject_FormBuilder_QuickForm::_getAttributes()
*
* Returns the attributes to apply to a field based on the field name and
* element type. The field's attributes take precedence over the element type's.
*
* @param string $elementType the internal type of the element
* @param string $fieldName the name of the field
* @return array an array of attributes to apply to the element
*/
function _getAttributes($elementType, $fieldName)
{
if (isset($this->elementTypeAttributes[$elementType])) {
if (is_string($this->elementTypeAttributes[$elementType])) {
$this->elementTypeAttributes[$elementType] = HTML_Common::_parseAttributes($this->elementTypeAttributes[$elementType]);
}
$attr = $this->elementTypeAttributes[$elementType];
} else {
$attr = array();
}
if (isset($this->fieldAttributes[$fieldName])) {
if (is_string($this->fieldAttributes[$fieldName])) {
$this->fieldAttributes[$fieldName] = HTML_Common::_parseAttributes($this->fieldAttributes[$fieldName]);
}
$attr = array_merge($attr, $this->fieldAttributes[$fieldName]);
}
return $attr;
}