本文整理汇总了PHP中HTML_Common类的典型用法代码示例。如果您正苦于以下问题:PHP HTML_Common类的具体用法?PHP HTML_Common怎么用?PHP HTML_Common使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HTML_Common类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MyQuickForm
function MyQuickForm($formName = '', $method = 'post', $action = '', $target = '', $attributes = null, $trackSubmit = false)
{
HTML_Common::HTML_Common($attributes);
$method = strtoupper($method) == 'GET' ? 'get' : 'post';
$action = $action == '' ? $_SERVER['PHP_SELF'] : $action;
$target = empty($target) ? array() : array('target' => $target);
$attributes = array('action' => $action, 'method' => $method, 'name' => $formName, 'id' => $formName) + $target;
$this->_trackSubmit = $trackSubmit;
$this->updateAttributes($attributes);
$this->initRequest();
if (preg_match('/^([0-9]+)([a-zA-Z]*)$/', ini_get('upload_max_filesize'), $matches)) {
// see http://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes
switch (strtoupper($matches['2'])) {
case 'G':
$this->_maxFileSize = $matches['1'] * 1073741824;
break;
case 'M':
$this->_maxFileSize = $matches['1'] * 1048576;
break;
case 'K':
$this->_maxFileSize = $matches['1'] * 1024;
break;
default:
$this->_maxFileSize = $matches['1'];
}
}
}
示例2: HTML_Table
/**
* Class constructor
* @param array $attributes Associative array of table tag attributes
* @param int $tabOffset
* @access public
*/
function HTML_Table($attributes = null, $tabOffset = 0)
{
$commonVersion = 1.7;
if (HTML_Common::apiVersion() < $commonVersion) {
return PEAR::raiseError("HTML_Table version " . $this->apiVersion() . " requires " . "HTML_Common version {$commonVersion} or greater.", 0, PEAR_ERROR_TRIGGER);
}
HTML_Common::HTML_Common($attributes, $tabOffset);
}
示例3: HTML_Select
/**
* Class constructor
*
* @param string $name (optional)Name attribute of the SELECT
* @param int $size (optional) Size attribute of the SELECT
* @param bool $multiple (optional)Whether the select will allow multiple
* selections or not
* @param mixed $attributes (optional)Either a typical HTML attribute string
* or an associative array
* @param int $tabOffset (optional)Number of tabs to offset HTML source
* @since 1.0
* @access public
* @return void
* @throws
*/
function HTML_Select($name = '', $size = 1, $multiple = false, $attributes = null, $tabOffset = 0)
{
HTML_Common::HTML_Common($attributes, $tabOffset);
$attr = array('name' => $name, 'size' => $size);
if ($multiple) {
$attr['multiple'] = 'multiple';
}
$this->updateAttributes($attr);
$this->setSelectedValues(array());
}
示例4: HTML_QuickForm_element
/**
* Class constructor
*
* @param string Name of the element
* @param mixed Label(s) for the element
* @param mixed Associative array of tag attributes or HTML attributes name="value" pairs
* @since 1.0
* @access public
* @return void
*/
function HTML_QuickForm_element($elementName = null, $elementLabel = null, $attributes = null)
{
HTML_Common::HTML_Common($attributes);
if (isset($elementName)) {
$this->setName($elementName);
}
if (isset($elementLabel)) {
$this->setLabel($elementLabel);
}
}
示例5: ilp_MoodleQuickForm
/**
* Class constructor - same parameters as HTML_QuickForm_DHTMLRulesTableless
* @param string $formName Form's name.
* @param string $method (optional)Form's method defaults to 'POST'
* @param mixed $action (optional)Form's action - string or moodle_url
* @param string $target (optional)Form's target defaults to none
* @param mixed $attributes (optional)Extra attributes for <form> tag
* @param bool $trackSubmit (optional)Whether to track if the form was submitted by adding a special hidden field
* @access public
*/
function ilp_MoodleQuickForm($formName, $method, $action, $target = '', $attributes = array())
{
global $CFG, $OUTPUT;
static $formcounter = 1;
HTML_Common::HTML_Common($attributes);
$target = empty($target) ? array() : array('target' => $target);
$this->_formName = $formName;
if (is_a($action, 'moodle_url')) {
$this->_pageparams = $action->hidden_params_out();
$action = $action->out(true);
} else {
$this->_pageparams = '';
}
//no 'name' atttribute for form in xhtml strict :
$attributes['action'] = $action;
$attributes['method'] = $method;
$attributes['accept-charset'] = 'utf-8';
$attributes['id'] = empty($attributes['id']) ? 'mform' . $formcounter : $attributes['id'];
$attributes += $target;
//
// array('action'=>$action, 'method'=>$method,
// 'accept-charset'=>'utf-8', 'id'=>'mform'.$formcounter) + $target;
$formcounter++;
$this->updateAttributes($attributes);
//this is custom stuff for Moodle :
$oldclass = $this->getAttribute('class');
if (!empty($oldclass)) {
$this->updateAttributes(array('class' => $oldclass . ' mform'));
} else {
$this->updateAttributes(array('class' => 'mform'));
}
$this->_reqHTML = '<img class="req" title="' . get_string('requiredelement', 'form') . '" alt="' . get_string('requiredelement', 'form') . '" src="' . $OUTPUT->pix_url('req') . '" />';
$this->_advancedHTML = '<img class="adv" title="' . get_string('advancedelement', 'form') . '" alt="' . get_string('advancedelement', 'form') . '" src="' . $OUTPUT->pix_url('adv') . '" />';
$this->setRequiredNote(get_string('somefieldsrequired', 'form', '<img alt="' . get_string('requiredelement', 'form') . '" src="' . $OUTPUT->pix_url('req') . '" />'));
//(Help file doesn't add anything) helpbutton('requiredelement', get_string('requiredelement', 'form'), 'moodle', true, false, '', true));
}
示例6: _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;
}
示例7: __construct
/**
* Class constructor
*
* @param int $tabOffset
* @param bool $useTGroups Whether to use <thead>, <tfoot> and
* <tbody> or not
* @access public
*/
function __construct($tabOffset = 0, $useTGroups = false)
{
HTML_Common::HTML_Common(null, (int) $tabOffset);
$this->_useTGroups = (bool) $useTGroups;
}
示例8: MoodleQuickForm
/**
* Class constructor - same parameters as HTML_QuickForm_DHTMLRulesTableless
*
* @staticvar int $formcounter counts number of forms
* @param string $formName Form's name.
* @param string $method Form's method defaults to 'POST'
* @param string|moodle_url $action Form's action
* @param string $target (optional)Form's target defaults to none
* @param mixed $attributes (optional)Extra attributes for <form> tag
*/
function MoodleQuickForm($formName, $method, $action, $target = '', $attributes = null)
{
global $CFG, $OUTPUT;
static $formcounter = 1;
HTML_Common::HTML_Common($attributes);
$target = empty($target) ? array() : array('target' => $target);
$this->_formName = $formName;
if (is_a($action, 'moodle_url')) {
$this->_pageparams = html_writer::input_hidden_params($action);
$action = $action->out_omit_querystring();
} else {
$this->_pageparams = '';
}
// No 'name' atttribute for form in xhtml strict :
$attributes = array('action' => $action, 'method' => $method, 'accept-charset' => 'utf-8') + $target;
if (is_null($this->getAttribute('id'))) {
$attributes['id'] = 'mform' . $formcounter;
}
$formcounter++;
$this->updateAttributes($attributes);
// This is custom stuff for Moodle :
$oldclass = $this->getAttribute('class');
if (!empty($oldclass)) {
$this->updateAttributes(array('class' => $oldclass . ' mform'));
} else {
$this->updateAttributes(array('class' => 'mform'));
}
$this->_reqHTML = '<img class="req" title="' . get_string('requiredelement', 'form') . '" alt="' . get_string('requiredelement', 'form') . '" src="' . $OUTPUT->pix_url('req') . '" />';
$this->_advancedHTML = '<img class="adv" title="' . get_string('advancedelement', 'form') . '" alt="' . get_string('advancedelement', 'form') . '" src="' . $OUTPUT->pix_url('adv') . '" />';
$this->setRequiredNote(get_string('somefieldsrequired', 'form', '<img alt="' . get_string('requiredelement', 'form') . '" src="' . $OUTPUT->pix_url('req') . '" />'));
}
示例9: 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);
}
示例10: HTML_Table
/**
* Class constructor
* @param array $attributes Associative array of table tag attributes
* @param int $tabOffset Tab offset of the table
* @param bool $useTGroups Whether to use <thead>, <tfoot> and
* <tbody> or not
* @access public
*/
function HTML_Table($attributes = null, $tabOffset = 0, $useTGroups = false)
{
$commonVersion = 1.7;
if (HTML_Common::apiVersion() < $commonVersion) {
return PEAR::raiseError('HTML_Table version ' . $this->apiVersion() . ' requires ' . "HTML_Common version {$commonVersion} or greater.", 0, PEAR_ERROR_TRIGGER);
}
HTML_Common::HTML_Common($attributes, (int) $tabOffset);
$this->_useTGroups = (bool) $useTGroups;
$this->_tbody = new HTML_Table_Storage($attributes, $tabOffset, $this->_useTGroups);
if ($this->_useTGroups) {
$this->_thead = new HTML_Table_Storage($attributes, $tabOffset, $this->_useTGroups);
$this->_tfoot = new HTML_Table_Storage($attributes, $tabOffset, $this->_useTGroups);
}
}
示例11: _getAttrString
/**
* Returns an HTML formatted attribute string
* Use Sigma for parsing
* @param array $attributes
* @return string
* @access private
*/
function _getAttrString($attributes)
{
$template = new \Cx\Core\Html\Sigma(ASCMS_CORE_PATH . '/Html/View/Template/Generic/');
$template->loadTemplateFile('Attribute.html');
$strAttr = '';
if (is_array($attributes)) {
$charset = HTML_Common::charset();
foreach ($attributes as $key => $value) {
$template->setVariable(array('ATTRIBUTE_NAME' => $key, 'ATTRIBUTE_VALUE' => htmlspecialchars($value, ENT_COMPAT, $charset)));
$template->parse('attribute');
}
}
return $template->get();
}
示例12: HTML_QuickForm
/**
* Class constructor
* @param string $formName Form's name.
* @param string $method (optional)Form's method defaults to 'POST'
* @param string $action (optional)Form's action
* @param string $target (optional)Form's target defaults to '_self'
* @param mixed $attributes (optional)Extra attributes for <form> tag
* @param bool $trackSubmit (optional)Whether to track if the form was submitted by adding a special hidden field
* @access public
*/
function HTML_QuickForm($formName = '', $method = 'post', $action = '', $target = '_self', $attributes = null, $trackSubmit = false)
{
HTML_Common::HTML_Common($attributes);
$method = strtoupper($method) == 'GET' ? 'get' : 'post';
$action = $action == '' ? $_SERVER['PHP_SELF'] : $action;
$target = empty($target) || $target == '_self' ? array() : array('target' => $target);
$attributes = array('action' => $action, 'method' => $method, 'name' => $formName, 'id' => $formName) + $target;
$this->updateAttributes($attributes);
if (!$trackSubmit || isset($_REQUEST['_qf__' . $formName])) {
if (1 == get_magic_quotes_gpc()) {
$this->_submitValues = $this->_recursiveFilter('stripslashes', 'get' == $method ? $_GET : $_POST);
foreach ($_FILES as $keyFirst => $valFirst) {
foreach ($valFirst as $keySecond => $valSecond) {
if ('name' == $keySecond) {
$this->_submitFiles[$keyFirst][$keySecond] = $this->_recursiveFilter('stripslashes', $valSecond);
} else {
$this->_submitFiles[$keyFirst][$keySecond] = $valSecond;
}
}
}
} else {
$this->_submitValues = 'get' == $method ? $_GET : $_POST;
$this->_submitFiles = $_FILES;
}
}
if ($trackSubmit) {
unset($this->_submitValues['_qf__' . $formName]);
$this->addElement('hidden', '_qf__' . $formName, null);
}
}
示例13: HTML_Table
/**
* Class constructor
* @param array $attributes Associative array of table tag
* attributes
* @param int $tabOffset Tab offset of the table
* @param bool $useTGroups Whether to use <thead>, <tfoot> and
* <tbody> or not
* @access public
*/
public function HTML_Table($attributes = null, $tabOffset = 0, $useTGroups = false)
{
HTML_Common::HTML_Common($attributes, (int) $tabOffset);
$this->_useTGroups = (bool) $useTGroups;
$this->addBody();
if ($this->_useTGroups) {
$this->_thead =& new HTML_Table_Storage($tabOffset, $this->_useTGroups);
$this->_tfoot =& new HTML_Table_Storage($tabOffset, $this->_useTGroups);
}
}
示例14: HTML_QuickForm
/**
* Class constructor
* @param string $formName Form's name.
* @param string $method (optional)Form's method defaults to 'POST'
* @param string $action (optional)Form's action
* @param string $target (optional)Form's target defaults to '_self'
* @param mixed $attributes (optional)Extra attributes for <form> tag
* @param bool $trackSubmit (optional)Whether to track if the form was submitted by adding a special hidden field
* @access public
*/
function HTML_QuickForm($formName = '', $method = 'post', $action = '', $target = '', $attributes = null, $trackSubmit = false)
{
HTML_Common::HTML_Common($attributes);
$method = strtoupper($method) == 'GET' ? 'get' : 'post';
$action = $action == '' ? $_SERVER['PHP_SELF'] : $action;
$target = empty($target) ? array() : array('target' => $target);
$attributes = array('action' => $action, 'method' => $method, 'name' => $formName, 'id' => $formName) + $target;
$this->updateAttributes($attributes);
if (!$trackSubmit || isset($_REQUEST['_qf__' . $formName])) {
$this->_setSubmitValues('get' == $method ? $_GET : $_POST, $_FILES);
}
if ($trackSubmit) {
unset($this->_submitValues['_qf__' . $formName]);
$this->addElement('hidden', '_qf__' . $formName, null);
}
if (preg_match('/^([0-9]+)([a-zA-Z]*)$/', ini_get('upload_max_filesize'), $matches)) {
// see http://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes
switch (strtoupper($matches['2'])) {
case 'G':
$this->_maxFileSize = $matches['1'] * 1073741824;
break;
case 'M':
$this->_maxFileSize = $matches['1'] * 1048576;
break;
case 'K':
$this->_maxFileSize = $matches['1'] * 1024;
break;
default:
$this->_maxFileSize = $matches['1'];
}
}
}
示例15: _getAttrString
/**
* Returns an HTML formatted attribute string
* @param array $attributes
* @return string
* @access private
*/
function _getAttrString($attributes)
{
$strAttr = '';
if (is_array($attributes)) {
$charset = HTML_Common::charset();
foreach ($attributes as $key => $value) {
// Modified by Ivan Tcholakov, 16-MAR-2010
//$strAttr .= ' ' . $key . '="' . htmlspecialchars($value, ENT_COMPAT, $charset) . '"';
$strAttr .= ' ' . $key . '="' . @htmlspecialchars($value, ENT_COMPAT, $charset) . '"';
//
}
}
return $strAttr;
}