Passed
Branch master (2ecc51)
by Michael
03:51
created
class/class.listing.php 3 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -56,17 +56,17 @@  discard block
 block discarded – undo
56 56
 		// class constructor;
57 57
 		$this->setCurrentUser();		
58 58
 		$this->initVar('itemid', XOBJ_DTYPE_INT, 0, true);
59
-        $this->initVar('logourl', XOBJ_DTYPE_TXTBOX, null, false, 255);
60
-        $this->initVar('uid', XOBJ_DTYPE_INT, 0, true);
61
-        $this->initVar('status', XOBJ_DTYPE_INT, 0, true);
62
-        $this->initVar('created', XOBJ_DTYPE_INT, 0, true); 
63
-        $this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false, 255);
64
-        $this->initVar('hits', XOBJ_DTYPE_INT, 0, true);
65
-        $this->initVar('rating', XOBJ_DTYPE_OTHER, 0.0, true);
66
-        $this->initVar('votes', XOBJ_DTYPE_INT, 0, true);     
67
-        $this->initVar('typeid', XOBJ_DTYPE_INT, 0, true); 
68
-        $this->initVar('dirid', XOBJ_DTYPE_INT, 0, true);
69
-        $this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false);
59
+		$this->initVar('logourl', XOBJ_DTYPE_TXTBOX, null, false, 255);
60
+		$this->initVar('uid', XOBJ_DTYPE_INT, 0, true);
61
+		$this->initVar('status', XOBJ_DTYPE_INT, 0, true);
62
+		$this->initVar('created', XOBJ_DTYPE_INT, 0, true); 
63
+		$this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false, 255);
64
+		$this->initVar('hits', XOBJ_DTYPE_INT, 0, true);
65
+		$this->initVar('rating', XOBJ_DTYPE_OTHER, 0.0, true);
66
+		$this->initVar('votes', XOBJ_DTYPE_INT, 0, true);     
67
+		$this->initVar('typeid', XOBJ_DTYPE_INT, 0, true); 
68
+		$this->initVar('dirid', XOBJ_DTYPE_INT, 0, true);
69
+		$this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false);
70 70
 	}	
71 71
 		
72 72
 	/**
@@ -82,16 +82,16 @@  discard block
 block discarded – undo
82 82
 		global $moddir;
83 83
 		if ($arr != false and $handlername != false) {
84 84
 			if (is_array($arr)) {
85
-                $this->assignVars($arr);
86
-            } else {
85
+				$this->assignVars($arr);
86
+			} else {
87 87
 				$obj_handler = xoops_getmodulehandler($handlername, $moddir);
88
-                $object =& $obj_handler->get($arr);
89
-                foreach ($object->vars as $k => $v) {
90
-                    $this->assignVar($k, $v['value']);
91
-                }
92
-                unset($object);
93
-            }
94
-        }
88
+				$object =& $obj_handler->get($arr);
89
+				foreach ($object->vars as $k => $v) {
90
+					$this->assignVar($k, $v['value']);
91
+				}
92
+				unset($object);
93
+			}
94
+		}
95 95
 	}
96 96
 	
97 97
 	function setDataTypes($arr = array()) {
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 		}		
205 205
 		$result = $this->db->query($sql);
206 206
 		$numrows = $this->db->getRowsNum($result);
207
-	    $arr = array();
207
+		$arr = array();
208 208
 		if ( $numrows > 0 ) {
209 209
 			while(list($cid, $active) = $this->db->fetchRow($result)) {
210 210
 				$arr[] = $cid;
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 		}
233 233
 		$result = $this->db->query($sql);
234 234
 		$numrows = $this->db->getRowsNum($result);
235
-	    $arr = array();
235
+		$arr = array();
236 236
 		if ( $numrows > 0 ) {
237 237
 			while(list($cid) = $this->db->fetchRow($result)) {
238 238
 				$arr[] = $cid;
@@ -257,16 +257,16 @@  discard block
 block discarded – undo
257 257
 		$result = $this->db->query($sql);
258 258
 		$arr = array();
259 259
 		if (!$result) {
260
-            return $arr;
261
-        } else {
262
-        	$numrows = $this->db->getRowsNum($result);
263
-        	if ($numrows == 0) {
264
-        		return $arr;
265
-        	} else {
266
-        		$arr = $this->db->fetchArray($result);
267
-        	}
268
-        }
269
-        return $arr;
260
+			return $arr;
261
+		} else {
262
+			$numrows = $this->db->getRowsNum($result);
263
+			if ($numrows == 0) {
264
+				return $arr;
265
+			} else {
266
+				$arr = $this->db->fetchArray($result);
267
+			}
268
+		}
269
+		return $arr;
270 270
 	}
271 271
 	
272 272
 	function getListingsByDirectory( $dirid=0, $show=10, $min=0, $orderby=false ) {
Please login to merge, or discard this patch.
Switch Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -318,25 +318,25 @@  discard block
 block discarded – undo
318 318
 	function getFieldValue($fieldtype="", $options="", $value=0) {
319 319
 		global $myts, $moddir;
320 320
 		switch ($fieldtype) {
321
-		case "dhtml":
322
-			return $myts->makeTareaData4Show($value);
323
-			break;
324
-		case "gmap":
325
-			$gmapHandler = new efqGmapHandler();
326
-			$gmap = new efqGmap();
327
-			$gmap->setPointsJS($gmapHandler->getPointsJS($gmap));
328
-			$gmap->generateMap();
329
-			$ret = $gmap->showMap();
330
-			unset($gmap);
331
-			unset($gmapHandler);
332
-			return $ret;
333
-			break;
334
-		case "radio":
335
-			return $myts->makeTboxData4Show($value);
336
-			break;
337
-		case "rating":
338
-			$xoops_url = XOOPS_URL;
339
-			switch ($value) {
321
+			case "dhtml":
322
+				return $myts->makeTareaData4Show($value);
323
+				break;
324
+			case "gmap":
325
+				$gmapHandler = new efqGmapHandler();
326
+				$gmap = new efqGmap();
327
+				$gmap->setPointsJS($gmapHandler->getPointsJS($gmap));
328
+				$gmap->generateMap();
329
+				$ret = $gmap->showMap();
330
+				unset($gmap);
331
+				unset($gmapHandler);
332
+				return $ret;
333
+				break;
334
+			case "radio":
335
+				return $myts->makeTboxData4Show($value);
336
+				break;
337
+			case "rating":
338
+				$xoops_url = XOOPS_URL;
339
+				switch ($value) {
340 340
 				case 1:
341 341
 					$src = "$xoops_url/modules/$moddir/images/rating_1.gif";
342 342
 					break;
@@ -369,30 +369,30 @@  discard block
 block discarded – undo
369 369
 					break;
370 370
 				default:
371 371
 				$src = "";
372
-			}			
372
+				}			
373 373
 			$rating = "<img src=\"$src\" />";
374 374
 			return $rating;
375 375
 			break;
376
-		case "select":
377
-			return $myts->makeTboxData4Show($value);
378
-			break;
379
-		case "textbox":
380
-			return $myts->makeTboxData4Show($value);
381
-			break;
382
-		case "url":
383
-			$link = explode('|',$value);
384
-			return '<a href="'.$myts->makeTboxData4Show($link[0]).'" title="'.$myts->makeTboxData4Show($link[1]).'">'.$myts->makeTboxData4Show($link[0]).'</a>';
385
-			break;
386
-		case "yesno":
387
-			if ($value == '1') {
388
-				return _YES;
389
-			} else {
390
-				return _NO;
391
-			}
392
-			break;
393
-		default:
394
-			return $myts->makeTboxData4Show($value);
395
-			break;
376
+			case "select":
377
+				return $myts->makeTboxData4Show($value);
378
+				break;
379
+			case "textbox":
380
+				return $myts->makeTboxData4Show($value);
381
+				break;
382
+			case "url":
383
+				$link = explode('|',$value);
384
+				return '<a href="'.$myts->makeTboxData4Show($link[0]).'" title="'.$myts->makeTboxData4Show($link[1]).'">'.$myts->makeTboxData4Show($link[0]).'</a>';
385
+				break;
386
+			case "yesno":
387
+				if ($value == '1') {
388
+					return _YES;
389
+				} else {
390
+					return _NO;
391
+				}
392
+				break;
393
+			default:
394
+				return $myts->makeTboxData4Show($value);
395
+				break;
396 396
 		}
397 397
 	}
398 398
 	
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 * 
78 78
 	 * @param   array   $listing	Array with listing details
79 79
 	 */
