/** * renderTemplate * * @since 3.0.0 * * @return mixed */ public static function renderTemplate() { $registry = Registry::getInstance(); $request = Request::getInstance(); $language = Language::getInstance(); /* handle notification */ if (!is_dir(self::$_configArray['directory']) && !mkdir(self::$_configArray['directory'])) { self::setNotification('error', $language->get('directory_not_found') . $language->get('colon') . ' ' . self::$_configArray['directory'] . $language->get('point')); } /* prevent as needed */ if ($request->getPost() || $registry->get('noCache')) { return false; } /* cache as needed */ $cache = new Cache(); $cache->init(self::$_configArray['directory'], self::$_configArray['extension']); $fullRoute = $registry->get('fullRoute'); /* load from cache */ if ($cache->validate($fullRoute, self::$_configArray['lifetime'])) { $raw = $cache->retrieve($fullRoute); $content = preg_replace('/' . self::$_configArray['tokenPlaceholder'] . '/', $registry->get('token'), self::_uncompress($raw)); return ['header' => function_exists('gzdeflate') ? 'content-encoding: deflate' : null, 'content' => self::_compress($content)]; } else { $raw = Template\Tag::partial('templates/' . $registry->get('template') . '/index.phtml'); $content = preg_replace('/' . $registry->get('token') . '/', self::$_configArray['tokenPlaceholder'], $raw); $cache->store($fullRoute, self::_compress($content)); return ['content' => $raw]; } }
/** * setUp * * @since 3.0.0 */ public function setUp() { $this->_registry = Registry::getInstance(); $this->_request = Request::getInstance(); $this->_config = Config::getInstance(); $this->_configArray = $this->_config->get(); }
/** * setUp * * @since 3.0.0 */ public function setUp() { $this->_registry = Registry::getInstance(); $this->_language = Language::getInstance(); $this->_request = Request::getInstance(); $this->_config = Config::getInstance(); $this->_configArray = $this->_config->get(); $this->_config->set('dbPrefix', 'controller_'); }
/** * render * * @since 2.6.0 */ public static function render() { $formElement = new Html\Form(Registry::getInstance(), Language::getInstance()); $formElement->init(array('form' => array('class' => 'js_validate_form form_default'), 'label' => array('class' => 'label'), 'textarea' => array('class' => 'js_auto_resize js_editor_textarea field_textarea'), 'input' => array('email' => array('class' => 'field_text'), 'number' => array('class' => 'field_text'), 'text' => array('class' => 'field_text'), 'url' => array('class' => 'field_text')), 'button' => array('submit' => array('class' => 'js_submit button_default', 'name' => get_class()), 'reset' => array('class' => 'js_reset button_default', 'name' => get_class()))), array('captcha' => Db::getSettings('captcha') > 0)); /* create the form */ $formElement->append('<fieldset>')->legend()->append('<ul><li>')->label('* ' . Language::get('author'), array('for' => 'author'))->text(array('id' => 'author', 'name' => 'author', 'readonly' => Registry::get('myName') ? 'readonly' : null, 'required' => 'required', 'value' => Registry::get('myName') ? Registry::get('myName') : Request::getPost('author')))->append('</li><li>')->label('* ' . Language::get('email'), array('for' => 'email'))->email(array('id' => 'email', 'name' => 'email', 'readonly' => Registry::get('myEmail') ? 'readonly' : null, 'required' => 'required', 'value' => Registry::get('myEmail') ? Registry::get('myEmail') : Request::getPost('email')))->append('</li><li>')->label(Language::get('url'), array('for' => 'url'))->url(array('id' => 'url', 'name' => 'url', 'value' => Request::getPost('url')))->append('</li><li>')->label('* ' . Language::get('message'), array('for' => 'text'))->textarea(array('id' => 'text', 'name' => 'text', 'required' => 'required', 'value' => Request::getPost('text')))->append('</li>'); if (Db::getSettings('captcha') > 0) { $formElement->append('<li>')->captcha('task')->append('</li>'); } $formElement->append('</ul></fieldset>'); if (Db::getSettings('captcha') > 0) { $formElement->captcha('solution'); } $formElement->token()->submit()->reset(); return $formElement; }
/** * setUp * * @since 2.1.0 */ protected function setUp() { $this->_registry = Registry::getInstance(); $this->_request = Request::getInstance(); }
/** * setUp * * @since 2.4.0 */ public function setUp() { $this->_registry = Registry::getInstance(); }
/** * setUp * * @since 2.6.0 */ public function setUp() { $this->_registry = Registry::getInstance(); $this->_language = Language::getInstance(); $this->_request = Request::getInstance(); }
/** * setUp * * @since 2.1.0 */ protected function setUp() { $this->_registry = Registry::getInstance(); $this->_registry->init(); }
/** * registry * * @since 2.6.0 * * @param string $key * * @return string */ public static function registry($key = null) { $registry = Registry::getInstance(); return $registry->get($key); }
/** * setUp * * @since 2.6.0 */ protected function setUp() { $this->_registry = Registry::getInstance(); $this->_language = Language::getInstance(); }
/** * testRewrite * * @since 3.0.0 * * @param array $collectionArray * @param array $rewriteArray * @param string $expect * * @dataProvider providerRewrite */ public function testRewrite($collectionArray = [], $rewriteArray = [], $expect = null) { /* setup */ $optionArray = ['directory' => Stream::url('root/cache/styles'), 'extension' => 'css', 'attribute' => 'href', 'lifetime' => 86400]; $loader = new Assetic\Loader(Registry::getInstance()); $loader->init($collectionArray, 'css')->concat($optionArray, $rewriteArray)->concat($optionArray, $rewriteArray); /* actual */ $file = $loader->getCollectionArray()['bundle']['href']; $actual = file_get_contents($file); /* compare */ $this->assertEquals($expect, $actual); }
/** * error * * @since 3.0.0 * * @return string */ protected static function _error() { $messenger = new Messenger(Registry::getInstance()); return $messenger->setRoute(Language::get('back'), 'login')->doRedirect()->error(Language::get('something_wrong'), Language::get('error_occurred')); }
/** * error * * @since 3.0.0 * * @param array $errorArray array of the error * * @return string */ protected static function _error($errorArray = []) { $messenger = new Messenger(Registry::getInstance()); return $messenger->setRoute(Language::get('home'), Registry::get('root'))->error($errorArray['message'], Language::get('error_occurred')); }
/** * get the transport * * @since 3.0.0 * * @return string */ public static function getTransport() { $transport = new Assetic\Transport(Registry::getInstance(), Language::getInstance()); return $transport->getArray(); }
/** * concat the script * * @since 3.0.0 * * @param array $optionArray * * @return Script */ public function concat($optionArray = []) { $optionArray = array_merge(self::$_optionArray, $optionArray); $loader = new Assetic\Loader(Registry::getInstance()); $loader->init(self::$_collectionArray[self::$_namespace])->concat($optionArray); /* update collection */ self::$_collectionArray[self::$_namespace] = $loader->getCollectionArray(); return $this; }