@@ -12,7 +12,7 @@ |
||
| 12 | 12 | $this->data['userLevel'] = 'Admin'; |
| 13 | 13 | } elseif ($this->auth->isUser()) { |
| 14 | 14 | $this->data['userLevel'] = 'User'; |
| 15 | - } else { |
|
| 15 | + }else { |
|
| 16 | 16 | $this->alertbox->setAlert("Not Admin", 'warning'); |
| 17 | 17 | $this->alertbox->setAlert("TESTING", 'error'); |
| 18 | 18 | $this->container->getResponse()->redirect(); |
@@ -8,22 +8,22 @@ |
||
| 8 | 8 | |
| 9 | 9 | //all the connects will finaly be got it a single function grabbed from the DB / Session. |
| 10 | 10 | //this is just for testing purposes until the core framework is finished |
| 11 | - public function connectAdmin(){ |
|
| 11 | + public function connectAdmin() { |
|
| 12 | 12 | $this->session->set('session_level', 'Admin'); |
| 13 | 13 | $this->container->getResponse()->redirect(); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - public function connectUser(){ |
|
| 16 | + public function connectUser() { |
|
| 17 | 17 | $this->session->set('session_level', 'User'); |
| 18 | 18 | $this->container->getResponse()->redirect(); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function connectVisitor(){ |
|
| 21 | + public function connectVisitor() { |
|
| 22 | 22 | $this->session->set('session_level', 'Shit'); //just ot override any other setting, and fun !!! |
| 23 | 23 | $this->container->getResponse()->redirect(); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function disconnect(){ |
|
| 26 | + public function disconnect() { |
|
| 27 | 27 | $this->container->getSession()->unsetAll(); |
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | \ No newline at end of file |
@@ -22,8 +22,8 @@ |
||
| 22 | 22 | $data = []; |
| 23 | 23 | //get the categories from database |
| 24 | 24 | $categories = $this->getResultSet('categories'); |
| 25 | - foreach ( $categories as $category) { |
|
| 26 | - $data +=[ |
|
| 25 | + foreach ($categories as $category) { |
|
| 26 | + $data += [ |
|
| 27 | 27 | $category['category_name'] => '/category/'.$category['idcategories'] |
| 28 | 28 | ]; |
| 29 | 29 | } |
@@ -9,7 +9,7 @@ |
||
| 9 | 9 | * Class JsonException |
| 10 | 10 | * @package Core |
| 11 | 11 | */ |
| 12 | -class JsonException extends \Exception{ |
|
| 12 | +class JsonException extends \Exception { |
|
| 13 | 13 | |
| 14 | 14 | public function __construct(string $message = "", int $code = 0, Throwable $previous = null) |
| 15 | 15 | { |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | $viewData['showErrors'] = true; //sending the config option down to twig |
| 67 | 67 | $viewData['classException'] = get_class($exception); |
| 68 | 68 | $viewData['stackTrace'] = $exception->getTraceAsString(); |
| 69 | - $viewData['thrownIn'] = $exception->getFile() . " On line " . $exception->getLine(); |
|
| 69 | + $viewData['thrownIn'] = $exception->getFile()." On line ".$exception->getLine(); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $container = new Container(); |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | //Making sure that the twig template renders correctly. |
| 75 | 75 | try { |
| 76 | 76 | $twig = $container->getTemplate(); |
| 77 | - $twig->display('ErrorPages/' . $code . '.twig', $viewData); |
|
| 77 | + $twig->display('ErrorPages/'.$code.'.twig', $viewData); |
|
| 78 | 78 | } catch (\Exception $e) { |
| 79 | - echo 'Twig Error : ' . $e->getMessage(); |
|
| 79 | + echo 'Twig Error : '.$e->getMessage(); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | |
@@ -102,7 +102,7 @@ |
||
| 102 | 102 | 500 => '500 Internal Server Error' |
| 103 | 103 | ); |
| 104 | 104 | // ok, validation error, or failure |
| 105 | - header('Status: ' . $status[$code]); |
|
| 105 | + header('Status: '.$status[$code]); |
|
| 106 | 106 | // return the encoded json |
| 107 | 107 | return json_encode(array( |
| 108 | 108 | 'status' => $code < 300, // success or not? |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | //We load all our module objects into our object |
| 54 | 54 | foreach ($this->loadModules as $loadModule) { |
| 55 | - $loadModuleObj = 'Core\\Modules\\' . $loadModule; |
|
| 55 | + $loadModuleObj = 'Core\\Modules\\'.$loadModule; |
|
| 56 | 56 | |
| 57 | 57 | $loadModuleName = strtolower($loadModule); |
| 58 | 58 | $loadedModule = new $loadModuleObj($this->container); |
| 59 | - if(!is_subclass_of($loadedModule,'Core\Modules\Module')){ |
|
| 59 | + if (!is_subclass_of($loadedModule, 'Core\Modules\Module')) { |
|
| 60 | 60 | throw new \ErrorException('Modules musit be a sub class of module'); |
| 61 | 61 | } |
| 62 | 62 | $this->$loadModuleName = $loadedModule; |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | $this->data['csrf_token'] = $this->csrf->getCsrfKey(); //storing the security id into the data array to be sent to the view and added in the meta head |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function index(){ |
|
| 70 | + public function index() { |
|
| 71 | 71 | //if no index, then redirect to the home page or throw an error if in dev; just for debugging purposes |
| 72 | - if(Config::DEV_ENVIRONMENT){ |
|
| 72 | + if (Config::DEV_ENVIRONMENT) { |
|
| 73 | 73 | throw new \ErrorException("no index() available in controller call"); |
| 74 | 74 | } |
| 75 | 75 | $this->container->getResponse()->redirect(); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | public function getView($template) |
| 88 | 88 | { |
| 89 | 89 | $twig = $this->container->getTemplate(); |
| 90 | - return $twig->render($template . '.twig', $this->data); |
|
| 90 | + return $twig->render($template.'.twig', $this->data); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -105,6 +105,6 @@ discard block |
||
| 105 | 105 | $this->data['alert_messages'] = $this->alertbox->getAlerts(); |
| 106 | 106 | } |
| 107 | 107 | $twig = $this->container->getTemplate(); |
| 108 | - $twig->display($template . '.twig', $this->data); |
|
| 108 | + $twig->display($template.'.twig', $this->data); |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | \ No newline at end of file |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | if ($table == null) { |
| 117 | 117 | $reflect = new \ReflectionClass(get_class($this)); |
| 118 | 118 | $table = $reflect->getShortName(); //this is to only get the model name, otherwise we get the full namespace |
| 119 | - $table = $table . 's'; //adding the s since the table should be plural. Might be some special case where the plural isn't just with an s |
|
| 119 | + $table = $table.'s'; //adding the s since the table should be plural. Might be some special case where the plural isn't just with an s |
|
| 120 | 120 | $table = strtolower($table); //the database names are in lowercase |
| 121 | 121 | } |
| 122 | 122 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | //if we are here, then table doesn't exist, check for view |
| 136 | - $view = 'v_' . $table; |
|
| 136 | + $view = 'v_'.$table; |
|
| 137 | 137 | $stmt->bindValue(':table', $view, PDO::PARAM_STR); |
| 138 | 138 | $stmt->execute(); |
| 139 | 139 | $exists = $stmt->rowCount() > 0; //will return 1 if table exists or 0 if non existant |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | protected function getRowById($rowId, $table = ''): array |
| 213 | 213 | { |
| 214 | 214 | $tableName = $this->getTable($table); |
| 215 | - $idName = 'id' . $tableName; |
|
| 215 | + $idName = 'id'.$tableName; |
|
| 216 | 216 | $sql = "SELECT * FROM $tableName WHERE $idName = :rowId"; |
| 217 | 217 | $this->query($sql); |
| 218 | 218 | $this->bind(':rowId', $rowId); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $specialNamespace = array_shift($url); |
| 68 | 68 | |
| 69 | 69 | //making sure we have a single backslash |
| 70 | - $specialNamespace = rtrim($specialNamespace, '\\') . '\\'; |
|
| 70 | + $specialNamespace = rtrim($specialNamespace, '\\').'\\'; |
|
| 71 | 71 | |
| 72 | 72 | //capitalize the special namespace |
| 73 | 73 | $specialNamespace = $this->convertToStudlyCaps($specialNamespace); |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | { |
| 102 | 102 | |
| 103 | 103 | $url = $this->container->getRequest()->getData('url'); |
| 104 | - if($url){ |
|
| 104 | + if ($url) { |
|
| 105 | 105 | //remove right slash |
| 106 | 106 | $url = rtrim($url, '/'); |
| 107 | 107 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | { |
| 134 | 134 | |
| 135 | 135 | //try to create the controller object |
| 136 | - $fullControllerName = $this->currentNamespace . $this->currentController; |
|
| 136 | + $fullControllerName = $this->currentNamespace.$this->currentController; |
|
| 137 | 137 | |
| 138 | 138 | //make sure the class exists before continuing |
| 139 | 139 | if (!class_exists($fullControllerName)) { |