Completed
Push — prado-3.3 ( e90646...0b76d5 )
by Fabio
23:37 queued 03:01
created
buildscripts/classtree/build.php 4 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -67,6 +67,9 @@  discard block
 block discarded – undo
67 67
 		$this->displayTreeInternal(array_keys($this->_baseClasses),0);
68 68
 	}
69 69
 
70
+	/**
71
+	 * @param integer $level
72
+	 */
70 73
 	public function displayTreeInternal($classNames,$level)
71 74
 	{
72 75
 		foreach($classNames as $className)
@@ -153,6 +156,9 @@  discard block
 block discarded – undo
153 156
 		}
154 157
 	}
155 158
 
159
+	/**
160
+	 * @param string $path
161
+	 */
156 162
 	protected function isValidPath($path)
157 163
 	{
158 164
 		if(is_dir($path))
@@ -161,6 +167,9 @@  discard block
 block discarded – undo
161 167
 			return basename($path)!==basename($path,'.php') && !isset($this->_exclusions[basename($path)]);
162 168
 	}
163 169
 
170
+	/**
171
+	 * @param string $path
172
+	 */
164 173
 	public function getSourceFiles($path)
165 174
 	{
166 175
 		$files=array();
@@ -227,6 +236,9 @@  discard block
 block discarded – undo
227 236
 
228 237
 	}
229 238
 
239
+	/**
240
+	 * @param PradoVTMDocument $doc
241
+	 */
230 242
 	private	function processObjectType($objectType,$objectInfo,$prefix,$doc)
