Completed
Push — autoload ( 7f2c9b...4808d1 )
by Fabio
42:25 queued 32:40
created
framework/I18N/core/Gettext/MO.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      * _read
87 87
      *
88 88
      * @access  private
89
-     * @return  mixed
89
+     * @return  string|null
90 90
      * @param   int     $bytes
91 91
      */
92 92
     function _read($bytes = 1)
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      * Load MO file
166 166
      *
167 167
      * @access   public
168
-     * @return   mixed   Returns true on success or PEAR_Error on failure.
168
+     * @return   boolean   Returns true on success or PEAR_Error on failure.
169 169
      * @param    string  $file
170 170
      */
171 171
     function load($file = null)
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
      * Save MO file
262 262
      *
263 263
      * @access  public
264
-     * @return  mixed   Returns true on success or PEAR_Error on failure.
264
+     * @return  boolean   Returns true on success or PEAR_Error on failure.
265 265
      * @param   string  $file
266 266
      */
267 267
     function save($file = null)
Please login to merge, or discard this patch.
Indentation   +295 added lines, -295 removed lines patch added patch discarded remove patch
@@ -52,304 +52,304 @@
 block discarded – undo
52 52
  */
53 53
 class TGettext_MO extends TGettext
54 54
 {
55
-    /**
56
-     * file handle
57
-     *
58
-     * @access  private
59
-     * @var     resource
60
-     */
61
-    protected $_handle = null;
62
-
63
-    /**
64
-     * big endianess
65
-     *
66
-     * Whether to write with big endian byte order.
67
-     *
68
-     * @access  public
69
-     * @var     bool
70
-     */
71
-    protected $writeBigEndian = false;
72
-
73
-    /**
74
-     * Constructor
75
-     *
76
-     * @access  public
77
-     * @return  object      File_Gettext_MO
78
-     * @param   string      $file   path to GNU MO file
79
-     */
80
-    function TGettext_MO($file = '')
81
-    {
82
-        $this->file = $file;
83
-    }
84
-
85
-    /**
86
-     * _read
87
-     *
88
-     * @access  private
89
-     * @return  mixed
90
-     * @param   int     $bytes
91
-     */
92
-    function _read($bytes = 1)
93
-    {
94
-        if (0 < $bytes = abs($bytes)) {
95
-            return fread($this->_handle, $bytes);
96
-        }
97
-        return null;
98
-    }
99
-
100
-    /**
101
-     * _readInt
102
-     *
103
-     * @access  private
104
-     * @return  int
105
-     * @param   bool    $bigendian
106
-     */
107
-    function _readInt($bigendian = false)
108
-    {
55
+	/**
56
+	 * file handle
57
+	 *
58
+	 * @access  private
59
+	 * @var     resource
60
+	 */
61
+	protected $_handle = null;
62
+
63
+	/**
64
+	 * big endianess
65
+	 *
66
+	 * Whether to write with big endian byte order.
67
+	 *
68
+	 * @access  public
69
+	 * @var     bool
70
+	 */
71
+	protected $writeBigEndian = false;
72
+
73
+	/**
74
+	 * Constructor
75
+	 *
76
+	 * @access  public
77
+	 * @return  object      File_Gettext_MO
78
+	 * @param   string      $file   path to GNU MO file
79
+	 */
80
+	function TGettext_MO($file = '')
81
+	{
82
+		$this->file = $file;
83
+	}
84
+
85
+	/**
86
+	 * _read
87
+	 *
88
+	 * @access  private
89
+	 * @return  mixed
90
+	 * @param   int     $bytes
91
+	 */
92
+	function _read($bytes = 1)
93
+	{
94
+		if (0 < $bytes = abs($bytes)) {
95
+			return fread($this->_handle, $bytes);
96
+		}
97
+		return null;
98
+	}
99
+
100
+	/**
101
+	 * _readInt
102
+	 *
103
+	 * @access  private
104
+	 * @return  int
105
+	 * @param   bool    $bigendian
106
+	 */
107
+	function _readInt($bigendian = false)
108
+	{
109 109
 		//unpack returns a reference????
110 110
 		$unpacked = unpack($bigendian ? 'N' : 'V', $this->_read(4));
111
-        return array_shift($unpacked);
112
-    }
113
-
114
-    /**
115
-     * _writeInt
116
-     *
117
-     * @access  private
118
-     * @return  int
119
-     * @param   int     $int
120
-     */
121
-    function _writeInt($int)
122
-    {
123
-        return $this->_write(pack($this->writeBigEndian ? 'N' : 'V', (int) $int));
124
-    }
125
-
126
-    /**
127
-     * _write
128
-     *
129
-     * @access  private
130
-     * @return  int
131
-     * @param   string  $data
132
-     */
133
-    function _write($data)
134
-    {
135
-        return fwrite($this->_handle, $data);
136
-    }
137
-
138
-    /**
139
-     * _writeStr
140
-     *
141
-     * @access  private
142
-     * @return  int
143
-     * @param   string  $string
144
-     */
145
-    function _writeStr($string)
146
-    {
147
-        return $this->_write($string . "\0");
148
-    }
149
-
150
-    /**
151
-     * _readStr
152
-     *
153
-     * @access  private
154
-     * @return  string
155
-     * @param   array   $params     associative array with offset and length
156
-     *                              of the string
157
-     */
158
-    function _readStr($params)
159
-    {
160
-        fseek($this->_handle, $params['offset']);
161
-        return $this->_read($params['length']);
162
-    }
163
-
164
-    /**
165
-     * Load MO file
166
-     *
167
-     * @access   public
168
-     * @return   mixed   Returns true on success or PEAR_Error on failure.
169
-     * @param    string  $file
170
-     */
171
-    function load($file = null)
172
-    {
173
-        if (!isset($file)) {
174
-            $file = $this->file;
175
-        }
176
-
177
-        // open MO file
178
-        if (!is_resource($this->_handle = @fopen($file, 'rb'))) {
179
-            return false;
180
-        }
181
-        // lock MO file shared
182
-        if (!@flock($this->_handle, LOCK_SH)) {
183
-            @fclose($this->_handle);
184
-            return false;
185
-        }
186
-
187
-        // read (part of) magic number from MO file header and define endianess
111
+		return array_shift($unpacked);
112
+	}
113
+
114
+	/**
115
+	 * _writeInt
116
+	 *
117
+	 * @access  private
118
+	 * @return  int
119
+	 * @param   int     $int
120
+	 */
121
+	function _writeInt($int)
122
+	{
123
+		return $this->_write(pack($this->writeBigEndian ? 'N' : 'V', (int) $int));
124
+	}
125
+
126
+	/**
127
+	 * _write
128
+	 *
129
+	 * @access  private
130
+	 * @return  int
131
+	 * @param   string  $data
132
+	 */
133
+	function _write($data)
134
+	{
135
+		return fwrite($this->_handle, $data);
136
+	}
137
+
138
+	/**
139
+	 * _writeStr
140
+	 *
141
+	 * @access  private
142
+	 * @return  int
143
+	 * @param   string  $string
144
+	 */
145
+	function _writeStr($string)
146
+	{
147
+		return $this->_write($string . "\0");
148
+	}
149
+
150
+	/**
151
+	 * _readStr
152
+	 *
153
+	 * @access  private
154
+	 * @return  string
155
+	 * @param   array   $params     associative array with offset and length
156
+	 *                              of the string
157
+	 */
158
+	function _readStr($params)
159
+	{
160
+		fseek($this->_handle, $params['offset']);
161
+		return $this->_read($params['length']);
162
+	}
163
+
164
+	/**
165
+	 * Load MO file
166
+	 *
167
+	 * @access   public
168
+	 * @return   mixed   Returns true on success or PEAR_Error on failure.
169
+	 * @param    string  $file
170
+	 */
171
+	function load($file = null)
172
+	{
173
+		if (!isset($file)) {
174
+			$file = $this->file;
175
+		}
176
+
177
+		// open MO file
178
+		if (!is_resource($this->_handle = @fopen($file, 'rb'))) {
179
+			return false;
180
+		}
181
+		// lock MO file shared
182
+		if (!@flock($this->_handle, LOCK_SH)) {
183
+			@fclose($this->_handle);
184
+			return false;
185
+		}
186
+
187
+		// read (part of) magic number from MO file header and define endianess
188 188
 
189 189
 		//unpack returns a reference????
190 190
 		$unpacked = unpack('c', $this->_read(4));
191
-        switch ($magic = array_shift($unpacked))
192
-        {
193
-            case -34:
194
-                $be = false;
195
-            break;
196
-
197
-            case -107:
198
-                $be = true;
199
-            break;
200
-
201
-            default:
202
-                return false;
203
-        }
204
-
205
-        // check file format revision - we currently only support 0
206
-        if (0 !== ($_rev = $this->_readInt($be))) {
207
-            return false;
208
-        }
209
-
210
-        // count of strings in this file
211
-        $count = $this->_readInt($be);
212
-
213
-        // offset of hashing table of the msgids
214
-        $offset_original = $this->_readInt($be);
215
-        // offset of hashing table of the msgstrs
216
-        $offset_translat = $this->_readInt($be);
217
-
218
-        // move to msgid hash table
219
-        fseek($this->_handle, $offset_original);
220
-        // read lengths and offsets of msgids
221
-        $original = array();
222
-        for ($i = 0; $i < $count; $i++) {
223
-            $original[$i] = array(
224
-                'length' => $this->_readInt($be),
225
-                'offset' => $this->_readInt($be)
226
-            );
227
-        }
228
-
229
-        // move to msgstr hash table
230
-        fseek($this->_handle, $offset_translat);
231
-        // read lengths and offsets of msgstrs
232
-        $translat = array();
233
-        for ($i = 0; $i < $count; $i++) {
234
-            $translat[$i] = array(
235
-                'length' => $this->_readInt($be),
236
-                'offset' => $this->_readInt($be)
237
-            );
238
-        }
239
-
240
-        // read all
241
-        for ($i = 0; $i < $count; $i++) {
242
-            $this->strings[$this->_readStr($original[$i])] =
243
-                $this->_readStr($translat[$i]);
244
-        }
245
-
246
-        // done
247
-        @flock($this->_handle, LOCK_UN);
248
-        @fclose($this->_handle);
249
-        $this->_handle = null;
250
-
251
-        // check for meta info
252
-        if (isset($this->strings[''])) {
253
-            $this->meta = parent::meta2array($this->strings['']);
254
-            unset($this->strings['']);
255
-        }
256
-
257
-        return true;
258
-    }
259
-
260
-    /**
261
-     * Save MO file
262
-     *
263
-     * @access  public
264
-     * @return  mixed   Returns true on success or PEAR_Error on failure.
265
-     * @param   string  $file
266
-     */
267
-    function save($file = null)
268
-    {
269
-        if (!isset($file)) {
270
-            $file = $this->file;
271
-        }
272
-
273
-        // open MO file
274
-        if (!is_resource($this->_handle = @fopen($file, 'wb'))) {
275
-            return false;
276
-        }
277
-        // lock MO file exclusively
278
-        if (!@flock($this->_handle, LOCK_EX)) {
279
-            @fclose($this->_handle);
280
-            return false;
281
-        }
282
-
283
-        // write magic number
284
-        if ($this->writeBigEndian) {
285
-            $this->_write(pack('c*', 0x95, 0x04, 0x12, 0xde));
286
-        } else {
287
-            $this->_write(pack('c*', 0xde, 0x12, 0x04, 0x95));
288
-        }
289
-
290
-        // write file format revision
291
-        $this->_writeInt(0);
292
-
293
-        $count = count($this->strings) + ($meta = (count($this->meta) ? 1 : 0));
294
-        // write count of strings
295
-        $this->_writeInt($count);
296
-
297
-        $offset = 28;
298
-        // write offset of orig. strings hash table
299
-        $this->_writeInt($offset);
300
-
301
-        $offset += ($count * 8);
302
-        // write offset transl. strings hash table
303
-        $this->_writeInt($offset);
304
-
305
-        // write size of hash table (we currently ommit the hash table)
306
-        $this->_writeInt(0);
307
-
308
-        $offset += ($count * 8);
309
-        // write offset of hash table
310
-        $this->_writeInt($offset);
311
-
312
-        // unshift meta info
313
-        if ($this->meta) {
314
-            $meta = '';
315
-            foreach ($this->meta as $key => $val) {
316
-                $meta .= $key . ': ' . $val . "\n";
317
-            }
318
-            $strings = array('' => $meta) + $this->strings;
319
-        } else {
320
-            $strings = $this->strings;
321
-        }
322
-
323
-        // write offsets for original strings
324
-        foreach (array_keys($strings) as $o) {
325
-            $len = strlen($o);
326
-            $this->_writeInt($len);
327
-            $this->_writeInt($offset);
328
-            $offset += $len + 1;
329
-        }
330
-
331
-        // write offsets for translated strings
332
-        foreach ($strings as $t) {
333
-            $len = strlen($t);
334
-            $this->_writeInt($len);
335
-            $this->_writeInt($offset);
336
-            $offset += $len + 1;
337
-        }
338
-
339
-        // write original strings
340
-        foreach (array_keys($strings) as $o) {
341
-            $this->_writeStr($o);
342
-        }
343
-
344
-        // write translated strings
345
-        foreach ($strings as $t) {
346
-            $this->_writeStr($t);
347
-        }
348
-
349
-        // done
350
-        @flock($this->_handle, LOCK_UN);
351
-        @fclose($this->_handle);
352
-        chmod($file,PRADO_CHMOD);
353
-        return true;
354
-    }
191
+		switch ($magic = array_shift($unpacked))
192
+		{
193
+			case -34:
194
+				$be = false;
195
+			break;
196
+
197
+			case -107:
198
+				$be = true;
199
+			break;
200
+
201
+			default:
202
+				return false;
203
+		}
204
+
205
+		// check file format revision - we currently only support 0
206
+		if (0 !== ($_rev = $this->_readInt($be))) {
207
+			return false;
208
+		}
209
+
210
+		// count of strings in this file
211
+		$count = $this->_readInt($be);
212
+
213
+		// offset of hashing table of the msgids
214
+		$offset_original = $this->_readInt($be);
215
+		// offset of hashing table of the msgstrs
216
+		$offset_translat = $this->_readInt($be);
217
+
218
+		// move to msgid hash table
219
+		fseek($this->_handle, $offset_original);
220
+		// read lengths and offsets of msgids
221
+		$original = array();
222
+		for ($i = 0; $i < $count; $i++) {
223
+			$original[$i] = array(
224
+				'length' => $this->_readInt($be),
225
+				'offset' => $this->_readInt($be)
226
+			);
227
+		}
228
+
229
+		// move to msgstr hash table
230
+		fseek($this->_handle, $offset_translat);
231
+		// read lengths and offsets of msgstrs
232
+		$translat = array();
233
+		for ($i = 0; $i < $count; $i++) {
234
+			$translat[$i] = array(
235
+				'length' => $this->_readInt($be),
236
+				'offset' => $this->_readInt($be)
237
+			);
238
+		}
239
+
240
+		// read all
241
+		for ($i = 0; $i < $count; $i++) {
242
+			$this->strings[$this->_readStr($original[$i])] =
243
+				$this->_readStr($translat[$i]);
244
+		}
245
+
246
+		// done
247
+		@flock($this->_handle, LOCK_UN);
248
+		@fclose($this->_handle);
249
+		$this->_handle = null;
250
+
251
+		// check for meta info
252
+		if (isset($this->strings[''])) {
253
+			$this->meta = parent::meta2array($this->strings['']);
254
+			unset($this->strings['']);
255
+		}
256
+
257
+		return true;
258
+	}
259
+
260
+	/**
261
+	 * Save MO file
262
+	 *
263
+	 * @access  public
264
+	 * @return  mixed   Returns true on success or PEAR_Error on failure.
265
+	 * @param   string  $file
266
+	 */
267
+	function save($file = null)
268
+	{
269
+		if (!isset($file)) {
270
+			$file = $this->file;
271
+		}
272
+
273
+		// open MO file
274
+		if (!is_resource($this->_handle = @fopen($file, 'wb'))) {
275
+			return false;
276
+		}
277
+		// lock MO file exclusively
278
+		if (!@flock($this->_handle, LOCK_EX)) {
279
+			@fclose($this->_handle);
280
+			return false;
281
+		}
282
+
283
+		// write magic number
284
+		if ($this->writeBigEndian) {
285
+			$this->_write(pack('c*', 0x95, 0x04, 0x12, 0xde));
286
+		} else {
287
+			$this->_write(pack('c*', 0xde, 0x12, 0x04, 0x95));
288
+		}
289
+
290
+		// write file format revision
291
+		$this->_writeInt(0);
292
+
293
+		$count = count($this->strings) + ($meta = (count($this->meta) ? 1 : 0));
294
+		// write count of strings
295
+		$this->_writeInt($count);
296
+
297
+		$offset = 28;
298
+		// write offset of orig. strings hash table
299
+		$this->_writeInt($offset);
300
+
301
+		$offset += ($count * 8);
302
+		// write offset transl. strings hash table
303
+		$this->_writeInt($offset);
304
+
305
+		// write size of hash table (we currently ommit the hash table)
306
+		$this->_writeInt(0);
307
+
308
+		$offset += ($count * 8);
309
+		// write offset of hash table
310
+		$this->_writeInt($offset);
311
+
312
+		// unshift meta info
313
+		if ($this->meta) {
314
+			$meta = '';
315
+			foreach ($this->meta as $key => $val) {
316
+				$meta .= $key . ': ' . $val . "\n";
317
+			}
318
+			$strings = array('' => $meta) + $this->strings;
319
+		} else {
320
+			$strings = $this->strings;
321
+		}
322
+
323
+		// write offsets for original strings
324
+		foreach (array_keys($strings) as $o) {
325
+			$len = strlen($o);
326
+			$this->_writeInt($len);
327
+			$this->_writeInt($offset);
328
+			$offset += $len + 1;
329
+		}
330
+
331
+		// write offsets for translated strings
332
+		foreach ($strings as $t) {
333
+			$len = strlen($t);
334
+			$this->_writeInt($len);
335
+			$this->_writeInt($offset);
336
+			$offset += $len + 1;
337
+		}
338
+
339
+		// write original strings
340
+		foreach (array_keys($strings) as $o) {
341
+			$this->_writeStr($o);
342
+		}
343
+
344
+		// write translated strings
345
+		foreach ($strings as $t) {
346
+			$this->_writeStr($t);
347
+		}
348
+
349
+		// done
350
+		@flock($this->_handle, LOCK_UN);
351
+		@fclose($this->_handle);
352
+		chmod($file,PRADO_CHMOD);
353
+		return true;
354
+	}
355 355
 }
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      * @access  private
59 59
      * @var     resource
