| @@ -5,8 +5,8 @@ discard block | ||
| 5 | 5 | protected $pages; | 
| 6 | 6 | protected $defaultPage; | 
| 7 | 7 | protected $urlCaseSensitive; | 
| 8 | -    public function __construct( $_path, $_urlCaseSensitive = false ) { | |
| 9 | - if(!is_string($_path)) | |
| 8 | +    public function __construct($_path, $_urlCaseSensitive = false) { | |
| 9 | + if (!is_string($_path)) | |
| 10 | 10 |          throw new JException("Parameter must be a string."); | 
| 11 | 11 | $jConfig = new JConfig($_path); | 
| 12 | 12 | $server = new ServerVars(); | 
| @@ -23,8 +23,8 @@ discard block | ||
| 23 | 23 | $pageSelected = null; | 
| 24 | 24 |        foreach ($this->pages as $page) { | 
| 25 | 25 |          $urlParameters = $this->pathSeeker(explode("/", $page[0]), $this->url); | 
| 26 | -        if(is_array($urlParameters)) { | |
| 27 | - if(isset($page[2]) && is_array($page[2])) | |
| 26 | +        if (is_array($urlParameters)) { | |
| 27 | + if (isset($page[2]) && is_array($page[2])) | |
| 28 | 28 | $urlParameters = array_merge($urlParameters, $page[2]); | 
| 29 | 29 | $pageSelected = [ | 
| 30 | 30 | $page[1], | 
| @@ -33,28 +33,28 @@ discard block | ||
| 33 | 33 | break; | 
| 34 | 34 | } | 
| 35 | 35 | } | 
| 36 | - if( $pageSelected !== null ) | |
| 36 | + if ($pageSelected !== null) | |
| 37 | 37 | return $pageSelected; | 
| 38 | 38 | else | 
| 39 | 39 | return $this->defaultPage; | 
| 40 | 40 | } | 
| 41 | -    protected function pathSeeker( $_path, $_url ) { | |
| 41 | +    protected function pathSeeker($_path, $_url) { | |
| 42 | 42 | $urlLength = count($_url); | 
| 43 | 43 | $cont = 0; | 
| 44 | 44 | $variables = []; | 
| 45 | 45 | $pathLength = count($_path); | 
| 46 | -      if($urlLength == $pathLength) { | |
| 47 | -        while($cont < $urlLength) { | |
| 48 | - if( | |
| 46 | +      if ($urlLength == $pathLength) { | |
| 47 | +        while ($cont < $urlLength) { | |
| 48 | + if ( | |
| 49 | 49 | ($this->urlCaseSensitive && $_path[$cont] == $_url[$cont]) || | 
| 50 | 50 | (!$this->urlCaseSensitive && strtolower($_path[$cont]) == strtolower($_url[$cont])) ) | 
| 51 | 51 | $cont++; | 
| 52 | -          else if( strpos($_path[$cont], "\$") !== false ) { | |
| 52 | +          else if (strpos($_path[$cont], "\$") !== false) { | |
| 53 | 53 |              $variables[str_replace('$', "", $_path[$cont])] = $_url[$cont]; | 
| 54 | 54 | $cont++; | 
| 55 | 55 | } else break; | 
| 56 | 56 | } | 
| 57 | - if($cont == $urlLength) | |
| 57 | + if ($cont == $urlLength) | |
| 58 | 58 | return $variables; | 
| 59 | 59 | } | 
| 60 | 60 | return null; | 
| @@ -21,13 +21,13 @@ discard block | ||
| 21 | 21 | "base" => "" | 
| 22 | 22 | ]; | 
| 23 | 23 | } | 
| 24 | -    public function setParameters( $_parameters = [ "app" => null, "page" => null] ) { | |
| 24 | +    public function setParameters($_parameters = ["app" => null, "page" => null]) { | |
| 25 | 25 | $this->app = $_parameters["app"]; | 
| 26 | 26 | $this->page = $_parameters["page"]; | 
| 27 | 27 | } | 
| 28 | 28 | abstract public function init(); | 
| 29 | 29 |      public function draw() { | 
| 30 | - if($this->template == "") | |
| 30 | + if ($this->template == "") | |
| 31 | 31 |          throw new JException("The variable \$this->template must be set in class $this->name function init()."); | 
| 32 | 32 | $server = new ServerVars(); | 
| 33 | 33 | $this->addDipendences(); | 
| @@ -38,23 +38,23 @@ discard block | ||
| 38 | 38 | return jBlockFile($this->template, $this->tags); | 
| 39 | 39 | } | 
| 40 | 40 |      public function getCss() { | 
| 41 | -      return $this->getRequire("getCss",".css"); | |
| 41 | +      return $this->getRequire("getCss", ".css"); | |
| 42 | 42 | } | 
| 43 | 43 |      public function getJs() { | 
| 44 | -      return $this->getRequire("getJs",".js"); | |
| 44 | +      return $this->getRequire("getJs", ".js"); | |
| 45 | 45 | } | 
| 46 | 46 |      public function getJsVars() { | 
| 47 | 47 | return $this->jsVars; | 
| 48 | 48 | } | 
| 49 | -    public function addJsVar( $_name, $_value ) { | |
| 50 | - if(!is_string($_name)) | |
| 49 | +    public function addJsVar($_name, $_value) { | |
| 50 | + if (!is_string($_name)) | |
| 51 | 51 |          throw new InvalidArgumentException("Parameter name must be a string."); | 
| 52 | - if(!is_string($_value)) | |
| 52 | + if (!is_string($_value)) | |
| 53 | 53 |          throw new InvalidArgumentException("Parameter value must be a string."); | 
| 54 | 54 | $this->jsVars[] = [$_name, $_value]; | 
| 55 | 55 | } | 
| 56 | -    public function addJsVars( $_array ) { | |
| 57 | - if(!is_array($_array)) | |
| 56 | +    public function addJsVars($_array) { | |
| 57 | + if (!is_array($_array)) | |
| 58 | 58 |          throw new InvalidArgumentException("Parameter must be an array."); | 
| 59 | 59 | foreach ($_array as $value) | 
| 60 | 60 | $this->addJsVar($value[0], $value[1]); | 
| @@ -83,7 +83,7 @@ discard block | ||
| 83 | 83 | $this->tags["js"] = $this->getJs(); | 
| 84 | 84 | $this->tags["jsVar"] = $this->getJsVars(); | 
| 85 | 85 | } | 
| 86 | -    protected function getRequire( $_function, $_extenction) { | |
| 86 | +    protected function getRequire($_function, $_extenction) { | |
| 87 | 87 | $temp = []; | 
| 88 | 88 | $filesRequired = $this->getFilesRequired(); | 
| 89 | 89 | $files = $this->getFiles(); | 
| @@ -91,7 +91,7 @@ discard block | ||
| 91 | 91 | if (!is_array($i) && strpos($i, $_extenction) !== FALSE) | 
| 92 | 92 | $temp[] = $i; | 
| 93 | 93 | foreach ($this->modules as $i) | 
| 94 | - $temp = array_merge( $temp, $i->$_function() ); | |
| 94 | + $temp = array_merge($temp, $i->$_function()); | |
| 95 | 95 | foreach ($files as $i) | 
| 96 | 96 | if (!is_array($i) && strpos($i, $_extenction) !== FALSE) | 
| 97 | 97 | $temp[] = $i; | 
| @@ -16,19 +16,19 @@ | ||
| 16 | 16 | $this->__queryConstruct(); | 
| 17 | 17 | $this->__fileConstruct(); | 
| 18 | 18 | } | 
| 19 | -    public function addModules( $_modules ) { | |
| 20 | - if(!is_array($_modules)) | |
| 19 | +    public function addModules($_modules) { | |
| 20 | + if (!is_array($_modules)) | |
| 21 | 21 |          throw new JException("Parameter must be an array."); | 
| 22 | 22 | foreach ($_modules as $value) | 
| 23 | 23 | $this->addModule($value); | 
| 24 | 24 | } | 
| 25 | -    public function addModule( $_module ) { | |
| 26 | - if(!is_object($_module)) | |
| 25 | +    public function addModule($_module) { | |
| 26 | + if (!is_object($_module)) | |
| 27 | 27 |          throw new JException("Parameter must be a object."); | 
| 28 | - if(! is_subclass_of ($_module, "Module")) | |
| 28 | + if (!is_subclass_of($_module, "Module")) | |
| 29 | 29 |          throw new JException("Parameter must be a object inherited from Module object."); | 
| 30 | 30 | $this->modules[$_module->name] = $_module; | 
| 31 | - if($this->currentConnection) | |
| 31 | + if ($this->currentConnection) | |
| 32 | 32 | $this->modules[$_module->name]->addConnectionMan($this->currentConnection); | 
| 33 | 33 | } | 
| 34 | 34 | } | 
| @@ -1,18 +1,18 @@ | ||
| 1 | 1 | <?php | 
| 2 | 2 |    class JConfig { | 
| 3 | -    public function __construct( $_path ) { | |
| 4 | - if(!is_string($_path)) | |
| 3 | +    public function __construct($_path) { | |
| 4 | + if (!is_string($_path)) | |
| 5 | 5 |          throw new JException("Path must be a string."); | 
| 6 | - if(!file_exists($_path)) | |
| 6 | + if (!file_exists($_path)) | |
| 7 | 7 |          throw new JException("File [$_path] not found."); | 
| 8 | 8 | $data = file_get_contents($_path); | 
| 9 | 9 | $data = json_decode($data); | 
| 10 | - if($data === NULL) | |
| 10 | + if ($data === NULL) | |
| 11 | 11 |          throw new JException("Invalid file data. [$_path]"); | 
| 12 | - if(is_object($data)) | |
| 12 | + if (is_object($data)) | |
| 13 | 13 | foreach (get_object_vars($data) as $key => $value) | 
| 14 | 14 | $this->$key = $value; | 
| 15 | - if(is_array($data)) | |
| 15 | + if (is_array($data)) | |
| 16 | 16 | $this->data = $data; | 
| 17 | 17 | } | 
| 18 | 18 | } | 
| @@ -3,8 +3,8 @@ discard block | ||
| 3 | 3 |    class Connection { | 
| 4 | 4 | public $database; | 
| 5 | 5 | public $info; | 
| 6 | -    public function __construct( $_object ) { | |
| 7 | - if(!is_object($_object)) | |
| 6 | +    public function __construct($_object) { | |
| 7 | + if (!is_object($_object)) | |
| 8 | 8 |          throw new InvalidArgumentException("Parameter must be an object."); | 
| 9 | 9 | $this->setConnection( | 
| 10 | 10 | $_object->server, | 
| @@ -14,7 +14,7 @@ discard block | ||
| 14 | 14 | $this->getConnectionType($_object->engine) | 
| 15 | 15 | ); | 
| 16 | 16 | } | 
| 17 | -    protected function setConnection ( $_srv, $_db, $_usr, $_pass, $_type ) { | |
| 17 | +    protected function setConnection($_srv, $_db, $_usr, $_pass, $_type) { | |
| 18 | 18 |        switch ($_type) { | 
| 19 | 19 | case "mysqli": | 
| 20 | 20 | $this->database = new MysqliAdapter($_srv, $_db, $_usr, $_pass); | 
| @@ -38,10 +38,10 @@ discard block | ||
| 38 | 38 | "type" => $_type | 
| 39 | 39 | ]; | 
| 40 | 40 | } | 
| 41 | -    protected function getConnectionType( $_type ) { | |
| 42 | - $array = (array)$_type; | |
| 41 | +    protected function getConnectionType($_type) { | |
| 42 | + $array = (array) $_type; | |
| 43 | 43 | foreach ($array as $key => $value) | 
| 44 | - if($value) | |
| 44 | + if ($value) | |
| 45 | 45 | return $key; | 
| 46 | 46 | return "pdo"; | 
| 47 | 47 | } |