Completed
Push — master ( 8edafe...cb9f87 )
by Charles
08:15
created
protected/commands/CiiCacheCommand.php 2 patches
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 Yii::import('cii.commands.CiiConsoleCommand');
4
-class CiiCacheCommand extends CiiConsoleCommand
5
-{
6
-    public function actionFlush()
7
-    {
4
+class CiiCacheCommand extends CiiConsoleCommand
5
+{
6
+    public function actionFlush()
7
+    {
8 8
         $this->log(Yii::app()->cache->flush() ? "Cache flushed" : "Unable to flush cache. Are we connected?");
9 9
         unlink(__DIR__.DS.'..'.DS.'runtime'.DS.'modules.config.php');
10 10
         return;
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-Yii::import('cii.commands.CiiConsoleCommand');
3
+Yii::import ('cii.commands.CiiConsoleCommand');
4 4
 class CiiCacheCommand extends CiiConsoleCommand
5 5
 {
6
-    public function actionFlush()
6
+    public function actionFlush ()
7 7
     {
8
-        $this->log(Yii::app()->cache->flush() ? "Cache flushed" : "Unable to flush cache. Are we connected?");
9
-        unlink(__DIR__.DS.'..'.DS.'runtime'.DS.'modules.config.php');
8
+        $this->log (Yii::app ()->cache->flush () ? "Cache flushed" : "Unable to flush cache. Are we connected?");
9
+        unlink (__DIR__.DS.'..'.DS.'runtime'.DS.'modules.config.php');
10 10
         return;
11 11
     }
12 12
 }
Please login to merge, or discard this patch.
protected/commands/CiiClassMapCommand.php 2 patches
Braces   +11 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 Yii::import('cii.commands.CiiConsoleCommand');
4
-class CiiClassMapCommand extends CiiConsoleCommand
5
-{
6
-    public function actionIndex()
7
-    {
4
+class CiiClassMapCommand extends CiiConsoleCommand
5
+{
6
+    public function actionIndex()
7
+    {
8 8
         $data = "<?php\n";
9 9
         $data .= '$basePath = dirname(__FILE__) . \'/..\';' . "\n";
10 10
         $data .= 'Yii::$classMap = ' . "array(\n";
@@ -21,16 +21,17 @@  discard block
 block discarded – undo
21 21
         return;
22 22
     }
23 23
 
24
-    private function updateDataPath($path, &$data)
25
-    {
24
+    private function updateDataPath($path, &$data)
25
+    {
26 26
         $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
27 27
         foreach($objects as $name => $object)
28 28
         {
29 29
             if (strpos($name, '.php') !== false && strpos($name, 'gii') === false)
30 30
             {
31 31
                 $id = str_replace('.php', '', substr( $name, strrpos( $name, '/' )+1 ));
32
-                if ($this->startsWithUpper($id))
33
-                    $data .=  "    '" . $id . "' => " . '$basePath . \'' . str_replace('/var/www/ciims/protected', '', $name) . "',\n";
32
+                if ($this->startsWithUpper($id)) {
33
+                                    $data .=  "    '" . $id . "' => " . '$basePath . \'' . str_replace('/var/www/ciims/protected', '', $name) . "',\n";
34
+                }
34 35
             }
35 36
         }
36 37
 
@@ -40,8 +41,8 @@  discard block
 block discarded – undo
40 41
     /**
41 42
      * @param string $str
42 43
      */
43
-    private function startsWithUpper($str)
44
-    {
44
+    private function startsWithUpper($str)
45
+    {
45 46
         $chr = mb_substr ($str, 0, 1, "UTF-8");
46 47
         return mb_strtolower($chr, "UTF-8") != $chr;
47 48
     }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,36 +1,36 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-Yii::import('cii.commands.CiiConsoleCommand');
3
+Yii::import ('cii.commands.CiiConsoleCommand');
4 4
 class CiiClassMapCommand extends CiiConsoleCommand
5 5
 {
6
-    public function actionIndex()
6
+    public function actionIndex ()
7 7
     {
8 8
         $data = "<?php\n";
9
-        $data .= '$basePath = dirname(__FILE__) . \'/..\';' . "\n";
10
-        $data .= 'Yii::$classMap = ' . "array(\n";
9
+        $data .= '$basePath = dirname(__FILE__) . \'/..\';'."\n";
10
+        $data .= 'Yii::$classMap = '."array(\n";
11 11
 
12
-        $this->updateDataPath(Yii::getPathOfAlias('ext'), $data);
13
-        $this->updateDataPath( Yii::getPathOfAlias('application.models'), $data);
14
-        $this->updateDataPath(Yii::getPathOfAlias('application.controllers'), $data);
12
+        $this->updateDataPath (Yii::getPathOfAlias ('ext'), $data);
13
+        $this->updateDataPath (Yii::getPathOfAlias ('application.models'), $data);
14
+        $this->updateDataPath (Yii::getPathOfAlias ('application.controllers'), $data);
15 15
 
16
-        $data .=  ");\n";
16
+        $data .= ");\n";
17 17
 
18
-        $handle = fopen(Yii::getPathOfAlias('application.config') . DIRECTORY_SEPARATOR . 'classmap.php', 'w+');
19
-        fwrite($handle, $data);
20
-        fclose($handle);
18
+        $handle = fopen (Yii::getPathOfAlias ('application.config').DIRECTORY_SEPARATOR.'classmap.php', 'w+');
19
+        fwrite ($handle, $data);
20
+        fclose ($handle);
21 21
         return;
22 22
     }
23 23
 
24
-    private function updateDataPath($path, &$data)
24
+    private function updateDataPath ($path, &$data)
25 25
     {
26
-        $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
27
-        foreach($objects as $name => $object)
26
+        $objects = new RecursiveIteratorIterator (new RecursiveDirectoryIterator ($path), RecursiveIteratorIterator::SELF_FIRST);
27
+        foreach ($objects as $name => $object)
28 28
         {
29
-            if (strpos($name, '.php') !== false && strpos($name, 'gii') === false)
29
+            if (strpos ($name, '.php') !== false && strpos ($name, 'gii') === false)
30 30
             {
31
-                $id = str_replace('.php', '', substr( $name, strrpos( $name, '/' )+1 ));
32
-                if ($this->startsWithUpper($id))
33
-                    $data .=  "    '" . $id . "' => " . '$basePath . \'' . str_replace('/var/www/ciims/protected', '', $name) . "',\n";
31
+                $id = str_replace ('.php', '', substr ($name, strrpos ($name, '/') + 1));
32
+                if ($this->startsWithUpper ($id))
33
+                    $data .= "    '".$id."' => ".'$basePath . \''.str_replace ('/var/www/ciims/protected', '', $name)."',\n";
34 34
             }
35 35
         }
36 36
 
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
     /**
41 41
      * @param string $str
42 42
      */
43
-    private function startsWithUpper($str)
43
+    private function startsWithUpper ($str)
44 44
     {
45 45
         $chr = mb_substr ($str, 0, 1, "UTF-8");
46
-        return mb_strtolower($chr, "UTF-8") != $chr;
46
+        return mb_strtolower ($chr, "UTF-8") != $chr;
47 47
     }
48 48
 }
49 49
 
Please login to merge, or discard this patch.
protected/commands/CiiMessageCommand.php 3 patches
Indentation   +332 added lines, -332 removed lines patch added patch discarded remove patch
@@ -6,336 +6,336 @@  discard block
 block discarded – undo
6 6
 class CiiMessageCommand extends CiiConsoleCommand
7 7
 {
8 8
 
9
-	/**
10
-	 * The configuration object
11
-	 * @var array _$config
12
-	 */
13
-	private $_config = array();
14
-
15
-	/**
16
-	 * The messages that should be translated
17
-	 * @var array $_messages
18
-	 */
19
-	private $_messages = array();
20
-
21
-	/**
22
-	 * The stirng that should be used for translations
23
-	 * @var string $_translator
24
-	 */
25
-	private $_translator = 'Yii::t';
26
-
27
-	/**
28
-	 * Default args
29
-	 * @return array
30
-	 */
31
-	private function getArgs()
32
-	{
33
-		return array(
34
-			'type'			=> 'core',
35
-			'sourcePath'	=> Yii::getPathOfAlias('application').DS,
36
-			'messagePath'	=> Yii::getPathOfAlias('application.messages').DS,
37
-			'languages'		=> array('en_us'),
38
-			'fileTypes'		=> array('php'),
39
-			'overwrite'		=> true,
40
-			'sort'			=> true,
41
-			'removeOld'		=> false,
42
-			'exclude'		=> array(
43
-				'assets',
44
-				'css',
45
-				'js',
46
-				'images',
47
-				'.svn',
48
-				'.gitignore',
49
-				'.git',
50
-				'yiilite.php',
51
-				'yiit.php',
52
-				'i18n/data',
53
-				'messages',
54
-				'vendor',
55
-				'tests',
56
-				'runtime'
57
-			)
58
-		);
59
-	}
60
-
61
-	/**
62
-	 * Init method
63
-	 */
64
-	public function init()
65
-	{
66
-		$this->_config = $this->getArgs();
67
-	}
68
-
69
-	/**
70
- 	 * Generates translation files for a given mtheme
71
-	 * @param string $name 	The name of the theme to generate translations for
72
-	 */
73
-	public function actionThemes($name=NULL)
74
-	{
75
-		if ($name === NULL)
76
-			$this->usageError('A theme was not specified for translations');
77
-
78
-		$this->_config['type'] = 'theme';
79
-		array_push($this->_config['exclude'], 'modules');
80
-		$this->_config['sourcePath'] .= '..'.DS.'themes' . DS . $name . DS;
81
-		$this->_config['messagePath'] = $this->_config['sourcePath'].'messages';
82
-		$this->execute();
83
-	}
84
-
85
-	/**
86
- 	 * Generates translation files for a given module
87
-	 * @param string $name 	The name of the module to generate translations for
88
-	 */
89
-	public function actionModules($name=NULL)
90
-	{
91
-		if ($name === NULL)
92
-			$this->usageError('A module was not specified for translations');
93
-
94
-		$this->_config['type'] = 'module';
95
-		array_push($this->_config['exclude'], 'themes');
96
-		unset($this->_config['exclude']['modules']);
97
-		$this->_config['sourcePath'] = Yii::getPathOfAlias('application.modules') . DS . $name . DS;
98
-		$this->_config['messagePath'] = $this->_config['sourcePath'].'messages';
99
-		$this->execute($this->_config);
100
-	}
101
-
102
-	/**
103
- 	 * Defualt action
104
-	 */
105
-	public function actionIndex()
106
-	{
107
-		array_push($this->_config['exclude'], 'modules');
108
-		array_push($this->_config['exclude'], 'themes');
109
-		return $this->execute();
110
-	}
111
-
112
-	/**
113
-	 * Execute the action.
114
-	 */
115
-	private function execute()
116
-	{
117
-		// Validate the configuration
118
-		extract($this->_config);
119
-		$this->validateConfig();
120
-
121
-		// Determine the messages
122
-		foreach($this->getFiles() as $file)
123
-			$this->_messages = array_merge_recursive($this->_messages,$this->extractMessages($file,$this->_translator));
124
-
125
-		foreach($languages as $language)
126
-		{
127
-			$dir = $messagePath.DS.$language;
128
-
129
-			$this->createDirectory($dir);
130
-
131
-			foreach ($this->_messages as $category=>$msgs)
132
-			{
133
-				$msgs = array_values(array_unique($msgs));
134
-
135
-				$dir = $this->_config['messagePath'].DS.$language;
136
-
137
-				if ($this->_config['type']  == 'theme')
138
-				{
139
-					$data = explode('.', $category);
140
-					unset($data[0]);
141
-					$dirPath = implode(DS, $data);
142
-				}
143
-				else if ($this->_config['type'] == 'module')
144
-				{
145
-					$data = explode('.', $category);
146
-					unset($data[0]);
147
-					unset($data[1]);
148
-					$dirPath = implode(DS, $data);
149
-				}
150
-				else
151
-					$dirPath = implode(DS, explode('.', $category));
152
-
153
-				if (empty($dirPath))
154
-					continue;
155
-
156
-				$this->createDirectory($dir . DS . $dirPath);
157
-				$this->createDirectory($dir . DS . $language);
158
-
159
-				$this->generateMessageFile($msgs,$dir.DS.$dirPath.'.php',$overwrite,$removeOld,$sort);
160
-			}
161
-		}
162
-	}
163
-
164
-	/**
165
-	 * Creates a directory at the given path
166
-	 * @param string $directory
167
-	 * @return boolean
168
-	 */
169
-	private function createDirectory($directory)
170
-	{
171
-		if (!is_dir($directory)) 
172
-		{
173
-			if (!mkdir($directory, 0777, true))
174
-				$this->usageError('The directory ' . $directory .' could not be created. Please make sure this process has write access to this directory.');
175
-		}
176
-
177
-		return true;
178
-	}
179
-
180
-	/**
181
-	 * Retrieves the files that should be translated
182
-	 * @return array $files
183
-	 */
184
-	private function getFiles()
185
-	{
186
-		extract($this->_config);
187
-		$files = CFileHelper::findFiles(realpath($sourcePath),array(
188
-					'fileTypes' => $fileTypes,
189
-					'exclude'	=> $exclude
190
-				 ));
191
-
192
-		// Strip out all extensions
193
-		foreach ($files as $k=>$file)
194
-		{
195
-			if (strpos($file, 'extensions') !== false)
196
-				unset($files[$k]);
197
-		}
198
-
199
-		reset($files);
200
-
201
-		return $files;
202
-	}
203
-
204
-	/**
205
-	 * Does basic validation on the configuration options
206
-	 */
207
-	private function validateConfig()
208
-	{
209
-		extract($this->_config);
210
-
211
-		if(!isset($sourcePath,$messagePath,$languages))
212
-			$this->usageError('The configuration file must specify "sourcePath", "messagePath" and "languages".');
213
-
214
-		if(!is_dir($sourcePath))
215
-			$this->usageError("The source path $sourcePath is not a valid directory.");
216
-
217
-		if(!is_dir($messagePath))
218
-			$this->usageError("The message path $messagePath is not a valid directory.");
219
-
220
-		if(empty($languages))
221
-			$this->usageError("Languages cannot be empty.");
222
-	}
223
-
224
-	/**
225
-	 * @param string $translator
226
-	 */
227
-	protected function extractMessages($fileName,$translator)
228
-	{
229
-		$subject=file_get_contents($fileName);
230
-		$messages=array();
231
-		if(!is_array($translator))
232
-			$translator=array($translator);
233
-
234
-		foreach ($translator as $currentTranslator)
235
-		{
236
-			$n=preg_match_all('/\b'.$currentTranslator.'\s*\(\s*(\'[\w.\/]*?(?<!\.)\'|"[\w.]*?(?<!\.)")\s*,\s*(\'.*?(?<!\\\\)\'|".*?(?<!\\\\)")\s*[,\)]/s',$subject,$matches,PREG_SET_ORDER);
237
-
238
-			for($i=0; $i<$n; ++$i)
239
-			{
240
-				if(($pos=strpos($matches[$i][1],'.'))!==false)
241
-				{
242
-					if (strpos($matches[$i][1],'Dashboard')!==false || strpos($matches[$i][1],'Hybridauth')!==false || strpos($matches[$i][1],'Install')!==false)
243
-						$category='module.'.substr($matches[$i][1],1,-1);
244
-					else if (strpos($matches[$i][1],'Theme')!==false)
245
-						$category=$matches[$i][1];
246
-					else
247
-						$category=substr($matches[$i][1],$pos+1,-1);
248
-				}
249
-				else
250
-					$category=substr($matches[$i][1],1,-1);
251
-
252
-
253
-				$message=$matches[$i][2];
254
-
255
-				$category = str_replace("'", '', $category);
256
-
257
-				// This is how Yii does it
258
-				$messages[$category][]=eval("return $message;");  // use eval to eliminate quote escape
259
-			}
260
-		}
261
-
262
-		return $messages;
263
-	}
264
-
265
-	/**
266
-	 * @param string $fileName
267
-	 * @param boolean $overwrite
268
-	 * @param boolean $removeOld
269
-	 * @param boolean $sort
270
-	 */
271
-	protected function generateMessageFile($messages,$fileName,$overwrite,$removeOld,$sort)
272
-	{
273
-		echo "Saving messages to $fileName...";
274
-		if(is_file($fileName))
275
-		{
276
-			$translated=require($fileName);
277
-			sort($messages);
278
-			ksort($translated);
279
-			if(array_keys($translated)==$messages)
280
-			{
281
-				echo "nothing new...skipped.\n";
282
-				return;
283
-			}
284
-
285
-			$merged=array();
286
-			$untranslated=array();
287
-
288
-			foreach($messages as $message)
289
-			{
290
-				if(array_key_exists($message,$translated) && strlen($translated[$message])>0)
291
-					$merged[$message]=$translated[$message];
292
-				else
293
-					$untranslated[]=$message;
294
-			}
295
-
296
-			ksort($merged);
297
-			sort($untranslated);
298
-			$todo=array();
299
-
300
-			foreach($untranslated as $message)
301
-				$todo[$message]='';
302
-
303
-			ksort($translated);
304
-
305
-			foreach($translated as $message=>$translation)
306
-			{
307
-				if(!isset($merged[$message]) && !isset($todo[$message]) && !$removeOld)
308
-				{
309
-					if(substr($translation,0,2)==='@@' && substr($translation,-2)==='@@')
310
-						$todo[$message]=$translation;
311
-					else if ($translation == '')
312
-						$todo[$message] = '';
313
-					else
314
-						$todo[$message]='@@'.$translation.'@@';
315
-				}
316
-			}
317
-
318
-			$merged=array_merge($todo,$merged);
319
-
320
-			if($sort)
321
-				ksort($merged);
322
-
323
-			if($overwrite === false)
324
-				$fileName.='.merged';
325
-
326
-			echo "translation merged.\n";
327
-		}
328
-		else
329
-		{
330
-			$merged=array();
331
-			foreach($messages as $message)
332
-				$merged[$message]='';
333
-
334
-			ksort($merged);
335
-			echo "saved.\n";
336
-		}
337
-		$array=str_replace("\r",'',var_export($merged,true));
338
-		$content=<<<EOD
9
+    /**
10
+     * The configuration object
11
+     * @var array _$config
12
+     */
13
+    private $_config = array();
14
+
15
+    /**
16
+     * The messages that should be translated
17
+     * @var array $_messages
18
+     */
19
+    private $_messages = array();
20
+
21
+    /**
22
+     * The stirng that should be used for translations
23
+     * @var string $_translator
24
+     */
25
+    private $_translator = 'Yii::t';
26
+
27
+    /**
28
+     * Default args
29
+     * @return array
30
+     */
31
+    private function getArgs()
32
+    {
33
+        return array(
34
+            'type'			=> 'core',
35
+            'sourcePath'	=> Yii::getPathOfAlias('application').DS,
36
+            'messagePath'	=> Yii::getPathOfAlias('application.messages').DS,
37
+            'languages'		=> array('en_us'),
38
+            'fileTypes'		=> array('php'),
39
+            'overwrite'		=> true,
40
+            'sort'			=> true,
41
+            'removeOld'		=> false,
42
+            'exclude'		=> array(
43
+                'assets',
44
+                'css',
45
+                'js',
46
+                'images',
47
+                '.svn',
48
+                '.gitignore',
49
+                '.git',
50
+                'yiilite.php',
51
+                'yiit.php',
52
+                'i18n/data',
53
+                'messages',
54
+                'vendor',
55
+                'tests',
56
+                'runtime'
57
+            )
58
+        );
59
+    }
60
+
61
+    /**
62
+     * Init method
63
+     */
64
+    public function init()
65
+    {
66
+        $this->_config = $this->getArgs();
67
+    }
68
+
69
+    /**
70
+     * Generates translation files for a given mtheme
71
+     * @param string $name 	The name of the theme to generate translations for
72
+     */
73
+    public function actionThemes($name=NULL)
74
+    {
75
+        if ($name === NULL)
76
+            $this->usageError('A theme was not specified for translations');
77
+
78
+        $this->_config['type'] = 'theme';
79
+        array_push($this->_config['exclude'], 'modules');
80
+        $this->_config['sourcePath'] .= '..'.DS.'themes' . DS . $name . DS;
81
+        $this->_config['messagePath'] = $this->_config['sourcePath'].'messages';
82
+        $this->execute();
83
+    }
84
+
85
+    /**
86
+     * Generates translation files for a given module
87
+     * @param string $name 	The name of the module to generate translations for
88
+     */
89
+    public function actionModules($name=NULL)
90
+    {
91
+        if ($name === NULL)
92
+            $this->usageError('A module was not specified for translations');
93
+
94
+        $this->_config['type'] = 'module';
95
+        array_push($this->_config['exclude'], 'themes');
96
+        unset($this->_config['exclude']['modules']);
97
+        $this->_config['sourcePath'] = Yii::getPathOfAlias('application.modules') . DS . $name . DS;
98
+        $this->_config['messagePath'] = $this->_config['sourcePath'].'messages';
99
+        $this->execute($this->_config);
100
+    }
101
+
102
+    /**
103
+     * Defualt action
104
+     */
105
+    public function actionIndex()
106
+    {
107
+        array_push($this->_config['exclude'], 'modules');
108
+        array_push($this->_config['exclude'], 'themes');
109
+        return $this->execute();
110
+    }
111
+
112
+    /**
113
+     * Execute the action.
114
+     */
115
+    private function execute()
116
+    {
117
+        // Validate the configuration
118
+        extract($this->_config);
119
+        $this->validateConfig();
120
+
121
+        // Determine the messages
122
+        foreach($this->getFiles() as $file)
123
+            $this->_messages = array_merge_recursive($this->_messages,$this->extractMessages($file,$this->_translator));
124
+
125
+        foreach($languages as $language)
126
+        {
127
+            $dir = $messagePath.DS.$language;
128
+
129
+            $this->createDirectory($dir);
130
+
131
+            foreach ($this->_messages as $category=>$msgs)
132
+            {
133
+                $msgs = array_values(array_unique($msgs));
134
+
135
+                $dir = $this->_config['messagePath'].DS.$language;
136
+
137
+                if ($this->_config['type']  == 'theme')
138
+                {
139
+                    $data = explode('.', $category);
140
+                    unset($data[0]);
141
+                    $dirPath = implode(DS, $data);
142
+                }
143
+                else if ($this->_config['type'] == 'module')
144
+                {
145
+                    $data = explode('.', $category);
146
+                    unset($data[0]);
147
+                    unset($data[1]);
148
+                    $dirPath = implode(DS, $data);
149
+                }
150
+                else
151
+                    $dirPath = implode(DS, explode('.', $category));
152
+
153
+                if (empty($dirPath))
154
+                    continue;
155
+
156
+                $this->createDirectory($dir . DS . $dirPath);
157
+                $this->createDirectory($dir . DS . $language);
158
+
159
+                $this->generateMessageFile($msgs,$dir.DS.$dirPath.'.php',$overwrite,$removeOld,$sort);
160
+            }
161
+        }
162
+    }
163
+
164
+    /**
165
+     * Creates a directory at the given path
166
+     * @param string $directory
167
+     * @return boolean
168
+     */
169
+    private function createDirectory($directory)
170
+    {
171
+        if (!is_dir($directory)) 
172
+        {
173
+            if (!mkdir($directory, 0777, true))
174
+                $this->usageError('The directory ' . $directory .' could not be created. Please make sure this process has write access to this directory.');
175
+        }
176
+
177
+        return true;
178
+    }
179
+
180
+    /**
181
+     * Retrieves the files that should be translated
182
+     * @return array $files
183
+     */
184
+    private function getFiles()
185
+    {
186
+        extract($this->_config);
187
+        $files = CFileHelper::findFiles(realpath($sourcePath),array(
188
+                    'fileTypes' => $fileTypes,
189
+                    'exclude'	=> $exclude
190
+                    ));
191
+
192
+        // Strip out all extensions
193
+        foreach ($files as $k=>$file)
194
+        {
195
+            if (strpos($file, 'extensions') !== false)
196
+                unset($files[$k]);
197
+        }
198
+
199
+        reset($files);
200
+
201
+        return $files;
202
+    }
203
+
204
+    /**
205
+     * Does basic validation on the configuration options
206
+     */
207
+    private function validateConfig()
208
+    {
209
+        extract($this->_config);
210
+
211
+        if(!isset($sourcePath,$messagePath,$languages))
212
+            $this->usageError('The configuration file must specify "sourcePath", "messagePath" and "languages".');
213
+
214
+        if(!is_dir($sourcePath))
215
+            $this->usageError("The source path $sourcePath is not a valid directory.");
216
+
217
+        if(!is_dir($messagePath))
218
+            $this->usageError("The message path $messagePath is not a valid directory.");
219
+
220
+        if(empty($languages))
221
+            $this->usageError("Languages cannot be empty.");
222
+    }
223
+
224
+    /**
225
+     * @param string $translator
226
+     */
227
+    protected function extractMessages($fileName,$translator)
228
+    {
229
+        $subject=file_get_contents($fileName);
230
+        $messages=array();
231
+        if(!is_array($translator))
232
+            $translator=array($translator);
233
+
234
+        foreach ($translator as $currentTranslator)
235
+        {
236
+            $n=preg_match_all('/\b'.$currentTranslator.'\s*\(\s*(\'[\w.\/]*?(?<!\.)\'|"[\w.]*?(?<!\.)")\s*,\s*(\'.*?(?<!\\\\)\'|".*?(?<!\\\\)")\s*[,\)]/s',$subject,$matches,PREG_SET_ORDER);
237
+
238
+            for($i=0; $i<$n; ++$i)
239
+            {
240
+                if(($pos=strpos($matches[$i][1],'.'))!==false)
241
+                {
242
+                    if (strpos($matches[$i][1],'Dashboard')!==false || strpos($matches[$i][1],'Hybridauth')!==false || strpos($matches[$i][1],'Install')!==false)
243
+                        $category='module.'.substr($matches[$i][1],1,-1);
244
+                    else if (strpos($matches[$i][1],'Theme')!==false)
245
+                        $category=$matches[$i][1];
246
+                    else
247
+                        $category=substr($matches[$i][1],$pos+1,-1);
248
+                }
249
+                else
250
+                    $category=substr($matches[$i][1],1,-1);
251
+
252
+
253
+                $message=$matches[$i][2];
254
+
255
+                $category = str_replace("'", '', $category);
256
+
257
+                // This is how Yii does it
258
+                $messages[$category][]=eval("return $message;");  // use eval to eliminate quote escape
259
+            }
260
+        }
261
+
262
+        return $messages;
263
+    }
264
+
265
+    /**
266
+     * @param string $fileName
267
+     * @param boolean $overwrite
268
+     * @param boolean $removeOld
269
+     * @param boolean $sort
270
+     */
271
+    protected function generateMessageFile($messages,$fileName,$overwrite,$removeOld,$sort)
272
+    {
273
+        echo "Saving messages to $fileName...";
274
+        if(is_file($fileName))
275
+        {
276
+            $translated=require($fileName);
277
+            sort($messages);
278
+            ksort($translated);
279
+            if(array_keys($translated)==$messages)
280
+            {
281
+                echo "nothing new...skipped.\n";
282
+                return;
283
+            }
284
+
285
+            $merged=array();
286
+            $untranslated=array();
287
+
288
+            foreach($messages as $message)
289
+            {
290
+                if(array_key_exists($message,$translated) && strlen($translated[$message])>0)
291
+                    $merged[$message]=$translated[$message];
292
+                else
293
+                    $untranslated[]=$message;
294
+            }
295
+
296
+            ksort($merged);
297
+            sort($untranslated);
298
+            $todo=array();
299
+
300
+            foreach($untranslated as $message)
301
+                $todo[$message]='';
302
+
303
+            ksort($translated);
304
+
305
+            foreach($translated as $message=>$translation)
306
+            {
307
+                if(!isset($merged[$message]) && !isset($todo[$message]) && !$removeOld)
308
+                {
309
+                    if(substr($translation,0,2)==='@@' && substr($translation,-2)==='@@')
310
+                        $todo[$message]=$translation;
311
+                    else if ($translation == '')
312
+                        $todo[$message] = '';
313
+                    else
314
+                        $todo[$message]='@@'.$translation.'@@';
315
+                }
316
+            }
317
+
318
+            $merged=array_merge($todo,$merged);
319
+
320
+            if($sort)
321
+                ksort($merged);
322
+
323
+            if($overwrite === false)
324
+                $fileName.='.merged';
325
+
326
+            echo "translation merged.\n";
327
+        }
328
+        else
329
+        {
330
+            $merged=array();
331
+            foreach($messages as $message)
332
+                $merged[$message]='';
333
+
334
+            ksort($merged);
335
+            echo "saved.\n";
336
+        }
337
+        $array=str_replace("\r",'',var_export($merged,true));
338
+        $content=<<<EOD
339 339
 <?php
340 340
 /**
341 341
  * Message translations.
@@ -357,6 +357,6 @@  discard block
 block discarded – undo
357 357
 return $array;
358 358
 
359 359
 EOD;
360
-		file_put_contents($fileName, $content);
361
-	}
360
+        file_put_contents($fileName, $content);
361
+    }
362 362
 }
Please login to merge, or discard this patch.
Braces   +70 added lines, -54 removed lines patch added patch discarded remove patch
@@ -72,8 +72,9 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	public function actionThemes($name=NULL)
74 74
 	{
75
-		if ($name === NULL)
76
-			$this->usageError('A theme was not specified for translations');
75
+		if ($name === NULL) {
76
+					$this->usageError('A theme was not specified for translations');
77
+		}
77 78
 
78 79
 		$this->_config['type'] = 'theme';
79 80
 		array_push($this->_config['exclude'], 'modules');
@@ -88,8 +89,9 @@  discard block
 block discarded – undo
88 89
 	 */
89 90
 	public function actionModules($name=NULL)
90 91
 	{
91
-		if ($name === NULL)
92
-			$this->usageError('A module was not specified for translations');
92
+		if ($name === NULL) {
93
+					$this->usageError('A module was not specified for translations');
94
+		}
93 95
 
94 96
 		$this->_config['type'] = 'module';
95 97
 		array_push($this->_config['exclude'], 'themes');
@@ -119,8 +121,9 @@  discard block
 block discarded – undo
119 121
 		$this->validateConfig();
120 122
 
121 123
 		// Determine the messages
122
-		foreach($this->getFiles() as $file)
123
-			$this->_messages = array_merge_recursive($this->_messages,$this->extractMessages($file,$this->_translator));
124
+		foreach($this->getFiles() as $file) {
125
+					$this->_messages = array_merge_recursive($this->_messages,$this->extractMessages($file,$this->_translator));
126
+		}
124 127
 
125 128
 		foreach($languages as $language)
126 129
 		{
@@ -139,19 +142,19 @@  discard block
 block discarded – undo
139 142
 					$data = explode('.', $category);
140 143
 					unset($data[0]);
141 144
 					$dirPath = implode(DS, $data);
142
-				}
143
-				else if ($this->_config['type'] == 'module')
145
+				} else if ($this->_config['type'] == 'module')
144 146
 				{
145 147
 					$data = explode('.', $category);
146 148
 					unset($data[0]);
147 149
 					unset($data[1]);
148 150
 					$dirPath = implode(DS, $data);
151
+				} else {
152
+									$dirPath = implode(DS, explode('.', $category));
149 153
 				}
150
-				else
151
-					$dirPath = implode(DS, explode('.', $category));
152 154
 
153
-				if (empty($dirPath))
154
-					continue;
155
+				if (empty($dirPath)) {
156
+									continue;
157
+				}
155 158
 
156 159
 				$this->createDirectory($dir . DS . $dirPath);
157 160
 				$this->createDirectory($dir . DS . $language);
@@ -170,8 +173,9 @@  discard block
 block discarded – undo
170 173
 	{
171 174
 		if (!is_dir($directory)) 
172 175
 		{
173
-			if (!mkdir($directory, 0777, true))
174
-				$this->usageError('The directory ' . $directory .' could not be created. Please make sure this process has write access to this directory.');
176
+			if (!mkdir($directory, 0777, true)) {
177
+							$this->usageError('The directory ' . $directory .' could not be created. Please make sure this process has write access to this directory.');
178
+			}
175 179
 		}
176 180
 
177 181
 		return true;
@@ -192,8 +196,9 @@  discard block
 block discarded – undo
192 196
 		// Strip out all extensions
193 197
 		foreach ($files as $k=>$file)
194 198
 		{
195
-			if (strpos($file, 'extensions') !== false)
196
-				unset($files[$k]);
199
+			if (strpos($file, 'extensions') !== false) {
200
+							unset($files[$k]);
201
+			}
197 202
 		}
198 203
 
199 204
 		reset($files);
@@ -208,17 +213,21 @@  discard block
 block discarded – undo
208 213
 	{
209 214
 		extract($this->_config);
210 215
 
211
-		if(!isset($sourcePath,$messagePath,$languages))
212
-			$this->usageError('The configuration file must specify "sourcePath", "messagePath" and "languages".');
216
+		if(!isset($sourcePath,$messagePath,$languages)) {
217
+					$this->usageError('The configuration file must specify "sourcePath", "messagePath" and "languages".');
218
+		}
213 219
 
214
-		if(!is_dir($sourcePath))
215
-			$this->usageError("The source path $sourcePath is not a valid directory.");
220
+		if(!is_dir($sourcePath)) {
221
+					$this->usageError("The source path $sourcePath is not a valid directory.");
222
+		}
216 223
 
217
-		if(!is_dir($messagePath))
218
-			$this->usageError("The message path $messagePath is not a valid directory.");
224
+		if(!is_dir($messagePath)) {
225
+					$this->usageError("The message path $messagePath is not a valid directory.");
226
+		}
219 227
 
220
-		if(empty($languages))
221
-			$this->usageError("Languages cannot be empty.");
228
+		if(empty($languages)) {
229
+					$this->usageError("Languages cannot be empty.");
230
+		}
222 231
 	}
223 232
 
224 233
 	/**
@@ -228,8 +237,9 @@  discard block
 block discarded – undo
228 237
 	{
229 238
 		$subject=file_get_contents($fileName);
230 239
 		$messages=array();
231
-		if(!is_array($translator))
232
-			$translator=array($translator);
240
+		if(!is_array($translator)) {
241
+					$translator=array($translator);
242
+		}
233 243
 
234 244
 		foreach ($translator as $currentTranslator)
235 245
 		{
@@ -239,15 +249,16 @@  discard block
 block discarded – undo
239 249
 			{
240 250
 				if(($pos=strpos($matches[$i][1],'.'))!==false)
241 251
 				{
242
-					if (strpos($matches[$i][1],'Dashboard')!==false || strpos($matches[$i][1],'Hybridauth')!==false || strpos($matches[$i][1],'Install')!==false)
243
-						$category='module.'.substr($matches[$i][1],1,-1);
244
-					else if (strpos($matches[$i][1],'Theme')!==false)
245
-						$category=$matches[$i][1];
246
-					else
247
-						$category=substr($matches[$i][1],$pos+1,-1);
252
+					if (strpos($matches[$i][1],'Dashboard')!==false || strpos($matches[$i][1],'Hybridauth')!==false || strpos($matches[$i][1],'Install')!==false) {
253
+											$category='module.'.substr($matches[$i][1],1,-1);
254
+					} else if (strpos($matches[$i][1],'Theme')!==false) {
255
+											$category=$matches[$i][1];
256
+					} else {
257
+											$category=substr($matches[$i][1],$pos+1,-1);
258
+					}
259
+				} else {
260
+									$category=substr($matches[$i][1],1,-1);
248 261
 				}
249
-				else
250
-					$category=substr($matches[$i][1],1,-1);
251 262
 
252 263
 
253 264
 				$message=$matches[$i][2];
@@ -287,18 +298,20 @@  discard block
 block discarded – undo
287 298
 
288 299
 			foreach($messages as $message)
289 300
 			{
290
-				if(array_key_exists($message,$translated) && strlen($translated[$message])>0)
291
-					$merged[$message]=$translated[$message];
292
-				else
293
-					$untranslated[]=$message;
301
+				if(array_key_exists($message,$translated) && strlen($translated[$message])>0) {
302
+									$merged[$message]=$translated[$message];
303
+				} else {
304
+									$untranslated[]=$message;
305
+				}
294 306
 			}
295 307
 
296 308
 			ksort($merged);
297 309
 			sort($untranslated);
298 310
 			$todo=array();
299 311
 
300
-			foreach($untranslated as $message)
301
-				$todo[$message]='';
312
+			foreach($untranslated as $message) {
313
+							$todo[$message]='';
314
+			}
302 315
 
303 316
 			ksort($translated);
304 317
 
@@ -306,30 +319,33 @@  discard block
 block discarded – undo
306 319
 			{
307 320
 				if(!isset($merged[$message]) && !isset($todo[$message]) && !$removeOld)
308 321
 				{
309
-					if(substr($translation,0,2)==='@@' && substr($translation,-2)==='@@')
310
-						$todo[$message]=$translation;
311
-					else if ($translation == '')
312
-						$todo[$message] = '';
313
-					else
314
-						$todo[$message]='@@'.$translation.'@@';
322
+					if(substr($translation,0,2)==='@@' && substr($translation,-2)==='@@') {
323
+											$todo[$message]=$translation;
324
+					} else if ($translation == '') {
325
+											$todo[$message] = '';
326
+					} else {
327
+											$todo[$message]='@@'.$translation.'@@';
328
+					}
315 329
 				}
316 330
 			}
317 331
 
318 332
 			$merged=array_merge($todo,$merged);
319 333
 
320
-			if($sort)
321
-				ksort($merged);
334
+			if($sort) {
335
+							ksort($merged);
336
+			}
322 337
 
323
-			if($overwrite === false)
324
-				$fileName.='.merged';
338
+			if($overwrite === false) {
339
+							$fileName.='.merged';
340
+			}
325 341
 
326 342
 			echo "translation merged.\n";
327
-		}
328
-		else
343
+		} else
329 344
 		{
330 345
 			$merged=array();
331
-			foreach($messages as $message)
332
-				$merged[$message]='';
346
+			foreach($messages as $message) {
347
+							$merged[$message]='';
348
+			}
333 349
 
334 350
 			ksort($merged);
335 351
 			echo "saved.\n";
Please login to merge, or discard this patch.
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 /**
3 3
  * This is an alternative implementation of the MessageCommand class, designed to work with CiiMS' modules and themes
4 4
  */
5
-Yii::import('cii.commands.CiiConsoleCommand');
5
+Yii::import ('cii.commands.CiiConsoleCommand');
6 6
 class CiiMessageCommand extends CiiConsoleCommand
7 7
 {
8 8
 
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
 	 * Default args
29 29
 	 * @return array
30 30
 	 */
31
-	private function getArgs()
31
+	private function getArgs ()
32 32
 	{
33 33
 		return array(
34 34
 			'type'			=> 'core',
35
-			'sourcePath'	=> Yii::getPathOfAlias('application').DS,
36
-			'messagePath'	=> Yii::getPathOfAlias('application.messages').DS,
35
+			'sourcePath'	=> Yii::getPathOfAlias ('application').DS,
36
+			'messagePath'	=> Yii::getPathOfAlias ('application.messages').DS,
37 37
 			'languages'		=> array('en_us'),
38 38
 			'fileTypes'		=> array('php'),
39 39
 			'overwrite'		=> true,
@@ -61,102 +61,102 @@  discard block
 block discarded – undo
61 61
 	/**
62 62
 	 * Init method
63 63
 	 */
64
-	public function init()
64
+	public function init ()
65 65
 	{
66
-		$this->_config = $this->getArgs();
66
+		$this->_config = $this->getArgs ();
67 67
 	}
68 68
 
69 69
 	/**
70 70
  	 * Generates translation files for a given mtheme
71 71
 	 * @param string $name 	The name of the theme to generate translations for
72 72
 	 */
73
-	public function actionThemes($name=NULL)
73
+	public function actionThemes ($name = NULL)
74 74
 	{
75 75
 		if ($name === NULL)
76
-			$this->usageError('A theme was not specified for translations');
76
+			$this->usageError ('A theme was not specified for translations');
77 77
 
78 78
 		$this->_config['type'] = 'theme';
79
-		array_push($this->_config['exclude'], 'modules');
80
-		$this->_config['sourcePath'] .= '..'.DS.'themes' . DS . $name . DS;
79
+		array_push ($this->_config['exclude'], 'modules');
80
+		$this->_config['sourcePath'] .= '..'.DS.'themes'.DS.$name.DS;
81 81
 		$this->_config['messagePath'] = $this->_config['sourcePath'].'messages';
82
-		$this->execute();
82
+		$this->execute ();
83 83
 	}
84 84
 
85 85
 	/**
86 86
  	 * Generates translation files for a given module
87 87
 	 * @param string $name 	The name of the module to generate translations for
88 88
 	 */
89
-	public function actionModules($name=NULL)
89
+	public function actionModules ($name = NULL)
90 90
 	{
91 91
 		if ($name === NULL)
92
-			$this->usageError('A module was not specified for translations');
92
+			$this->usageError ('A module was not specified for translations');
93 93
 
94 94
 		$this->_config['type'] = 'module';
95
-		array_push($this->_config['exclude'], 'themes');
95
+		array_push ($this->_config['exclude'], 'themes');
96 96
 		unset($this->_config['exclude']['modules']);
97
-		$this->_config['sourcePath'] = Yii::getPathOfAlias('application.modules') . DS . $name . DS;
97
+		$this->_config['sourcePath'] = Yii::getPathOfAlias ('application.modules').DS.$name.DS;
98 98
 		$this->_config['messagePath'] = $this->_config['sourcePath'].'messages';
99
-		$this->execute($this->_config);
99
+		$this->execute ($this->_config);
100 100
 	}
101 101
 
102 102
 	/**
103 103
  	 * Defualt action
104 104
 	 */
105
-	public function actionIndex()
105
+	public function actionIndex ()
106 106
 	{
107
-		array_push($this->_config['exclude'], 'modules');
108
-		array_push($this->_config['exclude'], 'themes');
109
-		return $this->execute();
107
+		array_push ($this->_config['exclude'], 'modules');
108
+		array_push ($this->_config['exclude'], 'themes');
109
+		return $this->execute ();
110 110
 	}
111 111
 
112 112
 	/**
113 113
 	 * Execute the action.
114 114
 	 */
115
-	private function execute()
115
+	private function execute ()
116 116
 	{
117 117
 		// Validate the configuration
118
-		extract($this->_config);
119
-		$this->validateConfig();
118
+		extract ($this->_config);
119
+		$this->validateConfig ();
120 120
 
121 121
 		// Determine the messages
122
-		foreach($this->getFiles() as $file)
123
-			$this->_messages = array_merge_recursive($this->_messages,$this->extractMessages($file,$this->_translator));
122
+		foreach ($this->getFiles () as $file)
123
+			$this->_messages = array_merge_recursive ($this->_messages, $this->extractMessages ($file, $this->_translator));
124 124
 
125
-		foreach($languages as $language)
125
+		foreach ($languages as $language)
126 126
 		{
127 127
 			$dir = $messagePath.DS.$language;
128 128
 
129
-			$this->createDirectory($dir);
129
+			$this->createDirectory ($dir);
130 130
 
131 131
 			foreach ($this->_messages as $category=>$msgs)
132 132
 			{
133
-				$msgs = array_values(array_unique($msgs));
133
+				$msgs = array_values (array_unique ($msgs));
134 134
 
135 135
 				$dir = $this->_config['messagePath'].DS.$language;
136 136
 
137
-				if ($this->_config['type']  == 'theme')
137
+				if ($this->_config['type'] == 'theme')
138 138
 				{
139
-					$data = explode('.', $category);
139
+					$data = explode ('.', $category);
140 140
 					unset($data[0]);
141
-					$dirPath = implode(DS, $data);
141
+					$dirPath = implode (DS, $data);
142 142
 				}
143 143
 				else if ($this->_config['type'] == 'module')
144 144
 				{
145
-					$data = explode('.', $category);
145
+					$data = explode ('.', $category);
146 146
 					unset($data[0]);
147 147
 					unset($data[1]);
148
-					$dirPath = implode(DS, $data);
148
+					$dirPath = implode (DS, $data);
149 149
 				}
150 150
 				else
151
-					$dirPath = implode(DS, explode('.', $category));
151
+					$dirPath = implode (DS, explode ('.', $category));
152 152
 
153 153
 				if (empty($dirPath))
154 154
 					continue;
155 155
 
156
-				$this->createDirectory($dir . DS . $dirPath);
157
-				$this->createDirectory($dir . DS . $language);
156
+				$this->createDirectory ($dir.DS.$dirPath);
157
+				$this->createDirectory ($dir.DS.$language);
158 158
 
159
-				$this->generateMessageFile($msgs,$dir.DS.$dirPath.'.php',$overwrite,$removeOld,$sort);
159
+				$this->generateMessageFile ($msgs, $dir.DS.$dirPath.'.php', $overwrite, $removeOld, $sort);
160 160
 			}
161 161
 		}
162 162
 	}
@@ -166,12 +166,12 @@  discard block
 block discarded – undo
166 166
 	 * @param string $directory
167 167
 	 * @return boolean
168 168
 	 */
169
-	private function createDirectory($directory)
169
+	private function createDirectory ($directory)
170 170
 	{
171
-		if (!is_dir($directory)) 
171
+		if (!is_dir ($directory)) 
172 172
 		{
173
-			if (!mkdir($directory, 0777, true))
174
-				$this->usageError('The directory ' . $directory .' could not be created. Please make sure this process has write access to this directory.');
173
+			if (!mkdir ($directory, 0777, true))
174
+				$this->usageError ('The directory '.$directory.' could not be created. Please make sure this process has write access to this directory.');
175 175
 		}
176 176
 
177 177
 		return true;
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
 	 * Retrieves the files that should be translated
182 182
 	 * @return array $files
183 183
 	 */
184
-	private function getFiles()
184
+	private function getFiles ()
185 185
 	{
186
-		extract($this->_config);
187
-		$files = CFileHelper::findFiles(realpath($sourcePath),array(
186
+		extract ($this->_config);
187
+		$files = CFileHelper::findFiles (realpath ($sourcePath), array(
188 188
 					'fileTypes' => $fileTypes,
189 189
 					'exclude'	=> $exclude
190 190
 				 ));
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 		// Strip out all extensions
193 193
 		foreach ($files as $k=>$file)
194 194
 		{
195
-			if (strpos($file, 'extensions') !== false)
195
+			if (strpos ($file, 'extensions') !== false)
196 196
 				unset($files[$k]);
197 197
 		}
198 198
 
199
-		reset($files);
199
+		reset ($files);
200 200
 
201 201
 		return $files;
202 202
 	}
@@ -204,58 +204,58 @@  discard block
 block discarded – undo
204 204
 	/**
205 205
 	 * Does basic validation on the configuration options
206 206
 	 */
207
-	private function validateConfig()
207
+	private function validateConfig ()
208 208
 	{
209
-		extract($this->_config);
209
+		extract ($this->_config);
210 210
 
211
-		if(!isset($sourcePath,$messagePath,$languages))
212
-			$this->usageError('The configuration file must specify "sourcePath", "messagePath" and "languages".');
211
+		if (!isset($sourcePath, $messagePath, $languages))
212
+			$this->usageError ('The configuration file must specify "sourcePath", "messagePath" and "languages".');
213 213
 
214
-		if(!is_dir($sourcePath))
215
-			$this->usageError("The source path $sourcePath is not a valid directory.");
214
+		if (!is_dir ($sourcePath))
215
+			$this->usageError ("The source path $sourcePath is not a valid directory.");
216 216
 
217
-		if(!is_dir($messagePath))
218
-			$this->usageError("The message path $messagePath is not a valid directory.");
217
+		if (!is_dir ($messagePath))
218
+			$this->usageError ("The message path $messagePath is not a valid directory.");
219 219
 
220
-		if(empty($languages))
221
-			$this->usageError("Languages cannot be empty.");
220
+		if (empty($languages))
221
+			$this->usageError ("Languages cannot be empty.");
222 222
 	}
223 223
 
224 224
 	/**
225 225
 	 * @param string $translator
226 226
 	 */
227
-	protected function extractMessages($fileName,$translator)
227
+	protected function extractMessages ($fileName, $translator)
228 228
 	{
229
-		$subject=file_get_contents($fileName);
230
-		$messages=array();
231
-		if(!is_array($translator))
232
-			$translator=array($translator);
229
+		$subject = file_get_contents ($fileName);
230
+		$messages = array();
231
+		if (!is_array ($translator))
232
+			$translator = array($translator);
233 233
 
234 234
 		foreach ($translator as $currentTranslator)
235 235
 		{
236
-			$n=preg_match_all('/\b'.$currentTranslator.'\s*\(\s*(\'[\w.\/]*?(?<!\.)\'|"[\w.]*?(?<!\.)")\s*,\s*(\'.*?(?<!\\\\)\'|".*?(?<!\\\\)")\s*[,\)]/s',$subject,$matches,PREG_SET_ORDER);
236
+			$n = preg_match_all ('/\b'.$currentTranslator.'\s*\(\s*(\'[\w.\/]*?(?<!\.)\'|"[\w.]*?(?<!\.)")\s*,\s*(\'.*?(?<!\\\\)\'|".*?(?<!\\\\)")\s*[,\)]/s', $subject, $matches, PREG_SET_ORDER);
237 237
 
238
-			for($i=0; $i<$n; ++$i)
238
+			for ($i = 0; $i < $n; ++$i)
239 239
 			{
240
-				if(($pos=strpos($matches[$i][1],'.'))!==false)
240
+				if (($pos = strpos ($matches[$i][1], '.')) !== false)
241 241
 				{
242
-					if (strpos($matches[$i][1],'Dashboard')!==false || strpos($matches[$i][1],'Hybridauth')!==false || strpos($matches[$i][1],'Install')!==false)
243
-						$category='module.'.substr($matches[$i][1],1,-1);
244
-					else if (strpos($matches[$i][1],'Theme')!==false)
245
-						$category=$matches[$i][1];
242
+					if (strpos ($matches[$i][1], 'Dashboard') !== false || strpos ($matches[$i][1], 'Hybridauth') !== false || strpos ($matches[$i][1], 'Install') !== false)
243
+						$category = 'module.'.substr ($matches[$i][1], 1, -1);
244
+					else if (strpos ($matches[$i][1], 'Theme') !== false)
245
+						$category = $matches[$i][1];
246 246
 					else
247
-						$category=substr($matches[$i][1],$pos+1,-1);
247
+						$category = substr ($matches[$i][1], $pos + 1, -1);
248 248
 				}
249 249
 				else
250
-					$category=substr($matches[$i][1],1,-1);
250
+					$category = substr ($matches[$i][1], 1, -1);
251 251
 
252 252
 
253
-				$message=$matches[$i][2];
253
+				$message = $matches[$i][2];
254 254
 
255
-				$category = str_replace("'", '', $category);
255
+				$category = str_replace ("'", '', $category);
256 256
 
257 257
 				// This is how Yii does it
258
-				$messages[$category][]=eval("return $message;");  // use eval to eliminate quote escape
258
+				$messages[$category][] = eval("return $message;"); // use eval to eliminate quote escape
259 259
 			}
260 260
 		}
261 261
 
@@ -268,74 +268,74 @@  discard block
 block discarded – undo
268 268
 	 * @param boolean $removeOld
269 269
 	 * @param boolean $sort
270 270
 	 */
271
-	protected function generateMessageFile($messages,$fileName,$overwrite,$removeOld,$sort)
271
+	protected function generateMessageFile ($messages, $fileName, $overwrite, $removeOld, $sort)
272 272
 	{
273 273
 		echo "Saving messages to $fileName...";
274
-		if(is_file($fileName))
274
+		if (is_file ($fileName))
275 275
 		{
276
-			$translated=require($fileName);
277
-			sort($messages);
278
-			ksort($translated);
279
-			if(array_keys($translated)==$messages)
276
+			$translated = require($fileName);
277
+			sort ($messages);
278
+			ksort ($translated);
279
+			if (array_keys ($translated) == $messages)
280 280
 			{
281 281
 				echo "nothing new...skipped.\n";
282 282
 				return;
283 283
 			}
284 284
 
285
-			$merged=array();
286
-			$untranslated=array();
285
+			$merged = array();
286
+			$untranslated = array();
287 287
 
288
-			foreach($messages as $message)
288
+			foreach ($messages as $message)
289 289
 			{
290
-				if(array_key_exists($message,$translated) && strlen($translated[$message])>0)
291
-					$merged[$message]=$translated[$message];
290
+				if (array_key_exists ($message, $translated) && strlen ($translated[$message]) > 0)
291
+					$merged[$message] = $translated[$message];
292 292
 				else
293
-					$untranslated[]=$message;
293
+					$untranslated[] = $message;
294 294
 			}
295 295
 
296
-			ksort($merged);
297
-			sort($untranslated);
298
-			$todo=array();
296
+			ksort ($merged);
297
+			sort ($untranslated);
298
+			$todo = array();
299 299
 
300
-			foreach($untranslated as $message)
301
-				$todo[$message]='';
300
+			foreach ($untranslated as $message)
301
+				$todo[$message] = '';
302 302
 
303
-			ksort($translated);
303
+			ksort ($translated);
304 304
 
305
-			foreach($translated as $message=>$translation)
305
+			foreach ($translated as $message=>$translation)
306 306
 			{
307
-				if(!isset($merged[$message]) && !isset($todo[$message]) && !$removeOld)
307
+				if (!isset($merged[$message]) && !isset($todo[$message]) && !$removeOld)
308 308
 				{
309
-					if(substr($translation,0,2)==='@@' && substr($translation,-2)==='@@')
310
-						$todo[$message]=$translation;
309
+					if (substr ($translation, 0, 2) === '@@' && substr ($translation, -2) === '@@')
310
+						$todo[$message] = $translation;
311 311
 					else if ($translation == '')
312 312
 						$todo[$message] = '';
313 313
 					else
314
-						$todo[$message]='@@'.$translation.'@@';
314
+						$todo[$message] = '@@'.$translation.'@@';
315 315
 				}
316 316
 			}
317 317
 
318
-			$merged=array_merge($todo,$merged);
318
+			$merged = array_merge ($todo, $merged);
319 319
 
320
-			if($sort)
321
-				ksort($merged);
320
+			if ($sort)
321
+				ksort ($merged);
322 322
 
323
-			if($overwrite === false)
324
-				$fileName.='.merged';
323
+			if ($overwrite === false)
324
+				$fileName .= '.merged';
325 325
 
326 326
 			echo "translation merged.\n";
327 327
 		}
328 328
 		else
329 329
 		{
330
-			$merged=array();
331
-			foreach($messages as $message)
332
-				$merged[$message]='';
330
+			$merged = array();
331
+			foreach ($messages as $message)
332
+				$merged[$message] = '';
333 333
 
334
-			ksort($merged);
334
+			ksort ($merged);
335 335
 			echo "saved.\n";
336 336
 		}
337
-		$array=str_replace("\r",'',var_export($merged,true));
338
-		$content=<<<EOD
337
+		$array = str_replace ("\r", '', var_export ($merged, true));
338
+		$content = <<<EOD
339 339
 <?php
340 340
 /**
341 341
  * Message translations.
@@ -357,6 +357,6 @@  discard block
 block discarded – undo
357 357
 return $array;
358 358
 
359 359
 EOD;
360
-		file_put_contents($fileName, $content);
360
+		file_put_contents ($fileName, $content);
361 361
 	}
362 362
 }
Please login to merge, or discard this patch.
protected/commands/CiiMigrateCommand.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Import System/Cli/Commands/MigrateCommand
3
-Yii::import('system.cli.commands.MigrateCommand');
3
+Yii::import ('system.cli.commands.MigrateCommand');
4 4
 /**
5 5
  * This class is an injection container for CDbMigration which permits us to
6 6
  * directly access CDbMigrations from our web application without having
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
      * This is our overloaded getDbConnection, allowing us to tell yii what our db connection is
22 22
      * without it having to go through
23 23
      */
24
-    public function getDbConnection()
24
+    public function getDbConnection ()
25 25
     {
26
-        $connection = new CDbConnection("mysql:host={$this->dsn['host']};dbname={$this->dsn['dbname']}", $this->dsn['username'], $this->dsn['password']);
27
-        $connection->setActive(true);
26
+        $connection = new CDbConnection ("mysql:host={$this->dsn['host']};dbname={$this->dsn['dbname']}", $this->dsn['username'], $this->dsn['password']);
27
+        $connection->setActive (true);
28 28
         return $connection;
29 29
     }
30 30
 }
31 31
\ No newline at end of file
Please login to merge, or discard this patch.
protected/config/install.php 2 patches
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -1,62 +1,62 @@
 block discarded – undo
1 1
 <?php return array(
2
-	'basePath' => dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
3
-	'name' => 'CiiMS Installer',
4
-	'preload' => array(
5
-		'cii'
6
-	),
7
-	'import' => array(
8
-		'application.components.*',
9
-		'application.modules.install.*'
10
-	),
11
-	'modules' => array(
12
-		'install'
13
-	),
14
-	'components' => array(
15
-		'cii' => array(
16
-			'class' => 'vendor.charlesportwoodii.cii.components.CiiBase'
17
-		),
18
-		'errorHandler' => array(
19
-			'errorAction' => '/install/default/error',
20
-		),
21
-		'session' => array(
22
-			'autoStart' => true,
23
-			'sessionName'   => 'CiiMS_Installer',
24
-			'cookieMode'    => 'only',
25
-		),
26
-		'cache' => array(
27
-			'class' => 'CFileCache'
28
-		),
29
-		'urlManager' => array(
30
-			'urlFormat' => 'path',
31
-			'showScriptName' => false,
32
-			'rules' => array(
33
-				'' => '/install/default/index',
34
-				'/migrate' => '/install/default/migrate',
35
-				'/runmigrations' => '/install/default/runmigrations',
36
-				'/createadmin' => '/install/default/createadmin',
37
-				'/admin' => '/install/default/admin'
38
-			),
39
-		),
40
-		'log' => array(
41
-			'class' => 'CLogRouter',
42
-			'routes' => array(
43
-				array(
44
-					'class' => 'CWebLogRoute',
45
-					'levels' => 'error, warning, trace, info',
46
-					'enabled' => true
47
-				),
48
-				array(
49
-					'class'=>'CProfileLogRoute',
50
-					'report'=>'summary',
51
-					'enabled' => true
52
-				)
53
-			)
54
-		),
55
-	),
56
-	'params' => array(
57
-		'stage' => 0,
58
-		'debug' => true,
59
-		'trace' => 3
60
-	),
2
+    'basePath' => dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
3
+    'name' => 'CiiMS Installer',
4
+    'preload' => array(
5
+        'cii'
6
+    ),
7
+    'import' => array(
8
+        'application.components.*',
9
+        'application.modules.install.*'
10
+    ),
11
+    'modules' => array(
12
+        'install'
13
+    ),
14
+    'components' => array(
15
+        'cii' => array(
16
+            'class' => 'vendor.charlesportwoodii.cii.components.CiiBase'
17
+        ),
18
+        'errorHandler' => array(
19
+            'errorAction' => '/install/default/error',
20
+        ),
21
+        'session' => array(
22
+            'autoStart' => true,
23
+            'sessionName'   => 'CiiMS_Installer',
24
+            'cookieMode'    => 'only',
25
+        ),
26
+        'cache' => array(
27
+            'class' => 'CFileCache'
28
+        ),
29
+        'urlManager' => array(
30
+            'urlFormat' => 'path',
31
+            'showScriptName' => false,
32
+            'rules' => array(
33
+                '' => '/install/default/index',
34
+                '/migrate' => '/install/default/migrate',
35
+                '/runmigrations' => '/install/default/runmigrations',
36
+                '/createadmin' => '/install/default/createadmin',
37
+                '/admin' => '/install/default/admin'
38
+            ),
39
+        ),
40
+        'log' => array(
41
+            'class' => 'CLogRouter',
42
+            'routes' => array(
43
+                array(
44
+                    'class' => 'CWebLogRoute',
45
+                    'levels' => 'error, warning, trace, info',
46
+                    'enabled' => true
47
+                ),
48
+                array(
49
+                    'class'=>'CProfileLogRoute',
50
+                    'report'=>'summary',
51
+                    'enabled' => true
52
+                )
53
+            )
54
+        ),
55
+    ),
56
+    'params' => array(
57
+        'stage' => 0,
58
+        'debug' => true,
59
+        'trace' => 3
60
+    ),
61 61
 );
62 62
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php return array(
2
-	'basePath' => dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
2
+	'basePath' => dirname (__FILE__).DIRECTORY_SEPARATOR.'..',
3 3
 	'name' => 'CiiMS Installer',
4 4
 	'preload' => array(
5 5
 		'cii'
Please login to merge, or discard this patch.
protected/config/main.default.php 3 patches
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -20,145 +20,145 @@
 block discarded – undo
20 20
 */
21 21
 $import = function($default=false) {
22 22
 
23
-	$modules = (require __DIR__ . DS . 'modules.php');
23
+    $modules = (require __DIR__ . DS . 'modules.php');
24 24
 
25
-	if ($default === true)
26
-		return $modules;
25
+    if ($default === true)
26
+        return $modules;
27 27
 
28
-	$m = array(
29
-		'application.models.*',
30
-		'application.models.forms.*',
31
-		'application.models.settings.*'
32
-	);
28
+    $m = array(
29
+        'application.models.*',
30
+        'application.models.forms.*',
31
+        'application.models.settings.*'
32
+    );
33 33
 
34
-	foreach ($modules as $k=>$v) {
35
-		$m[] = 'application.modules.'.$v.'.*';
36
-	}
34
+    foreach ($modules as $k=>$v) {
35
+        $m[] = 'application.modules.'.$v.'.*';
36
+    }
37 37
 
38
-	return $m;
38
+    return $m;
39 39
 };
40 40
 
41 41
 $ciimsCoreConfig = array(
42
-	'basePath' => __DIR__.DS.'..',
43
-	'name' => NULL,
44
-	'sourceLanguage' => 'en_US',
45
-	'preload' => array(
46
-		'cii',
47
-		'analytics'
48
-	),
49
-	'import' => $import(),
50
-	'modules' => $import(true),
51
-	'behaviors' => array(
52
-		'onBeginRequest' => array(
53
-			'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicWebAppBehavior',
54
-		),
55
-	),
56
-	'components' => array(
57
-		'themeManager' => array(
58
-			'basePath' => (__DIR__ . DS . '..' . DS . '..' . DS . 'themes')
59
-		),
60
-		'messages' => array(
61
-			'class' => 'vendor.charlesportwoodii.cii.components.CiiPHPMessageSource'
62
-		),
63
-			'newRelic' => array(
64
-			'class' => 'vendor.charlesportwoodii.yii-newrelic.YiiNewRelic',
65
-			'setAppNameToYiiName' => false
66
-		),
67
-		'cii' => array(
68
-			'class' => 'vendor.charlesportwoodii.cii.components.CiiBase'
69
-		),
70
-		'analytics' => array(
71
-			'class' => 'vendor.charlesportwoodii.cii.components.CiiAnalytics',
72
-			'lowerBounceRate' => true,
73
-			'options' => array(),
74
-		),
75
-		'assetManager' => array(
76
-			'class' => 'vendor.charlesportwoodii.cii.components.CiiAssetManager',
77
-		),
78
-		'clientScript' => array(
79
-			'class' => 'vendor.charlesportwoodii.cii.components.CiiClientScript',
80
-		),
81
-		'errorHandler' => array(
82
-			'errorAction' => 'site/error',
83
-		),
84
-		'session' => array(
85
-			'autoStart'     => true,
86
-			'sessionName'   => '_ciims',
87
-			'cookieMode'    => 'only',
88
-			'cookieParams'  => array(
89
-				'httponly' => true,
90
-				'secure' => (
91
-					(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || 
92
-					(!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) || 
93
-					(!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
94
-				)
95
-			)
96
-		),
97
-		'urlManager' => array(
98
-			'class'          => 'vendor.charlesportwoodii.cii.components.CiiURLManager',
99
-			'urlFormat'      => 'path',
100
-			'showScriptName' => false
101
-		),
102
-		'user' => array(
103
-			'authTimeout'    		=> 900,
104
-			'absoluteAuthTimeout' 	=> 1900,
105
-			'autoRenewCookie' 		=> true
106
-		),
107
-		'db' => array(
108
-			'class'                 => 'CDbConnection',
109
-			'connectionString'      => NULL,
110
-			'emulatePrepare'        => true,
111
-			'username'              => NULL,
112
-			'password'              => NULL,
113
-			'charset'               => 'utf8',
114
-			'schemaCachingDuration' => 3600,
115
-			'enableProfiling'       => false,
116
-			'enableParamLogging'    => false
117
-		),
118
-		'log' => array(
119
-			'class' => 'CLogRouter',
120
-			'routes' => array(
121
-				array(
122
-					'class'=>'CFileLogRoute',
123
-					'levels'=>'error, warning',
124
-				)
125
-			)
126
-		),
127
-		'cache' => array(
128
-			'class' => 'CFileCache',
129
-		)
130
-	),
131
-	'params' => array(
132
-		'encryptionKey'       => NULL,
133
-		'debug'               => false,
134
-		'trace'               => 0,
135
-		'NewRelicAppName'     => null,
136
-		'max_fileupload_size' => (10 * 1024 * 1024),
137
-		'cards' => 'https://cards.ciims.io/1.0.0',
138
-	)
42
+    'basePath' => __DIR__.DS.'..',
43
+    'name' => NULL,
44
+    'sourceLanguage' => 'en_US',
45
+    'preload' => array(
46
+        'cii',
47
+        'analytics'
48
+    ),
49
+    'import' => $import(),
50
+    'modules' => $import(true),
51
+    'behaviors' => array(
52
+        'onBeginRequest' => array(
53
+            'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicWebAppBehavior',
54
+        ),
55
+    ),
56
+    'components' => array(
57
+        'themeManager' => array(
58
+            'basePath' => (__DIR__ . DS . '..' . DS . '..' . DS . 'themes')
59
+        ),
60
+        'messages' => array(
61
+            'class' => 'vendor.charlesportwoodii.cii.components.CiiPHPMessageSource'
62
+        ),
63
+            'newRelic' => array(
64
+            'class' => 'vendor.charlesportwoodii.yii-newrelic.YiiNewRelic',
65
+            'setAppNameToYiiName' => false
66
+        ),
67
+        'cii' => array(
68
+            'class' => 'vendor.charlesportwoodii.cii.components.CiiBase'
69
+        ),
70
+        'analytics' => array(
71
+            'class' => 'vendor.charlesportwoodii.cii.components.CiiAnalytics',
72
+            'lowerBounceRate' => true,
73
+            'options' => array(),
74
+        ),
75
+        'assetManager' => array(
76
+            'class' => 'vendor.charlesportwoodii.cii.components.CiiAssetManager',
77
+        ),
78
+        'clientScript' => array(
79
+            'class' => 'vendor.charlesportwoodii.cii.components.CiiClientScript',
80
+        ),
81
+        'errorHandler' => array(
82
+            'errorAction' => 'site/error',
83
+        ),
84
+        'session' => array(
85
+            'autoStart'     => true,
86
+            'sessionName'   => '_ciims',
87
+            'cookieMode'    => 'only',
88
+            'cookieParams'  => array(
89
+                'httponly' => true,
90
+                'secure' => (
91
+                    (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || 
92
+                    (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) || 
93
+                    (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
94
+                )
95
+            )
96
+        ),
97
+        'urlManager' => array(
98
+            'class'          => 'vendor.charlesportwoodii.cii.components.CiiURLManager',
99
+            'urlFormat'      => 'path',
100
+            'showScriptName' => false
101
+        ),
102
+        'user' => array(
103
+            'authTimeout'    		=> 900,
104
+            'absoluteAuthTimeout' 	=> 1900,
105
+            'autoRenewCookie' 		=> true
106
+        ),
107
+        'db' => array(
108
+            'class'                 => 'CDbConnection',
109
+            'connectionString'      => NULL,
110
+            'emulatePrepare'        => true,
111
+            'username'              => NULL,
112
+            'password'              => NULL,
113
+            'charset'               => 'utf8',
114
+            'schemaCachingDuration' => 3600,
115
+            'enableProfiling'       => false,
116
+            'enableParamLogging'    => false
117
+        ),
118
+        'log' => array(
119
+            'class' => 'CLogRouter',
120
+            'routes' => array(
121
+                array(
122
+                    'class'=>'CFileLogRoute',
123
+                    'levels'=>'error, warning',
124
+                )
125
+            )
126
+        ),
127
+        'cache' => array(
128
+            'class' => 'CFileCache',
129
+        )
130
+    ),
131
+    'params' => array(
132
+        'encryptionKey'       => NULL,
133
+        'debug'               => false,
134
+        'trace'               => 0,
135
+        'NewRelicAppName'     => null,
136
+        'max_fileupload_size' => (10 * 1024 * 1024),
137
+        'cards' => 'https://cards.ciims.io/1.0.0',
138
+    )
139 139
 );
140 140
 
141 141
 // CLI specific data
142 142
 if (php_sapi_name() == "cli")
143 143
 {
144
-	$ciimsCoreConfig['behaviors'] = array(
145
-		'onBeginRequest' => array(
146
-			'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicConsoleAppBehavior',
147
-		),
148
-		'onEndRequest' => array(
149
-			'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicConsoleAppBehavior',
150
-		)
151
-	);
144
+    $ciimsCoreConfig['behaviors'] = array(
145
+        'onBeginRequest' => array(
146
+            'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicConsoleAppBehavior',
147
+        ),
148
+        'onEndRequest' => array(
149
+            'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicConsoleAppBehavior',
150
+        )
151
+    );
152 152
 }
153 153
 
154 154
 if (php_sapi_name() != "cli" && YII_DEBUG)
155 155
 {
156
-	$ciimsCoreConfig['preload'][] = 'debug';
157
-	$ciimsCoreConfig['components']['debug'] = array(
158
-		'class' => 'vendor.zhuravljov.yii2-debug.Yii2Debug',
159
-		'enabled' => YII_DEBUG,
160
-		'allowedIPs' => array('*')
161
-	);
156
+    $ciimsCoreConfig['preload'][] = 'debug';
157
+    $ciimsCoreConfig['components']['debug'] = array(
158
+        'class' => 'vendor.zhuravljov.yii2-debug.Yii2Debug',
159
+        'enabled' => YII_DEBUG,
160
+        'allowedIPs' => array('*')
161
+    );
162 162
 }
163 163
 
164 164
 return $ciimsCoreConfig;
Please login to merge, or discard this patch.
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,12 +18,14 @@
 block discarded – undo
18 18
 * @license    http://opensource.org/licenses/MIT  MIT LICENSE
19 19
 * @link       https://github.com/charlesportwoodii/CiiMS
20 20
 */
21
-$import = function($default=false) {
21
+$import = function($default=false)
22
+{
22 23
 
23 24
 	$modules = (require __DIR__ . DS . 'modules.php');
24 25
 
25
-	if ($default === true)
26
-		return $modules;
26
+	if ($default === true) {
27
+			return $modules;
28
+	}
27 29
 
28 30
 	$m = array(
29 31
 		'application.models.*',
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
 * @license    http://opensource.org/licenses/MIT  MIT LICENSE
19 19
 * @link       https://github.com/charlesportwoodii/CiiMS
20 20
 */
21
-$import = function($default=false) {
21
+$import = function ($default = false) {
22 22
 
23
-	$modules = (require __DIR__ . DS . 'modules.php');
23
+	$modules = (require __DIR__.DS.'modules.php');
24 24
 
25 25
 	if ($default === true)
26 26
 		return $modules;
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 		'cii',
47 47
 		'analytics'
48 48
 	),
49
-	'import' => $import(),
50
-	'modules' => $import(true),
49
+	'import' => $import (),
50
+	'modules' => $import (true),
51 51
 	'behaviors' => array(
52 52
 		'onBeginRequest' => array(
53 53
 			'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicWebAppBehavior',
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	),
56 56
 	'components' => array(
57 57
 		'themeManager' => array(
58
-			'basePath' => (__DIR__ . DS . '..' . DS . '..' . DS . 'themes')
58
+			'basePath' => (__DIR__.DS.'..'.DS.'..'.DS.'themes')
59 59
 		),
60 60
 		'messages' => array(
61 61
 			'class' => 'vendor.charlesportwoodii.cii.components.CiiPHPMessageSource'
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 );
140 140
 
141 141
 // CLI specific data
142
-if (php_sapi_name() == "cli")
142
+if (php_sapi_name () == "cli")
143 143
 {
144 144
 	$ciimsCoreConfig['behaviors'] = array(
145 145
 		'onBeginRequest' => array(
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	);
152 152
 }
153 153
 
154
-if (php_sapi_name() != "cli" && YII_DEBUG)
154
+if (php_sapi_name () != "cli" && YII_DEBUG)
155 155
 {
156 156
 	$ciimsCoreConfig['preload'][] = 'debug';
157 157
 	$ciimsCoreConfig['components']['debug'] = array(
Please login to merge, or discard this patch.
protected/config/modules.php 3 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,30 +6,30 @@
 block discarded – undo
6 6
 
7 7
 // Attempt to load the cached file if it exists
8 8
 if (file_exists($cachedConfig))
9
-	return require($cachedConfig);
9
+    return require($cachedConfig);
10 10
 else
11 11
 {
12
-	// Otherwise generate one, and return it
13
-	$response = array();
12
+    // Otherwise generate one, and return it
13
+    $response = array();
14 14
 
15
-	// Find all the modules currently installed, and preload them
16
-	foreach (new IteratorIterator(new DirectoryIterator($directory)) as $filename)
17
-	{
18
-		// Don't import dot files
19
-		if (!$filename->isDot() && strpos($filename->getFileName(), ".") === false)
20
-		{
21
-			$path = $filename->getPathname();
15
+    // Find all the modules currently installed, and preload them
16
+    foreach (new IteratorIterator(new DirectoryIterator($directory)) as $filename)
17
+    {
18
+        // Don't import dot files
19
+        if (!$filename->isDot() && strpos($filename->getFileName(), ".") === false)
20
+        {
21
+            $path = $filename->getPathname();
22 22
 
23
-			if (file_exists($path.DS.'config'.DS.'main.php'))
24
-				$response[$filename->getFilename()] = require($path.DS.'config'.DS.'main.php');
25
-			else
26
-				array_push($response, $filename->getFilename());
27
-		}
28
-	}
23
+            if (file_exists($path.DS.'config'.DS.'main.php'))
24
+                $response[$filename->getFilename()] = require($path.DS.'config'.DS.'main.php');
25
+            else
26
+                array_push($response, $filename->getFilename());
27
+        }
28
+    }
29 29
 
30
-	$encoded = serialize($response);
31
-	file_put_contents($cachedConfig, '<?php return unserialize(\''.$encoded.'\');');
30
+    $encoded = serialize($response);
31
+    file_put_contents($cachedConfig, '<?php return unserialize(\''.$encoded.'\');');
32 32
 
33
-	// return the response
34
-	return $response;
33
+    // return the response
34
+    return $response;
35 35
 }
Please login to merge, or discard this patch.
Braces   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -5,9 +5,9 @@  discard block
 block discarded – undo
5 5
 $cachedConfig = __DIR__.DS.'..'.DS.'runtime'.DS.'modules.config.php';
6 6
 
7 7
 // Attempt to load the cached file if it exists
8
-if (file_exists($cachedConfig))
8
+if (file_exists($cachedConfig)) {
9 9
 	return require($cachedConfig);
10
-else
10
+} else
11 11
 {
12 12
 	// Otherwise generate one, and return it
13 13
 	$response = array();
@@ -20,10 +20,11 @@  discard block
 block discarded – undo
20 20
 		{
21 21
 			$path = $filename->getPathname();
22 22
 
23
-			if (file_exists($path.DS.'config'.DS.'main.php'))
24
-				$response[$filename->getFilename()] = require($path.DS.'config'.DS.'main.php');
25
-			else
26
-				array_push($response, $filename->getFilename());
23
+			if (file_exists($path.DS.'config'.DS.'main.php')) {
24
+							$response[$filename->getFilename()] = require($path.DS.'config'.DS.'main.php');
25
+			} else {
26
+							array_push($response, $filename->getFilename());
27
+			}
27 28
 		}
28 29
 	}
29 30
 
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Set the scan directory
4
-$directory = __DIR__ . DS . '..' . DS . 'modules';
4
+$directory = __DIR__.DS.'..'.DS.'modules';
5 5
 $cachedConfig = __DIR__.DS.'..'.DS.'runtime'.DS.'modules.config.php';
6 6
 
7 7
 // Attempt to load the cached file if it exists
8
-if (file_exists($cachedConfig))
8
+if (file_exists ($cachedConfig))
9 9
 	return require($cachedConfig);
10 10
 else
11 11
 {
@@ -13,22 +13,22 @@  discard block
 block discarded – undo
13 13
 	$response = array();
14 14
 
15 15
 	// Find all the modules currently installed, and preload them
16
-	foreach (new IteratorIterator(new DirectoryIterator($directory)) as $filename)
16
+	foreach (new IteratorIterator (new DirectoryIterator ($directory)) as $filename)
17 17
 	{
18 18
 		// Don't import dot files
19
-		if (!$filename->isDot() && strpos($filename->getFileName(), ".") === false)
19
+		if (!$filename->isDot () && strpos ($filename->getFileName (), ".") === false)
20 20
 		{
21
-			$path = $filename->getPathname();
21
+			$path = $filename->getPathname ();
22 22
 
23
-			if (file_exists($path.DS.'config'.DS.'main.php'))
24
-				$response[$filename->getFilename()] = require($path.DS.'config'.DS.'main.php');
23
+			if (file_exists ($path.DS.'config'.DS.'main.php'))
24
+				$response[$filename->getFilename ()] = require($path.DS.'config'.DS.'main.php');
25 25
 			else
26
-				array_push($response, $filename->getFilename());
26
+				array_push ($response, $filename->getFilename ());
27 27
 		}
28 28
 	}
29 29
 
30
-	$encoded = serialize($response);
31
-	file_put_contents($cachedConfig, '<?php return unserialize(\''.$encoded.'\');');
30
+	$encoded = serialize ($response);
31
+	file_put_contents ($cachedConfig, '<?php return unserialize(\''.$encoded.'\');');
32 32
 
33 33
 	// return the response
34 34
 	return $response;
Please login to merge, or discard this patch.
protected/controllers/CategoriesController.php 3 patches
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -2,126 +2,126 @@
 block discarded – undo
2 2
 
3 3
 class CategoriesController extends CiiController
4 4
 {
5
-	/**
6
-	 * Base filter, allows logged in and non-logged in users to cache the page
7
-	 */
8
-	public function filters()
9
-	{
10
-		$id = Yii::app()->getRequest()->getQuery('id');
11
-
12
-		if ($id == NULL || $id === false)
13
-			throw new CHttpException(400, Yii::t('ciims.controllers.Categories', 'Invalid routing'));
14
-
15
-		return CMap::mergeArray(parent::filters(), array(
16
-			array(
17
-				'CHttpCacheFilter + index',
18
-				'cacheControl'=>Cii::get(Yii::app()->user->id) == NULL ? 'public' : 'private' .', no-cache, must-revalidate',
19
-				'etagSeed'=>$id
20
-			),
21
-			array(
22
-				'COutputCache + list',
23
-				'duration' => YII_DEBUG ? 1 : 86400,
24
-				'varyByParam' => array('page'),
25
-				'varyByLanguage' => true,
26
-				'dependency' => array(
27
-					'class'=>'CDbCacheDependency',
28
-					'sql'=>'SELECT MAX(updated) FROM content WHERE category_id = :id',
29
-					'params' => array(':id' => $id)
30
-				)
31
-			),
32
-			array(
33
-				'COutputCache + rss',
34
-				'duration' => YII_DEBUG ? 1 : 86400,
35
-				'dependency' => array(
36
-					'class'=>'CDbCacheDependency',
37
-					'sql'=>'SELECT MAX(updated) FROM content WHERE category_id = :id',
38
-					'params' => array(':id' => $id)
39
-				)
40
-			)
41
-		));
42
-	}
43
-
44
-	/**
45
-	 * Handles all incoming requests for the entire site that are not previous defined in CUrlManager
46
-	 * Requests come in, are verified, and then pulled from the database dynamically
47
-	 * Shows all blog posts for a particular category_id
48
-	 * @param $id	- The content ID that we want to pull from the database
49
-	 **/
50
-	public function actionIndex($id=NULL)
51
-	{
52
-		// Run a pre check of our data
53
-		$this->beforeCiiAction($id);
54
-
55
-		// Retrieve the data
56
-		$category = Categories::model()->findByPk($id);
57
-
58
-		// Set the layout
59
-		$this->setLayout('default');
60
-
61
-		$this->setPageTitle(Yii::t('ciims.controllers.Categories', '{{app_name}} | {{label}}', array(
62
-			'{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
63
-			'{{label}}'    => $category->name
64
-		)));
65
-
66
-		$pageSize = Cii::getConfig('categoryPaginationSize', 10);
67
-
68
-		$criteria = Content::model()
69
-					->getBaseCriteria()
70
-					->addCondition('type_id >= 2')
71
-					->addCondition("category_id = " . $id)
72
-					->addCondition('password = ""');
73
-
74
-		$criteria->limit = $pageSize;
75
-		$criteria->order = 'created DESC';
76
-
77
-		$itemCount = Content::model()->count($criteria);
78
-		$pages=new CPagination($itemCount);
79
-		$pages->pageSize=$pageSize;
80
-
81
-
82
-		$criteria->offset = $criteria->limit*($pages->getCurrentPage());
83
-		$data = Content::model()->findAll($criteria);
84
-
85
-		$pages->applyLimit($criteria);
86
-
87
-		$this->render('index', array(
88
-			'id'		=> $id,
89
-			'category' 	=> $category,
90
-			'data' 		=> $data,
91
-			'itemCount' => $itemCount,
92
-			'pages' 	=> $pages,
93
-			'meta' 		=> array(
94
-				'description' => $category->getDescription()
95
-		)));
96
-	}
97
-
98
-	/**
99
-	 * Displays either all posts or all posts for a particular category_id if an $id is set in RSS Format
100
-	 * So that RSS Readers can access the website
101
-	 * @param  int $id
102
-	 */
103
-	public function actionRss($id=NULL)
104
-	{
105
-		Yii::app()->log->routes[0]->enabled = false;
106
-		ob_end_clean();
107
-		header('Content-type: text/xml; charset=utf-8');
108
-		$url = 'http://'.Yii::app()->request->serverName . Yii::app()->baseUrl;
109
-		$this->setLayout(null);
110
-		$criteria = Content::model()
111
-					->getBaseCriteria()
112
-					->addCondition('type_id >= 2')
113
-					->addCondition('password = ""');
114
-
115
-		if ($id !== NULL)
116
-			$criteria->addCondition("category_id = " . $id);
117
-
118
-		$criteria->order = 'created DESC';
119
-		$data = Content::model()->findAll($criteria);
120
-
121
-		$this->renderPartial('application.views.site/rss', array(
122
-			'data' 	=> $data, 
123
-			'url'	=> $url
124
-		));
125
-		return;
126
-	}
5
+    /**
6
+     * Base filter, allows logged in and non-logged in users to cache the page
7
+     */
8
+    public function filters()
9
+    {
10
+        $id = Yii::app()->getRequest()->getQuery('id');
11
+
12
+        if ($id == NULL || $id === false)
13
+            throw new CHttpException(400, Yii::t('ciims.controllers.Categories', 'Invalid routing'));
14
+
15
+        return CMap::mergeArray(parent::filters(), array(
16
+            array(
17
+                'CHttpCacheFilter + index',
18
+                'cacheControl'=>Cii::get(Yii::app()->user->id) == NULL ? 'public' : 'private' .', no-cache, must-revalidate',
19
+                'etagSeed'=>$id
20
+            ),
21
+            array(
22
+                'COutputCache + list',
23
+                'duration' => YII_DEBUG ? 1 : 86400,
24
+                'varyByParam' => array('page'),
25
+                'varyByLanguage' => true,
26
+                'dependency' => array(
27
+                    'class'=>'CDbCacheDependency',
28
+                    'sql'=>'SELECT MAX(updated) FROM content WHERE category_id = :id',
29
+                    'params' => array(':id' => $id)
30
+                )
31
+            ),
32
+            array(
33
+                'COutputCache + rss',
34
+                'duration' => YII_DEBUG ? 1 : 86400,
35
+                'dependency' => array(
36
+                    'class'=>'CDbCacheDependency',
37
+                    'sql'=>'SELECT MAX(updated) FROM content WHERE category_id = :id',
38
+                    'params' => array(':id' => $id)
39
+                )
40
+            )
41
+        ));
42
+    }
43
+
44
+    /**
45
+     * Handles all incoming requests for the entire site that are not previous defined in CUrlManager
46
+     * Requests come in, are verified, and then pulled from the database dynamically
47
+     * Shows all blog posts for a particular category_id
48
+     * @param $id	- The content ID that we want to pull from the database
49
+     **/
50
+    public function actionIndex($id=NULL)
51
+    {
52
+        // Run a pre check of our data
53
+        $this->beforeCiiAction($id);
54
+
55
+        // Retrieve the data
56
+        $category = Categories::model()->findByPk($id);
57
+
58
+        // Set the layout
59
+        $this->setLayout('default');
60
+
61
+        $this->setPageTitle(Yii::t('ciims.controllers.Categories', '{{app_name}} | {{label}}', array(
62
+            '{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
63
+            '{{label}}'    => $category->name
64
+        )));
65
+
66
+        $pageSize = Cii::getConfig('categoryPaginationSize', 10);
67
+
68
+        $criteria = Content::model()
69
+                    ->getBaseCriteria()
70
+                    ->addCondition('type_id >= 2')
71
+                    ->addCondition("category_id = " . $id)
72
+                    ->addCondition('password = ""');
73
+
74
+        $criteria->limit = $pageSize;
75
+        $criteria->order = 'created DESC';
76
+
77
+        $itemCount = Content::model()->count($criteria);
78
+        $pages=new CPagination($itemCount);
79
+        $pages->pageSize=$pageSize;
80
+
81
+
82
+        $criteria->offset = $criteria->limit*($pages->getCurrentPage());
83
+        $data = Content::model()->findAll($criteria);
84
+
85
+        $pages->applyLimit($criteria);
86
+
87
+        $this->render('index', array(
88
+            'id'		=> $id,
89
+            'category' 	=> $category,
90
+            'data' 		=> $data,
91
+            'itemCount' => $itemCount,
92
+            'pages' 	=> $pages,
93
+            'meta' 		=> array(
94
+                'description' => $category->getDescription()
95
+        )));
96
+    }
97
+
98
+    /**
99
+     * Displays either all posts or all posts for a particular category_id if an $id is set in RSS Format
100
+     * So that RSS Readers can access the website
101
+     * @param  int $id
102
+     */
103
+    public function actionRss($id=NULL)
104
+    {
105
+        Yii::app()->log->routes[0]->enabled = false;
106
+        ob_end_clean();
107
+        header('Content-type: text/xml; charset=utf-8');
108
+        $url = 'http://'.Yii::app()->request->serverName . Yii::app()->baseUrl;
109
+        $this->setLayout(null);
110
+        $criteria = Content::model()
111
+                    ->getBaseCriteria()
112
+                    ->addCondition('type_id >= 2')
113
+                    ->addCondition('password = ""');
114
+
115
+        if ($id !== NULL)
116
+            $criteria->addCondition("category_id = " . $id);
117
+
118
+        $criteria->order = 'created DESC';
119
+        $data = Content::model()->findAll($criteria);
120
+
121
+        $this->renderPartial('application.views.site/rss', array(
122
+            'data' 	=> $data, 
123
+            'url'	=> $url
124
+        ));
125
+        return;
126
+    }
127 127
 }
Please login to merge, or discard this patch.
Braces   +14 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,16 +1,17 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class CategoriesController extends CiiController
4
-{
3
+class CategoriesController extends CiiController
4
+{
5 5
 	/**
6 6
 	 * Base filter, allows logged in and non-logged in users to cache the page
7 7
 	 */
8
-	public function filters()
9
-	{
8
+	public function filters()
9
+	{
10 10
 		$id = Yii::app()->getRequest()->getQuery('id');
11 11
 
12
-		if ($id == NULL || $id === false)
13
-			throw new CHttpException(400, Yii::t('ciims.controllers.Categories', 'Invalid routing'));
12
+		if ($id == NULL || $id === false) {
13
+					throw new CHttpException(400, Yii::t('ciims.controllers.Categories', 'Invalid routing'));
14
+		}
14 15
 
15 16
 		return CMap::mergeArray(parent::filters(), array(
16 17
 			array(
@@ -47,8 +48,8 @@  discard block
 block discarded – undo
47 48
 	 * Shows all blog posts for a particular category_id
48 49
 	 * @param $id	- The content ID that we want to pull from the database
49 50
 	 **/
50
-	public function actionIndex($id=NULL)
51
-	{
51
+	public function actionIndex($id=NULL)
52
+	{
52 53
 		// Run a pre check of our data
53 54
 		$this->beforeCiiAction($id);
54 55
 
@@ -100,8 +101,8 @@  discard block
 block discarded – undo
100 101
 	 * So that RSS Readers can access the website
101 102
 	 * @param  int $id
102 103
 	 */
103
-	public function actionRss($id=NULL)
104
-	{
104
+	public function actionRss($id=NULL)
105
+	{
105 106
 		Yii::app()->log->routes[0]->enabled = false;
106 107
 		ob_end_clean();
107 108
 		header('Content-type: text/xml; charset=utf-8');
@@ -112,8 +113,9 @@  discard block
 block discarded – undo
112 113
 					->addCondition('type_id >= 2')
113 114
 					->addCondition('password = ""');
114 115
 
115
-		if ($id !== NULL)
116
-			$criteria->addCondition("category_id = " . $id);
116
+		if ($id !== NULL) {
117
+					$criteria->addCondition("category_id = " . $id);
118
+		}
117 119
 
118 120
 		$criteria->order = 'created DESC';
119 121
 		$data = Content::model()->findAll($criteria);
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -5,17 +5,17 @@  discard block
 block discarded – undo
5 5
 	/**
6 6
 	 * Base filter, allows logged in and non-logged in users to cache the page
7 7
 	 */
8
-	public function filters()
8
+	public function filters ()
9 9
 	{
10
-		$id = Yii::app()->getRequest()->getQuery('id');
10
+		$id = Yii::app ()->getRequest ()->getQuery ('id');
11 11
 
12 12
 		if ($id == NULL || $id === false)
13
-			throw new CHttpException(400, Yii::t('ciims.controllers.Categories', 'Invalid routing'));
13
+			throw new CHttpException (400, Yii::t ('ciims.controllers.Categories', 'Invalid routing'));
14 14
 
15
-		return CMap::mergeArray(parent::filters(), array(
15
+		return CMap::mergeArray (parent::filters (), array(
16 16
 			array(
17 17
 				'CHttpCacheFilter + index',
18
-				'cacheControl'=>Cii::get(Yii::app()->user->id) == NULL ? 'public' : 'private' .', no-cache, must-revalidate',
18
+				'cacheControl'=>Cii::get (Yii::app ()->user->id) == NULL ? 'public' : 'private'.', no-cache, must-revalidate',
19 19
 				'etagSeed'=>$id
20 20
 			),
21 21
 			array(
@@ -47,51 +47,51 @@  discard block
 block discarded – undo
47 47
 	 * Shows all blog posts for a particular category_id
48 48
 	 * @param $id	- The content ID that we want to pull from the database
49 49
 	 **/
50
-	public function actionIndex($id=NULL)
50
+	public function actionIndex ($id = NULL)
51 51
 	{
52 52
 		// Run a pre check of our data
53
-		$this->beforeCiiAction($id);
53
+		$this->beforeCiiAction ($id);
54 54
 
55 55
 		// Retrieve the data
56
-		$category = Categories::model()->findByPk($id);
56
+		$category = Categories::model ()->findByPk ($id);
57 57
 
58 58
 		// Set the layout
59
-		$this->setLayout('default');
59
+		$this->setLayout ('default');
60 60
 
61
-		$this->setPageTitle(Yii::t('ciims.controllers.Categories', '{{app_name}} | {{label}}', array(
62
-			'{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
61
+		$this->setPageTitle (Yii::t ('ciims.controllers.Categories', '{{app_name}} | {{label}}', array(
62
+			'{{app_name}}' => Cii::getConfig ('name', Yii::app ()->name),
63 63
 			'{{label}}'    => $category->name
64 64
 		)));
65 65
 
66
-		$pageSize = Cii::getConfig('categoryPaginationSize', 10);
66
+		$pageSize = Cii::getConfig ('categoryPaginationSize', 10);
67 67
 
68
-		$criteria = Content::model()
69
-					->getBaseCriteria()
70
-					->addCondition('type_id >= 2')
71
-					->addCondition("category_id = " . $id)
72
-					->addCondition('password = ""');
68
+		$criteria = Content::model ()
69
+					->getBaseCriteria ()
70
+					->addCondition ('type_id >= 2')
71
+					->addCondition ("category_id = ".$id)
72
+					->addCondition ('password = ""');
73 73
 
74 74
 		$criteria->limit = $pageSize;
75 75
 		$criteria->order = 'created DESC';
76 76
 
77
-		$itemCount = Content::model()->count($criteria);
78
-		$pages=new CPagination($itemCount);
79
-		$pages->pageSize=$pageSize;
77
+		$itemCount = Content::model ()->count ($criteria);
78
+		$pages = new CPagination ($itemCount);
79
+		$pages->pageSize = $pageSize;
80 80
 
81 81
 
82
-		$criteria->offset = $criteria->limit*($pages->getCurrentPage());
83
-		$data = Content::model()->findAll($criteria);
82
+		$criteria->offset = $criteria->limit * ($pages->getCurrentPage ());
83
+		$data = Content::model ()->findAll ($criteria);
84 84
 
85
-		$pages->applyLimit($criteria);
85
+		$pages->applyLimit ($criteria);
86 86
 
87
-		$this->render('index', array(
87
+		$this->render ('index', array(
88 88
 			'id'		=> $id,
89 89
 			'category' 	=> $category,
90 90
 			'data' 		=> $data,
91 91
 			'itemCount' => $itemCount,
92 92
 			'pages' 	=> $pages,
93 93
 			'meta' 		=> array(
94
-				'description' => $category->getDescription()
94
+				'description' => $category->getDescription ()
95 95
 		)));
96 96
 	}
97 97
 
@@ -100,25 +100,25 @@  discard block
 block discarded – undo
100 100
 	 * So that RSS Readers can access the website
101 101
 	 * @param  int $id
102 102
 	 */
103
-	public function actionRss($id=NULL)
103
+	public function actionRss ($id = NULL)
104 104
 	{
105
-		Yii::app()->log->routes[0]->enabled = false;
106
-		ob_end_clean();
107
-		header('Content-type: text/xml; charset=utf-8');
108
-		$url = 'http://'.Yii::app()->request->serverName . Yii::app()->baseUrl;
109
-		$this->setLayout(null);
110
-		$criteria = Content::model()
111
-					->getBaseCriteria()
112
-					->addCondition('type_id >= 2')
113
-					->addCondition('password = ""');
105
+		Yii::app ()->log->routes[0]->enabled = false;
106
+		ob_end_clean ();
107
+		header ('Content-type: text/xml; charset=utf-8');
108
+		$url = 'http://'.Yii::app ()->request->serverName.Yii::app ()->baseUrl;
109
+		$this->setLayout (null);
110
+		$criteria = Content::model ()
111
+					->getBaseCriteria ()
112
+					->addCondition ('type_id >= 2')
113
+					->addCondition ('password = ""');
114 114
 
115 115
 		if ($id !== NULL)
116
-			$criteria->addCondition("category_id = " . $id);
116
+			$criteria->addCondition ("category_id = ".$id);
117 117
 
118 118
 		$criteria->order = 'created DESC';
119
-		$data = Content::model()->findAll($criteria);
119
+		$data = Content::model ()->findAll ($criteria);
120 120
 
121
-		$this->renderPartial('application.views.site/rss', array(
121
+		$this->renderPartial ('application.views.site/rss', array(
122 122
 			'data' 	=> $data, 
123 123
 			'url'	=> $url
124 124
 		));
Please login to merge, or discard this patch.
protected/controllers/ContentController.php 3 patches
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -2,212 +2,212 @@  discard block
 block discarded – undo
2 2
 
3 3
 class ContentController extends CiiController
4 4
 {
5
-	/**
6
-	 * Base filter, allows logged in and non-logged in users to cache the page
7
-	 */
8
-	public function filters()
9
-	{
10
-		$id = Yii::app()->getRequest()->getQuery('id');
11
-
12
-		if ($id != NULL)
13
-		{
14
-			$vid =  Yii::app()->getRequest()->getQuery('vid');
15
-			return array(
16
-				'accessControl',
17
-				array(
18
-					'CHttpCacheFilter + index',
19
-					'cacheControl'=>Cii::get(Yii::app()->user->id) == NULL ? 'public' : 'private' .', no-cache, must-revalidate',
20
-					'etagSeed' => $id.$vid
21
-				),
22
-				array(
23
-					'COutputCache + index',
24
-					'duration' => YII_DEBUG ? 1 : 86400, // 24 hour cache duration
25
-					'varyByParam' => array('id', 'vid'),
26
-					'varyByLanguage' => true,
27
-					'varyByExpression' => 'Yii::app()->user->isGuest'
28
-				)
29
-			);
30
-		}
31
-
32
-		return CMap::mergeArray(parent::filters(), array(array(
33
-			'COutputCache + list',
34
-			'duration' => YII_DEBUG ? 1 : 86400,
35
-			'varyByParam' => array('page'),
36
-			'varyByLanguage' => true,
37
-			'dependency' => array(
38
-				'class'=>'CDbCacheDependency',
39
-				'sql'=>'SELECT MAX(updated) FROM content',
40
-			)
41
-		)));
42
-	}
43
-
44
-
45
-	/**
46
-	 * Specifies the access control rules.
47
-	 * This method is used by the 'accessControl' filter.
48
-	 * @return array access control rules
49
-	 */
50
-	public function accessRules()
51
-	{
52
-		return array(
53
-			array('allow',  // Allow all users to any section
54
-				'actions' => array('index', 'password', 'list'),
55
-				'users'=>array('*'),
56
-			),
57
-			array('deny',  // deny all users
58
-				'users'=>array('*'),
59
-			),
60
-		);
61
-	}
62
-
63
-	/**
64
-	 * Handles all incoming requests for the entire site that are not previous defined in CUrlManager
65
-	 * Requests come in, are verified, and then pulled from the database dynamically
66
-	 * @param $id	- The content ID that we want to pull from the database
67
-	 **/
68
-	public function actionIndex($id=NULL, $vid=NULL)
69
-	{
70
-		// Set the ReturnURL to this page so that the user can be redirected back to here after login
71
-		Yii::app()->user->setReturnUrl($this->beforeCiiAction($id));
72
-
73
-		// Retrieve the data
74
-		$content = Content::model()->findByPk($id);
75
-
76
-		if ($content->status != 1 || !$content->isPublished())
77
-			throw new CHttpException(404, Yii::t('ciims.controllers.Content', 'The article you specified does not exist. If you bookmarked this page, please delete it.'));
78
-
79
-		// Check for a password
80
-		if (!empty($content->password))
81
-		{
82
-			// Check SESSION to see if a password is set
83
-			$tmpPassword = Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'password', NULL);
84
-
85
-			if ($tmpPassword != $content->password)
86
-				$this->redirect(Yii::app()->createUrl('/content/password/' . $id));
87
-		}
88
-
89
-		// Parse Metadata
90
-		$this->setLayout($content->layout);
91
-
92
-		$this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
93
-			'{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
94
-			'{{label}}'    => $content->title
95
-		)));
96
-
97
-		$this->params['meta']['description'] = $content->extract;
98
-		$this->render($content->view, array(
99
-			'id' 	=> $content->id,
100
-			'data' 	=> $content,
101
-			'meta' 	=> $content->parseMeta($content->id)
102
-		));
103
-	}
104
-
105
-	/**
106
-	 * Forces a password to be assigned before the user can proceed to the previous page
107
-	 * @param $id - ID of the content we want to investigate
108
-	 **/
109
-	public function actionPassword($id=NULL)
110
-	{
111
-		$this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
112
-			'{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
113
-			'{{label}}'    => Yii::t('ciims.controllers.Content', 'Password Required')
114
-		)));
115
-
116
-		if ($id == NULL)
117
-			$this->redirect(Yii::app()->user->returnUrl);
118
-
119
-		// Set some default data
120
-		if (Cii::get(Cii::get($_SESSION, 'password', array()), $id, NULL) == NULL)
121
-			$_SESSION['password'][$id] = array('tries'=>0, 'expires' => time() + 300);
122
-
123
-		// If the number of attempts is >= 3
124
-		if (Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'tries', 0) >= 3)
125
-		{
126
-			// If the expires time has already passed, unlock the account
127
-			if (Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'expires', 0) <= time())
128
-			{
129
-				$_SESSION['password'][$id] = array('tries'=>0, 'expires' => time() + 300);
130
-			}
131
-			else
132
-			{
133
-				// Otherwise prevent access to it
134
-				Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Content', 'Too many password attempts. Please try again in 5 minutes'));
135
-				unset($_POST['password']);
136
-				$_SESSION['password'][$id]['expires'] 	= time() + 300;
137
-			}
138
-		}
139
-
140
-		if (Cii::get($_POST, 'password', NULL) !== NULL)
141
-		{
142
-			$content = Content::model()->findByPk($id);
143
-
144
-			$encrypted = Cii::encrypt(Cii::get($_POST, 'password'));
145
-
146
-			if ($encrypted == $content->attributes['password'])
147
-			{
148
-				$_SESSION['password'][$id]['password'] = $encrypted;
149
-				$_SESSION['password'][$id]['tries'] = 0;
150
-				$this->redirect(Yii::app()->createUrl($content->attributes['slug']));
151
-			}
152
-			else
153
-			{
154
-				Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Content', 'Incorrect password'));
155
-				$_SESSION['password'][$id]['tries'] 	= $_SESSION['password'][$id]['tries'] + 1;
156
-				$_SESSION['password'][$id]['expires'] 	= time() + 300;
157
-			}
158
-
159
-		}
160
-
161
-		$this->layout = 'password';
162
-		$this->render('password', array(
163
-			'id' => $id
164
-		));
165
-	}
166
-
167
-	/*
168
-	 * Displays a listing of all blog posts for all time in all categories
169
-	 * Is used as a generic catch all behavior
170
-	 */
171
-	public function actionList()
172
-	{
173
-		$this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
174
-			'{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
175
-			'{{label}}'    => Yii::t('ciims.controllers.Content', 'All Content')
176
-		)));
177
-
178
-		$this->setLayout('default');
179
-
180
-		$pageSize = Cii::getConfig('contentPaginationSize', 10);
5
+    /**
6
+     * Base filter, allows logged in and non-logged in users to cache the page
7
+     */
8
+    public function filters()
9
+    {
10
+        $id = Yii::app()->getRequest()->getQuery('id');
11
+
12
+        if ($id != NULL)
13
+        {
14
+            $vid =  Yii::app()->getRequest()->getQuery('vid');
15
+            return array(
16
+                'accessControl',
17
+                array(
18
+                    'CHttpCacheFilter + index',
19
+                    'cacheControl'=>Cii::get(Yii::app()->user->id) == NULL ? 'public' : 'private' .', no-cache, must-revalidate',
20
+                    'etagSeed' => $id.$vid
21
+                ),
22
+                array(
23
+                    'COutputCache + index',
24
+                    'duration' => YII_DEBUG ? 1 : 86400, // 24 hour cache duration
25
+                    'varyByParam' => array('id', 'vid'),
26
+                    'varyByLanguage' => true,
27
+                    'varyByExpression' => 'Yii::app()->user->isGuest'
28
+                )
29
+            );
30
+        }
181 31
 
182
-		$criteria = Content::model()
183
-					->getBaseCriteria()
184
-					->addCondition('type_id >= 2')
185
-					->addCondition('password = ""');
32
+        return CMap::mergeArray(parent::filters(), array(array(
33
+            'COutputCache + list',
34
+            'duration' => YII_DEBUG ? 1 : 86400,
35
+            'varyByParam' => array('page'),
36
+            'varyByLanguage' => true,
37
+            'dependency' => array(
38
+                'class'=>'CDbCacheDependency',
39
+                'sql'=>'SELECT MAX(updated) FROM content',
40
+            )
41
+        )));
42
+    }
43
+
44
+
45
+    /**
46
+     * Specifies the access control rules.
47
+     * This method is used by the 'accessControl' filter.
48
+     * @return array access control rules
49
+     */
50
+    public function accessRules()
51
+    {
52
+        return array(
53
+            array('allow',  // Allow all users to any section
54
+                'actions' => array('index', 'password', 'list'),
55
+                'users'=>array('*'),
56
+            ),
57
+            array('deny',  // deny all users
58
+                'users'=>array('*'),
59
+            ),
60
+        );
61
+    }
62
+
63
+    /**
64
+     * Handles all incoming requests for the entire site that are not previous defined in CUrlManager
65
+     * Requests come in, are verified, and then pulled from the database dynamically
66
+     * @param $id	- The content ID that we want to pull from the database
67
+     **/
68
+    public function actionIndex($id=NULL, $vid=NULL)
69
+    {
70
+        // Set the ReturnURL to this page so that the user can be redirected back to here after login
71
+        Yii::app()->user->setReturnUrl($this->beforeCiiAction($id));
72
+
73
+        // Retrieve the data
74
+        $content = Content::model()->findByPk($id);
75
+
76
+        if ($content->status != 1 || !$content->isPublished())
77
+            throw new CHttpException(404, Yii::t('ciims.controllers.Content', 'The article you specified does not exist. If you bookmarked this page, please delete it.'));
78
+
79
+        // Check for a password
80
+        if (!empty($content->password))
81
+        {
82
+            // Check SESSION to see if a password is set
83
+            $tmpPassword = Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'password', NULL);
186 84
 
187
-		$criteria->order = 'published DESC';
85
+            if ($tmpPassword != $content->password)
86
+                $this->redirect(Yii::app()->createUrl('/content/password/' . $id));
87
+        }
188 88
 
189
-		$criteria->limit = $pageSize;
89
+        // Parse Metadata
90
+        $this->setLayout($content->layout);
91
+
92
+        $this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
93
+            '{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
94
+            '{{label}}'    => $content->title
95
+        )));
96
+
97
+        $this->params['meta']['description'] = $content->extract;
98
+        $this->render($content->view, array(
99
+            'id' 	=> $content->id,
100
+            'data' 	=> $content,
101
+            'meta' 	=> $content->parseMeta($content->id)
102
+        ));
103
+    }
104
+
105
+    /**
106
+     * Forces a password to be assigned before the user can proceed to the previous page
107
+     * @param $id - ID of the content we want to investigate
108
+     **/
109
+    public function actionPassword($id=NULL)
110
+    {
111
+        $this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
112
+            '{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
113
+            '{{label}}'    => Yii::t('ciims.controllers.Content', 'Password Required')
114
+        )));
115
+
116
+        if ($id == NULL)
117
+            $this->redirect(Yii::app()->user->returnUrl);
118
+
119
+        // Set some default data
120
+        if (Cii::get(Cii::get($_SESSION, 'password', array()), $id, NULL) == NULL)
121
+            $_SESSION['password'][$id] = array('tries'=>0, 'expires' => time() + 300);
122
+
123
+        // If the number of attempts is >= 3
124
+        if (Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'tries', 0) >= 3)
125
+        {
126
+            // If the expires time has already passed, unlock the account
127
+            if (Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'expires', 0) <= time())
128
+            {
129
+                $_SESSION['password'][$id] = array('tries'=>0, 'expires' => time() + 300);
130
+            }
131
+            else
132
+            {
133
+                // Otherwise prevent access to it
134
+                Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Content', 'Too many password attempts. Please try again in 5 minutes'));
135
+                unset($_POST['password']);
136
+                $_SESSION['password'][$id]['expires'] 	= time() + 300;
137
+            }
138
+        }
190 139
 
191
-		$itemCount = Content::model()->count($criteria);
192
-		$pages = new CPagination($itemCount);
193
-		$pages->pageSize=$pageSize;
140
+        if (Cii::get($_POST, 'password', NULL) !== NULL)
141
+        {
142
+            $content = Content::model()->findByPk($id);
143
+
144
+            $encrypted = Cii::encrypt(Cii::get($_POST, 'password'));
145
+
146
+            if ($encrypted == $content->attributes['password'])
147
+            {
148
+                $_SESSION['password'][$id]['password'] = $encrypted;
149
+                $_SESSION['password'][$id]['tries'] = 0;
150
+                $this->redirect(Yii::app()->createUrl($content->attributes['slug']));
151
+            }
152
+            else
153
+            {
154
+                Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Content', 'Incorrect password'));
155
+                $_SESSION['password'][$id]['tries'] 	= $_SESSION['password'][$id]['tries'] + 1;
156
+                $_SESSION['password'][$id]['expires'] 	= time() + 300;
157
+            }
194 158
 
195
-		$criteria->offset = $criteria->limit*($pages->getCurrentPage());
196
-		$data = Content::model()->findAll($criteria);
197
-		$pages->applyLimit($criteria);
159
+        }
198 160
 
199
-		$this->render('all', array(
200
-			'data'		=> $data,
201
-			'itemCount' => $itemCount,
202
-			'pages' 	=> $pages
203
-		));
204
-	}
161
+        $this->layout = 'password';
162
+        $this->render('password', array(
163
+            'id' => $id
164
+        ));
165
+    }
205 166
 
206
-	/**
207
-	 * No routing action
167
+    /*
168
+	 * Displays a listing of all blog posts for all time in all categories
169
+	 * Is used as a generic catch all behavior
208 170
 	 */
209
-	public function actionNR()
210
-	{
171
+    public function actionList()
172
+    {
173
+        $this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
174
+            '{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
175
+            '{{label}}'    => Yii::t('ciims.controllers.Content', 'All Content')
176
+        )));
177
+
178
+        $this->setLayout('default');
179
+
180
+        $pageSize = Cii::getConfig('contentPaginationSize', 10);
181
+
182
+        $criteria = Content::model()
183
+                    ->getBaseCriteria()
184
+                    ->addCondition('type_id >= 2')
185
+                    ->addCondition('password = ""');
186
+
187
+        $criteria->order = 'published DESC';
188
+
189
+        $criteria->limit = $pageSize;
190
+
191
+        $itemCount = Content::model()->count($criteria);
192
+        $pages = new CPagination($itemCount);
193
+        $pages->pageSize=$pageSize;
194
+
195
+        $criteria->offset = $criteria->limit*($pages->getCurrentPage());
196
+        $data = Content::model()->findAll($criteria);
197
+        $pages->applyLimit($criteria);
198
+
199
+        $this->render('all', array(
200
+            'data'		=> $data,
201
+            'itemCount' => $itemCount,
202
+            'pages' 	=> $pages
203
+        ));
204
+    }
205
+
206
+    /**
207
+     * No routing action
208
+     */
209
+    public function actionNR()
210
+    {
211 211
         $themeName = Cii::getConfig('theme', 'default');
212 212
         if (file_exists(Yii::getPathOfAlias('webroot.themes.') . DS . $themeName .  DS . 'Theme.php'))
213 213
         {
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
             $theme = new Theme;
216 216
         }
217 217
 
218
-		if ($theme->noRouting !== false)
219
-			$this->render('index');
220
-		else
221
-			throw new CHttpException(404);
222
-	}
218
+        if ($theme->noRouting !== false)
219
+            $this->render('index');
220
+        else
221
+            throw new CHttpException(404);
222
+    }
223 223
 }
Please login to merge, or discard this patch.
Braces   +33 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class ContentController extends CiiController
4
-{
3
+class ContentController extends CiiController
4
+{
5 5
 	/**
6 6
 	 * Base filter, allows logged in and non-logged in users to cache the page
7 7
 	 */
8
-	public function filters()
9
-	{
8
+	public function filters()
9
+	{
10 10
 		$id = Yii::app()->getRequest()->getQuery('id');
11 11
 
12 12
 		if ($id != NULL)
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 	 * This method is used by the 'accessControl' filter.
48 48
 	 * @return array access control rules
49 49
 	 */
50
-	public function accessRules()
51
-	{
50
+	public function accessRules()
51
+	{
52 52
 		return array(
53 53
 			array('allow',  // Allow all users to any section
54 54
 				'actions' => array('index', 'password', 'list'),
@@ -65,16 +65,17 @@  discard block
 block discarded – undo
65 65
 	 * Requests come in, are verified, and then pulled from the database dynamically
66 66
 	 * @param $id	- The content ID that we want to pull from the database
67 67
 	 **/
68
-	public function actionIndex($id=NULL, $vid=NULL)
69
-	{
68
+	public function actionIndex($id=NULL, $vid=NULL)
69
+	{
70 70
 		// Set the ReturnURL to this page so that the user can be redirected back to here after login
71 71
 		Yii::app()->user->setReturnUrl($this->beforeCiiAction($id));
72 72
 
73 73
 		// Retrieve the data
74 74
 		$content = Content::model()->findByPk($id);
75 75
 
76
-		if ($content->status != 1 || !$content->isPublished())
77
-			throw new CHttpException(404, Yii::t('ciims.controllers.Content', 'The article you specified does not exist. If you bookmarked this page, please delete it.'));
76
+		if ($content->status != 1 || !$content->isPublished()) {
77
+					throw new CHttpException(404, Yii::t('ciims.controllers.Content', 'The article you specified does not exist. If you bookmarked this page, please delete it.'));
78
+		}
78 79
 
79 80
 		// Check for a password
80 81
 		if (!empty($content->password))
@@ -82,8 +83,9 @@  discard block
 block discarded – undo
82 83
 			// Check SESSION to see if a password is set
83 84
 			$tmpPassword = Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'password', NULL);
84 85
 
85
-			if ($tmpPassword != $content->password)
86
-				$this->redirect(Yii::app()->createUrl('/content/password/' . $id));
86
+			if ($tmpPassword != $content->password) {
87
+							$this->redirect(Yii::app()->createUrl('/content/password/' . $id));
88
+			}
87 89
 		}
88 90
 
89 91
 		// Parse Metadata
@@ -106,19 +108,21 @@  discard block
 block discarded – undo
106 108
 	 * Forces a password to be assigned before the user can proceed to the previous page
107 109
 	 * @param $id - ID of the content we want to investigate
108 110
 	 **/
109
-	public function actionPassword($id=NULL)
110
-	{
111
+	public function actionPassword($id=NULL)
112
+	{
111 113
 		$this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
112 114
 			'{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
113 115
 			'{{label}}'    => Yii::t('ciims.controllers.Content', 'Password Required')
114 116
 		)));
115 117
 
116
-		if ($id == NULL)
117
-			$this->redirect(Yii::app()->user->returnUrl);
118
+		if ($id == NULL) {
119
+					$this->redirect(Yii::app()->user->returnUrl);
120
+		}
118 121
 
119 122
 		// Set some default data
120
-		if (Cii::get(Cii::get($_SESSION, 'password', array()), $id, NULL) == NULL)
121
-			$_SESSION['password'][$id] = array('tries'=>0, 'expires' => time() + 300);
123
+		if (Cii::get(Cii::get($_SESSION, 'password', array()), $id, NULL) == NULL) {
124
+					$_SESSION['password'][$id] = array('tries'=>0, 'expires' => time() + 300);
125
+		}
122 126
 
123 127
 		// If the number of attempts is >= 3
124 128
 		if (Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'tries', 0) >= 3)
@@ -127,8 +131,7 @@  discard block
 block discarded – undo
127 131
 			if (Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'expires', 0) <= time())
128 132
 			{
129 133
 				$_SESSION['password'][$id] = array('tries'=>0, 'expires' => time() + 300);
130
-			}
131
-			else
134
+			} else
132 135
 			{
133 136
 				// Otherwise prevent access to it
134 137
 				Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Content', 'Too many password attempts. Please try again in 5 minutes'));
@@ -148,8 +151,7 @@  discard block
 block discarded – undo
148 151
 				$_SESSION['password'][$id]['password'] = $encrypted;
149 152
 				$_SESSION['password'][$id]['tries'] = 0;
150 153
 				$this->redirect(Yii::app()->createUrl($content->attributes['slug']));
151
-			}
152
-			else
154
+			} else
153 155
 			{
154 156
 				Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Content', 'Incorrect password'));
155 157
 				$_SESSION['password'][$id]['tries'] 	= $_SESSION['password'][$id]['tries'] + 1;
@@ -168,8 +170,8 @@  discard block
 block discarded – undo
168 170
 	 * Displays a listing of all blog posts for all time in all categories
169 171
 	 * Is used as a generic catch all behavior
170 172
 	 */
171
-	public function actionList()
172
-	{
173
+	public function actionList()
174
+	{
173 175
 		$this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
174 176
 			'{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
175 177
 			'{{label}}'    => Yii::t('ciims.controllers.Content', 'All Content')
@@ -206,8 +208,8 @@  discard block
 block discarded – undo
206 208
 	/**
207 209
 	 * No routing action
208 210
 	 */
209
-	public function actionNR()
210
-	{
211
+	public function actionNR()
212
+	{
211 213
         $themeName = Cii::getConfig('theme', 'default');
212 214
         if (file_exists(Yii::getPathOfAlias('webroot.themes.') . DS . $themeName .  DS . 'Theme.php'))
213 215
         {
@@ -215,9 +217,10 @@  discard block
 block discarded – undo
215 217
             $theme = new Theme;
216 218
         }
217 219
 
218
-		if ($theme->noRouting !== false)
219
-			$this->render('index');
220
-		else
221
-			throw new CHttpException(404);
220
+		if ($theme->noRouting !== false) {
221
+					$this->render('index');
222
+		} else {
223
+					throw new CHttpException(404);
224
+		}
222 225
 	}
223 226
 }
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -5,18 +5,18 @@  discard block
 block discarded – undo
5 5
 	/**
6 6
 	 * Base filter, allows logged in and non-logged in users to cache the page
7 7
 	 */
8
-	public function filters()
8
+	public function filters ()
9 9
 	{
10
-		$id = Yii::app()->getRequest()->getQuery('id');
10
+		$id = Yii::app ()->getRequest ()->getQuery ('id');
11 11
 
12 12
 		if ($id != NULL)
13 13
 		{
14
-			$vid =  Yii::app()->getRequest()->getQuery('vid');
14
+			$vid = Yii::app ()->getRequest ()->getQuery ('vid');
15 15
 			return array(
16 16
 				'accessControl',
17 17
 				array(
18 18
 					'CHttpCacheFilter + index',
19
-					'cacheControl'=>Cii::get(Yii::app()->user->id) == NULL ? 'public' : 'private' .', no-cache, must-revalidate',
19
+					'cacheControl'=>Cii::get (Yii::app ()->user->id) == NULL ? 'public' : 'private'.', no-cache, must-revalidate',
20 20
 					'etagSeed' => $id.$vid
21 21
 				),
22 22
 				array(
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 			);
30 30
 		}
31 31
 
32
-		return CMap::mergeArray(parent::filters(), array(array(
32
+		return CMap::mergeArray (parent::filters (), array(array(
33 33
 			'COutputCache + list',
34 34
 			'duration' => YII_DEBUG ? 1 : 86400,
35 35
 			'varyByParam' => array('page'),
@@ -47,14 +47,14 @@  discard block
 block discarded – undo
47 47
 	 * This method is used by the 'accessControl' filter.
48 48
 	 * @return array access control rules
49 49
 	 */
50
-	public function accessRules()
50
+	public function accessRules ()
51 51
 	{
52 52
 		return array(
53
-			array('allow',  // Allow all users to any section
53
+			array('allow', // Allow all users to any section
54 54
 				'actions' => array('index', 'password', 'list'),
55 55
 				'users'=>array('*'),
56 56
 			),
57
-			array('deny',  // deny all users
57
+			array('deny', // deny all users
58 58
 				'users'=>array('*'),
59 59
 			),
60 60
 		);
@@ -65,40 +65,40 @@  discard block
 block discarded – undo
65 65
 	 * Requests come in, are verified, and then pulled from the database dynamically
66 66
 	 * @param $id	- The content ID that we want to pull from the database
67 67
 	 **/
68
-	public function actionIndex($id=NULL, $vid=NULL)
68
+	public function actionIndex ($id = NULL, $vid = NULL)
69 69
 	{
70 70
 		// Set the ReturnURL to this page so that the user can be redirected back to here after login
71
-		Yii::app()->user->setReturnUrl($this->beforeCiiAction($id));
71
+		Yii::app ()->user->setReturnUrl ($this->beforeCiiAction ($id));
72 72
 
73 73
 		// Retrieve the data
74
-		$content = Content::model()->findByPk($id);
74
+		$content = Content::model ()->findByPk ($id);
75 75
 
76
-		if ($content->status != 1 || !$content->isPublished())
77
-			throw new CHttpException(404, Yii::t('ciims.controllers.Content', 'The article you specified does not exist. If you bookmarked this page, please delete it.'));
76
+		if ($content->status != 1 || !$content->isPublished ())
77
+			throw new CHttpException (404, Yii::t ('ciims.controllers.Content', 'The article you specified does not exist. If you bookmarked this page, please delete it.'));
78 78
 
79 79
 		// Check for a password
80 80
 		if (!empty($content->password))
81 81
 		{
82 82
 			// Check SESSION to see if a password is set
83
-			$tmpPassword = Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'password', NULL);
83
+			$tmpPassword = Cii::get (Cii::get (Cii::get ($_SESSION, 'password', array()), $id, array()), 'password', NULL);
84 84
 
85 85
 			if ($tmpPassword != $content->password)
86
-				$this->redirect(Yii::app()->createUrl('/content/password/' . $id));
86
+				$this->redirect (Yii::app ()->createUrl ('/content/password/'.$id));
87 87
 		}
88 88
 
89 89
 		// Parse Metadata
90
-		$this->setLayout($content->layout);
90
+		$this->setLayout ($content->layout);
91 91
 
92
-		$this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
93
-			'{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
92
+		$this->setPageTitle (Yii::t ('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
93
+			'{{app_name}}' => Cii::getConfig ('name', Yii::app ()->name),
94 94
 			'{{label}}'    => $content->title
95 95
 		)));
96 96
 
97 97
 		$this->params['meta']['description'] = $content->extract;
98
-		$this->render($content->view, array(
98
+		$this->render ($content->view, array(
99 99
 			'id' 	=> $content->id,
100 100
 			'data' 	=> $content,
101
-			'meta' 	=> $content->parseMeta($content->id)
101
+			'meta' 	=> $content->parseMeta ($content->id)
102 102
 		));
103 103
 	}
104 104
 
@@ -106,60 +106,60 @@  discard block
 block discarded – undo
106 106
 	 * Forces a password to be assigned before the user can proceed to the previous page
107 107
 	 * @param $id - ID of the content we want to investigate
108 108
 	 **/
109
-	public function actionPassword($id=NULL)
109
+	public function actionPassword ($id = NULL)
110 110
 	{
111
-		$this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
112
-			'{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
113
-			'{{label}}'    => Yii::t('ciims.controllers.Content', 'Password Required')
111
+		$this->setPageTitle (Yii::t ('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
112
+			'{{app_name}}' => Cii::getConfig ('name', Yii::app ()->name),
113
+			'{{label}}'    => Yii::t ('ciims.controllers.Content', 'Password Required')
114 114
 		)));
115 115
 
116 116
 		if ($id == NULL)
117
-			$this->redirect(Yii::app()->user->returnUrl);
117
+			$this->redirect (Yii::app ()->user->returnUrl);
118 118
 
119 119
 		// Set some default data
120
-		if (Cii::get(Cii::get($_SESSION, 'password', array()), $id, NULL) == NULL)
121
-			$_SESSION['password'][$id] = array('tries'=>0, 'expires' => time() + 300);
120
+		if (Cii::get (Cii::get ($_SESSION, 'password', array()), $id, NULL) == NULL)
121
+			$_SESSION['password'][$id] = array('tries'=>0, 'expires' => time () + 300);
122 122
 
123 123
 		// If the number of attempts is >= 3
124
-		if (Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'tries', 0) >= 3)
124
+		if (Cii::get (Cii::get (Cii::get ($_SESSION, 'password', array()), $id, array()), 'tries', 0) >= 3)
125 125
 		{
126 126
 			// If the expires time has already passed, unlock the account
127
-			if (Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'expires', 0) <= time())
127
+			if (Cii::get (Cii::get (Cii::get ($_SESSION, 'password', array()), $id, array()), 'expires', 0) <= time ())
128 128
 			{
129
-				$_SESSION['password'][$id] = array('tries'=>0, 'expires' => time() + 300);
129
+				$_SESSION['password'][$id] = array('tries'=>0, 'expires' => time () + 300);
130 130
 			}
131 131
 			else
132 132
 			{
133 133
 				// Otherwise prevent access to it
134
-				Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Content', 'Too many password attempts. Please try again in 5 minutes'));
134
+				Yii::app ()->user->setFlash ('error', Yii::t ('ciims.controllers.Content', 'Too many password attempts. Please try again in 5 minutes'));
135 135
 				unset($_POST['password']);
136
-				$_SESSION['password'][$id]['expires'] 	= time() + 300;
136
+				$_SESSION['password'][$id]['expires'] = time () + 300;
137 137
 			}
138 138
 		}
139 139
 
140
-		if (Cii::get($_POST, 'password', NULL) !== NULL)
140
+		if (Cii::get ($_POST, 'password', NULL) !== NULL)
141 141
 		{
142
-			$content = Content::model()->findByPk($id);
142
+			$content = Content::model ()->findByPk ($id);
143 143
 
144
-			$encrypted = Cii::encrypt(Cii::get($_POST, 'password'));
144
+			$encrypted = Cii::encrypt (Cii::get ($_POST, 'password'));
145 145
 
146 146
 			if ($encrypted == $content->attributes['password'])
147 147
 			{
148 148
 				$_SESSION['password'][$id]['password'] = $encrypted;
149 149
 				$_SESSION['password'][$id]['tries'] = 0;
150
-				$this->redirect(Yii::app()->createUrl($content->attributes['slug']));
150
+				$this->redirect (Yii::app ()->createUrl ($content->attributes['slug']));
151 151
 			}
152 152
 			else
153 153
 			{
154
-				Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Content', 'Incorrect password'));
155
-				$_SESSION['password'][$id]['tries'] 	= $_SESSION['password'][$id]['tries'] + 1;
156
-				$_SESSION['password'][$id]['expires'] 	= time() + 300;
154
+				Yii::app ()->user->setFlash ('error', Yii::t ('ciims.controllers.Content', 'Incorrect password'));
155
+				$_SESSION['password'][$id]['tries'] = $_SESSION['password'][$id]['tries'] + 1;
156
+				$_SESSION['password'][$id]['expires'] = time () + 300;
157 157
 			}
158 158
 
159 159
 		}
160 160
 
161 161
 		$this->layout = 'password';
162
-		$this->render('password', array(
162
+		$this->render ('password', array(
163 163
 			'id' => $id
164 164
 		));
165 165
 	}
@@ -168,35 +168,35 @@  discard block
 block discarded – undo
168 168
 	 * Displays a listing of all blog posts for all time in all categories
169 169
 	 * Is used as a generic catch all behavior
170 170
 	 */
171
-	public function actionList()
171
+	public function actionList ()
172 172
 	{
173
-		$this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
174
-			'{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
175
-			'{{label}}'    => Yii::t('ciims.controllers.Content', 'All Content')
173
+		$this->setPageTitle (Yii::t ('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
174
+			'{{app_name}}' => Cii::getConfig ('name', Yii::app ()->name),
175
+			'{{label}}'    => Yii::t ('ciims.controllers.Content', 'All Content')
176 176
 		)));
177 177
 
178
-		$this->setLayout('default');
178
+		$this->setLayout ('default');
179 179
 
180
-		$pageSize = Cii::getConfig('contentPaginationSize', 10);
180
+		$pageSize = Cii::getConfig ('contentPaginationSize', 10);
181 181
 
182
-		$criteria = Content::model()
183
-					->getBaseCriteria()
184
-					->addCondition('type_id >= 2')
185
-					->addCondition('password = ""');
182
+		$criteria = Content::model ()
183
+					->getBaseCriteria ()
184
+					->addCondition ('type_id >= 2')
185
+					->addCondition ('password = ""');
186 186
 
187 187
 		$criteria->order = 'published DESC';
188 188
 
189 189
 		$criteria->limit = $pageSize;
190 190
 
191
-		$itemCount = Content::model()->count($criteria);
192
-		$pages = new CPagination($itemCount);
193
-		$pages->pageSize=$pageSize;
191
+		$itemCount = Content::model ()->count ($criteria);
192
+		$pages = new CPagination ($itemCount);
193
+		$pages->pageSize = $pageSize;
194 194
 
195
-		$criteria->offset = $criteria->limit*($pages->getCurrentPage());
196
-		$data = Content::model()->findAll($criteria);
197
-		$pages->applyLimit($criteria);
195
+		$criteria->offset = $criteria->limit * ($pages->getCurrentPage ());
196
+		$data = Content::model ()->findAll ($criteria);
197
+		$pages->applyLimit ($criteria);
198 198
 
199
-		$this->render('all', array(
199
+		$this->render ('all', array(
200 200
 			'data'		=> $data,
201 201
 			'itemCount' => $itemCount,
202 202
 			'pages' 	=> $pages
@@ -206,18 +206,18 @@  discard block
 block discarded – undo
206 206
 	/**
207 207
 	 * No routing action
208 208
 	 */
209
-	public function actionNR()
209
+	public function actionNR ()
210 210
 	{
211
-        $themeName = Cii::getConfig('theme', 'default');
212
-        if (file_exists(Yii::getPathOfAlias('webroot.themes.') . DS . $themeName .  DS . 'Theme.php'))
211
+        $themeName = Cii::getConfig ('theme', 'default');
212
+        if (file_exists (Yii::getPathOfAlias ('webroot.themes.').DS.$themeName.DS.'Theme.php'))
213 213
         {
214
-            Yii::import('webroot.themes.' . $themeName . '.Theme');
214
+            Yii::import ('webroot.themes.'.$themeName.'.Theme');
215 215
             $theme = new Theme;
216 216
         }
217 217
 
218 218
 		if ($theme->noRouting !== false)
219
-			$this->render('index');
219
+			$this->render ('index');
220 220
 		else
221
-			throw new CHttpException(404);
221
+			throw new CHttpException (404);
222 222
 	}
223 223
 }
Please login to merge, or discard this patch.