public function setUp() { restore_error_handler(); if (!BEAR::exists('BEAR_Session')) { BEAR::set('BEAR_Session', BEAR::factory('BEAR_Session', array('adapter' => 0, 'prefix' => ''))); } $this->_token = new BEAR_Form_Token(array()); $this->_token->onInject(); }
/** * 初期化 * * @return void */ public function init() { $appPath = $this->_getAppPath(); ob_start(); if ($appPath) { ini_set('include_path', $appPath . ':' . get_include_path()); $bearMode = $this->getBearMode($appPath); $_SERVER['bearmode'] = $bearMode; include_once "{$appPath}/App.php"; // CLI用ページをセット BEAR::set('page', new BEAR_Page_Cli(array())); } $this->_initBear(); }
/** * ファクトリー * * Quick_Formオブエクトを生成して設定します。 * * @return HTML_QuickForm */ public function factory() { $this->_config['action'] = !isset($this->_config['action']) || $this->_config['action'] == '' ? $_SERVER['REQUEST_URI'] : $this->_config['action']; $options = array('formName' => 'form', 'method' => 'post', 'action' => '', 'target' => '', 'attributes' => null, 'callback' => false); if ($this->_config) { $options = array_merge($options, $this->_config); } $page = BEAR::get('page'); $onClick = $page->getOnClick(); if ($onClick && !$options['action']) { $options['action'] = '?' . BEAR_Page::KEY_CLICK_NAME . '=' . $onClick; } // フォーム名の登録 self::$formNames[] = $formName = $options['formName']; // $formObject生成 $options['trackSubmit'] = true; $formObject = $this->_factory($formName, $options); BEAR::set('BEAR_Form_' . $formName, $formObject); self::$method = $options['method']; // set render form $page = BEAR::get('page'); $page->setConfig('redner_form', true); self::$_renderConfig[$formName] = $this->_config; // extra elements $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES']['bcheckbox'] = array(_BEAR_BEAR_HOME . '/BEAR/Form/elements/bcheckbox.php', 'HTML_QuickForm_bcheckbox'); $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES']['bradio'] = array(_BEAR_BEAR_HOME . '/BEAR/Form/elements/bradio.php', 'HTML_QuickForm_bradio'); return $formObject; }
<?php restore_error_handler(); error_reporting(E_ALL); // set path $bearPath = realpath(dirname(__DIR__)); $bearDemoPath = __DIR__ . '/sites/beardemo.local'; $pandaPath = dirname(__DIR__) . '/vendors/Panda'; // set autoloder set_include_path($bearPath . PATH_SEPARATOR . $bearDemoPath . PATH_SEPARATOR . $pandaPath . PATH_SEPARATOR . get_include_path()); spl_autoload_register('bearTestAutolodaer'); BEAR::set('page', new BEAR_Page_Cli(array())); function bearTestAutolodaer($class) { $file = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php'; include_once $file; }
/** * Inject * * @return void */ public function onInject() { // ページを生成してレジストリにセット $config = array('resource_id' => $this->_config['page_class'], 'enable_ua_sniffing' => $this->_config['enable_ua_sniffing'], 'ua' => $this->_config['ua'], 'mode' => BEAR_Page::CONFIG_MODE_HTML); $options = array('injector' => isset($this->_config['injector']) ? $this->_config['injector'] : 'onInject'); $this->_page = BEAR::factory($this->_config['page_class'], $config, $options); BEAR::set('page', $this->_page); $this->_log = BEAR::dependency('BEAR_Log'); $this->_roPrototype = BEAR::dependency('BEAR_Ro_Prototype'); }
/** * ページャーリンクの登録 * * ページャーリンクのHTMLとメタ情報を'pager'というキーでサービスに登録します。 * 登録済みの場合は何もしません。 * * @param array $links * @param array $info * * @return BEAR_Pager */ public function setPagerLinks(array $links, array $info) { if (!BEAR::exists('pager')) { BEAR::set('pager', new ArrayObject(array('links' => $links, 'info' => $info))); } return $this; }