public function testUniqueIdsGeneratedWithoutIndexes() { HTML_Common2::setOption('id_force_append_index', false); $this->testUniqueIdsGenerated(); }
* @license http://opensource.org/licenses/bsd-license.php New BSD License * @link http://pear.php.net/package/HTML_QuickForm2 */ /** * HTML_Common2 - base class for HTML elements */ require_once 'HTML/Common2.php'; // By default, we generate element IDs with numeric indexes appended even for // elements with unique names. If you want IDs to be equal to the element // names by default, set this configuration option to false. if (null === HTML_Common2::getOption('id_force_append_index')) { HTML_Common2::setOption('id_force_append_index', true); } // set the default language for various elements' messages if (null === HTML_Common2::getOption('language')) { HTML_Common2::setOption('language', 'en'); } /** * Exception classes for HTML_QuickForm2 */ require_once 'HTML/QuickForm2/Exception.php'; /** * Static factory class for QuickForm2 elements */ require_once 'HTML/QuickForm2/Factory.php'; /** * Base class for HTML_QuickForm2 rules */ require_once 'HTML/QuickForm2/Rule.php'; /** * Abstract base class for all QuickForm2 Elements and Containers
public function testAnyOptionAllowed() { HTML_Common2::setOption('foobar', 'baz'); $this->assertEquals('baz', HTML_Common2::getOption('foobar')); }
<?php /** * @package Am_Form */ if (!defined('INCLUDED_AMEMBER_CONFIG')) { die("Direct access to this location is not allowed"); } HTML_Common2::setOption('charset', 'UTF-8'); /** * Adds the following functionality to QF2 forms: * - adds submit detecition * - adds init() method support * - adds JqueryValidation rendering */ class Am_Form extends HTML_QuickForm2 { protected $width; protected static $_usedIds = array(); protected $prolog = null; protected $epilog = null; function __construct($id = null, $attributes = null, $method = 'post') { $this->addFilter(array(__CLASS__, '_trimArray')); if ($id === null) { $id = get_class($this); } $i = 0; $suggestId = $id; while (isset(self::$_usedIds[$suggestId])) { $suggestId = $id . '-' . ++$i;
* @package HTML_QuickForm2 * @author Alexey Borzov <*****@*****.**> * @author Bertrand Mansion <*****@*****.**> * @license http://opensource.org/licenses/bsd-license.php New BSD License * @version SVN: $Id: Node.php 306085 2010-12-08 19:43:59Z avb $ * @link http://pear.php.net/package/HTML_QuickForm2 */ /** * HTML_Common2 - base class for HTML elements */ require_once 'HTML/Common2.php'; // By default, we generate element IDs with numeric indexes appended even for // elements with unique names. If you want IDs to be equal to the element // names by default, set this configuration option to false. if (null === HTML_Common2::getOption('id_force_append_index')) { HTML_Common2::setOption('id_force_append_index', true); } /** * Exception classes for HTML_QuickForm2 */ require_once 'HTML/QuickForm2/Exception.php'; /** * Static factory class for QuickForm2 elements */ require_once 'HTML/QuickForm2/Factory.php'; /** * Base class for HTML_QuickForm2 rules */ require_once 'HTML/QuickForm2/Rule.php'; /** * Abstract base class for all QuickForm2 Elements and Containers
/** * Class constructor * * Sets the $config data from the primary config.php file as a class variable. * * @return void */ public function __construct() { $this->config =& get_config(); // Added by Ivan Tcholakov, 20-JAN-2014. // Load additional configuration data for languages. $c = array(); $config = array(); if (file_exists(COMMONPATH . 'config/lang.php')) { require COMMONPATH . 'config/lang.php'; $c = array_replace_recursive($c, $config); $config = array(); } if (file_exists(COMMONPATH . 'config/' . ENVIRONMENT . '/lang.php')) { require COMMONPATH . 'config/' . ENVIRONMENT . '/lang.php'; $c = array_replace_recursive($c, $config); $config = array(); } if (file_exists(APPPATH . 'config/lang.php')) { require APPPATH . 'config/lang.php'; $c = array_replace_recursive($c, $config); $config = array(); } if (file_exists(APPPATH . 'config/' . ENVIRONMENT . '/lang.php')) { require APPPATH . 'config/' . ENVIRONMENT . '/lang.php'; $c = array_replace_recursive($c, $config); $config = array(); } $c['hide_default_uri_segment'] = !empty($c['hide_default_uri_segment']); $languages = isset($c['languages']) && is_array($c['languages']) ? $c['languages'] : array(); foreach ($languages as $key => $value) { if (!isset($value['direction'])) { $languages[$key]['direction'] = 'ltr'; } if (!isset($value['uri_segment'])) { $languages[$key]['uri_segment'] = $value['code']; } } $c['languages'] = $languages; $c['default_language'] = $this->config['language']; if (!isset($c['enabled_languages']) && !is_array($c['enabled_languages'])) { $c['enabled_languages'] = array($c['default_language']); } if (!in_array($c['default_language'], $c['enabled_languages'])) { $c['enabled_languages'][] = $c['default_language']; } $this->config = array_replace_recursive($this->config, $c); // global $DETECT_URL; // Set the base_url automatically if none was provided if (empty($this->config['base_url'])) { $this->set_item('base_url', $DETECT_URL['base_url']); } else { $this->set_item('base_url', http_build_url($this->config['base_url'], array('scheme' => $DETECT_URL['server_protocol'], 'port' => $DETECT_URL['port']))); } if (!defined('BASE_URL')) { define('BASE_URL', $this->add_slash($this->base_url())); } if (!defined('BASE_URI')) { define('BASE_URI', $DETECT_URL['base_uri']); } if (!defined('SERVER_URL')) { define('SERVER_URL', $this->add_slash(substr(BASE_URL, 0, strlen(BASE_URL) - strlen(BASE_URI)))); } if (!defined('SITE_URL')) { define('SITE_URL', $this->add_slash($this->site_url())); } if (!defined('SITE_URI')) { define('SITE_URI', '/' . str_replace(SERVER_URL, '', SITE_URL)); } if (!defined('CURRENT_URI')) { define('CURRENT_URI', $DETECT_URL['current_uri']); } if (!defined('CURRENT_URL')) { define('CURRENT_URL', rtrim(SERVER_URL, '/') . CURRENT_URI); } if (!defined('CURRENT_URL_IS_HTTPS')) { define('CURRENT_URL_IS_HTTPS', $DETECT_URL['is_https']); } if (!defined('CURRENT_URL_PROTOCOL')) { define('CURRENT_URL_PROTOCOL', $DETECT_URL['server_protocol']); } if (!defined('CURRENT_URL_HOST')) { define('CURRENT_URL_HOST', $DETECT_URL['server_name']); } if (!defined('CURRENT_URL_PORT')) { define('CURRENT_URL_PORT', $DETECT_URL['port']); } if (!defined('CURRENT_URI_STRING')) { define('CURRENT_URI_STRING', $DETECT_URL['current_uri_string']); } if (!defined('CURRENT_QUERY_STRING')) { define('CURRENT_QUERY_STRING', $DETECT_URL['current_query_string']); } // Added by Ivan Tcholakov, 13-JAN-2014. if (!defined('DEFAULT_BASE_URL')) { if (APPSEGMENT != '') { define('DEFAULT_BASE_URL', preg_replace('/' . preg_quote($this->add_slash(APPSEGMENT), '/') . '$/', '', BASE_URL)); } else { define('DEFAULT_BASE_URL', BASE_URL); } } // // Added by Ivan Tcholakov, 13-JAN-2014. if (!defined('DEFAULT_BASE_URI')) { if (APPSEGMENT != '') { define('DEFAULT_BASE_URI', preg_replace('/' . preg_quote($this->add_slash(APPSEGMENT), '/') . '$/', '', BASE_URI)); } else { define('DEFAULT_BASE_URI', BASE_URI); } } // // Added by Ivan Tcholakov, 26-DEC-2013. // See https://github.com/EllisLab/CodeIgniter/issues/2792 if (!defined('IS_UTF8_CHARSET')) { define('IS_UTF8_CHARSET', strtolower($this->config['charset']) === 'utf-8'); } // // Added by Ivan Tcholakov, 02-JAN-2016. HTML_Common2::setOption('charset', $this->config['charset']); // // Common Purpose File System Repositories $public_upload_path = $this->add_slash(isset($this->config['public_upload_path']) && $this->config['public_upload_path'] != '' ? $this->config['public_upload_path'] : DEFAULTFCPATH . 'upload/'); $this->set_item('public_upload_path', $public_upload_path); if (!defined('PUBLIC_UPLOAD_PATH')) { define('PUBLIC_UPLOAD_PATH', $public_upload_path); } $public_upload_url = $this->add_slash(isset($this->config['public_upload_url']) && $this->config['public_upload_url'] != '' ? str_replace(array('{default_base_url}', '{base_url}'), array(DEFAULT_BASE_URL, BASE_URL), $this->config['public_upload_url']) : DEFAULT_BASE_URL . 'upload/'); $this->set_item('public_upload_url', $public_upload_url); if (!defined('PUBLIC_UPLOAD_URL')) { define('PUBLIC_UPLOAD_URL', $public_upload_url); } $platform_upload_path = $this->add_slash(isset($this->config['platform_upload_path']) && $this->config['platform_upload_path'] != '' ? $this->config['platform_upload_path'] : PLATFORMPATH . 'upload/'); $this->set_item('platform_upload_path', $platform_upload_path); if (!defined('PLATFORM_UPLOAD_PATH')) { define('PLATFORM_UPLOAD_PATH', $platform_upload_path); } // Assets $c = array(); $config = array(); if (file_exists(COMMONPATH . 'config/asset.php')) { require COMMONPATH . 'config/asset.php'; $c = array_replace_recursive($c, $config); $config = array(); } if (file_exists(COMMONPATH . 'config/' . ENVIRONMENT . '/asset.php')) { require COMMONPATH . 'config/' . ENVIRONMENT . '/asset.php'; $c = array_replace_recursive($c, $config); $config = array(); } if (file_exists(APPPATH . 'config/asset.php')) { require APPPATH . 'config/asset.php'; $c = array_replace_recursive($c, $config); $config = array(); } if (file_exists(APPPATH . 'config/' . ENVIRONMENT . '/asset.php')) { require APPPATH . 'config/' . ENVIRONMENT . '/asset.php'; $c = array_replace_recursive($c, $config); $config = array(); } if (!defined('ASSET_URL')) { define('ASSET_URL', $this->add_slash($c['asset_url'])); } if (!defined('ASSET_URI')) { define('ASSET_URI', $this->add_slash($c['asset_dir'])); } if (!defined('THEME_ASSET_URL')) { define('THEME_ASSET_URL', $this->add_slash($c['theme_asset_url'])); } if (!defined('THEME_ASSET_URI')) { define('THEME_ASSET_URI', $this->add_slash($c['theme_asset_dir'])); } if (!defined('ASSET_IMG_URL')) { define('ASSET_IMG_URL', ASSET_URL . $this->add_slash($c['asset_img_dir'])); } if (!defined('ASSET_IMG_URI')) { define('ASSET_IMG_URI', ASSET_URI . $this->add_slash($c['asset_img_dir'])); } if (!defined('ASSET_JS_URL')) { define('ASSET_JS_URL', ASSET_URL . $this->add_slash($c['asset_js_dir'])); } if (!defined('ASSET_JS_URI')) { define('ASSET_JS_URI', ASSET_URI . $this->add_slash($c['asset_js_dir'])); } if (!defined('ASSET_CSS_URL')) { define('ASSET_CSS_URL', ASSET_URL . $this->add_slash($c['asset_css_dir'])); } if (!defined('ASSET_CSS_URI')) { define('ASSET_CSS_URI', ASSET_URI . $this->add_slash($c['asset_css_dir'])); } if (!defined('THEME_IMG_URL')) { define('THEME_IMG_URL', THEME_ASSET_URL . $this->add_slash($c['asset_img_dir'])); } if (!defined('THEME_IMG_URI')) { define('THEME_IMG_URI', THEME_ASSET_URI . $this->add_slash($c['asset_img_dir'])); } if (!defined('THEME_JS_URL')) { define('THEME_JS_URL', THEME_ASSET_URL . $this->add_slash($c['asset_js_dir'])); } if (!defined('THEME_JS_URI')) { define('THEME_JS_URI', THEME_ASSET_URI . $this->add_slash($c['asset_js_dir'])); } if (!defined('THEME_CSS_URL')) { define('THEME_CSS_URL', THEME_ASSET_URL . $this->add_slash($c['asset_css_dir'])); } if (!defined('THEME_CSS_URI')) { define('THEME_CSS_URI', THEME_ASSET_URI . $this->add_slash($c['asset_css_dir'])); } log_message('info', 'Config Class Initialized'); }