60 60
      */
61
-    protected $_handle = null;
61
+    protected $_handle=null;
62 62
 
63 63
     /**
64 64
      * big endianess
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      * @access  public
69 69
      * @var     bool
70 70
      */
71
-    protected $writeBigEndian = false;
71
+    protected $writeBigEndian=false;
72 72
 
73 73
     /**
74 74
      * Constructor
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
      * @return  object      File_Gettext_MO
78 78
      * @param   string      $file   path to GNU MO file
79 79
      */
80
-    function TGettext_MO($file = '')
80
+    function TGettext_MO($file='')
81 81
     {
82
-        $this->file = $file;
82
+        $this->file=$file;
83 83
     }
84 84
 
85 85
     /**
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
      * @return  mixed
90 90
      * @param   int     $bytes
91 91
      */
92
-    function _read($bytes = 1)
92
+    function _read($bytes=1)
93 93
     {
94
-        if (0 < $bytes = abs($bytes)) {
94
+        if(0 < $bytes=abs($bytes)) {
95 95
             return fread($this->_handle, $bytes);
96 96
         }
97 97
         return null;
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
      * @return  int
105 105
      * @param   bool    $bigendian
106 106
      */
107
-    function _readInt($bigendian = false)
107
+    function _readInt($bigendian=false)
108 108
     {
109 109
 		//unpack returns a reference????
110
-		$unpacked = unpack($bigendian ? 'N' : 'V', $this->_read(4));
110
+		$unpacked=unpack($bigendian ? 'N' : 'V', $this->_read(4));
111 111
         return array_shift($unpacked);
112 112
     }
113 113
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      */
145 145
     function _writeStr($string)
146 146
     {
147
-        return $this->_write($string . "\0");
147
+        return $this->_write($string."\0");
148 148
     }
149 149
 
150 150
     /**
@@ -168,18 +168,18 @@  discard block
 block discarded – undo
168 168
      * @return   mixed   Returns true on success or PEAR_Error on failure.
169 169
      * @param    string  $file
170 170
      */
171
-    function load($file = null)
171
+    function load($file=null)
172 172
     {
173
-        if (!isset($file)) {
174
-            $file = $this->file;
173
+        if(!isset($file)) {
174
+            $file=$this->file;
175 175
         }
176 176
 
177 177
         // open MO file
178
-        if (!is_resource($this->_handle = @fopen($file, 'rb'))) {
178
+        if(!is_resource($this->_handle=@fopen($file, 'rb'))) {
179 179
             return false;
180 180
         }
181 181
         // lock MO file shared
182
-        if (!@flock($this->_handle, LOCK_SH)) {
182
+        if(!@flock($this->_handle, LOCK_SH)) {
183 183
             @fclose($this->_handle);
184 184
             return false;
185 185
         }
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
         // read (part of) magic number from MO file header and define endianess
188 188
 
189 189
 		//unpack returns a reference????
190
-		$unpacked = unpack('c', $this->_read(4));
191
-        switch ($magic = array_shift($unpacked))
190
+		$unpacked=unpack('c', $this->_read(4));
191
+        switch($magic=array_shift($unpacked))
192 192
         {
193 193
             case -34:
194
-                $be = false;
194
+                $be=false;
195 195
             break;
196 196
 
197 197
             case -107:
198
-                $be = true;
198
+                $be=true;
199 199
             break;
200 200
 
201 201
             default:
@@ -203,24 +203,24 @@  discard block
 block discarded – undo
203 203
         }
204 204
 
205 205
         // check file format revision - we currently only support 0
206
-        if (0 !== ($_rev = $this->_readInt($be))) {
206
+        if(0!==($_rev=$this->_readInt($be))) {
207 207
             return false;
208 208
         }
209 209
 
210 210
         // count of strings in this file
211
-        $count = $this->_readInt($be);
211
+        $count=$this->_readInt($be);
212 212
 
213 213
         // offset of hashing table of the msgids
214
-        $offset_original = $this->_readInt($be);
214
+        $offset_original=$this->_readInt($be);
215 215
         // offset of hashing table of the msgstrs
216
-        $offset_translat = $this->_readInt($be);
216
+        $offset_translat=$this->_readInt($be);
217 217
 
218 218
         // move to msgid hash table
219 219
         fseek($this->_handle, $offset_original);
220 220
         // read lengths and offsets of msgids
221
-        $original = array();
222
-        for ($i = 0; $i < $count; $i++) {
223
-            $original[$i] = array(
221
+        $original=array();
222
+        for($i=0; $i < $count; $i++) {
223
+            $original[$i]=array(
224 224
                 'length' => $this->_readInt($be),
225 225
                 'offset' => $this->_readInt($be)
226 226
             );
@@ -229,28 +229,28 @@  discard block
 block discarded – undo
229 229
         // move to msgstr hash table
230 230
         fseek($this->_handle, $offset_translat);
231 231
         // read lengths and offsets of msgstrs
232
-        $translat = array();
233
-        for ($i = 0; $i < $count; $i++) {
234
-            $translat[$i] = array(
232
+        $translat=array();
233
+        for($i=0; $i < $count; $i++) {
234
+            $translat[$i]=array(
235 235
                 'length' => $this->_readInt($be),
236 236
                 'offset' => $this->_readInt($be)
237 237
             );
238 238
         }
239 239
 
240 240
         // read all
241
-        for ($i = 0; $i < $count; $i++) {
242
-            $this->strings[$this->_readStr($original[$i])] =
241
+        for($i=0; $i < $count; $i++) {
242
+            $this->strings[$this->_readStr($original[$i])]=
243 243
                 $this->_readStr($translat[$i]);
244 244
         }
245 245
 
246 246
         // done
247 247
         @flock($this->_handle, LOCK_UN);
248 248
         @fclose($this->_handle);
249
-        $this->_handle = null;
249
+        $this->_handle=null;
250 250
 
251 251
         // check for meta info
252
-        if (isset($this->strings[''])) {
253
-            $this->meta = parent::meta2array($this->strings['']);
252
+        if(isset($this->strings[''])) {
253
+            $this->meta=parent::meta2array($this->strings['']);
254 254
             unset($this->strings['']);
255 255
         }
256 256
 
@@ -264,24 +264,24 @@  discard block
 block discarded – undo
264 264
      * @return  mixed   Returns true on success or PEAR_Error on failure.
265 265
      * @param   string  $file
266 266
      */
267
-    function save($file = null)
267
+    function save($file=null)
268 268
     {
269
-        if (!isset($file)) {
270
-            $file = $this->file;
269
+        if(!isset($file)) {
270
+            $file=$this->file;
271 271
         }
272 272
 
273 273
         // open MO file
274
-        if (!is_resource($this->_handle = @fopen($file, 'wb'))) {
274
+        if(!is_resource($this->_handle=@fopen($file, 'wb'))) {
275 275
             return false;
276 276
         }
277 277
         // lock MO file exclusively
278
-        if (!@flock($this->_handle, LOCK_EX)) {
278
+        if(!@flock($this->_handle, LOCK_EX)) {
279 279
             @fclose($this->_handle);
280 280
             return false;
281 281
         }
282 282
 
283 283
         // write magic number
284
-        if ($this->writeBigEndian) {
284
+        if($this->writeBigEndian) {
285 285
             $this->_write(pack('c*', 0x95, 0x04, 0x12, 0xde));
286 286
         } else {
287 287
             $this->_write(pack('c*', 0xde, 0x12, 0x04, 0x95));
@@ -290,66 +290,66 @@  discard block
 block discarded – undo
290 290
         // write file format revision
291 291
         $this->_writeInt(0);
292 292
 
293
-        $count = count($this->strings) + ($meta = (count($this->meta) ? 1 : 0));
293
+        $count=count($this->strings) + ($meta=(count($this->meta) ? 1 : 0));
294 294
         // write count of strings
295 295
         $this->_writeInt($count);
296 296
 
297
-        $offset = 28;
297
+        $offset=28;
298 298
         // write offset of orig. strings hash table
299 299
         $this->_writeInt($offset);
300 300
 
301
-        $offset += ($count * 8);
301
+        $offset+=($count * 8);
302 302
         // write offset transl. strings hash table
303 303
         $this->_writeInt($offset);
304 304
 
305 305
         // write size of hash table (we currently ommit the hash table)
306 306
         $this->_writeInt(0);
307 307
 
308
-        $offset += ($count * 8);
308
+        $offset+=($count * 8);
309 309
         // write offset of hash table
310 310
         $this->_writeInt($offset);
311 311
 
312 312
         // unshift meta info
313
-        if ($this->meta) {
314
-            $meta = '';
315
-            foreach ($this->meta as $key => $val) {
316
-                $meta .= $key . ': ' . $val . "\n";
313
+        if($this->meta) {
314
+            $meta='';
315
+            foreach($this->meta as $key => $val) {
316
+                $meta.=$key.': '.$val."\n";
317 317
             }
318
-            $strings = array('' => $meta) + $this->strings;
318
+            $strings=array('' => $meta) + $this->strings;
319 319
         } else {
320
-            $strings = $this->strings;
320
+            $strings=$this->strings;
321 321
         }
322 322
 
323 323
         // write offsets for original strings
324
-        foreach (array_keys($strings) as $o) {
325
-            $len = strlen($o);
324
+        foreach(array_keys($strings) as $o) {
325
+            $len=strlen($o);
326 326
             $this->_writeInt($len);
327 327
             $this->_writeInt($offset);
328
-            $offset += $len + 1;
328
+            $offset+=$len + 1;
329 329
         }
330 330
 
331 331
         // write offsets for translated strings
332
-        foreach ($strings as $t) {
333
-            $len = strlen($t);
332
+        foreach($strings as $t) {
333
+            $len=strlen($t);
334 334
             $this->_writeInt($len);
335 335
             $this->_writeInt($offset);
336
-            $offset += $len + 1;
336
+            $offset+=$len + 1;
337 337
         }
338 338
 
339 339
         // write original strings
340
-        foreach (array_keys($strings) as $o) {
340
+        foreach(array_keys($strings) as $o) {
341 341
             $this->_writeStr($o);
342 342
         }
343 343
 
344 344
         // write translated strings
345
-        foreach ($strings as $t) {
345
+        foreach($strings as $t) {
346 346
             $this->_writeStr($t);
347 347
         }
348 348
 
349 349
         // done
350 350
         @flock($this->_handle, LOCK_UN);
351 351
         @fclose($this->_handle);
352
-        chmod($file,PRADO_CHMOD);
352
+        chmod($file, PRADO_CHMOD);
353 353
         return true;
354 354
     }
355 355
 }
Please login to merge, or discard this patch.
framework/I18N/core/Gettext/PO.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      * Load PO file
68 68
      *
69 69
      * @access  public
70
-     * @return  mixed   Returns true on success or PEAR_Error on failure.
70
+     * @return  boolean   Returns true on success or PEAR_Error on failure.
71 71
      * @param   string  $file
72 72
      */
73 73
     function load($file = null)
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
      * Save PO file
117 117
      *
118 118
      * @access  public
119
-     * @return  mixed   Returns true on success or PEAR_Error on failure.
119
+     * @return  boolean   Returns true on success or PEAR_Error on failure.
120 120
      * @param   string  $file
121 121
      */
122 122
     function save($file = null)
Please login to merge, or discard this patch.
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -1,20 +1,20 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TGettext_PO class file.
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the BSD License.
7
- *
8
- * Copyright(c) 2004 by Qiang Xue. All rights reserved.
9
- *
10
- * To contact the author write to {@link mailto:[email protected] Qiang Xue}
11
- * The latest version of PRADO can be obtained from:
12
- * {@link http://prado.sourceforge.net/}
13
- *
14
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
15
- * @version $Revision: 1.2 $  $Date: 2005/01/05 03:15:14 $
16
- * @package System.I18N.core
17
- */
3
+	 * TGettext_PO class file.
4
+	 *
5
+	 * This program is free software; you can redistribute it and/or modify
6
+	 * it under the terms of the BSD License.
7
+	 *
8
+	 * Copyright(c) 2004 by Qiang Xue. All rights reserved.
9
+	 *
10
+	 * To contact the author write to {@link mailto:[email protected] Qiang Xue}
11
+	 * The latest version of PRADO can be obtained from:
12
+	 * {@link http://prado.sourceforge.net/}
13
+	 *
14
+	 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
15
+	 * @version $Revision: 1.2 $  $Date: 2005/01/05 03:15:14 $
16
+	 * @package System.I18N.core
17
+	 */
18 18
 
19 19
 // +----------------------------------------------------------------------+
20 20
 // | PEAR :: File :: Gettext :: PO                                        |
@@ -51,110 +51,110 @@  discard block
 block discarded – undo
51 51
  */
52 52
 class TGettext_PO extends TGettext
53 53
 {
54
-    /**
55
-     * Constructor
56
-     *
57
-     * @access  public
58
-     * @return  object      File_Gettext_PO
59
-     * @param   string      path to GNU PO file
60
-     */
61
-    function TGettext_PO($file = '')
62
-    {
63
-        $this->file = $file;
64
-    }
54
+	/**
55
+	 * Constructor
56
+	 *
57
+	 * @access  public
58
+	 * @return  object      File_Gettext_PO
59
+	 * @param   string      path to GNU PO file
60
+	 */
61
+	function TGettext_PO($file = '')
62
+	{
63
+		$this->file = $file;
64
+	}
65 65
 
66
-    /**
67
-     * Load PO file
68
-     *
69
-     * @access  public
70
-     * @return  mixed   Returns true on success or PEAR_Error on failure.
71
-     * @param   string  $file
72
-     */
73
-    function load($file = null)
74
-    {
75
-        if (!isset($file)) {
76
-            $file = $this->file;
77
-        }
66
+	/**
67
+	 * Load PO file
68
+	 *
69
+	 * @access  public
70
+	 * @return  mixed   Returns true on success or PEAR_Error on failure.
71
+	 * @param   string  $file
72
+	 */
73
+	function load($file = null)
74
+	{
75
+		if (!isset($file)) {
76
+			$file = $this->file;
77
+		}
78 78
 
79
-        // load file
80
-        if (!$contents = @file($file)) {
81
-            return false;
82
-        }
83
-        $contents = implode('', $contents);
79
+		// load file
80
+		if (!$contents = @file($file)) {
81
+			return false;
82
+		}
83
+		$contents = implode('', $contents);
84 84
 
85
-        // match all msgid/msgstr entries
86
-        $matched = preg_match_all(
87
-            '/(msgid\s+("([^"]|\\\\")*?"\s*)+)\s+' .
88
-            '(msgstr\s+("([^"]|\\\\")*?"\s*)+)/',
89
-            $contents, $matches
90
-        );
91
-        unset($contents);
85
+		// match all msgid/msgstr entries
86
+		$matched = preg_match_all(
87
+			'/(msgid\s+("([^"]|\\\\")*?"\s*)+)\s+' .
88
+			'(msgstr\s+("([^"]|\\\\")*?"\s*)+)/',
89
+			$contents, $matches
90
+		);
91
+		unset($contents);
92 92
 
93
-        if (!$matched) {
94
-            return false;
95
-        }
93
+		if (!$matched) {
94
+			return false;
95
+		}
96 96
 
97
-        // get all msgids and msgtrs
98
-        for ($i = 0; $i < $matched; $i++) {
99
-            $msgid = preg_replace(
100
-                '/\s*msgid\s*"(.*)"\s*/s', '\\1', $matches[1][$i]);
101
-            $msgstr= preg_replace(
102
-                '/\s*msgstr\s*"(.*)"\s*/s', '\\1', $matches[4][$i]);
103
-            $this->strings[parent::prepare($msgid)] = parent::prepare($msgstr);
104
-        }
97
+		// get all msgids and msgtrs
98
+		for ($i = 0; $i < $matched; $i++) {
99
+			$msgid = preg_replace(
100
+				'/\s*msgid\s*"(.*)"\s*/s', '\\1', $matches[1][$i]);
101
+			$msgstr= preg_replace(
102
+				'/\s*msgstr\s*"(.*)"\s*/s', '\\1', $matches[4][$i]);
103
+			$this->strings[parent::prepare($msgid)] = parent::prepare($msgstr);
104
+		}
105 105
 
106
-        // check for meta info
107
-        if (isset($this->strings[''])) {
108
-            $this->meta = parent::meta2array($this->strings['']);
109
-            unset($this->strings['']);
110
-        }
106
+		// check for meta info
107
+		if (isset($this->strings[''])) {
108
+			$this->meta = parent::meta2array($this->strings['']);
109
+			unset($this->strings['']);
110
+		}
111 111
 
112
-        return true;
113
-    }
112
+		return true;
113
+	}
114 114
 
115
-    /**
116
-     * Save PO file
117
-     *
118
-     * @access  public
119
-     * @return  mixed   Returns true on success or PEAR_Error on failure.
120
-     * @param   string  $file
121
-     */
122
-    function save($file = null)
123
-    {
124
-        if (!isset($file)) {
125
-            $file = $this->file;
126
-        }
115
+	/**
116
+	 * Save PO file
117
+	 *
118
+	 * @access  public
119
+	 * @return  mixed   Returns true on success or PEAR_Error on failure.
120
+	 * @param   string  $file
121
+	 */
122
+	function save($file = null)
123
+	{
124
+		if (!isset($file)) {
125
+			$file = $this->file;
126
+		}
127 127
 
128
-        // open PO file
129
-        if (!is_resource($fh = @fopen($file, 'w'))) {
130
-            return false;
131
-        }
128
+		// open PO file
129
+		if (!is_resource($fh = @fopen($file, 'w'))) {
130
+			return false;
131
+		}
132 132
 
133
-        // lock PO file exclusively
134
-        if (!flock($fh, LOCK_EX)) {
135
-            fclose($fh);
136
-            return false;
137
-        }
138
-        // write meta info
139
-        if (count($this->meta)) {
140
-            $meta = 'msgid ""' . "\nmsgstr " . '""' . "\n";
141
-            foreach ($this->meta as $k => $v) {
142
-                $meta .= '"' . $k . ': ' . $v . '\n"' . "\n";
143
-            }
144
-            fwrite($fh, $meta . "\n");
145
-        }
146
-        // write strings
147
-        foreach ($this->strings as $o => $t) {
148
-            fwrite($fh,
149
-                'msgid "'  . parent::prepare($o, true) . '"' . "\n" .
150
-                'msgstr "' . parent::prepare($t, true) . '"' . "\n\n"
151
-            );
152
-        }
133
+		// lock PO file exclusively
134
+		if (!flock($fh, LOCK_EX)) {
135
+			fclose($fh);
136
+			return false;
137
+		}
138
+		// write meta info
139
+		if (count($this->meta)) {
140
+			$meta = 'msgid ""' . "\nmsgstr " . '""' . "\n";
141
+			foreach ($this->meta as $k => $v) {
142
+				$meta .= '"' . $k . ': ' . $v . '\n"' . "\n";
143
+			}
144
+			fwrite($fh, $meta . "\n");
145
+		}
146
+		// write strings
147
+		foreach ($this->strings as $o => $t) {
148
+			fwrite($fh,
149
+				'msgid "'  . parent::prepare($o, true) . '"' . "\n" .
150
+				'msgstr "' . parent::prepare($t, true) . '"' . "\n\n"
151
+			);
152
+		}
153 153
 
154
-        //done
155
-        @flock($fh, LOCK_UN);
156
-        @fclose($fh);
157
-        chmod($file,PRADO_CHMOD);
158
-        return true;
159
-    }
154
+		//done
155
+		@flock($fh, LOCK_UN);
156
+		@fclose($fh);
157
+		chmod($file,PRADO_CHMOD);
158
+		return true;
159
+	}
160 160
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
      * @return  object      File_Gettext_PO
59 59
      * @param   string      path to GNU PO file
60 60
      */
61
-    function TGettext_PO($file = '')
61
+    function TGettext_PO($file='')
62 62
     {
63
-        $this->file = $file;
63
+        $this->file=$file;
64 64
     }
65 65
 
66 66
     /**
@@ -70,42 +70,42 @@  discard block
 block discarded – undo
70 70
      * @return  mixed   Returns true on success or PEAR_Error on failure.
71 71
      * @param   string  $file
72 72
      */
73
-    function load($file = null)
73
+    function load($file=null)
74 74
     {
75
-        if (!isset($file)) {
76
-            $file = $this->file;
75
+        if(!isset($file)) {
76
+            $file=$this->file;
77 77
         }
78 78
 
79 79
         // load file
80
-        if (!$contents = @file($file)) {
80
+        if(!$contents=@file($file)) {
81 81
             return false;
82 82
         }
83
-        $contents = implode('', $contents);
83
+        $contents=implode('', $contents);
84 84
 
85 85
         // match all msgid/msgstr entries
86
-        $matched = preg_match_all(
87
-            '/(msgid\s+("([^"]|\\\\")*?"\s*)+)\s+' .
86
+        $matched=preg_match_all(
87
+            '/(msgid\s+("([^"]|\\\\")*?"\s*)+)\s+'.
88 88
             '(msgstr\s+("([^"]|\\\\")*?"\s*)+)/',
89 89
             $contents, $matches
90 90
         );
91 91
         unset($contents);
92 92
 
93
-        if (!$matched) {
93
+        if(!$matched) {
94 94
             return false;
95 95
         }
96 96
 
97 97
         // get all msgids and msgtrs
98
-        for ($i = 0; $i < $matched; $i++) {
99
-            $msgid = preg_replace(
98
+        for($i=0; $i < $matched; $i++) {
99
+            $msgid=preg_replace(
100 100
                 '/\s*msgid\s*"(.*)"\s*/s', '\\1', $matches[1][$i]);
101
-            $msgstr= preg_replace(
101
+            $msgstr=preg_replace(
102 102
                 '/\s*msgstr\s*"(.*)"\s*/s', '\\1', $matches[4][$i]);
103
-            $this->strings[parent::prepare($msgid)] = parent::prepare($msgstr);
103
+            $this->strings[parent::prepare($msgid)]=parent::prepare($msgstr);
104 104
         }
105 105
 
106 106
         // check for meta info
107
-        if (isset($this->strings[''])) {
108
-            $this->meta = parent::meta2array($this->strings['']);
107
+        if(isset($this->strings[''])) {
108
+            $this->meta=parent::meta2array($this->strings['']);
109 109
             unset($this->strings['']);
110 110
         }
111 111
 
@@ -119,42 +119,42 @@  discard block
 block discarded – undo
119 119
      * @return  mixed   Returns true on success or PEAR_Error on failure.
120 120
      * @param   string  $file
121 121
      */
122
-    function save($file = null)
122
+    function save($file=null)
123 123
     {
124
-        if (!isset($file)) {
125
-            $file = $this->file;
124
+        if(!isset($file)) {
125
+            $file=$this->file;
126 126
         }
127 127
 
128 128
         // open PO file
129
-        if (!is_resource($fh = @fopen($file, 'w'))) {
129
+        if(!is_resource($fh=@fopen($file, 'w'))) {
130 130
             return false;
131 131
         }
132 132
 
133 133
         // lock PO file exclusively
134
-        if (!flock($fh, LOCK_EX)) {
134
+        if(!flock($fh, LOCK_EX)) {
135 135
             fclose($fh);
136 136
             return false;
137 137
         }
138 138
         // write meta info
139
-        if (count($this->meta)) {
140
-            $meta = 'msgid ""' . "\nmsgstr " . '""' . "\n";
141
-            foreach ($this->meta as $k => $v) {
142
-                $meta .= '"' . $k . ': ' . $v . '\n"' . "\n";
139
+        if(count($this->meta)) {
140
+            $meta='msgid ""'."\nmsgstr ".'""'."\n";
141
+            foreach($this->meta as $k => $v) {
142
+                $meta.='"'.$k.': '.$v.'\n"'."\n";
143 143
             }
144
-            fwrite($fh, $meta . "\n");
144
+            fwrite($fh, $meta."\n");
145 145
         }
146 146
         // write strings
147
-        foreach ($this->strings as $o => $t) {
147
+        foreach($this->strings as $o => $t) {
148 148
             fwrite($fh,
149
-                'msgid "'  . parent::prepare($o, true) . '"' . "\n" .
150
-                'msgstr "' . parent::prepare($t, true) . '"' . "\n\n"
149
+                'msgid "'.parent::prepare($o, true).'"'."\n".
150
+                'msgstr "'.parent::prepare($t, true).'"'."\n\n"
151 151
             );
152 152
         }
153 153
 
154 154
         //done
155 155
         @flock($fh, LOCK_UN);
156 156
         @fclose($fh);
157
-        chmod($file,PRADO_CHMOD);
157
+        chmod($file, PRADO_CHMOD);
158 158
         return true;
159 159
     }
160 160
 }
Please login to merge, or discard this patch.
framework/I18N/core/Gettext/TGettext.php 3 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   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -1,20 +1,20 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TGettext class file.
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the BSD License.
7
- *
8
- * Copyright(c) 2004 by Qiang Xue. All rights reserved.
9
- *
10
- * To contact the author write to {@link mailto:[email protected] Qiang Xue}
11
- * The latest version of PRADO can be obtained from:
12
- * {@link http://prado.sourceforge.net/}
13
- *
14
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
15
- * @version $Revision: 1.4 $  $Date: 2005/01/09 23:36:23 $
16
- * @package System.I18N.core
17
- */
3
+	 * TGettext class file.
4
+	 *
5
+	 * This program is free software; you can redistribute it and/or modify
6
+	 * it under the terms of the BSD License.
7
+	 *
8
+	 * Copyright(c) 2004 by Qiang Xue. All rights reserved.
9
+	 *
10
+	 * To contact the author write to {@link mailto:[email protected] Qiang Xue}
11
+	 * The latest version of PRADO can be obtained from:
12
+	 * {@link http://prado.sourceforge.net/}
13
+	 *
14
+	 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
15
+	 * @version $Revision: 1.4 $  $Date: 2005/01/09 23:36:23 $
16
+	 * @package System.I18N.core
17
+	 */
18 18
 
19 19
 // +----------------------------------------------------------------------+
20 20
 // | PEAR :: File :: Gettext                                              |
@@ -58,229 +58,229 @@  discard block
 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   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      * @access  protected
67 67
      * @var     array
68 68
     */
69
-    protected $strings = array();
69
+    protected $strings=array();
70 70
 
71 71
     /**
72 72
      * meta
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      * @access  protected
78 78
      * @var     array
79 79
      */
80
-    protected $meta = array();
80
+    protected $meta=array();
81 81
 
82 82
     /**
83 83
      * file path
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      * @access  protected
86 86
      * @var     string
87 87
      */
88
-    protected $file = '';
88
+    protected $file='';
89 89
 
90 90
     /**
91 91
      * Factory
@@ -97,15 +97,15 @@  discard block
 block discarded – undo
97 97
      * @param   string  $format MO or PO
98 98
      * @param   string  $file   path to GNU gettext file
99 99
      */
100
-    static function factory($format, $file = '')
100
+    static function factory($format, $file='')
101 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");
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 107
         include_once $filename;
108
-        $class = 'TGettext_' . $format;
108
+        $class='TGettext_'.$format;
109 109
 
110 110
         return new $class($file);
111 111
     }
@@ -124,19 +124,19 @@  discard block
 block discarded – undo
124 124
      */
125 125
     static function poFile2moFile($pofile, $mofile)
126 126
     {
127
-        if (!is_file($pofile)) {
127
+        if(!is_file($pofile)) {
128 128
             throw new Exception("File $pofile doesn't exist.");
129 129
         }
130 130
 
131 131
         include_once dirname(__FILE__).'/PO.php';
132 132
 
133
-        $PO = new TGettext_PO($pofile);
134
-        if (true !== ($e = $PO->load())) {
133
+        $PO=new TGettext_PO($pofile);
134
+        if(true!==($e=$PO->load())) {
135 135
             return $e;
136 136
         }
137 137
 
138
-        $MO = $PO->toMO();
139
-        if (true !== ($e = $MO->save($mofile))) {
138
+        $MO=$PO->toMO();
139
+        if(true!==($e=$MO->save($mofile))) {
140 140
             return $e;
141 141
         }
142 142
         unset($PO, $MO);
@@ -153,16 +153,16 @@  discard block
 block discarded – undo
153 153
      * @param   string  $string
154 154
      * @param   bool    $reverse
155 155
      */
156
-    static function prepare($string, $reverse = false)
156
+    static function prepare($string, $reverse=false)
157 157
     {
158
-        if ($reverse) {
159
-            $smap = array('"', "\n", "\t", "\r");
160
-            $rmap = array('\"', '\\n"' . "\n" . '"', '\\t', '\\r');
158
+        if($reverse) {
159
+            $smap=array('"', "\n", "\t", "\r");
160
+            $rmap=array('\"', '\\n"'."\n".'"', '\\t', '\\r');
161 161
             return (string) str_replace($smap, $rmap, $string);
162 162
         } else {
163
-        	$string = preg_replace('/"\s+"/', '', $string);
164
-            $smap = array('\\n', '\\r', '\\t', '\"');
165
-            $rmap = array("\n", "\r", "\t", '"');
163
+        	$string=preg_replace('/"\s+"/', '', $string);
164
+            $smap=array('\\n', '\\r', '\\t', '\"');
165
+            $rmap=array("\n", "\r", "\t", '"');
166 166
             return (string) str_replace($smap, $rmap, $string);
167 167
         }
168 168
     }
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
      */
178 178
     static function meta2array($meta)
179 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);
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 185
             }
186 186
         }
187 187
         return $array;
@@ -243,15 +243,15 @@  discard block
 block discarded – undo
243 243
      */
244 244
     function fromArray($array)
245 245
     {
246
-    	if (!array_key_exists('strings', $array)) {
247
-    	    if (count($array) != 2) {
246
+    	if(!array_key_exists('strings', $array)) {
247
+    	    if(count($array)!=2) {
248 248
                 return false;
249 249
     	    } else {
250
-    	        list($this->meta, $this->strings) = $array;
250
+    	        list($this->meta, $this->strings)=$array;
251 251
             }
252 252
     	} else {
253
-            $this->meta = @$array['meta'];
254
-            $this->strings = @$array['strings'];
253
+            $this->meta=@$array['meta'];
254
+            $this->strings=@$array['strings'];
255 255
         }
256 256
         return true;
257 257
     }
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
     function toMO()
266 266
     {
267 267
         include_once dirname(__FILE__).'/MO.php';
268
-        $MO = new TGettext_MO;
268
+        $MO=new TGettext_MO;
269 269
         $MO->fromArray($this->toArray());
270 270
         return $MO;
271 271
     }
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
     function toPO()
280 280
     {
281 281
         include_once dirname(__FILE__).'/PO.php';
282
-        $PO = new TGettext_PO;
282
+        $PO=new TGettext_PO;
283 283
         $PO->fromArray($this->toArray());
284 284
         return $PO;
285 285
     }
Please login to merge, or discard this patch.
framework/I18N/core/IMessageSource.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -109,6 +109,7 @@
 block discarded – undo
109 109
 	/**
110 110
 	 * Set the culture for this particular message source.
111 111
 	 * @param string the Culture name.
112
+	 * @return void
112 113
 	 */
113 114
 	function setCulture($culture);
114 115
 	
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
 	 * @param string a catalogue to load
48 48
 	 * @return boolean true if loaded, false otherwise.
49 49
 	 */
50
-	function load($catalogue = 'messages');	
50
+	function load($catalogue='messages');	
51 51
 	
52 52
 	/**
53 53
 	 * Get the translation table. This includes all the loaded sections.
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
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	/**
29 29
 	 * Caceh life time, default is 1 year.
30 30
 	 */
31
-	protected $lifetime = 3153600;
31
+	protected $lifetime=3153600;
32 32
 
33 33
 
34 34
 	/**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 */
38 38
 	public function __construct($cacheDir)
39 39
 	{
40
-		$cacheDir = $cacheDir.'/';
40
+		$cacheDir=$cacheDir.'/';
41 41
 
42 42
 		if(!is_dir($cacheDir))
43 43
 			throw new Exception(
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 				'The cache directory '.$cacheDir.' must be writable '.
49 49
 				'by the server.');
50 50
 
51
-		$options = array(
51
+		$options=array(
52 52
 			'cacheDir' => $cacheDir,
53 53
 			'lifeTime' => $this->getLifeTime(),
54 54
 			'automaticSerialization' => true
55 55
 		);
56 56
 
57
-		$this->cache = new TCache_Lite($options);
57
+		$this->cache=new TCache_Lite($options);
58 58
 	}
59 59
 
60 60
 	/**
@@ -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
 	/**
@@ -106,18 +106,18 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	public function get($catalogue, $culture, $lastmodified=0)
108 108
 	{
109
-		$ID = $this->getID($catalogue, $culture);
110
-		$group = $this->getGroup($catalogue, $culture);
109
+		$ID=$this->getID($catalogue, $culture);
110
+		$group=$this->getGroup($catalogue, $culture);
111 111
 
112 112
 		$this->cache->_setFileName($ID, $group);
113 113
 
114
-		$cache = $this->cache->getCacheFile();
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 122
 		if($lastmodified <= 0 || $lastmodified > filemtime($cache))
123 123
 			return false;
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
 	 */
137 137
 	public function save($data, $catalogue, $culture)
138 138
 	{
139
-		$ID = $this->getID($catalogue, $culture);
140
-		$group = $this->getGroup($catalogue, $culture);
139
+		$ID=$this->getID($catalogue, $culture);
140
+		$group=$this->getGroup($catalogue, $culture);
141 141
 
142 142
 		//echo '## Cache save: "'.$ID.'" : "'.$group.'"';
143 143
 		//echo "<br>\n";
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function clean($catalogue, $culture)
154 154
 	{
155
-		$group = $this->getGroup($catalogue, $culture);
155
+		$group=$this->getGroup($catalogue, $culture);
156 156
 		$this->cache->clean($group);
157 157
 	}
158 158
 
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   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -63,25 +63,25 @@  discard block
 block discarded – undo
63 63
 	 * A list of loaded message catalogues.
64 64
 	 * @var array 
65 65
 	 */
66
-	protected $catagloues = array();
66
+	protected $catagloues=array();
67 67
 	
68 68
 	/**
69 69
 	 * The translation messages.
70 70
 	 * @var array 
71 71
 	 */
72
-	protected $messages = array();
72
+	protected $messages=array();
73 73
 	
74 74
 	/**
75 75
 	 * A list of untranslated messages.
76 76
 	 * @var array 
77 77
 	 */
78
-	protected $untranslated = array();
78
+	protected $untranslated=array();
79 79
 	
80 80
 	/**
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.
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * Output encoding charset
94 94
 	 * @var string
95 95
 	 */
96
-	protected $charset = 'UTF-8'; 
96
+	protected $charset='UTF-8'; 
97 97
 
98 98
 	/**
99 99
 	 * Constructor.
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	function __construct(IMessageSource $source, $charset='UTF-8')
106 106
 	{
107
-		$this->source = $source;	
107
+		$this->source=$source;	
108 108
 		$this->setCharset($charset);
109 109
 	}
110 110
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	public function setCharset($charset)
116 116
 	{
117
-		$this->charset = $charset;
117
+		$this->charset=$charset;
118 118
 	}
119 119
 
120 120
 	/**
@@ -135,13 +135,13 @@  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 141
 		if($this->source->load($catalogue))
142 142
 		{
143
-			$this->messages[$catalogue] = $this->source->read();
144
-			$this->catagloues[] = $catalogue;						
143
+			$this->messages[$catalogue]=$this->source->read();
144
+			$this->catagloues[]=$catalogue;						
145 145
 		}
146 146
 	}
147 147
 
@@ -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 166
 		foreach($args as $k => $v)
167
-			$args[$k] = I18N_toUTF8($v, $charset);
168
-		$s = $this->formatString(I18N_toUTF8($string, $charset),$args,$catalogue);
167
+			$args[$k]=I18N_toUTF8($v, $charset);
168
+		$s=$this->formatString(I18N_toUTF8($string, $charset), $args, $catalogue);
169 169
 		return I18N_toEncoding($s, $charset);
170 170
 	}
171 171
 
@@ -182,15 +182,15 @@  discard block
 block discarded – undo
182 182
 		if(empty($catalogue))
183 183
 		{
184 184
 			if(empty($this->Catalogue))
185
-				$catalogue = 'messages';
185
+				$catalogue='messages';
186 186
 			else 
187
-				$catalogue = $this->Catalogue;
187
+				$catalogue=$this->Catalogue;
188 188
 		}
189 189
 				
190 190
 		$this->loadCatalogue($catalogue);
191 191
 		
192 192
 		if(empty($args))
193
-			$args = array();		
193
+			$args=array();		
194 194
 		
195 195
 		foreach($this->messages[$catalogue] as $variant)
196 196
 		{
@@ -198,14 +198,14 @@  discard block
 block discarded – undo
198 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 204
 					if(is_string($result))
205
-						$target = $result;
205
+						$target=$result;
206 206
 					else
207 207
 					{
208
-						$target = $result[0];
208
+						$target=$result[0];
209 209
 					}
210 210
 					//found, but untranslated
211 211
 					if(empty($target))
@@ -245,10 +245,10 @@  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
-			$this->postscript[0] = $postscript[0];
251
-			$this->postscript[1] = $postscript[1];
250
+			$this->postscript[0]=$postscript[0];
251
+			$this->postscript[1]=$postscript[1];
252 252
 		}
253 253
 	}
254 254
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -213,8 +213,7 @@
 block discarded – undo
213 213
 						return 	$this->postscript[0].
214 214
 								strtr($string, $args).
215 215
 								$this->postscript[1];		
216
-					}
217
-					else
216
+					} else
218 217
 						return strtr($target, $args);
219 218
 				}
220 219
 			}
Please login to merge, or discard this patch.
framework/I18N/core/MessageSource.php 3 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
@@ -110,15 +110,15 @@
 block discarded – undo
110 110
 	/**
111 111
 	 * Factory method to instantiate a new MessageSource depending on the
112 112
 	 * source type. The allowed source types are 'XLIFF', 'gettext' and
113
-     * 'Database'. The source parameter depends on the source type. 
114
-     * For 'gettext' and 'XLIFF', 'source' should point to the directory 
115
-     * where the messages are stored. 
116
-     * For 'Database', 'source' must be a valid connection id.
117
-     * If one of the deprecated types 'MySQL' or 'SQLite' is used, 
118
-     * 'source' must contain a valid  DSN.
113
+	 * 'Database'. The source parameter depends on the source type. 
114
+	 * For 'gettext' and 'XLIFF', 'source' should point to the directory 
115
+	 * where the messages are stored. 
116
+	 * For 'Database', 'source' must be a valid connection id.
117
+	 * If one of the deprecated types 'MySQL' or 'SQLite' is used, 
118
+	 * 'source' must contain a valid  DSN.
119 119
 	 *
120
- 	 * Custom message source are possible by supplying the a filename parameter
121
- 	 * in the factory method.
120
+	 * Custom message source are possible by supplying the a filename parameter
121
+	 * in the factory method.
122 122
 	 * 
123 123
 	 * @param string the message source type.
124 124
 	 * @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
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 * Array of translation messages.
83 83
 	 * @var array 
84 84
 	 */
85
-	protected $messages = array();
85
+	protected $messages=array();
86 86
 
87 87
 	/**
88 88
 	 * The source of message translations.
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	protected $cache;
98 98
 	
99
-	protected $untranslated = array();
99
+	protected $untranslated=array();
100 100
 
101 101
 	/**
102 102
 	 * Private constructor. MessageSource must be initialized using
@@ -128,23 +128,23 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	static function &factory($type, $source='.', $filename='')
130 130
 	{
131
-		$types = array('XLIFF','gettext','Database','MySQL','SQLite');
131
+		$types=array('XLIFF', 'gettext', 'Database', 'MySQL', 'SQLite');
132 132
 		
133 133
 		if(empty($filename) && !in_array($type, $types))
134 134
 			throw new Exception('Invalid type "'.$type.'", valid types are '.
135 135
 				implode(', ', $types));
136 136
 		
137
-		$class = 'MessageSource_'.$type;
137
+		$class='MessageSource_'.$type;
138 138
 		
139 139
 		if(empty($filename))
140
-			$filename = dirname(__FILE__).'/'.$class.'.php';
140
+			$filename=dirname(__FILE__).'/'.$class.'.php';
141 141
 						
142
-		if(is_file($filename) == false)
142
+		if(is_file($filename)==false)
143 143
 			throw new Exception("File $filename not found");
144 144
 						
145 145
 		include_once $filename;
146 146
         
147
-		$obj =  new $class($source);
147
+		$obj=new $class($source);
148 148
 		
149 149
 		return $obj;
150 150
 	}
@@ -170,36 +170,36 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	function load($catalogue='messages')
172 172
 	{
173
-		$variants = $this->getCatalogueList($catalogue);
173
+		$variants=$this->getCatalogueList($catalogue);
174 174
 		
175
-		$this->messages = array();
175
+		$this->messages=array();
176 176
 		
177 177
 		foreach($variants as $variant)
178 178
 		{
179
-			$source = $this->getSource($variant);
179
+			$source=$this->getSource($variant);
180 180
 			
181
-			if($this->isValidSource($source) == false) continue;
181
+			if($this->isValidSource($source)==false) continue;
182 182
 
183
-			$loadData = true;
183
+			$loadData=true;
184 184
 			
185 185
 			if($this->cache)
186 186
 			{
187
-				$data = $this->cache->get($variant, 
187
+				$data=$this->cache->get($variant, 
188 188
 					$this->culture, $this->getLastModified($source));
189 189
 				
190 190
 				if(is_array($data))
191 191
 				{
192
-					$this->messages[$variant] = $data;
193
-					$loadData = false;
192
+					$this->messages[$variant]=$data;
193
+					$loadData=false;
194 194
 				}
195 195
 				unset($data);
196 196
 			}
197 197
 			if($loadData)
198 198
 			{
199
-				$data = &$this->loadData($source);
199
+				$data=&$this->loadData($source);
200 200
 				if(is_array($data))
201 201
 				{
202
-					$this->messages[$variant] = $data;
202
+					$this->messages[$variant]=$data;
203 203
 					if($this->cache)
204 204
 						$this->cache->save($data, $variant, $this->culture);
205 205
 				}	
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	 */
236 236
 	public function setCache(MessageCache $cache)
237 237
 	{
238
-		$this->cache = $cache;
238
+		$this->cache=$cache;
239 239
 	}
240 240
 	
241 241
 	/**
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	public function append($message)
247 247
 	{
248 248
 		if(!in_array($message, $this->untranslated))
249
-			$this->untranslated[] = $message;
249
+			$this->untranslated[]=$message;
250 250
 	}
251 251
 	
252 252
 	/**
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 	 */
256 256
 	public function setCulture($culture)
257 257
 	{
258
-		$this->culture = $culture;
258
+		$this->culture=$culture;
259 259
 	}	
260 260
 	
261 261
 	/**
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   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -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
 	/**
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 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');
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
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);
94
+		$command->bindParameter(':variant', $variant, PDO::PARAM_STR);
95 95
 		$dataReader=$command->query();
96 96
 
97
-		$result = array();
97
+		$result=array();
98 98
 
99
-		foreach ($dataReader as $row)
100
-			$result[$row['source']] = array($row['target'],$row['id'],$row['comments']);
99
+		foreach($dataReader as $row)
100
+			$result[$row['source']]=array($row['target'], $row['id'], $row['comments']);
101 101
 
102 102
 		return $result;
103 103
 	}
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	{
113 113
 		$command=$this->getDBConnection()->createCommand(
114 114
 			'SELECT date_modified FROM catalogue WHERE name = :source');
115
-		$command->bindParameter(':source',$source,PDO::PARAM_STR);
115
+		$command->bindParameter(':source', $source, PDO::PARAM_STR);
116 116
 		$result=$command->queryScalar();
117 117
 		return $result ? $result : 0;
118 118
 	}
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	{
129 129
 		$command=$this->getDBConnection()->createCommand(
130 130
 			'SELECT COUNT(*) FROM catalogue WHERE name = :variant');
131
-		$command->bindParameter(':variant',$variant,PDO::PARAM_STR);
131
+		$command->bindParameter(':variant', $variant, PDO::PARAM_STR);
132 132
 		return $command->queryScalar()==1;
133 133
 	}
134 134
 
@@ -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
-		$catalogues = array($catalogue);
144
+		$catalogues=array($catalogue);
145 145
 
146
-		$variant = null;
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 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);
@@ -164,20 +164,20 @@  discard block
 block discarded – undo
164 164
 	private function getCatalogueDetails($catalogue='messages')
165 165
 	{
166 166
 		if(empty($catalogue))
167
-			$catalogue = 'messages';
167
+			$catalogue='messages';
168 168
 
169
-		$variant = $catalogue.'.'.$this->culture;
169
+		$variant=$catalogue.'.'.$this->culture;
170 170
 
171 171
 		$command=$this->getDBConnection()->createCommand(
172 172
 			'SELECT cat_id FROM catalogue WHERE name = :variant');
173
-		$command->bindParameter(':variant',$variant,PDO::PARAM_STR);
173
+		$command->bindParameter(':variant', $variant, PDO::PARAM_STR);
174 174
 		$cat_id=$command->queryScalar();
175 175
 
176
-		if ($cat_id===null) return false;
176
+		if($cat_id===null) return false;
177 177
 
178 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);
180
+		$command->bindParameter(':catid', $cat_id, PDO::PARAM_INT);
181 181
 		$count=$command->queryScalar();
182 182
 
183 183
 		return array($cat_id, $variant, $count);
@@ -189,11 +189,11 @@  discard block
 block discarded – undo
189 189
 	 */
190 190
 	private function updateCatalogueTime($cat_id, $variant)
191 191
 	{
192
-		$time = time();
192
+		$time=time();
193 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);
195
+		$command->bindParameter(':moddate', $time, PDO::PARAM_INT);
196
+		$command->bindParameter(':catid', $cat_id, PDO::PARAM_INT);
197 197
 		$result=$command->execute();
198 198
 
199 199
 		if(!empty($this->cache))
@@ -211,31 +211,31 @@  discard block
 block discarded – undo
211 211
 	 */
212 212
 	function save($catalogue='messages')
213 213
 	{
214
-		$messages = $this->untranslated;
214
+		$messages=$this->untranslated;
215 215
 
216 216
 		if(count($messages) <= 0) return false;
217 217
 
218
-		$details = $this->getCatalogueDetails($catalogue);
218
+		$details=$this->getCatalogueDetails($catalogue);
219 219
 
220 220
 		if($details)
221
-			list($cat_id, $variant, $count) = $details;
221
+			list($cat_id, $variant, $count)=$details;
222 222
 		else
223 223
 			return false;
224 224
 
225 225
 		if($cat_id <= 0) return false;
226
-		$inserted = 0;
226
+		$inserted=0;
227 227
 
228
-		$time = time();
228
+		$time=time();
229 229
 
230 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);
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 236
 		foreach($messages as $message)
237 237
 		{
238
-			if (empty($message)) continue;
238
+			if(empty($message)) continue;
239 239
 			$count++; $inserted++;
240 240
 			$command->execute();
241 241
 		}
@@ -253,16 +253,16 @@  discard block
 block discarded – undo
253 253
 	 */
254 254
 	function delete($message, $catalogue='messages')
255 255
 	{
256
-		$details = $this->getCatalogueDetails($catalogue);
256
+		$details=$this->getCatalogueDetails($catalogue);
257 257
 		if($details)
258
-			list($cat_id, $variant, $count) = $details;
258
+			list($cat_id, $variant, $count)=$details;
259 259
 		else
260 260
 			return false;
261 261
 
262 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 267
 		return ($command->execute()==1) ? $this->updateCatalogueTime($cat_id, $variant) : false;
268 268
 
@@ -278,21 +278,21 @@  discard block
 block discarded – undo
278 278
 	 */
279 279
 	function update($text, $target, $comments, $catalogue='messages')
280 280
 	{
281
-		$details = $this->getCatalogueDetails($catalogue);
281
+		$details=$this->getCatalogueDetails($catalogue);
282 282
 		if($details)
283
-			list($cat_id, $variant, $count) = $details;
283
+			list($cat_id, $variant, $count)=$details;
284 284
 		else
285 285
 			return false;
286 286
 
287
-		$time = time();
287
+		$time=time();
288 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 297
 		return ($command->execute()==1) ? $this->updateCatalogueTime($cat_id, $variant) : false;
298 298
 	}
@@ -303,17 +303,17 @@  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');
306
+		$command=$this->getDBConnection()->createCommand('SELECT name FROM catalogue ORDER BY name');
307 307
 		$dataReader=$command->query();
308 308
 
309
-		$result = array();
309
+		$result=array();
310 310
 
311
-		foreach ($dataReader as $row)
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
-			$result[] = $details;
316
+			$result[]=$details;
317 317
 		}
318 318
 
319 319
 		return $result;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,8 +58,7 @@
 block discarded – undo
58 58
 		if ($this->sourcepath === NULL)
59 59
 		{
60 60
 			$this->sourcepath = $sourcepath;
61
-		}
62
-		else
61
+		} else
63 62
 		{
64 63
 			$this->sourcepath->append($sourcepath);
65 64
 		}
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   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -45,23 +45,23 @@  discard block
 block discarded – undo
45 45
 	 * Message data filename extension.
46 46
 	 * @var string
47 47
 	 */
48
-	protected $dataExt = '.mo';
48
+	protected $dataExt='.mo';
49 49
 
50 50
 	/**
51 51
 	 * PO data filename extension
52 52
 	 * @var string
53 53
 	 */
54
-	protected $poExt = '.po';
54
+	protected $poExt='.po';
55 55
 
56 56
 	/**
57 57
 	 * Separator between culture name and source.
58 58
 	 * @var string
59 59
 	 */
60
-	protected $dataSeparator = '.';
60
+	protected $dataSeparator='.';
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,17 +72,17 @@  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
-		$result = $mo->toArray();
77
+		$result=$mo->toArray();
78 78
 
79
-		$results = array();
79
+		$results=array();
80 80
 		$count=0;
81 81
 		foreach($result['strings'] as $source => $target)
82 82
 		{
83
-			$results[$source][] = $target; //target
84
-			$results[$source][] = $count++; //id
85
-			$results[$source][] = ''; //comments
83
+			$results[$source][]=$target; //target
84
+			$results[$source][]=$count++; //id
85
+			$results[$source][]=''; //comments
86 86
 		}
87 87
 		return $results;
88 88
 	}
@@ -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
-		$catalogues = array($source);
135
+		$catalogues=array($source);
136 136
 
137
-		$variant = null;
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 141
 			if(isset($variants[$i]{0}))
142 142
 			{
143
-				$variant .= ($variant)?'_'.$variants[$i]:$variants[$i];
144
-				$catalogues[] = $catalogue.$this->dataSeparator.
143
+				$variant.=($variant) ? '_'.$variants[$i] : $variants[$i];
144
+				$catalogues[]=$catalogue.$this->dataSeparator.
145 145
 								$variant.$this->dataExt;
146 146
 			}
147 147
 		}
148
-		$byDir = $this->getCatalogueByDir($catalogue);
149
-		$catalogues = array_merge($byDir,array_reverse($catalogues));
148
+		$byDir=$this->getCatalogueByDir($catalogue);
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);
164
-		$catalogues = array();
163
+		$variants=explode('_', $this->culture);
164
+		$catalogues=array();
165 165
 
166
-		$variant = null;
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 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);
@@ -186,14 +186,14 @@  discard block
 block discarded – undo
186 186
 	 */
187 187
 	private function getVariants($catalogue='messages')
188 188
 	{
189
-		if($catalogue === null) {
190
-			$catalogue = 'messages';
189
+		if($catalogue===null) {
190
+			$catalogue='messages';
191 191
 		}
192 192
 
193 193
 		foreach($this->getCatalogueList($catalogue) as $variant)
194 194
 		{
195
-			$file = $this->getSource($variant);
196
-			$po = $this->getPOFile($file);
195
+			$file=$this->getSource($variant);
196
+			$po=$this->getPOFile($file);
197 197
 			if(is_file($file) || is_file($po))
198 198
 				return array($variant, $file, $po);
199 199
 		}
@@ -202,7 +202,7 @@  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));
205
+		$filebase=substr($MOFile, 0, strlen($MOFile) - strlen($this->dataExt));
206 206
 		return $filebase.$this->poExt;
207 207
 	}
208 208
 
@@ -215,46 +215,46 @@  discard block
 block discarded – undo
215 215
 	 */
216 216
 	function save($catalogue='messages')
217 217
 	{
218
-		$messages = $this->untranslated;
218
+		$messages=$this->untranslated;
219 219
 
220 220
 		if(count($messages) <= 0) return false;
221 221
 
222
-		$variants = $this->getVariants($catalogue);
222
+		$variants=$this->getVariants($catalogue);
223 223
 
224 224
 		if($variants)
225
-			list($variant, $MOFile, $POFile) = $variants;
225
+			list($variant, $MOFile, $POFile)=$variants;
226 226
 		else
227
-			list($variant, $MOFile, $POFile) = $this->createMessageTemplate($catalogue);
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
-		$strings = array();
235
+		$strings=array();
236 236
 		foreach($messages as $message)
237
-			$strings[$message] = '';
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
-		$result = $po->toArray();
242
+		$result=$po->toArray();
243 243
 
244
-		$existing = count($result['strings']);
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
-		$new = count($result['strings']);
249
+		$new=count($result['strings']);
250 250
 
251 251
 		if($new > $existing)
252 252
 		{
253 253
 			//change the date 2004-12-25 12:26
254
-			$result['meta']['PO-Revision-Date'] = @date('Y-m-d H:i:s');
254
+			$result['meta']['PO-Revision-Date']=@date('Y-m-d H:i:s');
255 255
 
256 256
 			$po->fromArray($result);
257
-			$mo = $po->toMO();
257
+			$mo=$po->toMO();
258 258
 			if($po->save() && $mo->save($MOFile))
259 259
 			{
260 260
 				if(!empty($this->cache))
@@ -275,30 +275,30 @@  discard block
 block discarded – undo
275 275
 	 */
276 276
 	function delete($message, $catalogue='messages')
277 277
 	{
278
-		$variants = $this->getVariants($catalogue);
278
+		$variants=$this->getVariants($catalogue);
279 279
 		if($variants)
280
-			list($variant, $MOFile, $POFile) = $variants;
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
-		$result = $po->toArray();
291
+		$result=$po->toArray();
292 292
 
293 293
 		foreach($result['strings'] as $string => $value)
294 294
 		{
295
-			if($string == $message)
295
+			if($string==$message)
296 296
 			{
297
-				$result['meta']['PO-Revision-Date'] = @date('Y-m-d H:i:s');
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
-				$mo = $po->toMO();
301
+				$mo=$po->toMO();
302 302
 				if($po->save() && $mo->save($MOFile))
303 303
 				{
304 304
 					if(!empty($this->cache))
@@ -323,31 +323,31 @@  discard block
 block discarded – undo
323 323
 	 */
324 324
 	function update($text, $target, $comments, $catalogue='messages')
325 325
 	{
326
-		$variants = $this->getVariants($catalogue);
326
+		$variants=$this->getVariants($catalogue);
327 327
 		if($variants)
328
-			list($variant, $MOFile, $POFile) = $variants;
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
-		$result = $po->toArray();
340
+		$result=$po->toArray();
341 341
 
342 342
 		foreach($result['strings'] as $string => $value)
343 343
 		{
344
-			if($string == $text)
344
+			if($string==$text)
345 345
 			{
346
-				$result['strings'][$string] = $target;
347
-				$result['meta']['PO-Revision-Date'] = @date('Y-m-d H:i:s');
346
+				$result['strings'][$string]=$target;
347
+				$result['meta']['PO-Revision-Date']=@date('Y-m-d H:i:s');
348 348
 
349 349
 				$po->fromArray($result);
350
-				$mo = $po->toMO();
350
+				$mo=$po->toMO();
351 351
 
352 352
 				if($po->save() && $mo->save($MOFile))
353 353
 				{
@@ -379,42 +379,42 @@  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;
385
-		$files = scandir($dir);
384
+		$dir=$dir ? $dir : $this->source;
385
+		$files=scandir($dir);
386 386
 
387
-		$catalogue = array();
387
+		$catalogue=array();
388 388
 
389 389
 		foreach($files as $file)
390 390
 		{
391 391
 			if(is_dir($dir.'/'.$file)
392
-				&& preg_match('/^[a-z]{2}(_[A-Z]{2,3})?$/',$file))
392
+				&& preg_match('/^[a-z]{2}(_[A-Z]{2,3})?$/', $file))
393 393
 			{
394 394
 
395
-				$catalogue = array_merge($catalogue,
395
+				$catalogue=array_merge($catalogue,
396 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);
406
-				$culture = $variant;
407
-				$cat = $name;
404
+				$name=substr($file, 0, $pos);
405
+				$dot=strrpos($name, $this->dataSeparator);
406
+				$culture=$variant;
407
+				$cat=$name;
408 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
-				$details[0] = $cat;
414
-				$details[1] = $culture;
413
+				$details[0]=$cat;
414
+				$details[1]=$culture;
415 415
 
416 416
 
417
-				$catalogue[] = $details;
417
+				$catalogue[]=$details;
418 418
 			}
419 419
 		}
420 420
 		sort($catalogue);
@@ -424,29 +424,29 @@  discard block
 block discarded – undo
424 424
 
425 425
 	protected function createMessageTemplate($catalogue)
426 426
 	{
427
-		if($catalogue === null) {
428
-			$catalogue = 'messages';
427
+		if($catalogue===null) {
428
+			$catalogue='messages';
429 429
 		}
430
-		$variants = $this->getCatalogueList($catalogue);
431
-		$variant = array_shift($variants);
432
-		$mo_file = $this->getSource($variant);
433
-		$po_file = $this->getPOFile($mo_file);
430
+		$variants=$this->getCatalogueList($catalogue);
431
+		$variant=array_shift($variants);
432
+		$mo_file=$this->getSource($variant);
433
+		$po_file=$this->getPOFile($mo_file);
434 434
 
435
-		$dir = dirname($mo_file);
435
+		$dir=dirname($mo_file);
436 436
 		if(!is_dir($dir))
437 437
 		{
438 438
 			@mkdir($dir);
439
-			@chmod($dir,PRADO_CHMOD);
439
+			@chmod($dir, PRADO_CHMOD);
440 440
 		}
441 441
 		if(!is_dir($dir))
442 442
 			throw new TException("Unable to create directory $dir");
443 443
 
444
-		$po = TGettext::factory('PO',$po_file);
445
-		$result['meta']['PO-Revision-Date'] = @date('Y-m-d H:i:s');
446
-		$result['strings'] = array();
444
+		$po=TGettext::factory('PO', $po_file);
445
+		$result['meta']['PO-Revision-Date']=@date('Y-m-d H:i:s');
446
+		$result['strings']=array();
447 447
 
448 448
 		$po->fromArray($result);
449
-		$mo = $po->toMO();
449
+		$mo=$po->toMO();
450 450
 		if($po->save() && $mo->save($mo_file))
451 451
 			return array($variant, $mo_file, $po_file);
452 452
 		else
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -260,8 +260,7 @@  discard block
 block discarded – undo
260 260
 				if(!empty($this->cache))
261 261
 					$this->cache->clean($variant, $this->culture);
262 262
 				return true;
263
-			}
264
-			else
263
+			} else
265 264
 				return false;
266 265
 		}
267 266
 		return false;
@@ -304,8 +303,7 @@  discard block
 block discarded – undo
304 303
 					if(!empty($this->cache))
305 304
 						$this->cache->clean($variant, $this->culture);
306 305
 					return true;
307
-				}
308
-				else
306
+				} else
309 307
 					return false;
310 308
 			}
311 309
 		}
@@ -354,8 +352,7 @@  discard block
 block discarded – undo
354 352
 					if(!empty($this->cache))
355 353
 						$this->cache->clean($variant, $this->culture);
356 354
 					return true;
357
-				}
358
-				else
355
+				} else
359 356
 					return false;
360 357
 			}
361 358
 		}
Please login to merge, or discard this patch.