示例#1
0
 /**
  * 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];
     }
 }
示例#2
0
 /**
  * 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();
 }
示例#3
0
 /**
  * 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_');
 }
 /**
  * setUp
  *
  * @since 2.1.0
  */
 protected function setUp()
 {
     $this->_registry = Registry::getInstance();
     $this->_request = Request::getInstance();
 }
示例#5
0
 /**
  * setUp
  *
  * @since 2.6.0
  */
 public function setUp()
 {
     $this->_registry = Registry::getInstance();
     $this->_language = Language::getInstance();
     $this->_request = Request::getInstance();
 }
示例#6
0
 /**
  * console line
  *
  * @since 3.0.0
  *
  * @return string
  */
 public static function consoleLine()
 {
     $console = new Console\Console(Registry::getInstance(), Request::getInstance(), Config::getInstance());
     $output = $console->init('template');
     if (is_string($output)) {
         return htmlentities($output);
     }
 }
示例#7
0
 /**
  * setUp
  *
  * @since 2.4.0
  */
 public function setUp()
 {
     $this->_request = Request::getInstance();
 }
 /**
  * setUp
  *
  * @since 2.4.0
  */
 protected function setUp()
 {
     $this->_request = Request::getInstance();
     $this->_request->init();
 }
 /**
  * setUp
  *
  * @since 2.4.0
  */
 protected function setUp()
 {
     $this->_request = Request::getInstance();
     $this->_request->init();
     $this->_request->set('server', array('HTTP_HOST' => 'localhost', 'HTTPS' => 'off', 'SCRIPT_NAME' => '/tests/includes/Server/ServerTest.php'));
 }
示例#10
0
 /**
  * setUp
  *
  * @since 2.4.0
  */
 public function setUp()
 {
     $this->_request = Request::getInstance();
     $this->_request->set('server', ['HTTP_HOST' => 'localhost', 'HTTPS' => 'off', 'SCRIPT_NAME' => '/tests/includes/Server/ServerTest.php']);
 }
示例#11
0
 /**
  * process
  *
  * @since 3.0.0
  *
  * @return string
  */
 public static function process()
 {
     $auth = new Auth(Request::getInstance());
     $tableArray = ['categories', 'articles', 'extras', 'comments', 'groups', 'users'];
     /* set user */
     $auth->setUser('name', 'Demo');
     $auth->setUser('user', 'demo');
     $auth->setUser('email', 'demo@localhost');
     /* set permission */
     foreach ($tableArray as $value) {
         $auth->setPermission($value, [1, 2, 3]);
     }
     $auth->setPermission('settings', [1]);
     /* save user and permission */
     $auth->save();
     /* handle success */
     if ($auth->getStatus()) {
         return self::_success();
     }
     return self::_error();
 }