Completed
Push — prado-3.3 ( e90646...0b76d5 )
by Fabio
23:37 queued 03:01
created
framework/I18N/core/Gettext/TGettext.php 4 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
      *
119 119
      * @static
120 120
      * @access  public
121
-     * @return  mixed   Returns true on success or PEAR_Error on failure.
121
+     * @return  boolean   Returns true on success or PEAR_Error on failure.
122 122
      * @param   string  $pofile path to GNU PO file
123 123
      * @param   string  $mofile path to GNU MO file
124 124
      */
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
      * toMO
261 261
      *
262 262
      * @access  protected
263
-     * @return  object  File_Gettext_MO
263
+     * @return  TGettext_MO  File_Gettext_MO
264 264
      */
265 265
     function toMO()
266 266
     {
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
      * toPO
275 275
      *
276 276
      * @access  protected
277
-     * @return  object      File_Gettext_PO
277
+     * @return  TGettext_PO      File_Gettext_PO
278 278
      */
279 279
     function toPO()
280 280
     {
Please login to merge, or discard this patch.
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -58,229 +58,229 @@
 block discarded – undo
58 58
  */
59 59
 class TGettext
60 60
 {
61
-    /**
62
-     * strings
63
-     *
64
-     * associative array with all [msgid => msgstr] entries
65
-     *
66
-     * @access  protected
67
-     * @var     array
68
-    */
69
-    protected $strings = array();
61
+	/**
62
+	 * strings
63
+	 *
64
+	 * associative array with all [msgid => msgstr] entries
65
+	 *
66
+	 * @access  protected
67
+	 * @var     array
68
+	 */
69
+	protected $strings = array();
70 70
 
71
-    /**
72
-     * meta
73
-     *
74
-     * associative array containing meta
75
-     * information like project name or content type
76
-     *
77
-     * @access  protected
78
-     * @var     array
79
-     */
80
-    protected $meta = array();
71
+	/**
72
+	 * meta
73
+	 *
74
+	 * associative array containing meta
75
+	 * information like project name or content type
76
+	 *
77
+	 * @access  protected
78
+	 * @var     array
79
+	 */
80
+	protected $meta = array();
81 81
 
82
-    /**
83
-     * file path
84
-     *
85
-     * @access  protected
86
-     * @var     string
87
-     */
88
-    protected $file = '';
82
+	/**
83
+	 * file path
84
+	 *
85
+	 * @access  protected
86
+	 * @var     string
87
+	 */
88
+	protected $file = '';
89 89
 
90
-    /**
91
-     * Factory
92
-     *
93
-     * @static
94
-     * @access  public
95
-     * @return  object  Returns File_Gettext_PO or File_Gettext_MO on success
96
-     *                  or PEAR_Error on failure.
97
-     * @param   string  $format MO or PO
98
-     * @param   string  $file   path to GNU gettext file
99
-     */
100
-    static function factory($format, $file = '')
101
-    {
102
-        $format = strToUpper($format);
103
-        $filename = dirname(__FILE__).'/'.$format.'.php';
104
-        if(is_file($filename) == false)
105
-        	throw new Exception ("Class file $file not found");
90
+	/**
91
+	 * Factory
92
+	 *
93
+	 * @static
94
+	 * @access  public
95
+	 * @return  object  Returns File_Gettext_PO or File_Gettext_MO on success
96
+	 *                  or PEAR_Error on failure.
97
+	 * @param   string  $format MO or PO
98
+	 * @param   string  $file   path to GNU gettext file
99
+	 */
100
+	static function factory($format, $file = '')
101
+	{
102
+		$format = strToUpper($format);
103
+		$filename = dirname(__FILE__).'/'.$format.'.php';
104
+		if(is_file($filename) == false)
105
+			throw new Exception ("Class file $file not found");
106 106
 
107
-        include_once $filename;
108
-        $class = 'TGettext_' . $format;
107
+		include_once $filename;
108
+		$class = 'TGettext_' . $format;
109 109
 
110
-        return new $class($file);
111
-    }
110
+		return new $class($file);
111
+	}
112 112
 
113
-    /**
114
-     * poFile2moFile
115
-     *
116
-     * That's a simple fake of the 'msgfmt' console command.  It reads the
117
-     * contents of a GNU PO file and saves them to a GNU MO file.
118
-     *
119
-     * @static
120
-     * @access  public
121
-     * @return  mixed   Returns true on success or PEAR_Error on failure.
122
-     * @param   string  $pofile path to GNU PO file
123
-     * @param   string  $mofile path to GNU MO file
124
-     */
125
-    static function poFile2moFile($pofile, $mofile)
126
-    {
127
-        if (!is_file($pofile)) {
128
-            throw new Exception("File $pofile doesn't exist.");
129
-        }
113
+	/**
114
+	 * poFile2moFile
115
+	 *
116
+	 * That's a simple fake of the 'msgfmt' console command.  It reads the
117
+	 * contents of a GNU PO file and saves them to a GNU MO file.
118
+	 *
119
+	 * @static
120
+	 * @access  public
121
+	 * @return  mixed   Returns true on success or PEAR_Error on failure.
122
+	 * @param   string  $pofile path to GNU PO file
123
+	 * @param   string  $mofile path to GNU MO file
124
+	 */
125
+	static function poFile2moFile($pofile, $mofile)
126
+	{
127
+		if (!is_file($pofile)) {
128
+			throw new Exception("File $pofile doesn't exist.");
129
+		}
130 130
 
131
-        include_once dirname(__FILE__).'/PO.php';
131
+		include_once dirname(__FILE__).'/PO.php';
132 132
 
133
-        $PO = new TGettext_PO($pofile);
134
-        if (true !== ($e = $PO->load())) {
135
-            return $e;
136
-        }
133
+		$PO = new TGettext_PO($pofile);
134
+		if (true !== ($e = $PO->load())) {
135
+			return $e;
136
+		}
137 137
 
138
-        $MO = $PO->toMO();
139
-        if (true !== ($e = $MO->save($mofile))) {
140
-            return $e;
141
-        }
142
-        unset($PO, $MO);
138
+		$MO = $PO->toMO();
139
+		if (true !== ($e = $MO->save($mofile))) {
140
+			return $e;
141
+		}
142
+		unset($PO, $MO);
143 143
 
144
-        return true;
145
-    }
144
+		return true;
145
+	}
146 146
 
147
-    /**
148
-     * prepare
149
-     *
150
-     * @static
151
-     * @access  protected
152
-     * @return  string
153
-     * @param   string  $string
154
-     * @param   bool    $reverse
155
-     */
156
-    static function prepare($string, $reverse = false)
157
-    {
158
-        if ($reverse) {
159
-            $smap = array('"', "\n", "\t", "\r");
160
-            $rmap = array('\"', '\\n"' . "\n" . '"', '\\t', '\\r');
161
-            return (string) str_replace($smap, $rmap, $string);
162
-        } else {
163
-        	$string = preg_replace('/"\s+"/', '', $string);
164
-            $smap = array('\\n', '\\r', '\\t', '\"');
165
-            $rmap = array("\n", "\r", "\t", '"');
166
-            return (string) str_replace($smap, $rmap, $string);
167
-        }
168
-    }
147
+	/**
148
+	 * prepare
149
+	 *
150
+	 * @static
151
+	 * @access  protected
152
+	 * @return  string
153
+	 * @param   string  $string
154
+	 * @param   bool    $reverse
155
+	 */
156
+	static function prepare($string, $reverse = false)
157
+	{
158
+		if ($reverse) {
159
+			$smap = array('"', "\n", "\t", "\r");
160
+			$rmap = array('\"', '\\n"' . "\n" . '"', '\\t', '\\r');
161
+			return (string) str_replace($smap, $rmap, $string);
162
+		} else {
163
+			$string = preg_replace('/"\s+"/', '', $string);
164
+			$smap = array('\\n', '\\r', '\\t', '\"');
165
+			$rmap = array("\n", "\r", "\t", '"');
166
+			return (string) str_replace($smap, $rmap, $string);
167
+		}
168
+	}
169 169
 
170
-    /**
171
-     * meta2array
172
-     *
173
-     * @static
174
-     * @access  public
175
-     * @return  array
176
-     * @param   string  $meta
177
-     */
178
-    static function meta2array($meta)
179
-    {
180
-        $array = array();
181
-        foreach (explode("\n", $meta) as $info) {
182
-            if ($info = trim($info)) {
183
-                list($key, $value) = explode(':', $info, 2);
184
-                $array[trim($key)] = trim($value);
185
-            }
186
-        }
187
-        return $array;
188
-    }
170
+	/**
171
+	 * meta2array
172
+	 *
173
+	 * @static
174
+	 * @access  public
175
+	 * @return  array
176
+	 * @param   string  $meta
177
+	 */
178
+	static function meta2array($meta)
179
+	{
180
+		$array = array();
181
+		foreach (explode("\n", $meta) as $info) {
182
+			if ($info = trim($info)) {
183
+				list($key, $value) = explode(':', $info, 2);
184
+				$array[trim($key)] = trim($value);
185
+			}
186
+		}
187
+		return $array;
188
+	}
189 189
 
190
-    /**
191
-     * toArray
192
-     *
193
-     * Returns meta info and strings as an array of a structure like that:
194
-     * <code>
195
-     *   array(
196
-     *       'meta' => array(
197
-     *           'Content-Type'      => 'text/plain; charset=iso-8859-1',
198
-     *           'Last-Translator'   => 'Michael Wallner <[email protected]>',
199
-     *           'PO-Revision-Date'  => '2004-07-21 17:03+0200',
200
-     *           'Language-Team'     => 'German <[email protected]>',
201
-     *       ),
202
-     *       'strings' => array(
203
-     *           'All rights reserved'   => 'Alle Rechte vorbehalten',
204
-     *           'Welcome'               => 'Willkommen',
205
-     *           // ...
206
-     *       )
207
-     *   )
208
-     * </code>
209
-     *
210
-     * @see     fromArray()
211
-     * @access  protected
212
-     * @return  array
213
-     */
214
-    function toArray()
215
-    {
216
-    	return array('meta' => $this->meta, 'strings' => $this->strings);
217
-    }
190
+	/**
191
+	 * toArray
192
+	 *
193
+	 * Returns meta info and strings as an array of a structure like that:
194
+	 * <code>
195
+	 *   array(
196
+	 *       'meta' => array(
197
+	 *           'Content-Type'      => 'text/plain; charset=iso-8859-1',
198
+	 *           'Last-Translator'   => 'Michael Wallner <[email protected]>',
199
+	 *           'PO-Revision-Date'  => '2004-07-21 17:03+0200',
200
+	 *           'Language-Team'     => 'German <[email protected]>',
201
+	 *       ),
202
+	 *       'strings' => array(
203
+	 *           'All rights reserved'   => 'Alle Rechte vorbehalten',
204
+	 *           'Welcome'               => 'Willkommen',
205
+	 *           // ...
206
+	 *       )
207
+	 *   )
208
+	 * </code>
209
+	 *
210
+	 * @see     fromArray()
211
+	 * @access  protected
212
+	 * @return  array
213
+	 */
214
+	function toArray()
215
+	{
216
+		return array('meta' => $this->meta, 'strings' => $this->strings);
217
+	}
218 218
 
219
-    /**
220
-     * fromArray
221
-     *
222
-     * Assigns meta info and strings from an array of a structure like that:
223
-     * <code>
224
-     *   array(
225
-     *       'meta' => array(
226
-     *           'Content-Type'      => 'text/plain; charset=iso-8859-1',
227
-     *           'Last-Translator'   => 'Michael Wallner <[email protected]>',
228
-     *           'PO-Revision-Date'  => date('Y-m-d H:iO'),
229
-     *           'Language-Team'     => 'German <[email protected]>',
230
-     *       ),
231
-     *       'strings' => array(
232
-     *           'All rights reserved'   => 'Alle Rechte vorbehalten',
233
-     *           'Welcome'               => 'Willkommen',
234
-     *           // ...
235
-     *       )
236
-     *   )
237
-     * </code>
238
-     *
239
-     * @see     toArray()
240
-     * @access  protected
241
-     * @return  bool
242
-     * @param   array       $array
243
-     */
244
-    function fromArray($array)
245
-    {
246
-    	if (!array_key_exists('strings', $array)) {
247
-    	    if (count($array) != 2) {
248
-                return false;
249
-    	    } else {
250
-    	        list($this->meta, $this->strings) = $array;
251
-            }
252
-    	} else {
253
-            $this->meta = @$array['meta'];
254
-            $this->strings = @$array['strings'];
255
-        }
256
-        return true;
257
-    }
219
+	/**
220
+	 * fromArray
221
+	 *
222
+	 * Assigns meta info and strings from an array of a structure like that:
223
+	 * <code>
224
+	 *   array(
225
+	 *       'meta' => array(
226
+	 *           'Content-Type'      => 'text/plain; charset=iso-8859-1',
227
+	 *           'Last-Translator'   => 'Michael Wallner <[email protected]>',
228
+	 *           'PO-Revision-Date'  => date('Y-m-d H:iO'),
229
+	 *           'Language-Team'     => 'German <[email protected]>',
230
+	 *       ),
231
+	 *       'strings' => array(
232
+	 *           'All rights reserved'   => 'Alle Rechte vorbehalten',
233
+	 *           'Welcome'               => 'Willkommen',
234
+	 *           // ...
235
+	 *       )
236
+	 *   )
237
+	 * </code>
238
+	 *
239
+	 * @see     toArray()
240
+	 * @access  protected
241
+	 * @return  bool
242
+	 * @param   array       $array
243
+	 */
244
+	function fromArray($array)
245
+	{
246
+		if (!array_key_exists('strings', $array)) {
247
+			if (count($array) != 2) {
248
+				return false;
249
+			} else {
250
+				list($this->meta, $this->strings) = $array;
251
+			}
252
+		} else {
253
+			$this->meta = @$array['meta'];
254
+			$this->strings = @$array['strings'];
255
+		}
256
+		return true;
257
+	}
258 258
 
259
-    /**
260
-     * toMO
261
-     *
262
-     * @access  protected
263
-     * @return  object  File_Gettext_MO
264
-     */
265
-    function toMO()
266
-    {
267
-        include_once dirname(__FILE__).'/MO.php';
268
-        $MO = new TGettext_MO;
269
-        $MO->fromArray($this->toArray());
270
-        return $MO;
271
-    }
259
+	/**
260
+	 * toMO
261
+	 *
262
+	 * @access  protected
263
+	 * @return  object  File_Gettext_MO
264
+	 */
265
+	function toMO()
266
+	{
267
+		include_once dirname(__FILE__).'/MO.php';
268
+		$MO = new TGettext_MO;
269
+		$MO->fromArray($this->toArray());
270
+		return $MO;
271
+	}
272 272
 
273
-    /**
274
-     * toPO
275
-     *
276
-     * @access  protected
277
-     * @return  object      File_Gettext_PO
278
-     */
279
-    function toPO()
280
-    {
281
-        include_once dirname(__FILE__).'/PO.php';
282
-        $PO = new TGettext_PO;
283
-        $PO->fromArray($this->toArray());
284
-        return $PO;
285
-    }
273
+	/**
274
+	 * toPO
275
+	 *
276
+	 * @access  protected
277
+	 * @return  object      File_Gettext_PO
278
+	 */
279
+	function toPO()
280
+	{
281
+		include_once dirname(__FILE__).'/PO.php';
282
+		$PO = new TGettext_PO;
283
+		$PO->fromArray($this->toArray());
284
+		return $PO;
285
+	}
286 286
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
     static function factory($format, $file = '')
101 101
     {
102 102
         $format = strToUpper($format);
103
-        $filename = dirname(__FILE__).'/'.$format.'.php';
104
-        if(is_file($filename) == false)
105
-        	throw new Exception ("Class file $file not found");
103
+        $filename = dirname(__FILE__) . '/' . $format . '.php';
104
+        if (is_file($filename) == false)
105
+        	throw new Exception("Class file $file not found");
106 106
 
107 107
         include_once $filename;
108 108
         $class = 'TGettext_' . $format;
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
             throw new Exception("File $pofile doesn't exist.");
129 129
         }
130 130
 
131
-        include_once dirname(__FILE__).'/PO.php';
131
+        include_once dirname(__FILE__) . '/PO.php';
132 132
 
133 133
         $PO = new TGettext_PO($pofile);
134 134
         if (true !== ($e = $PO->load())) {
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
      */
265 265
     function toMO()
266 266
     {
267
-        include_once dirname(__FILE__).'/MO.php';
267
+        include_once dirname(__FILE__) . '/MO.php';
268 268
         $MO = new TGettext_MO;
269 269
         $MO->fromArray($this->toArray());
270 270
         return $MO;
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
      */
279 279
     function toPO()
280 280
     {
281
-        include_once dirname(__FILE__).'/PO.php';
281
+        include_once dirname(__FILE__) . '/PO.php';
282 282
         $PO = new TGettext_PO;
283 283
         $PO->fromArray($this->toArray());
284 284
         return $PO;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@
 block discarded – undo
125 125
     static function poFile2moFile($pofile, $mofile)
126 126
     {
127 127
         if (!is_file($pofile)) {
128
-            throw new Exception("File $pofile doesn't exist.");
128
+            throw new Exception("file $pofile doesn't exist.");
129 129
         }
130 130
 
131 131
         include_once dirname(__FILE__).'/PO.php';
Please login to merge, or discard this patch.
framework/I18N/core/MessageCache.php 2 patches
Doc Comments   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -99,9 +99,7 @@
 block discarded – undo
99 99
 	 * Get the data from the cache.
100 100
 	 * @param string $catalogue The translation section.
101 101
 	 * @param string $culture The translation locale, e.g. "en_AU".
102
-	 * @param string $filename If the source is a file, this file's modified
103
-	 * time is newer than the cache's modified time, no cache hit.
104
-	 * @return mixed Boolean FALSE if no cache hit. Otherwise, translation
102
+	 * @return false|string Boolean FALSE if no cache hit. Otherwise, translation
105 103
 	 * table data for the specified section and locale.
106 104
 	 */
107 105
 	public function get($catalogue, $culture, $lastmodified=0)
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 /**
9 9
  * Load the cache lite library.
10 10
  */
11
-require_once(dirname(__FILE__).'/TCache_Lite.php');
11
+require_once(dirname(__FILE__) . '/TCache_Lite.php');
12 12
 
13 13
 /**
14 14
  * Cache the translation table into the file system.
@@ -37,15 +37,15 @@  discard block
 block discarded – undo
37 37
 	 */
38 38
 	public function __construct($cacheDir)
39 39
 	{
40
-		$cacheDir = $cacheDir.'/';
40
+		$cacheDir = $cacheDir . '/';
41 41
 
42
-		if(!is_dir($cacheDir))
42
+		if (!is_dir($cacheDir))
43 43
 			throw new Exception(
44
-				'The cache directory '.$cacheDir.' does not exists.'.
44
+				'The cache directory ' . $cacheDir . ' does not exists.' .
45 45
 				'The cache directory must be writable by the server.');
46
-		if(!is_writable($cacheDir))
46
+		if (!is_writable($cacheDir))
47 47
 			throw new Exception(
48
-				'The cache directory '.$cacheDir.' must be writable '.
48
+				'The cache directory ' . $cacheDir . ' must be writable ' .
49 49
 				'by the server.');
50 50
 
51 51
 		$options = array(
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	public function setLifeTime($time)
74 74
 	{
75
-		$this->lifetime = (int)$time;
75
+		$this->lifetime = (int) $time;
76 76
 	}
77 77
 
78 78
 	/**
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 */
83 83
 	protected function getID($catalogue, $culture)
84 84
 	{
85
-		return $catalogue.':'.$culture;
85
+		return $catalogue . ':' . $culture;
86 86
 	}
87 87
 
88 88
 	/**
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	protected function getGroup($catalogue, $culture)
94 94
 	{
95
-		return $catalogue.':'.get_class($this);
95
+		return $catalogue . ':' . get_class($this);
96 96
 	}
97 97
 
98 98
 	/**
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * @return mixed Boolean FALSE if no cache hit. Otherwise, translation
105 105
 	 * table data for the specified section and locale.
106 106
 	 */
107
-	public function get($catalogue, $culture, $lastmodified=0)
107
+	public function get($catalogue, $culture, $lastmodified = 0)
108 108
 	{
109 109
 		$ID = $this->getID($catalogue, $culture);
110 110
 		$group = $this->getGroup($catalogue, $culture);
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
 
114 114
 		$cache = $this->cache->getCacheFile();
115 115
 
116
-		if(is_file($cache) == false)
116
+		if (is_file($cache) == false)
117 117
 			return false;
118 118
 
119 119
 
120
-		$lastmodified = (int)$lastmodified;
120
+		$lastmodified = (int) $lastmodified;
121 121
 
122
-		if($lastmodified <= 0 || $lastmodified > filemtime($cache))
122
+		if ($lastmodified <= 0 || $lastmodified > filemtime($cache))
123 123
 			return false;
124 124
 
125 125
 		//echo '@@ Cache hit: "'.$ID.'" : "'.$group.'"';
Please login to merge, or discard this patch.
framework/I18N/core/MessageFormat.php 3 patches
Doc Comments   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -111,6 +111,7 @@  discard block
 block discarded – undo
111 111
 	/** 
112 112
 	 * Sets the charset for message output.
113 113
 	 * @param string charset, default is UTF-8
114
+	 * @param string $charset
114 115
 	 */
115 116
 	public function setCharset($charset)
116 117
 	{
@@ -171,9 +172,9 @@  discard block
 block discarded – undo
171 172
 
172 173
 	/**
173 174
 	 * Do string translation.
174
-	 * @param string the string to translate.
175
+	 * @param string string string to translate.
175 176
 	 * @param array a list of string to substitute.
176
-	 * @param string get the translation from a particular message
177
+	 * @param string string the translation from a particular message
177 178
 	 * catalogue.
178 179
 	 * @return string translated string.
179 180
 	 */
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
 /**
21 21
  * Get the MessageSource classes.
22 22
  */
23
-require_once(dirname(__FILE__).'/MessageSource.php');
23
+require_once(dirname(__FILE__) . '/MessageSource.php');
24 24
 
25 25
 /**
26 26
  * Get the encoding utilities
27 27
  */
28
-require_once(dirname(__FILE__).'/util.php');
28
+require_once(dirname(__FILE__) . '/util.php');
29 29
 
30 30
 /**
31 31
  * MessageFormat class.
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 * The prefix and suffix to append to untranslated messages.
82 82
 	 * @var array 
83 83
 	 */
84
-	protected $postscript = array('','');
84
+	protected $postscript = array('', '');
85 85
 	
86 86
 	/**
87 87
 	 * Set the default catalogue.
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @param MessageSource the source of translation messages.
103 103
 	 * @param string charset for the message output.
104 104
 	 */
105
-	function __construct(IMessageSource $source, $charset='UTF-8')
105
+	function __construct(IMessageSource $source, $charset = 'UTF-8')
106 106
 	{
107 107
 		$this->source = $source;	
108 108
 		$this->setCharset($charset);
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
 	 */
136 136
 	protected function loadCatalogue($catalogue)
137 137
 	{
138
-		if(in_array($catalogue,$this->catagloues))
138
+		if (in_array($catalogue, $this->catagloues))
139 139
 			return;
140 140
 			
141
-		if($this->source->load($catalogue))
141
+		if ($this->source->load($catalogue))
142 142
 		{
143 143
 			$this->messages[$catalogue] = $this->source->read();
144 144
 			$this->catagloues[] = $catalogue;						
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
 	 * catalogue.
159 159
 	 * @return string translated string.
160 160
 	 */
161
-	public function format($string,$args=array(), $catalogue=null, $charset=null) 
161
+	public function format($string, $args = array(), $catalogue = null, $charset = null) 
162 162
 	{
163
-		if(empty($charset)) $charset = $this->getCharset();
163
+		if (empty($charset)) $charset = $this->getCharset();
164 164
 		
165 165
 		//force args as UTF-8
166
-		foreach($args as $k => $v)
166
+		foreach ($args as $k => $v)
167 167
 			$args[$k] = I18N_toUTF8($v, $charset);
168
-		$s = $this->formatString(I18N_toUTF8($string, $charset),$args,$catalogue);
168
+		$s = $this->formatString(I18N_toUTF8($string, $charset), $args, $catalogue);
169 169
 		return I18N_toEncoding($s, $charset);
170 170
 	}
171 171
 
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 	 * catalogue.
178 178
 	 * @return string translated string.
179 179
 	 */
180
-	protected function formatString($string, $args=array(), $catalogue=null)
180
+	protected function formatString($string, $args = array(), $catalogue = null)
181 181
 	{		
182
-		if(empty($catalogue))
182
+		if (empty($catalogue))
183 183
 		{
184
-			if(empty($this->Catalogue))
184
+			if (empty($this->Catalogue))
185 185
 				$catalogue = 'messages';
186 186
 			else 
187 187
 				$catalogue = $this->Catalogue;
@@ -189,29 +189,29 @@  discard block
 block discarded – undo
189 189
 				
190 190
 		$this->loadCatalogue($catalogue);
191 191
 		
192
-		if(empty($args))
192
+		if (empty($args))
193 193
 			$args = array();		
194 194
 		
195
-		foreach($this->messages[$catalogue] as $variant)
195
+		foreach ($this->messages[$catalogue] as $variant)
196 196
 		{
197 197
 			// foreach of the translation units
198
-			foreach($variant as $source => $result)
198
+			foreach ($variant as $source => $result)
199 199
 			{ 
200 200
 				// we found it, so return the target translation
201
-				if($source == $string)
201
+				if ($source == $string)
202 202
 				{
203 203
 					//check if it contains only strings.
204
-					if(is_string($result))
204
+					if (is_string($result))
205 205
 						$target = $result;
206 206
 					else
207 207
 					{
208 208
 						$target = $result[0];
209 209
 					}
210 210
 					//found, but untranslated
211
-					if(empty($target))
211
+					if (empty($target))
212 212
 					{
213
-						return 	$this->postscript[0].
214
-								strtr($string, $args).
213
+						return 	$this->postscript[0] .
214
+								strtr($string, $args) .
215 215
 								$this->postscript[1];		
216 216
 					}
217 217
 					else
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 		// well we did not find the translation string.
224 224
 		$this->source->append($string);
225 225
 		
226
-		return 	$this->postscript[0].
227
-				strtr($string, $args).
226
+		return 	$this->postscript[0] .
227
+				strtr($string, $args) .
228 228
 				$this->postscript[1];
229 229
 	}
230 230
 	
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 */
246 246
 	function setUntranslatedPS($postscript)
247 247
 	{
248
-		if(is_array($postscript) && count($postscript)>=2)
248
+		if (is_array($postscript) && count($postscript) >= 2)
249 249
 		{
250 250
 			$this->postscript[0] = $postscript[0];
251 251
 			$this->postscript[1] = $postscript[1];
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -163,8 +163,9 @@  discard block
 block discarded – undo
163 163
 		if(empty($charset)) $charset = $this->getCharset();
164 164
 		
165 165
 		//force args as UTF-8
166
-		foreach($args as $k => $v)
167
-			$args[$k] = I18N_toUTF8($v, $charset);
166
+		foreach($args as $k => $v) {
167
+					$args[$k] = I18N_toUTF8($v, $charset);
168
+		}
168 169
 		$s = $this->formatString(I18N_toUTF8($string, $charset),$args,$catalogue);
169 170
 		return I18N_toEncoding($s, $charset);
170 171
 	}
@@ -213,8 +214,7 @@  discard block
 block discarded – undo
213 214
 						return 	$this->postscript[0].
214 215
 								strtr($string, $args).
215 216
 								$this->postscript[1];		
216
-					}
217
-					else
217
+					} else
218 218
 						return strtr($target, $args);
219 219
 				}
220 220
 			}
Please login to merge, or discard this patch.
framework/I18N/core/MessageSource.php 4 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -252,6 +252,7 @@  discard block
 block discarded – undo
252 252
 	/**
253 253
 	 * Set the culture for this message source.
254 254
 	 * @param string culture name
255
+	 * @param string $culture
255 256
 	 */
256 257
 	public function setCulture($culture)
257 258
 	{
@@ -270,6 +271,7 @@  discard block
 block discarded – undo
270 271
 	/**
271 272
 	 * Get the last modified unix-time for this particular catalogue+variant.
272 273
 	 * @param string catalogue+variant
274
+	 * @param string $source
273 275
 	 * @return int last modified in unix-time format.
274 276
 	 */
275 277
 	protected function getLastModified($source)
@@ -281,6 +283,7 @@  discard block
 block discarded – undo
281 283
 	 * Load the message for a particular catalogue+variant.
282 284
 	 * This methods needs to implemented by subclasses.
283 285
 	 * @param string catalogue+variant.
286
+	 * @param string $variant
284 287
 	 * @return array of translation messages. 
285 288
 	 */
286 289
 	protected function &loadData($variant)
@@ -301,6 +304,7 @@  discard block
 block discarded – undo
301 304
 	/**
302 305
 	 * Determine if the source is valid.
303 306
 	 * @param string catalogue+variant
307
+	 * @param string $source
304 308
 	 * @return boolean true if valid, false otherwise. 
305 309
 	 */
306 310
 	protected function isValidSource($source)
@@ -312,6 +316,7 @@  discard block
 block discarded – undo
312 316
 	 * Get all the variants of a particular catalogue.
313 317
 	 * This method must be implemented by subclasses.
314 318
 	 * @param string catalogue name
319
+	 * @param string $catalogue
315 320
 	 * @return array list of all variants for this catalogue. 
316 321
 	 */	
317 322
 	protected function getCatalogueList($catalogue)
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -109,15 +109,15 @@
 block discarded – undo
109 109
 	/**
110 110
 	 * Factory method to instantiate a new MessageSource depending on the
111 111
 	 * source type. The allowed source types are 'XLIFF', 'gettext' and
112
-     * 'Database'. The source parameter depends on the source type. 
113
-     * For 'gettext' and 'XLIFF', 'source' should point to the directory 
114
-     * where the messages are stored. 
115
-     * For 'Database', 'source' must be a valid connection id.
116
-     * If a deprecated 'SQLite' type is used, 'source' must contain
117
-     * a valid DSN.
112
+	 * 'Database'. The source parameter depends on the source type. 
113
+	 * For 'gettext' and 'XLIFF', 'source' should point to the directory 
114
+	 * where the messages are stored. 
115
+	 * For 'Database', 'source' must be a valid connection id.
116
+	 * If a deprecated 'SQLite' type is used, 'source' must contain
117
+	 * a valid DSN.
118 118
 	 *
119
- 	 * Custom message source are possible by supplying the a filename parameter
120
- 	 * in the factory method.
119
+	 * Custom message source are possible by supplying the a filename parameter
120
+	 * in the factory method.
121 121
 	 * 
122 122
 	 * @param string the message source type.
123 123
 	 * @param string the location of the resource or the ConnectionID.
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
  /**
21 21
   * Get the IMessageSource interface.
22 22
   */
23
-require_once(dirname(__FILE__).'/IMessageSource.php');
23
+require_once(dirname(__FILE__) . '/IMessageSource.php');
24 24
 
25 25
 /**
26 26
  * Get the MessageCache class file.
27 27
  */
28
-require_once(dirname(__FILE__).'/MessageCache.php');
28
+require_once(dirname(__FILE__) . '/MessageCache.php');
29 29
 
30 30
 /**
31 31
  * Abstract MessageSource class.
@@ -125,25 +125,25 @@  discard block
 block discarded – undo
125 125
 	 * @return MessageSource a new message source of the specified type. 
126 126
 	 * @throws InvalidMessageSourceTypeException
127 127
 	 */
128
-	static function &factory($type, $source='.', $filename='')
128
+	static function &factory($type, $source = '.', $filename = '')
129 129
 	{
130
-		$types = array('XLIFF','gettext','Database','SQLite');
130
+		$types = array('XLIFF', 'gettext', 'Database', 'SQLite');
131 131
 
132
-		if(empty($filename) && !in_array($type, $types))
133
-			throw new Exception('Invalid type "'.$type.'", valid types are '.
132
+		if (empty($filename) && !in_array($type, $types))
133
+			throw new Exception('Invalid type "' . $type . '", valid types are ' .
134 134
 				implode(', ', $types));
135 135
 		
136
-		$class = 'MessageSource_'.$type;
136
+		$class = 'MessageSource_' . $type;
137 137
 		
138
-		if(empty($filename))
139
-			$filename = dirname(__FILE__).'/'.$class.'.php';
138
+		if (empty($filename))
139
+			$filename = dirname(__FILE__) . '/' . $class . '.php';
140 140
 						
141
-		if(is_file($filename) == false)
141
+		if (is_file($filename) == false)
142 142
 			throw new Exception("File $filename not found");
143 143
 						
144 144
 		include_once $filename;
145 145
         
146
-		$obj =  new $class($source);
146
+		$obj = new $class($source);
147 147
 		
148 148
 		return $obj;
149 149
 	}
@@ -167,39 +167,39 @@  discard block
 block discarded – undo
167 167
 	 * @return boolean true if loaded, false otherwise.	 
168 168
 	 * @see read()
169 169
 	 */
170
-	function load($catalogue='messages')
170
+	function load($catalogue = 'messages')
171 171
 	{
172 172
 		$variants = $this->getCatalogueList($catalogue);
173 173
 		
174 174
 		$this->messages = array();
175 175
 		
176
-		foreach($variants as $variant)
176
+		foreach ($variants as $variant)
177 177
 		{
178 178
 			$source = $this->getSource($variant);
179 179
 			
180
-			if($this->isValidSource($source) == false) continue;
180
+			if ($this->isValidSource($source) == false) continue;
181 181
 
182 182
 			$loadData = true;
183 183
 			
184
-			if($this->cache)
184
+			if ($this->cache)
185 185
 			{
186 186
 				$data = $this->cache->get($variant, 
187 187
 					$this->culture, $this->getLastModified($source));
188 188
 				
189
-				if(is_array($data))
189
+				if (is_array($data))
190 190
 				{
191 191
 					$this->messages[$variant] = $data;
192 192
 					$loadData = false;
193 193
 				}
194 194
 				unset($data);
195 195
 			}
196
-			if($loadData)
196
+			if ($loadData)
197 197
 			{
198 198
 				$data = &$this->loadData($source);
199
-				if(is_array($data))
199
+				if (is_array($data))
200 200
 				{
201 201
 					$this->messages[$variant] = $data;
202
-					if($this->cache)
202
+					if ($this->cache)
203 203
 						$this->cache->save($data, $variant, $this->culture);
204 204
 				}	
205 205
 				unset($data);
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 	 */	
245 245
 	public function append($message)
246 246
 	{
247
-		if(!in_array($message, $this->untranslated))
247
+		if (!in_array($message, $this->untranslated))
248 248
 			$this->untranslated[] = $message;
249 249
 	}
250 250
 	
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@
 block discarded – undo
139 139
 			$filename = dirname(__FILE__).'/'.$class.'.php';
140 140
 						
141 141
 		if(is_file($filename) == false)
142
-			throw new Exception("File $filename not found");
142
+			throw new Exception("file $filename not found");
143 143
 						
144 144
 		include_once $filename;
145 145
         
Please login to merge, or discard this patch.
framework/I18N/core/MessageSource_Database.php 3 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,6 +60,7 @@  discard block
 block discarded – undo
60 60
 	/**
61 61
 	 * Creates the DB connection.
62 62
 	 * @param string the module ID for TDataSourceConfig
63
+	 * @param string $connectionID
63 64
 	 * @return TDbConnection the created DB connection
64 65
 	 * @throws TConfigurationException if module ID is invalid or empty
65 66
 	 */
@@ -185,7 +186,7 @@  discard block
 block discarded – undo
185 186
 
186 187
 	/**
187 188
 	 * Update the catalogue last modified time.
188
-	 * @return boolean true if updated, false otherwise.
189
+	 * @return integer true if updated, false otherwise.
189 190
 	 */
190 191
 	private function updateCatalogueTime($cat_id, $variant)
191 192
 	{
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * Get the MessageSource class file.
19 19
  */
20
-require_once(dirname(__FILE__).'/MessageSource.php');
20
+require_once(dirname(__FILE__) . '/MessageSource.php');
21 21
 
22 22
 /**
23 23
  * MessageSource_Database class.
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class MessageSource_Database extends MessageSource
32 32
 {
33
-	private $_connID='';
33
+	private $_connID = '';
34 34
 	private $_conn;
35 35
 
36 36
 	/**
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	function __construct($source)
43 43
 	{
44
-		$this->_connID= (string)$source;
44
+		$this->_connID = (string) $source;
45 45
 	}
46 46
 
47 47
 	/**
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public function getDbConnection()
51 51
 	{
52
-		if($this->_conn===null)
52
+		if ($this->_conn === null)
53 53
 		{
54
-			$this->_conn=$this->createDbConnection($this->_connID);
54
+			$this->_conn = $this->createDbConnection($this->_connID);
55 55
 			$this->_conn->setActive(true);
56 56
 		}
57 57
 		return $this->_conn;
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	protected function createDbConnection($connectionID)
67 67
 	{
68
-		if($connectionID!=='')
68
+		if ($connectionID !== '')
69 69
 		{
70
-			$conn=Prado::getApplication()->getModule($connectionID);
71
-			if($conn instanceof TDataSourceConfig)
70
+			$conn = Prado::getApplication()->getModule($connectionID);
71
+			if ($conn instanceof TDataSourceConfig)
72 72
 				return $conn->getDbConnection();
73 73
 			else
74
-				throw new TConfigurationException('messagesource_connectionid_invalid',$connectionID);
74
+				throw new TConfigurationException('messagesource_connectionid_invalid', $connectionID);
75 75
 		}
76 76
 		else
77 77
 			throw new TConfigurationException('messagesource_connectionid_required');
@@ -85,19 +85,19 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	protected function &loadData($variant)
87 87
 	{
88
-		$command=$this->getDBConnection()->createCommand(
88
+		$command = $this->getDBConnection()->createCommand(
89 89
 			'SELECT t.id, t.source, t.target, t.comments
90 90
 				FROM trans_unit t, catalogue c
91 91
 				WHERE c.cat_id =  t.cat_id
92 92
 					AND c.name = :variant
93 93
 				ORDER BY id ASC');
94
-		$command->bindParameter(':variant',$variant,PDO::PARAM_STR);
95
-		$dataReader=$command->query();
94
+		$command->bindParameter(':variant', $variant, PDO::PARAM_STR);
95
+		$dataReader = $command->query();
96 96
 
97 97
 		$result = array();
98 98
 
99 99
 		foreach ($dataReader as $row)
100
-			$result[$row['source']] = array($row['target'],$row['id'],$row['comments']);
100
+			$result[$row['source']] = array($row['target'], $row['id'], $row['comments']);
101 101
 
102 102
 		return $result;
103 103
 	}
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	protected function getLastModified($source)
112 112
 	{
113
-		$command=$this->getDBConnection()->createCommand(
113
+		$command = $this->getDBConnection()->createCommand(
114 114
 			'SELECT date_modified FROM catalogue WHERE name = :source');
115
-		$command->bindParameter(':source',$source,PDO::PARAM_STR);
116
-		$result=$command->queryScalar();
115
+		$command->bindParameter(':source', $source, PDO::PARAM_STR);
116
+		$result = $command->queryScalar();
117 117
 		return $result ? $result : 0;
118 118
 	}
119 119
 
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	protected function isValidSource($variant)
128 128
 	{
129
-		$command=$this->getDBConnection()->createCommand(
129
+		$command = $this->getDBConnection()->createCommand(
130 130
 			'SELECT COUNT(*) FROM catalogue WHERE name = :variant');
131
-		$command->bindParameter(':variant',$variant,PDO::PARAM_STR);
132
-		return $command->queryScalar()==1;
131
+		$command->bindParameter(':variant', $variant, PDO::PARAM_STR);
132
+		return $command->queryScalar() == 1;
133 133
 	}
134 134
 
135 135
 	/**
@@ -139,18 +139,18 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	protected function getCatalogueList($catalogue)
141 141
 	{
142
-		$variants = explode('_',$this->culture);
142
+		$variants = explode('_', $this->culture);
143 143
 
144 144
 		$catalogues = array($catalogue);
145 145
 
146 146
 		$variant = null;
147 147
 
148
-		for($i = 0, $k = count($variants); $i < $k; ++$i)
148
+		for ($i = 0, $k = count($variants); $i < $k; ++$i)
149 149
 		{
150
-			if(isset($variants[$i]{0}))
150
+			if (isset($variants[$i]{0}))
151 151
 			{
152
-				$variant .= ($variant)?'_'.$variants[$i]:$variants[$i];
153
-				$catalogues[] = $catalogue.'.'.$variant;
152
+				$variant .= ($variant) ? '_' . $variants[$i] : $variants[$i];
153
+				$catalogues[] = $catalogue . '.' . $variant;
154 154
 			}
155 155
 		}
156 156
 		return array_reverse($catalogues);
@@ -161,24 +161,24 @@  discard block
 block discarded – undo
161 161
 	 * @param string catalogue
162 162
 	 * @return array catalogue details, array($cat_id, $variant, $count).
163 163
 	 */
164
-	private function getCatalogueDetails($catalogue='messages')
164
+	private function getCatalogueDetails($catalogue = 'messages')
165 165
 	{
166
-		if(empty($catalogue))
166
+		if (empty($catalogue))
167 167
 			$catalogue = 'messages';
168 168
 
169
-		$variant = $catalogue.'.'.$this->culture;
169
+		$variant = $catalogue . '.' . $this->culture;
170 170
 
171
-		$command=$this->getDBConnection()->createCommand(
171
+		$command = $this->getDBConnection()->createCommand(
172 172
 			'SELECT cat_id FROM catalogue WHERE name = :variant');
173
-		$command->bindParameter(':variant',$variant,PDO::PARAM_STR);
174
-		$cat_id=$command->queryScalar();
173
+		$command->bindParameter(':variant', $variant, PDO::PARAM_STR);
174
+		$cat_id = $command->queryScalar();
175 175
 
176
-		if ($cat_id===null) return false;
176
+		if ($cat_id === null) return false;
177 177
 
178
-		$command=$this->getDBConnection()->createCommand(
178
+		$command = $this->getDBConnection()->createCommand(
179 179
 			'SELECT COUNT(msg_id) FROM trans_unit WHERE cat_id = :catid ');
180
-		$command->bindParameter(':catid',$cat_id,PDO::PARAM_INT);
181
-		$count=$command->queryScalar();
180
+		$command->bindParameter(':catid', $cat_id, PDO::PARAM_INT);
181
+		$count = $command->queryScalar();
182 182
 
183 183
 		return array($cat_id, $variant, $count);
184 184
 	}
@@ -190,13 +190,13 @@  discard block
 block discarded – undo
190 190
 	private function updateCatalogueTime($cat_id, $variant)
191 191
 	{
192 192
 		$time = time();
193
-		$command=$this->getDBConnection()->createCommand(
193
+		$command = $this->getDBConnection()->createCommand(
194 194
 			'UPDATE catalogue SET date_modified = :moddate WHERE cat_id = :catid');
195
-		$command->bindParameter(':moddate',$time,PDO::PARAM_INT);
196
-		$command->bindParameter(':catid',$cat_id,PDO::PARAM_INT);
197
-		$result=$command->execute();
195
+		$command->bindParameter(':moddate', $time, PDO::PARAM_INT);
196
+		$command->bindParameter(':catid', $cat_id, PDO::PARAM_INT);
197
+		$result = $command->execute();
198 198
 
199
-		if(!empty($this->cache))
199
+		if (!empty($this->cache))
200 200
 			$this->cache->clean($variant, $this->culture);
201 201
 
202 202
 		return $result;
@@ -209,37 +209,37 @@  discard block
 block discarded – undo
209 209
 	 * @param string the catalogue to add to
210 210
 	 * @return boolean true if saved successfuly, false otherwise.
211 211
 	 */
212
-	function save($catalogue='messages')
212
+	function save($catalogue = 'messages')
213 213
 	{
214 214
 		$messages = $this->untranslated;
215 215
 
216
-		if(count($messages) <= 0) return false;
216
+		if (count($messages) <= 0) return false;
217 217
 
218 218
 		$details = $this->getCatalogueDetails($catalogue);
219 219
 
220
-		if($details)
220
+		if ($details)
221 221
 			list($cat_id, $variant, $count) = $details;
222 222
 		else
223 223
 			return false;
224 224
 
225
-		if($cat_id <= 0) return false;
225
+		if ($cat_id <= 0) return false;
226 226
 		$inserted = 0;
227 227
 
228 228
 		$time = time();
229 229
 
230
-		$command=$this->getDBConnection()->createCommand(
230
+		$command = $this->getDBConnection()->createCommand(
231 231
 			'INSERT INTO trans_unit (cat_id,id,source,date_added) VALUES (:catid,:id,:source,:dateadded)');
232
-		$command->bindParameter(':catid',$cat_id,PDO::PARAM_INT);
233
-		$command->bindParameter(':id',$count,PDO::PARAM_INT);
234
-		$command->bindParameter(':source',$message,PDO::PARAM_STR);
235
-		$command->bindParameter(':dateadded',$time,PDO::PARAM_INT);
236
-		foreach($messages as $message)
232
+		$command->bindParameter(':catid', $cat_id, PDO::PARAM_INT);
233
+		$command->bindParameter(':id', $count, PDO::PARAM_INT);
234
+		$command->bindParameter(':source', $message, PDO::PARAM_STR);
235
+		$command->bindParameter(':dateadded', $time, PDO::PARAM_INT);
236
+		foreach ($messages as $message)
237 237
 		{
238 238
 			if (empty($message)) continue;
239 239
 			$count++; $inserted++;
240 240
 			$command->execute();
241 241
 		}
242
-		if($inserted > 0)
242
+		if ($inserted > 0)
243 243
 			$this->updateCatalogueTime($cat_id, $variant);
244 244
 
245 245
 		return $inserted > 0;
@@ -251,20 +251,20 @@  discard block
 block discarded – undo
251 251
 	 * @param string the catalogue to delete from.
252 252
 	 * @return boolean true if deleted, false otherwise.
253 253
 	 */
254
-	function delete($message, $catalogue='messages')
254
+	function delete($message, $catalogue = 'messages')
255 255
 	{
256 256
 		$details = $this->getCatalogueDetails($catalogue);
257
-		if($details)
257
+		if ($details)
258 258
 			list($cat_id, $variant, $count) = $details;
259 259
 		else
260 260
 			return false;
261 261
 
262
-		$command=$this->getDBConnection()->createCommand(
262
+		$command = $this->getDBConnection()->createCommand(
263 263
 			'DELETE FROM trans_unit WHERE cat_id = :catid AND source = :message');
264
-		$command->bindParameter(':catid',$cat_id,PDO::PARAM_INT);
265
-		$command->bindParameter(':message',$message,PDO::PARAM_STR);
264
+		$command->bindParameter(':catid', $cat_id, PDO::PARAM_INT);
265
+		$command->bindParameter(':message', $message, PDO::PARAM_STR);
266 266
 
267
-		return ($command->execute()==1) ? $this->updateCatalogueTime($cat_id, $variant) : false;
267
+		return ($command->execute() == 1) ? $this->updateCatalogueTime($cat_id, $variant) : false;
268 268
 
269 269
 	}
270 270
 
@@ -276,25 +276,25 @@  discard block
 block discarded – undo
276 276
 	 * @param string the catalogue of the translation.
277 277
 	 * @return boolean true if translation was updated, false otherwise.
278 278
 	 */
279
-	function update($text, $target, $comments, $catalogue='messages')
279
+	function update($text, $target, $comments, $catalogue = 'messages')
280 280
 	{
281 281
 		$details = $this->getCatalogueDetails($catalogue);
282
-		if($details)
282
+		if ($details)
283 283
 			list($cat_id, $variant, $count) = $details;
284 284
 		else
285 285
 			return false;
286 286
 
287 287
 		$time = time();
288
-		$command=$this->getDBConnection()->createCommand(
288
+		$command = $this->getDBConnection()->createCommand(
289 289
 			'UPDATE trans_unit SET target = :target, comments = :comments, date_modified = :datemod
290 290
 					WHERE cat_id = :catid AND source = :source');
291
-		$command->bindParameter(':target',$target,PDO::PARAM_STR);
292
-		$command->bindParameter(':comments',$comments,PDO::PARAM_STR);
293
-		$command->bindParameter(':datemod',$time,PDO::PARAM_INT);
294
-		$command->bindParameter(':catid',$cat_id,PDO::PARAM_INT);
295
-		$command->bindParameter(':source',$text,PDO::PARAM_STR);
291
+		$command->bindParameter(':target', $target, PDO::PARAM_STR);
292
+		$command->bindParameter(':comments', $comments, PDO::PARAM_STR);
293
+		$command->bindParameter(':datemod', $time, PDO::PARAM_INT);
294
+		$command->bindParameter(':catid', $cat_id, PDO::PARAM_INT);
295
+		$command->bindParameter(':source', $text, PDO::PARAM_STR);
296 296
 
297
-		return ($command->execute()==1) ? $this->updateCatalogueTime($cat_id, $variant) : false;
297
+		return ($command->execute() == 1) ? $this->updateCatalogueTime($cat_id, $variant) : false;
298 298
 	}
299 299
 
300 300
 	/**
@@ -303,15 +303,15 @@  discard block
 block discarded – undo
303 303
 	 */
304 304
 	function catalogues()
305 305
 	{
306
-		$command=$this->getDBConnection()->createCommand( 'SELECT name FROM catalogue ORDER BY name');
307
-		$dataReader=$command->query();
306
+		$command = $this->getDBConnection()->createCommand('SELECT name FROM catalogue ORDER BY name');
307
+		$dataReader = $command->query();
308 308
 
309 309
 		$result = array();
310 310
 
311 311
 		foreach ($dataReader as $row)
312 312
 		{
313
-			$details = explode('.',$row[0]);
314
-			if(!isset($details[1])) $details[1] = null;
313
+			$details = explode('.', $row[0]);
314
+			if (!isset($details[1])) $details[1] = null;
315 315
 
316 316
 			$result[] = $details;
317 317
 		}
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,8 +72,7 @@  discard block
 block discarded – undo
72 72
 				return $conn->getDbConnection();
73 73
 			else
74 74
 				throw new TConfigurationException('messagesource_connectionid_invalid',$connectionID);
75
-		}
76
-		else
75
+		} else
77 76
 			throw new TConfigurationException('messagesource_connectionid_required');
78 77
 	}
79 78
 
@@ -96,8 +95,9 @@  discard block
 block discarded – undo
96 95
 
97 96
 		$result = array();
98 97
 
99
-		foreach ($dataReader as $row)
100
-			$result[$row['source']] = array($row['target'],$row['id'],$row['comments']);
98
+		foreach ($dataReader as $row) {
99
+					$result[$row['source']] = array($row['target'],$row['id'],$row['comments']);
100
+		}
101 101
 
102 102
 		return $result;
103 103
 	}
Please login to merge, or discard this patch.
framework/I18N/core/MessageSource_gettext.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -200,6 +200,9 @@  discard block
 block discarded – undo
200 200
 		return false;
201 201
 	}
202 202
 
203
+	/**
204
+	 * @param string $MOFile
205
+	 */
203 206
 	private function getPOFile($MOFile)
204 207
 	{
205 208
 		$filebase = substr($MOFile, 0, strlen($MOFile)-strlen($this->dataExt));
@@ -422,6 +425,9 @@  discard block
 block discarded – undo
422 425
 		return $catalogue;
423 426
 	}
424 427
 
428
+	/**
429
+	 * @param string $catalogue
430
+	 */
425 431
 	protected function createMessageTemplate($catalogue)
426 432
 	{
427 433
 		if($catalogue === null) {
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
 /**
21 21
  * Get the MessageSource class file.
22 22
  */
23
-require_once(dirname(__FILE__).'/MessageSource.php');
23
+require_once(dirname(__FILE__) . '/MessageSource.php');
24 24
 
25 25
 /**
26 26
  * Get the Gettext class.
27 27
  */
28
-require_once(dirname(__FILE__).'/Gettext/TGettext.php');
28
+require_once(dirname(__FILE__) . '/Gettext/TGettext.php');
29 29
 
30 30
 /**
31 31
  * MessageSource_gettext class.
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 
62 62
 	function __construct($source)
63 63
 	{
64
-		$this->source = (string)$source;
64
+		$this->source = (string) $source;
65 65
 	}
66 66
 
67 67
 
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	protected function &loadData($filename)
74 74
 	{
75
-		$mo = TGettext::factory('MO',$filename);
75
+		$mo = TGettext::factory('MO', $filename);
76 76
 		$mo->load();
77 77
 		$result = $mo->toArray();
78 78
 
79 79
 		$results = array();
80
-		$count=0;
81
-		foreach($result['strings'] as $source => $target)
80
+		$count = 0;
81
+		foreach ($result['strings'] as $source => $target)
82 82
 		{
83 83
 			$results[$source][] = $target; //target
84 84
 			$results[$source][] = $count++; //id
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	protected function getSource($variant)
107 107
 	{
108
-		return $this->source.'/'.$variant;
108
+		return $this->source . '/' . $variant;
109 109
 	}
110 110
 
111 111
 	/**
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	protected function getLastModified($source)
118 118
 	{
119
-		if(is_file($source))
119
+		if (is_file($source))
120 120
 			return filemtime($source);
121 121
 		else
122 122
 			return 0;
@@ -129,24 +129,24 @@  discard block
 block discarded – undo
129 129
 	 */
130 130
 	protected function getCatalogueList($catalogue)
131 131
 	{
132
-		$variants = explode('_',$this->culture);
133
-		$source = $catalogue.$this->dataExt;
132
+		$variants = explode('_', $this->culture);
133
+		$source = $catalogue . $this->dataExt;
134 134
 
135 135
 		$catalogues = array($source);
136 136
 
137 137
 		$variant = null;
138 138
 
139
-		for($i = 0, $k = count($variants); $i < $k; ++$i)
139
+		for ($i = 0, $k = count($variants); $i < $k; ++$i)
140 140
 		{
141
-			if(isset($variants[$i]{0}))
141
+			if (isset($variants[$i]{0}))
142 142
 			{
143
-				$variant .= ($variant)?'_'.$variants[$i]:$variants[$i];
144
-				$catalogues[] = $catalogue.$this->dataSeparator.
145
-								$variant.$this->dataExt;
143
+				$variant .= ($variant) ? '_' . $variants[$i] : $variants[$i];
144
+				$catalogues[] = $catalogue . $this->dataSeparator .
145
+								$variant . $this->dataExt;
146 146
 			}
147 147
 		}
148 148
 		$byDir = $this->getCatalogueByDir($catalogue);
149
-		$catalogues = array_merge($byDir,array_reverse($catalogues));
149
+		$catalogues = array_merge($byDir, array_reverse($catalogues));
150 150
 		return $catalogues;
151 151
 	}
152 152
 
@@ -160,17 +160,17 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	private function getCatalogueByDir($catalogue)
162 162
 	{
163
-		$variants = explode('_',$this->culture);
163
+		$variants = explode('_', $this->culture);
164 164
 		$catalogues = array();
165 165
 
166 166
 		$variant = null;
167 167
 
168
-		for($i = 0, $k = count($variants); $i < $k; ++$i)
168
+		for ($i = 0, $k = count($variants); $i < $k; ++$i)
169 169
 		{
170
-			if(isset($variants[$i]{0}))
170
+			if (isset($variants[$i]{0}))
171 171
 			{
172
-				$variant .= ($variant)?'_'.$variants[$i]:$variants[$i];
173
-				$catalogues[] = $variant.'/'.$catalogue.$this->dataExt;
172
+				$variant .= ($variant) ? '_' . $variants[$i] : $variants[$i];
173
+				$catalogues[] = $variant . '/' . $catalogue . $this->dataExt;
174 174
 			}
175 175
 		}
176 176
 		return array_reverse($catalogues);
@@ -184,17 +184,17 @@  discard block
 block discarded – undo
184 184
 	 * @see update()
185 185
 	 * @see delete()
186 186
 	 */
187
-	private function getVariants($catalogue='messages')
187
+	private function getVariants($catalogue = 'messages')
188 188
 	{
189
-		if($catalogue === null) {
189
+		if ($catalogue === null) {
190 190
 			$catalogue = 'messages';
191 191
 		}
192 192
 
193
-		foreach($this->getCatalogueList($catalogue) as $variant)
193
+		foreach ($this->getCatalogueList($catalogue) as $variant)
194 194
 		{
195 195
 			$file = $this->getSource($variant);
196 196
 			$po = $this->getPOFile($file);
197
-			if(is_file($file) || is_file($po))
197
+			if (is_file($file) || is_file($po))
198 198
 				return array($variant, $file, $po);
199 199
 		}
200 200
 		return false;
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
 
203 203
 	private function getPOFile($MOFile)
204 204
 	{
205
-		$filebase = substr($MOFile, 0, strlen($MOFile)-strlen($this->dataExt));
206
-		return $filebase.$this->poExt;
205
+		$filebase = substr($MOFile, 0, strlen($MOFile) - strlen($this->dataExt));
206
+		return $filebase . $this->poExt;
207 207
 	}
208 208
 
209 209
 	/**
@@ -213,51 +213,51 @@  discard block
 block discarded – undo
213 213
 	 * @param string the catalogue to add to
214 214
 	 * @return boolean true if saved successfuly, false otherwise.
215 215
 	 */
216
-	function save($catalogue='messages')
216
+	function save($catalogue = 'messages')
217 217
 	{
218 218
 		$messages = $this->untranslated;
219 219
 
220
-		if(count($messages) <= 0) return false;
220
+		if (count($messages) <= 0) return false;
221 221
 
222 222
 		$variants = $this->getVariants($catalogue);
223 223
 
224
-		if($variants)
224
+		if ($variants)
225 225
 			list($variant, $MOFile, $POFile) = $variants;
226 226
 		else
227 227
 			list($variant, $MOFile, $POFile) = $this->createMessageTemplate($catalogue);
228 228
 
229
-		if(is_writable($MOFile) == false)
229
+		if (is_writable($MOFile) == false)
230 230
 			throw new TIOException("Unable to save to file {$MOFile}, file must be writable.");
231
-		if(is_writable($POFile) == false)
231
+		if (is_writable($POFile) == false)
232 232
 			throw new TIOException("Unable to save to file {$POFile}, file must be writable.");
233 233
 
234 234
 		//set the strings as untranslated.
235 235
 		$strings = array();
236
-		foreach($messages as $message)
236
+		foreach ($messages as $message)
237 237
 			$strings[$message] = '';
238 238
 
239 239
 		//load the PO
240
-		$po = TGettext::factory('PO',$POFile);
240
+		$po = TGettext::factory('PO', $POFile);
241 241
 		$po->load();
242 242
 		$result = $po->toArray();
243 243
 
244 244
 		$existing = count($result['strings']);
245 245
 
246 246
 		//add to strings to the existing message list
247
-		$result['strings'] = array_merge($result['strings'],$strings);
247
+		$result['strings'] = array_merge($result['strings'], $strings);
248 248
 
249 249
 		$new = count($result['strings']);
250 250
 
251
-		if($new > $existing)
251
+		if ($new > $existing)
252 252
 		{
253 253
 			//change the date 2004-12-25 12:26
254 254
 			$result['meta']['PO-Revision-Date'] = @date('Y-m-d H:i:s');
255 255
 
256 256
 			$po->fromArray($result);
257 257
 			$mo = $po->toMO();
258
-			if($po->save() && $mo->save($MOFile))
258
+			if ($po->save() && $mo->save($MOFile))
259 259
 			{
260
-				if(!empty($this->cache))
260
+				if (!empty($this->cache))
261 261
 					$this->cache->clean($variant, $this->culture);
262 262
 				return true;
263 263
 			}
@@ -273,35 +273,35 @@  discard block
 block discarded – undo
273 273
 	 * @param string the catalogue to delete from.
274 274
 	 * @return boolean true if deleted, false otherwise.
275 275
 	 */
276
-	function delete($message, $catalogue='messages')
276
+	function delete($message, $catalogue = 'messages')
277 277
 	{
278 278
 		$variants = $this->getVariants($catalogue);
279
-		if($variants)
279
+		if ($variants)
280 280
 			list($variant, $MOFile, $POFile) = $variants;
281 281
 		else
282 282
 			return false;
283 283
 
284
-		if(is_writable($MOFile) == false)
284
+		if (is_writable($MOFile) == false)
285 285
 			throw new TIOException("Unable to modify file {$MOFile}, file must be writable.");
286
-		if(is_writable($POFile) == false)
286
+		if (is_writable($POFile) == false)
287 287
 			throw new TIOException("Unable to modify file {$POFile}, file must be writable.");
288 288
 
289
-		$po = TGettext::factory('PO',$POFile);
289
+		$po = TGettext::factory('PO', $POFile);
290 290
 		$po->load();
291 291
 		$result = $po->toArray();
292 292
 
293
-		foreach($result['strings'] as $string => $value)
293
+		foreach ($result['strings'] as $string => $value)
294 294
 		{
295
-			if($string == $message)
295
+			if ($string == $message)
296 296
 			{
297 297
 				$result['meta']['PO-Revision-Date'] = @date('Y-m-d H:i:s');
298 298
 				unset($result['strings'][$string]);
299 299
 
300 300
 				$po->fromArray($result);
301 301
 				$mo = $po->toMO();
302
-				if($po->save() && $mo->save($MOFile))
302
+				if ($po->save() && $mo->save($MOFile))
303 303
 				{
304
-					if(!empty($this->cache))
304
+					if (!empty($this->cache))
305 305
 						$this->cache->clean($variant, $this->culture);
306 306
 					return true;
307 307
 				}
@@ -321,27 +321,27 @@  discard block
 block discarded – undo
321 321
 	 * @param string the catalogue of the translation.
322 322
 	 * @return boolean true if translation was updated, false otherwise.
323 323
 	 */
324
-	function update($text, $target, $comments, $catalogue='messages')
324
+	function update($text, $target, $comments, $catalogue = 'messages')
325 325
 	{
326 326
 		$variants = $this->getVariants($catalogue);
327
-		if($variants)
327
+		if ($variants)
328 328
 			list($variant, $MOFile, $POFile) = $variants;
329 329
 		else
330 330
 			return false;
331 331
 
332
-		if(is_writable($MOFile) == false)
332
+		if (is_writable($MOFile) == false)
333 333
 			throw new TIOException("Unable to update file {$MOFile}, file must be writable.");
334
-		if(is_writable($POFile) == false)
334
+		if (is_writable($POFile) == false)
335 335
 			throw new TIOException("Unable to update file {$POFile}, file must be writable.");
336 336
 
337 337
 
338
-		$po = TGettext::factory('PO',$POFile);
338
+		$po = TGettext::factory('PO', $POFile);
339 339
 		$po->load();
340 340
 		$result = $po->toArray();
341 341
 
342
-		foreach($result['strings'] as $string => $value)
342
+		foreach ($result['strings'] as $string => $value)
343 343
 		{
344
-			if($string == $text)
344
+			if ($string == $text)
345 345
 			{
346 346
 				$result['strings'][$string] = $target;
347 347
 				$result['meta']['PO-Revision-Date'] = @date('Y-m-d H:i:s');
@@ -349,9 +349,9 @@  discard block
 block discarded – undo
349 349
 				$po->fromArray($result);
350 350
 				$mo = $po->toMO();
351 351
 
352
-				if($po->save() && $mo->save($MOFile))
352
+				if ($po->save() && $mo->save($MOFile))
353 353
 				{
354
-					if(!empty($this->cache))
354
+					if (!empty($this->cache))
355 355
 						$this->cache->clean($variant, $this->culture);
356 356
 					return true;
357 357
 				}
@@ -379,36 +379,36 @@  discard block
 block discarded – undo
379 379
 	 * E.g. array('messages','en_AU')
380 380
 	 * @return array list of catalogues
381 381
 	 */
382
-	protected function getCatalogues($dir=null,$variant=null)
382
+	protected function getCatalogues($dir = null, $variant = null)
383 383
 	{
384
-		$dir = $dir?$dir:$this->source;
384
+		$dir = $dir ? $dir : $this->source;
385 385
 		$files = scandir($dir);
386 386
 
387 387
 		$catalogue = array();
388 388
 
389
-		foreach($files as $file)
389
+		foreach ($files as $file)
390 390
 		{
391
-			if(is_dir($dir.'/'.$file)
392
-				&& preg_match('/^[a-z]{2}(_[A-Z]{2,3})?$/',$file))
391
+			if (is_dir($dir . '/' . $file)
392
+				&& preg_match('/^[a-z]{2}(_[A-Z]{2,3})?$/', $file))
393 393
 			{
394 394
 
395 395
 				$catalogue = array_merge($catalogue,
396
-								$this->getCatalogues($dir.'/'.$file, $file));
396
+								$this->getCatalogues($dir . '/' . $file, $file));
397 397
 			}
398 398
 
399
-			$pos = strpos($file,$this->dataExt);
399
+			$pos = strpos($file, $this->dataExt);
400 400
 
401
-			if($pos >0
402
-				&& substr($file,-1*strlen($this->dataExt)) == $this->dataExt)
401
+			if ($pos > 0
402
+				&& substr($file, -1 * strlen($this->dataExt)) == $this->dataExt)
403 403
 			{
404
-				$name = substr($file,0,$pos);
405
-				$dot = strrpos($name,$this->dataSeparator);
404
+				$name = substr($file, 0, $pos);
405
+				$dot = strrpos($name, $this->dataSeparator);
406 406
 				$culture = $variant;
407 407
 				$cat = $name;
408
-				if(is_int($dot))
408
+				if (is_int($dot))
409 409
 				{
410
-					$culture = substr($name, $dot+1,strlen($name));
411
-					$cat = substr($name,0,$dot);
410
+					$culture = substr($name, $dot + 1, strlen($name));
411
+					$cat = substr($name, 0, $dot);
412 412
 				}
413 413
 				$details[0] = $cat;
414 414
 				$details[1] = $culture;
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 
425 425
 	protected function createMessageTemplate($catalogue)
426 426
 	{
427
-		if($catalogue === null) {
427
+		if ($catalogue === null) {
428 428
 			$catalogue = 'messages';
429 429
 		}
430 430
 		$variants = $this->getCatalogueList($catalogue);
@@ -433,21 +433,21 @@  discard block
 block discarded – undo
433 433
 		$po_file = $this->getPOFile($mo_file);
434 434
 
435 435
 		$dir = dirname($mo_file);
436
-		if(!is_dir($dir))
436
+		if (!is_dir($dir))
437 437
 		{
438 438
 			@mkdir($dir);
439
-			@chmod($dir,PRADO_CHMOD);
439
+			@chmod($dir, PRADO_CHMOD);
440 440
 		}
441
-		if(!is_dir($dir))
441
+		if (!is_dir($dir))
442 442
 			throw new TException("Unable to create directory $dir");
443 443
 
444
-		$po = TGettext::factory('PO',$po_file);
444
+		$po = TGettext::factory('PO', $po_file);
445 445
 		$result['meta']['PO-Revision-Date'] = @date('Y-m-d H:i:s');
446 446
 		$result['strings'] = array();
447 447
 
448 448
 		$po->fromArray($result);
449 449
 		$mo = $po->toMO();
450
-		if($po->save() && $mo->save($mo_file))
450
+		if ($po->save() && $mo->save($mo_file))
451 451
 			return array($variant, $mo_file, $po_file);
452 452
 		else
453 453
 			throw new TException("Unable to create file $po_file and $mo_file");
Please login to merge, or discard this patch.
Braces   +6 added lines, -8 removed lines patch added patch discarded remove patch
@@ -233,8 +233,9 @@  discard block
 block discarded – undo
233 233
 
234 234
 		//set the strings as untranslated.
235 235
 		$strings = array();
236
-		foreach($messages as $message)
237
-			$strings[$message] = '';
236
+		foreach($messages as $message) {
237
+					$strings[$message] = '';
238
+		}
238 239
 
239 240
 		//load the PO
240 241
 		$po = TGettext::factory('PO',$POFile);
@@ -260,8 +261,7 @@  discard block
 block discarded – undo
260 261
 				if(!empty($this->cache))
261 262
 					$this->cache->clean($variant, $this->culture);
262 263
 				return true;
263
-			}
264
-			else
264
+			} else
265 265
 				return false;
266 266
 		}
267 267
 		return false;
@@ -304,8 +304,7 @@  discard block
 block discarded – undo
304 304
 					if(!empty($this->cache))
305 305
 						$this->cache->clean($variant, $this->culture);
306 306
 					return true;
307
-				}
308
-				else
307
+				} else
309 308
 					return false;
310 309
 			}
311 310
 		}
@@ -354,8 +353,7 @@  discard block
 block discarded – undo
354 353
 					if(!empty($this->cache))
355 354
 						$this->cache->clean($variant, $this->culture);
356 355
 					return true;
357
-				}
358
-				else
356
+				} else
359 357
 					return false;
360 358
 			}
361 359
 		}
Please login to merge, or discard this patch.
framework/I18N/core/MessageSource_SQLite.php 2 patches
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -198,7 +198,9 @@
 block discarded – undo
198 198
 	
199 199
 	/**
200 200
 	 * Update the catalogue last modified time.
201
-	 * @return boolean true if updated, false otherwise. 
201
+	 * @param integer $cat_id
202
+	 * @param string $variant
203
+	 * @return SQLiteResult true if updated, false otherwise. 
202 204
 	 */
203 205
 	private function updateCatalogueTime($cat_id, $variant, $db)
204 206
 	{
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
 /**
21 21
  * Get the MessageSource class file.
22 22
  */
23
-require_once(dirname(__FILE__).'/MessageSource.php');
23
+require_once(dirname(__FILE__) . '/MessageSource.php');
24 24
 
25 25
 /**
26 26
  * Get the I18N utility file, contains the DSN parser.
27 27
  */
28
-require_once(dirname(__FILE__).'/util.php');
28
+require_once(dirname(__FILE__) . '/util.php');
29 29
 
30 30
 /**
31 31
  * MessageSource_SQLite class.
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	function __construct($source)
56 56
 	{
57
-		$dsn = parseDSN((string)$source);
57
+		$dsn = parseDSN((string) $source);
58 58
 		$this->source = $dsn['database'];
59 59
 	}
60 60
 	
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 			
81 81
 		$result = array();
82 82
 		
83
-		while($row = sqlite_fetch_array($rs,SQLITE_NUM))
83
+		while ($row = sqlite_fetch_array($rs, SQLITE_NUM))
84 84
 		{
85 85
 			$source = $row[1];
86 86
 			$result[$source][] = $row[2]; //target
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 			"SELECT date_modified FROM catalogue WHERE name = '{$source}'",
110 110
 			$db);
111 111
 			
112
-		$result = $rs ? (int)sqlite_fetch_single($rs) : 0;
112
+		$result = $rs ? (int) sqlite_fetch_single($rs) : 0;
113 113
 		
114 114
 		sqlite_close($db);		
115 115
 	
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 		$rs = sqlite_query(
130 130
 			"SELECT COUNT(*) FROM catalogue WHERE name = '{$variant}'",
131 131
 			$db);
132
-		$result = $rs && (int)sqlite_fetch_single($rs);	
132
+		$result = $rs && (int) sqlite_fetch_single($rs);	
133 133
 		sqlite_close($db);
134 134
 
135 135
 		return $result;
@@ -142,18 +142,18 @@  discard block
 block discarded – undo
142 142
 	 */
143 143
 	protected function getCatalogueList($catalogue)
144 144
 	{
145
-		$variants = explode('_',$this->culture);
145
+		$variants = explode('_', $this->culture);
146 146
 		
147 147
 		$catalogues = array($catalogue);
148 148
 
149 149
 		$variant = null;
150 150
 				
151
-		for($i = 0, $k = count($variants); $i < $k; ++$i)
151
+		for ($i = 0, $k = count($variants); $i < $k; ++$i)
152 152
 		{						
153
-			if(isset($variants[$i]{0}))
153
+			if (isset($variants[$i]{0}))
154 154
 			{
155
-				$variant .= ($variant)?'_'.$variants[$i]:$variants[$i];
156
-				$catalogues[] = $catalogue.'.'.$variant;
155
+				$variant .= ($variant) ? '_' . $variants[$i] : $variants[$i];
156
+				$catalogues[] = $catalogue . '.' . $variant;
157 157
 			}
158 158
 		}
159 159
 		return array_reverse($catalogues);	
@@ -164,12 +164,12 @@  discard block
 block discarded – undo
164 164
 	 * @param string catalogue
165 165
 	 * @return array catalogue details, array($cat_id, $variant, $count). 
166 166
 	 */
167
-	private function getCatalogueDetails($catalogue='messages')
167
+	private function getCatalogueDetails($catalogue = 'messages')
168 168
 	{
169
-		if(empty($catalogue))
169
+		if (empty($catalogue))
170 170
 			$catalogue = 'messages';
171 171
 
172
-		$variant = $catalogue.'.'.$this->culture;
172
+		$variant = $catalogue . '.' . $this->culture;
173 173
 		
174 174
 		$name = sqlite_escape_string($this->getSource($variant));	
175 175
 			
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
 		$rs = sqlite_query("SELECT cat_id
179 179
 					FROM catalogue WHERE name = '{$name}'", $db);
180 180
 		
181
-		if(sqlite_num_rows($rs) != 1)
181
+		if (sqlite_num_rows($rs) != 1)
182 182
 			return false;
183 183
 		
184
-		$cat_id = (int)sqlite_fetch_single($rs);
184
+		$cat_id = (int) sqlite_fetch_single($rs);
185 185
 		
186 186
 		//first get the catalogue ID
187 187
 		$rs = sqlite_query(
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 				FROM trans_unit
190 190
 				WHERE cat_id = {$cat_id}", $db);
191 191
 
192
-		$count = (int)sqlite_fetch_single($rs);
192
+		$count = (int) sqlite_fetch_single($rs);
193 193
 
194 194
 		sqlite_close($db);	
195 195
 		
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 							SET date_modified = {$time}
209 209
 							WHERE cat_id = {$cat_id}", $db);
210 210
 
211
-		if(!empty($this->cache))		
211
+		if (!empty($this->cache))		
212 212
 			$this->cache->clean($variant, $this->culture);	
213 213
 		
214 214
 		return $result;
@@ -221,37 +221,37 @@  discard block
 block discarded – undo
221 221
 	 * @param string the catalogue to add to
222 222
 	 * @return boolean true if saved successfuly, false otherwise.
223 223
 	 */
224
-	function save($catalogue='messages')
224
+	function save($catalogue = 'messages')
225 225
 	{
226 226
 		$messages = $this->untranslated;
227 227
 		
228
-		if(count($messages) <= 0) return false;				
228
+		if (count($messages) <= 0) return false;				
229 229
 		
230 230
 		$details = $this->getCatalogueDetails($catalogue);	
231 231
 		
232
-		if($details)
232
+		if ($details)
233 233
 			list($cat_id, $variant, $count) = $details;
234 234
 		else
235 235
 			return false;
236 236
 		
237
-		if($cat_id <= 0) return false;
237
+		if ($cat_id <= 0) return false;
238 238
 		$inserted = 0;
239 239
 		
240 240
 		$db = sqlite_open($this->source);
241 241
 		$time = time();
242 242
 
243
-		foreach($messages as $message)
243
+		foreach ($messages as $message)
244 244
 		{
245 245
 			$message = sqlite_escape_string($message);
246 246
 			$statement = "INSERT INTO trans_unit
247 247
 				(cat_id,id,source,date_added) VALUES
248 248
 				({$cat_id}, {$count},'{$message}',$time)";
249
-			if(sqlite_query($statement, $db))
249
+			if (sqlite_query($statement, $db))
250 250
 			{
251 251
 				$count++; $inserted++;			
252 252
 			}
253 253
 		}
254
-		if($inserted > 0)
254
+		if ($inserted > 0)
255 255
 			$this->updateCatalogueTime($cat_id, $variant, $db);
256 256
 	
257 257
 		sqlite_close($db);	
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
 	 * @param string the catalogue of the translation.
268 268
 	 * @return boolean true if translation was updated, false otherwise. 
269 269
 	 */	
270
-	function update($text, $target, $comments, $catalogue='messages')
270
+	function update($text, $target, $comments, $catalogue = 'messages')
271 271
 	{
272 272
 		$details = $this->getCatalogueDetails($catalogue);
273
-		if($details)
273
+		if ($details)
274 274
 			list($cat_id, $variant, $count) = $details;
275 275
 		else
276 276
 			return false;
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 		
293 293
 		$updated = false;
294 294
 		
295
-		if(sqlite_query($statement, $db))
295
+		if (sqlite_query($statement, $db))
296 296
 			$updated = $this->updateCatalogueTime($cat_id, $variant, $db);
297 297
 		
298 298
 		sqlite_close($db);			
@@ -306,10 +306,10 @@  discard block
 block discarded – undo
306 306
 	 * @param string the catalogue to delete from.
307 307
 	 * @return boolean true if deleted, false otherwise. 
308 308
 	 */
309
-	function delete($message, $catalogue='messages')
309
+	function delete($message, $catalogue = 'messages')
310 310
 	{
311 311
 		$details = $this->getCatalogueDetails($catalogue);
312
-		if($details)
312
+		if ($details)
313 313
 			list($cat_id, $variant, $count) = $details;
314 314
 		else
315 315
 			return false;
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 						cat_id = {$cat_id} AND source = '{$message}'";
322 322
 		$deleted = false;
323 323
 				
324
-		if(sqlite_query($statement, $db))
324
+		if (sqlite_query($statement, $db))
325 325
 			$deleted = $this->updateCatalogueTime($cat_id, $variant, $db);		
326 326
 			
327 327
 		sqlite_close($db);	
@@ -339,10 +339,10 @@  discard block
 block discarded – undo
339 339
 		$statement = 'SELECT name FROM catalogue ORDER BY name';
340 340
 		$rs = sqlite_query($statement, $db);
341 341
 		$result = array();
342
-		while($row = sqlite_fetch_array($rs,SQLITE_NUM))
342
+		while ($row = sqlite_fetch_array($rs, SQLITE_NUM))
343 343
 		{
344
-			$details = explode('.',$row[0]);
345
-			if(!isset($details[1])) $details[1] = null;
344
+			$details = explode('.', $row[0]);
345
+			if (!isset($details[1])) $details[1] = null;
346 346
 			
347 347
 			$result[] = $details;
348 348
 		}
Please login to merge, or discard this patch.
framework/I18N/core/MessageSource_XLIFF.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -486,6 +486,9 @@
 block discarded – undo
486 486
 		return false;
487 487
 	}
488 488
 
489
+	/**
490
+	 * @param string $catalogue
491
+	 */
489 492
 	protected function createMessageTemplate($catalogue)
490 493
 	{
491 494
 		if($catalogue === null) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -290,7 +290,7 @@
 block discarded – undo
290 290
 
291 291
 		//find the body element
292 292
 		$xpath = new DomXPath($dom);
293
-    	$body = $xpath->query('//body')->item(0);
293
+		$body = $xpath->query('//body')->item(0);
294 294
 
295 295
 		$lastNodes = $xpath->query('//trans-unit[last()]');
296 296
 		if(($last=$lastNodes->item(0))!==null) {
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 /**
21 21
  * Get the MessageSource class file.
22 22
  */
23
-require_once(dirname(__FILE__).'/MessageSource.php');
23
+require_once(dirname(__FILE__) . '/MessageSource.php');
24 24
 
25 25
 /**
26 26
  * MessageSource_XLIFF class.
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	function __construct($source)
60 60
 	{
61
-		$this->source = (string)$source;
61
+		$this->source = (string) $source;
62 62
 	}
63 63
 
64 64
 	/**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	protected function &loadData($filename)
70 70
 	{
71 71
 		//load it.
72
-		if(false === ($XML = simplexml_load_file($filename))) {
72
+		if (false === ($XML = simplexml_load_file($filename))) {
73 73
 			return false;
74 74
 		}
75 75
 
@@ -77,12 +77,12 @@  discard block
 block discarded – undo
77 77
 
78 78
 		$translations = array();
79 79
 
80
-		foreach($translationUnit as $unit)
80
+		foreach ($translationUnit as $unit)
81 81
 		{
82
-			$source = (string)$unit->source;
83
-			$translations[$source][] = (string)$unit->target;
84
-			$translations[$source][] = (string)$unit['id'];
85
-			$translations[$source][] = (string)$unit->note;
82
+			$source = (string) $unit->source;
83
+			$translations[$source][] = (string) $unit->target;
84
+			$translations[$source][] = (string) $unit['id'];
85
+			$translations[$source][] = (string) $unit->note;
86 86
 		}
87 87
 
88 88
 		return $translations;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	protected function getSource($variant)
109 109
 	{
110
-		return $this->source.'/'.$variant;
110
+		return $this->source . '/' . $variant;
111 111
 	}
112 112
 
113 113
 	/**
@@ -127,25 +127,25 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	protected function getCatalogueList($catalogue)
129 129
 	{
130
-		$variants = explode('_',$this->culture);
131
-		$source = $catalogue.$this->dataExt;
130
+		$variants = explode('_', $this->culture);
131
+		$source = $catalogue . $this->dataExt;
132 132
 		$catalogues = array($source);
133 133
 		$variant = null;
134 134
 
135
-		for($i = 0, $k = count($variants); $i < $k; ++$i)
135
+		for ($i = 0, $k = count($variants); $i < $k; ++$i)
136 136
 		{
137
-			if(isset($variants[$i]{0}))
137
+			if (isset($variants[$i]{0}))
138 138
 			{
139
-				$variant .= ($variant)?'_'.$variants[$i]:$variants[$i];
140
-				$catalogues[] = $catalogue.$this->dataSeparator.$variant.$this->dataExt;
139
+				$variant .= ($variant) ? '_' . $variants[$i] : $variants[$i];
140
+				$catalogues[] = $catalogue . $this->dataSeparator . $variant . $this->dataExt;
141 141
 			}
142 142
 		}
143 143
 
144 144
 		$byDir = $this->getCatalogueByDir($catalogue);
145
-		$catalogues = array_merge($byDir,array_reverse($catalogues));
145
+		$catalogues = array_merge($byDir, array_reverse($catalogues));
146 146
 		$files = array();
147 147
 
148
-		foreach($catalogues as $file)
148
+		foreach ($catalogues as $file)
149 149
 		{
150 150
 			$files[] = $file;
151 151
 			$files[] = preg_replace('/\.xml$/', '.xlf', $file);
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
 	 */
164 164
 	private function getCatalogueByDir($catalogue)
165 165
 	{
166
-		$variants = explode('_',$this->culture);
166
+		$variants = explode('_', $this->culture);
167 167
 		$catalogues = array();
168 168
 		$variant = null;
169 169
 
170
-		for($i = 0, $k = count($variants); $i < $k; ++$i)
170
+		for ($i = 0, $k = count($variants); $i < $k; ++$i)
171 171
 		{
172
-			if(isset($variants[$i]{0}))
172
+			if (isset($variants[$i]{0}))
173 173
 			{
174
-				$variant .= ($variant)?'_'.$variants[$i]:$variants[$i];
175
-				$catalogues[] = $variant.'/'.$catalogue.$this->dataExt;
174
+				$variant .= ($variant) ? '_' . $variants[$i] : $variants[$i];
175
+				$catalogues[] = $variant . '/' . $catalogue . $this->dataExt;
176 176
 			}
177 177
 		}
178 178
 
@@ -196,32 +196,32 @@  discard block
 block discarded – undo
196 196
 	 * E.g. array('messages','en_AU')
197 197
 	 * @return array list of catalogues
198 198
 	 */
199
-	protected function getCatalogues($dir=null,$variant=null)
199
+	protected function getCatalogues($dir = null, $variant = null)
200 200
 	{
201
-		$dir = $dir?$dir:$this->source;
201
+		$dir = $dir ? $dir : $this->source;
202 202
 		$files = scandir($dir);
203 203
 		$catalogue = array();
204 204
 
205
-		foreach($files as $file)
205
+		foreach ($files as $file)
206 206
 		{
207
-			if(is_dir($dir.'/'.$file) && preg_match('/^[a-z]{2}(_[A-Z]{2,3})?$/',$file)) {
207
+			if (is_dir($dir . '/' . $file) && preg_match('/^[a-z]{2}(_[A-Z]{2,3})?$/', $file)) {
208 208
 				$catalogue = array_merge(
209 209
 					$catalogue,
210
-					$this->getCatalogues($dir.'/'.$file, $file)
210
+					$this->getCatalogues($dir . '/' . $file, $file)
211 211
 				);
212 212
 			}
213 213
 
214
-			$pos = strpos($file,$this->dataExt);
215
-			if($pos >0 && substr($file, -1*strlen($this->dataExt)) == $this->dataExt)
214
+			$pos = strpos($file, $this->dataExt);
215
+			if ($pos > 0 && substr($file, -1 * strlen($this->dataExt)) == $this->dataExt)
216 216
 			{
217
-				$name = substr($file,0,$pos);
218
-				$dot = strrpos($name,$this->dataSeparator);
217
+				$name = substr($file, 0, $pos);
218
+				$dot = strrpos($name, $this->dataSeparator);
219 219
 				$culture = $variant;
220 220
 				$cat = $name;
221 221
 
222
-				if(is_int($dot))
222
+				if (is_int($dot))
223 223
 				{
224
-					$culture = substr($name, $dot+1, strlen($name));
224
+					$culture = substr($name, $dot + 1, strlen($name));
225 225
 					$cat = substr($name, 0, $dot);
226 226
 				}
227 227
 
@@ -242,16 +242,16 @@  discard block
 block discarded – undo
242 242
 	 * @see update()
243 243
 	 * @see delete()
244 244
 	 */
245
-	private function getVariants($catalogue='messages')
245
+	private function getVariants($catalogue = 'messages')
246 246
 	{
247
-		if($catalogue === null) {
247
+		if ($catalogue === null) {
248 248
 			$catalogue = 'messages';
249 249
 		}
250 250
 
251
-		foreach($this->getCatalogueList($catalogue) as $variant)
251
+		foreach ($this->getCatalogueList($catalogue) as $variant)
252 252
 		{
253 253
 			$file = $this->getSource($variant);
254
-			if(is_file($file)) {
254
+			if (is_file($file)) {
255 255
 				return array($variant, $file);
256 256
 			}
257 257
 		}
@@ -265,22 +265,22 @@  discard block
 block discarded – undo
265 265
 	 * @param string the catalogue to add to
266 266
 	 * @return boolean true if saved successfuly, false otherwise.
267 267
 	 */
268
-	public function save($catalogue='messages')
268
+	public function save($catalogue = 'messages')
269 269
 	{
270 270
 		$messages = $this->untranslated;
271
-		if(count($messages) <= 0) {
271
+		if (count($messages) <= 0) {
272 272
 			return false;
273 273
 		}
274 274
 
275 275
 		$variants = $this->getVariants($catalogue);
276 276
 
277
-		if($variants) {
277
+		if ($variants) {
278 278
 			list($variant, $filename) = $variants;
279 279
 		} else {
280 280
 			list($variant, $filename) = $this->createMessageTemplate($catalogue);
281 281
 		}
282 282
 
283
-		if(is_writable($filename) == false) {
283
+		if (is_writable($filename) == false) {
284 284
 			throw new TIOException("Unable to save to file {$filename}, file must be writable.");
285 285
 		}
286 286
 
@@ -293,17 +293,17 @@  discard block
 block discarded – undo
293 293
     	$body = $xpath->query('//body')->item(0);
294 294
 
295 295
 		$lastNodes = $xpath->query('//trans-unit[last()]');
296
-		if(($last=$lastNodes->item(0))!==null) {
297
-			$count = (int)$last->getAttribute('id');
296
+		if (($last = $lastNodes->item(0)) !== null) {
297
+			$count = (int) $last->getAttribute('id');
298 298
 		} else {
299 299
 			$count = 0;
300 300
 		}
301 301
 
302 302
 		//for each message add it to the XML file using DOM
303
-		foreach($messages as $message)
303
+		foreach ($messages as $message)
304 304
 		{
305 305
 			$unit = $dom->createElement('trans-unit');
306
-			$unit->setAttribute('id',++$count);
306
+			$unit->setAttribute('id', ++$count);
307 307
 
308 308
 			$source = $dom->createElement('source');
309 309
 			$source->appendChild($dom->createCDATASection($message));
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 
329 329
 		//save it and clear the cache for this variant
330 330
 		$dom->save($filename);
331
-		if(!empty($this->cache)) {
331
+		if (!empty($this->cache)) {
332 332
 			$this->cache->clean($variant, $this->culture);
333 333
 		}
334 334
 
@@ -343,17 +343,17 @@  discard block
 block discarded – undo
343 343
 	 * @param string the catalogue to save to.
344 344
 	 * @return boolean true if translation was updated, false otherwise.
345 345
 	 */
346
-	public function update($text, $target, $comments, $catalogue='messages')
346
+	public function update($text, $target, $comments, $catalogue = 'messages')
347 347
 	{
348 348
 		$variants = $this->getVariants($catalogue);
349 349
 
350
-		if($variants) {
350
+		if ($variants) {
351 351
 			list($variant, $filename) = $variants;
352 352
 		} else {
353 353
 			return false;
354 354
 		}
355 355
 
356
-		if(is_writable($filename) == false) {
356
+		if (is_writable($filename) == false) {
357 357
 			throw new TIOException("Unable to update file {$filename}, file must be writable.");
358 358
 		}
359 359
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 		$units = $xpath->query('//trans-unit');
366 366
 
367 367
 		//for each of the existin units
368
-		foreach($units as $unit)
368
+		foreach ($units as $unit)
369 369
 		{
370 370
 			$found = false;
371 371
 			$targetted = false;
@@ -373,25 +373,25 @@  discard block
 block discarded – undo
373 373
 
374 374
 			//in each unit, need to find the source, target and comment nodes
375 375
 			//it will assume that the source is before the target.
376
-			foreach($unit->childNodes as $node)
376
+			foreach ($unit->childNodes as $node)
377 377
 			{
378 378
 				//source node
379
-				if($node->nodeName == 'source' && $node->firstChild->wholeText == $text) {
379
+				if ($node->nodeName == 'source' && $node->firstChild->wholeText == $text) {
380 380
 					$found = true;
381 381
 				}
382 382
 
383 383
 				//found source, get the target and notes
384
-				if($found)
384
+				if ($found)
385 385
 				{
386 386
 					//set the new translated string
387
-					if($node->nodeName == 'target')
387
+					if ($node->nodeName == 'target')
388 388
 					{
389 389
 						$node->nodeValue = $target;
390 390
 						$targetted = true;
391 391
 					}
392 392
 
393 393
 					//set the notes
394
-					if(!empty($comments) && $node->nodeName == 'note')
394
+					if (!empty($comments) && $node->nodeName == 'note')
395 395
 					{
396 396
 						$node->nodeValue = $comments;
397 397
 						$commented = true;
@@ -400,17 +400,17 @@  discard block
 block discarded – undo
400 400
 			}
401 401
 
402 402
 			//append a target
403
-			if($found && !$targetted) {
404
-				$unit->appendChild($dom->createElement('target',$target));
403
+			if ($found && !$targetted) {
404
+				$unit->appendChild($dom->createElement('target', $target));
405 405
 			}
406 406
 
407 407
 			//append a note
408
-			if($found && !$commented && !empty($comments)) {
409
-				$unit->appendChild($dom->createElement('note',$comments));
408
+			if ($found && !$commented && !empty($comments)) {
409
+				$unit->appendChild($dom->createElement('note', $comments));
410 410
 			}
411 411
 
412 412
 			//finished searching
413
-			if($found) {
413
+			if ($found) {
414 414
 				break;
415 415
 			}
416 416
 		}
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
 		$fileNode = $xpath->query('//file')->item(0);
419 419
 		$fileNode->setAttribute('date', @date('Y-m-d\TH:i:s\Z'));
420 420
 
421
-		if($dom->save($filename) >0)
421
+		if ($dom->save($filename) > 0)
422 422
 		{
423
-			if(!empty($this->cache)) {
423
+			if (!empty($this->cache)) {
424 424
 				$this->cache->clean($variant, $this->culture);
425 425
 			}
426 426
 
@@ -436,16 +436,16 @@  discard block
 block discarded – undo
436 436
 	 * @param string the catalogue to delete from.
437 437
 	 * @return boolean true if deleted, false otherwise.
438 438
 	 */
439
-	public function delete($message, $catalogue='messages')
439
+	public function delete($message, $catalogue = 'messages')
440 440
 	{
441 441
 		$variants = $this->getVariants($catalogue);
442
-		if($variants) {
442
+		if ($variants) {
443 443
 			list($variant, $filename) = $variants;
444 444
 		} else {
445 445
 			return false;
446 446
 		}
447 447
 
448
-		if(is_writable($filename) == false) {
448
+		if (is_writable($filename) == false) {
449 449
 			throw new TIOException("Unable to modify file {$filename}, file must be writable.");
450 450
 		}
451 451
 
@@ -457,22 +457,22 @@  discard block
 block discarded – undo
457 457
 		$units = $xpath->query('//trans-unit');
458 458
 
459 459
 		//for each of the existin units
460
-		foreach($units as $unit)
460
+		foreach ($units as $unit)
461 461
 		{
462 462
 			//in each unit, need to find the source, target and comment nodes
463 463
 			//it will assume that the source is before the target.
464
-			foreach($unit->childNodes as $node)
464
+			foreach ($unit->childNodes as $node)
465 465
 			{
466 466
 				//source node
467
-				if($node->nodeName == 'source' && $node->firstChild->wholeText == $message)
467
+				if ($node->nodeName == 'source' && $node->firstChild->wholeText == $message)
468 468
 				{
469 469
 					//we found it, remove and save the xml file.
470 470
 					$unit->parentNode->removeChild($unit);
471 471
 					$fileNode = $xpath->query('//file')->item(0);
472 472
 					$fileNode->setAttribute('date', @date('Y-m-d\TH:i:s\Z'));
473 473
 
474
-					if(false !== $dom->save($filename)) {
475
-						if(!empty($this->cache)) {
474
+					if (false !== $dom->save($filename)) {
475
+						if (!empty($this->cache)) {
476 476
 							$this->cache->clean($variant, $this->culture);
477 477
 						}
478 478
 						return true;
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 
489 489
 	protected function createMessageTemplate($catalogue)
490 490
 	{
491
-		if($catalogue === null) {
491
+		if ($catalogue === null) {
492 492
 			$catalogue = 'messages';
493 493
 		}
494 494
 		
@@ -497,12 +497,12 @@  discard block
 block discarded – undo
497 497
 		$file = $this->getSource($variant);
498 498
 		$dir = dirname($file);
499 499
 
500
-		if(!is_dir($dir)) {
500
+		if (!is_dir($dir)) {
501 501
 			@mkdir($dir);
502
-			@chmod($dir,PRADO_CHMOD);
502
+			@chmod($dir, PRADO_CHMOD);
503 503
 		}
504 504
 
505
-		if(!is_dir($dir)) {
505
+		if (!is_dir($dir)) {
506 506
 			throw new TException("Unable to create directory $dir");
507 507
 		}
508 508
 		
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -523,7 +523,7 @@
 block discarded – undo
523 523
   </body>
524 524
  </file>
525 525
 </xliff>
526
-EOD;
526
+eod;
527 527
 		return $xml;
528 528
 	}
529 529
 }
Please login to merge, or discard this patch.
framework/I18N/core/NumberFormatInfo.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -170,6 +170,7 @@
 block discarded – undo
170 170
      * @param int the number formatting type, it should be
171 171
      * NumberFormatInfo::DECIMAL, NumberFormatInfo::CURRENCY,
172 172
      * NumberFormatInfo::PERCENTAGE, or NumberFormatInfo::SCIENTIFIC
173
+     * @param integer $type
173 174
      * @return NumberFormatInfo NumberFormatInfo for the specified
174 175
      * culture.
175 176
      * @see getCurrencyInstance();
Please login to merge, or discard this patch.
Indentation   +368 added lines, -368 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	/**
123 123
 	 * Set the pattern for a specific number pattern. The validate patterns
124 124
 	 * NumberFormatInfo::DECIMAL, NumberFormatInfo::CURRENCY,
125
-     * NumberFormatInfo::PERCENTAGE, or NumberFormatInfo::SCIENTIFIC
125
+	 * NumberFormatInfo::PERCENTAGE, or NumberFormatInfo::SCIENTIFIC
126 126
 	 * @param int pattern type.
127 127
 	 */
128 128
 	public function setPattern($type=NumberFormatInfo::DECIMAL)
@@ -152,94 +152,94 @@  discard block
 block discarded – undo
152 152
 	 * (invariant).
153 153
 	 * @return NumberFormatInfo default NumberFormatInfo.
154 154
 	 */
155
-    public static function getInvariantInfo($type=NumberFormatInfo::DECIMAL)
156
-    {
157
-        static $invariant;
155
+	public static function getInvariantInfo($type=NumberFormatInfo::DECIMAL)
156
+	{
157
+		static $invariant;
158 158
 		if($invariant === null)
159
-        {
160
-            $culture = CultureInfo::getInvariantCulture();
161
-            $invariant = $culture->NumberFormat;
162
-            $invariant->setPattern($type);
163
-        }
159
+		{
160
+			$culture = CultureInfo::getInvariantCulture();
161
+			$invariant = $culture->NumberFormat;
162
+			$invariant->setPattern($type);
163
+		}
164 164
 		return $invariant;
165
-    }
166
-
167
-    /**
168
-     * Returns the NumberFormatInfo associated with the specified culture.
169
-     * @param CultureInfo the culture that gets the NumberFormat property.
170
-     * @param int the number formatting type, it should be
171
-     * NumberFormatInfo::DECIMAL, NumberFormatInfo::CURRENCY,
172
-     * NumberFormatInfo::PERCENTAGE, or NumberFormatInfo::SCIENTIFIC
173
-     * @return NumberFormatInfo NumberFormatInfo for the specified
174
-     * culture.
175
-     * @see getCurrencyInstance();
176
-     * @see getPercentageInstance();
177
-     * @see getScientificInstance();
178
-     */
179
-    public static function getInstance($culture=null,
180
-    								   $type=NumberFormatInfo::DECIMAL)
181
-    {
165
+	}
166
+
167
+	/**
168
+	 * Returns the NumberFormatInfo associated with the specified culture.
169
+	 * @param CultureInfo the culture that gets the NumberFormat property.
170
+	 * @param int the number formatting type, it should be
171
+	 * NumberFormatInfo::DECIMAL, NumberFormatInfo::CURRENCY,
172
+	 * NumberFormatInfo::PERCENTAGE, or NumberFormatInfo::SCIENTIFIC
173
+	 * @return NumberFormatInfo NumberFormatInfo for the specified
174
+	 * culture.
175
+	 * @see getCurrencyInstance();
176
+	 * @see getPercentageInstance();
177
+	 * @see getScientificInstance();
178
+	 */
179
+	public static function getInstance($culture=null,
180
+									   $type=NumberFormatInfo::DECIMAL)
181
+	{
182 182
    		if ($culture instanceof CultureInfo)
183 183
    		{
184
-            $formatInfo = $culture->NumberFormat;
185
-            $formatInfo->setPattern($type);
186
-            return $formatInfo;
184
+			$formatInfo = $culture->NumberFormat;
185
+			$formatInfo->setPattern($type);
186
+			return $formatInfo;
187 187
    		}
188
-       	else if(is_string($culture))
189
-       	{
190
-       		$cultureInfo = new CultureInfo($culture);
191
-       		$formatInfo = $cultureInfo->NumberFormat;
192
-       		$formatInfo->setPattern($type);
193
-       		return $formatInfo;
194
-       	}
195
-       	else
196
-       	{
197
-            $cultureInfo = new CultureInfo();
198
-       		$formatInfo = $cultureInfo->NumberFormat;
199
-       		$formatInfo->setPattern($type);
200
-       		return $formatInfo;
201
-       	}
202
-    }
203
-
204
-    /**
205
-     * Returns the currency format info associated with the specified culture.
206
-     * @param CultureInfo the culture that gets the NumberFormat property.
207
-     * @return NumberFormatInfo NumberFormatInfo for the specified
208
-     * culture.
209
-     */
210
-    public static function getCurrencyInstance($culture=null)
211
-    {
212
-        return self::getInstance($culture, self::CURRENCY);
213
-    }
214
-
215
-    /**
216
-     * Returns the percentage format info associated with the specified culture.
217
-     * @param CultureInfo the culture that gets the NumberFormat property.
218
-     * @return NumberFormatInfo NumberFormatInfo for the specified
219
-     * culture.
220
-     */
221
-    public static function getPercentageInstance($culture=null)
222
-    {
223
-        return self::getInstance($culture, self::PERCENTAGE);
224
-    }
225
-
226
-    /**
227
-     * Returns the scientific format info associated with the specified culture.
228
-     * @param CultureInfo the culture that gets the NumberFormat property.
229
-     * @return NumberFormatInfo NumberFormatInfo for the specified
230
-     * culture.
231
-     */
232
-    public static function getScientificInstance($culture=null)
233
-    {
234
-        return self::getInstance($culture, self::SCIENTIFIC);
235
-    }
236
-
237
-    /**
238
-     * Parse the given pattern and return a list of known properties.
239
-     * @param string a number pattern.
240
-     * @return array list of pattern properties.
241
-     */
242
-    protected function parsePattern($pattern)
188
+	   	else if(is_string($culture))
189
+	   	{
190
+	   		$cultureInfo = new CultureInfo($culture);
191
+	   		$formatInfo = $cultureInfo->NumberFormat;
192
+	   		$formatInfo->setPattern($type);
193
+	   		return $formatInfo;
194
+	   	}
195
+	   	else
196
+	   	{
197
+			$cultureInfo = new CultureInfo();
198
+	   		$formatInfo = $cultureInfo->NumberFormat;
199
+	   		$formatInfo->setPattern($type);
200
+	   		return $formatInfo;
201
+	   	}
202
+	}
203
+
204
+	/**
205
+	 * Returns the currency format info associated with the specified culture.
206
+	 * @param CultureInfo the culture that gets the NumberFormat property.
207
+	 * @return NumberFormatInfo NumberFormatInfo for the specified
208
+	 * culture.
209
+	 */
210
+	public static function getCurrencyInstance($culture=null)
211
+	{
212
+		return self::getInstance($culture, self::CURRENCY);
213
+	}
214
+
215
+	/**
216
+	 * Returns the percentage format info associated with the specified culture.
217
+	 * @param CultureInfo the culture that gets the NumberFormat property.
218
+	 * @return NumberFormatInfo NumberFormatInfo for the specified
219
+	 * culture.
220
+	 */
221
+	public static function getPercentageInstance($culture=null)
222
+	{
223
+		return self::getInstance($culture, self::PERCENTAGE);
224
+	}
225
+
226
+	/**
227
+	 * Returns the scientific format info associated with the specified culture.
228
+	 * @param CultureInfo the culture that gets the NumberFormat property.
229
+	 * @return NumberFormatInfo NumberFormatInfo for the specified
230
+	 * culture.
231
+	 */
232
+	public static function getScientificInstance($culture=null)
233
+	{
234
+		return self::getInstance($culture, self::SCIENTIFIC);
235
+	}
236
+
237
+	/**
238
+	 * Parse the given pattern and return a list of known properties.
239
+	 * @param string a number pattern.
240
+	 * @return array list of pattern properties.
241
+	 */
242
+	protected function parsePattern($pattern)
243 243
 	{
244 244
 		$pattern = explode(';',$pattern);
245 245
 
@@ -355,296 +355,296 @@  discard block
 block discarded – undo
355 355
 	}
356 356
 
357 357
 
358
-    /**
359
-     * Indicates the number of decimal places.
360
-     * @return int number of decimal places.
361
-     */
362
-    function getDecimalDigits()
363
-    {
364
-    	return $this->pattern['decimalPoints'];
365
-    }
366
-
367
-    /**
368
-     * Set the number of decimal places.
369
-     * @param int number of decimal places.
370
-     */
371
-    function setDecimalDigits($value)
372
-    {
373
-    	return $this->pattern['decimalPoints'] = $value;
374
-    }
375
-
376
-    function getDigitSize()
377
-    {
378
-    	return $this->pattern['digitSize'];
379
-    }
380
-
381
-    function setDigitSize($value)
382
-    {
383
-    	$this->pattern['digitSize'] = $value;
384
-    }
385
-
386
-    /**
387
-     * Gets the string to use as the decimal separator.
388
-     * @return string decimal separator.
389
-     */
390
-    function getDecimalSeparator()
391
-    {
392
-    	return $this->data['NumberElements'][0];
393
-    }
394
-
395
-    /**
396
-     * Set the string to use as the decimal separator.
397
-     * @param string the decimal point
398
-     */
399
-    function setDecimalSeparator($value)
400
-    {
401
-    	return $this->data['NumberElements'][0] = $value;
402
-    }
403
-
404
-    /**
405
-     * Gets the string that separates groups of digits to the left
406
-     * of the decimal in currency values.
407
-     * @param parameter
408
-     * @return string currency group separator.
409
-     */
410
-    function getGroupSeparator()
411
-    {
412
-    	return $this->data['NumberElements'][1];
413
-    }
414
-
415
-    /**
416
-     * Set the string to use as the group separator.
417
-     * @param string the group separator.
418
-     */
419
-    function setGroupSeparator($value)
420
-    {
421
-    	return $this->data['NumberElements'][1] = $value;
422
-    }
423
-
424
-    /**
425
-     * Gets the number of digits in each group to the left of the decimal
426
-     * There can be two grouping sizes, this fucntion
427
-     * returns <b>array(group1, group2)</b>, if there is only 1 grouping size,
428
-     * group2 will be false.
429
-     * @return array grouping size(s).
430
-     */
431
-    function getGroupSizes()
432
-    {
433
-    	$group1 = $this->pattern['groupSize1'];
434
-    	$group2 = $this->pattern['groupSize2'];
435
-
436
-    	return array($group1, $group2);
437
-    }
438
-
439
-    /**
440
-     * Set the number of digits in each group to the left of the decimal.
441
-     * There can be two grouping sizes, the value should
442
-     * be an <b>array(group1, group2)</b>, if there is only 1 grouping size,
443
-     * group2 should be false.
444
-     * @param array grouping size(s).
445
-     */
446
-    function setGroupSizes($groupSize)
447
-    {
358
+	/**
359
+	 * Indicates the number of decimal places.
360
+	 * @return int number of decimal places.
361
+	 */
362
+	function getDecimalDigits()
363
+	{
364
+		return $this->pattern['decimalPoints'];
365
+	}
366
+
367
+	/**
368
+	 * Set the number of decimal places.
369
+	 * @param int number of decimal places.
370
+	 */
371
+	function setDecimalDigits($value)
372
+	{
373
+		return $this->pattern['decimalPoints'] = $value;
374
+	}
375
+
376
+	function getDigitSize()
377
+	{
378
+		return $this->pattern['digitSize'];
379
+	}
380
+
381
+	function setDigitSize($value)
382
+	{
383
+		$this->pattern['digitSize'] = $value;
384
+	}
385
+
386
+	/**
387
+	 * Gets the string to use as the decimal separator.
388
+	 * @return string decimal separator.
389
+	 */
390
+	function getDecimalSeparator()
391
+	{
392
+		return $this->data['NumberElements'][0];
393
+	}
394
+
395
+	/**
396
+	 * Set the string to use as the decimal separator.
397
+	 * @param string the decimal point
398
+	 */
399
+	function setDecimalSeparator($value)
400
+	{
401
+		return $this->data['NumberElements'][0] = $value;
402
+	}
403
+
404
+	/**
405
+	 * Gets the string that separates groups of digits to the left
406
+	 * of the decimal in currency values.
407
+	 * @param parameter
408
+	 * @return string currency group separator.
409
+	 */
410
+	function getGroupSeparator()
411
+	{
412
+		return $this->data['NumberElements'][1];
413
+	}
414
+
415
+	/**
416
+	 * Set the string to use as the group separator.
417
+	 * @param string the group separator.
418
+	 */
419
+	function setGroupSeparator($value)
420
+	{
421
+		return $this->data['NumberElements'][1] = $value;
422
+	}
423
+
424
+	/**
425
+	 * Gets the number of digits in each group to the left of the decimal
426
+	 * There can be two grouping sizes, this fucntion
427
+	 * returns <b>array(group1, group2)</b>, if there is only 1 grouping size,
428
+	 * group2 will be false.
429
+	 * @return array grouping size(s).
430
+	 */
431
+	function getGroupSizes()
432
+	{
433
+		$group1 = $this->pattern['groupSize1'];
434
+		$group2 = $this->pattern['groupSize2'];
435
+
436
+		return array($group1, $group2);
437
+	}
438
+
439
+	/**
440
+	 * Set the number of digits in each group to the left of the decimal.
441
+	 * There can be two grouping sizes, the value should
442
+	 * be an <b>array(group1, group2)</b>, if there is only 1 grouping size,
443
+	 * group2 should be false.
444
+	 * @param array grouping size(s).
445
+	 */
446
+	function setGroupSizes($groupSize)
447
+	{
448 448
    		$this->pattern['groupSize1'] = $groupSize[0];
449 449
    		$this->pattern['groupSize2'] = $groupSize[1];
450
-    }
451
-
452
-    /**
453
-     * Gets the format pattern for negative values.
454
-     * The negative pattern is composed of a prefix, and postfix.
455
-     * This function returns <b>array(prefix, postfix)</b>.
456
-     * @return arary negative pattern.
457
-     */
458
-    function getNegativePattern()
459
-    {
460
-    	$prefix = $this->pattern['negPref'];
461
-    	$postfix = $this->pattern['negPost'];
462
-    	return array($prefix, $postfix);
463
-    }
464
-
465
-    /**
466
-     * Set the format pattern for negative values.
467
-     * The negative pattern is composed of a prefix, and postfix in the form
468
-     * <b>array(prefix, postfix)</b>.
469
-     * @param arary negative pattern.
470
-     */
471
-    function setNegativePattern($pattern)
472
-    {
473
-    	$this->pattern['negPref'] = $pattern[0];
474
-    	$this->pattern['negPost'] = $pattern[1];
475
-    }
476
-
477
-    /**
478
-     * Gets the format pattern for positive values.
479
-     * The positive pattern is composed of a prefix, and postfix.
480
-     * This function returns <b>array(prefix, postfix)</b>.
481
-     * @return arary positive pattern.
482
-     */
483
-    function getPositivePattern()
484
-    {
485
-    	$prefix = $this->pattern['posPref'];
486
-    	$postfix = $this->pattern['posPost'];
487
-    	return array($prefix, $postfix);
488
-    }
489
-
490
-    /**
491
-     * Set the format pattern for positive values.
492
-     * The positive pattern is composed of a prefix, and postfix in the form
493
-     * <b>array(prefix, postfix)</b>.
494
-     * @param arary positive pattern.
495
-     */
496
-    function setPositivePattern($pattern)
497
-    {
498
-    	$this->pattern['posPref'] = $pattern[0];
499
-    	$this->pattern['posPost'] = $pattern[1];
500
-    }
501
-
502
-    /**
503
-     * Gets the string to use as the currency symbol.
504
-     * @return string currency symbol.
505
-     */
506
-    function getCurrencySymbol($currency='USD')
507
-    {
508
-    	if(isset($this->pattern['symbol']))
450
+	}
451
+
452
+	/**
453
+	 * Gets the format pattern for negative values.
454
+	 * The negative pattern is composed of a prefix, and postfix.
455
+	 * This function returns <b>array(prefix, postfix)</b>.
456
+	 * @return arary negative pattern.
457
+	 */
458
+	function getNegativePattern()
459
+	{
460
+		$prefix = $this->pattern['negPref'];
461
+		$postfix = $this->pattern['negPost'];
462
+		return array($prefix, $postfix);
463
+	}
464
+
465
+	/**
466
+	 * Set the format pattern for negative values.
467
+	 * The negative pattern is composed of a prefix, and postfix in the form
468
+	 * <b>array(prefix, postfix)</b>.
469
+	 * @param arary negative pattern.
470
+	 */
471
+	function setNegativePattern($pattern)
472
+	{
473
+		$this->pattern['negPref'] = $pattern[0];
474
+		$this->pattern['negPost'] = $pattern[1];
475
+	}
476
+
477
+	/**
478
+	 * Gets the format pattern for positive values.
479
+	 * The positive pattern is composed of a prefix, and postfix.
480
+	 * This function returns <b>array(prefix, postfix)</b>.
481
+	 * @return arary positive pattern.
482
+	 */
483
+	function getPositivePattern()
484
+	{
485
+		$prefix = $this->pattern['posPref'];
486
+		$postfix = $this->pattern['posPost'];
487
+		return array($prefix, $postfix);
488
+	}
489
+
490
+	/**
491
+	 * Set the format pattern for positive values.
492
+	 * The positive pattern is composed of a prefix, and postfix in the form
493
+	 * <b>array(prefix, postfix)</b>.
494
+	 * @param arary positive pattern.
495
+	 */
496
+	function setPositivePattern($pattern)
497
+	{
498
+		$this->pattern['posPref'] = $pattern[0];
499
+		$this->pattern['posPost'] = $pattern[1];
500
+	}
501
+
502
+	/**
503
+	 * Gets the string to use as the currency symbol.
504
+	 * @return string currency symbol.
505
+	 */
506
+	function getCurrencySymbol($currency='USD')
507
+	{
508
+		if(isset($this->pattern['symbol']))
509 509
 			return $this->pattern['symbol'];
510
-    	else
511
-    		return $this->data['Currencies'][$currency][0];
512
-    }
513
-
514
-
515
-    /**
516
-     * Set the string to use as the currency symbol.
517
-     * @param string currency symbol.
518
-     */
519
-    function setCurrencySymbol($symbol)
520
-    {
521
-    	$this->pattern['symbol'] = $symbol;
522
-    }
523
-
524
-    /**
525
-     * Gets the string that represents negative infinity.
526
-     * @return string negative infinity.
527
-     */
528
-    function getNegativeInfinitySymbol()
529
-    {
510
+		else
511
+			return $this->data['Currencies'][$currency][0];
512
+	}
513
+
514
+
515
+	/**
516
+	 * Set the string to use as the currency symbol.
517
+	 * @param string currency symbol.
518
+	 */
519
+	function setCurrencySymbol($symbol)
520
+	{
521
+		$this->pattern['symbol'] = $symbol;
522
+	}
523
+
524
+	/**
525
+	 * Gets the string that represents negative infinity.
526
+	 * @return string negative infinity.
527
+	 */
528
+	function getNegativeInfinitySymbol()
529
+	{
530 530
 		return $this->pattern['negInfty'];
531
-    }
532
-
533
-    /**
534
-     * Set the string that represents negative infinity.
535
-     * @param string negative infinity.
536
-     */
537
-    function setNegativeInfinitySymbol($value)
538
-    {
531
+	}
532
+
533
+	/**
534
+	 * Set the string that represents negative infinity.
535
+	 * @param string negative infinity.
536
+	 */
537
+	function setNegativeInfinitySymbol($value)
538
+	{
539 539
 		$this->pattern['negInfty'] = $value;
540
-    }
541
-
542
-    /**
543
-     * Gets the string that represents positive infinity.
544
-     * @return string positive infinity.
545
-     */
546
-    function getPositiveInfinitySymbol()
547
-    {
540
+	}
541
+
542
+	/**
543
+	 * Gets the string that represents positive infinity.
544
+	 * @return string positive infinity.
545
+	 */
546
+	function getPositiveInfinitySymbol()
547
+	{
548 548
 		return $this->pattern['posInfty'];
549
-    }
550
-
551
-    /**
552
-     * Set the string that represents positive infinity.
553
-     * @param string positive infinity.
554
-     */
555
-    function setPositiveInfinitySymbol($value)
556
-    {
549
+	}
550
+
551
+	/**
552
+	 * Set the string that represents positive infinity.
553
+	 * @param string positive infinity.
554
+	 */
555
+	function setPositiveInfinitySymbol($value)
556
+	{
557 557
 		$this->pattern['posInfty'] = $value;
558
-    }
559
-
560
-    /**
561
-     * Gets the string that denotes that the associated number is negative.
562
-     * @return string negative sign.
563
-     */
564
-    function getNegativeSign()
565
-    {
566
-    	return $this->data['NumberElements'][6];
567
-    }
568
-
569
-    /**
570
-     * Set the string that denotes that the associated number is negative.
571
-     * @param string negative sign.
572
-     */
573
-    function setNegativeSign($value)
574
-    {
575
-    	$this->data['NumberElements'][6] = $value;
576
-    }
577
-
578
-    /**
579
-     * Gets the string that denotes that the associated number is positive.
580
-     * @return string positive sign.
581
-     */
582
-    function getPositiveSign()
583
-    {
584
-    	return $this->data['NumberElements'][11];
585
-    }
586
-
587
-    /**
588
-     * Set the string that denotes that the associated number is positive.
589
-     * @param string positive sign.
590
-     */
591
-    function setPositiveSign($value)
592
-    {
593
-    	$this->data['NumberElements'][11] = $value;
594
-    }
595
-
596
-    /**
597
-     * Gets the string that represents the IEEE NaN (not a number) value.
598
-     * @return string NaN symbol.
599
-     */
600
-    function getNaNSymbol()
601
-    {
602
-    	return $this->data['NumberElements'][10];
603
-    }
604
-
605
-    /**
606
-     * Set the string that represents the IEEE NaN (not a number) value.
607
-     * @param string NaN symbol.
608
-     */
609
-    function setNaNSymbol($value)
610
-    {
611
-    	$this->data['NumberElements'][10] = $value;
612
-    }
613
-
614
-    /**
615
-     * Gets the string to use as the percent symbol.
616
-     * @return string percent symbol.
617
-     */
618
-    function getPercentSymbol()
619
-    {
620
-    	return $this->data['NumberElements'][3];
621
-    }
622
-
623
-    /**
624
-     * Set the string to use as the percent symbol.
625
-     * @param string percent symbol.
626
-     */
627
-    function setPercentSymbol($value)
628
-    {
629
-    	$this->data['NumberElements'][3] = $value;
630
-    }
631
-
632
-    /**
633
-     * Gets the string to use as the per mille symbol.
634
-     * @return string percent symbol.
635
-     */
636
-    function getPerMilleSymbol()
637
-    {
638
-    	return $this->data['NumberElements'][8];
639
-    }
640
-
641
-    /**
642
-     * Set the string to use as the per mille symbol.
643
-     * @param string percent symbol.
644
-     */
645
-    function setPerMilleSymbol($value)
646
-    {
647
-    	$this->data['NumberElements'][8] = $value;
648
-    }
558
+	}
559
+
560
+	/**
561
+	 * Gets the string that denotes that the associated number is negative.
562
+	 * @return string negative sign.
563
+	 */
564
+	function getNegativeSign()
565
+	{
566
+		return $this->data['NumberElements'][6];
567
+	}
568
+
569
+	/**
570
+	 * Set the string that denotes that the associated number is negative.
571
+	 * @param string negative sign.
572
+	 */
573
+	function setNegativeSign($value)
574
+	{
575
+		$this->data['NumberElements'][6] = $value;
576
+	}
577
+
578
+	/**
579
+	 * Gets the string that denotes that the associated number is positive.
580
+	 * @return string positive sign.
581
+	 */
582
+	function getPositiveSign()
583
+	{
584
+		return $this->data['NumberElements'][11];
585
+	}
586
+
587
+	/**
588
+	 * Set the string that denotes that the associated number is positive.
589
+	 * @param string positive sign.
590
+	 */
591
+	function setPositiveSign($value)
592
+	{
593
+		$this->data['NumberElements'][11] = $value;
594
+	}
595
+
596
+	/**
597
+	 * Gets the string that represents the IEEE NaN (not a number) value.
598
+	 * @return string NaN symbol.
599
+	 */
600
+	function getNaNSymbol()
601
+	{
602
+		return $this->data['NumberElements'][10];
603
+	}
604
+
605
+	/**
606
+	 * Set the string that represents the IEEE NaN (not a number) value.
607
+	 * @param string NaN symbol.
608
+	 */
609
+	function setNaNSymbol($value)
610
+	{
611
+		$this->data['NumberElements'][10] = $value;
612
+	}
613
+
614
+	/**
615
+	 * Gets the string to use as the percent symbol.
616
+	 * @return string percent symbol.
617
+	 */
618
+	function getPercentSymbol()
619
+	{
620
+		return $this->data['NumberElements'][3];
621
+	}
622
+
623
+	/**
624
+	 * Set the string to use as the percent symbol.
625
+	 * @param string percent symbol.
626
+	 */
627
+	function setPercentSymbol($value)
628
+	{
629
+		$this->data['NumberElements'][3] = $value;
630
+	}
631
+
632
+	/**
633
+	 * Gets the string to use as the per mille symbol.
634
+	 * @return string percent symbol.
635
+	 */
636
+	function getPerMilleSymbol()
637
+	{
638
+		return $this->data['NumberElements'][8];
639
+	}
640
+
641
+	/**
642
+	 * Set the string to use as the per mille symbol.
643
+	 * @param string percent symbol.
644
+	 */
645
+	function setPerMilleSymbol($value)
646
+	{
647
+		$this->data['NumberElements'][8] = $value;
648
+	}
649 649
 }
650 650
 
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 /**
21 21
  * Get the CultureInfo class file.
22 22
  */
23
-require_once(dirname(__FILE__).'/CultureInfo.php');
23
+require_once(dirname(__FILE__) . '/CultureInfo.php');
24 24
 
25 25
 /**
26 26
  * NumberFormatInfo class
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	public function __get($name)
80 80
 	{
81
-		$getProperty = 'get'.$name;
82
-		if(in_array($getProperty, $this->properties))
81
+		$getProperty = 'get' . $name;
82
+		if (in_array($getProperty, $this->properties))
83 83
 			return $this->$getProperty();
84 84
 		else
85
-			throw new Exception('Property '.$name.' does not exists.');
85
+			throw new Exception('Property ' . $name . ' does not exists.');
86 86
 	}
87 87
 
88 88
 	/**
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function __set($name, $value)
93 93
 	{
94
-		$setProperty = 'set'.$name;
95
-		if(in_array($setProperty, $this->properties))
94
+		$setProperty = 'set' . $name;
95
+		if (in_array($setProperty, $this->properties))
96 96
 			$this->$setProperty($value);
97 97
 		else
98
-			throw new Exception('Property '.$name.' can not be set.');
98
+			throw new Exception('Property ' . $name . ' can not be set.');
99 99
 	}
100 100
 
101 101
 	/**
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 	 * @param array ICU data for date time formatting.
108 108
 	 * @see getInstance()
109 109
 	 */
110
-	public function __construct($data=array(), $type=NumberFormatInfo::DECIMAL)
110
+	public function __construct($data = array(), $type = NumberFormatInfo::DECIMAL)
111 111
 	{
112 112
 		$this->properties = get_class_methods($this);
113 113
 
114
-		if(empty($data))
114
+		if (empty($data))
115 115
 			throw new Exception('Please provide the ICU data to initialize.');
116 116
 
117 117
 		$this->data = $data;
@@ -125,20 +125,20 @@  discard block
 block discarded – undo
125 125
      * NumberFormatInfo::PERCENTAGE, or NumberFormatInfo::SCIENTIFIC
126 126
 	 * @param int pattern type.
127 127
 	 */
128
-	public function setPattern($type=NumberFormatInfo::DECIMAL)
128
+	public function setPattern($type = NumberFormatInfo::DECIMAL)
129 129
 	{
130
-		if(is_int($type))
130
+		if (is_int($type))
131 131
 			$this->pattern =
132 132
 				$this->parsePattern($this->data['NumberPatterns'][$type]);
133 133
 		else
134 134
 			$this->pattern = $this->parsePattern($type);
135 135
 
136 136
 		$this->pattern['negInfty'] =
137
-			$this->data['NumberElements'][6].
137
+			$this->data['NumberElements'][6] .
138 138
 			$this->data['NumberElements'][9];
139 139
 
140 140
 		$this->pattern['posInfty'] =
141
-			$this->data['NumberElements'][11].
141
+			$this->data['NumberElements'][11] .
142 142
 			$this->data['NumberElements'][9];
143 143
 	}
144 144
 
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
 	 * (invariant).
153 153
 	 * @return NumberFormatInfo default NumberFormatInfo.
154 154
 	 */
155
-    public static function getInvariantInfo($type=NumberFormatInfo::DECIMAL)
155
+    public static function getInvariantInfo($type = NumberFormatInfo::DECIMAL)
156 156
     {
157 157
         static $invariant;
158
-		if($invariant === null)
158
+		if ($invariant === null)
159 159
         {
160 160
             $culture = CultureInfo::getInvariantCulture();
161 161
             $invariant = $culture->NumberFormat;
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
      * @see getPercentageInstance();
177 177
      * @see getScientificInstance();
178 178
      */
179
-    public static function getInstance($culture=null,
180
-    								   $type=NumberFormatInfo::DECIMAL)
179
+    public static function getInstance($culture = null,
180
+    								   $type = NumberFormatInfo::DECIMAL)
181 181
     {
182 182
    		if ($culture instanceof CultureInfo)
183 183
    		{
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
             $formatInfo->setPattern($type);
186 186
             return $formatInfo;
187 187
    		}
188
-       	else if(is_string($culture))
188
+       	else if (is_string($culture))
189 189
        	{
190 190
        		$cultureInfo = new CultureInfo($culture);
191 191
        		$formatInfo = $cultureInfo->NumberFormat;
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
      * @return NumberFormatInfo NumberFormatInfo for the specified
208 208
      * culture.
209 209
      */
210
-    public static function getCurrencyInstance($culture=null)
210
+    public static function getCurrencyInstance($culture = null)
211 211
     {
212 212
         return self::getInstance($culture, self::CURRENCY);
213 213
     }
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
      * @return NumberFormatInfo NumberFormatInfo for the specified
219 219
      * culture.
220 220
      */
221
-    public static function getPercentageInstance($culture=null)
221
+    public static function getPercentageInstance($culture = null)
222 222
     {
223 223
         return self::getInstance($culture, self::PERCENTAGE);
224 224
     }
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
      * @return NumberFormatInfo NumberFormatInfo for the specified
230 230
      * culture.
231 231
      */
232
-    public static function getScientificInstance($culture=null)
232
+    public static function getScientificInstance($culture = null)
233 233
     {
234 234
         return self::getInstance($culture, self::SCIENTIFIC);
235 235
     }
@@ -241,10 +241,10 @@  discard block
 block discarded – undo
241 241
      */
242 242
     protected function parsePattern($pattern)
243 243
 	{
244
-		$pattern = explode(';',$pattern);
244
+		$pattern = explode(';', $pattern);
245 245
 
246 246
 		$negative = null;
247
-		if(count($pattern) > 1)
247
+		if (count($pattern) > 1)
248 248
 			$negative = $pattern[1];
249 249
 		$pattern = $pattern[0];
250 250
 
@@ -254,13 +254,13 @@  discard block
 block discarded – undo
254 254
 		$hash = '#';
255 255
 
256 256
 		//find the first group point, and decimal point
257
-		$groupPos1 = strrpos($pattern,$comma);
258
-		$decimalPos = strrpos($pattern,$dot);
257
+		$groupPos1 = strrpos($pattern, $comma);
258
+		$decimalPos = strrpos($pattern, $dot);
259 259
 
260 260
 		$groupPos2 = false;
261 261
 		$groupSize1 = false;
262 262
 		$groupSize2 = false;
263
-		$decimalPoints = is_int($decimalPos)?-1:false;
263
+		$decimalPoints = is_int($decimalPos) ?-1 : false;
264 264
 
265 265
 		$info['negPref'] = $this->data['NumberElements'][6];
266 266
 		$info['negPost'] = '';
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 		$info['positive'] = $pattern;
270 270
 
271 271
 		//find the negative prefix and postfix
272
-		if($negative)
272
+		if ($negative)
273 273
 		{
274 274
 			$prefixPostfix = $this->getPrePostfix($negative);
275 275
 			$info['negPref'] = $prefixPostfix[0];
@@ -282,24 +282,24 @@  discard block
 block discarded – undo
282 282
 
283 283
 		//var_dump($pattern);
284 284
 		//var_dump($decimalPos);
285
-		if(is_int($groupPos1))
285
+		if (is_int($groupPos1))
286 286
 		{
287 287
 			//get the second group
288
-			$groupPos2 = strrpos(substr($pattern,0,$groupPos1),$comma);
288
+			$groupPos2 = strrpos(substr($pattern, 0, $groupPos1), $comma);
289 289
 
290 290
 			//get the number of decimal digits
291
-			if(is_int($decimalPos))
291
+			if (is_int($decimalPos))
292 292
 			{
293
-				$groupSize1 = $decimalPos - $groupPos1-1;
293
+				$groupSize1 = $decimalPos - $groupPos1 - 1;
294 294
 
295 295
 			}
296 296
 			else
297 297
 			{
298 298
 				//no decimal point, so traverse from the back
299 299
 				//to find the groupsize 1.
300
-				for($i=strlen($pattern)-1; $i>=0; $i--)
300
+				for ($i = strlen($pattern) - 1; $i >= 0; $i--)
301 301
 				{
302
-					if($pattern{$i} == $digit || $pattern{$i}==$hash)
302
+					if ($pattern{$i} == $digit || $pattern{$i} == $hash)
303 303
 					{
304 304
 						$groupSize1 = $i - $groupPos1;
305 305
 						break;
@@ -308,16 +308,16 @@  discard block
 block discarded – undo
308 308
 			}
309 309
 
310 310
 			//get the second group size
311
-			if(is_int($groupPos2))
312
-				$groupSize2 = $groupPos1 - $groupPos2-1;
311
+			if (is_int($groupPos2))
312
+				$groupSize2 = $groupPos1 - $groupPos2 - 1;
313 313
 		}
314 314
 
315
-		if(is_int($decimalPos))
315
+		if (is_int($decimalPos))
316 316
 		{
317
-			for($i=strlen($pattern)-1; $i>=0; $i--)
317
+			for ($i = strlen($pattern) - 1; $i >= 0; $i--)
318 318
 			{
319
-				if($pattern{$i} == $dot) break;
320
-				if($pattern{$i} == $digit)
319
+				if ($pattern{$i} == $dot) break;
320
+				if ($pattern{$i} == $digit)
321 321
 				{
322 322
 					$decimalPoints = $i - $decimalPos;
323 323
 					break;
@@ -325,12 +325,12 @@  discard block
 block discarded – undo
325 325
 			}
326 326
 		}
327 327
 
328
-		if(is_int($decimalPos))
329
-			$digitPattern = substr($pattern,0,$decimalPos);
328
+		if (is_int($decimalPos))
329
+			$digitPattern = substr($pattern, 0, $decimalPos);
330 330
 		else
331
-			$digitPattern  = $pattern;
331
+			$digitPattern = $pattern;
332 332
 
333
-		$digitPattern  = preg_replace('/[^0]/','',$digitPattern);
333
+		$digitPattern = preg_replace('/[^0]/', '', $digitPattern);
334 334
 
335 335
 		$info['groupPos1'] = $groupPos1;
336 336
 		$info['groupSize1'] = $groupSize1;
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 	{
352 352
 		$regexp = '/[#,\.0]+/';
353 353
 		$result = preg_split($regexp, $pattern);
354
-		return array($result[0],$result[1]);
354
+		return array($result[0], $result[1]);
355 355
 	}
356 356
 
357 357
 
@@ -503,9 +503,9 @@  discard block
 block discarded – undo
503 503
      * Gets the string to use as the currency symbol.
504 504
      * @return string currency symbol.
505 505
      */
506
-    function getCurrencySymbol($currency='USD')
506
+    function getCurrencySymbol($currency = 'USD')
507 507
     {
508
-    	if(isset($this->pattern['symbol']))
508
+    	if (isset($this->pattern['symbol']))
509 509
 			return $this->pattern['symbol'];
510 510
     	else
511 511
     		return $this->data['Currencies'][$currency][0];
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -184,15 +184,13 @@  discard block
 block discarded – undo
184 184
             $formatInfo = $culture->NumberFormat;
185 185
             $formatInfo->setPattern($type);
186 186
             return $formatInfo;
187
-   		}
188
-       	else if(is_string($culture))
187
+   		} else if(is_string($culture))
189 188
        	{
190 189
        		$cultureInfo = new CultureInfo($culture);
191 190
        		$formatInfo = $cultureInfo->NumberFormat;
192 191
        		$formatInfo->setPattern($type);
193 192
        		return $formatInfo;
194
-       	}
195
-       	else
193
+       	} else
196 194
        	{
197 195
             $cultureInfo = new CultureInfo();
198 196
        		$formatInfo = $cultureInfo->NumberFormat;
@@ -292,8 +290,7 @@  discard block
 block discarded – undo
292 290
 			{
293 291
 				$groupSize1 = $decimalPos - $groupPos1-1;
294 292
 
295
-			}
296
-			else
293
+			} else
297 294
 			{
298 295
 				//no decimal point, so traverse from the back
299 296
 				//to find the groupsize 1.
Please login to merge, or discard this patch.