diff --git a/system/database/autoload.php b/system/database/autoload.php index 97c3ac3..fa9c3a9 100644 --- a/system/database/autoload.php +++ b/system/database/autoload.php @@ -47,7 +47,6 @@ final class Database { $this->createDriver(new $driverClass($hostname, $username, $password, $database)); } catch (Exception $th) { throw new Exception('Error: Could not load database file ' . $driver . '!'); - //exit('Error: Could not load database file ' . $driver . '!'); } } @@ -68,7 +67,8 @@ final class Database { /** * Check is connected on database - * @return bool */ + * @return bool + **/ public function isConnected() { return $this->driver->isConnected(); } @@ -76,7 +76,8 @@ final class Database { /** * Destroy the connection * - * @return void */ + * @return void + */ public function __destruct() { unset($this->driver); } @@ -115,7 +116,8 @@ final class Database { /** * Gets the number of rows affected by the last operation * - * @return int */ + * @return int + */ public function countAffected() { return $this->driver->countAffected(); } @@ -123,7 +125,8 @@ final class Database { /** * Gets the ID of the last inserted row or sequence of values * - * @return int|string */ + * @return int + */ public function getLastId() { return $this->driver->getLastId(); } @@ -133,7 +136,7 @@ final class Database { * @param int $pageNum_exibe * @param int $maxRows_exibe * @param bool $cache - * @param mixed|null $sqlTotal + * @param string|null $sqlTotal * @return object * @throws PhpfastcacheInvalidArgumentException */ diff --git a/system/engine/action.php b/system/engine/action.php index 1ba26ee..6b4da2a 100644 --- a/system/engine/action.php +++ b/system/engine/action.php @@ -30,6 +30,8 @@ final class Action implements ActionInterface { $pathC = ""; $parts = explode('/', str_replace('../', '', (string)$route)); + + $this->route = $route; foreach ($parts as $part) { $pathNew = $path; diff --git a/system/engine/controller.php b/system/engine/controller.php index 91eb9d2..f129a7b 100644 --- a/system/engine/controller.php +++ b/system/engine/controller.php @@ -111,6 +111,13 @@ abstract class Controller { */ public $routeOrig; + /** + * The output content type + * + * @var string + */ + public $contentType = 'text/html; charset=utf-8'; + /** * Implements constructor. * @@ -438,6 +445,8 @@ abstract class Controller { } + $this->registry->response->addHeader('Content-Type', $this->contentType); + return $this->output; } else { diff --git a/system/engine/front.php b/system/engine/front.php index 37c0621..69f0133 100644 --- a/system/engine/front.php +++ b/system/engine/front.php @@ -55,6 +55,8 @@ final class Front implements frontinterface { */ public function dispatch(\Phacil\Framework\Interfaces\Action $action, $error) { $this->error = $error; + + $this->registry->set('route', $action->getRoute()); foreach ($this->pre_action as $pre_action) { $result = $this->execute($pre_action); diff --git a/system/engine/loader.php b/system/engine/loader.php index a6eece6..e299d4a 100644 --- a/system/engine/loader.php +++ b/system/engine/loader.php @@ -181,7 +181,10 @@ final class Loader implements \Phacil\Framework\Interfaces\Loader { * @param string $language * @return mixed */ - public function language($language) { + public function language($language = null) { + + $language = ($language) ?: $this->registry->route; + return $this->language->load($language); } } diff --git a/system/engine/registry.php b/system/engine/registry.php index d2078a3..04c3a73 100644 --- a/system/engine/registry.php +++ b/system/engine/registry.php @@ -28,6 +28,12 @@ final class Registry { */ public $routeOrig; + /** + * + * @var string + */ + public $route; + /** * @param string $key * @return mixed diff --git a/system/engine/traits/action.php b/system/engine/traits/action.php index e174689..902a8cd 100644 --- a/system/engine/traits/action.php +++ b/system/engine/traits/action.php @@ -23,6 +23,12 @@ trait Action { * @var string */ protected $file; + + /** + * + * @var string + */ + private $route; /** * Storage the class to be loaded @@ -91,4 +97,8 @@ trait Action { public function getArgs() { return $this->args; } + + public function getRoute() { + return $this->route; + } } \ No newline at end of file diff --git a/system/language/autoload.php b/system/language/autoload.php new file mode 100644 index 0000000..c4babd1 --- /dev/null +++ b/system/language/autoload.php @@ -0,0 +1,41 @@ +directory = $directory; + } + + public function get($key) + { + return (isset($this->data[$key]) ? $this->data[$key] : $key); + } + + public function load($filename) + { + $file = DIR_LANGUAGE . $this->directory . '/' . $filename . '.php'; + + if (file_exists($file)) { + $_ = array(); + + require($file); + + $this->data = array_merge($this->data, $_); + + return $this->data; + } else { + trigger_error('Error: Could not load language ' . $filename . '!'); + exit(); + } + } +} diff --git a/system/pagination/autoload.php b/system/pagination/autoload.php index 6696a04..fdd0838 100644 --- a/system/pagination/autoload.php +++ b/system/pagination/autoload.php @@ -9,7 +9,7 @@ namespace Phacil\Framework; /** @package Phacil\Framework */ -final class Pagination { +class Pagination { /** *