80
-	function setListingVars($arr=array(),$handlername=false)
80
+	function setListingVars($arr = array(), $handlername = false)
81 81
 	{
82 82
 		global $moddir;
83 83
 		if ($arr != false and $handlername != false) {
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
                 $this->assignVars($arr);
86 86
             } else {
87 87
 				$obj_handler = xoops_getmodulehandler($handlername, $moddir);
88
-                $object =& $obj_handler->get($arr);
88
+                $object = & $obj_handler->get($arr);
89 89
                 foreach ($object->vars as $k => $v) {
90 90
                     $this->assignVar($k, $v['value']);
91 91
                 }
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
 	}
117 117
 	
118 118
 	//Set variable $_updated to true of false (default)
119
-	function setUpdated($set=false) {
119
+	function setUpdated($set = false) {
120 120
 		$this->_updated = $set;
121 121
 	}
122 122
 	
123 123
 	//Set variable $_inserted to true of false (default)
124
-	function setInserted($set=false) {
124
+	function setInserted($set = false) {
125 125
 		$this->_inserted = $set;
126 126
 	}
127 127
 	
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	{
145 145
 		//Instantiate class
146 146
 		global $eh;
147
-		$this->db =& XoopsDatabaseFactory::getDatabaseConnection();
147
+		$this->db = & XoopsDatabaseFactory::getDatabaseConnection();
148 148
 		$this->errorhandler = $eh;
149 149
 	}
150 150
 	
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 * 
160 160
 	 * @return	bool	true if update is succesful, false if unsuccesful
161 161
 	 */
162
-	function updateStatus($itemid=0, $newstatus='1') {
162
+	function updateStatus($itemid = 0, $newstatus = '1') {
163 163
 		$sql = "UPDATE ".$this->db->prefix("efqdiralpha1_items")." SET status = ".$newstatus." WHERE itemid = ".intval($itemid)."";
164 164
 		if ($this->db->query($sql)) {
165 165
 			return true;	
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	 * 
178 178
 	 * @return	bool	true if update is succesful, false if unsuccesful
179 179
 	 */
180
-	function incrementHits($itemid=0) {
180
+	function incrementHits($itemid = 0) {
181 181
 		$sql = sprintf("UPDATE %s SET hits = hits+1 WHERE itemid = %u AND status = 2", $this->db->prefix("efqdiralpha1_items"), intval($itemid));
182 182
 		if ($this->db->queryF($sql)) {
183 183
 			return true;	
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 * 
198 198
 	 * @return	array	$arr Array with category ID's
199 199
 	 */
200
-	function getLinkedCategories($itemid='0', $dirid='0', $activeonly=true) {
200
+	function getLinkedCategories($itemid = '0', $dirid = '0', $activeonly = true) {
201 201
 		$sql = "SELECT c.cid, x.active FROM ".$this->db->prefix("efqdiralpha1_cat")." c, ".$this->db->prefix("efqdiralpha1_item_x_cat")." x WHERE c.cid=x.cid AND x.itemid=".intval($itemid)." AND c.dirid='".intval($dirid)."'";
202 202
 		if ($activeonly) {
203 203
 			$sql .= " AND c.active='1'";	
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 		$result = $this->db->query($sql);
206 206
 		$numrows = $this->db->getRowsNum($result);
207 207
 	    $arr = array();
208
-		if ( $numrows > 0 ) {
209
-			while(list($cid, $active) = $this->db->fetchRow($result)) {
208
+		if ($numrows > 0) {
209
+			while (list($cid, $active) = $this->db->fetchRow($result)) {
210 210
 				$arr[] = $cid;
211 211
 			}
212 212
 		}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 * 
226 226
 	 * @return	array	$arr Array with category ID's
227 227
 	 */
228
-	function getAllCategories($dirid='0', $activeonly=true) {
228
+	function getAllCategories($dirid = '0', $activeonly = true) {
229 229
 		$sql = "SELECT cid FROM ".$this->db->prefix("efqdiralpha1_cat")." WHERE dirid='".intval($dirid)."'";
230 230
 		if ($activeonly) {
231 231
 			$sql .= " AND active='1'";	
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 		$result = $this->db->query($sql);
234 234
 		$numrows = $this->db->getRowsNum($result);
235 235
 	    $arr = array();
236
-		if ( $numrows > 0 ) {
237
-			while(list($cid) = $this->db->fetchRow($result)) {
236
+		if ($numrows > 0) {
237
+			while (list($cid) = $this->db->fetchRow($result)) {
238 238
 				$arr[] = $cid;
239 239
 			}
240 240
 		}
@@ -269,27 +269,27 @@  discard block
 block discarded – undo
269 269
         return $arr;
270 270
 	}
271 271
 	
272
-	function getListingsByDirectory( $dirid=0, $show=10, $min=0, $orderby=false ) {
272
+	function getListingsByDirectory($dirid = 0, $show = 10, $min = 0, $orderby = false) {
273 273
 		$sql = "SELECT l.itemid, l.logourl, l.uid, l.status, l.created, l.title, l.hits, l.rating, l.votes, l.typeid, l.dirid, t.description FROM ".$this->db->prefix("efqdiralpha1_cat")." c, ".$this->db->prefix("efqdiralpha1_item_x_cat")." x, ".$this->db->prefix("efqdiralpha1_items")." l LEFT JOIN ".$this->db->prefix("efqdiralpha1_item_text")." t ON (l.itemid=t.itemid) WHERE x.cid=c.cid AND l.itemid=x.itemid AND c.showpopular=1 AND l.status='2' AND l.dirid = '".$dirid."' ORDER BY l.created DESC";
274
-		$result = $this->db->query($sql) or  $this->errorhandler->show("0013");
274
+		$result = $this->db->query($sql) or $this->errorhandler->show("0013");
275 275
 		return $result;
276 276
 	}
277 277
 	
278
-	function getListingsByCategory( $catid=0, $show=10, $min=0, $orderby=false ) {
278
+	function getListingsByCategory($catid = 0, $show = 10, $min = 0, $orderby = false) {
279 279
 		$sql = "SELECT i.itemid, i.logourl, i.uid, i.status, i.created, i.title, i.hits, i.rating, i.votes, i.typeid, i.dirid, t.level, txt.description, x.cid FROM ".$this->db->prefix("efqdiralpha1_item_x_cat")." x, ".$this->db->prefix("efqdiralpha1_items")." i LEFT JOIN ".$this->db->prefix("efqdiralpha1_itemtypes")." t ON (t.typeid=i.typeid) LEFT JOIN ".$this->db->prefix("efqdiralpha1_item_text")." txt ON (txt.itemid=i.itemid) WHERE i.itemid=x.itemid AND x.cid=$catid AND x.active='1' AND i.status='2' ORDER BY $orderby";
280
-		$result = $this->db->query($sql) or  $this->errorhandler->show("0013");
280
+		$result = $this->db->query($sql) or $this->errorhandler->show("0013");
281 281
 		return $result;
282 282
 	}
283 283
 	
284
-	function getDataTypes( $itemid, $show=10, $min=0 ) {
284
+	function getDataTypes($itemid, $show = 10, $min = 0) {
285 285
 		$sql = "SELECT DISTINCT t.dtypeid, t.title, t.section, t.icon, f.typeid, f.fieldtype, f.ext, t.options, t.custom, d.itemid, d.value, d.customtitle ";
286 286
 		$sql .= "FROM ".$this->db->prefix("efqdiralpha1_item_x_cat")." ic, ".$this->db->prefix("efqdiralpha1_dtypes_x_cat")." xc, ".$this->db->prefix("efqdiralpha1_fieldtypes")." f, ".$this->db->prefix("efqdiralpha1_dtypes")." t ";
287 287
 		$sql .= "LEFT JOIN ".$this->db->prefix("efqdiralpha1_data")." d ON (t.dtypeid=d.dtypeid AND d.itemid=".intval($itemid).") ";
288 288
 		$sql .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=".intval($itemid)." ORDER BY t.seq ASC";
289
-		$result=$this->db->query($sql,$show,$min) or $this->errorhandler->show("0013");
289
+		$result = $this->db->query($sql, $show, $min) or $this->errorhandler->show("0013");
290 290
 		$numrows = $this->db->getRowsNum($result);
291 291
 		$arr = array();
292
-		while(list($dtypeid, $title, $section, $icon, $ftypeid, $fieldtype, $ext, $options, $custom, $itemid, $value, $customtitle) = $this->db->fetchRow($result)) {
292
+		while (list($dtypeid, $title, $section, $icon, $ftypeid, $fieldtype, $ext, $options, $custom, $itemid, $value, $customtitle) = $this->db->fetchRow($result)) {
293 293
 			$fieldvalue = $this->getFieldValue($fieldtype, $options, $value);
294 294
 			if ($icon != '') {
295 295
 				$iconurl = "<img src=\"uploads/$icon\" />";
@@ -310,12 +310,12 @@  discard block
 block discarded – undo
310 310
 				'custom' => $custom,
311 311
 				'itemid' => $itemid,
312 312
 				'value' => $fieldvalue,
313
-				'customtitle' => $customtitle );			
313
+				'customtitle' => $customtitle);			
314 314
 		}
315 315
 		return $arr;
316 316
 	}
317 317
 	
318
-	function getFieldValue($fieldtype="", $options="", $value=0) {
318
+	function getFieldValue($fieldtype = "", $options = "", $value = 0) {
319 319
 		global $myts, $moddir;
320 320
 		switch ($fieldtype) {
321 321
 		case "dhtml":
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 			return $myts->makeTboxData4Show($value);
381 381
 			break;
382 382
 		case "url":
383
-			$link = explode('|',$value);
383
+			$link = explode('|', $value);
384 384
 			return '<a href="'.$myts->makeTboxData4Show($link[0]).'" title="'.$myts->makeTboxData4Show($link[1]).'">'.$myts->makeTboxData4Show($link[0]).'</a>';
385 385
 			break;
386 386
 		case "yesno":
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 	 * 
408 408
 	 * @return	bool	true if update is succesful, false if unsuccesful
409 409
 	 */
410
-	function updateDescription($itemid=0, $descr="") {
410
+	function updateDescription($itemid = 0, $descr = "") {
411 411
 		$sql = sprintf("UPDATE %s SET description = %s WHERE itemid = %u", $this->db->prefix("efqdiralpha1_item_text"), $this->db->quoteString($descr), intval($itemid));
412 412
 		if ($this->db->queryF($sql)) {
413 413
 			return true;	
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 	 * 
427 427
 	 * @return	bool	true if update is succesful, false if unsuccesful
428 428
 	 */
429
-	function insertDescription($itemid=0, $descr="") {
429
+	function insertDescription($itemid = 0, $descr = "") {
430 430
 		$sql = sprintf("INSERT INTO %s (itemid, description) VALUES (%u, %s)", $this->db->prefix("efqdiralpha1_item_text"), intval($itemid), $this->db->quoteString($descr));
431 431
 		if ($this->db->queryF($sql)) {
432 432
 			return true;	
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 	 * 
445 445
 	 * @return	bool	true if update is succesful, false if unsuccesful
446 446
 	 */
447
-	function updateListing($obj, $forceQuery=false) {
447
+	function updateListing($obj, $forceQuery = false) {
448 448
 		$tablename = "efqdiralpha1_items";
449 449
 		$keyName = "itemid";
450 450
 		if ($obj instanceof efqListing) {
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 	 * 
493 493
 	 * @return	bool	true if insertion is succesful, false if unsuccesful
494 494
 	 */
495
-	function insertListing($obj, $forceQuery=false) {
495
+	function insertListing($obj, $forceQuery = false) {
496 496
 		$tablename = "efqdiralpha1_items";
497 497
 		$keyName = "itemid";
498 498
 		if ($obj instanceof efqListing) {
Please login to merge, or discard this patch.
class/class.datafield.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -74,12 +74,12 @@
 block discarded – undo
74 74
 	
75 75
 	function getDataFields( $itemid, $show=10, $min=0 ) {
76 76
 		$sql = "SELECT DISTINCT t.dtypeid, t.title, t.section, t.icon, f.typeid, f.fieldtype, f.ext, t.options, d.itemid, d.value, d.customtitle, t.custom ";
77
-        $sql .= "FROM ".$this->db->prefix("efqdiralpha1_item_x_cat")." ic, ".$this->db->prefix("efqdiralpha1_dtypes_x_cat")." xc, ".$this->db->prefix("efqdiralpha1_fieldtypes")." f, ".$this->db->prefix("efqdiralpha1_dtypes")." t ";
78
-        $sql .= "LEFT JOIN ".$this->db->prefix("efqdiralpha1_data") .
79
-            " d ON (t.dtypeid=d.dtypeid AND d.itemid=".$itemid.") ";
80
-        $sql .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=".$itemid."";
81
-        $data_result = $this->db->query($sql) or $this->errorhandler->show("0013");
82
-        //$numrows = $this->db->getRowsNum($data_result);
77
+		$sql .= "FROM ".$this->db->prefix("efqdiralpha1_item_x_cat")." ic, ".$this->db->prefix("efqdiralpha1_dtypes_x_cat")." xc, ".$this->db->prefix("efqdiralpha1_fieldtypes")." f, ".$this->db->prefix("efqdiralpha1_dtypes")." t ";
78
+		$sql .= "LEFT JOIN ".$this->db->prefix("efqdiralpha1_data") .
79
+			" d ON (t.dtypeid=d.dtypeid AND d.itemid=".$itemid.") ";
80
+		$sql .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=".$itemid."";
81
+		$data_result = $this->db->query($sql) or $this->errorhandler->show("0013");
82
+		//$numrows = $this->db->getRowsNum($data_result);
83 83
 		$arr = array();
84 84
 		while (list($dtypeid, $title, $section, $icon, $ftypeid, $fieldtype, $ext, $options, $itemid, $value, $customtitle, $custom) = $this->db->fetchRow($data_result)) {
85 85
 			$fieldvalue = $this->getFieldValue($fieldtype, $options, $value);
Please login to merge, or discard this patch.
Switch Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -110,25 +110,25 @@  discard block
 block discarded – undo
110 110
 	function getFieldValue($fieldtype="", $options="", $value=0) {
111 111
 		global $myts, $moddir;
112 112
 		switch ($fieldtype) {
113
-		case "dhtml":
114
-			return $myts->makeTareaData4Show($value);
115
-			break;
116
-		//case "gmap":
117
-//			$gmapHandler = new efqGmapHandler();			
118
-//			$gmap = new efqGmap();
119
-//			$gmap->setPointsJS($gmapHandler->getPointsJS($gmap));
120
-//			$gmap->generateMap();
121
-//			$ret = $gmap->showMap();
122
-//			unset($gmap);
123
-//			unset($gmapHandler);
124
-			//return $myts->makeTboxData4Show($value);
125
-			//break;
126
-		case "radio":
127
-			return $myts->makeTboxData4Show($value);
128
-			break;
129
-		case "rating":
130
-			$xoops_url = XOOPS_URL;
131
-			switch ($value) {
113
+			case "dhtml":
114
+				return $myts->makeTareaData4Show($value);
115
+				break;
116
+			//case "gmap":
117
+	//			$gmapHandler = new efqGmapHandler();			
118
+	//			$gmap = new efqGmap();
119
+	//			$gmap->setPointsJS($gmapHandler->getPointsJS($gmap));
120
+	//			$gmap->generateMap();
121
+	//			$ret = $gmap->showMap();
122
+	//			unset($gmap);
123
+	//			unset($gmapHandler);
124
+				//return $myts->makeTboxData4Show($value);
125
+				//break;
126
+			case "radio":
127
+				return $myts->makeTboxData4Show($value);
128
+				break;
129
+			case "rating":
130
+				$xoops_url = XOOPS_URL;
131
+				switch ($value) {
132 132
 				case 1:
133 133
 					$src = "$xoops_url/modules/$moddir/images/rating_1.gif";
134 134
 					break;
@@ -161,30 +161,30 @@  discard block
 block discarded – undo
161 161
 					break;
162 162
 				default:
163 163
 				$src = "";
164
-			}			
164
+				}			
165 165
 			$rating = "<img src=\"$src\" />";
166 166
 			return $rating;
167 167
 			break;
168
-		case "select":
169
-			return $myts->makeTboxData4Show($value);
170
-			break;
171
-		case "textbox":
172
-			return $myts->makeTboxData4Show($value);
173
-			break;
174
-		case "url":
175
-			$link = explode('|',$value);
176
-			return '<a href="'.$myts->makeTboxData4Show($link[0]).'" title="'.$myts->makeTboxData4Show($link[1]).'">'.$myts->makeTboxData4Show($link[0]).'</a>';
177
-			break;
178
-		case "yesno":
179
-			if ($value == '1') {
180
-				return _YES;
181
-			} else {
182
-				return _NO;
183
-			}
184
-			break;
185
-		default:
186
-			return $myts->makeTboxData4Show($value);
187
-			break;
168
+			case "select":
169
+				return $myts->makeTboxData4Show($value);
170
+				break;
171
+			case "textbox":
172
+				return $myts->makeTboxData4Show($value);
173
+				break;
174
+			case "url":
175
+				$link = explode('|',$value);
176
+				return '<a href="'.$myts->makeTboxData4Show($link[0]).'" title="'.$myts->makeTboxData4Show($link[1]).'">'.$myts->makeTboxData4Show($link[0]).'</a>';
177
+				break;
178
+			case "yesno":
179
+				if ($value == '1') {
180
+					return _YES;
181
+				} else {
182
+					return _NO;
183
+				}
184
+				break;
185
+			default:
186
+				return $myts->makeTboxData4Show($value);
187
+				break;
188 188
 		}
189 189
 	}
190 190
 	
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
 	{
69 69
 		//Instantiate class
70 70
 		global $eh;
71
-		$this->db =& XoopsDatabaseFactory::getDatabaseConnection();
71
+		$this->db = & XoopsDatabaseFactory::getDatabaseConnection();
72 72
 		$this->errorhandler = $eh;
73 73
 	}
74 74
 	
75
-	function getDataFields( $itemid, $show=10, $min=0 ) {
75
+	function getDataFields($itemid, $show = 10, $min = 0) {
76 76
 		$sql = "SELECT DISTINCT t.dtypeid, t.title, t.section, t.icon, f.typeid, f.fieldtype, f.ext, t.options, d.itemid, d.value, d.customtitle, t.custom ";
77 77
         $sql .= "FROM ".$this->db->prefix("efqdiralpha1_item_x_cat")." ic, ".$this->db->prefix("efqdiralpha1_dtypes_x_cat")." xc, ".$this->db->prefix("efqdiralpha1_fieldtypes")." f, ".$this->db->prefix("efqdiralpha1_dtypes")." t ";
78
-        $sql .= "LEFT JOIN ".$this->db->prefix("efqdiralpha1_data") .
78
+        $sql .= "LEFT JOIN ".$this->db->prefix("efqdiralpha1_data").
79 79
             " d ON (t.dtypeid=d.dtypeid AND d.itemid=".$itemid.") ";
80 80
         $sql .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=".$itemid."";
81 81
         $data_result = $this->db->query($sql) or $this->errorhandler->show("0013");
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 				'custom' => $custom,
103 103
 				'itemid' => $itemid,
104 104
 				'value' => $fieldvalue,
105
-				'customtitle' => $customtitle );			
105
+				'customtitle' => $customtitle);			
106 106
 		}
107 107
 		return $arr;
108 108
 	}
109 109
 	
110
-	function getFieldValue($fieldtype="", $options="", $value=0) {
110
+	function getFieldValue($fieldtype = "", $options = "", $value = 0) {
111 111
 		global $myts, $moddir;
112 112
 		switch ($fieldtype) {
113 113
 		case "dhtml":
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 			return $myts->makeTboxData4Show($value);
173 173
 			break;
174 174
 		case "url":
175
-			$link = explode('|',$value);
175
+			$link = explode('|', $value);
176 176
 			return '<a href="'.$myts->makeTboxData4Show($link[0]).'" title="'.$myts->makeTboxData4Show($link[1]).'">'.$myts->makeTboxData4Show($link[0]).'</a>';
177 177
 			break;
178 178
 		case "yesno":
Please login to merge, or discard this patch.
class/class.offer.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
 	{
55 55
 		global $moddir;
56 56
 		$this->db = Database::getInstance();
57
-	    $this->initVar('offerid', XOBJ_DTYPE_INT, 0, false);
58
-	    $this->initVar('dirid', XOBJ_DTYPE_INT, 0, false);
57
+		$this->initVar('offerid', XOBJ_DTYPE_INT, 0, false);
58
+		$this->initVar('dirid', XOBJ_DTYPE_INT, 0, false);
59 59
 		$this->initVar('typeid', XOBJ_DTYPE_INT, 0, false);
60
-	    $this->initVar('title', XOBJ_DTYPE_TXTBOX, null, true, 255);
61
-	    $this->initVar('duration', XOBJ_DTYPE_INT, 0, true, 5);
62
-	    $this->initVar('count', XOBJ_DTYPE_INT, 0, true, 5);
63
-	    $this->initVar('price', XOBJ_DTYPE_CURRENCY, 0.00, true);
64
-	    $this->initVar('activeyn', XOBJ_DTYPE_INT, 0, true, 2);
60
+		$this->initVar('title', XOBJ_DTYPE_TXTBOX, null, true, 255);
61
+		$this->initVar('duration', XOBJ_DTYPE_INT, 0, true, 5);
62
+		$this->initVar('count', XOBJ_DTYPE_INT, 0, true, 5);
63
+		$this->initVar('price', XOBJ_DTYPE_CURRENCY, 0.00, true);
64
+		$this->initVar('activeyn', XOBJ_DTYPE_INT, 0, true, 2);
65 65
 		$this->initVar('currency', XOBJ_DTYPE_TXTBOX, null, false, 10);
66 66
 		$this->initVar('descr', XOBJ_DTYPE_OTHER, 0);
67 67
 		$this->initVar('typename', XOBJ_DTYPE_TXTBOX, null, false, 50);
@@ -207,13 +207,13 @@  discard block
 block discarded – undo
207 207
 	function setOffer($gpc_offerid=0) {
208 208
 		$sql = "SELECT o.offerid, o.title, o.typeid, o.duration, o.count, " .
209 209
 		"o.price, o.activeyn, o.currency, o.descr, o.dirid, t.typename, t.level FROM " .
210
-            $this->db->prefix("efqdiralpha1_itemtypes") . " t, " . $this->db->prefix("efqdiralpha1_subscr_offers") .
211
-            " o	WHERE o.typeid=t.typeid AND o.offerid=" . intval($gpc_offerid) . "";
212
-        $result = $this->db->query($sql);
213
-        $numrows = $this->db->getRowsNum($result);
214
-        if ( $numrows > 0 ) {
215
-	        while (list($offerid, $offertitle, $typeid, $duration, $count, $price, $activeyn,
216
-	                $currency, $descr, $dirid, $typename, $level) = $this->db->fetchRow($result)) {
210
+			$this->db->prefix("efqdiralpha1_itemtypes") . " t, " . $this->db->prefix("efqdiralpha1_subscr_offers") .
211
+			" o	WHERE o.typeid=t.typeid AND o.offerid=" . intval($gpc_offerid) . "";
212
+		$result = $this->db->query($sql);
213
+		$numrows = $this->db->getRowsNum($result);
214
+		if ( $numrows > 0 ) {
215
+			while (list($offerid, $offertitle, $typeid, $duration, $count, $price, $activeyn,
216
+					$currency, $descr, $dirid, $typename, $level) = $this->db->fetchRow($result)) {
217 217
 				if (! $this->objOffer ) {
218 218
 					$this->objOffer = new efqSubscriptionOffer();
219 219
 				}
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
 				$this->objOffer->setVar('dirid', $dirid);
230 230
 				$this->objOffer->setVar('typename', $typename);
231 231
 				$this->objOffer->setVar('level', $level);
232
-	        }
233
-	    } else {
232
+			}
233
+		} else {
234 234
 			return false;
235 235
 		}
236 236
 		return true;
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
    * @param bool $itemtype
51 51
    * @return
52 52
    */
53
-	function efqSubscriptionOffer($offer=false)
53
+	function efqSubscriptionOffer($offer = false)
54 54
 	{
55 55
 		global $moddir;
56 56
 		$this->db = Database::getInstance();
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
    * 
90 90
    * @return
91 91
    */
92
-	function efqSubscriptionOfferHandler($offer=false) {
92
+	function efqSubscriptionOfferHandler($offer = false) {
93 93
 		$this->db = Database::getInstance();
94 94
 		$this->objOffer = $offer;
95 95
 	}
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * 
105 105
 	 * @return	bool	true if insertion is succesful, false if unsuccesful
106 106
 	 */
107
-	function insertOffer($obj, $forceQuery=false) {
107
+	function insertOffer($obj, $forceQuery = false) {
108 108
 		$tablename = "efqdiralpha1_subscr_offers";
109 109
 		$keyName = "offerid";
110 110
 		$excludedVars = array('level', 'typename');
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 		$strFields = "";
122 122
 		$strValues = "";
123 123
 		foreach ($cleanvars as $k => $v) {
124
-			if ( !in_array($k, $excludedVars) ) {
124
+			if (!in_array($k, $excludedVars)) {
125 125
 				$strFields .= $k;
126 126
 				$strValues .= "'".$v."'";
127 127
 				if ($i < $countVars) {
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 * 
159 159
 	 * @return	bool	true if update is succesful, false if unsuccesful
160 160
 	 */
161
-	function updateOffer($obj, $forceQuery=false) {
161
+	function updateOffer($obj, $forceQuery = false) {
162 162
 		$tablename = "efqdiralpha1_subscr_offers";
163 163
 		$keyName = "offerid";
164 164
 		$excludedVars = array('level', 'typename');
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		$strSet = "";
177 177
 		$strValues = "";
178 178
 		foreach ($cleanvars as $k => $v) {
179
-			if ( !in_array($k, $excludedVars) ) {
179
+			if (!in_array($k, $excludedVars)) {
180 180
 				if ($i < $countVars and $i > 1) {
181 181
 					$strSet .= ", ";
182 182
 				}
@@ -204,17 +204,17 @@  discard block
 block discarded – undo
204 204
    * 
205 205
    * @return bool true or false
206 206
    */
207
-	function setOffer($gpc_offerid=0) {
208
-		$sql = "SELECT o.offerid, o.title, o.typeid, o.duration, o.count, " .
209
-		"o.price, o.activeyn, o.currency, o.descr, o.dirid, t.typename, t.level FROM " .
210
-            $this->db->prefix("efqdiralpha1_itemtypes") . " t, " . $this->db->prefix("efqdiralpha1_subscr_offers") .
211
-            " o	WHERE o.typeid=t.typeid AND o.offerid=" . intval($gpc_offerid) . "";
207
+	function setOffer($gpc_offerid = 0) {
208
+		$sql = "SELECT o.offerid, o.title, o.typeid, o.duration, o.count, ".
209
+		"o.price, o.activeyn, o.currency, o.descr, o.dirid, t.typename, t.level FROM ".
210
+            $this->db->prefix("efqdiralpha1_itemtypes")." t, ".$this->db->prefix("efqdiralpha1_subscr_offers").
211
+            " o	WHERE o.typeid=t.typeid AND o.offerid=".intval($gpc_offerid)."";
212 212
         $result = $this->db->query($sql);
213 213
         $numrows = $this->db->getRowsNum($result);
214
-        if ( $numrows > 0 ) {
214
+        if ($numrows > 0) {
215 215
 	        while (list($offerid, $offertitle, $typeid, $duration, $count, $price, $activeyn,
216 216
 	                $currency, $descr, $dirid, $typename, $level) = $this->db->fetchRow($result)) {
217
-				if (! $this->objOffer ) {
217
+				if (!$this->objOffer) {
218 218
 					$this->objOffer = new efqSubscriptionOffer();
219 219
 				}
220 220
 				$this->objOffer->setVar('offerid', $offerid);
Please login to merge, or discard this patch.
class/class.efqtree.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
 
35 35
 class efqTree
36 36
 {
37
-	var $table;     //table with parent-child structure
38
-	var $id;    //name of unique id for records in table $table
39
-	var $pid;     // name of parent id used in table $table
40
-	var $order;    //specifies the order of query results
41
-	var $title;     // name of a field in table $table which will be used when  selection box and paths are generated
37
+	var $table; //table with parent-child structure
38
+	var $id; //name of unique id for records in table $table
39
+	var $pid; // name of parent id used in table $table
40
+	var $order; //specifies the order of query results
41
+	var $title; // name of a field in table $table which will be used when  selection box and paths are generated
42 42
 	var $db;
43 43
 	var $dirid;
44 44
 
@@ -46,32 +46,32 @@  discard block
 block discarded – undo
46 46
 	//sets the names of table, unique id, and parend id
47 47
 	function EfqTree($table_name, $id_name, $pid_name)
48 48
 	{
49
-		$this->db =& Database::getInstance();
49
+		$this->db = & Database::getInstance();
50 50
 		$this->table = $table_name;
51 51
 		$this->id = $id_name;
52 52
 		$this->pid = $pid_name;
53 53
 		$this->dirid = 0;
54 54
 	}
55 55
 	
56
-	function setDir($dirid=0) {
56
+	function setDir($dirid = 0) {
57 57
 		$this->dirid = $dirid;
58 58
 	}
59 59
 
60 60
 
61 61
 	// returns an array of first child objects for a given id($sel_id)
62
-	function getFirstChild($sel_id, $order="")
62
+	function getFirstChild($sel_id, $order = "")
63 63
 	{
64
-		$arr =array();
64
+		$arr = array();
65 65
 		$sql = "SELECT * FROM ".$this->table." WHERE ".$this->pid."=".$sel_id."";
66
-		if ( $order != "" ) {
66
+		if ($order != "") {
67 67
 			$sql .= " ORDER BY $order";
68 68
 		}
69 69
 		$result = $this->db->query($sql);
70 70
 		$count = $this->db->getRowsNum($result);
71
-		if ( $count==0 ) {
71
+		if ($count == 0) {
72 72
 			return $arr;
73 73
 		}
74
-		while ( $myrow=$this->db->fetchArray($result) ) {
74
+		while ($myrow = $this->db->fetchArray($result)) {
75 75
 			array_push($arr, $myrow);
76 76
 		}
77 77
 		return $arr;
@@ -80,67 +80,67 @@  discard block
 block discarded – undo
80 80
 	// returns an array of all FIRST child ids of a given id($sel_id)
81 81
 	function getFirstChildId($sel_id)
82 82
 	{
83
-		$idarray =array();
83
+		$idarray = array();
84 84
 		$result = $this->db->query("SELECT ".$this->id." FROM ".$this->table." WHERE ".$this->pid."=".$sel_id."");
85 85
 		$count = $this->db->getRowsNum($result);
86
-		if ( $count == 0 ) {
86
+		if ($count == 0) {
87 87
 			return $idarray;
88 88
 		}
89
-		while ( list($id) = $this->db->fetchRow($result) ) {
89
+		while (list($id) = $this->db->fetchRow($result)) {
90 90
 			array_push($idarray, $id);
91 91
 		}
92 92
 		return $idarray;
93 93
 	}
94 94
 
95 95
 	//returns an array of ALL child ids for a given id($sel_id)
96
-	function getAllChildId($sel_id, $order="", $idarray = array())
96
+	function getAllChildId($sel_id, $order = "", $idarray = array())
97 97
 	{
98 98
 		$sql = "SELECT ".$this->id." FROM ".$this->table." WHERE ".$this->pid."=".$sel_id."";
99
-		if ( $order != "" ) {
99
+		if ($order != "") {
100 100
 			$sql .= " ORDER BY $order";
101 101
 		}
102
-		$result=$this->db->query($sql);
102
+		$result = $this->db->query($sql);
103 103
 		$count = $this->db->getRowsNum($result);
104
-		if ( $count==0 ) {
104
+		if ($count == 0) {
105 105
 			return $idarray;
106 106
 		}
107
-		while ( list($r_id) = $this->db->fetchRow($result) ) {
107
+		while (list($r_id) = $this->db->fetchRow($result)) {
108 108
 			array_push($idarray, $r_id);
109
-			$idarray = $this->getAllChildId($r_id,$order,$idarray);
109
+			$idarray = $this->getAllChildId($r_id, $order, $idarray);
110 110
 		}
111 111
 		return $idarray;
112 112
 	}
113 113
 
114 114
 	//returns an array of ALL parent ids for a given id($sel_id)
115
-	function getAllParentId($sel_id, $order="", $idarray = array())
115
+	function getAllParentId($sel_id, $order = "", $idarray = array())
116 116
 	{
117 117
 		$sql = "SELECT ".$this->pid." FROM ".$this->table." WHERE ".$this->id."=".$sel_id."";
118
-		if ( $order != "" ) {
118
+		if ($order != "") {
119 119
 			$sql .= " ORDER BY $order";
120 120
 		}
121
-		$result=$this->db->query($sql);
121
+		$result = $this->db->query($sql);
122 122
 		list($r_id) = $this->db->fetchRow($result);
123
-		if ( $r_id == 0 ) {
123
+		if ($r_id == 0) {
124 124
 			return $idarray;
125 125
 		}
126 126
 		array_push($idarray, $r_id);
127
-		$idarray = $this->getAllParentId($r_id,$order,$idarray);
127
+		$idarray = $this->getAllParentId($r_id, $order, $idarray);
128 128
 		return $idarray;
129 129
 	}
130 130
 
131 131
 	//generates path from the root id to a given id($sel_id)
132 132
 	// the path is delimetered with "/"
133
-	function getPathFromId($sel_id, $title, $path="")
133
+	function getPathFromId($sel_id, $title, $path = "")
134 134
 	{
135 135
 		$result = $this->db->query("SELECT ".$this->pid.", ".$title." FROM ".$this->table." WHERE ".$this->id."=$sel_id");
136
-		if ( $this->db->getRowsNum($result) == 0 ) {
136
+		if ($this->db->getRowsNum($result) == 0) {
137 137
 			return $path;
138 138
 		}
139
-		list($parentid,$name) = $this->db->fetchRow($result);
140
-		$myts =& MyTextSanitizer::getInstance();
139
+		list($parentid, $name) = $this->db->fetchRow($result);
140
+		$myts = & MyTextSanitizer::getInstance();
141 141
 		$name = $myts->makeTboxData4Show($name);
142 142
 		$path = "/".$name.$path."";
143
-		if ( $parentid == 0 ) {
143
+		if ($parentid == 0) {
144 144
 			return $path;
145 145
 		}
146 146
 		$path = $this->getPathFromId($parentid, $title, $path);
@@ -150,18 +150,18 @@  discard block
 block discarded – undo
150 150
 	//makes a nicely ordered selection box
151 151
 	//$preset_id is used to specify a preselected item
152 152
 	//set $none to 1 to add a option with value 0
153
-	function makeMySelBox($title, $order="",$preset_id=0, $none=0, $sel_name="", $onchange="", $multiple=0)
153
+	function makeMySelBox($title, $order = "", $preset_id = 0, $none = 0, $sel_name = "", $onchange = "", $multiple = 0)
154 154
 	{
155
-		if ( $sel_name == "" ) {
155
+		if ($sel_name == "") {
156 156
 			$sel_name = $this->id;
157 157
 		}
158
-		$myts =& MyTextSanitizer::getInstance();
158
+		$myts = & MyTextSanitizer::getInstance();
159 159
 		
160 160
 		$sql = "SELECT ".$this->id.", ".$title." FROM ".$this->table." WHERE ".$this->pid."=0";
161 161
 		if ($this->dirid != 0) {
162 162
 			$sql .= " AND dirid=$this->dirid";	
163 163
 		}
164
-		if ( $order != "" ) {
164
+		if ($order != "") {
165 165
 			$sql .= " ORDER BY $order";
166 166
 		}
167 167
 		//echo 'test';
@@ -169,29 +169,29 @@  discard block
 block discarded – undo
169 169
 		$result = $this->db->query($sql);
170 170
 		
171 171
 		echo "<select name='".$sel_name."'";
172
-		if ( $onchange != "" ) {
172
+		if ($onchange != "") {
173 173
 			echo " onchange='".$onchange."'";
174 174
 		}
175
-		if ( $multiple != 0 ) {
175
+		if ($multiple != 0) {
176 176
 			echo " multiple=\"multiple\"";
177 177
 		}
178 178
 		echo ">\n";
179 179
 		
180
-		if ( $none ) {
180
+		if ($none) {
181 181
 			echo "<option value='0'>----</option>\n";
182 182
 		}
183
-		while ( list($catid, $name) = $this->db->fetchRow($result) ) {
183
+		while (list($catid, $name) = $this->db->fetchRow($result)) {
184 184
 			$sel = "";
185
-			if ( $catid == $preset_id ) {
185
+			if ($catid == $preset_id) {
186 186
 				$sel = " selected='selected'";
187 187
 			}
188 188
 			echo "<option value='$catid'$sel>$name</option>\n";
189 189
 			$sel = "";
190 190
 			$arr = $this->getChildTreeArray($catid, $order);
191
-			foreach ( $arr as $option ) {
192
-				$option['prefix'] = str_replace(".","--",$option['prefix']);
191
+			foreach ($arr as $option) {
192
+				$option['prefix'] = str_replace(".", "--", $option['prefix']);
193 193
 				$catpath = $option['prefix']."&nbsp;".$myts->makeTboxData4Show($option[$title]);
194
-				if ( $option[$this->id] == $preset_id ) {
194
+				if ($option[$this->id] == $preset_id) {
195 195
 					$sel = " selected='selected'";
196 196
 				}
197 197
 				echo "<option value='".$option[$this->id]."'$sel>$catpath</option>\n";
@@ -202,18 +202,18 @@  discard block
 block discarded – undo
202 202
 	}
203 203
 
204 204
 	//generates nicely formatted linked path from the root id to a given id
205
-	function getNicePathFromId($sel_id, $title, $funcURL, $path="", $outputvar="catid")
205
+	function getNicePathFromId($sel_id, $title, $funcURL, $path = "", $outputvar = "catid")
206 206
 	{
207 207
 		$sql = "SELECT ".$this->pid.", ".$title." FROM ".$this->table." WHERE ".$this->id."=$sel_id";
208 208
 		$result = $this->db->query($sql);
209
-		if ( $this->db->getRowsNum($result) == 0 ) {
209
+		if ($this->db->getRowsNum($result) == 0) {
210 210
 			return $path;
211 211
 		}
212
-		list($parentid,$name) = $this->db->fetchRow($result);
213
-		$myts =& MyTextSanitizer::getInstance();
212
+		list($parentid, $name) = $this->db->fetchRow($result);
213
+		$myts = & MyTextSanitizer::getInstance();
214 214
 		$name = $myts->makeTboxData4Show($name);
215 215
 		$path = "<a href='".$funcURL."&".$outputvar."=".$sel_id."'>".$name."</a>&nbsp;:&nbsp;".$path."";
216
-		if ( $parentid == 0 ) {
216
+		if ($parentid == 0) {
217 217
 			return $path;
218 218
 		}
219 219
 		$path = $this->getNicePathFromId($parentid, $title, $funcURL, $path, $outputvar);
@@ -221,15 +221,15 @@  discard block
 block discarded – undo
221 221
 	}
222 222
 	
223 223
 	//generates nicely formatted path from the root id to a given id
224
-	function getUnformattedPathFromId($sel_id, $title, $path="")
224
+	function getUnformattedPathFromId($sel_id, $title, $path = "")
225 225
 	{
226 226
 		$sql = "SELECT ".$this->pid.", ".$title." FROM ".$this->table." WHERE ".$this->id."=$sel_id";
227 227
 		$result = $this->db->query($sql);
228
-		if ( $this->db->getRowsNum($result) == 0 ) {
228
+		if ($this->db->getRowsNum($result) == 0) {
229 229
 			return $path;
230 230
 		}
231
-		list($parentid,$name) = $this->db->fetchRow($result);
232
-		$myts =& MyTextSanitizer::getInstance();
231
+		list($parentid, $name) = $this->db->fetchRow($result);
232
+		$myts = & MyTextSanitizer::getInstance();
233 233
 		$name = $myts->makeTboxData4Show($name);
234 234
 		if ($path != "") {
235 235
 			$path = "".$name."&nbsp;:&nbsp;".$path."";
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 			$path = "".$name."";
238 238
 		}
239 239
 		
240
-		if ( $parentid == 0 ) {
240
+		if ($parentid == 0) {
241 241
 			return $path;
242 242
 		}
243 243
 		$path = $this->getUnformattedPathFromId($parentid, $title, $path);
@@ -246,54 +246,54 @@  discard block
 block discarded – undo
246 246
 
247 247
 	//generates id path from the root id to a given id
248 248
 	// the path is delimetered with "/"
249
-	function getIdPathFromId($sel_id, $path="")
249
+	function getIdPathFromId($sel_id, $path = "")
250 250
 	{
251 251
 		$result = $this->db->query("SELECT ".$this->pid." FROM ".$this->table." WHERE ".$this->id."=$sel_id");
252
-		if ( $this->db->getRowsNum($result) == 0 ) {
252
+		if ($this->db->getRowsNum($result) == 0) {
253 253
 			return $path;
254 254
 		}
255 255
 		list($parentid) = $this->db->fetchRow($result);
256 256
 		$path = "/".$sel_id.$path."";
257
-		if ( $parentid == 0 ) {
257
+		if ($parentid == 0) {
258 258
 			return $path;
259 259
 		}
260 260
 		$path = $this->getIdPathFromId($parentid, $path);
261 261
 		return $path;
262 262
 	}
263 263
 
264
-	function getAllChild($sel_id=0,$order="",$parray = array())
264
+	function getAllChild($sel_id = 0, $order = "", $parray = array())
265 265
 	{
266 266
 		$sql = "SELECT * FROM ".$this->table." WHERE ".$this->pid."=".$sel_id."";
267
-		if ( $order != "" ) {
267
+		if ($order != "") {
268 268
 			$sql .= " ORDER BY $order";
269 269
 		}
270 270
 		$result = $this->db->query($sql);
271 271
 		$count = $this->db->getRowsNum($result);
272
-		if ( $count == 0 ) {
272
+		if ($count == 0) {
273 273
 			return $parray;
274 274
 		}
275
-		while ( $row = $this->db->fetchArray($result) ) {
275
+		while ($row = $this->db->fetchArray($result)) {
276 276
 			array_push($parray, $row);
277
-			$parray=$this->getAllChild($row[$this->id],$order,$parray);
277
+			$parray = $this->getAllChild($row[$this->id], $order, $parray);
278 278
 		}
279 279
 		return $parray;
280 280
 	}
281 281
 
282
-	function getChildTreeArray($sel_id=0,$order="",$parray = array(),$r_prefix="")
282
+	function getChildTreeArray($sel_id = 0, $order = "", $parray = array(), $r_prefix = "")
283 283
 	{
284 284
 		$sql = "SELECT * FROM ".$this->table." WHERE ".$this->pid."=".$sel_id."";
285
-		if ( $order != "" ) {
285
+		if ($order != "") {
286 286
 			$sql .= " ORDER BY $order";
287 287
 		}
288 288
 		$result = $this->db->query($sql);
289 289
 		$count = $this->db->getRowsNum($result);
290
-		if ( $count == 0 ) {
290
+		if ($count == 0) {
291 291
 			return $parray;
292 292
 		}
293
-		while ( $row = $this->db->fetchArray($result) ) {
293
+		while ($row = $this->db->fetchArray($result)) {
294 294
 			$row['prefix'] = $r_prefix.".";
295 295
 			array_push($parray, $row);
296
-			$parray = $this->getChildTreeArray($row[$this->id],$order,$parray,$row['prefix']);
296
+			$parray = $this->getChildTreeArray($row[$this->id], $order, $parray, $row['prefix']);
297 297
 		}
298 298
 		return $parray;
299 299
 	}
Please login to merge, or discard this patch.
class/class.xdir.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -89,16 +89,16 @@
 block discarded – undo
89 89
 	function setCategories_xdir() {
90 90
 		$arr = array();
91 91
 		$sql = 'SELECT cid, pid, title, imgurl FROM '.$this->db->prefix("efqdiralpha1_xdir_cat");
92
-        $result = $this->db->query($sql);
93
-        if (!$result) {
94
-        	return false;
95
-        }
96
-        $numrows = $this->db->getRowsNum($result);
97
-        if ( $numrows > 0 ) {
98
-	        while (list($cid, $pid, $title, $imgurl) = $this->db->fetchRow($result)) {
92
+		$result = $this->db->query($sql);
93
+		if (!$result) {
94
+			return false;
95
+		}
96
+		$numrows = $this->db->getRowsNum($result);
97
+		if ( $numrows > 0 ) {
98
+			while (list($cid, $pid, $title, $imgurl) = $this->db->fetchRow($result)) {
99 99
 				$arr[] = array('cid'=>$cid,'pid'=>$pid,'title'=>$title,'imgurl'=>$imgurl);
100
-	        }
101
-	    } else {
100
+			}
101
+		} else {
102 102
 			return false;
103 103
 		}
104 104
 		$this->set_xdir_cats($arr);
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
         	return false;
95 95
         }
96 96
         $numrows = $this->db->getRowsNum($result);
97
-        if ( $numrows > 0 ) {
97
+        if ($numrows > 0) {
98 98
 	        while (list($cid, $pid, $title, $imgurl) = $this->db->fetchRow($result)) {
99
-				$arr[] = array('cid'=>$cid,'pid'=>$pid,'title'=>$title,'imgurl'=>$imgurl);
99
+				$arr[] = array('cid'=>$cid, 'pid'=>$pid, 'title'=>$title, 'imgurl'=>$imgurl);
100 100
 	        }
101 101
 	    } else {
102 102
 			return false;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		return true;
106 106
 	}
107 107
 	
108
-	function saveCategories($dirid=0) {
108
+	function saveCategories($dirid = 0) {
109 109
 		$tablename = "efqdiralpha1_cat";
110 110
 		$xdir_cats = $this->get_xdir_cats();
111 111
 		foreach ($xdir_cats as $xdir_cat) {
@@ -137,26 +137,26 @@  discard block
 block discarded – undo
137 137
 	 */
138 138
 	function createDataTypes() {
139 139
 		$datatype_handler = new efqDataTypeHandler();
140
-		$arr[] = array('title'=>_MD_XDIR_DTYPE_ADDRESS,'fieldtype'=>_MD_XDIR_FIELDTYPE_TEXTBOX);
141
-		$arr[] = array('title'=>_MD_XDIR_DTYPE_ADDRESS2,'fieldtype'=>_MD_XDIR_FIELDTYPE_TEXTBOX);
142
-		$arr[] = array('title'=>_MD_XDIR_DTYPE_CITY,'fieldtype'=>_MD_XDIR_FIELDTYPE_TEXTBOX);
143
-		$arr[] = array('title'=>_MD_XDIR_DTYPE_STATE,'fieldtype'=>_MD_XDIR_FIELDTYPE_TEXTBOX);
144
-		$arr[] = array('title'=>_MD_XDIR_DTYPE_ZIP,'fieldtype'=>_MD_XDIR_FIELDTYPE_TEXTBOX);
145
-		$arr[] = array('title'=>_MD_XDIR_DTYPE_COUNTRY,'fieldtype'=>_MD_XDIR_FIELDTYPE_TEXTBOX);
146
-		$arr[] = array('title'=>_MD_XDIR_DTYPE_PHONE,'fieldtype'=>_MD_XDIR_FIELDTYPE_TEXTBOX);
147
-		$arr[] = array('title'=>_MD_XDIR_DTYPE_FAX,'fieldtype'=>_MD_XDIR_FIELDTYPE_TEXTBOX);
148
-		$arr[] = array('title'=>_MD_XDIR_DTYPE_EMAIL,'fieldtype'=>_MD_XDIR_FIELDTYPE_EMAIL);
149
-		$arr[] = array('title'=>_MD_XDIR_DTYPE_URL,'fieldtype'=>_MD_XDIR_FIELDTYPE_URL);
140
+		$arr[] = array('title'=>_MD_XDIR_DTYPE_ADDRESS, 'fieldtype'=>_MD_XDIR_FIELDTYPE_TEXTBOX);
141
+		$arr[] = array('title'=>_MD_XDIR_DTYPE_ADDRESS2, 'fieldtype'=>_MD_XDIR_FIELDTYPE_TEXTBOX);
142
+		$arr[] = array('title'=>_MD_XDIR_DTYPE_CITY, 'fieldtype'=>_MD_XDIR_FIELDTYPE_TEXTBOX);
143
+		$arr[] = array('title'=>_MD_XDIR_DTYPE_STATE, 'fieldtype'=>_MD_XDIR_FIELDTYPE_TEXTBOX);
144
+		$arr[] = array('title'=>_MD_XDIR_DTYPE_ZIP, 'fieldtype'=>_MD_XDIR_FIELDTYPE_TEXTBOX);
145
+		$arr[] = array('title'=>_MD_XDIR_DTYPE_COUNTRY, 'fieldtype'=>_MD_XDIR_FIELDTYPE_TEXTBOX);
146
+		$arr[] = array('title'=>_MD_XDIR_DTYPE_PHONE, 'fieldtype'=>_MD_XDIR_FIELDTYPE_TEXTBOX);
147
+		$arr[] = array('title'=>_MD_XDIR_DTYPE_FAX, 'fieldtype'=>_MD_XDIR_FIELDTYPE_TEXTBOX);
148
+		$arr[] = array('title'=>_MD_XDIR_DTYPE_EMAIL, 'fieldtype'=>_MD_XDIR_FIELDTYPE_EMAIL);
149
+		$arr[] = array('title'=>_MD_XDIR_DTYPE_URL, 'fieldtype'=>_MD_XDIR_FIELDTYPE_URL);
150 150
 		foreach ($arr as $datatype) {
151 151
 			$objDataType = new efqFieldType;
152
-			$objDataType->setVar('title',$datatype['title']);
153
-			$objDataType->setVar('section',0);
154
-			$objDataType->setVar('uid',$xoopsUser->getVar('uid'));
155
-			$objDataType->setVar('defaultyn',1);
156
-			$objDataType->setVar('created',time());
157
-			$objDataType->setVar('activeyn',1);
158
-			$objDataType->setVar('fieldtypeid',$this->fieldtypes[$datatype['fieldtype']]);
159
-			$datatype_handler->insertDataType($objDataType,true);
152
+			$objDataType->setVar('title', $datatype['title']);
153
+			$objDataType->setVar('section', 0);
154
+			$objDataType->setVar('uid', $xoopsUser->getVar('uid'));
155
+			$objDataType->setVar('defaultyn', 1);
156
+			$objDataType->setVar('created', time());
157
+			$objDataType->setVar('activeyn', 1);
158
+			$objDataType->setVar('fieldtypeid', $this->fieldtypes[$datatype['fieldtype']]);
159
+			$datatype_handler->insertDataType($objDataType, true);
160 160
 			$datatypes[$datatype['title']] = $objDataType->getVar('dtypeid');
161 161
 		}
162 162
 	}
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
 	 */
174 174
 	function createFieldTypes() {
175 175
 		$fieldtype_handler = new efqFieldTypeHandler();
176
-		$arr[] = array('title'=>_MD_XDIR_FIELDTYPE_TEXTBOX,'fieldtype'=>'textbox');
177
-		$arr[] = array('title'=>_MD_XDIR_FIELDTYPE_EMAIL,'fieldtype'=>'email');
178
-		$arr[] = array('title'=>_MD_XDIR_FIELDTYPE_URL,'fieldtype'=>'url');
176
+		$arr[] = array('title'=>_MD_XDIR_FIELDTYPE_TEXTBOX, 'fieldtype'=>'textbox');
177
+		$arr[] = array('title'=>_MD_XDIR_FIELDTYPE_EMAIL, 'fieldtype'=>'email');
178
+		$arr[] = array('title'=>_MD_XDIR_FIELDTYPE_URL, 'fieldtype'=>'url');
179 179
 		foreach ($arr as $fieldtype) {
180 180
 			$objFieldtype = new efqFieldType;
181
-			$objFieldtype->setVar('title',$fieldtype['title']);
182
-			$objFieldtype->setVar('fieldtype',$fieldtype['fieldtype']);
183
-			$objFieldtype->setVar('dirid',$this->efq_dirid);
184
-			$fieldtype_handler->insertFieldType($objFieldtype,true);
181
+			$objFieldtype->setVar('title', $fieldtype['title']);
182
+			$objFieldtype->setVar('fieldtype', $fieldtype['fieldtype']);
183
+			$objFieldtype->setVar('dirid', $this->efq_dirid);
184
+			$fieldtype_handler->insertFieldType($objFieldtype, true);
185 185
 			$fieldtypes[$fieldtype['title']] = $objFieldtype->getVar('typeid');
186 186
 		}
187 187
 	}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 * 
197 197
 	 * @return	bool	true if insertion is succesful, false if unsuccesful
198 198
 	 */	
199
-	function doMigrate($dirid=0) {
199
+	function doMigrate($dirid = 0) {
200 200
 		$this->setCategories_xdir();
201 201
 		$this->saveCategories($this->efq_dirid);
202 202
 		$this->createFieldTypes();
Please login to merge, or discard this patch.
class/class.formdate.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
 	 * 
49 49
 	 * @param   array   $listing	Array with listing details
50 50
 	 */
51
-	function XoopsFormDate($caption, $name, $size = 15, $value='')
51
+	function XoopsFormDate($caption, $name, $size = 15, $value = '')
52 52
 	{
53 53
 		$this->XoopsFormElementTray($caption, '&nbsp;');
54 54
 		$datetime = getDate($value);
Please login to merge, or discard this patch.
class/class.directory.php 2 patches
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	{
47 47
 		global $moddir;
48 48
 		$this->db = Database::getInstance();
49
-	    $this->initVar('dirid', XOBJ_DTYPE_INT, null, false);
50
-	    $this->initVar('postfix', XOBJ_DTYPE_TXTBOX);
49
+		$this->initVar('dirid', XOBJ_DTYPE_INT, null, false);
50
+		$this->initVar('postfix', XOBJ_DTYPE_TXTBOX);
51 51
 		$this->initVar('open', XOBJ_DTYPE_INT, 0, false);
52 52
 		$this->initVar('name', XOBJ_DTYPE_TXTBOX);
53 53
 		$this->initVar('description', XOBJ_DTYPE_TXTAREA);
@@ -56,16 +56,16 @@  discard block
 block discarded – undo
56 56
 		
57 57
 		if ($directory != false) {
58 58
 			if (is_array($directory)) {
59
-                $this->assignVars($directory);
60
-            } else {
59
+				$this->assignVars($directory);
60
+			} else {
61 61
 				$directory_handler = xoops_getmodulehandler('directory', $moddir);
62
-                $objDirectory =& $directory_handler->get($directory);
63
-                foreach ($objDirectory->vars as $k => $v) {
64
-                    $this->assignVar($k, $v['value']);
65
-                }
66
-                unset($objDirectory);
67
-            }
68
-        }
62
+				$objDirectory =& $directory_handler->get($directory);
63
+				foreach ($objDirectory->vars as $k => $v) {
64
+					$this->assignVar($k, $v['value']);
65
+				}
66
+				unset($objDirectory);
67
+			}
68
+		}
69 69
 	}
70 70
 }
71 71
 
@@ -86,53 +86,53 @@  discard block
 block discarded – undo
86 86
 	}
87 87
 	
88 88
 	/**
89
-     * create instance of directory class or reset the existing instance.
90
-     * 
91
-     * @return object $directory
92
-     */
89
+	 * create instance of directory class or reset the existing instance.
90
+	 * 
91
+	 * @return object $directory
92
+	 */
93 93
 	function &create($isNew = true)
94
-    {
95
-        $directory = new efqDirectory();
96
-        if ($isNew) {
97
-            $directory->setNew();
98
-        }
99
-        return $directory;
100
-    }
94
+	{
95
+		$directory = new efqDirectory();
96
+		if ($isNew) {
97
+			$directory->setNew();
98
+		}
99
+		return $directory;
100
+	}
101 101
      
102
-    /**
103
-     * retrieve a directory
104
-     * 
105
-     * @param int $dirid ID of the directory
106
-     * @return mixed reference to the {@link efqDirectory} object, FALSE if failed
107
-     */
108
-    function &get($dirid = false) {
109
-        if ($dirid == false) {
110
-            return false;
111
-        }
112
-        $dirid = intval($dirid);
113
-        if ($dirid > 0) {
114
-            $sql = "SELECT * FROM ".$this->db->prefix("efqdiralpha1_dir")." WHERE dirid=".$dirid;
115
-            if (!$result = $this->db->query($sql)) {
116
-                return false;
117
-            }
118
-            $directory =& $this->create(false);
119
-            $directory->assignVars($this->db->fetchArray($result));
120
-            return $directory;
121
-        }
122
-        return false;
123
-    }
102
+	/**
103
+	 * retrieve a directory
104
+	 * 
105
+	 * @param int $dirid ID of the directory
106
+	 * @return mixed reference to the {@link efqDirectory} object, FALSE if failed
107
+	 */
108
+	function &get($dirid = false) {
109
+		if ($dirid == false) {
110
+			return false;
111
+		}
112
+		$dirid = intval($dirid);
113
+		if ($dirid > 0) {
114
+			$sql = "SELECT * FROM ".$this->db->prefix("efqdiralpha1_dir")." WHERE dirid=".$dirid;
115
+			if (!$result = $this->db->query($sql)) {
116
+				return false;
117
+			}
118
+			$directory =& $this->create(false);
119
+			$directory->assignVars($this->db->fetchArray($result));
120
+			return $directory;
121
+		}
122
+		return false;
123
+	}
124 124
      
125
-     /**
126
-     * retrieve all directories
127
-     * 
128
-     * @return mixed reference to the {@link efqDirectory} object, FALSE if failed
129
-     */
130
-    function &getAll() {
131
-        $sql = "SELECT dirid,postfix,open,name,descr,img FROM ".$this->db->prefix("efqdiralpha1_dir")."";
132
-        if (!$result = $this->db->query($sql)) {
133
-            return false;
134
-        }
135
-        while ( list($dirid,$postfix,$open,$name,$descr,$img) = $this->db->fetchRow($result) ) {
125
+	 /**
126
+	  * retrieve all directories
127
+	  * 
128
+	  * @return mixed reference to the {@link efqDirectory} object, FALSE if failed
129
+	  */
130
+	function &getAll() {
131
+		$sql = "SELECT dirid,postfix,open,name,descr,img FROM ".$this->db->prefix("efqdiralpha1_dir")."";
132
+		if (!$result = $this->db->query($sql)) {
133
+			return false;
134
+		}
135
+		while ( list($dirid,$postfix,$open,$name,$descr,$img) = $this->db->fetchRow($result) ) {
136 136
 			$arr[] = array('dirid' => $dirid,
137 137
 				'postfix' => $postfix,
138 138
 				'open' => $open,
@@ -140,76 +140,76 @@  discard block
 block discarded – undo
140 140
 				'descr' => $descr,
141 141
 				'img' => $img );
142 142
 		}
143
-        return $arr;
144
-    }
143
+		return $arr;
144
+	}
145 145
     
146 146
          
147
-    /**
148
-     * retrieve all directory ID's
149
-     * 
150
-     * @return array $idarray
151
-     */
152
-    function &getAllDirectoryIds($idarray = array()) {
153
-        $sql = "SELECT dirid FROM ".$this->db->prefix("efqdiralpha1_dir")."";
154
-        if (!$result = $this->db->query($sql)) {
155
-            return false;
156
-        }
157
-        while ( list($r_id) = $this->db->fetchRow($result) ) {
147
+	/**
148
+	 * retrieve all directory ID's
149
+	 * 
150
+	 * @return array $idarray
151
+	 */
152
+	function &getAllDirectoryIds($idarray = array()) {
153
+		$sql = "SELECT dirid FROM ".$this->db->prefix("efqdiralpha1_dir")."";
154
+		if (!$result = $this->db->query($sql)) {
155
+			return false;
156
+		}
157
+		while ( list($r_id) = $this->db->fetchRow($result) ) {
158 158
 			array_push($idarray, $r_id);
159 159
 		}
160
-        return $idarray;
161
-    }
160
+		return $idarray;
161
+	}
162 162
     
163
-    /**
164
-     * retrieve all directory ID's and titles as array
165
-     * 
166
-     * @return array $idarray
167
-     */
168
-    function &getAllDirectoryTitles($arr = array()) {
169
-        $sql = "SELECT dirid, name FROM ".$this->db->prefix("efqdiralpha1_dir")."";
170
-        if (!$result = $this->db->query($sql)) {
171
-            return false;
172
-        }
173
-        while ( list($r_id, $r_title) = $this->db->fetchRow($result) ) {
163
+	/**
164
+	 * retrieve all directory ID's and titles as array
165
+	 * 
166
+	 * @return array $idarray
167
+	 */
168
+	function &getAllDirectoryTitles($arr = array()) {
169
+		$sql = "SELECT dirid, name FROM ".$this->db->prefix("efqdiralpha1_dir")."";
170
+		if (!$result = $this->db->query($sql)) {
171
+			return false;
172
+		}
173
+		while ( list($r_id, $r_title) = $this->db->fetchRow($result) ) {
174 174
 			$result_arr[$r_id] = $r_title;
175 175
 			//array_push($arr, $result_arr);
176 176
 		}
177
-        return $result_arr;
178
-    }
177
+		return $result_arr;
178
+	}
179 179
     
180 180
     
181 181
 	
182 182
 	/**
183
-     * count number of directories and if count == 1, set directory.
184
-     * 
185
-     * @return mixed $result, FALSE if failed, 0 if count is 0.
186
-     */
183
+	 * count number of directories and if count == 1, set directory.
184
+	 * 
185
+	 * @return mixed $result, FALSE if failed, 0 if count is 0.
186
+	 */
187 187
 	function countAll()
188 188
 	{		
189 189
 		global $xoopsDB;
190
-	    $block = array();
190
+		$block = array();
191 191
 		$myts =& MyTextSanitizer::getInstance();
192 192
 		$dirid = 0;
193
-	    $result = $xoopsDB->query("SELECT dirid FROM ".$xoopsDB->prefix("efqdiralpha1_dir")."");
194
-	    $num_results = $xoopsDB->getRowsNum($result);
195
-	    if (!$result) {
196
-	        return false;
197
-	    } else if ($num_results == 0) {
198
-	    	return 0;
199
-	    } else if ($num_results == 1) {
200
-	    	$row = mysql_fetch_array($result);
201
-	        $dirid = $row['dirid'];
202
-	        return $dirid;
203
-	    } else {
204
-	    	return false;
205
-	    }
193
+		$result = $xoopsDB->query("SELECT dirid FROM ".$xoopsDB->prefix("efqdiralpha1_dir")."");
194
+		$num_results = $xoopsDB->getRowsNum($result);
195
+		if (!$result) {
196
+			return false;
197
+		} else if ($num_results == 0) {
198
+			return 0;
199
+		} else if ($num_results == 1) {
200
+			$row = mysql_fetch_array($result);
201
+			$dirid = $row['dirid'];
202
+			return $dirid;
203
+		} else {
204
+			return false;
205
+		}
206 206
 	}
207 207
 	
208 208
 	/**
209
-     * retrieve all directory ID's and names
210
-     * 
211
-     * @return array $array
212
-     */
209
+	 * retrieve all directory ID's and names
210
+	 * 
211
+	 * @return array $array
212
+	 */
213 213
 	function directoryArray($dashes = false) {
214 214
 		$sql = "SELECT dirid, name FROM ".$this->db->prefix("efqdiralpha1_dir")." ORDER BY name ASC";
215 215
 		$result = $this->db->query($sql);
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
                 $this->assignVars($directory);
60 60
             } else {
61 61
 				$directory_handler = xoops_getmodulehandler('directory', $moddir);
62
-                $objDirectory =& $directory_handler->get($directory);
62
+                $objDirectory = & $directory_handler->get($directory);
63 63
                 foreach ($objDirectory->vars as $k => $v) {
64 64
                     $this->assignVar($k, $v['value']);
65 65
                 }
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 {
83 83
 	function efqDirectoryHandler()
84 84
 	{
85
-		$this->db =& Database::getInstance();
85
+		$this->db = & Database::getInstance();
86 86
 	}
87 87
 	
88 88
 	/**
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             if (!$result = $this->db->query($sql)) {
116 116
                 return false;
117 117
             }
118
-            $directory =& $this->create(false);
118
+            $directory = & $this->create(false);
119 119
             $directory->assignVars($this->db->fetchArray($result));
120 120
             return $directory;
121 121
         }
@@ -132,13 +132,13 @@  discard block
 block discarded – undo
132 132
         if (!$result = $this->db->query($sql)) {
133 133
             return false;
134 134
         }
135
-        while ( list($dirid,$postfix,$open,$name,$descr,$img) = $this->db->fetchRow($result) ) {
135
+        while (list($dirid, $postfix, $open, $name, $descr, $img) = $this->db->fetchRow($result)) {
136 136
 			$arr[] = array('dirid' => $dirid,
137 137
 				'postfix' => $postfix,
138 138
 				'open' => $open,
139 139
 				'name' => $name,
140 140
 				'descr' => $descr,
141
-				'img' => $img );
141
+				'img' => $img);
142 142
 		}
143 143
         return $arr;
144 144
     }
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
         if (!$result = $this->db->query($sql)) {
155 155
             return false;
156 156
         }
157
-        while ( list($r_id) = $this->db->fetchRow($result) ) {
157
+        while (list($r_id) = $this->db->fetchRow($result)) {
158 158
 			array_push($idarray, $r_id);
159 159
 		}
160 160
         return $idarray;
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
         if (!$result = $this->db->query($sql)) {
171 171
             return false;
172 172
         }
173
-        while ( list($r_id, $r_title) = $this->db->fetchRow($result) ) {
173
+        while (list($r_id, $r_title) = $this->db->fetchRow($result)) {
174 174
 			$result_arr[$r_id] = $r_title;
175 175
 			//array_push($arr, $result_arr);
176 176
 		}
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	{		
189 189
 		global $xoopsDB;
190 190
 	    $block = array();
191
-		$myts =& MyTextSanitizer::getInstance();
191
+		$myts = & MyTextSanitizer::getInstance();
192 192
 		$dirid = 0;
193 193
 	    $result = $xoopsDB->query("SELECT dirid FROM ".$xoopsDB->prefix("efqdiralpha1_dir")."");
194 194
 	    $num_results = $xoopsDB->getRowsNum($result);
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 		if ($dashes != false) {
219 219
 			$arr = array('0' => '---');
220 220
 		}
221
-		while ( list($dirid, $dirname) = $this->db->fetchRow($result) ) {
221
+		while (list($dirid, $dirname) = $this->db->fetchRow($result)) {
222 222
 			$arr[$dirid] = $dirname;
223 223
 		}
224 224
 		return $arr;
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 * 
235 235
 	 * @return	bool	true if insertion is succesful, false if unsuccesful
236 236
 	 */	
237
-	function insertDirectory($obj, $forceQuery=false) {
237
+	function insertDirectory($obj, $forceQuery = false) {
238 238
 		$tablename = "efqdiralpha1_dir";
239 239
 		$keyName = "dirid";
240 240
 		$excludedVars = array();
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 		$strFields = "";
252 252
 		$strValues = "";
253 253
 		foreach ($cleanvars as $k => $v) {
254
-			if ( !in_array($k, $excludedVars) ) {
254
+			if (!in_array($k, $excludedVars)) {
255 255
 				$strFields .= $k;
256 256
 				$strValues .= "'".$v."'";
257 257
 				if ($i < $countVars) {
Please login to merge, or discard this patch.
class/class.uploader.php 2 patches
Indentation   +326 added lines, -326 removed lines patch added patch discarded remove patch
@@ -85,99 +85,99 @@  discard block
 block discarded – undo
85 85
 class XoopsMediaUploader
86 86
 {
87 87
 	/**
88
-	* Flag indicating if unrecognized mimetypes should be allowed (use with precaution ! may lead to security issues )
89
-	**/
88
+	 * Flag indicating if unrecognized mimetypes should be allowed (use with precaution ! may lead to security issues )
89
+	 **/
90 90
  	var $allowUnknownTypes = false;
91 91
 
92
-    var $mediaName;
93
-    var $mediaType;
94
-    var $mediaSize;
95
-    var $mediaTmpName;
96
-    var $mediaError;
97
-    var $mediaRealType = '';
92
+	var $mediaName;
93
+	var $mediaType;
94
+	var $mediaSize;
95
+	var $mediaTmpName;
96
+	var $mediaError;
97
+	var $mediaRealType = '';
98 98
 
99
-    var $uploadDir = '';
99
+	var $uploadDir = '';
100 100
 
101
-    var $allowedMimeTypes = array();
101
+	var $allowedMimeTypes = array();
102 102
 
103
-    var $maxFileSize = 0;
104
-    var $maxWidth;
105
-    var $maxHeight;
103
+	var $maxFileSize = 0;
104
+	var $maxWidth;
105
+	var $maxHeight;
106 106
 
107
-    var $targetFileName;
107
+	var $targetFileName;
108 108
 
109
-    var $prefix;
109
+	var $prefix;
110 110
 
111
-    var $errors = array();
111
+	var $errors = array();
112 112
 
113
-    var $savedDestination;
113
+	var $savedDestination;
114 114
 
115
-    var $savedFileName;
115
+	var $savedFileName;
116 116
 
117 117
 	var $extensionToMime = array();
118
-    /**
119
-     * Constructor
120
-     *
121
-     * @param   string  $uploadDir
122
-     * @param   array   $allowedMimeTypes
123
-     * @param   int     $maxFileSize
124
-     * @param   int     $maxWidth
125
-     * @param   int     $maxHeight
126
-     * @param   int     $cmodvalue
127
-     **/
128
-    function XoopsMediaUploader($uploadDir, $allowedMimeTypes, $maxFileSize=0, $maxWidth=null, $maxHeight=null)
129
-    {
118
+	/**
119
+	 * Constructor
120
+	 *
121
+	 * @param   string  $uploadDir
122
+	 * @param   array   $allowedMimeTypes
123
+	 * @param   int     $maxFileSize
124
+	 * @param   int     $maxWidth
125
+	 * @param   int     $maxHeight
126
+	 * @param   int     $cmodvalue
127
+	 **/
128
+	function XoopsMediaUploader($uploadDir, $allowedMimeTypes, $maxFileSize=0, $maxWidth=null, $maxHeight=null)
129
+	{
130 130
 		@$this->extensionToMime = include( XOOPS_ROOT_PATH . '/class/mimetypes.inc.php' );
131 131
 		if ( !is_array( $this->extensionToMime ) ) {
132 132
 		 	$this->extensionToMime = array();
133 133
 			return false;
134 134
 		}
135
-        if (is_array($allowedMimeTypes)) {
136
-            $this->allowedMimeTypes =& $allowedMimeTypes;
137
-        }
138
-        $this->uploadDir = $uploadDir;
139
-        $this->maxFileSize = intval($maxFileSize);
140
-        if(isset($maxWidth)) {
141
-            $this->maxWidth = intval($maxWidth);
142
-        }
143
-        if(isset($maxHeight)) {
144
-            $this->maxHeight = intval($maxHeight);
145
-        }
146
-    }
135
+		if (is_array($allowedMimeTypes)) {
136
+			$this->allowedMimeTypes =& $allowedMimeTypes;
137
+		}
138
+		$this->uploadDir = $uploadDir;
139
+		$this->maxFileSize = intval($maxFileSize);
140
+		if(isset($maxWidth)) {
141
+			$this->maxWidth = intval($maxWidth);
142
+		}
143
+		if(isset($maxHeight)) {
144
+			$this->maxHeight = intval($maxHeight);
145
+		}
146
+	}
147 147
 
148
-    /**
149
-     * Fetch the uploaded file
150
-     *
151
-     * @param   string  $media_name Name of the file field
152
-     * @param   int     $index      Index of the file (if more than one uploaded under that name)
153
-     * @return  bool
154
-     **/
155
-    function fetchMedia($media_name, $index = null)
156
-    {
148
+	/**
149
+	 * Fetch the uploaded file
150
+	 *
151
+	 * @param   string  $media_name Name of the file field
152
+	 * @param   int     $index      Index of the file (if more than one uploaded under that name)
153
+	 * @return  bool
154
+	 **/
155
+	function fetchMedia($media_name, $index = null)
156
+	{
157 157
 		if ( empty( $this->extensionToMime ) ) {
158 158
 			$this->setErrors( 'Error loading mimetypes definition' );
159 159
 			return false;
160 160
 		}
161 161
 		if (!isset($_FILES[$media_name])) {
162
-            $this->setErrors('File not found');
162
+			$this->setErrors('File not found');
163 163
 			//echo " - no such file ";
164
-            return false;
165
-        } elseif (is_array($_FILES[$media_name]['name']) && isset($index)) {
166
-            $index = intval($index);
167
-            $this->mediaName = (get_magic_quotes_gpc()) ? stripslashes($_FILES[$media_name]['name'][$index]) : $_FILES[$media_name]['name'][$index];
168
-            $this->mediaType = $_FILES[$media_name]['type'][$index];
169
-            $this->mediaSize = $_FILES[$media_name]['size'][$index];
170
-            $this->mediaTmpName = $_FILES[$media_name]['tmp_name'][$index];
171
-            $this->mediaError = !empty($_FILES[$media_name]['error'][$index]) ? $_FILES[$media_name]['errir'][$index] : 0;
172
-        } else {
173
-            $media_name =& $_FILES[$media_name];
164
+			return false;
165
+		} elseif (is_array($_FILES[$media_name]['name']) && isset($index)) {
166
+			$index = intval($index);
167
+			$this->mediaName = (get_magic_quotes_gpc()) ? stripslashes($_FILES[$media_name]['name'][$index]) : $_FILES[$media_name]['name'][$index];
168
+			$this->mediaType = $_FILES[$media_name]['type'][$index];
169
+			$this->mediaSize = $_FILES[$media_name]['size'][$index];
170
+			$this->mediaTmpName = $_FILES[$media_name]['tmp_name'][$index];
171
+			$this->mediaError = !empty($_FILES[$media_name]['error'][$index]) ? $_FILES[$media_name]['errir'][$index] : 0;
172
+		} else {
173
+			$media_name =& $_FILES[$media_name];
174 174
 			$this->mediaName = (get_magic_quotes_gpc()) ? stripslashes($media_name['name']) : $media_name['name'];
175
-            $this->mediaName = $media_name['name'];
176
-            $this->mediaType = $media_name['type'];
177
-            $this->mediaSize = $media_name['size'];
178
-            $this->mediaTmpName = $media_name['tmp_name'];
179
-            $this->mediaError = !empty($media_name['error']) ? $media_name['error'] : 0;
180
-        }
175
+			$this->mediaName = $media_name['name'];
176
+			$this->mediaType = $media_name['type'];
177
+			$this->mediaSize = $media_name['size'];
178
+			$this->mediaTmpName = $media_name['tmp_name'];
179
+			$this->mediaError = !empty($media_name['error']) ? $media_name['error'] : 0;
180
+		}
181 181
 		if ( ($ext = strrpos( $this->mediaName, '.' )) !== false ) {
182 182
 			$ext = substr( $this->mediaName, $ext + 1 );
183 183
 			if ( isset( $this->extensionToMime[$ext] ) ) {
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 				//trigger_error( "XoopsMediaUploader: Set mediaRealType to {$this->mediaRealType} (file extension is $ext)", E_USER_NOTICE );
186 186
 			}
187 187
 		}
188
-        $this->errors = array();
188
+		$this->errors = array();
189 189
 		if ( $ext && in_array( $ext, array( 'gif', 'jpg', 'jpeg', 'png', 'bmp', 'xbm' ) ) ) {
190 190
 	   		// Prevent sending of invalid images that would crash IE
191 191
 			if ( ! ( $info = getimagesize( $this->mediaTmpName ) ) ) {
@@ -193,258 +193,258 @@  discard block
 block discarded – undo
193 193
 				return false;
194 194
 			}
195 195
 		}
196
-        if (intval($this->mediaSize) < 0) {
197
-            $this->setErrors('Invalid File Size');
198
-            return false;
199
-        }
200
-        if ($this->mediaName == '') {
201
-            $this->setErrors('Filename Is Empty');
202
-            return false;
203
-        }
204
-        if ($this->mediaTmpName == 'none' || !is_uploaded_file($this->mediaTmpName)) {
205
-            $this->setErrors('No file uploaded');
206
-            return false;
207
-        }
208
-        if ($this->mediaError > 0) {
209
-            $this->setErrors('Error occurred: Error #'.$this->mediaError);
210
-            return false;
211
-        }
212
-        return true;
213
-    }
196
+		if (intval($this->mediaSize) < 0) {
197
+			$this->setErrors('Invalid File Size');
198
+			return false;
199
+		}
200
+		if ($this->mediaName == '') {
201
+			$this->setErrors('Filename Is Empty');
202
+			return false;
203
+		}
204
+		if ($this->mediaTmpName == 'none' || !is_uploaded_file($this->mediaTmpName)) {
205
+			$this->setErrors('No file uploaded');
206
+			return false;
207
+		}
208
+		if ($this->mediaError > 0) {
209
+			$this->setErrors('Error occurred: Error #'.$this->mediaError);
210
+			return false;
211
+		}
212
+		return true;
213
+	}
214 214
 
215
-    /**
216
-     * Set the target filename
217
-     * 
218
-     * @param   string  $value
219
-     **/
220
-    function setTargetFileName($value){
221
-        $this->targetFileName = strval(trim($value));
222
-    }
215
+	/**
216
+	 * Set the target filename
217
+	 * 
218
+	 * @param   string  $value
219
+	 **/
220
+	function setTargetFileName($value){
221
+		$this->targetFileName = strval(trim($value));
222
+	}
223 223
 
224
-    /**
225
-     * Set the prefix
226
-     * 
227
-     * @param   string  $value
228
-     **/
229
-    function setPrefix($value){
230
-        $this->prefix = strval(trim($value));
231
-    }
224
+	/**
225
+	 * Set the prefix
226
+	 * 
227
+	 * @param   string  $value
228
+	 **/
229
+	function setPrefix($value){
230
+		$this->prefix = strval(trim($value));
231
+	}
232 232
 
233
-    /**
234
-     * Get the uploaded filename
235
-     * 
236
-     * @return  string 
237
-     **/
238
-    function getMediaName()
239
-    {
240
-        return $this->mediaName;
241
-    }
233
+	/**
234
+	 * Get the uploaded filename
235
+	 * 
236
+	 * @return  string 
237
+	 **/
238
+	function getMediaName()
239
+	{
240
+		return $this->mediaName;
241
+	}
242 242
 
243
-    /**
244
-     * Get the type of the uploaded file
245
-     * 
246
-     * @return  string 
247
-     **/
248
-    function getMediaType()
249
-    {
250
-        return $this->mediaType;
251
-    }
243
+	/**
244
+	 * Get the type of the uploaded file
245
+	 * 
246
+	 * @return  string 
247
+	 **/
248
+	function getMediaType()
249
+	{
250
+		return $this->mediaType;
251
+	}
252 252
 
253
-    /**
254
-     * Get the size of the uploaded file
255
-     * 
256
-     * @return  int 
257
-     **/
258
-    function getMediaSize()
259
-    {
260
-        return $this->mediaSize;
261
-    }
253
+	/**
254
+	 * Get the size of the uploaded file
255
+	 * 
256
+	 * @return  int 
257
+	 **/
258
+	function getMediaSize()
259
+	{
260
+		return $this->mediaSize;
261
+	}
262 262
 
263
-    /**
264
-     * Get the temporary name that the uploaded file was stored under
265
-     * 
266
-     * @return  string 
267
-     **/
268
-    function getMediaTmpName()
269
-    {
270
-        return $this->mediaTmpName;
271
-    }
263
+	/**
264
+	 * Get the temporary name that the uploaded file was stored under
265
+	 * 
266
+	 * @return  string 
267
+	 **/
268
+	function getMediaTmpName()
269
+	{
270
+		return $this->mediaTmpName;
271
+	}
272 272
 
273
-    /**
274
-     * Get the saved filename
275
-     * 
276
-     * @return  string 
277
-     **/
278
-    function getSavedFileName(){
279
-        return $this->savedFileName;
280
-    }
273
+	/**
274
+	 * Get the saved filename
275
+	 * 
276
+	 * @return  string 
277
+	 **/
278
+	function getSavedFileName(){
279
+		return $this->savedFileName;
280
+	}
281 281
 
282
-    /**
283
-     * Get the destination the file is saved to
284
-     * 
285
-     * @return  string
286
-     **/
287
-    function getSavedDestination(){
288
-        return $this->savedDestination;
289
-    }
282
+	/**
283
+	 * Get the destination the file is saved to
284
+	 * 
285
+	 * @return  string
286
+	 **/
287
+	function getSavedDestination(){
288
+		return $this->savedDestination;
289
+	}
290 290
 
291
-    /**
292
-     * Check the file and copy it to the destination
293
-     * 
294
-     * @return  bool
295
-     **/
296
-    function upload($chmod = 0644)
297
-    {
298
-        if ($this->uploadDir == '') {
299
-            $this->setErrors('Upload directory not set');
300
-            return false;
301
-        }
302
-        if (!is_dir($this->uploadDir)) {
303
-            $this->setErrors('Failed opening directory: '.$this->uploadDir);
304
-        }
305
-        if (!is_writeable($this->uploadDir)) {
306
-            $this->setErrors('Failed opening directory with write permission: '.$this->uploadDir);
307
-        }
308
-        if (!$this->checkMaxFileSize()) {
309
-            $this->setErrors('File size too large: '.$this->mediaSize);
310
-        }
311
-        if (!$this->checkMaxWidth()) {
312
-            $this->setErrors(sprintf('File width must be smaller than %u', $this->maxWidth));
313
-        }
314
-        if (!$this->checkMaxHeight()) {
315
-            $this->setErrors(sprintf('File height must be smaller than %u', $this->maxHeight));
316
-        }
317
-        if (!$this->checkMimeType()) {
318
-            $this->setErrors('MIME type not allowed: '.$this->mediaType);
319
-        }
320
-        if (count($this->errors) > 0) {
321
-            return false;
322
-        }
323
-        if (!$this->_copyFile($chmod)) {
324
-            $this->setErrors('Failed uploading file: '.$this->mediaName);
325
-            return false;
326
-        }
327
-        return true;
328
-    }
291
+	/**
292
+	 * Check the file and copy it to the destination
293
+	 * 
294
+	 * @return  bool
295
+	 **/
296
+	function upload($chmod = 0644)
297
+	{
298
+		if ($this->uploadDir == '') {
299
+			$this->setErrors('Upload directory not set');
300
+			return false;
301
+		}
302
+		if (!is_dir($this->uploadDir)) {
303
+			$this->setErrors('Failed opening directory: '.$this->uploadDir);
304
+		}
305
+		if (!is_writeable($this->uploadDir)) {
306
+			$this->setErrors('Failed opening directory with write permission: '.$this->uploadDir);
307
+		}
308
+		if (!$this->checkMaxFileSize()) {
309
+			$this->setErrors('File size too large: '.$this->mediaSize);
310
+		}
311
+		if (!$this->checkMaxWidth()) {
312
+			$this->setErrors(sprintf('File width must be smaller than %u', $this->maxWidth));
313
+		}
314
+		if (!$this->checkMaxHeight()) {
315
+			$this->setErrors(sprintf('File height must be smaller than %u', $this->maxHeight));
316
+		}
317
+		if (!$this->checkMimeType()) {
318
+			$this->setErrors('MIME type not allowed: '.$this->mediaType);
319
+		}
320
+		if (count($this->errors) > 0) {
321
+			return false;
322
+		}
323
+		if (!$this->_copyFile($chmod)) {
324
+			$this->setErrors('Failed uploading file: '.$this->mediaName);
325
+			return false;
326
+		}
327
+		return true;
328
+	}
329 329
 
330
-    /**
331
-     * Copy the file to its destination
332
-     * 
333
-     * @return  bool 
334
-     **/
335
-    function _copyFile($chmod)
336
-    {
337
-        $matched = array();
338
-        if (!preg_match("/\.([a-zA-Z0-9]+)$/", $this->mediaName, $matched)) {
339
-            return false;
340
-        }
341
-        if (isset($this->targetFileName)) {
342
-            $this->savedFileName = $this->targetFileName;
343
-        } elseif (isset($this->prefix)) {
344
-            $this->savedFileName = uniqid($this->prefix).'.'.strtolower($matched[1]);
345
-        } else {
346
-            $this->savedFileName = strtolower($this->mediaName);
347
-        }
348
-        $this->savedDestination = $this->uploadDir.'/'.$this->savedFileName;
349
-        if (!move_uploaded_file($this->mediaTmpName, $this->savedDestination)) {
350
-            return false;
351
-        }
352
-        @chmod($this->savedDestination, $chmod);
353
-        return true;
354
-    }
330
+	/**
331
+	 * Copy the file to its destination
332
+	 * 
333
+	 * @return  bool 
334
+	 **/
335
+	function _copyFile($chmod)
336
+	{
337
+		$matched = array();
338
+		if (!preg_match("/\.([a-zA-Z0-9]+)$/", $this->mediaName, $matched)) {
339
+			return false;
340
+		}
341
+		if (isset($this->targetFileName)) {
342
+			$this->savedFileName = $this->targetFileName;
343
+		} elseif (isset($this->prefix)) {
344
+			$this->savedFileName = uniqid($this->prefix).'.'.strtolower($matched[1]);
345
+		} else {
346
+			$this->savedFileName = strtolower($this->mediaName);
347
+		}
348
+		$this->savedDestination = $this->uploadDir.'/'.$this->savedFileName;
349
+		if (!move_uploaded_file($this->mediaTmpName, $this->savedDestination)) {
350
+			return false;
351
+		}
352
+		@chmod($this->savedDestination, $chmod);
353
+		return true;
354
+	}
355 355
 
356
-    /**
357
-     * Is the file the right size?
358
-     * 
359
-     * @return  bool 
360
-     **/
361
-    function checkMaxFileSize()
362
-    {
363
-        if ($this->mediaSize > $this->maxFileSize) {
364
-            return false;
365
-        }
366
-        return true;
367
-    }
356
+	/**
357
+	 * Is the file the right size?
358
+	 * 
359
+	 * @return  bool 
360
+	 **/
361
+	function checkMaxFileSize()
362
+	{
363
+		if ($this->mediaSize > $this->maxFileSize) {
364
+			return false;
365
+		}
366
+		return true;
367
+	}
368 368
 
369
-    /**
370
-     * Is the picture the right width?
371
-     * 
372
-     * @return  bool 
373
-     **/
374
-    function checkMaxWidth()
375
-    {
376
-        if (!isset($this->maxWidth)) {
377
-            return true;
378
-        }
379
-        if (false !== $dimension = getimagesize($this->mediaTmpName)) {
380
-            if ($dimension[0] > $this->maxWidth) {
381
-                return false;
382
-            }
369
+	/**
370
+	 * Is the picture the right width?
371
+	 * 
372
+	 * @return  bool 
373
+	 **/
374
+	function checkMaxWidth()
375
+	{
376
+		if (!isset($this->maxWidth)) {
377
+			return true;
378
+		}
379
+		if (false !== $dimension = getimagesize($this->mediaTmpName)) {
380
+			if ($dimension[0] > $this->maxWidth) {
381
+				return false;
382
+			}
383 383
 			//$result = $dimension[0];
384 384
 			//$this->width = $result;
385
-        } else {
386
-            trigger_error(sprintf('Failed fetching image size of %s, skipping max width check..', $this->mediaTmpName), E_USER_WARNING);
387
-        }
388
-        return true;
389
-    }
385
+		} else {
386
+			trigger_error(sprintf('Failed fetching image size of %s, skipping max width check..', $this->mediaTmpName), E_USER_WARNING);
387
+		}
388
+		return true;
389
+	}
390 390
 
391 391
 	function getWidth()
392
-    {
393
-        //$filename = $imgloc."/";
392
+	{
393
+		//$filename = $imgloc."/";
394 394
 		$filename = $this->uploadDir."/";
395 395
 		$filename .= $this->savedFileName;
396 396
 		if (false !== $dimension = getimagesize($filename)) {
397
-            if ($dimension[0] > 0) {
398
-                $result = $dimension[0];
399
-            }
400
-        } else {
401
-            trigger_error(sprintf('Failed fetching image size of %s, image width unknown..', $this->mediaTmpName), E_USER_WARNING);
402
-        }
403
-        return $result;
404
-    }
397
+			if ($dimension[0] > 0) {
398
+				$result = $dimension[0];
399
+			}
400
+		} else {
401
+			trigger_error(sprintf('Failed fetching image size of %s, image width unknown..', $this->mediaTmpName), E_USER_WARNING);
402
+		}
403
+		return $result;
404
+	}
405 405
 	
406 406
 	function getHeight()
407
-    {
408
-        //$filename = $imgloc."/";
407
+	{
408
+		//$filename = $imgloc."/";
409 409
 		$filename = $this->uploadDir."/";
410 410
 		$filename .= $this->savedFileName;
411 411
 		if (false !== $dimension = getimagesize($filename)) {
412
-            if ($dimension[1] > 0) {
413
-                $result = $dimension[1];
414
-            }
415
-        } else {
416
-            trigger_error(sprintf('Failed fetching image size of %s, image height unknown..', $this->mediaTmpName), E_USER_WARNING);
417
-        }
418
-        return $result;
419
-    }
412
+			if ($dimension[1] > 0) {
413
+				$result = $dimension[1];
414
+			}
415
+		} else {
416
+			trigger_error(sprintf('Failed fetching image size of %s, image height unknown..', $this->mediaTmpName), E_USER_WARNING);
417
+		}
418
+		return $result;
419
+	}
420 420
 	
421
-    /**
422
-     * Is the picture the right height?
423
-     * 
424
-     * @return  bool 
425
-     **/
426
-    function checkMaxHeight()
427
-    {
428
-        if (!isset($this->maxHeight)) {
429
-            return true;
430
-        }
431
-        if (false !== $dimension = getimagesize($this->mediaTmpName)) {
432
-            if ($dimension[1] > $this->maxHeight) {
433
-                return false;
434
-            }
435
-        } else {
436
-            trigger_error(sprintf('Failed fetching image size of %s, skipping max height check..', $this->mediaTmpName), E_USER_WARNING);
437
-        }
438
-        return true;
439
-    }
421
+	/**
422
+	 * Is the picture the right height?
423
+	 * 
424
+	 * @return  bool 
425
+	 **/
426
+	function checkMaxHeight()
427
+	{
428
+		if (!isset($this->maxHeight)) {
429
+			return true;
430
+		}
431
+		if (false !== $dimension = getimagesize($this->mediaTmpName)) {
432
+			if ($dimension[1] > $this->maxHeight) {
433
+				return false;
434
+			}
435
+		} else {
436
+			trigger_error(sprintf('Failed fetching image size of %s, skipping max height check..', $this->mediaTmpName), E_USER_WARNING);
437
+		}
438
+		return true;
439
+	}
440 440
 
441
-    /**
442
-     * Check whether or not the uploaded file type is allowed
443
-     *
444
-     * @return  bool
445
-     **/
446
-    function checkMimeType()
447
-    {
441
+	/**
442
+	 * Check whether or not the uploaded file type is allowed
443
+	 *
444
+	 * @return  bool
445
+	 **/
446
+	function checkMimeType()
447
+	{
448 448
 		if ( empty( $this->mediaRealType ) && !$this->allowUnknownTypes ) {
449 449
 			$this->setErrors( 'Unknown filetype rejected' );
450 450
 			return false;
@@ -453,37 +453,37 @@  discard block
 block discarded – undo
453 453
 		return ( empty($this->allowedMimeTypes) || in_array($this->mediaRealType, $this->allowedMimeTypes) );
454 454
 	}
455 455
 
456
-    /**
457
-     * Add an error
458
-     * 
459
-     * @param   string  $error
460
-     **/
461
-    function setErrors($error)
462
-    {
463
-        $this->errors[] = trim($error);
464
-    }
456
+	/**
457
+	 * Add an error
458
+	 * 
459
+	 * @param   string  $error
460
+	 **/
461
+	function setErrors($error)
462
+	{
463
+		$this->errors[] = trim($error);
464
+	}
465 465
 
466
-    /**
467
-     * Get generated errors
468
-     *
469
-     * @param    bool    $ashtml Format using HTML?
470
-     * 
471
-     * @return    array|string    Array of array messages OR HTML string
472
-     */
473
-    function &getErrors($ashtml = true)
474
-    {
475
-        if (!$ashtml) {
476
-            return $this->errors;
477
-        } else {
478
-            $ret = '';
479
-            if (count($this->errors) > 0) {
480
-                $ret = '<h4>Errors Returned While Uploading</h4>';
481
-                foreach ($this->errors as $error) {
482
-                    $ret .= $error.'<br />';
483
-                }
484
-            }
485
-            return $ret;
486
-        }
487
-    }
466
+	/**
467
+	 * Get generated errors
468
+	 *
469
+	 * @param    bool    $ashtml Format using HTML?
470
+	 * 
471
+	 * @return    array|string    Array of array messages OR HTML string
472
+	 */
473
+	function &getErrors($ashtml = true)
474
+	{
475
+		if (!$ashtml) {
476
+			return $this->errors;
477
+		} else {
478
+			$ret = '';
479
+			if (count($this->errors) > 0) {
480
+				$ret = '<h4>Errors Returned While Uploading</h4>';
481
+				foreach ($this->errors as $error) {
482
+					$ret .= $error.'<br />';
483
+				}
484
+			}
485
+			return $ret;
486
+		}
487
+	}
488 488
 }
489 489
 ?>
490 490
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -125,22 +125,22 @@  discard block
 block discarded – undo
125 125
      * @param   int     $maxHeight
126 126
      * @param   int     $cmodvalue
127 127
      **/
128
-    function XoopsMediaUploader($uploadDir, $allowedMimeTypes, $maxFileSize=0, $maxWidth=null, $maxHeight=null)
128
+    function XoopsMediaUploader($uploadDir, $allowedMimeTypes, $maxFileSize = 0, $maxWidth = null, $maxHeight = null)
129 129
     {
130
-		@$this->extensionToMime = include( XOOPS_ROOT_PATH . '/class/mimetypes.inc.php' );
131
-		if ( !is_array( $this->extensionToMime ) ) {
130
+		@$this->extensionToMime = include(XOOPS_ROOT_PATH.'/class/mimetypes.inc.php');
131
+		if (!is_array($this->extensionToMime)) {
132 132
 		 	$this->extensionToMime = array();
133 133
 			return false;
134 134
 		}
135 135
         if (is_array($allowedMimeTypes)) {
136
-            $this->allowedMimeTypes =& $allowedMimeTypes;
136
+            $this->allowedMimeTypes = & $allowedMimeTypes;
137 137
         }
138 138
         $this->uploadDir = $uploadDir;
139 139
         $this->maxFileSize = intval($maxFileSize);
140
-        if(isset($maxWidth)) {
140
+        if (isset($maxWidth)) {
141 141
             $this->maxWidth = intval($maxWidth);
142 142
         }
143
-        if(isset($maxHeight)) {
143
+        if (isset($maxHeight)) {
144 144
             $this->maxHeight = intval($maxHeight);
145 145
         }
146 146
     }
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
      **/
155 155
     function fetchMedia($media_name, $index = null)
156 156
     {
157
-		if ( empty( $this->extensionToMime ) ) {
158
-			$this->setErrors( 'Error loading mimetypes definition' );
157
+		if (empty($this->extensionToMime)) {
158
+			$this->setErrors('Error loading mimetypes definition');
159 159
 			return false;
160 160
 		}
161 161
 		if (!isset($_FILES[$media_name])) {
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
             $this->mediaTmpName = $_FILES[$media_name]['tmp_name'][$index];
171 171
             $this->mediaError = !empty($_FILES[$media_name]['error'][$index]) ? $_FILES[$media_name]['errir'][$index] : 0;
172 172
         } else {
173
-            $media_name =& $_FILES[$media_name];
173
+            $media_name = & $_FILES[$media_name];
174 174
 			$this->mediaName = (get_magic_quotes_gpc()) ? stripslashes($media_name['name']) : $media_name['name'];
175 175
             $this->mediaName = $media_name['name'];
176 176
             $this->mediaType = $media_name['type'];
@@ -178,18 +178,18 @@  discard block
 block discarded – undo
178 178
             $this->mediaTmpName = $media_name['tmp_name'];
179 179
             $this->mediaError = !empty($media_name['error']) ? $media_name['error'] : 0;
180 180
         }
181
-		if ( ($ext = strrpos( $this->mediaName, '.' )) !== false ) {
182
-			$ext = substr( $this->mediaName, $ext + 1 );
183
-			if ( isset( $this->extensionToMime[$ext] ) ) {
181
+		if (($ext = strrpos($this->mediaName, '.')) !== false) {
182
+			$ext = substr($this->mediaName, $ext + 1);
183
+			if (isset($this->extensionToMime[$ext])) {
184 184
 				$this->mediaRealType = $this->extensionToMime[$ext];
185 185
 				//trigger_error( "XoopsMediaUploader: Set mediaRealType to {$this->mediaRealType} (file extension is $ext)", E_USER_NOTICE );
186 186
 			}
187 187
 		}
188 188
         $this->errors = array();
189
-		if ( $ext && in_array( $ext, array( 'gif', 'jpg', 'jpeg', 'png', 'bmp', 'xbm' ) ) ) {
189
+		if ($ext && in_array($ext, array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'xbm'))) {
190 190
 	   		// Prevent sending of invalid images that would crash IE
191
-			if ( ! ( $info = getimagesize( $this->mediaTmpName ) ) ) {
192
-				$this->setErrors( 'Invalid file content' );
191
+			if (!($info = getimagesize($this->mediaTmpName))) {
192
+				$this->setErrors('Invalid file content');
193 193
 				return false;
194 194
 			}
195 195
 		}
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
      * 
218 218
      * @param   string  $value
219 219
      **/
220
-    function setTargetFileName($value){
220
+    function setTargetFileName($value) {
221 221
         $this->targetFileName = strval(trim($value));
222 222
     }
223 223
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
      * 
227 227
      * @param   string  $value
228 228
      **/
229
-    function setPrefix($value){
229
+    function setPrefix($value) {
230 230
         $this->prefix = strval(trim($value));
231 231
     }
232 232
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
      * 
276 276
      * @return  string 
277 277
      **/
278
-    function getSavedFileName(){
278
+    function getSavedFileName() {
279 279
         return $this->savedFileName;
280 280
     }
281 281
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
      * 
285 285
      * @return  string
286 286
      **/
287
-    function getSavedDestination(){
287
+    function getSavedDestination() {
288 288
         return $this->savedDestination;
289 289
     }
290 290
 
@@ -445,12 +445,12 @@  discard block
 block discarded – undo
445 445
      **/
446 446
     function checkMimeType()
447 447
     {
448
-		if ( empty( $this->mediaRealType ) && !$this->allowUnknownTypes ) {
449
-			$this->setErrors( 'Unknown filetype rejected' );
448
+		if (empty($this->mediaRealType) && !$this->allowUnknownTypes) {
449
+			$this->setErrors('Unknown filetype rejected');
450 450
 			return false;
451 451
 		}
452 452
 
453
-		return ( empty($this->allowedMimeTypes) || in_array($this->mediaRealType, $this->allowedMimeTypes) );
453
+		return (empty($this->allowedMimeTypes) || in_array($this->mediaRealType, $this->allowedMimeTypes));
454 454
 	}
455 455
 
456 456
     /**
Please login to merge, or discard this patch.
class/class.listingdata.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
51 51
 		// class constructor;
52 52
 		//$this->setCurrentUser();		
53 53
 		$this->initVar('dataid', XOBJ_DTYPE_INT, 0, true);
54
-        $this->initVar('itemid', XOBJ_DTYPE_INT, 0, true);
55
-        $this->initVar('dtypeid', XOBJ_DTYPE_INT, 0, true);
56
-        $this->initVar('itemid', XOBJ_DTYPE_INT, 0, true);
57
-        $this->initVar('value', XOBJ_DTYPE_TXTAREA, null, false);
58
-        $this->initVar('created', XOBJ_DTYPE_INT, 0, true); 
59
-        $this->initVar('customtitle', XOBJ_DTYPE_TXTBOX, null, false, 255);
54
+		$this->initVar('itemid', XOBJ_DTYPE_INT, 0, true);
55
+		$this->initVar('dtypeid', XOBJ_DTYPE_INT, 0, true);
56
+		$this->initVar('itemid', XOBJ_DTYPE_INT, 0, true);
57
+		$this->initVar('value', XOBJ_DTYPE_TXTAREA, null, false);
58
+		$this->initVar('created', XOBJ_DTYPE_INT, 0, true); 
59
+		$this->initVar('customtitle', XOBJ_DTYPE_TXTBOX, null, false, 255);
60 60
 	}
61 61
 		
62 62
 	//Set variable $_updated to true of false (default)
@@ -110,19 +110,19 @@  discard block
 block discarded – undo
110 110
 	{
111 111
 		$arr = array();
112 112
 		$sql = "SELECT DISTINCT t.dtypeid, t.title, t.section, f.typeid, f.fieldtype, f.ext, t.options, d.dataid, d.itemid, d.value, d.created, t.custom ";
113
-	    $sql .= "FROM ".$this->db->prefix("efqdiralpha1_item_x_cat")." ic, ".$this->db->
114
-	        prefix("efqdiralpha1_dtypes_x_cat")." xc, ".$this->db->prefix("efqdiralpha1_fieldtypes")." f, ".$this->db->prefix("efqdiralpha1_dtypes")." t ";
115
-	    $sql .= "LEFT JOIN ".$this->db->prefix("efqdiralpha1_data") .
116
-	        " d ON (t.dtypeid=d.dtypeid AND d.itemid=".$itemid.") ";
117
-	    $sql .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=".$itemid."";
118
-	    $data_result = $this->db->query($sql) or $eh->show("0013");
119
-	    while (list($dtypeid, $title, $section, $ftypeid, $fieldtype, $ext, $options, $dataid, $itemid, $value, $created, $custom) = $this->db->fetchRow($data_result)) {
120
-	    	$arr[] = array('dtypeid'=>$dtypeid, 'title'=>$title, 'section'=>$section,
113
+		$sql .= "FROM ".$this->db->prefix("efqdiralpha1_item_x_cat")." ic, ".$this->db->
114
+			prefix("efqdiralpha1_dtypes_x_cat")." xc, ".$this->db->prefix("efqdiralpha1_fieldtypes")." f, ".$this->db->prefix("efqdiralpha1_dtypes")." t ";
115
+		$sql .= "LEFT JOIN ".$this->db->prefix("efqdiralpha1_data") .
116
+			" d ON (t.dtypeid=d.dtypeid AND d.itemid=".$itemid.") ";
117
+		$sql .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=".$itemid."";
118
+		$data_result = $this->db->query($sql) or $eh->show("0013");
119
+		while (list($dtypeid, $title, $section, $ftypeid, $fieldtype, $ext, $options, $dataid, $itemid, $value, $created, $custom) = $this->db->fetchRow($data_result)) {
120
+			$arr[] = array('dtypeid'=>$dtypeid, 'title'=>$title, 'section'=>$section,
121 121
 				'ftypeid'=>$ftypeid, 'fieldtype'=>$fieldtype, 'ext'=>$ext,
122 122
 				'options'=>$options, 'dataid' => $dataid, 'itemid'=>$itemid,
123 123
 				'value'=>$value, 'created'=>$created, 'customtitle'=>$custom);
124
-	    }
125
-	    return $arr;
124
+		}
125
+		return $arr;
126 126
 	}
127 127
 
128 128
 	
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
 	}
61 61
 		
62 62
 	//Set variable $_updated to true of false (default)
63
-	function setUpdated($set=false) {
63
+	function setUpdated($set = false) {
64 64
 		$this->_updated = $set;
65 65
 	}
66 66
 	
67 67
 	//Set variable $_inserted to true of false (default)
68
-	function setInserted($set=false) {
68
+	function setInserted($set = false) {
69 69
 		$this->_inserted = $set;
70 70
 	}
71 71
 	
@@ -102,17 +102,17 @@  discard block
 block discarded – undo
102 102
 	{
103 103
 		//Instantiate class
104 104
 		global $eh;
105
-		$this->db =& XoopsDatabaseFactory::getDatabaseConnection();
105
+		$this->db = & XoopsDatabaseFactory::getDatabaseConnection();
106 106
 		$this->errorhandler = $eh;
107 107
 	}
108 108
 	
109
-	function getData($itemid=0)
109
+	function getData($itemid = 0)
110 110
 	{
111 111
 		$arr = array();
112 112
 		$sql = "SELECT DISTINCT t.dtypeid, t.title, t.section, f.typeid, f.fieldtype, f.ext, t.options, d.dataid, d.itemid, d.value, d.created, t.custom ";
113 113
 	    $sql .= "FROM ".$this->db->prefix("efqdiralpha1_item_x_cat")." ic, ".$this->db->
114 114
 	        prefix("efqdiralpha1_dtypes_x_cat")." xc, ".$this->db->prefix("efqdiralpha1_fieldtypes")." f, ".$this->db->prefix("efqdiralpha1_dtypes")." t ";
115
-	    $sql .= "LEFT JOIN ".$this->db->prefix("efqdiralpha1_data") .
115
+	    $sql .= "LEFT JOIN ".$this->db->prefix("efqdiralpha1_data").
116 116
 	        " d ON (t.dtypeid=d.dtypeid AND d.itemid=".$itemid.") ";
117 117
 	    $sql .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=".$itemid."";
118 118
 	    $data_result = $this->db->query($sql) or $eh->show("0013");
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 * 
137 137
 	 * @return	bool	true if update is succesful, false if unsuccesful
138 138
 	 */
139
-	function updateListingData($obj, $forceQuery=false) {
139
+	function updateListingData($obj, $forceQuery = false) {
140 140
 		$tablename = "efqdiralpha1_data";
141 141
 		$keyName = "dataid";
142 142
 		if ($obj instanceof efqListingData) {
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 * 
183 183
 	 * @return	bool	true if insertion is succesful, false if unsuccesful
184 184
 	 */
185
-	function insertListingData($obj, $forceQuery=false) {
185
+	function insertListingData($obj, $forceQuery = false) {
186 186
 		$tablename = "efqdiralpha1_data";
187 187
 		$keyName = "dataid";
188 188
 		if ($obj instanceof efqListingData) {
Please login to merge, or discard this patch.