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']; } } }
/** * 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); }
/** * 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 */ public function __construct($elementName = null, $elementLabel = null, $attributes = null) { parent::__construct($attributes); if (isset($elementName)) { $this->setName($elementName); } if (isset($elementLabel)) { $this->setLabel($elementLabel); } }
/** * 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()); }
/** * 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); } }
/** * 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)); }
/** * 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) { parent::__construct($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); } }
/** * 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; }
/** * 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; }
/** * 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 MoodleQuickForm($formName, $method, $action, $target = '', $attributes = null) { global $CFG; 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 : // 2007-09-04 kowy - let user of this class thinks up form name //$attributes = array('action'=>$action, 'method'=>$method, 'id'=>'mform'.$formcounter) + $target; $attributes = array('action' => $action, 'method' => $method, 'id' => $formName) + $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="' . $CFG->pixpath . '/req.gif' . '" />'; $this->_advancedHTML = '<img class="adv" title="' . get_string('advancedelement', 'form') . '" alt="' . get_string('advancedelement', 'form') . '" src="' . $CFG->pixpath . '/adv.gif' . '" />'; $this->setRequiredNote(get_string('somefieldsrequired', 'form', '<img alt="' . get_string('requiredelement', 'form') . '" src="' . $CFG->pixpath . '/req.gif' . '" />')); //(Help file doesn't add anything) helpbutton('requiredelement', get_string('requiredelement', 'form'), 'moodle', true, false, '', true)); }
/** * 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') . '" />')); }
/** * 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); }
/** * 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); } }
/** * 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(); }
/** * 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); } }
/** * 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); } }
/** * 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']; } } }
function __sleep() { $this->_defRender =& $this->defaultRenderer(); $result = parent::__sleep(); return $result; }
/** * 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; }
/** * Class constructor * * @access public */ function HTML_CSS() { $commonVersion = 1.7; if (HTML_Common::apiVersion() < $commonVersion) { return PEAR::raiseError("HTML_CSS version " . $this->apiVersion() . " requires " . "HTML_Common version 1.2 or greater.", 0, PEAR_ERROR_TRIGGER); } }
/** * 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) { $strAttr .= ' ' . $key . '="' . htmlspecialchars($value, ENT_COMPAT, $charset) . '"'; } } return $strAttr; }
/** * Returns the value of field without HTML tags * * @since 1.0 * @access public * @return string */ function getFrozenHtml() { $value = $this->getValue(); // Modified by Ivan Tcholakov, 16-MAR-2010. //return ('' != $value? htmlspecialchars($value): ' ') . // $this->_getPersistantData(); $value = ('' != $value ? @htmlspecialchars($value, ENT_COMPAT, HTML_Common::charset()) : ' ') . $this->_getPersistantData(); return '<span class="freeze">' . $value . '</span>'; // }
/** * 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 */ public function __construct($formName = '', $method = 'post', $action = '', $target = '', $attributes = null, $trackSubmit = false) { HTML_Common::HTML_Common($attributes); $method = strtoupper($method) == 'GET' ? 'get' : 'post'; // Modified by Chamilo team, 16-MAR-2010 //$action = ($action == '') ? $_SERVER['PHP_SELF'] : $action; $action = $action == '' ? api_get_self() : $action; // $target = empty($target) ? array() : array('target' => $target); $form_id = $formName; if (isset($attributes['id']) && !empty($attributes['id'])) { $form_id = Security::remove_XSS($attributes['id']); } $attributes = array('action' => $action, 'method' => $method, 'name' => $formName, 'id' => $form_id) + $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; } $this->_flagSubmitted = count($this->_submitValues) > 0 || count($this->_submitFiles) > 0; } 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']; } } $course_id = api_get_course_int_id(); //If I'm in a course replace the default max filesize with the course limits if (!empty($course_id)) { $free_course_quota = DocumentManager::get_course_quota() - DocumentManager::documents_total_space(); if (empty($this->_maxFileSize) || $free_course_quota <= $this->_maxFileSize) { $this->_maxFileSize = intval($free_course_quota); } } }
/** * Set lineend value * * Set the line end style to Windows, Mac, Unix or a custom string * * @param string $style "win", "mac", "unix" or custom string. * * @since version 1.4.0 (2007-12-13) * @access public * @return void */ function setLineEnd($style) { $this->__set('lineEnd', $style); parent::setLineEnd($style); }
/** * 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 = CRM_Utils_System::postURL($action); // $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])) { 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; } $this->_flagSubmitted = count($this->_submitValues) > 0 || count($this->_submitFiles) > 0; } 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']; } } }
/** * Class constructor * Possible attributes are: * - general options: * - "lineend" => "unix|win|mac" (Sets line ending style; defaults to unix.) * - "tab" => string (Sets line ending style; defaults to \t.) * - "cache" => "false|true" * - "charset" => charset string (Sets charset encoding; defaults to utf-8) * - "mime" => mime encoding string (Sets document mime type; defaults to text/html) * - XHTML specific: * - "doctype" => string (Sets XHTML doctype; defaults to XHTML 1.0 Transitional.) * - "language" => two letter language designation. (Defines global document language; defaults to "en".) * - "namespace" => string (Sets document namespace; defaults to the W3C defined namespace.) * * @param mixed $attributes Associative array of table tag attributes * or HTML attributes name="value" pairs * @access public */ function HTML_Page($attributes = array()) { $commonVersion = 1.7; if (HTML_Common::apiVersion() < $commonVersion) { return PEAR::raiseError("HTML_Page version " . $this->apiVersion() . " requires " . "HTML_Common version 1.2 or greater.", 0, PEAR_ERROR_TRIGGER); } if ($attributes) { $attributes = $this->_parseAttributes($attributes); } if (isset($attributes['lineend'])) { $this->setLineEnd($attributes['lineend']); } if (isset($attributes['charset'])) { $this->setCharset($attributes['charset']); } if (isset($attributes['doctype'])) { if ($attributes['doctype'] == 'none') { $this->_simple = true; } elseif ($attributes['doctype']) { $this->setDoctype($attributes['doctype']); } } if (isset($attributes['language'])) { $this->setLang($attributes['language']); } if (isset($attributes['mime'])) { $this->setMimeEncoding($attributes['mime']); } if (isset($attributes['namespace'])) { $this->setNamespace($attributes['namespace']); } if (isset($attributes['tab'])) { $this->setTab($attributes['tab']); } if (isset($attributes['cache'])) { $this->setCache($attributes['cache']); } }
/** * Returns the value of field without HTML tags (in this case, value is changed to a mask) * * @since 1.0 * @access public * @return string */ public function getFrozenHtml() { // Modified by Ivan Tcholakov, 16-MAR-2010. //$value = htmlspecialchars($this->getValue()); $value = @htmlspecialchars($this->getValue(), ENT_COMPAT, HTML_Common::charset()); // if ($this->getAttribute('wrap') == 'off') { $html = $this->_getTabs() . '<pre>' . $value . "</pre>\n"; } else { $html = nl2br($value) . "\n"; } return $html . $this->_getPersistantData(); }
/** * Builds command buttons of the Wizard. * * @return void * @since 2.1.0 * @access public */ function buildButtons($disable = null, $commands = null) { $buttons = array('back', 'next', 'cancel', 'reset', 'dump', 'apply', 'process'); if (isset($commands)) { $buttons = array_merge($buttons, $commands); } if (!isset($disable)) { $disable = array(); } elseif (!isset($disable[0])) { $disable = array($disable); } $confirm = $attributes = array('class' => 'cmdButton'); $confirm['onclick'] = "return(confirm('Are you sure ?'));"; $prevnext = array(); foreach ($buttons as $event) { switch ($event) { case 'cancel': $type = 'submit'; $attrs = $confirm; break; case 'reset': $type = 'reset'; $attrs = $confirm; break; default: $type = 'submit'; $attrs = $attributes; break; } if (in_array($event, $disable)) { $attrs['disabled'] = 'true'; } if ($event == 'dump') { $dump = $this->controller->_act[$event]; if ($dump === false) { continue; } $opts = array('1' => 'Progress2 dump info', '2' => 'Forms values container', '3' => 'Included Files', '4' => 'Declared Classes', '5' => 'Declared Actions'); $prevnext[] =& HTML_QuickForm::createElement('select', 'dumpOption', '', $opts); } $prevnext[] =& HTML_QuickForm::createElement($type, $this->getButtonName($event), ucfirst($event), HTML_Common::_getAttrString($attrs)); } $this->addGroup($prevnext, 'buttons', '', ' ', false); }
/** * Class constructor * @param int $tabOffset * @param bool $useTGroups Whether to use <thead>, <tfoot> and * <tbody> or not * @access public */ function HTML_Table_Storage($tabOffset = 0, $useTGroups = false) { HTML_Common::HTML_Common(null, (int) $tabOffset); $this->_useTGroups = (bool) $useTGroups; }
/** * Called when visiting a header element * * @param object An HTML_QuickForm_header element being visited * @access public * @return void */ function renderHeader(&$header) { $name = $header->getName(); $id = empty($name) ? '' : ' id="' . $name . '"'; if (!empty($name) && isset($this->_templates[$name])) { $header_html = str_replace('{header}', $header->toHtml(), $this->_templates[$name]); } else { $header_html = str_replace('{header}', $header->toHtml(), $this->_headerTemplate); } $attributes = $header->getAttributes(); $strAttr = ''; if (is_array($attributes)) { $charset = HTML_Common::charset(); foreach ($attributes as $key => $value) { if ($key == 'name') { continue; } $strAttr .= ' ' . $key . '="' . htmlspecialchars($value, ENT_COMPAT, $charset) . '"'; } } if ($this->_fieldsetsOpen > 0) { $this->_html .= $this->_closeFieldsetTemplate; $this->_fieldsetsOpen--; } $openFieldsetTemplate = str_replace('{id}', $id, $this->_openFieldsetTemplate); $openFieldsetTemplate = str_replace('{attributes}', $strAttr, $openFieldsetTemplate); $this->_html .= $openFieldsetTemplate . $header_html; $this->_fieldsetsOpen++; }