231 243
 	{
232 244
 		foreach($objectInfo['Properties'] as $name=>$property)
Please login to merge, or discard this patch.
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-$basePath=dirname(__FILE__);
4
-$frameworkPath=realpath($basePath.'/../../framework');
5
-require_once($frameworkPath.'/prado.php');
6
-require_once($basePath.'/DWExtension.php');
3
+$basePath = dirname(__FILE__);
4
+$frameworkPath = realpath($basePath . '/../../framework');
5
+require_once($frameworkPath . '/prado.php');
6
+require_once($basePath . '/DWExtension.php');
7 7
 
8 8
 //the manager class sets up some dependency paths
9 9
 Prado::using('System.Data.SqlMap.TSqlMapManager');
10 10
 
11
-$exclusions=array(
11
+$exclusions = array(
12 12
 	'pradolite.php',
13 13
 	'prado-cli.php',
14 14
 	'JSMin.php',
@@ -17,93 +17,93 @@  discard block
 block discarded – undo
17 17
 	'/Testing',
18 18
 	'/Web/UI/WebControls/assets',
19 19
 	);
20
-$a=new ClassTreeBuilder($frameworkPath,$exclusions);
20
+$a = new ClassTreeBuilder($frameworkPath, $exclusions);
21 21
 $a->buildTree();
22
-$a->saveToFile($basePath.'/classes.data');
22
+$a->saveToFile($basePath . '/classes.data');
23 23
 $a->saveAsDWExtension($basePath);
24 24
 
25 25
 class ClassTreeBuilder
26 26
 {
27
-	const REGEX_RULES='/^\s*(abstract\s+)?class\s+(\w+)(\s+extends\s+(\w+)\s*|\s*)/msS';
27
+	const REGEX_RULES = '/^\s*(abstract\s+)?class\s+(\w+)(\s+extends\s+(\w+)\s*|\s*)/msS';
28 28
 	private $_frameworkPath;
29 29
 	private $_exclusions;
30
-	private $_classes=array();
30
+	private $_classes = array();
31 31
 
32
-	public function __construct($frameworkPath,$exclusions)
32
+	public function __construct($frameworkPath, $exclusions)
33 33
 	{
34
-		$this->_frameworkPath=realpath($frameworkPath);
35
-		$this->_exclusions=array();
36
-		foreach($exclusions as $exclusion)
34
+		$this->_frameworkPath = realpath($frameworkPath);
35
+		$this->_exclusions = array();
36
+		foreach ($exclusions as $exclusion)
37 37
 		{
38
-			if($exclusion[0]==='/')
39
-				$this->_exclusions[realpath($frameworkPath.'/'.$exclusion)]=true;
38
+			if ($exclusion[0] === '/')
39
+				$this->_exclusions[realpath($frameworkPath . '/' . $exclusion)] = true;
40 40
 			else
41
-				$this->_exclusions[$exclusion]=true;
41
+				$this->_exclusions[$exclusion] = true;
42 42
 		}
43 43
 	}
44 44
 
45 45
 	public function buildTree()
46 46
 	{
47
-		$sourceFiles=$this->getSourceFiles($this->_frameworkPath);
48
-		foreach($sourceFiles as $sourceFile)
47
+		$sourceFiles = $this->getSourceFiles($this->_frameworkPath);
48
+		foreach ($sourceFiles as $sourceFile)
49 49
 			$this->parseFile($sourceFile);
50 50
 		ksort($this->_classes);
51
-		foreach(array_keys($this->_classes) as $className)
51
+		foreach (array_keys($this->_classes) as $className)
52 52
 		{
53
-			$parentClass=$this->_classes[$className]['ParentClass'];
54
-			if(isset($this->_classes[$parentClass]))
55
-				$this->_classes[$parentClass]['ChildClasses'][]=$className;
53
+			$parentClass = $this->_classes[$className]['ParentClass'];
54
+			if (isset($this->_classes[$parentClass]))
55
+				$this->_classes[$parentClass]['ChildClasses'][] = $className;
56 56
 		}
57
-		echo "\nClass tree built successfully. Total ".count($this->_classes)." classes found.\n";
57
+		echo "\nClass tree built successfully. Total " . count($this->_classes) . " classes found.\n";
58 58
 	}
59 59
 
60 60
 	public function saveToFile($fileName)
61 61
 	{
62
-		file_put_contents($fileName,serialize($this->_classes));
62
+		file_put_contents($fileName, serialize($this->_classes));
63 63
 	}
64 64
 
65 65
 	public function displayTree()
66 66
 	{
67
-		$this->displayTreeInternal(array_keys($this->_baseClasses),0);
67
+		$this->displayTreeInternal(array_keys($this->_baseClasses), 0);
68 68
 	}
69 69
 
70
-	public function displayTreeInternal($classNames,$level)
70
+	public function displayTreeInternal($classNames, $level)
71 71
 	{
72
-		foreach($classNames as $className)
72
+		foreach ($classNames as $className)
73 73
 		{
74
-			echo str_repeat(' ',$level*4);
75
-			echo $className.':'.$this->_classes[$className]->Package."\n";
76
-			$this->displayTreeInternal(array_keys($this->_classes[$className]->ChildClasses),$level+1);
74
+			echo str_repeat(' ', $level * 4);
75
+			echo $className . ':' . $this->_classes[$className]->Package . "\n";
76
+			$this->displayTreeInternal(array_keys($this->_classes[$className]->ChildClasses), $level + 1);
77 77
 		}
78 78
 	}
79 79
 
80 80
 	protected function parseFile($sourceFile)
81 81
 	{
82 82
 		include_once($sourceFile);
83
-		$classFile=strtr(substr($sourceFile,strlen($this->_frameworkPath)),'\\','/');
83
+		$classFile = strtr(substr($sourceFile, strlen($this->_frameworkPath)), '\\', '/');
84 84
 		echo "Parsing $classFile...\n";
85
-		$content=file_get_contents($sourceFile);
86
-		if(preg_match('/@package\s+([\w\.]+)\s*/msS',$content,$matches)>0)
87
-			$package=$matches[1];
85
+		$content = file_get_contents($sourceFile);
86
+		if (preg_match('/@package\s+([\w\.]+)\s*/msS', $content, $matches) > 0)
87
+			$package = $matches[1];
88 88
 		else
89
-			$package='';
90
-		$n=preg_match_all(self::REGEX_RULES,$content,$matches,PREG_SET_ORDER);
91
-		for($i=0;$i<$n;++$i)
89
+			$package = '';
90
+		$n = preg_match_all(self::REGEX_RULES, $content, $matches, PREG_SET_ORDER);
91
+		for ($i = 0; $i < $n; ++$i)
92 92
 		{
93
-			$className=$matches[$i][2];
94
-			if(isset($this->_classes[$className]))
95
-				throw new Exception("Class $className is defined in both $sourceFile and ".$this->_classes[$className]->ClassFile);
96
-			$c=new TComponentReflection($className);
97
-			$properties=$c->getProperties();
93
+			$className = $matches[$i][2];
94
+			if (isset($this->_classes[$className]))
95
+				throw new Exception("Class $className is defined in both $sourceFile and " . $this->_classes[$className]->ClassFile);
96
+			$c = new TComponentReflection($className);
97
+			$properties = $c->getProperties();
98 98
 			$this->parseMethodComments($properties);
99
-			$events=$c->getEvents();
99
+			$events = $c->getEvents();
100 100
 			$this->parseMethodComments($events);
101
-			$methods=$c->getMethods();
101
+			$methods = $c->getMethods();
102 102
 			$this->parseMethodComments($methods);
103
-			$this->_classes[$className]=array(
103
+			$this->_classes[$className] = array(
104 104
 				'ClassFile'=>$classFile,
105 105
 				'Package'=>$package,
106
-				'ParentClass'=>isset($matches[$i][4])?$matches[$i][4]:'',
106
+				'ParentClass'=>isset($matches[$i][4]) ? $matches[$i][4] : '',
107 107
 				'ChildClasses'=>array(),
108 108
 				'Properties'=>$properties,
109 109
 				'Events'=>$events,
@@ -113,69 +113,69 @@  discard block
 block discarded – undo
113 113
 
114 114
 	protected function parseMethodComments(&$methods)
115 115
 	{
116
-		foreach(array_keys($methods) as $key)
116
+		foreach (array_keys($methods) as $key)
117 117
 		{
118
-			$method=&$methods[$key];
119
-			$comments=$method['comments'];
120
-			$s='';
121
-			foreach(explode("\n",$comments) as $line)
118
+			$method = &$methods[$key];
119
+			$comments = $method['comments'];
120
+			$s = '';
121
+			foreach (explode("\n", $comments) as $line)
122 122
 			{
123
-				$line=trim($line);
124
-				$line=trim($line,'/*');
125
-				$s.=' '.$line;
123
+				$line = trim($line);
124
+				$line = trim($line, '/*');
125
+				$s .= ' ' . $line;
126 126
 			}
127
-			$s=trim($s);
128
-			$s=preg_replace('/\{@link.*?([\w\(\)]+)\}/i','$1',$s);
129
-			$pos1=strpos($s,'@');
130
-			$pos2=strpos($s,'.');
131
-			if($pos1===false)
127
+			$s = trim($s);
128
+			$s = preg_replace('/\{@link.*?([\w\(\)]+)\}/i', '$1', $s);
129
+			$pos1 = strpos($s, '@');
130
+			$pos2 = strpos($s, '.');
131
+			if ($pos1 === false)
132 132
 			{
133
-				if($pos2!==false)
134
-					$method['comments']=substr($s,0,$pos2);
133
+				if ($pos2 !== false)
134
+					$method['comments'] = substr($s, 0, $pos2);
135 135
 				else
136
-					$method['comments']=$s;
136
+					$method['comments'] = $s;
137 137
 			}
138
-			else if($pos1>0)
138
+			else if ($pos1 > 0)
139 139
 			{
140
-				if($pos2 && $pos2<$pos1)	// use the first line as comment
141
-					$method['comments']=substr($s,0,$pos2);
140
+				if ($pos2 && $pos2 < $pos1)	// use the first line as comment
141
+					$method['comments'] = substr($s, 0, $pos2);
142 142
 				else
143
-					$method['comments']=substr($s,0,$pos1);
143
+					$method['comments'] = substr($s, 0, $pos1);
144 144
 			}
145 145
 			else
146 146
 			{
147
-				$matches=array();
148
-				if(preg_match('/@return\s+[\w\|]+\s+([^\.]*)/',$s,$matches)>0)
149
-					$method['comments']=$matches[1];
147
+				$matches = array();
148
+				if (preg_match('/@return\s+[\w\|]+\s+([^\.]*)/', $s, $matches) > 0)
149
+					$method['comments'] = $matches[1];
150 150
 				else
151
-					$method['comments']='';
151
+					$method['comments'] = '';
152 152
 			}
153 153
 		}
154 154
 	}
155 155
 
156 156
 	protected function isValidPath($path)
157 157
 	{
158
-		if(is_dir($path))
158
+		if (is_dir($path))
159 159
 			return !isset($this->_exclusions[basename($path)]) && !isset($this->_exclusions[$path]);
160 160
 		else
161
-			return basename($path)!==basename($path,'.php') && !isset($this->_exclusions[basename($path)]);
161
+			return basename($path) !== basename($path, '.php') && !isset($this->_exclusions[basename($path)]);
162 162
 	}
163 163
 
164 164
 	public function getSourceFiles($path)
165 165
 	{
166
-		$files=array();
167
-		$folder=opendir($path);
168
-		while($file=readdir($folder))
166
+		$files = array();
167
+		$folder = opendir($path);
168
+		while ($file = readdir($folder))
169 169
 		{
170
-			if($file==='.' || $file==='..')
170
+			if ($file === '.' || $file === '..')
171 171
 				continue;
172
-			$fullPath=realpath($path.'/'.$file);
173
-			if($this->isValidPath($fullPath))
172
+			$fullPath = realpath($path . '/' . $file);
173
+			if ($this->isValidPath($fullPath))
174 174
 			{
175
-				if(is_file($fullPath))
176
-					$files[]=$fullPath;
175
+				if (is_file($fullPath))
176
+					$files[] = $fullPath;
177 177
 				else
178
-					$files=array_merge($files,$this->getSourceFiles($fullPath));
178
+					$files = array_merge($files, $this->getSourceFiles($fullPath));
179 179
 			}
180 180
 		}
181 181
 		closedir($folder);
@@ -184,71 +184,71 @@  discard block
 block discarded – undo
184 184
 
185 185
 	public function saveAsDWExtension($basePath)
186 186
 	{
187
-		$tagPath=$basePath.'/Configuration/TagLibraries/PRADO';
187
+		$tagPath = $basePath . '/Configuration/TagLibraries/PRADO';
188 188
 
189 189
 		// prepare the directory to save tag lib
190
-		@mkdir($basePath.'/Configuration');
191
-		@mkdir($basePath.'/Configuration/TagLibraries');
192
-		@mkdir($basePath.'/Configuration/TagLibraries/PRADO');
190
+		@mkdir($basePath . '/Configuration');
191
+		@mkdir($basePath . '/Configuration/TagLibraries');
192
+		@mkdir($basePath . '/Configuration/TagLibraries/PRADO');
193 193
 
194 194
 		$docMXI = new PradoMXIDocument(Prado::getVersion());
195 195
 		$tagChooser = new PradoTagChooser;
196 196
 
197 197
 		$controlClass = new ReflectionClass('TControl');
198 198
 
199
-		foreach($this->_classes as $className=>$classInfo)
199
+		foreach ($this->_classes as $className=>$classInfo)
200 200
 		{
201 201
 			$class = new ReflectionClass($className);
202
-			if($class->isInstantiable() && ($className==='TControl' || $class->isSubclassOf($controlClass)))
202
+			if ($class->isInstantiable() && ($className === 'TControl' || $class->isSubclassOf($controlClass)))
203 203
 			{
204 204
 				$docMXI->addTag($className);
205 205
 				$tagChooser->addElement($className);
206 206
 				$docVTM = new PradoVTMDocument($className);
207
-				foreach($classInfo['Properties'] as $name=>$property)
207
+				foreach ($classInfo['Properties'] as $name=>$property)
208 208
 				{
209
-					$type=$property['type'];
210
-					if(isset($this->_classes[$type]) && ($type==='TFont' || strrpos($type,'Style')===strlen($type)-5 && $type!=='TStyle'))
211
-						$this->processObjectType($type,$this->_classes[$type],$name,$docVTM);
212
-					if($property['readonly'] || $property['protected'])
209
+					$type = $property['type'];
210
+					if (isset($this->_classes[$type]) && ($type === 'TFont' || strrpos($type, 'Style') === strlen($type) - 5 && $type !== 'TStyle'))
211
+						$this->processObjectType($type, $this->_classes[$type], $name, $docVTM);
212
+					if ($property['readonly'] || $property['protected'])
213 213
 						continue;
214
-					if(($type=$this->checkType($className,$name,$property['type']))!=='')
215
-						$docVTM->addAttribute($name,$type);
214
+					if (($type = $this->checkType($className, $name, $property['type'])) !== '')
215
+						$docVTM->addAttribute($name, $type);
216 216
 				}
217
-				foreach($classInfo['Events'] as $name=>$event)
217
+				foreach ($classInfo['Events'] as $name=>$event)
218 218
 				{
219 219
 					$docVTM->addEvent($name);
220 220
 				}
221
-				file_put_contents($tagPath.'/'.$className.'.vtm',$docVTM->getXML());
221
+				file_put_contents($tagPath . '/' . $className . '.vtm', $docVTM->getXML());
222 222
 			}
223 223
 		}
224 224
 
225
-		file_put_contents($basePath.'/PRADO.mxi',$docMXI->getXML());
226
-		file_put_contents($tagPath.'/TagChooser.xml',$tagChooser->getXML());
225
+		file_put_contents($basePath . '/PRADO.mxi', $docMXI->getXML());
226
+		file_put_contents($tagPath . '/TagChooser.xml', $tagChooser->getXML());
227 227
 
228 228
 	}
229 229
 
230
-	private	function processObjectType($objectType,$objectInfo,$prefix,$doc)
230
+	private	function processObjectType($objectType, $objectInfo, $prefix, $doc)
231 231
 	{
232
-		foreach($objectInfo['Properties'] as $name=>$property)
232
+		foreach ($objectInfo['Properties'] as $name=>$property)
233 233
 		{
234
-			if($property['type']==='TFont')
235
-				$this->processObjectType('TFont',$this->_classes['TFont'],$prefix.'.'.$name,$doc);
236
-			if($property['readonly'] || $property['protected'])
234
+			if ($property['type'] === 'TFont')
235
+				$this->processObjectType('TFont', $this->_classes['TFont'], $prefix . '.' . $name, $doc);
236
+			if ($property['readonly'] || $property['protected'])
237 237
 				continue;
238
-			if(($type=$this->checkType($objectType,$name,$property['type']))!=='')
239
-				$doc->addAttribute($prefix.'.'.$name,$type);
238
+			if (($type = $this->checkType($objectType, $name, $property['type'])) !== '')
239
+				$doc->addAttribute($prefix . '.' . $name, $type);
240 240
 		}
241 241
 	}
242 242
 
243
-	private	function checkType($className,$propertyName,$type)
243
+	private	function checkType($className, $propertyName, $type)
244 244
 	{
245
-		if(strrpos($propertyName,'Color')===strlen($propertyName)-5)
245
+		if (strrpos($propertyName, 'Color') === strlen($propertyName) - 5)
246 246
 			return 'color';
247
-		if($propertyName==='Style')
247
+		if ($propertyName === 'Style')
248 248
 			return 'style';
249
-		if($type==='boolean')
250
-			return array('true','false');
251
-		if($type==='string' || $type==='integer' || $type==='ITemplate')
249
+		if ($type === 'boolean')
250
+			return array('true', 'false');
251
+		if ($type === 'string' || $type === 'integer' || $type === 'ITemplate')
252 252
 			return 'text';
253 253
 		return '';
254 254
 	}
Please login to merge, or discard this patch.
Braces   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -45,8 +45,9 @@  discard block
 block discarded – undo
45 45
 	public function buildTree()
46 46
 	{
47 47
 		$sourceFiles=$this->getSourceFiles($this->_frameworkPath);
48
-		foreach($sourceFiles as $sourceFile)
49
-			$this->parseFile($sourceFile);
48
+		foreach($sourceFiles as $sourceFile) {
49
+					$this->parseFile($sourceFile);
50
+		}
50 51
 		ksort($this->_classes);
51 52
 		foreach(array_keys($this->_classes) as $className)
52 53
 		{
@@ -134,15 +135,13 @@  discard block
 block discarded – undo
134 135
 					$method['comments']=substr($s,0,$pos2);
135 136
 				else
136 137
 					$method['comments']=$s;
137
-			}
138
-			else if($pos1>0)
138
+			} else if($pos1>0)
139 139
 			{
140 140
 				if($pos2 && $pos2<$pos1)	// use the first line as comment
141 141
 					$method['comments']=substr($s,0,$pos2);
142 142
 				else
143 143
 					$method['comments']=substr($s,0,$pos1);
144
-			}
145
-			else
144
+			} else
146 145
 			{
147 146
 				$matches=array();
148 147
 				if(preg_match('/@return\s+[\w\|]+\s+([^\.]*)/',$s,$matches)>0)
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	{
82 82
 		include_once($sourceFile);
83 83
 		$classFile=strtr(substr($sourceFile,strlen($this->_frameworkPath)),'\\','/');
84
-		echo "Parsing $classFile...\n";
84
+		echo "parsing $classFile...\n";
85 85
 		$content=file_get_contents($sourceFile);
86 86
 		if(preg_match('/@package\s+([\w\.]+)\s*/msS',$content,$matches)>0)
87 87
 			$package=$matches[1];
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		{
93 93
 			$className=$matches[$i][2];
94 94
 			if(isset($this->_classes[$className]))
95
-				throw new Exception("Class $className is defined in both $sourceFile and ".$this->_classes[$className]->ClassFile);
95
+				throw new Exception("class $className is defined in both $sourceFile and ".$this->_classes[$className]->ClassFile);
96 96
 			$c=new TComponentReflection($className);
97 97
 			$properties=$c->getProperties();
98 98
 			$this->parseMethodComments($properties);
Please login to merge, or discard this patch.
buildscripts/index/api_index.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -10,6 +10,9 @@
 block discarded – undo
10 10
 	private $_index;	
11 11
 	private $_api;
12 12
 	
13
+	/**
14
+	 * @param string $api
15
+	 */
13 16
 	public function __construct($index_file, $api)
14 17
 	{
15 18
 		$this->_api = $api;
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 		echo "Building search index...\n";
24 24
 		$files = $this->get_files($this->_api);
25 25
 		$count = 0;
26
-		foreach($files as $file)
26
+		foreach ($files as $file)
27 27
 		{
28 28
 			$content = $this->get_details($file, $this->_api);
29 29
 			
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 			
32 32
 			$title = $content['class'];
33 33
 			
34
-			echo "  Adding ".$title."\n";
34
+			echo "  Adding " . $title . "\n";
35 35
 			
36 36
 			//unsearchable text
37 37
 			$doc->addField(Zend_Search_Lucene_Field::UnIndexed('link', $content['link']));
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 			//$doc->addField(Zend_Search_Lucene_Field::UnIndexed('text', $content['content']));
40 40
 			
41 41
 			//searchable
42
-			$body = strtolower($this->sanitize($content['content'])).' '.strtolower($title);			
43
-			$doc->addField(Zend_Search_Lucene_Field::Keyword('page', strtolower(str_replace('.',' ',$title))));
44
-			$doc->addField(Zend_Search_Lucene_Field::Unstored('contents',$body));
42
+			$body = strtolower($this->sanitize($content['content'])) . ' ' . strtolower($title);			
43
+			$doc->addField(Zend_Search_Lucene_Field::Keyword('page', strtolower(str_replace('.', ' ', $title))));
44
+			$doc->addField(Zend_Search_Lucene_Field::Unstored('contents', $body));
45 45
 			$this->_index->addDocument($doc);
46 46
 			$count++;
47 47
 		}
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
 	function sanitize($input) 
53 53
 	{
54
-		return htmlentities(strip_tags( $input ));
54
+		return htmlentities(strip_tags($input));
55 55
 	}	
56 56
 
57 57
 	function get_files($path)
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 		$files = array();
62 62
 		while (false !== ($entry = $d->read()))
63 63
 		{
64
-			$filepath = $path.'/'.$entry;
65
-			if(is_file($filepath) && strpos($entry, 'class-')===0)
64
+			$filepath = $path . '/' . $entry;
65
+			if (is_file($filepath) && strpos($entry, 'class-') === 0)
66 66
 				$files[] = realpath($filepath);
67 67
 		}
68 68
 		$d->close();
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
 	function get_doc_content($file)
73 73
 	{
74 74
 		$content = file_get_contents($file);
75
-		$html = preg_replace('/<h1>/','~~~', $content);
75
+		$html = preg_replace('/<h1>/', '~~~', $content);
76 76
 		$html = preg_replace('/<![^~]+/m', '', $html);
77 77
 		$html = preg_replace('/<div class="credit">[\s\w\W\S]+/m', '', $html);
78
-		$html = preg_replace('/&nbsp;|~+|\s{2,}/',' ',$html);
79
-		$html = preg_replace('/\s{2,}/',' ',$html);
78
+		$html = preg_replace('/&nbsp;|~+|\s{2,}/', ' ', $html);
79
+		$html = preg_replace('/\s{2,}/', ' ', $html);
80 80
 		$text = strip_tags($html);
81
-		$text = str_replace(' , ',', ',$text);
81
+		$text = str_replace(' , ', ', ', $text);
82 82
 		return $text;
83 83
 	}
84 84
 	
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		$replace = array('', '', '');
90 90
 		$path = str_replace($find, $replace, $file);
91 91
 		$result['class'] = $path;
92
-		$result['link'] = self::API_URL.$file;
92
+		$result['link'] = self::API_URL . $file;
93 93
 		return $result;
94 94
 	}
95 95
 }
Please login to merge, or discard this patch.
buildscripts/index/quickstart_index.php 2 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -8,6 +8,10 @@  discard block
 block discarded – undo
8 8
 	private $_base;
9 9
 	private $_source;
10 10
 
11
+	/**
12
+	 * @param string $base
13
+	 * @param string $source
14
+	 */
11 15
 	public function __construct($index_file, $base, $source)
12 16
 	{
13 17
 		$this->_index = new Zend_Search_Lucene($index_file, true);
@@ -37,6 +41,10 @@  discard block
 block discarded – undo
37 41
 		echo "\n {$count} files indexed.\n";
38 42
 	}
39 43
 
44
+	/**
45
+	 * @param string $content
46
+	 * @param integer $mtime
47
+	 */
40 48
 	public function add($content, $section, $mtime)
41 49
 	{
42 50
 		foreach($this->split_headings($content) as $headers)
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
 		echo "Building search index...\n";
22 22
 		$pages = include($this->_source);
23 23
 		$count = 0;
24
-		foreach($pages as $chapter => $sections)
24
+		foreach ($pages as $chapter => $sections)
25 25
 		{
26
-			foreach($sections as $section)
26
+			foreach ($sections as $section)
27 27
 			{
28 28
 				echo "    Adding $section\n";
29
-				$page = $this->_base.'/'.$section;
29
+				$page = $this->_base . '/' . $section;
30 30
 				$file_content = file_get_contents($page);
31
-				$this->add($file_content,$section, filemtime($page));
31
+				$this->add($file_content, $section, filemtime($page));
32 32
 				$count++;
33 33
 			}
34 34
 		}
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 
40 40
 	public function add($content, $section, $mtime)
41 41
 	{
42
-		foreach($this->split_headings($content) as $headers)
42
+		foreach ($this->split_headings($content) as $headers)
43 43
 		{
44 44
 			$doc = new Zend_Search_Lucene_Document();
45
-			$link = "index.php?page=".preg_replace('/\/|\\\/', '.', $section);
46
-			$link = str_replace('.page', '', $link).'#'.$headers['section'];
45
+			$link = "index.php?page=" . preg_replace('/\/|\\\/', '.', $section);
46
+			$link = str_replace('.page', '', $link) . '#' . $headers['section'];
47 47
 
48 48
 			//unsearchable text
49 49
 			$doc->addField(Zend_Search_Lucene_Field::UnIndexed('link', $link));
@@ -53,15 +53,15 @@  discard block
 block discarded – undo
53 53
 
54 54
 			//searchable text
55 55
 			$doc->addField(Zend_Search_Lucene_Field::Keyword('page', strtolower($headers['title'])));
56
-			$body = strtolower($this->sanitize($headers['content'])).' '.strtolower($headers['title']);
57
-			$doc->addField(Zend_Search_Lucene_Field::Unstored('contents',$body));
56
+			$body = strtolower($this->sanitize($headers['content'])) . ' ' . strtolower($headers['title']);
57
+			$doc->addField(Zend_Search_Lucene_Field::Unstored('contents', $body));
58 58
 			$this->_index->addDocument($doc);
59 59
 		}
60 60
 	}
61 61
 
62 62
 	function sanitize($input)
63 63
 	{
64
-		return htmlentities(strip_tags( $input ));
64
+		return htmlentities(strip_tags($input));
65 65
 	}
66 66
 
67 67
 	public function index()
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
 		$html = preg_replace('/<h3([^>]*)>([^<]*)<\/h3>/', '<hh$1>$2</hh>', $html);
83 83
 
84 84
 
85
-		$sections = preg_split('/<hh[^>]*>([^<]+)<\/hh>/', $html,-1);
85
+		$sections = preg_split('/<hh[^>]*>([^<]+)<\/hh>/', $html, -1);
86 86
 		$headers = array();
87 87
 		preg_match_all('/<hh([^>]*)>([^<]+)<\/hh>/', $html, $headers);
88 88
 		$contents = array();
89
-		for($i = 1, $t = count($sections); $i < $t; $i++)
89
+		for ($i = 1, $t = count($sections); $i < $t; $i++)
90 90
 		{
91
-			$content['title'] = trim($this->sanitize($headers[2][$i-1]));
92
-			$content['section'] = str_replace('"', '',trim($headers[1][$i-1],'"'));
91
+			$content['title'] = trim($this->sanitize($headers[2][$i - 1]));
92
+			$content['section'] = str_replace('"', '', trim($headers[1][$i - 1], '"'));
93 93
 			$content['content'] = trim($this->sanitize($sections[$i]));
94 94
 			$contents[] = $content;
95 95
 		}
Please login to merge, or discard this patch.
buildscripts/texbuilder/Page2Tex.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -71,6 +71,9 @@
 block discarded – undo
71 71
 		}
72 72
 	}
73 73
 
74
+	/**
75
+	 * @param string $filename
76
+	 */
74 77
 	function include_figure($info, $filename)
75 78
 	{
76 79
 		$width = sprintf('%0.2f', $info[0]/(135/2.54));
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -167,10 +167,10 @@
 block discarded – undo
167 167
 
168 168
 		//DocLink
169 169
 		$html = preg_replace('/<com:DocLink\s+ClassPath="([^"]*)[.]([^."]*)"\s+Text="([^"]+)"\s*\/>/',
170
-	                        '\href{http://pradosoft.github.io/docs/manual/$1/$2.html}{$3}', $html);
170
+							'\href{http://pradosoft.github.io/docs/manual/$1/$2.html}{$3}', $html);
171 171
 
172 172
 		$html = preg_replace('/<com:DocLink\s+ClassPath="([^"]*)[.]([^.]*)"\s+\/>/',
173
-	                        '\href{http://pradosoft.github.io/docs/manual/$1/$2.html}{$1.$2 API Reference}', $html);
173
+							'\href{http://pradosoft.github.io/docs/manual/$1/$2.html}{$1.$2 API Reference}', $html);
174 174
 
175 175
 		//text modifiers
176 176
 		$html = preg_replace('/<(b|strong)[^>]*>([^<]*)<\/(b|strong)>/', '\textbf{$2}', $html);
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@  discard block
 block discarded – undo
4 4
 {
5 5
 	private $_current_page;
6 6
 	private static $header_count = 0;
7
-	private static $p_count=0;
8
-	private static $hil_count=0;
9
-	private $page_count=0;
7
+	private static $p_count = 0;
8
+	private static $hil_count = 0;
9
+	private $page_count = 0;
10 10
 	private $_base;
11 11
 	private $_dir;
12 12
 
13
-	private $_verb_find = array('\$','\%', '\{', '\}', "\t",'``','`');
14
-	private $_verb_replace = array('$', '%', '{','}', "     ",'"','\'');
13
+	private $_verb_find = array('\$', '\%', '\{', '\}', "\t", '``', '`');
14
+	private $_verb_replace = array('$', '%', '{', '}', "     ", '"', '\'');
15 15
 
16
-	function __construct($base, $dir, $current='')
16
+	function __construct($base, $dir, $current = '')
17 17
 	{
18 18
 		$this->_base = $base;
19 19
 		$this->_current_page = $current;
@@ -22,21 +22,21 @@  discard block
 block discarded – undo
22 22
 
23 23
 	function setCurrentPage($current)
24 24
 	{
25
-		self::$header_count = self::$header_count+1000;
25
+		self::$header_count = self::$header_count + 1000;
26 26
 		$this->_current_page = $current;
27 27
 	}
28 28
 
29 29
 	function escape_verbatim($matches)
30 30
 	{
31
-		return "\begin{small}\begin{verbatim}".
32
-				str_replace($this->_verb_find, $this->_verb_replace, $matches[1]).
33
-				'\end{verbatim}\end{small}'."\n";
31
+		return "\begin{small}\begin{verbatim}" .
32
+				str_replace($this->_verb_find, $this->_verb_replace, $matches[1]) .
33
+				'\end{verbatim}\end{small}' . "\n";
34 34
 	}
35 35
 
36 36
 	function escape_verb($matches)
37 37
 	{
38 38
 		$text = str_replace($this->_verb_find, $this->_verb_replace, $matches[1]);
39
-		return '\begin{small}\verb<'.$text.'< \end{small}';
39
+		return '\begin{small}\verb<' . $text . '< \end{small}';
40 40
 	}
41 41
 
42 42
 	function include_image($matches)
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
 
45 45
 		$current_path = $this->_current_page;
46 46
 
47
-		$image = dirname($current_path).'/'.trim($matches[1]);
47
+		$image = dirname($current_path) . '/' . trim($matches[1]);
48 48
 
49 49
 		$file = realpath($image);
50 50
 		$info = getimagesize($file);
51
-		switch($info[2])
51
+		switch ($info[2])
52 52
 		{
53 53
 			case 1:
54 54
 				$im = imagecreatefromgif($file);
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
 		}
59 59
 		$base = $this->_base;
60 60
 
61
-		if(isset($im))
61
+		if (isset($im))
62 62
 		{
63 63
 			$prefix = strtolower(str_replace(realpath($base), '', $file));
64
-			$filename = preg_replace('/\\\|\//', '_', substr($prefix,1));
65
-			$filename = substr($filename, 0, strrpos($filename,'.')).'.png';
66
-			$newfile = $this->_dir.'/'.$filename;
67
-			imagepng($im,$newfile);
64
+			$filename = preg_replace('/\\\|\//', '_', substr($prefix, 1));
65
+			$filename = substr($filename, 0, strrpos($filename, '.')) . '.png';
66
+			$newfile = $this->_dir . '/' . $filename;
67
+			imagepng($im, $newfile);
68 68
 			imagedestroy($im);
69 69
 
70 70
 			return $this->include_figure($info, $filename);
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 
74 74
 	function include_figure($info, $filename)
75 75
 	{
76
-		$width = sprintf('%0.2f', $info[0]/(135/2.54));
76
+		$width = sprintf('%0.2f', $info[0] / (135 / 2.54));
77 77
 		return '
78 78
 	\begin{figure}[!ht]
79 79
 		\centering
80
-			\includegraphics[width='.$width.'cm]{'.$filename.'}
81
-		\label{fig:'.$filename.'}
80
+			\includegraphics[width='.$width . 'cm]{' . $filename . '}
81
+		\label{fig:'.$filename . '}
82 82
 	\end{figure}
83 83
 	';
84 84
 	}
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
 	function anchor($matches)
87 87
 	{
88 88
 		$page = $this->get_current_path();
89
-		return '\hypertarget{'.$page.'/'.strtolower($matches[1]).'}{}';
89
+		return '\hypertarget{' . $page . '/' . strtolower($matches[1]) . '}{}';
90 90
 	}
91 91
 
92 92
 	function texttt($matches)
93 93
 	{
94
-		$text ='\texttt{'.str_replace(array('#','_','&amp;'),array('\#','\_','\&'), $matches[1]).'}';
94
+		$text = '\texttt{' . str_replace(array('#', '_', '&amp;'), array('\#', '\_', '\&'), $matches[1]) . '}';
95 95
 		//$text = preg_replace('/([^\\\\])&([^;]+)/', '$1\&$2', $text);
96 96
 		return $text;
97 97
 	}
@@ -100,39 +100,39 @@  discard block
 block discarded – undo
100 100
 	{
101 101
 		$current_path = $this->_current_page;
102 102
 		$base = $this->_base;
103
-		$page = strtolower(substr(str_replace($base, '', $current_path),1));
103
+		$page = strtolower(substr(str_replace($base, '', $current_path), 1));
104 104
 		return $page;
105 105
 	}
106 106
 
107 107
 	function make_link($matches)
108 108
 	{
109
-		if(is_int(strpos($matches[1], '#')))
109
+		if (is_int(strpos($matches[1], '#')))
110 110
 		{
111
-			if(strpos($matches[1],'?') ===false)
111
+			if (strpos($matches[1], '?') === false)
112 112
 			{
113
-				if(strpos($matches[1],'http://')===false)
113
+				if (strpos($matches[1], 'http://') === false)
114 114
 				{
115
-					$target = $this->get_current_path().'/'.substr($matches[1],1);
116
-					return '\hyperlink{'.$target.'}{'.$matches[2].'}';
115
+					$target = $this->get_current_path() . '/' . substr($matches[1], 1);
116
+					return '\hyperlink{' . $target . '}{' . $matches[2] . '}';
117 117
 				}
118 118
 			}
119 119
 			else
120 120
 			{
121 121
 				$page = strtolower(str_replace('?page=', '', $matches[1]));
122
-				$page = str_replace('.','/',$page);
123
-				$page = str_replace('#','.page/',$page);
124
-				return '\hyperlink{'.$page.'}{'.$matches[2].'}';
122
+				$page = str_replace('.', '/', $page);
123
+				$page = str_replace('#', '.page/', $page);
124
+				return '\hyperlink{' . $page . '}{' . $matches[2] . '}';
125 125
 			}
126 126
 		}
127
-		else if(is_int(strpos($matches[1],'?')))
127
+		else if (is_int(strpos($matches[1], '?')))
128 128
 		{
129
-			$page = str_replace('?page=','',$matches[1]);
130
-			return '\hyperlink{'.$page.'}{'.$matches[2].'}';
129
+			$page = str_replace('?page=', '', $matches[1]);
130
+			return '\hyperlink{' . $page . '}{' . $matches[2] . '}';
131 131
 		}
132
-		return '\href{'.str_replace('#','\\#',$matches[1]).'}{'.$matches[2].'}';
132
+		return '\href{' . str_replace('#', '\\#', $matches[1]) . '}{' . $matches[2] . '}';
133 133
 	}
134 134
 
135
-	function parse_html($page,$html)
135
+	function parse_html($page, $html)
136 136
 	{
137 137
 		$html = preg_replace('/<\/?com:TContent[^>]*>/', '', $html);
138 138
 		$html = preg_replace('/<\/?p [^>]*>/', '', $html);
@@ -152,14 +152,14 @@  discard block
 block discarded – undo
152 152
 		//codes
153 153
 		$html = str_replace('$', '\$', $html);
154 154
 
155
-		$html = preg_replace_callback('/<com:TTextHighlighter[^>]*>((.|\n)*?)<\/com:TTextHighlighter\s*>/', array($this,'escape_verbatim'), $html);
155
+		$html = preg_replace_callback('/<com:TTextHighlighter[^>]*>((.|\n)*?)<\/com:TTextHighlighter\s*>/', array($this, 'escape_verbatim'), $html);
156 156
 //		$html = preg_replace('/<\/com:TTextHighlighter>/', '`2`', $html);
157 157
 //		$html = preg_replace_callback('/(`1`)([^`]*)(`2`)/m', array($this,'escape_verbatim'), $html);
158
-		$html = preg_replace_callback('/(<div class="source">)((.|\n)*?)(<\/div>)/', array($this,'escape_verbatim'), $html);
159
-		$html = preg_replace_callback('/(<pre>)([^<]*)(<\/pre>)/', array($this,'escape_verbatim'), $html);
158
+		$html = preg_replace_callback('/(<div class="source">)((.|\n)*?)(<\/div>)/', array($this, 'escape_verbatim'), $html);
159
+		$html = preg_replace_callback('/(<pre>)([^<]*)(<\/pre>)/', array($this, 'escape_verbatim'), $html);
160 160
 
161 161
 		//<code>
162
-		$html = preg_replace_callback('/<code>([^<]*)<\/code>/', array($this,'escape_verb'), $html);
162
+		$html = preg_replace_callback('/<code>([^<]*)<\/code>/', array($this, 'escape_verb'), $html);
163 163
 
164 164
 		//runbar
165 165
 		$html = preg_replace('/<com:RunBar\s+PagePath="([^"]*)"\s+\/>/',
@@ -175,13 +175,13 @@  discard block
 block discarded – undo
175 175
 		//text modifiers
176 176
 		$html = preg_replace('/<(b|strong)[^>]*>([^<]*)<\/(b|strong)>/', '\textbf{$2}', $html);
177 177
 		$html = preg_replace('/<i [^>]*>([^<]*)+?<\/i>/', '\emph{$1}', $html);
178
-		$html = preg_replace_callback('/<tt>([^<]*)<\/tt>/', array($this,'texttt'), $html);
178
+		$html = preg_replace_callback('/<tt>([^<]*)<\/tt>/', array($this, 'texttt'), $html);
179 179
 
180 180
 		//links
181 181
 		$html = preg_replace_callback('/<a[^>]+href="([^"]*)"[^>]*>([^<]*)<\/a>/',
182
-								array($this,'make_link'), $html);
182
+								array($this, 'make_link'), $html);
183 183
 		//anchor
184
-		$html = preg_replace_callback('/<a[^>]+name="([^"]*)"[^>]*><\/a>/', array($this,'anchor'), $html);
184
+		$html = preg_replace_callback('/<a[^>]+name="([^"]*)"[^>]*><\/a>/', array($this, 'anchor'), $html);
185 185
 
186 186
 		//description <dl>
187 187
 		$html = preg_replace('/<dt>([^<]*)<\/dt>/', '\item[$1]', $html);
@@ -230,20 +230,20 @@  discard block
 block discarded – undo
230 230
 	function tabular($matches)
231 231
 	{
232 232
 		$options = array();
233
-		foreach(explode(',', $matches[1]) as $string)
233
+		foreach (explode(',', $matches[1]) as $string)
234 234
 		{
235 235
 			$sub = explode('=', trim($string));
236 236
 			$options[trim($sub[0])] = trim($sub[1]);
237 237
 		}
238 238
 
239
-		$widths = explode(' ',preg_replace('/\(|\)/', '', $options['width']));
239
+		$widths = explode(' ', preg_replace('/\(|\)/', '', $options['width']));
240 240
 		$this->_tabular_widths = $widths;
241 241
 
242 242
 		$this->_tabular_total = count($widths);
243 243
 		$this->_tabular_col = 0;
244 244
 
245
-		$begin = '\begin{table}[!hpt]\centering '."\n".' \begin{tabular}{'.$options['align'].'}\hline';
246
-		$end = '\end{tabular} '."\n".'\end{table}'."\n";
245
+		$begin = '\begin{table}[!hpt]\centering ' . "\n" . ' \begin{tabular}{' . $options['align'] . '}\hline';
246
+		$end = '\end{tabular} ' . "\n" . '\end{table}' . "\n";
247 247
 		$table = preg_replace('/<\/tr>/', '\\\\\\\\ \hline', $matches[2]);
248 248
 		$table = preg_replace('/<tr>/', '', $table);
249 249
 		$table = preg_replace('/<th>([^<]+)<\/th>/', '\textbf{$1} &', $table);
@@ -251,95 +251,95 @@  discard block
 block discarded – undo
251 251
 		$table = preg_replace('/<br \/>/', ' \\\\\\\\', $table);
252 252
 
253 253
 		$table = preg_replace('/&\s*\\\\\\\\/', '\\\\\\\\', $table);
254
-		return $begin.$table.$end;
254
+		return $begin . $table . $end;
255 255
 	}
256 256
 
257 257
 	function table_column($matches)
258 258
 	{
259 259
 		$width = $this->_tabular_widths[$this->_tabular_col];
260
-		if($this->_tabular_col >= $this->_tabular_total-1)
260
+		if ($this->_tabular_col >= $this->_tabular_total - 1)
261 261
 			$this->_tabular_col = 0;
262 262
 		else
263 263
 			$this->_tabular_col++;
264
-		return '\begin{minipage}{'.$width.'\textwidth}\vspace{3mm}'.
265
-			$matches[1].'\vspace{3mm}\end{minipage} & ';
264
+		return '\begin{minipage}{' . $width . '\textwidth}\vspace{3mm}' .
265
+			$matches[1] . '\vspace{3mm}\end{minipage} & ';
266 266
 	}
267 267
 
268 268
 	function mbox($matches)
269 269
 	{
270
-		return "\n\begin{mybox}\n".$matches[1]."\n".'\end{mybox}'."\n";
270
+		return "\n\begin{mybox}\n" . $matches[1] . "\n" . '\end{mybox}' . "\n";
271 271
 	}
272 272
 
273 273
 	function get_chapter_label($chapter)
274 274
 	{
275
-		return '\hypertarget{'.str_replace(' ', '', $chapter).'}{}';
275
+		return '\hypertarget{' . str_replace(' ', '', $chapter) . '}{}';
276 276
 	}
277 277
 
278 278
 	function get_section_label($section)
279 279
 	{
280 280
 		$section = str_replace('.page', '', $section);
281
-		return '\hypertarget{'.str_replace('/', '.', $section).'}{}';
281
+		return '\hypertarget{' . str_replace('/', '.', $section) . '}{}';
282 282
 	}
283 283
 
284 284
 
285 285
 	function set_header_id($content, $j)
286 286
 	{
287
-		$this->page_count=$j;
288
-		$content = preg_replace_callback('/<h1>/', array($this,"h1"), $content);
289
-		$content = preg_replace_callback('/<h2>/', array($this,"h2"), $content);
290
-		$content = preg_replace_callback('/<h3>/', array($this,"h3"), $content);
287
+		$this->page_count = $j;
288
+		$content = preg_replace_callback('/<h1>/', array($this, "h1"), $content);
289
+		$content = preg_replace_callback('/<h2>/', array($this, "h2"), $content);
290
+		$content = preg_replace_callback('/<h3>/', array($this, "h3"), $content);
291 291
 		$content = $this->set_block_content_id($content);
292 292
 		return $content;
293 293
 	}
294 294
 
295 295
 	function h1($matches)
296 296
 	{
297
-		$page = $this->page_count*1000;
298
-		return "<h1 id=\"".($page + (++self::$header_count))."\">";
297
+		$page = $this->page_count * 1000;
298
+		return "<h1 id=\"" . ($page + (++self::$header_count)) . "\">";
299 299
 	}
300 300
 
301 301
 	function h2($matches)
302 302
 	{
303
-		$page = $this->page_count*1000;
304
-		return "<h2 id=\"".($page + (++self::$header_count))."\">";
303
+		$page = $this->page_count * 1000;
304
+		return "<h2 id=\"" . ($page + (++self::$header_count)) . "\">";
305 305
 	}
306 306
 
307 307
 	function h3($matches)
308 308
 	{
309
-		$page = $this->page_count*1000;
310
-		return "<h3 id=\"".($page + (++self::$header_count))."\">";
309
+		$page = $this->page_count * 1000;
310
+		return "<h3 id=\"" . ($page + (++self::$header_count)) . "\">";
311 311
 	}
312 312
 
313 313
 	function set_block_content_id($content)
314 314
 	{
315
-		$content = preg_replace_callback('/<p>/',  array($this, 'add_p'), $content);
315
+		$content = preg_replace_callback('/<p>/', array($this, 'add_p'), $content);
316 316
 		$content = preg_replace_callback('/<com:TTextHighlighter([^>]+)>/', array($this, 'hil'), $content);
317 317
 		return $content;
318 318
 	}
319 319
 
320 320
 	function hil($matches)
321 321
 	{
322
-		$id = ($this->page_count*10000) + (++self::$hil_count);
323
-		if(preg_match('/id="code-\d+"/i', $matches[1]))
322
+		$id = ($this->page_count * 10000) + (++self::$hil_count);
323
+		if (preg_match('/id="code-\d+"/i', $matches[1]))
324 324
 		{
325 325
 			$code = preg_replace('/id="code-(\d+)"/', 'id="code_$1"', $matches[0]);
326 326
 			//var_dump($code);
327 327
 			return $code;
328 328
 		}
329
-		else if(preg_match('/id="[^"]+"/i', $matches[1]))
329
+		else if (preg_match('/id="[^"]+"/i', $matches[1]))
330 330
 		{
331 331
 			return $matches[0];
332 332
 		}
333 333
 		else
334 334
 		{
335
-			$changes = str_replace('"source"', '"source block-content" id="code-'.$id.'"', $matches[0]);
335
+			$changes = str_replace('"source"', '"source block-content" id="code-' . $id . '"', $matches[0]);
336 336
 			return $changes;
337 337
 		}
338 338
 	}
339 339
 
340 340
 	function add_p($matches)
341 341
 	{
342
-		 $page = $this->page_count*10000;
343
-		 return "<p id=\"".($page + (++self::$p_count))."\" class=\"block-content\">";
342
+		 $page = $this->page_count * 10000;
343
+		 return "<p id=\"" . ($page + (++self::$p_count)) . "\" class=\"block-content\">";
344 344
 	}
345 345
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -115,16 +115,14 @@  discard block
 block discarded – undo
115 115
 					$target = $this->get_current_path().'/'.substr($matches[1],1);
116 116
 					return '\hyperlink{'.$target.'}{'.$matches[2].'}';
117 117
 				}
118
-			}
119
-			else
118
+			} else
120 119
 			{
121 120
 				$page = strtolower(str_replace('?page=', '', $matches[1]));
122 121
 				$page = str_replace('.','/',$page);
123 122
 				$page = str_replace('#','.page/',$page);
124 123
 				return '\hyperlink{'.$page.'}{'.$matches[2].'}';
125 124
 			}
126
-		}
127
-		else if(is_int(strpos($matches[1],'?')))
125
+		} else if(is_int(strpos($matches[1],'?')))
128 126
 		{
129 127
 			$page = str_replace('?page=','',$matches[1]);
130 128
 			return '\hyperlink{'.$page.'}{'.$matches[2].'}';
@@ -325,12 +323,10 @@  discard block
 block discarded – undo
325 323
 			$code = preg_replace('/id="code-(\d+)"/', 'id="code_$1"', $matches[0]);
326 324
 			//var_dump($code);
327 325
 			return $code;
328
-		}
329
-		else if(preg_match('/id="[^"]+"/i', $matches[1]))
326
+		} else if(preg_match('/id="[^"]+"/i', $matches[1]))
330 327
 		{
331 328
 			return $matches[0];
332
-		}
333
-		else
329
+		} else
334 330
 		{
335 331
 			$changes = str_replace('"source"', '"source block-content" id="code-'.$id.'"', $matches[0]);
336 332
 			return $changes;
Please login to merge, or discard this patch.
demos/blog-tutorial/samples/day4/blog/protected/pages/posts/ListPost.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -48,6 +48,7 @@
 block discarded – undo
48 48
 
49 49
 	/**
50 50
 	 * Fetches posts from database with offset and limit.
51
+	 * @param double $offset
51 52
 	 */
52 53
 	protected function getPosts($offset, $limit)
53 54
 	{
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
 	public function onInit($param)
11 11
 	{
12 12
 		parent::onInit($param);
13
-		if(!$this->IsPostBack)  // if the page is requested the first time
13
+		if (!$this->IsPostBack)  // if the page is requested the first time
14 14
 		{
15 15
 			// get the total number of posts available
16
-			$this->Repeater->VirtualItemCount=PostRecord::finder()->count();
16
+			$this->Repeater->VirtualItemCount = PostRecord::finder()->count();
17 17
 			// populates post data into the repeater
18 18
 			$this->populateData();
19 19
 		}
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
 	 * This method is invoked when the user clicks on a page button
25 25
 	 * and thus changes the page of posts to display.
26 26
 	 */
27
-	public function pageChanged($sender,$param)
27
+	public function pageChanged($sender, $param)
28 28
 	{
29 29
 		// change the current page index to the new one
30
-		$this->Repeater->CurrentPageIndex=$param->NewPageIndex;
30
+		$this->Repeater->CurrentPageIndex = $param->NewPageIndex;
31 31
 		// re-populate data into the repeater
32 32
 		$this->populateData();
33 33
 	}
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	protected function populateData()
40 40
 	{
41
-		$offset=$this->Repeater->CurrentPageIndex*$this->Repeater->PageSize;
42
-		$limit=$this->Repeater->PageSize;
43
-		if($offset+$limit>$this->Repeater->VirtualItemCount)
44
-			$limit=$this->Repeater->VirtualItemCount-$offset;
45
-		$this->Repeater->DataSource=$this->getPosts($offset,$limit);
41
+		$offset = $this->Repeater->CurrentPageIndex * $this->Repeater->PageSize;
42
+		$limit = $this->Repeater->PageSize;
43
+		if ($offset + $limit > $this->Repeater->VirtualItemCount)
44
+			$limit = $this->Repeater->VirtualItemCount - $offset;
45
+		$this->Repeater->DataSource = $this->getPosts($offset, $limit);
46 46
 		$this->Repeater->dataBind();
47 47
 	}
48 48
 
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 	protected function getPosts($offset, $limit)
53 53
 	{
54 54
 		// Construts a query criteria
55
-		$criteria=new TActiveRecordCriteria;
56
-		$criteria->OrdersBy['create_time']='desc';
57
-		$criteria->Limit=$limit;
58
-		$criteria->Offset=$offset;
55
+		$criteria = new TActiveRecordCriteria;
56
+		$criteria->OrdersBy['create_time'] = 'desc';
57
+		$criteria->Limit = $limit;
58
+		$criteria->Offset = $offset;
59 59
 		// query for the posts with the above criteria and with author information
60 60
 		return PostRecord::finder()->withAuthor()->findAll($criteria);
61 61
 	}
Please login to merge, or discard this patch.
demos/blog/protected/Common/BlogDataModule.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -28,6 +28,9 @@
 block discarded – undo
28 28
 		$this->connectDatabase();
29 29
 	}
30 30
 
31
+	/**
32
+	 * @return string
33
+	 */
31 34
 	public function getDbFile()
32 35
 	{
33 36
 		if($this->_dbFile===null)
Please login to merge, or discard this patch.
Spacing   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class BlogDataModule extends TModule
20 20
 {
21
-	const DB_FILE_EXT='.db';
22
-	const DEFAULT_DB_FILE='Application.Data.Blog';
23
-	private $_db=null;
24
-	private $_dbFile=null;
21
+	const DB_FILE_EXT = '.db';
22
+	const DEFAULT_DB_FILE = 'Application.Data.Blog';
23
+	private $_db = null;
24
+	private $_dbFile = null;
25 25
 
26 26
 	public function init($config)
27 27
 	{
@@ -30,32 +30,32 @@  discard block
 block discarded – undo
30 30
 
31 31
 	public function getDbFile()
32 32
 	{
33
-		if($this->_dbFile===null)
34
-			$this->_dbFile=Prado::getPathOfNamespace(self::DEFAULT_DB_FILE,self::DB_FILE_EXT);
33
+		if ($this->_dbFile === null)
34
+			$this->_dbFile = Prado::getPathOfNamespace(self::DEFAULT_DB_FILE, self::DB_FILE_EXT);
35 35
 		return $this->_dbFile;
36 36
 	}
37 37
 
38 38
 	public function setDbFile($value)
39 39
 	{
40
-		if(($this->_dbFile=Prado::getPathOfNamespace($value,self::DB_FILE_EXT))===null)
41
-			throw new BlogException(500,'blogdatamodule_dbfile_invalid',$value);
40
+		if (($this->_dbFile = Prado::getPathOfNamespace($value, self::DB_FILE_EXT)) === null)
41
+			throw new BlogException(500, 'blogdatamodule_dbfile_invalid', $value);
42 42
 	}
43 43
 
44 44
 	protected function createDatabase()
45 45
 	{
46
-		$schemaFile=dirname(__FILE__).'/schema.sql';
47
-		$statements=explode(';',file_get_contents($schemaFile));
48
-		foreach($statements as $statement)
46
+		$schemaFile = dirname(__FILE__) . '/schema.sql';
47
+		$statements = explode(';', file_get_contents($schemaFile));
48
+		foreach ($statements as $statement)
49 49
 		{
50
-			if(trim($statement)!=='')
50
+			if (trim($statement) !== '')
51 51
 			{
52 52
 				try {
53
-					$command=$this->_db->createCommand($statement);
53
+					$command = $this->_db->createCommand($statement);
54 54
 					$command->execute();
55 55
 				}
56
-				catch(TDbException $e)
56
+				catch (TDbException $e)
57 57
 				{
58
-					throw new BlogException(500,'blogdatamodule_createdatabase_failed',$e->getErrorMessage(),$statement);
58
+					throw new BlogException(500, 'blogdatamodule_createdatabase_failed', $e->getErrorMessage(), $statement);
59 59
 				}
60 60
 			}
61 61
 		}
@@ -63,81 +63,81 @@  discard block
 block discarded – undo
63 63
 
64 64
 	protected function connectDatabase()
65 65
 	{
66
-		$dbFile=$this->getDbFile();
67
-		$newDb=!is_file($dbFile);
66
+		$dbFile = $this->getDbFile();
67
+		$newDb = !is_file($dbFile);
68 68
 
69 69
 		try {
70
-			$this->_db=new TDbConnection("sqlite:".$dbFile);
71
-			$this->_db->Active=true;
70
+			$this->_db = new TDbConnection("sqlite:" . $dbFile);
71
+			$this->_db->Active = true;
72 72
 		}
73
-		catch(TDbException $e)
73
+		catch (TDbException $e)
74 74
 		{
75
-			throw new BlogException(500,'blogdatamodule_dbconnect_failed',$e->getErrorMessage());
75
+			throw new BlogException(500, 'blogdatamodule_dbconnect_failed', $e->getErrorMessage());
76 76
 		}
77 77
 
78
-		if($newDb)
78
+		if ($newDb)
79 79
 			$this->createDatabase();
80 80
 	}
81 81
 
82
-	protected function generateModifier($filter,$orderBy,$limit)
82
+	protected function generateModifier($filter, $orderBy, $limit)
83 83
 	{
84
-		$modifier='';
85
-		if($filter!=='')
86
-			$modifier=' WHERE '.$filter;
87
-		if($orderBy!=='')
88
-			$modifier.=' ORDER BY '.$orderBy;
89
-		if($limit!=='')
90
-			$modifier.=' LIMIT '.$limit;
84
+		$modifier = '';
85
+		if ($filter !== '')
86
+			$modifier = ' WHERE ' . $filter;
87
+		if ($orderBy !== '')
88
+			$modifier .= ' ORDER BY ' . $orderBy;
89
+		if ($limit !== '')
90
+			$modifier .= ' LIMIT ' . $limit;
91 91
 		return $modifier;
92 92
 	}
93 93
 
94 94
 	public function query($sql)
95 95
 	{
96 96
 		try {
97
-			$command=$this->_db->createCommand($sql);
97
+			$command = $this->_db->createCommand($sql);
98 98
 			return $command->query();
99 99
 		}
100
-		catch(TDbException $e)
100
+		catch (TDbException $e)
101 101
 		{
102
-			throw new BlogException(500,'blogdatamodule_query_failed',$e->getErrorMessage(),$sql);
102
+			throw new BlogException(500, 'blogdatamodule_query_failed', $e->getErrorMessage(), $sql);
103 103
 		}
104 104
 	}
105 105
 
106 106
 	protected function populateUserRecord($row)
107 107
 	{
108
-		$userRecord=new UserRecord;
109
-		$userRecord->ID=(integer)$row['id'];
110
-		$userRecord->Name=$row['name'];
111
-		$userRecord->FullName=$row['full_name'];
112
-		$userRecord->Role=(integer)$row['role'];
113
-		$userRecord->Password=$row['passwd'];
114
-		$userRecord->VerifyCode=$row['vcode'];
115
-		$userRecord->Email=$row['email'];
116
-		$userRecord->CreateTime=(integer)$row['reg_time'];
117
-		$userRecord->Status=(integer)$row['status'];
118
-		$userRecord->Website=$row['website'];
108
+		$userRecord = new UserRecord;
109
+		$userRecord->ID = (integer) $row['id'];
110
+		$userRecord->Name = $row['name'];
111
+		$userRecord->FullName = $row['full_name'];
112
+		$userRecord->Role = (integer) $row['role'];
113
+		$userRecord->Password = $row['passwd'];
114
+		$userRecord->VerifyCode = $row['vcode'];
115
+		$userRecord->Email = $row['email'];
116
+		$userRecord->CreateTime = (integer) $row['reg_time'];
117
+		$userRecord->Status = (integer) $row['status'];
118
+		$userRecord->Website = $row['website'];
119 119
 		return $userRecord;
120 120
 	}
121 121
 
122
-	public function queryUsers($filter='',$orderBy='',$limit='')
122
+	public function queryUsers($filter = '', $orderBy = '', $limit = '')
123 123
 	{
124
-		if($filter!=='')
125
-			$filter='WHERE '.$filter;
126
-		$sql="SELECT * FROM tblUsers $filter $orderBy $limit";
127
-		$rows=$this->query($sql);
128
-		$users=array();
129
-		foreach($rows as $row)
130
-			$users[]=$this->populateUserRecord($row);
124
+		if ($filter !== '')
125
+			$filter = 'WHERE ' . $filter;
126
+		$sql = "SELECT * FROM tblUsers $filter $orderBy $limit";
127
+		$rows = $this->query($sql);
128
+		$users = array();
129
+		foreach ($rows as $row)
130
+			$users[] = $this->populateUserRecord($row);
131 131
 		return $users;
132 132
 	}
133 133
 
134 134
 	public function queryUserCount($filter)
135 135
 	{
136
-		if($filter!=='')
137
-			$filter='WHERE '.$filter;
138
-		$sql="SELECT COUNT(id) AS user_count FROM tblUsers $filter";
139
-		$result=$this->query($sql);
140
-		if(($row=$result->read())!==false)
136
+		if ($filter !== '')
137
+			$filter = 'WHERE ' . $filter;
138
+		$sql = "SELECT COUNT(id) AS user_count FROM tblUsers $filter";
139
+		$result = $this->query($sql);
140
+		if (($row = $result->read()) !== false)
141 141
 			return $row['user_count'];
142 142
 		else
143 143
 			return 0;
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
 
146 146
 	public function queryUserByID($id)
147 147
 	{
148
-		$sql="SELECT * FROM tblUsers WHERE id=$id";
149
-		$result=$this->query($sql);
150
-		if(($row=$result->read())!==false)
148
+		$sql = "SELECT * FROM tblUsers WHERE id=$id";
149
+		$result = $this->query($sql);
150
+		if (($row = $result->read()) !== false)
151 151
 			return $this->populateUserRecord($row);
152 152
 		else
153 153
 			return null;
@@ -155,12 +155,12 @@  discard block
 block discarded – undo
155 155
 
156 156
 	public function queryUserByName($name)
157 157
 	{
158
-		$command=$this->_db->createCommand("SELECT * FROM tblUsers WHERE name=?");
158
+		$command = $this->_db->createCommand("SELECT * FROM tblUsers WHERE name=?");
159 159
 		$command->bindValue(1, $name);
160 160
 
161
-		$result=$command->query();
161
+		$result = $command->query();
162 162
 
163
-		if(($row=$result->read())!==false)
163
+		if (($row = $result->read()) !== false)
164 164
 			return $this->populateUserRecord($row);
165 165
 		else
166 166
 			return null;
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 
169 169
 	public function insertUser($user)
170 170
 	{
171
-		$command=$this->_db->createCommand("INSERT INTO tblUsers ".
172
-				"(name,full_name,role,passwd,email,reg_time,status,website) ".
171
+		$command = $this->_db->createCommand("INSERT INTO tblUsers " .
172
+				"(name,full_name,role,passwd,email,reg_time,status,website) " .
173 173
 				"VALUES (?,?,?,?,?,?,?,?)");
174 174
 		$command->bindValue(1, $user->Name);
175 175
 		$command->bindValue(2, $user->FullName);
@@ -181,12 +181,12 @@  discard block
 block discarded – undo
181 181
 		$command->bindValue(8, $user->Website);
182 182
 		$command->execute();
183 183
 
184
-		$user->ID=$this->_db->getLastInsertID();
184
+		$user->ID = $this->_db->getLastInsertID();
185 185
 	}
186 186
 
187 187
 	public function updateUser($user)
188 188
 	{
189
-		$command=$this->_db->createCommand("UPDATE tblUsers SET
189
+		$command = $this->_db->createCommand("UPDATE tblUsers SET
190 190
 				name=?,
191 191
 				full_name=?,
192 192
 				role=?,
@@ -210,38 +210,38 @@  discard block
 block discarded – undo
210 210
 
211 211
 	public function deleteUser($id)
212 212
 	{
213
-		$command=$this->_db->createCommand("DELETE FROM tblUsers WHERE id=?");
213
+		$command = $this->_db->createCommand("DELETE FROM tblUsers WHERE id=?");
214 214
 		$command->bindValue(1, $id);
215 215
 		$command->execute();
216 216
 	}
217 217
 
218 218
 	protected function populatePostRecord($row)
219 219
 	{
220
-		$postRecord=new PostRecord;
221
-		$postRecord->ID=(integer)$row['id'];
222
-		$postRecord->AuthorID=(integer)$row['author_id'];
223
-		if($row['author_full_name']!=='')
224
-			$postRecord->AuthorName=$row['author_full_name'];
220
+		$postRecord = new PostRecord;
221
+		$postRecord->ID = (integer) $row['id'];
222
+		$postRecord->AuthorID = (integer) $row['author_id'];
223
+		if ($row['author_full_name'] !== '')
224
+			$postRecord->AuthorName = $row['author_full_name'];
225 225
 		else
226
-			$postRecord->AuthorName=$row['author_name'];
227
-		$postRecord->CreateTime=(integer)$row['create_time'];
228
-		$postRecord->ModifyTime=(integer)$row['modify_time'];
229
-		$postRecord->Title=$row['title'];
230
-		$postRecord->Content=$row['content'];
231
-		$postRecord->Status=(integer)$row['status'];
232
-		$postRecord->CommentCount=(integer)$row['comment_count'];
226
+			$postRecord->AuthorName = $row['author_name'];
227
+		$postRecord->CreateTime = (integer) $row['create_time'];
228
+		$postRecord->ModifyTime = (integer) $row['modify_time'];
229
+		$postRecord->Title = $row['title'];
230
+		$postRecord->Content = $row['content'];
231
+		$postRecord->Status = (integer) $row['status'];
232
+		$postRecord->CommentCount = (integer) $row['comment_count'];
233 233
 		return $postRecord;
234 234
 	}
235 235
 
236
-	public function queryPosts($postFilter,$categoryFilter,$orderBy,$limit)
236
+	public function queryPosts($postFilter, $categoryFilter, $orderBy, $limit)
237 237
 	{
238 238
 		//FIXME this is insecure by design since it misses proper escaping
239
-		$filter='';
240
-		if($postFilter!=='')
241
-			$filter.=" AND $postFilter";
242
-		if($categoryFilter!=='')
243
-			$filter.=" AND a.id IN (SELECT post_id AS id FROM tblPost2Category WHERE $categoryFilter)";
244
-		$sql="SELECT a.id AS id,
239
+		$filter = '';
240
+		if ($postFilter !== '')
241
+			$filter .= " AND $postFilter";
242
+		if ($categoryFilter !== '')
243
+			$filter .= " AND a.id IN (SELECT post_id AS id FROM tblPost2Category WHERE $categoryFilter)";
244
+		$sql = "SELECT a.id AS id,
245 245
 					a.author_id AS author_id,
246 246
 					b.name AS author_name,
247 247
 					b.full_name AS author_full_name,
@@ -253,16 +253,16 @@  discard block
 block discarded – undo
253 253
 					a.comment_count AS comment_count
254 254
 				FROM tblPosts a, tblUsers b
255 255
 				WHERE a.author_id=b.id $filter $orderBy $limit";
256
-		$rows=$this->query($sql);
257
-		$posts=array();
258
-		foreach($rows as $row)
259
-			$posts[]=$this->populatePostRecord($row);
256
+		$rows = $this->query($sql);
257
+		$posts = array();
258
+		foreach ($rows as $row)
259
+			$posts[] = $this->populatePostRecord($row);
260 260
 		return $posts;
261 261
 	}
262 262
 
263
-	public function queryPostsSearch($keywords,$orderBy,$limit)
263
+	public function queryPostsSearch($keywords, $orderBy, $limit)
264 264
 	{
265
-		$sql="SELECT a.id AS id,
265
+		$sql = "SELECT a.id AS id,
266 266
 					a.author_id AS author_id,
267 267
 					b.name AS author_name,
268 268
 					b.full_name AS author_full_name,
@@ -275,42 +275,42 @@  discard block
 block discarded – undo
275 275
 				FROM tblPosts a, tblUsers b
276 276
 				WHERE a.author_id=b.id AND a.status=0";
277 277
 
278
-		foreach($keywords as $keyword)
279
-			$sql.=" AND (content LIKE ? OR title LIKE ?)";
278
+		foreach ($keywords as $keyword)
279
+			$sql .= " AND (content LIKE ? OR title LIKE ?)";
280 280
 
281
-		$sql.=" $orderBy $limit";
281
+		$sql .= " $orderBy $limit";
282 282
 
283
-		$command=$this->_db->createCommand($sql);
283
+		$command = $this->_db->createCommand($sql);
284 284
 
285
-		$i=1;
286
-		foreach($keywords as $keyword)
285
+		$i = 1;
286
+		foreach ($keywords as $keyword)
287 287
 		{
288
-			$command->bindValue($i, "%".$keyword."%");
288
+			$command->bindValue($i, "%" . $keyword . "%");
289 289
 			$i++;
290 290
 		}
291 291
 
292
-		$rows=$command->query();
292
+		$rows = $command->query();
293 293
 
294
-		$posts=array();
295
-		foreach($rows as $row)
296
-			$posts[]=$this->populatePostRecord($row);
294
+		$posts = array();
295
+		foreach ($rows as $row)
296
+			$posts[] = $this->populatePostRecord($row);
297 297
 		return $posts;
298 298
 
299 299
 	}
300 300
 
301
-	public function queryPostCount($postFilter,$categoryFilter)
301
+	public function queryPostCount($postFilter, $categoryFilter)
302 302
 	{
303 303
 		//FIXME this is insecure by design since it misses proper escaping
304
-		$filter='';
305
-		if($postFilter!=='')
306
-			$filter.=" AND $postFilter";
307
-		if($categoryFilter!=='')
308
-			$filter.=" AND a.id IN (SELECT post_id AS id FROM tblPost2Category WHERE $categoryFilter)";
309
-		$sql="SELECT COUNT(a.id) AS post_count
304
+		$filter = '';
305
+		if ($postFilter !== '')
306
+			$filter .= " AND $postFilter";
307
+		if ($categoryFilter !== '')
308
+			$filter .= " AND a.id IN (SELECT post_id AS id FROM tblPost2Category WHERE $categoryFilter)";
309
+		$sql = "SELECT COUNT(a.id) AS post_count
310 310
 				FROM tblPosts a, tblUsers b
311 311
 				WHERE a.author_id=b.id $filter";
312
-		$result=$this->query($sql);
313
-		if(($row=$result->read())!==false)
312
+		$result = $this->query($sql);
313
+		if (($row = $result->read()) !== false)
314 314
 			return $row['post_count'];
315 315
 		else
316 316
 			return 0;
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 
319 319
 	public function queryPostByID($id)
320 320
 	{
321
-		$sql="SELECT a.id AS id,
321
+		$sql = "SELECT a.id AS id,
322 322
 		             a.author_id AS author_id,
323 323
 		             b.name AS author_name,
324 324
 		             b.full_name AS author_full_name,
@@ -331,20 +331,20 @@  discard block
 block discarded – undo
331 331
 		      FROM tblPosts a, tblUsers b
332 332
 		      WHERE a.id=? AND a.author_id=b.id";
333 333
 
334
-		$command=$this->_db->createCommand($sql);
334
+		$command = $this->_db->createCommand($sql);
335 335
 		$command->bindValue(1, $id);
336 336
 
337
-		$result=$command->query();
337
+		$result = $command->query();
338 338
 
339
-		if(($row=$result->read())!==false)
339
+		if (($row = $result->read()) !== false)
340 340
 			return $this->populatePostRecord($row);
341 341
 		else
342 342
 			return null;
343 343
 	}
344 344
 
345
-	public function insertPost($post,$catIDs)
345
+	public function insertPost($post, $catIDs)
346 346
 	{
347
-		$command=$this->_db->createCommand("INSERT INTO tblPosts
347
+		$command = $this->_db->createCommand("INSERT INTO tblPosts
348 348
 				(author_id,create_time,modify_time,title,content,status)
349 349
 				VALUES (?,?,?,?,?,?)");
350 350
 		$command->bindValue(1, $post->AuthorID);
@@ -355,28 +355,28 @@  discard block
 block discarded – undo
355 355
 		$command->bindValue(6, $post->Status);
356 356
 
357 357
 		$command->execute();
358
-		$post->ID=$this->_db->getLastInsertID();
359
-		foreach($catIDs as $catID)
360
-			$this->insertPostCategory($post->ID,$catID);
358
+		$post->ID = $this->_db->getLastInsertID();
359
+		foreach ($catIDs as $catID)
360
+			$this->insertPostCategory($post->ID, $catID);
361 361
 	}
362 362
 
363
-	public function updatePost($post,$newCatIDs=null)
363
+	public function updatePost($post, $newCatIDs = null)
364 364
 	{
365
-		if($newCatIDs!==null)
365
+		if ($newCatIDs !== null)
366 366
 		{
367
-			$cats=$this->queryCategoriesByPostID($post->ID);
368
-			$catIDs=array();
369
-			foreach($cats as $cat)
370
-				$catIDs[]=$cat->ID;
371
-			$deleteIDs=array_diff($catIDs,$newCatIDs);
372
-			foreach($deleteIDs as $id)
373
-				$this->deletePostCategory($post->ID,$id);
374
-			$insertIDs=array_diff($newCatIDs,$catIDs);
375
-			foreach($insertIDs as $id)
376
-				$this->insertPostCategory($post->ID,$id);
367
+			$cats = $this->queryCategoriesByPostID($post->ID);
368
+			$catIDs = array();
369
+			foreach ($cats as $cat)
370
+				$catIDs[] = $cat->ID;
371
+			$deleteIDs = array_diff($catIDs, $newCatIDs);
372
+			foreach ($deleteIDs as $id)
373
+				$this->deletePostCategory($post->ID, $id);
374
+			$insertIDs = array_diff($newCatIDs, $catIDs);
375
+			foreach ($insertIDs as $id)
376
+				$this->insertPostCategory($post->ID, $id);
377 377
 		}
378 378
 
379
-		$command=$this->_db->createCommand("UPDATE tblPosts SET
379
+		$command = $this->_db->createCommand("UPDATE tblPosts SET
380 380
 				modify_time=?,
381 381
 				title=?,
382 382
 				content=?,
@@ -393,67 +393,67 @@  discard block
 block discarded – undo
393 393
 
394 394
 	public function deletePost($id)
395 395
 	{
396
-		$cats=$this->queryCategoriesByPostID($id);
397
-		foreach($cats as $cat)
398
-			$this->deletePostCategory($id,$cat->ID);
396
+		$cats = $this->queryCategoriesByPostID($id);
397
+		foreach ($cats as $cat)
398
+			$this->deletePostCategory($id, $cat->ID);
399 399
 
400
-		$command=$this->_db->createCommand("DELETE FROM tblComments WHERE post_id=?");
400
+		$command = $this->_db->createCommand("DELETE FROM tblComments WHERE post_id=?");
401 401
 		$command->bindValue(1, $id);
402 402
 		$command->execute();
403 403
 
404
-		$command=$this->_db->createCommand("DELETE FROM tblPosts WHERE id=?");
404
+		$command = $this->_db->createCommand("DELETE FROM tblPosts WHERE id=?");
405 405
 		$command->bindValue(1, $id);
406 406
 		$command->execute();
407 407
 	}
408 408
 
409 409
 	protected function populateCommentRecord($row)
410 410
 	{
411
-		$commentRecord=new CommentRecord;
412
-		$commentRecord->ID=(integer)$row['id'];
413
-		$commentRecord->PostID=(integer)$row['post_id'];
414
-		$commentRecord->AuthorName=$row['author_name'];
415
-		$commentRecord->AuthorEmail=$row['author_email'];
416
-		$commentRecord->AuthorWebsite=$row['author_website'];
417
-		$commentRecord->AuthorIP=$row['author_ip'];
418
-		$commentRecord->CreateTime=(integer)$row['create_time'];
419
-		$commentRecord->Content=$row['content'];
420
-		$commentRecord->Status=(integer)$row['status'];
411
+		$commentRecord = new CommentRecord;
412
+		$commentRecord->ID = (integer) $row['id'];
413
+		$commentRecord->PostID = (integer) $row['post_id'];
414
+		$commentRecord->AuthorName = $row['author_name'];
415
+		$commentRecord->AuthorEmail = $row['author_email'];
416
+		$commentRecord->AuthorWebsite = $row['author_website'];
417
+		$commentRecord->AuthorIP = $row['author_ip'];
418
+		$commentRecord->CreateTime = (integer) $row['create_time'];
419
+		$commentRecord->Content = $row['content'];
420
+		$commentRecord->Status = (integer) $row['status'];
421 421
 		return $commentRecord;
422 422
 	}
423 423
 
424
-	public function queryComments($filter,$orderBy,$limit)
424
+	public function queryComments($filter, $orderBy, $limit)
425 425
 	{
426 426
 		//FIXME this is insecure by design since it misses proper escaping
427
-		if($filter!=='')
428
-			$filter='WHERE '.$filter;
429
-		$sql="SELECT * FROM tblComments $filter $orderBy $limit";
430
-		$rows=$this->query($sql);
431
-		$comments=array();
432
-		foreach($rows as $row)
433
-			$comments[]=$this->populateCommentRecord($row);
427
+		if ($filter !== '')
428
+			$filter = 'WHERE ' . $filter;
429
+		$sql = "SELECT * FROM tblComments $filter $orderBy $limit";
430
+		$rows = $this->query($sql);
431
+		$comments = array();
432
+		foreach ($rows as $row)
433
+			$comments[] = $this->populateCommentRecord($row);
434 434
 		return $comments;
435 435
 	}
436 436
 
437 437
 	public function queryCommentsByPostID($id)
438 438
 	{
439
-		$sql="SELECT * FROM tblComments WHERE post_id=? ORDER BY create_time DESC";
440
-		$command=$this->_db->createCommand($sql);
439
+		$sql = "SELECT * FROM tblComments WHERE post_id=? ORDER BY create_time DESC";
440
+		$command = $this->_db->createCommand($sql);
441 441
 		$command->bindValue(1, $id);
442 442
 
443
-		$rows=$command->query();
443
+		$rows = $command->query();
444 444
 
445
-		$comments=array();
446
-		foreach($rows as $row)
447
-			$comments[]=$this->populateCommentRecord($row);
445
+		$comments = array();
446
+		foreach ($rows as $row)
447
+			$comments[] = $this->populateCommentRecord($row);
448 448
 		return $comments;
449 449
 	}
450 450
 
451 451
 	public function insertComment($comment)
452 452
 	{
453
-		$sql="INSERT INTO tblComments
453
+		$sql = "INSERT INTO tblComments
454 454
 				(post_id,author_name,author_email,author_website,author_ip,create_time,status,content)
455 455
 				VALUES (?,?,?,?,?,?,?,?)";
456
-		$command=$this->_db->createCommand($sql);
456
+		$command = $this->_db->createCommand($sql);
457 457
 		$command->bindValue(1, $comment->PostID);
458 458
 		$command->bindValue(2, $comment->AuthorName);
459 459
 		$command->bindValue(3, $comment->AuthorEmail);
@@ -464,14 +464,14 @@  discard block
 block discarded – undo
464 464
 		$command->bindValue(8, $comment->Content);
465 465
 
466 466
 		$command->execute();
467
-		$comment->ID=$this->_db->getLastInsertID();
467
+		$comment->ID = $this->_db->getLastInsertID();
468 468
 		$this->query("UPDATE tblPosts SET comment_count=comment_count+1 WHERE id={$comment->PostID}");
469 469
 	}
470 470
 
471 471
 	public function updateComment($comment)
472 472
 	{
473
-		$sql="UPDATE tblComments SET status=? WHERE id=?";
474
-		$command=$this->_db->createCommand($sql);
473
+		$sql = "UPDATE tblComments SET status=? WHERE id=?";
474
+		$command = $this->_db->createCommand($sql);
475 475
 		$command->bindValue(1, $comment->Status);
476 476
 		$command->bindValue(2, $comment->ID);
477 477
 
@@ -480,18 +480,18 @@  discard block
 block discarded – undo
480 480
 
481 481
 	public function deleteComment($id)
482 482
 	{
483
-		$sql="SELECT post_id FROM tblComments WHERE id=?";
484
-		$command=$this->_db->createCommand($sql);
483
+		$sql = "SELECT post_id FROM tblComments WHERE id=?";
484
+		$command = $this->_db->createCommand($sql);
485 485
 		$command->bindValue(1, $id);
486
-		$result=$command->query();
486
+		$result = $command->query();
487 487
 
488
-		if(($row=$result->read())!==false)
488
+		if (($row = $result->read()) !== false)
489 489
 		{
490
-			$command=$this->_db->createCommand("DELETE FROM tblComments WHERE id=?");
490
+			$command = $this->_db->createCommand("DELETE FROM tblComments WHERE id=?");
491 491
 			$command->bindValue(1, $id);
492 492
 			$command->execute();
493 493
 
494
-			$command=$this->_db->createCommand("UPDATE tblPosts SET comment_count=comment_count-1 WHERE id=?");
494
+			$command = $this->_db->createCommand("UPDATE tblPosts SET comment_count=comment_count-1 WHERE id=?");
495 495
 			$command->bindValue(1, $row['post_id']);
496 496
 			$command->execute();
497 497
 		}
@@ -499,52 +499,52 @@  discard block
 block discarded – undo
499 499
 
500 500
 	protected function populateCategoryRecord($row)
501 501
 	{
502
-		$catRecord=new CategoryRecord;
503
-		$catRecord->ID=(integer)$row['id'];
504
-		$catRecord->Name=$row['name'];
505
-		$catRecord->Description=$row['description'];
506
-		$catRecord->PostCount=$row['post_count'];
502
+		$catRecord = new CategoryRecord;
503
+		$catRecord->ID = (integer) $row['id'];
504
+		$catRecord->Name = $row['name'];
505
+		$catRecord->Description = $row['description'];
506
+		$catRecord->PostCount = $row['post_count'];
507 507
 		return $catRecord;
508 508
 	}
509 509
 
510 510
 	public function queryCategories()
511 511
 	{
512
-		$sql="SELECT * FROM tblCategories ORDER BY name ASC";
513
-		$rows=$this->query($sql);
514
-		$cats=array();
515
-		foreach($rows as $row)
516
-			$cats[]=$this->populateCategoryRecord($row);
512
+		$sql = "SELECT * FROM tblCategories ORDER BY name ASC";
513
+		$rows = $this->query($sql);
514
+		$cats = array();
515
+		foreach ($rows as $row)
516
+			$cats[] = $this->populateCategoryRecord($row);
517 517
 		return $cats;
518 518
 	}
519 519
 
520 520
 	public function queryCategoriesByPostID($postID)
521 521
 	{
522
-		$sql="SELECT a.id AS id,
522
+		$sql = "SELECT a.id AS id,
523 523
 				a.name AS name,
524 524
 				a.description AS description,
525 525
 				a.post_count AS post_count
526 526
 				FROM tblCategories a, tblPost2Category b
527 527
 				WHERE a.id=b.category_id AND b.post_id=? ORDER BY a.name";
528 528
 
529
-		$command=$this->_db->createCommand($sql);
529
+		$command = $this->_db->createCommand($sql);
530 530
 		$command->bindValue(1, $postID);
531
-		$rows=$command->query();
531
+		$rows = $command->query();
532 532
 
533
-		$cats=array();
534
-		foreach($rows as $row)
535
-			$cats[]=$this->populateCategoryRecord($row);
533
+		$cats = array();
534
+		foreach ($rows as $row)
535
+			$cats[] = $this->populateCategoryRecord($row);
536 536
 		return $cats;
537 537
 	}
538 538
 
539 539
 	public function queryCategoryByID($id)
540 540
 	{
541
-		$sql="SELECT * FROM tblCategories WHERE id=?";
541
+		$sql = "SELECT * FROM tblCategories WHERE id=?";
542 542
 
543
-		$command=$this->_db->createCommand($sql);
543
+		$command = $this->_db->createCommand($sql);
544 544
 		$command->bindValue(1, $id);
545
-		$result=$command->query();
545
+		$result = $command->query();
546 546
 
547
-		if(($row=$result->read())!==false)
547
+		if (($row = $result->read()) !== false)
548 548
 			return $this->populateCategoryRecord($row);
549 549
 		else
550 550
 			return null;
@@ -552,13 +552,13 @@  discard block
 block discarded – undo
552 552
 
553 553
 	public function queryCategoryByName($name)
554 554
 	{
555
-		$sql="SELECT * FROM tblCategories WHERE name=?";
555
+		$sql = "SELECT * FROM tblCategories WHERE name=?";
556 556
 
557
-		$command=$this->_db->createCommand($sql);
557
+		$command = $this->_db->createCommand($sql);
558 558
 		$command->bindValue(1, $name);
559
-		$result=$command->query();
559
+		$result = $command->query();
560 560
 
561
-		if(($row=$result->read())!==false)
561
+		if (($row = $result->read()) !== false)
562 562
 			return $this->populateCategoryRecord($row);
563 563
 		else
564 564
 			return null;
@@ -566,23 +566,23 @@  discard block
 block discarded – undo
566 566
 
567 567
 	public function insertCategory($category)
568 568
 	{
569
-		$sql="INSERT INTO tblCategories
569
+		$sql = "INSERT INTO tblCategories
570 570
 				(name,description)
571 571
 				VALUES (?,?)";
572 572
 
573
-		$command=$this->_db->createCommand($sql);
573
+		$command = $this->_db->createCommand($sql);
574 574
 		$command->bindValue(1, $category->Name);
575 575
 		$command->bindValue(2, $category->Description);
576 576
 		$command->execute();
577 577
 
578
-		$category->ID=$this->_db->getLastInsertID();
578
+		$category->ID = $this->_db->getLastInsertID();
579 579
 	}
580 580
 
581 581
 	public function updateCategory($category)
582 582
 	{
583
-		$sql="UPDATE tblCategories SET name=?, description=?, post_count=? WHERE id=?";
583
+		$sql = "UPDATE tblCategories SET name=?, description=?, post_count=? WHERE id=?";
584 584
 
585
-		$command=$this->_db->createCommand($sql);
585
+		$command = $this->_db->createCommand($sql);
586 586
 		$command->bindValue(1, $category->Name);
587 587
 		$command->bindValue(2, $category->Description);
588 588
 		$command->bindValue(3, $category->PostCount);
@@ -593,44 +593,44 @@  discard block
 block discarded – undo
593 593
 
594 594
 	public function deleteCategory($id)
595 595
 	{
596
-		$sql="DELETE FROM tblPost2Category WHERE category_id=?";
597
-		$command=$this->_db->createCommand($sql);
596
+		$sql = "DELETE FROM tblPost2Category WHERE category_id=?";
597
+		$command = $this->_db->createCommand($sql);
598 598
 		$command->bindValue(1, $id);
599 599
 		$command->execute();
600 600
 
601
-		$sql="DELETE FROM tblCategories WHERE id=?";
602
-		$command=$this->_db->createCommand($sql);
601
+		$sql = "DELETE FROM tblCategories WHERE id=?";
602
+		$command = $this->_db->createCommand($sql);
603 603
 		$command->bindValue(1, $id);
604 604
 		$command->execute();
605 605
 	}
606 606
 
607
-	public function insertPostCategory($postID,$categoryID)
607
+	public function insertPostCategory($postID, $categoryID)
608 608
 	{
609
-		$sql="INSERT INTO tblPost2Category (post_id, category_id) VALUES (?, ?)";
610
-		$command=$this->_db->createCommand($sql);
609
+		$sql = "INSERT INTO tblPost2Category (post_id, category_id) VALUES (?, ?)";
610
+		$command = $this->_db->createCommand($sql);
611 611
 		$command->bindValue(1, $postID);
612 612
 		$command->bindValue(2, $categoryID);
613 613
 		$command->execute();
614 614
 
615
-		$sql="UPDATE tblCategories SET post_count=post_count+1 WHERE id=?";
616
-		$command=$this->_db->createCommand($sql);
615
+		$sql = "UPDATE tblCategories SET post_count=post_count+1 WHERE id=?";
616
+		$command = $this->_db->createCommand($sql);
617 617
 		$command->bindValue(1, $categoryID);
618 618
 		$command->execute();
619 619
 
620 620
 	}
621 621
 
622
-	public function deletePostCategory($postID,$categoryID)
622
+	public function deletePostCategory($postID, $categoryID)
623 623
 	{
624
-		$sql="DELETE FROM tblPost2Category WHERE post_id=? AND category_id=?";
625
-		$command=$this->_db->createCommand($sql);
624
+		$sql = "DELETE FROM tblPost2Category WHERE post_id=? AND category_id=?";
625
+		$command = $this->_db->createCommand($sql);
626 626
 		$command->bindValue(1, $postID);
627 627
 		$command->bindValue(2, $categoryID);
628
-		$result=$command->query();
628
+		$result = $command->query();
629 629
 
630
-		if($result->getRowCount()>0)
630
+		if ($result->getRowCount() > 0)
631 631
 		{
632
-			$sql="UPDATE tblCategories SET post_count=post_count-1 WHERE id=?";
633
-			$command=$this->_db->createCommand($sql);
632
+			$sql = "UPDATE tblCategories SET post_count=post_count-1 WHERE id=?";
633
+			$command = $this->_db->createCommand($sql);
634 634
 			$command->bindValue(1, $categoryID);
635 635
 			$command->execute();
636 636
 		}
@@ -638,9 +638,9 @@  discard block
 block discarded – undo
638 638
 
639 639
 	public function queryEarliestPostTime()
640 640
 	{
641
-		$sql="SELECT MIN(create_time) AS create_time FROM tblPosts";
642
-		$result=$this->query($sql);
643
-		if(($row=$result->read())!==false)
641
+		$sql = "SELECT MIN(create_time) AS create_time FROM tblPosts";
642
+		$result = $this->query($sql);
643
+		if (($row = $result->read()) !== false)
644 644
 			return $row['create_time'];
645 645
 		else
646 646
 			return time();
@@ -649,11 +649,11 @@  discard block
 block discarded – undo
649 649
 
650 650
 class UserRecord
651 651
 {
652
-	const ROLE_USER=0;
653
-	const ROLE_ADMIN=1;
654
-	const STATUS_NORMAL=0;
655
-	const STATUS_DISABLED=1;
656
-	const STATUS_PENDING=2;
652
+	const ROLE_USER = 0;
653
+	const ROLE_ADMIN = 1;
654
+	const STATUS_NORMAL = 0;
655
+	const STATUS_DISABLED = 1;
656
+	const STATUS_PENDING = 2;
657 657
 	public $ID;
658 658
 	public $Name;
659 659
 	public $FullName;
@@ -668,10 +668,10 @@  discard block
 block discarded – undo
668 668
 
669 669
 class PostRecord
670 670
 {
671
-	const STATUS_PUBLISHED=0;
672
-	const STATUS_DRAFT=1;
673
-	const STATUS_PENDING=2;
674
-	const STATUS_STICKY=3;
671
+	const STATUS_PUBLISHED = 0;
672
+	const STATUS_DRAFT = 1;
673
+	const STATUS_PENDING = 2;
674
+	const STATUS_STICKY = 3;
675 675
 	public $ID;
676 676
 	public $AuthorID;
677 677
 	public $AuthorName;
Please login to merge, or discard this patch.
Braces   +42 added lines, -32 removed lines patch added patch discarded remove patch
@@ -52,8 +52,7 @@  discard block
 block discarded – undo
52 52
 				try {
53 53
 					$command=$this->_db->createCommand($statement);
54 54
 					$command->execute();
55
-				}
56
-				catch(TDbException $e)
55
+				} catch(TDbException $e)
57 56
 				{
58 57
 					throw new BlogException(500,'blogdatamodule_createdatabase_failed',$e->getErrorMessage(),$statement);
59 58
 				}
@@ -69,8 +68,7 @@  discard block
 block discarded – undo
69 68
 		try {
70 69
 			$this->_db=new TDbConnection("sqlite:".$dbFile);
71 70
 			$this->_db->Active=true;
72
-		}
73
-		catch(TDbException $e)
71
+		} catch(TDbException $e)
74 72
 		{
75 73
 			throw new BlogException(500,'blogdatamodule_dbconnect_failed',$e->getErrorMessage());
76 74
 		}
@@ -96,8 +94,7 @@  discard block
 block discarded – undo
96 94
 		try {
97 95
 			$command=$this->_db->createCommand($sql);
98 96
 			return $command->query();
99
-		}
100
-		catch(TDbException $e)
97
+		} catch(TDbException $e)
101 98
 		{
102 99
 			throw new BlogException(500,'blogdatamodule_query_failed',$e->getErrorMessage(),$sql);
103 100
 		}
@@ -126,8 +123,9 @@  discard block
 block discarded – undo
126 123
 		$sql="SELECT * FROM tblUsers $filter $orderBy $limit";
127 124
 		$rows=$this->query($sql);
128 125
 		$users=array();
129
-		foreach($rows as $row)
130
-			$users[]=$this->populateUserRecord($row);
126
+		foreach($rows as $row) {
127
+					$users[]=$this->populateUserRecord($row);
128
+		}
131 129
 		return $users;
132 130
 	}
133 131
 
@@ -255,8 +253,9 @@  discard block
 block discarded – undo
255 253
 				WHERE a.author_id=b.id $filter $orderBy $limit";
256 254
 		$rows=$this->query($sql);
257 255
 		$posts=array();
258
-		foreach($rows as $row)
259
-			$posts[]=$this->populatePostRecord($row);
256
+		foreach($rows as $row) {
257
+					$posts[]=$this->populatePostRecord($row);
258
+		}
260 259
 		return $posts;
261 260
 	}
262 261
 
@@ -275,8 +274,9 @@  discard block
 block discarded – undo
275 274
 				FROM tblPosts a, tblUsers b
276 275
 				WHERE a.author_id=b.id AND a.status=0";
277 276
 
278
-		foreach($keywords as $keyword)
279
-			$sql.=" AND (content LIKE ? OR title LIKE ?)";
277
+		foreach($keywords as $keyword) {
278
+					$sql.=" AND (content LIKE ? OR title LIKE ?)";
279
+		}
280 280
 
281 281
 		$sql.=" $orderBy $limit";
282 282
 
@@ -292,8 +292,9 @@  discard block
 block discarded – undo
292 292
 		$rows=$command->query();
293 293
 
294 294
 		$posts=array();
295
-		foreach($rows as $row)
296
-			$posts[]=$this->populatePostRecord($row);
295
+		foreach($rows as $row) {
296
+					$posts[]=$this->populatePostRecord($row);
297
+		}
297 298
 		return $posts;
298 299
 
299 300
 	}
@@ -356,8 +357,9 @@  discard block
 block discarded – undo
356 357
 
357 358
 		$command->execute();
358 359
 		$post->ID=$this->_db->getLastInsertID();
359
-		foreach($catIDs as $catID)
360
-			$this->insertPostCategory($post->ID,$catID);
360
+		foreach($catIDs as $catID) {
361
+					$this->insertPostCategory($post->ID,$catID);
362
+		}
361 363
 	}
362 364
 
363 365
 	public function updatePost($post,$newCatIDs=null)
@@ -366,14 +368,17 @@  discard block
 block discarded – undo
366 368
 		{
367 369
 			$cats=$this->queryCategoriesByPostID($post->ID);
368 370
 			$catIDs=array();
369
-			foreach($cats as $cat)
370
-				$catIDs[]=$cat->ID;
371
+			foreach($cats as $cat) {
372
+							$catIDs[]=$cat->ID;
373
+			}
371 374
 			$deleteIDs=array_diff($catIDs,$newCatIDs);
372
-			foreach($deleteIDs as $id)
373
-				$this->deletePostCategory($post->ID,$id);
375
+			foreach($deleteIDs as $id) {
376
+							$this->deletePostCategory($post->ID,$id);
377
+			}
374 378
 			$insertIDs=array_diff($newCatIDs,$catIDs);
375
-			foreach($insertIDs as $id)
376
-				$this->insertPostCategory($post->ID,$id);
379
+			foreach($insertIDs as $id) {
380
+							$this->insertPostCategory($post->ID,$id);
381
+			}
377 382
 		}
378 383
 
379 384
 		$command=$this->_db->createCommand("UPDATE tblPosts SET
@@ -394,8 +399,9 @@  discard block
 block discarded – undo
394 399
 	public function deletePost($id)
395 400
 	{
396 401
 		$cats=$this->queryCategoriesByPostID($id);
397
-		foreach($cats as $cat)
398
-			$this->deletePostCategory($id,$cat->ID);
402
+		foreach($cats as $cat) {
403
+					$this->deletePostCategory($id,$cat->ID);
404
+		}
399 405
 
400 406
 		$command=$this->_db->createCommand("DELETE FROM tblComments WHERE post_id=?");
401 407
 		$command->bindValue(1, $id);
@@ -429,8 +435,9 @@  discard block
 block discarded – undo
429 435
 		$sql="SELECT * FROM tblComments $filter $orderBy $limit";
430 436
 		$rows=$this->query($sql);
431 437
 		$comments=array();
432
-		foreach($rows as $row)
433
-			$comments[]=$this->populateCommentRecord($row);
438
+		foreach($rows as $row) {
439
+					$comments[]=$this->populateCommentRecord($row);
440
+		}
434 441
 		return $comments;
435 442
 	}
436 443
 
@@ -443,8 +450,9 @@  discard block
 block discarded – undo
443 450
 		$rows=$command->query();
444 451
 
445 452
 		$comments=array();
446
-		foreach($rows as $row)
447
-			$comments[]=$this->populateCommentRecord($row);
453
+		foreach($rows as $row) {
454
+					$comments[]=$this->populateCommentRecord($row);
455
+		}
448 456
 		return $comments;
449 457
 	}
450 458
 
@@ -512,8 +520,9 @@  discard block
 block discarded – undo
512 520
 		$sql="SELECT * FROM tblCategories ORDER BY name ASC";
513 521
 		$rows=$this->query($sql);
514 522
 		$cats=array();
515
-		foreach($rows as $row)
516
-			$cats[]=$this->populateCategoryRecord($row);
523
+		foreach($rows as $row) {
524
+					$cats[]=$this->populateCategoryRecord($row);
525
+		}
517 526
 		return $cats;
518 527
 	}
519 528
 
@@ -531,8 +540,9 @@  discard block
 block discarded – undo
531 540
 		$rows=$command->query();
532 541
 
533 542
 		$cats=array();
534
-		foreach($rows as $row)
535
-			$cats[]=$this->populateCategoryRecord($row);
543
+		foreach($rows as $row) {
544
+					$cats[]=$this->populateCategoryRecord($row);
545
+		}
536 546
 		return $cats;
537 547
 	}
538 548
 
Please login to merge, or discard this patch.
demos/blog/protected/Common/BlogUserManager.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 	/**
30 30
 	 * Returns a user instance given the user name.
31 31
 	 * @param string user name, null if it is a guest.
32
-	 * @return TUser the user instance, null if the specified username is not in the user database.
32
+	 * @return BlogUser|null the user instance, null if the specified username is not in the user database.
33 33
 	 */
34 34
 	public function getUser($username=null)
35 35
 	{
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -31,21 +31,21 @@  discard block
 block discarded – undo
31 31
 	 * @param string user name, null if it is a guest.
32 32
 	 * @return TUser the user instance, null if the specified username is not in the user database.
33 33
 	 */
34
-	public function getUser($username=null)
34
+	public function getUser($username = null)
35 35
 	{
36
-		if($username===null)
36
+		if ($username === null)
37 37
 			return new BlogUser($this);
38 38
 		else
39 39
 		{
40
-			$username=strtolower($username);
41
-			$db=$this->Application->getModule('data');
42
-			if(($userRecord=$db->queryUserByName($username))!==null)
40
+			$username = strtolower($username);
41
+			$db = $this->Application->getModule('data');
42
+			if (($userRecord = $db->queryUserByName($username)) !== null)
43 43
 			{
44
-				$user=new BlogUser($this);
44
+				$user = new BlogUser($this);
45 45
 				$user->setID($userRecord->ID);
46 46
 				$user->setName($username);
47 47
 				$user->setIsGuest(false);
48
-				$user->setRoles($userRecord->Role===UserRecord::ROLE_USER?'user':'admin');
48
+				$user->setRoles($userRecord->Role === UserRecord::ROLE_USER ? 'user' : 'admin');
49 49
 				return $user;
50 50
 			}
51 51
 			else
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
 	 * @param string password
60 60
 	 * @return boolean true if validation is successful, false otherwise.
61 61
 	 */
62
-	public function validateUser($username,$password)
62
+	public function validateUser($username, $password)
63 63
 	{
64
-		$db=$this->Application->getModule('data');
65
-		if(($userRecord=$db->queryUserByName($username))!==null)
66
-			return $userRecord->Password===md5($password) && $userRecord->Status===UserRecord::STATUS_NORMAL;
64
+		$db = $this->Application->getModule('data');
65
+		if (($userRecord = $db->queryUserByName($username)) !== null)
66
+			return $userRecord->Password === md5($password) && $userRecord->Status === UserRecord::STATUS_NORMAL;
67 67
 		else
68 68
 			return false;
69 69
 	}
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,8 +47,7 @@
 block discarded – undo
47 47
 				$user->setIsGuest(false);
48 48
 				$user->setRoles($userRecord->Role===UserRecord::ROLE_USER?'user':'admin');
49 49
 				return $user;
50
-			}
51
-			else
50
+			} else
52 51
 				return null;
53 52
 		}
54 53
 	}
Please login to merge, or discard this patch.
demos/blog/protected/Pages/Admin/ConfigMan.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -64,6 +64,9 @@
 block discarded – undo
64 64
 			$this->Response->reload();
65 65
 	}
66 66
 
67
+	/**
68
+	 * @param string $id
69
+	 */
67 70
 	private function createParameter($id,$value)
68 71
 	{
69 72
 		$element=new TXmlElement('parameter');
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -18,57 +18,57 @@
 block discarded – undo
18 18
  */
19 19
 class ConfigMan extends BlogPage
20 20
 {
21
-	const CONFIG_FILE='Application.Data.Settings';
21
+	const CONFIG_FILE = 'Application.Data.Settings';
22 22
 
23 23
 	public function onLoad($param)
24 24
 	{
25 25
 		parent::onLoad($param);
26
-		if(!$this->IsPostBack)
26
+		if (!$this->IsPostBack)
27 27
 		{
28
-			$parameters=$this->Application->Parameters;
29
-			$this->SiteTitle->Text=$parameters['SiteTitle'];
30
-			$this->SiteSubtitle->Text=$parameters['SiteSubtitle'];
31
-			$this->SiteOwner->Text=$parameters['SiteOwner'];
32
-			$this->AdminEmail->Text=$parameters['AdminEmail'];
33
-			$this->MultipleUser->Checked=TPropertyValue::ensureBoolean($parameters['MultipleUser']);
34
-			$this->AccountApproval->Checked=TPropertyValue::ensureBoolean($parameters['AccountApproval']);
35
-			$this->PostPerPage->Text=$parameters['PostPerPage'];
36
-			$this->RecentComments->Text=$parameters['RecentComments'];
37
-			$this->PostApproval->Checked=TPropertyValue::ensureBoolean($parameters['PostApproval']);
38
-			$themes=$this->Service->ThemeManager->AvailableThemes;
39
-			$this->ThemeName->DataSource=$themes;
28
+			$parameters = $this->Application->Parameters;
29
+			$this->SiteTitle->Text = $parameters['SiteTitle'];
30
+			$this->SiteSubtitle->Text = $parameters['SiteSubtitle'];
31
+			$this->SiteOwner->Text = $parameters['SiteOwner'];
32
+			$this->AdminEmail->Text = $parameters['AdminEmail'];
33
+			$this->MultipleUser->Checked = TPropertyValue::ensureBoolean($parameters['MultipleUser']);
34
+			$this->AccountApproval->Checked = TPropertyValue::ensureBoolean($parameters['AccountApproval']);
35
+			$this->PostPerPage->Text = $parameters['PostPerPage'];
36
+			$this->RecentComments->Text = $parameters['RecentComments'];
37
+			$this->PostApproval->Checked = TPropertyValue::ensureBoolean($parameters['PostApproval']);
38
+			$themes = $this->Service->ThemeManager->AvailableThemes;
39
+			$this->ThemeName->DataSource = $themes;
40 40
 			$this->ThemeName->dataBind();
41
-			$this->ThemeName->SelectedValue=array_search($parameters['ThemeName'],$themes);
41
+			$this->ThemeName->SelectedValue = array_search($parameters['ThemeName'], $themes);
42 42
 		}
43 43
 	}
44 44
 
45
-	public function saveButtonClicked($sender,$param)
45
+	public function saveButtonClicked($sender, $param)
46 46
 	{
47
-		$dom=new TXmlDocument;
48
-		$dom->Encoding='utf-8';
49
-		$dom->TagName='parameters';
50
-		$elements=$dom->Elements;
51
-		$elements[]=$this->createParameter('SiteTitle',$this->SiteTitle->Text);
52
-		$elements[]=$this->createParameter('SiteSubtitle',$this->SiteSubtitle->Text);
53
-		$elements[]=$this->createParameter('SiteOwner',$this->SiteOwner->Text);
54
-		$elements[]=$this->createParameter('AdminEmail',$this->AdminEmail->Text);
55
-		$elements[]=$this->createParameter('MultipleUser',$this->MultipleUser->Checked);
56
-		$elements[]=$this->createParameter('AccountApproval',$this->AccountApproval->Checked);
57
-		$elements[]=$this->createParameter('PostPerPage',$this->PostPerPage->Text);
58
-		$elements[]=$this->createParameter('RecentComments',$this->RecentComments->Text);
59
-		$elements[]=$this->createParameter('PostApproval',$this->PostApproval->Checked);
60
-		$themeName=$this->ThemeName->SelectedItem->Text;
61
-		$elements[]=$this->createParameter('ThemeName',$themeName);
62
-		$dom->saveToFile(Prado::getPathOfNamespace(self::CONFIG_FILE,'.xml'));
63
-		if($themeName!==$this->Theme->Name)
47
+		$dom = new TXmlDocument;
48
+		$dom->Encoding = 'utf-8';
49
+		$dom->TagName = 'parameters';
50
+		$elements = $dom->Elements;
51
+		$elements[] = $this->createParameter('SiteTitle', $this->SiteTitle->Text);
52
+		$elements[] = $this->createParameter('SiteSubtitle', $this->SiteSubtitle->Text);
53
+		$elements[] = $this->createParameter('SiteOwner', $this->SiteOwner->Text);
54
+		$elements[] = $this->createParameter('AdminEmail', $this->AdminEmail->Text);
55
+		$elements[] = $this->createParameter('MultipleUser', $this->MultipleUser->Checked);
56
+		$elements[] = $this->createParameter('AccountApproval', $this->AccountApproval->Checked);
57
+		$elements[] = $this->createParameter('PostPerPage', $this->PostPerPage->Text);
58
+		$elements[] = $this->createParameter('RecentComments', $this->RecentComments->Text);
59
+		$elements[] = $this->createParameter('PostApproval', $this->PostApproval->Checked);
60
+		$themeName = $this->ThemeName->SelectedItem->Text;
61
+		$elements[] = $this->createParameter('ThemeName', $themeName);
62
+		$dom->saveToFile(Prado::getPathOfNamespace(self::CONFIG_FILE, '.xml'));
63
+		if ($themeName !== $this->Theme->Name)
64 64
 			$this->Response->reload();
65 65
 	}
66 66
 
67
-	private function createParameter($id,$value)
67
+	private function createParameter($id, $value)
68 68
 	{
69
-		$element=new TXmlElement('parameter');
70
-		$element->Attributes['id']=$id;
71
-		$element->Attributes['value']=TPropertyValue::ensureString($value);
69
+		$element = new TXmlElement('parameter');
70
+		$element->Attributes['id'] = $id;
71
+		$element->Attributes['value'] = TPropertyValue::ensureString($value);
72 72
 		return $element;
73 73
 	}
74 74
 }
Please login to merge, or discard this patch.
demos/blog/protected/Pages/SearchPost.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -32,6 +32,9 @@
 block discarded – undo
32 32
 		return $limit;
33 33
 	}
34 34
 
35
+	/**
36
+	 * @param integer $newOffset
37
+	 */
35 38
 	private function formUrl($newOffset)
36 39
 	{
37 40
 		$gets=array();
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -7,60 +7,60 @@
 block discarded – undo
7 7
 	public function onInit($param)
8 8
 	{
9 9
 		parent::onInit($param);
10
-		$this->_posts=$this->DataAccess->queryPostsSearch(
10
+		$this->_posts = $this->DataAccess->queryPostsSearch(
11 11
 				$this->getPostKeywords(),
12 12
 				'ORDER BY create_time DESC',
13
-				'LIMIT '.$this->getPageOffset().','.$this->getPageSize());
13
+				'LIMIT ' . $this->getPageOffset() . ',' . $this->getPageSize());
14 14
 	}
15 15
 
16 16
 	private function getPostKeywords()
17 17
 	{
18
-		return explode(' ',$this->Request['keyword']);
18
+		return explode(' ', $this->Request['keyword']);
19 19
 	}
20 20
 
21 21
 	private function getPageOffset()
22 22
 	{
23
-		if(($offset=TPropertyValue::ensureInteger($this->Request['offset']))<=0)
24
-			$offset=0;
23
+		if (($offset = TPropertyValue::ensureInteger($this->Request['offset'])) <= 0)
24
+			$offset = 0;
25 25
 		return $offset;
26 26
 	}
27 27
 
28 28
 	private function getPageSize()
29 29
 	{
30
-		if(($limit=TPropertyValue::ensureInteger($this->Request['limit']))<=0)
31
-			$limit=TPropertyValue::ensureInteger($this->Application->Parameters['PostPerPage']);
30
+		if (($limit = TPropertyValue::ensureInteger($this->Request['limit'])) <= 0)
31
+			$limit = TPropertyValue::ensureInteger($this->Application->Parameters['PostPerPage']);
32 32
 		return $limit;
33 33
 	}
34 34
 
35 35
 	private function formUrl($newOffset)
36 36
 	{
37
-		$gets=array();
38
-		$gets['offset']=$newOffset;
39
-		if($this->Request['limit']!==null)
40
-			$gets['limit']=$this->Request['limit'];
41
-		if($this->Request['time']!==null)
42
-			$gets['time']=$this->Request['time'];
43
-		if($this->Request['cat']!==null)
44
-			$gets['cat']=$this->Request['cat'];
45
-		return $this->Service->constructUrl('Posts.ListPost',$gets);
37
+		$gets = array();
38
+		$gets['offset'] = $newOffset;
39
+		if ($this->Request['limit'] !== null)
40
+			$gets['limit'] = $this->Request['limit'];
41
+		if ($this->Request['time'] !== null)
42
+			$gets['time'] = $this->Request['time'];
43
+		if ($this->Request['cat'] !== null)
44
+			$gets['cat'] = $this->Request['cat'];
45
+		return $this->Service->constructUrl('Posts.ListPost', $gets);
46 46
 	}
47 47
 
48 48
 	public function onLoad($param)
49 49
 	{
50 50
 		parent::onLoad($param);
51
-		$this->PostList->DataSource=$this->_posts;
51
+		$this->PostList->DataSource = $this->_posts;
52 52
 		$this->PostList->dataBind();
53
-		if($this->getPageOffset()>0)
53
+		if ($this->getPageOffset() > 0)
54 54
 		{
55
-			if(($offset=$this->getPageOffset()-$this->getPageSize())<0)
56
-				$offset=0;
57
-			$this->PrevPage->NavigateUrl=$this->formUrl($offset);
58
-			$this->PrevPage->Visible=true;
55
+			if (($offset = $this->getPageOffset() - $this->getPageSize()) < 0)
56
+				$offset = 0;
57
+			$this->PrevPage->NavigateUrl = $this->formUrl($offset);
58
+			$this->PrevPage->Visible = true;
59 59
 		}
60
-		if(count($this->_posts)===$this->getPageSize())
60
+		if (count($this->_posts) === $this->getPageSize())
61 61
 		{
62
-			$this->NextPage->NavigateUrl=$this->formUrl($this->getPageOffset()+$this->getPageSize());
63
-			$this->NextPage->Visible=true;
62
+			$this->NextPage->NavigateUrl = $this->formUrl($this->getPageOffset() + $this->getPageSize());
63
+			$this->NextPage->Visible = true;
64 64
 		}
65 65
 	}
66 66
 }
Please login to merge, or discard this patch.