Completed
Push — master ( 4de0c7...bc53b5 )
by Jean-Christophe
06:49
created
Ajax/php/ci/JsUtils.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,39 +1,39 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace Ajax\php\ci;
3 3
 
4
-class JsUtils extends \Ajax\JsUtils{
4
+class JsUtils extends \Ajax\JsUtils {
5 5
 	protected $ci;
6
-	protected $_my_controller_paths= array();
7
-	protected $_my_controllers= array();
6
+	protected $_my_controller_paths=array();
7
+	protected $_my_controllers=array();
8 8
 
9
-	public function __construct($params=array(),$injected=NULL){
10
-		parent::__construct($params,$injected);
11
-		$this->_my_controller_paths = array(APPPATH);
9
+	public function __construct($params=array(), $injected=NULL) {
10
+		parent::__construct($params, $injected);
11
+		$this->_my_controller_paths=array(APPPATH);
12 12
 	}
13
-	public function getUrl($url){
13
+	public function getUrl($url) {
14 14
 		return site_url($url);
15 15
 	}
16 16
 
17
-	public function getCi(){
18
-		if(isset($this->ci)===false){
19
-			$this->ci =& get_instance();
17
+	public function getCi() {
18
+		if (isset($this->ci)===false) {
19
+			$this->ci=& get_instance();
20 20
 			$this->ci->load->helper('url');
21 21
 		}
22 22
 		return $this->ci;
23 23
 	}
24 24
 
25
-	public function addViewElement($identifier,$content,&$view){
26
-		if(\array_key_exists("q", $view)===false){
25
+	public function addViewElement($identifier, $content, &$view) {
26
+		if (\array_key_exists("q", $view)===false) {
27 27
 			$view["q"]=array();
28 28
 		}
29 29
 		$view["q"][$identifier]=$content;
30 30
 	}
31 31
 
32
-	public function createScriptVariable(&$view,$view_var, $output){
32
+	public function createScriptVariable(&$view, $view_var, $output) {
33 33
 		$view[$view_var]=$output;
34 34
 	}
35 35
 
36
-	public function forward($initialControllerInstance,$controllerName,$actionName,$params=NULL){
36
+	public function forward($initialControllerInstance, $controllerName, $actionName, $params=NULL) {
37 37
 		$ci=$this->getCi();
38 38
 		$controllerName=strtolower($controllerName);
39 39
 		$this->controller($controllerName);
@@ -44,64 +44,64 @@  discard block
 block discarded – undo
44 44
 		return $result;
45 45
 	}
46 46
 
47
-	public function renderContent($initialControllerInstance,$viewName, $params=NULL) {
47
+	public function renderContent($initialControllerInstance, $viewName, $params=NULL) {
48 48
 		return $initialControllerInstance->load->view($viewName, $params, true);
49 49
 	}
50 50
 
51
-	public function fromDispatcher($dispatcher){
51
+	public function fromDispatcher($dispatcher) {
52 52
 		return array_values($dispatcher->uri->segment_array());
53 53
 	}
54 54
 
55
-	public function controller($controller, $name = '', $db_conn = FALSE){
56
-		if (is_array($controller)){
57
-			foreach ($controller as $babe){
55
+	public function controller($controller, $name='', $db_conn=FALSE) {
56
+		if (is_array($controller)) {
57
+			foreach ($controller as $babe) {
58 58
 				$this->controller($babe);
59 59
 			}
60 60
 			return;
61 61
 		}
62
-		if ($controller == ''){
62
+		if ($controller=='') {
63 63
 			return;
64 64
 		}
65
-		$path = '';
65
+		$path='';
66 66
 		// Is the controller in a sub-folder? If so, parse out the filename and path.
67
-		if (($last_slash = strrpos($controller, '/')) !== FALSE){
67
+		if (($last_slash=strrpos($controller, '/'))!==FALSE) {
68 68
 			// The path is in front of the last slash
69
-			$path = substr($controller, 0, $last_slash + 1);
69
+			$path=substr($controller, 0, $last_slash+1);
70 70
 			// And the controller name behind it
71
-			$controller = substr($controller, $last_slash + 1);
71
+			$controller=substr($controller, $last_slash+1);
72 72
 		}
73 73
 
74
-		if ($name == ''){
75
-			$name = $controller;
74
+		if ($name=='') {
75
+			$name=$controller;
76 76
 		}
77 77
 
78
-		if (in_array($name, $this->_my_controllers, TRUE)){
78
+		if (in_array($name, $this->_my_controllers, TRUE)) {
79 79
 			return;
80 80
 		}
81 81
 
82
-		$CI =$this->getCi();
83
-		if (isset($CI->$name)){
82
+		$CI=$this->getCi();
83
+		if (isset($CI->$name)) {
84 84
 			show_error('The controller name you are loading is the name of a resource that is already being used: '.$name);
85 85
 		}
86
-		$controller = strtolower($controller);
87
-		foreach ($this->_my_controller_paths as $mod_path){
88
-			if ( ! file_exists($mod_path.'controllers/'.$path.$controller.'.php')){
86
+		$controller=strtolower($controller);
87
+		foreach ($this->_my_controller_paths as $mod_path) {
88
+			if (!file_exists($mod_path.'controllers/'.$path.$controller.'.php')) {
89 89
 				continue;
90 90
 			}
91
-			if ($db_conn !== FALSE AND ! class_exists('CI_DB')){
92
-				if ($db_conn === TRUE){
93
-					$db_conn = '';
91
+			if ($db_conn!==FALSE AND !class_exists('CI_DB')) {
92
+				if ($db_conn===TRUE) {
93
+					$db_conn='';
94 94
 				}
95 95
 				$CI->load->database($db_conn, FALSE, TRUE);
96 96
 			}
97
-			if ( ! class_exists('CI_Controller')){
97
+			if (!class_exists('CI_Controller')) {
98 98
 				load_class('Controller', 'core');
99 99
 			}
100 100
 			require_once($mod_path.'controllers/'.$path.$controller.'.php');
101
-			$controller = ucfirst($controller);
102
-			$CI->$name = new $controller();
101
+			$controller=ucfirst($controller);
102
+			$CI->$name=new $controller();
103 103
 
104
-			$this->_my_controllers[] = $name;
104
+			$this->_my_controllers[]=$name;
105 105
 			return;
106 106
 		}
107 107
 		show_error('Unable to locate the controller you have specified: '.$controller);
Please login to merge, or discard this patch.