@@ -14,6 +14,9 @@ discard block |
||
14 | 14 | * ****************************************************************************** */ |
15 | 15 | |
16 | 16 | //Fix postgres queries |
17 | +/** |
|
18 | + * @param integer $debug |
|
19 | + */ |
|
17 | 20 | function fixPostgresQuery($query, $log, $debug) |
18 | 21 | { |
19 | 22 | // First select the query fields from the remaining query |
@@ -115,6 +118,9 @@ discard block |
||
115 | 118 | } |
116 | 119 | |
117 | 120 | //return an expanded table field list |
121 | +/** |
|
122 | + * @param string $table |
|
123 | + */ |
|
118 | 124 | function expandRecord($table, $log) |
119 | 125 | { |
120 | 126 | $result = ""; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | if ($debug) |
73 | 73 | $log->info("fixPostgresQuery result: " . $query); |
74 | 74 | |
75 | - return( $query); |
|
75 | + return($query); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | // Postgres8 will not accept a "tablename.*" entry in the GROUP BY clause |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | if ($expanded != '') |
112 | 112 | $expanded = " GROUP BY " . trim($expanded, ","); |
113 | 113 | //return the expanded fieldlist |
114 | - return( $expanded); |
|
114 | + return($expanded); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | //return an expanded table field list |
@@ -195,5 +195,5 @@ discard block |
||
195 | 195 | $result = substr($result, 0, strlen($result) - 1); |
196 | 196 | |
197 | 197 | //return out new string |
198 | - return( $result); |
|
198 | + return($result); |
|
199 | 199 | } |
@@ -22,8 +22,9 @@ discard block |
||
22 | 22 | $groupClause = ""; |
23 | 23 | $orderClause = ""; |
24 | 24 | |
25 | - if ($debug) |
|
26 | - $log->info("fixPostgresQuery: " . $query); |
|
25 | + if ($debug) { |
|
26 | + $log->info("fixPostgresQuery: " . $query); |
|
27 | + } |
|
27 | 28 | |
28 | 29 | // If we already have an order or group cluase separate ist for later use |
29 | 30 | if (stripos($queryRecord, 'GROUP BY') > 0) { |
@@ -45,32 +46,36 @@ discard block |
||
45 | 46 | $privateGroupList = []; |
46 | 47 | $token = strtok($queryFields, ", () "); |
47 | 48 | while ($token !== false) { |
48 | - if (strpos($token, ".") !== false) |
|
49 | - array_push($privateGroupList, $token); |
|
49 | + if (strpos($token, ".") !== false) { |
|
50 | + array_push($privateGroupList, $token); |
|
51 | + } |
|
50 | 52 | $token = strtok(", () "); |
51 | 53 | } |
52 | 54 | sort($privateGroupList); |
53 | 55 | $groupFields = ""; |
54 | 56 | $last = ""; |
55 | 57 | for ($i = 0; $i < count($privateGroupList); $i++) { |
56 | - if ($last != $privateGroupList[$i]) |
|
57 | - if ($groupFields == "") |
|
58 | + if ($last != $privateGroupList[$i]) { |
|
59 | + if ($groupFields == "") |
|
58 | 60 | $groupFields = $privateGroupList[$i]; |
59 | - else |
|
60 | - $groupFields .= "," . $privateGroupList[$i]; |
|
61 | + } else { |
|
62 | + $groupFields .= "," . $privateGroupList[$i]; |
|
63 | + } |
|
61 | 64 | $last = $privateGroupList[$i]; |
62 | 65 | } |
63 | 66 | |
64 | 67 | // Rebuild the query |
65 | 68 | $query = sprintf("SELECT %s%s", $queryFields, $queryRecord); |
66 | - if ($groupClause != "") |
|
67 | - $groupClause = $groupClause . "," . $groupFields; |
|
68 | - else |
|
69 | - $groupClause = $groupFields; |
|
69 | + if ($groupClause != "") { |
|
70 | + $groupClause = $groupClause . "," . $groupFields; |
|
71 | + } else { |
|
72 | + $groupClause = $groupFields; |
|
73 | + } |
|
70 | 74 | $query .= expandStar($groupClause, $log) . " " . $orderClause; |
71 | 75 | |
72 | - if ($debug) |
|
73 | - $log->info("fixPostgresQuery result: " . $query); |
|
76 | + if ($debug) { |
|
77 | + $log->info("fixPostgresQuery result: " . $query); |
|
78 | + } |
|
74 | 79 | |
75 | 80 | return( $query); |
76 | 81 | } |
@@ -94,22 +99,25 @@ discard block |
||
94 | 99 | $subfield = substr($field, $pos + 1, strlen($field) - $pos); |
95 | 100 | |
96 | 101 | //do we need to expand? |
97 | - if ($subfield == "*") |
|
98 | - $field = expandRecord($table, $log); |
|
102 | + if ($subfield == "*") { |
|
103 | + $field = expandRecord($table, $log); |
|
104 | + } |
|
99 | 105 | } |
100 | 106 | |
101 | 107 | //add the propably expanded field to the querylist |
102 | - if ($expanded == "") |
|
103 | - $expanded = $field; |
|
104 | - else |
|
105 | - $expanded .= "," . $field; |
|
108 | + if ($expanded == "") { |
|
109 | + $expanded = $field; |
|
110 | + } else { |
|
111 | + $expanded .= "," . $field; |
|
112 | + } |
|
106 | 113 | } |
107 | 114 | |
108 | 115 | //next field |
109 | 116 | $field = strtok(","); |
110 | 117 | } |
111 | - if ($expanded != '') |
|
112 | - $expanded = " GROUP BY " . trim($expanded, ","); |
|
118 | + if ($expanded != '') { |
|
119 | + $expanded = " GROUP BY " . trim($expanded, ","); |
|
120 | + } |
|
113 | 121 | //return the expanded fieldlist |
114 | 122 | return( $expanded); |
115 | 123 | } |
@@ -122,68 +130,84 @@ discard block |
||
122 | 130 | $subfields = []; |
123 | 131 | |
124 | 132 | //vtiger_products table |
125 | - if ($table == "vtiger_products") |
|
126 | - $subfields = array("productid", "productname", "productcode", "productcategory", "manufacturer", "qty_per_unit", "unit_price", "weight", "pack_size", "sales_start_date", "sales_end_date", "start_date", "expiry_date", "cost_factor", "commissionrate", "commissionmethod", "discontinued", "usageunit", "currency", "reorderlevel", "website", "taxclass", "mfr_part_no", "vendor_part_no", "serialno", "qtyinstock", "productsheet", "qtyindemand", "glacct", "vendor_id", "imagename"); |
|
133 | + if ($table == "vtiger_products") { |
|
134 | + $subfields = array("productid", "productname", "productcode", "productcategory", "manufacturer", "qty_per_unit", "unit_price", "weight", "pack_size", "sales_start_date", "sales_end_date", "start_date", "expiry_date", "cost_factor", "commissionrate", "commissionmethod", "discontinued", "usageunit", "currency", "reorderlevel", "website", "taxclass", "mfr_part_no", "vendor_part_no", "serialno", "qtyinstock", "productsheet", "qtyindemand", "glacct", "vendor_id", "imagename"); |
|
135 | + } |
|
127 | 136 | |
128 | 137 | //vtiger_activity table |
129 | - elseif ($table == "vtiger_activity") |
|
130 | - $subfields = array("activityid", "subject", "semodule", "activitytype", "date_start", "due_date", "time_start", "time_end", "sendnotification", "duration_hours", "duration_minutes", "status", "eventstatus", "priority", "location", "notime", "visibility", "recurringtype"); |
|
138 | + elseif ($table == "vtiger_activity") { |
|
139 | + $subfields = array("activityid", "subject", "semodule", "activitytype", "date_start", "due_date", "time_start", "time_end", "sendnotification", "duration_hours", "duration_minutes", "status", "eventstatus", "priority", "location", "notime", "visibility", "recurringtype"); |
|
140 | + } |
|
131 | 141 | |
132 | 142 | //vtiger_notes table |
133 | - elseif ($table == "vtiger_notes") |
|
134 | - $subfields = array("notesid", "contact_id", "title", "filename", "notecontent"); |
|
143 | + elseif ($table == "vtiger_notes") { |
|
144 | + $subfields = array("notesid", "contact_id", "title", "filename", "notecontent"); |
|
145 | + } |
|
135 | 146 | |
136 | 147 | //vtiger_faq table |
137 | - elseif ($table == "vtiger_faq") |
|
138 | - $subfields = array("id", "product_id", "question", "answer", "category", "status"); |
|
148 | + elseif ($table == "vtiger_faq") { |
|
149 | + $subfields = array("id", "product_id", "question", "answer", "category", "status"); |
|
150 | + } |
|
139 | 151 | |
140 | 152 | //vtiger_profile2field |
141 | - elseif ($table == "vtiger_profile2field") |
|
142 | - $subfields = array("profileid", "tabid", "fieldid", "visible", "readonly"); |
|
153 | + elseif ($table == "vtiger_profile2field") { |
|
154 | + $subfields = array("profileid", "tabid", "fieldid", "visible", "readonly"); |
|
155 | + } |
|
143 | 156 | |
144 | 157 | //vtiger_field |
145 | - elseif ($table == "vtiger_field") |
|
146 | - $subfields = array("tabid", "fieldid", "columnname", "tablename", "generatedtype", "uitype", "fieldname", "fieldlabel", "readonly", "presence", "selected", "maximumlength", "sequence", "block", "displaytype", "typeofdata", "quickcreate", "quickcreatesequence", "info_type"); |
|
158 | + elseif ($table == "vtiger_field") { |
|
159 | + $subfields = array("tabid", "fieldid", "columnname", "tablename", "generatedtype", "uitype", "fieldname", "fieldlabel", "readonly", "presence", "selected", "maximumlength", "sequence", "block", "displaytype", "typeofdata", "quickcreate", "quickcreatesequence", "info_type"); |
|
160 | + } |
|
147 | 161 | |
148 | 162 | //vtiger_producttaxrel |
149 | - elseif ($table == "vtiger_producttaxrel") |
|
150 | - $subfields = array("productid", "taxid", "taxpercentage"); |
|
163 | + elseif ($table == "vtiger_producttaxrel") { |
|
164 | + $subfields = array("productid", "taxid", "taxpercentage"); |
|
165 | + } |
|
151 | 166 | |
152 | 167 | //vtiger_inventorytaxinfo |
153 | - elseif ($table == "vtiger_inventorytaxinfo") |
|
154 | - $subfields = array("taxid", "taxname", "taxlabel", "percentage", "deleted"); |
|
168 | + elseif ($table == "vtiger_inventorytaxinfo") { |
|
169 | + $subfields = array("taxid", "taxname", "taxlabel", "percentage", "deleted"); |
|
170 | + } |
|
155 | 171 | |
156 | 172 | //vtiger_role2picklist |
157 | - elseif ($table == "vtiger_role2picklist") |
|
158 | - $subfields = array("roleid", "picklistid", "sortid"); |
|
173 | + elseif ($table == "vtiger_role2picklist") { |
|
174 | + $subfields = array("roleid", "picklistid", "sortid"); |
|
175 | + } |
|
159 | 176 | |
160 | 177 | //vtiger_contactdetails |
161 | - elseif ($table == "vtiger_contactdetails") |
|
162 | - $subfields = array("lastname", "contactid", "accountid", "salutation", "firstname", "email", "phone", "mobile", "title", "department", "fax", "reportsto", "training", "usertype", "contacttype", "otheremail", "yahooid", "donotcall", "emailoptout", "imagename", "reference", "notify_owner"); |
|
178 | + elseif ($table == "vtiger_contactdetails") { |
|
179 | + $subfields = array("lastname", "contactid", "accountid", "salutation", "firstname", "email", "phone", "mobile", "title", "department", "fax", "reportsto", "training", "usertype", "contacttype", "otheremail", "yahooid", "donotcall", "emailoptout", "imagename", "reference", "notify_owner"); |
|
180 | + } |
|
163 | 181 | |
164 | 182 | //vtiger_crmentity |
165 | - elseif ($table == "vtiger_crmentity") |
|
166 | - $subfields = array("crmid", "smcreatorid", "smownerid", "modifiedby", "setype", "description", "createdtime", "modifiedtime", "viewedtime", "status", "version", "presence", "deleted"); |
|
183 | + elseif ($table == "vtiger_crmentity") { |
|
184 | + $subfields = array("crmid", "smcreatorid", "smownerid", "modifiedby", "setype", "description", "createdtime", "modifiedtime", "viewedtime", "status", "version", "presence", "deleted"); |
|
185 | + } |
|
167 | 186 | |
168 | 187 | //vtiger_seactivityrel |
169 | - elseif ($table == "vtiger_seactivityrel") |
|
170 | - $subfields = array("crmid", "activityid"); |
|
188 | + elseif ($table == "vtiger_seactivityrel") { |
|
189 | + $subfields = array("crmid", "activityid"); |
|
190 | + } |
|
171 | 191 | |
172 | 192 | //vtiger_cntactivityrel |
173 | - elseif ($table == "vtiger_cntactivityrel") |
|
174 | - $subfields = array("contactid", "activityid"); |
|
193 | + elseif ($table == "vtiger_cntactivityrel") { |
|
194 | + $subfields = array("contactid", "activityid"); |
|
195 | + } |
|
175 | 196 | |
176 | 197 | //vtiger_leaddetails |
177 | - elseif ($table == "vtiger_leaddetails") |
|
178 | - $subfields = array("leadid", "email", "interest", "firstname", "salutation", "lastname", "company", "annualrevenue", "industry", "campaign", "rating", "leadstatus", "leadsource", "converted", "designation", "space", "comments", "priority", "demorequest", "partnercontact", "productversion", "product", "maildate", "nextstepdate", "fundingsituation", "purpose", "evaluationstatus", "transferdate", "revenuetype", "noofemployees", "yahooid", "assignleadchk"); |
|
198 | + elseif ($table == "vtiger_leaddetails") { |
|
199 | + $subfields = array("leadid", "email", "interest", "firstname", "salutation", "lastname", "company", "annualrevenue", "industry", "campaign", "rating", "leadstatus", "leadsource", "converted", "designation", "space", "comments", "priority", "demorequest", "partnercontact", "productversion", "product", "maildate", "nextstepdate", "fundingsituation", "purpose", "evaluationstatus", "transferdate", "revenuetype", "noofemployees", "yahooid", "assignleadchk"); |
|
200 | + } |
|
179 | 201 | |
180 | 202 | //vtiger_pricebook |
181 | - elseif ($table == "vtiger_pricebook") |
|
182 | - $subfields = array("pricebookid", "bookname", "active", "description"); |
|
203 | + elseif ($table == "vtiger_pricebook") { |
|
204 | + $subfields = array("pricebookid", "bookname", "active", "description"); |
|
205 | + } |
|
183 | 206 | |
184 | 207 | //fields of the requested array still undefined |
185 | - else |
|
186 | - $log->info("function expandRecord: please add structural information for table '" . $table . "'"); |
|
208 | + else { |
|
209 | + $log->info("function expandRecord: please add structural information for table '" . $table . "'"); |
|
210 | + } |
|
187 | 211 | |
188 | 212 | //construct an entity string |
189 | 213 | for ($i = 0; $i < count($subfields); $i++) { |
@@ -191,8 +215,9 @@ discard block |
||
191 | 215 | } |
192 | 216 | |
193 | 217 | //remove the trailiung , |
194 | - if (strlen($result) > 0) |
|
195 | - $result = substr($result, 0, strlen($result) - 1); |
|
218 | + if (strlen($result) > 0) { |
|
219 | + $result = substr($result, 0, strlen($result) - 1); |
|
220 | + } |
|
196 | 221 | |
197 | 222 | //return out new string |
198 | 223 | return( $result); |
@@ -390,6 +390,9 @@ discard block |
||
390 | 390 | return false; |
391 | 391 | } |
392 | 392 | |
393 | + /** |
|
394 | + * @param string[] $names |
|
395 | + */ |
|
393 | 396 | public function focusColumnValues($names, $delimeter = "\n") |
394 | 397 | { |
395 | 398 | if (!is_array($names)) { |
@@ -414,6 +417,9 @@ discard block |
||
414 | 417 | return $defvalue; |
415 | 418 | } |
416 | 419 | |
420 | + /** |
|
421 | + * @param string $id |
|
422 | + */ |
|
417 | 423 | public function resolveReferenceLabel($id, $module = false) |
418 | 424 | { |
419 | 425 | if (empty($id)) { |
@@ -448,6 +454,9 @@ discard block |
||
448 | 454 | return $currencyField->getDisplayValue(null, true); |
449 | 455 | } |
450 | 456 | |
457 | + /** |
|
458 | + * @param string $value |
|
459 | + */ |
|
451 | 460 | public function formatDate($value) |
452 | 461 | { |
453 | 462 | return DateTimeField::convertToUserFormat($value); |
@@ -148,7 +148,7 @@ |
||
148 | 148 | $subProducts = $productLineItem["subProductArray{$productLineItemIndex}"]; |
149 | 149 | if ($subProducts != '') { |
150 | 150 | foreach ($subProducts as $subProduct) { |
151 | - $productName .="\n" . " - " . decode_html($subProduct); |
|
151 | + $productName .= "\n" . " - " . decode_html($subProduct); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | $contentModel->set('Name', $productName); |
@@ -83,8 +83,9 @@ discard block |
||
83 | 83 | |
84 | 84 | public function Output($filename, $type) |
85 | 85 | { |
86 | - if (is_null($this->focus)) |
|
87 | - return; |
|
86 | + if (is_null($this->focus)) { |
|
87 | + return; |
|
88 | + } |
|
88 | 89 | |
89 | 90 | $pdfgenerator = $this->getPDFGenerator(); |
90 | 91 | |
@@ -256,24 +257,32 @@ discard block |
||
256 | 257 | |
257 | 258 | $addressValues = []; |
258 | 259 | $addressValues[] = $resultrow['address']; |
259 | - if (!empty($resultrow['city'])) |
|
260 | - $addressValues[] = "\n" . $resultrow['city']; |
|
261 | - if (!empty($resultrow['state'])) |
|
262 | - $addressValues[] = "," . $resultrow['state']; |
|
263 | - if (!empty($resultrow['code'])) |
|
264 | - $addressValues[] = $resultrow['code']; |
|
265 | - if (!empty($resultrow['country'])) |
|
266 | - $addressValues[] = "\n" . $resultrow['country']; |
|
260 | + if (!empty($resultrow['city'])) { |
|
261 | + $addressValues[] = "\n" . $resultrow['city']; |
|
262 | + } |
|
263 | + if (!empty($resultrow['state'])) { |
|
264 | + $addressValues[] = "," . $resultrow['state']; |
|
265 | + } |
|
266 | + if (!empty($resultrow['code'])) { |
|
267 | + $addressValues[] = $resultrow['code']; |
|
268 | + } |
|
269 | + if (!empty($resultrow['country'])) { |
|
270 | + $addressValues[] = "\n" . $resultrow['country']; |
|
271 | + } |
|
267 | 272 | |
268 | 273 | $additionalCompanyInfo = []; |
269 | - if (!empty($resultrow['phone'])) |
|
270 | - $additionalCompanyInfo[] = "\n" . \includes\Language::translate("Phone: ", $this->moduleName) . $resultrow['phone']; |
|
271 | - if (!empty($resultrow['fax'])) |
|
272 | - $additionalCompanyInfo[] = "\n" . \includes\Language::translate("Fax: ", $this->moduleName) . $resultrow['fax']; |
|
273 | - if (!empty($resultrow['website'])) |
|
274 | - $additionalCompanyInfo[] = "\n" . \includes\Language::translate("Website: ", $this->moduleName) . $resultrow['website']; |
|
275 | - if (!empty($resultrow['vatid'])) |
|
276 | - $additionalCompanyInfo[] = "\n" . \includes\Language::translate("VAT ID: ", $this->moduleName) . $resultrow['vatid']; |
|
274 | + if (!empty($resultrow['phone'])) { |
|
275 | + $additionalCompanyInfo[] = "\n" . \includes\Language::translate("Phone: ", $this->moduleName) . $resultrow['phone']; |
|
276 | + } |
|
277 | + if (!empty($resultrow['fax'])) { |
|
278 | + $additionalCompanyInfo[] = "\n" . \includes\Language::translate("Fax: ", $this->moduleName) . $resultrow['fax']; |
|
279 | + } |
|
280 | + if (!empty($resultrow['website'])) { |
|
281 | + $additionalCompanyInfo[] = "\n" . \includes\Language::translate("Website: ", $this->moduleName) . $resultrow['website']; |
|
282 | + } |
|
283 | + if (!empty($resultrow['vatid'])) { |
|
284 | + $additionalCompanyInfo[] = "\n" . \includes\Language::translate("VAT ID: ", $this->moduleName) . $resultrow['vatid']; |
|
285 | + } |
|
277 | 286 | |
278 | 287 | $modelColumnLeft = array( |
279 | 288 | 'logo' => "storage/Logo/" . $resultrow['logoname'], |
@@ -430,8 +439,9 @@ discard block |
||
430 | 439 | { |
431 | 440 | $valueString = ''; |
432 | 441 | foreach ($values as $value) { |
433 | - if (empty($value)) |
|
434 | - continue; |
|
442 | + if (empty($value)) { |
|
443 | + continue; |
|
444 | + } |
|
435 | 445 | $valueString .= $value . $delimeter; |
436 | 446 | } |
437 | 447 | return rtrim($valueString, $delimeter); |
@@ -98,7 +98,7 @@ |
||
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Function to get the class name of a given Component, of given Type, for a given Module |
101 | - * @param <String> $componentType |
|
101 | + * @param string $componentType |
|
102 | 102 | * @param <String> $componentName |
103 | 103 | * @param <String> $moduleName |
104 | 104 | * @return <String> Required Class Name |
@@ -124,8 +124,9 @@ |
||
124 | 124 | $secondFallBackModuleDir = $secondFallBackModuleClassPath = $actualModule; |
125 | 125 | if ($actualModule != 'Users') { |
126 | 126 | $baseModule = $moduleHierarchyParts[0]; |
127 | - if ($baseModule == 'Settings') |
|
128 | - $baseModule = 'Settings:Vtiger'; |
|
127 | + if ($baseModule == 'Settings') { |
|
128 | + $baseModule = 'Settings:Vtiger'; |
|
129 | + } |
|
129 | 130 | $firstFallBackDir = str_replace(':', '.', $baseModule); |
130 | 131 | $firstFallBackClassPath = str_replace(':', '_', $baseModule); |
131 | 132 | } |
@@ -31,6 +31,9 @@ |
||
31 | 31 | file_put_contents(self::$usersFile, '<?php return ' . \vtlib\Functions::varExportMin($users) . ';'); |
32 | 32 | } |
33 | 33 | |
34 | + /** |
|
35 | + * @param string $type |
|
36 | + */ |
|
34 | 37 | public static function getUser($type) |
35 | 38 | { |
36 | 39 | if (self::$usersFileCache === false) { |
@@ -153,6 +153,9 @@ discard block |
||
153 | 153 | return $this->whereFields; |
154 | 154 | } |
155 | 155 | |
156 | + /** |
|
157 | + * @param string $columns |
|
158 | + */ |
|
156 | 159 | public function setCustomColumn($columns) |
157 | 160 | { |
158 | 161 | $this->columnsCustom[] = $columns; |
@@ -193,6 +196,9 @@ discard block |
||
193 | 196 | return $this->ownerFields; |
194 | 197 | } |
195 | 198 | |
199 | + /** |
|
200 | + * @return string |
|
201 | + */ |
|
196 | 202 | public function getModuleNameFields($module) |
197 | 203 | { |
198 | 204 | return $this->moduleNameFields[$module]; |
@@ -1249,6 +1255,9 @@ discard block |
||
1249 | 1255 | return $sql; |
1250 | 1256 | } |
1251 | 1257 | |
1258 | + /** |
|
1259 | + * @param string $groupSql |
|
1260 | + */ |
|
1252 | 1261 | private function makeGroupSqlReplacements($fieldSqlList, $groupSql) |
1253 | 1262 | { |
1254 | 1263 | $pos = 0; |
@@ -1286,6 +1295,9 @@ discard block |
||
1286 | 1295 | return ($type == 'date' || $type == 'datetime'); |
1287 | 1296 | } |
1288 | 1297 | |
1298 | + /** |
|
1299 | + * @return string |
|
1300 | + */ |
|
1289 | 1301 | public function fixDateTimeValue($name, $value, $first = true) |
1290 | 1302 | { |
1291 | 1303 | $moduleFields = $this->getModuleFields(); |
@@ -1303,6 +1315,9 @@ discard block |
||
1303 | 1315 | return $value; |
1304 | 1316 | } |
1305 | 1317 | |
1318 | + /** |
|
1319 | + * @param string $glue |
|
1320 | + */ |
|
1306 | 1321 | public function addCondition($fieldname, $value, $operator, $glue = null, $custom = false, $newGroupType = null, $ignoreComma = false) |
1307 | 1322 | { |
1308 | 1323 | $conditionNumber = $this->conditionInstanceCount++; |
@@ -1346,6 +1361,9 @@ discard block |
||
1346 | 1361 | return array('name' => $fieldname, 'value' => $value, 'operator' => $operator, 'custom' => $custom); |
1347 | 1362 | } |
1348 | 1363 | |
1364 | + /** |
|
1365 | + * @param string $groupType |
|
1366 | + */ |
|
1349 | 1367 | public function startGroup($groupType) |
1350 | 1368 | { |
1351 | 1369 | $this->groupInfo .= " $groupType ("; |
@@ -306,8 +306,9 @@ discard block |
||
306 | 306 | |
307 | 307 | public function parseAdvFilterList($advFilterList, $glue = '') |
308 | 308 | { |
309 | - if (!empty($glue)) |
|
310 | - $this->addConditionGlue($glue); |
|
309 | + if (!empty($glue)) { |
|
310 | + $this->addConditionGlue($glue); |
|
311 | + } |
|
311 | 312 | |
312 | 313 | $customView = new CustomView($this->module); |
313 | 314 | $dateSpecificConditions = $customView->getStdFilterConditions(); |
@@ -318,8 +319,9 @@ discard block |
||
318 | 319 | foreach ($filtercolumns as $index => $filter) { |
319 | 320 | $nameComponents = explode(':', $filter['columnname']); |
320 | 321 | // For Events "End Date & Time" field datatype should be DT. But, db will give D for due_date field |
321 | - if ($nameComponents[2] == 'due_date' && $nameComponents[3] == 'Events_End_Date_&_Time') |
|
322 | - $nameComponents[4] = 'DT'; |
|
322 | + if ($nameComponents[2] == 'due_date' && $nameComponents[3] == 'Events_End_Date_&_Time') { |
|
323 | + $nameComponents[4] = 'DT'; |
|
324 | + } |
|
323 | 325 | if (empty($nameComponents[2]) && $nameComponents[1] == 'crmid' && $nameComponents[0] == 'vtiger_crmentity') { |
324 | 326 | $name = $this->getSQLColumn('id'); |
325 | 327 | } else { |
@@ -343,13 +345,15 @@ discard block |
||
343 | 345 | // If datatype is DT then we should append time also |
344 | 346 | if ($nameComponents[4] == 'DT') { |
345 | 347 | $startdate = explode(' ', $dateFilterResolvedList['startdate']); |
346 | - if ($startdate[1] == '') |
|
347 | - $startdate[1] = '00:00:00'; |
|
348 | + if ($startdate[1] == '') { |
|
349 | + $startdate[1] = '00:00:00'; |
|
350 | + } |
|
348 | 351 | $dateFilterResolvedList['startdate'] = $startdate[0] . ' ' . $startdate[1]; |
349 | 352 | |
350 | 353 | $enddate = explode(' ', $dateFilterResolvedList['enddate']); |
351 | - if ($enddate[1] == '') |
|
352 | - $enddate[1] = '23:59:59'; |
|
354 | + if ($enddate[1] == '') { |
|
355 | + $enddate[1] = '23:59:59'; |
|
356 | + } |
|
353 | 357 | $dateFilterResolvedList['enddate'] = $enddate[0] . ' ' . $enddate[1]; |
354 | 358 | } |
355 | 359 | $value = []; |
@@ -367,12 +371,14 @@ discard block |
||
367 | 371 | |
368 | 372 | $value = []; |
369 | 373 | $start = explode(' ', $startDate); |
370 | - if ($start[1] == "") |
|
371 | - $startDate = $start[0] . ' ' . '00:00:00'; |
|
374 | + if ($start[1] == "") { |
|
375 | + $startDate = $start[0] . ' ' . '00:00:00'; |
|
376 | + } |
|
372 | 377 | |
373 | 378 | $end = explode(' ', $endDate); |
374 | - if ($end[1] == "") |
|
375 | - $endDate = $end[0] . ' ' . '23:59:59'; |
|
379 | + if ($end[1] == "") { |
|
380 | + $endDate = $end[0] . ' ' . '23:59:59'; |
|
381 | + } |
|
376 | 382 | |
377 | 383 | $value[] = $startDate; |
378 | 384 | $value[] = $endDate; |
@@ -405,8 +411,9 @@ discard block |
||
405 | 411 | } |
406 | 412 | $this->endGroup(); |
407 | 413 | $groupConditionGlue = $groupcolumns['condition']; |
408 | - if (!empty($groupConditionGlue)) |
|
409 | - $this->addConditionGlue($groupConditionGlue); |
|
414 | + if (!empty($groupConditionGlue)) { |
|
415 | + $this->addConditionGlue($groupConditionGlue); |
|
416 | + } |
|
410 | 417 | } |
411 | 418 | } |
412 | 419 | } |
@@ -698,8 +705,9 @@ discard block |
||
698 | 705 | $fields = $meta->getModuleFields(); |
699 | 706 | $fieldObject = $fields[$fieldName]; |
700 | 707 | |
701 | - if (empty($fieldObject)) |
|
702 | - continue; |
|
708 | + if (empty($fieldObject)) { |
|
709 | + continue; |
|
710 | + } |
|
703 | 711 | |
704 | 712 | $tableName = $fieldObject->getTableName(); |
705 | 713 | if (!in_array($tableName, $referenceFieldTableList)) { |
@@ -758,8 +766,9 @@ discard block |
||
758 | 766 | $operator = strtolower($conditionInfo['operator']); |
759 | 767 | if ($operator == 'between' && $this->isDateType($field->getFieldDataType())) { |
760 | 768 | $start = explode(' ', $conditionInfo['value'][0]); |
761 | - if (count($start) == 2) |
|
762 | - $conditionInfo['value'][0] = getValidDBInsertDateTimeValue($start[0] . ' ' . $start[1]); |
|
769 | + if (count($start) == 2) { |
|
770 | + $conditionInfo['value'][0] = getValidDBInsertDateTimeValue($start[0] . ' ' . $start[1]); |
|
771 | + } |
|
763 | 772 | |
764 | 773 | $end = explode(' ', $conditionInfo['values'][1]); |
765 | 774 | // Dates will be equal for Today, Tomorrow, Yesterday. |
@@ -920,8 +929,9 @@ discard block |
||
920 | 929 | $conditionGlue = ' && '; |
921 | 930 | if ($conditionInfo['operator'] == 'n') { |
922 | 931 | $specialCondition = ' || ' . $field->getTableName() . '.' . $field->getColumnName() . ' IS NULL '; |
923 | - if (!empty($otherField)) |
|
924 | - $specialConditionForOtherField = ' || ' . $otherField->getTableName() . '.' . $otherField->getColumnName() . ' IS NULL '; |
|
932 | + if (!empty($otherField)) { |
|
933 | + $specialConditionForOtherField = ' || ' . $otherField->getTableName() . '.' . $otherField->getColumnName() . ' IS NULL '; |
|
934 | + } |
|
925 | 935 | } |
926 | 936 | } |
927 | 937 | |
@@ -931,10 +941,11 @@ discard block |
||
931 | 941 | } |
932 | 942 | |
933 | 943 | $fieldSql .= "$fieldGlue ((" . $field->getTableName() . '.' . $field->getColumnName() . ' ' . $valueSql . " $specialCondition) "; |
934 | - if (!empty($otherField)) |
|
935 | - $fieldSql .= $conditionGlue . '(' . $otherField->getTableName() . '.' . $otherField->getColumnName() . ' ' . $otherFieldValueSql . ' ' . $specialConditionForOtherField . '))'; |
|
936 | - else |
|
937 | - $fieldSql .= ')'; |
|
944 | + if (!empty($otherField)) { |
|
945 | + $fieldSql .= $conditionGlue . '(' . $otherField->getTableName() . '.' . $otherField->getColumnName() . ' ' . $otherFieldValueSql . ' ' . $specialConditionForOtherField . '))'; |
|
946 | + } else { |
|
947 | + $fieldSql .= ')'; |
|
948 | + } |
|
938 | 949 | } elseif ($conditionInfo['custom']) { |
939 | 950 | $fieldSql .= $fieldGlue . 'vtiger_crmentity.crmid ' . $valueSql; |
940 | 951 | } else { |
@@ -1306,8 +1317,9 @@ discard block |
||
1306 | 1317 | public function addCondition($fieldname, $value, $operator, $glue = null, $custom = false, $newGroupType = null, $ignoreComma = false) |
1307 | 1318 | { |
1308 | 1319 | $conditionNumber = $this->conditionInstanceCount++; |
1309 | - if ($glue != null && $conditionNumber > 0) |
|
1310 | - $this->addConditionGlue($glue); |
|
1320 | + if ($glue != null && $conditionNumber > 0) { |
|
1321 | + $this->addConditionGlue($glue); |
|
1322 | + } |
|
1311 | 1323 | |
1312 | 1324 | $this->groupInfo .= "$conditionNumber "; |
1313 | 1325 | $this->whereFields[] = $fieldname; |
@@ -1328,8 +1340,9 @@ discard block |
||
1328 | 1340 | public function addReferenceModuleFieldCondition($relatedModule, $referenceField, $fieldName, $value, $SQLOperator, $glue = null) |
1329 | 1341 | { |
1330 | 1342 | $conditionNumber = $this->conditionInstanceCount++; |
1331 | - if ($glue != null && $conditionNumber > 0) |
|
1332 | - $this->addConditionGlue($glue); |
|
1343 | + if ($glue != null && $conditionNumber > 0) { |
|
1344 | + $this->addConditionGlue($glue); |
|
1345 | + } |
|
1333 | 1346 | |
1334 | 1347 | $this->groupInfo .= "$conditionNumber "; |
1335 | 1348 | $this->referenceModuleField[$conditionNumber] = array('relatedModule' => $relatedModule, 'referenceField' => $referenceField, 'fieldName' => $fieldName, 'value' => $value, |
@@ -1403,8 +1416,9 @@ discard block |
||
1403 | 1416 | } |
1404 | 1417 | $this->endGroup(); |
1405 | 1418 | $groupConditionGlue = $groupcolumns['condition']; |
1406 | - if (!empty($groupConditionGlue)) |
|
1407 | - $this->addConditionGlue($groupConditionGlue); |
|
1419 | + if (!empty($groupConditionGlue)) { |
|
1420 | + $this->addConditionGlue($groupConditionGlue); |
|
1421 | + } |
|
1408 | 1422 | } |
1409 | 1423 | } |
1410 | 1424 | $this->endGroup(); |
@@ -120,6 +120,9 @@ discard block |
||
120 | 120 | public $tag_start = 0; |
121 | 121 | private $dom = null; |
122 | 122 | |
123 | + /** |
|
124 | + * @param simple_html_dom $dom |
|
125 | + */ |
|
123 | 126 | public function __construct($dom) |
124 | 127 | { |
125 | 128 | $this->dom = $dom; |
@@ -1553,6 +1556,10 @@ discard block |
||
1553 | 1556 | } |
1554 | 1557 | |
1555 | 1558 | // parse attributes |
1559 | +/** |
|
1560 | + * @param simple_html_dom_node $node |
|
1561 | + * @param string[] $space |
|
1562 | + */ |
|
1556 | 1563 | protected function parse_attr($node, $name, &$space) |
1557 | 1564 | { |
1558 | 1565 | // Per sourceforge: http://sourceforge.net/tracker/?func=detail&aid=3061408&group_id=218559&atid=1044037 |
@@ -1589,6 +1596,10 @@ discard block |
||
1589 | 1596 | } |
1590 | 1597 | |
1591 | 1598 | // link node's parent |
1599 | +/** |
|
1600 | + * @param simple_html_dom_node $node |
|
1601 | + * @param boolean $is_child |
|
1602 | + */ |
|
1592 | 1603 | protected function link_nodes(&$node, $is_child) |
1593 | 1604 | { |
1594 | 1605 | $node->parent = $this->parent; |
@@ -1599,6 +1610,9 @@ discard block |
||
1599 | 1610 | } |
1600 | 1611 | |
1601 | 1612 | // as a text node |
1613 | +/** |
|
1614 | + * @param string $tag |
|
1615 | + */ |
|
1602 | 1616 | protected function as_text_node($tag) |
1603 | 1617 | { |
1604 | 1618 | $node = new simple_html_dom_node($this); |
@@ -1609,12 +1623,18 @@ discard block |
||
1609 | 1623 | return true; |
1610 | 1624 | } |
1611 | 1625 | |
1626 | +/** |
|
1627 | + * @param string $chars |
|
1628 | + */ |
|
1612 | 1629 | protected function skip($chars) |
1613 | 1630 | { |
1614 | 1631 | $this->pos += strspn($this->doc, $chars, $this->pos); |
1615 | 1632 | $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
1616 | 1633 | } |
1617 | 1634 | |
1635 | +/** |
|
1636 | + * @param string $chars |
|
1637 | + */ |
|
1618 | 1638 | protected function copy_skip($chars) |
1619 | 1639 | { |
1620 | 1640 | $pos = $this->pos; |
@@ -1626,6 +1646,9 @@ discard block |
||
1626 | 1646 | return substr($this->doc, $pos, $len); |
1627 | 1647 | } |
1628 | 1648 | |
1649 | +/** |
|
1650 | + * @param string $chars |
|
1651 | + */ |
|
1629 | 1652 | protected function copy_until($chars) |
1630 | 1653 | { |
1631 | 1654 | $pos = $this->pos; |
@@ -1635,6 +1658,9 @@ discard block |
||
1635 | 1658 | return substr($this->doc, $pos, $len); |
1636 | 1659 | } |
1637 | 1660 | |
1661 | +/** |
|
1662 | + * @param string $char |
|
1663 | + */ |
|
1638 | 1664 | protected function copy_until_char($char) |
1639 | 1665 | { |
1640 | 1666 | if ($this->char === null) |
@@ -1655,6 +1681,9 @@ discard block |
||
1655 | 1681 | return substr($this->doc, $pos_old, $pos - $pos_old); |
1656 | 1682 | } |
1657 | 1683 | |
1684 | +/** |
|
1685 | + * @param string $char |
|
1686 | + */ |
|
1658 | 1687 | protected function copy_until_char_escape($char) |
1659 | 1688 | { |
1660 | 1689 | if ($this->char === null) |
@@ -1686,6 +1715,9 @@ discard block |
||
1686 | 1715 | |
1687 | 1716 | // remove noise from html content |
1688 | 1717 | // save the noise in the $this->noise array. |
1718 | +/** |
|
1719 | + * @param string $pattern |
|
1720 | + */ |
|
1689 | 1721 | protected function remove_noise($pattern, $remove_tag = false) |
1690 | 1722 | { |
1691 | 1723 | global $debugObject; |
@@ -1713,6 +1745,9 @@ discard block |
||
1713 | 1745 | } |
1714 | 1746 | |
1715 | 1747 | // restore noise to html content |
1748 | +/** |
|
1749 | + * @param string|null $text |
|
1750 | + */ |
|
1716 | 1751 | function restore_noise($text) |
1717 | 1752 | { |
1718 | 1753 | global $debugObject; |
@@ -399,9 +399,9 @@ discard block |
||
399 | 399 | if (isset($this->_[HDOM_INFO_INNER])) |
400 | 400 | return $this->_[HDOM_INFO_INNER]; |
401 | 401 | switch ($this->nodetype) { |
402 | - case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
403 | - case HDOM_TYPE_COMMENT: return ''; |
|
404 | - case HDOM_TYPE_UNKNOWN: return ''; |
|
402 | + case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
403 | + case HDOM_TYPE_COMMENT: return ''; |
|
404 | + case HDOM_TYPE_UNKNOWN: return ''; |
|
405 | 405 | } |
406 | 406 | if (strcasecmp($this->tag, 'script') === 0) |
407 | 407 | return ''; |
@@ -640,19 +640,19 @@ discard block |
||
640 | 640 | } |
641 | 641 | |
642 | 642 | switch ($exp) { |
643 | - case '=': |
|
644 | - return ($value === $pattern); |
|
645 | - case '!=': |
|
646 | - return ($value !== $pattern); |
|
647 | - case '^=': |
|
648 | - return preg_match("/^" . preg_quote($pattern, '/') . "/", $value); |
|
649 | - case '$=': |
|
650 | - return preg_match("/" . preg_quote($pattern, '/') . "$/", $value); |
|
651 | - case '*=': |
|
652 | - if ($pattern[0] == '/') { |
|
653 | - return preg_match($pattern, $value); |
|
654 | - } |
|
655 | - return preg_match("/" . $pattern . "/i", $value); |
|
643 | + case '=': |
|
644 | + return ($value === $pattern); |
|
645 | + case '!=': |
|
646 | + return ($value !== $pattern); |
|
647 | + case '^=': |
|
648 | + return preg_match("/^" . preg_quote($pattern, '/') . "/", $value); |
|
649 | + case '$=': |
|
650 | + return preg_match("/" . preg_quote($pattern, '/') . "$/", $value); |
|
651 | + case '*=': |
|
652 | + if ($pattern[0] == '/') { |
|
653 | + return preg_match($pattern, $value); |
|
654 | + } |
|
655 | + return preg_match("/" . $pattern . "/i", $value); |
|
656 | 656 | } |
657 | 657 | return false; |
658 | 658 | } |
@@ -736,11 +736,11 @@ discard block |
||
736 | 736 | return $this->convert_text($this->attr[$name]); |
737 | 737 | } |
738 | 738 | switch ($name) { |
739 | - case 'outertext': return $this->outertext(); |
|
740 | - case 'innertext': return $this->innertext(); |
|
741 | - case 'plaintext': return $this->text(); |
|
742 | - case 'xmltext': return $this->xmltext(); |
|
743 | - default: return array_key_exists($name, $this->attr); |
|
739 | + case 'outertext': return $this->outertext(); |
|
740 | + case 'innertext': return $this->innertext(); |
|
741 | + case 'plaintext': return $this->text(); |
|
742 | + case 'xmltext': return $this->xmltext(); |
|
743 | + default: return array_key_exists($name, $this->attr); |
|
744 | 744 | } |
745 | 745 | } |
746 | 746 |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | { |
225 | 225 | // I am SURE that this doesn't work properly. |
226 | 226 | // It fails to unset the current node from it's current parents nodes or children list first. |
227 | - if($parent !== null) |
|
227 | + if ($parent !== null) |
|
228 | 228 | { |
229 | 229 | $this->parent = $parent; |
230 | 230 | $this->parent->nodes[] = $this; |
@@ -1427,7 +1427,7 @@ discard block |
||
1427 | 1427 | $node->tag = 'unknown'; |
1428 | 1428 | } |
1429 | 1429 | if ($this->char === '>') |
1430 | - $node->_[HDOM_INFO_TEXT].='>'; |
|
1430 | + $node->_[HDOM_INFO_TEXT] .= '>'; |
|
1431 | 1431 | $this->link_nodes($node, true); |
1432 | 1432 | $this->char = ( ++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
1433 | 1433 | return true; |
@@ -1450,7 +1450,7 @@ discard block |
||
1450 | 1450 | } |
1451 | 1451 | |
1452 | 1452 | if ($this->char === '>') |
1453 | - $node->_[HDOM_INFO_TEXT].='>'; |
|
1453 | + $node->_[HDOM_INFO_TEXT] .= '>'; |
|
1454 | 1454 | $this->link_nodes($node, false); |
1455 | 1455 | $this->char = ( ++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
1456 | 1456 | return true; |
@@ -153,8 +153,9 @@ discard block |
||
153 | 153 | echo $lead . $this->tag; |
154 | 154 | if ($show_attr && count($this->attr) > 0) { |
155 | 155 | echo '('; |
156 | - foreach ($this->attr as $k => $v) |
|
157 | - echo "[$k]=>\"" . $this->$k . '", '; |
|
156 | + foreach ($this->attr as $k => $v) { |
|
157 | + echo "[$k]=>\"" . $this->$k . '", '; |
|
158 | + } |
|
158 | 159 | echo ')'; |
159 | 160 | } |
160 | 161 | echo "\n"; |
@@ -246,8 +247,9 @@ discard block |
||
246 | 247 | if ($idx === -1) { |
247 | 248 | return $this->children; |
248 | 249 | } |
249 | -if (isset($this->children[$idx])) |
|
250 | +if (isset($this->children[$idx])) { |
|
250 | 251 | return $this->children[$idx]; |
252 | +} |
|
251 | 253 | return null; |
252 | 254 | } |
253 | 255 | |
@@ -290,14 +292,17 @@ discard block |
||
290 | 292 | // returns the previous sibling of node |
291 | 293 | function prev_sibling() |
292 | 294 | { |
293 | -if ($this->parent === null) |
|
295 | +if ($this->parent === null) { |
|
294 | 296 | return null; |
297 | +} |
|
295 | 298 | $idx = 0; |
296 | 299 | $count = count($this->parent->children); |
297 | -while ($idx < $count && $this !== $this->parent->children[$idx]) |
|
300 | +while ($idx < $count && $this !== $this->parent->children[$idx]) { |
|
298 | 301 | ++$idx; |
299 | -if (--$idx < 0) |
|
302 | +} |
|
303 | +if (--$idx < 0) { |
|
300 | 304 | return null; |
305 | +} |
|
301 | 306 | return $this->parent->children[$idx]; |
302 | 307 | } |
303 | 308 | |
@@ -328,14 +333,17 @@ discard block |
||
328 | 333 | // get dom node's inner html |
329 | 334 | function innertext() |
330 | 335 | { |
331 | -if (isset($this->_[HDOM_INFO_INNER])) |
|
336 | +if (isset($this->_[HDOM_INFO_INNER])) { |
|
332 | 337 | return $this->_[HDOM_INFO_INNER]; |
333 | -if (isset($this->_[HDOM_INFO_TEXT])) |
|
338 | +} |
|
339 | +if (isset($this->_[HDOM_INFO_TEXT])) { |
|
334 | 340 | return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
341 | +} |
|
335 | 342 | |
336 | 343 | $ret = ''; |
337 | -foreach ($this->nodes as $n) |
|
344 | +foreach ($this->nodes as $n) { |
|
338 | 345 | $ret .= $n->outertext(); |
346 | +} |
|
339 | 347 | return $ret; |
340 | 348 | } |
341 | 349 | |
@@ -353,18 +361,21 @@ discard block |
||
353 | 361 | $debugObject->debugLog(1, 'Innertext of tag: ' . $this->tag . $text); |
354 | 362 | } |
355 | 363 | |
356 | -if ($this->tag === 'root') |
|
364 | +if ($this->tag === 'root') { |
|
357 | 365 | return $this->innertext(); |
366 | +} |
|
358 | 367 | |
359 | 368 | // trigger callback |
360 | 369 | if ($this->dom && $this->dom->callback !== null) { |
361 | 370 | call_user_func_array($this->dom->callback, array($this)); |
362 | 371 | } |
363 | 372 | |
364 | -if (isset($this->_[HDOM_INFO_OUTER])) |
|
373 | +if (isset($this->_[HDOM_INFO_OUTER])) { |
|
365 | 374 | return $this->_[HDOM_INFO_OUTER]; |
366 | -if (isset($this->_[HDOM_INFO_TEXT])) |
|
375 | +} |
|
376 | +if (isset($this->_[HDOM_INFO_TEXT])) { |
|
367 | 377 | return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
378 | +} |
|
368 | 379 | |
369 | 380 | // render begin tag |
370 | 381 | if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]) { |
@@ -388,25 +399,29 @@ discard block |
||
388 | 399 | } |
389 | 400 | |
390 | 401 | // render end tag |
391 | -if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END] != 0) |
|
402 | +if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END] != 0) { |
|
392 | 403 | $ret .= '</' . $this->tag . '>'; |
404 | +} |
|
393 | 405 | return $ret; |
394 | 406 | } |
395 | 407 | |
396 | 408 | // get dom node's plain text |
397 | 409 | function text() |
398 | 410 | { |
399 | -if (isset($this->_[HDOM_INFO_INNER])) |
|
411 | +if (isset($this->_[HDOM_INFO_INNER])) { |
|
400 | 412 | return $this->_[HDOM_INFO_INNER]; |
413 | +} |
|
401 | 414 | switch ($this->nodetype) { |
402 | 415 | case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
403 | 416 | case HDOM_TYPE_COMMENT: return ''; |
404 | 417 | case HDOM_TYPE_UNKNOWN: return ''; |
405 | 418 | } |
406 | -if (strcasecmp($this->tag, 'script') === 0) |
|
419 | +if (strcasecmp($this->tag, 'script') === 0) { |
|
407 | 420 | return ''; |
408 | -if (strcasecmp($this->tag, 'style') === 0) |
|
421 | +} |
|
422 | +if (strcasecmp($this->tag, 'style') === 0) { |
|
409 | 423 | return ''; |
424 | +} |
|
410 | 425 | |
411 | 426 | $ret = ''; |
412 | 427 | // In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL. |
@@ -437,8 +452,9 @@ discard block |
||
437 | 452 | function makeup() |
438 | 453 | { |
439 | 454 | // text, comment, unknown |
440 | -if (isset($this->_[HDOM_INFO_TEXT])) |
|
455 | +if (isset($this->_[HDOM_INFO_TEXT])) { |
|
441 | 456 | return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
457 | +} |
|
442 | 458 | |
443 | 459 | $ret = '<' . $this->tag; |
444 | 460 | $i = -1; |
@@ -447,14 +463,15 @@ discard block |
||
447 | 463 | ++$i; |
448 | 464 | |
449 | 465 | // skip removed attribute |
450 | - if ($val === null || $val === false) |
|
451 | - continue; |
|
466 | + if ($val === null || $val === false) { |
|
467 | + continue; |
|
468 | + } |
|
452 | 469 | |
453 | 470 | $ret .= $this->_[HDOM_INFO_SPACE][$i][0]; |
454 | 471 | //no value attr: nowrap, checked selected... |
455 | - if ($val === true) |
|
456 | - $ret .= $key; |
|
457 | - else { |
|
472 | + if ($val === true) { |
|
473 | + $ret .= $key; |
|
474 | + } else { |
|
458 | 475 | switch ($this->_[HDOM_INFO_QUOTE][$i]) { |
459 | 476 | case HDOM_QUOTE_DOUBLE: $quote = '"'; |
460 | 477 | break; |
@@ -474,18 +491,21 @@ discard block |
||
474 | 491 | function find($selector, $idx = null, $lowercase = false) |
475 | 492 | { |
476 | 493 | $selectors = $this->parse_selector($selector); |
477 | -if (($count = count($selectors)) === 0) |
|
494 | +if (($count = count($selectors)) === 0) { |
|
478 | 495 | return []; |
496 | +} |
|
479 | 497 | $found_keys = []; |
480 | 498 | |
481 | 499 | // find each selector |
482 | 500 | for ($c = 0; $c < $count; ++$c) { |
483 | 501 | // The change on the below line was documented on the sourceforge code tracker id 2788009 |
484 | 502 | // used to be: if (($levle=count($selectors[0]))===0) return []; |
485 | - if (($levle = count($selectors[$c])) === 0) |
|
486 | - return []; |
|
487 | - if (!isset($this->_[HDOM_INFO_BEGIN])) |
|
488 | - return []; |
|
503 | + if (($levle = count($selectors[$c])) === 0) { |
|
504 | + return []; |
|
505 | + } |
|
506 | + if (!isset($this->_[HDOM_INFO_BEGIN])) { |
|
507 | + return []; |
|
508 | + } |
|
489 | 509 | |
490 | 510 | $head = array($this->_[HDOM_INFO_BEGIN] => 1); |
491 | 511 | |
@@ -501,8 +521,9 @@ discard block |
||
501 | 521 | } |
502 | 522 | |
503 | 523 | foreach ($head as $k => $v) { |
504 | - if (!isset($found_keys[$k])) |
|
505 | - $found_keys[$k] = 1; |
|
524 | + if (!isset($found_keys[$k])) { |
|
525 | + $found_keys[$k] = 1; |
|
526 | + } |
|
506 | 527 | } |
507 | 528 | } |
508 | 529 | |
@@ -510,14 +531,16 @@ discard block |
||
510 | 531 | ksort($found_keys); |
511 | 532 | |
512 | 533 | $found = []; |
513 | -foreach ($found_keys as $k => $v) |
|
534 | +foreach ($found_keys as $k => $v) { |
|
514 | 535 | $found[] = $this->dom->nodes[$k]; |
536 | +} |
|
515 | 537 | |
516 | 538 | // return nth-element or array |
517 | -if (is_null($idx)) |
|
539 | +if (is_null($idx)) { |
|
518 | 540 | return $found; |
519 | -else if ($idx < 0) |
|
541 | +} else if ($idx < 0) { |
|
520 | 542 | $idx = count($found) + $idx; |
543 | +} |
|
521 | 544 | return (isset($found[$idx])) ? $found[$idx] : null; |
522 | 545 | } |
523 | 546 | |
@@ -562,8 +585,9 @@ discard block |
||
562 | 585 | $pass = true; |
563 | 586 | |
564 | 587 | if ($tag === '*' && !$key) { |
565 | - if (in_array($node, $this->children, true)) |
|
566 | - $ret[$i] = 1; |
|
588 | + if (in_array($node, $this->children, true)) { |
|
589 | + $ret[$i] = 1; |
|
590 | + } |
|
567 | 591 | continue; |
568 | 592 | } |
569 | 593 | |
@@ -574,11 +598,13 @@ discard block |
||
574 | 598 | // compare key |
575 | 599 | if ($pass && $key) { |
576 | 600 | if ($no_key) { |
577 | - if (isset($node->attr[$key])) |
|
578 | - $pass = false; |
|
601 | + if (isset($node->attr[$key])) { |
|
602 | + $pass = false; |
|
603 | + } |
|
579 | 604 | } else { |
580 | - if (($key != "plaintext") && !isset($node->attr[$key])) |
|
581 | - $pass = false; |
|
605 | + if (($key != "plaintext") && !isset($node->attr[$key])) { |
|
606 | + $pass = false; |
|
607 | + } |
|
582 | 608 | } |
583 | 609 | } |
584 | 610 | // compare value |
@@ -614,16 +640,19 @@ discard block |
||
614 | 640 | } else { |
615 | 641 | $check = $this->match($exp, $val, $k); |
616 | 642 | } |
617 | - if ($check) |
|
618 | - break; |
|
643 | + if ($check) { |
|
644 | + break; |
|
645 | + } |
|
619 | 646 | } |
620 | 647 | } |
621 | 648 | } |
622 | - if (!$check) |
|
623 | - $pass = false; |
|
649 | + if (!$check) { |
|
650 | + $pass = false; |
|
651 | + } |
|
652 | + } |
|
653 | + if ($pass) { |
|
654 | + $ret[$i] = 1; |
|
624 | 655 | } |
625 | - if ($pass) |
|
626 | - $ret[$i] = 1; |
|
627 | 656 | unset($node); |
628 | 657 | } |
629 | 658 | // It's passed by reference so this is actually what this function returns. |
@@ -683,11 +712,13 @@ discard block |
||
683 | 712 | |
684 | 713 | foreach ($matches as $m) { |
685 | 714 | $m[0] = trim($m[0]); |
686 | - if ($m[0] === '' || $m[0] === '/' || $m[0] === '//') |
|
687 | - continue; |
|
715 | + if ($m[0] === '' || $m[0] === '/' || $m[0] === '//') { |
|
716 | + continue; |
|
717 | + } |
|
688 | 718 | // for browser generated xpath |
689 | - if ($m[1] === 'tbody') |
|
690 | - continue; |
|
719 | + if ($m[1] === 'tbody') { |
|
720 | + continue; |
|
721 | + } |
|
691 | 722 | |
692 | 723 | list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false); |
693 | 724 | if (!empty($m[2])) { |
@@ -725,8 +756,9 @@ discard block |
||
725 | 756 | $result = []; |
726 | 757 | } |
727 | 758 | } |
728 | -if (count($result) > 0) |
|
759 | +if (count($result) > 0) { |
|
729 | 760 | $selectors[] = $result; |
761 | +} |
|
730 | 762 | return $selectors; |
731 | 763 | } |
732 | 764 | |
@@ -749,8 +781,9 @@ discard block |
||
749 | 781 | switch ($name) { |
750 | 782 | case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value; |
751 | 783 | case 'innertext': |
752 | - if (isset($this->_[HDOM_INFO_TEXT])) |
|
753 | - return $this->_[HDOM_INFO_TEXT] = $value; |
|
784 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
785 | + return $this->_[HDOM_INFO_TEXT] = $value; |
|
786 | + } |
|
754 | 787 | return $this->_[HDOM_INFO_INNER] = $value; |
755 | 788 | } |
756 | 789 | if (!isset($this->attr[$name])) { |
@@ -773,9 +806,10 @@ discard block |
||
773 | 806 | |
774 | 807 | function __unset($name) |
775 | 808 | { |
776 | -if (isset($this->attr[$name])) |
|
809 | +if (isset($this->attr[$name])) { |
|
777 | 810 | unset($this->attr[$name]); |
778 | 811 | } |
812 | +} |
|
779 | 813 | |
780 | 814 | // PaperG - Function to convert the text from one character set to another if the two sets are not the same. |
781 | 815 | function convert_text($text) |
@@ -835,27 +869,30 @@ discard block |
||
835 | 869 | for ($i = 0; $i < $len; $i++) { |
836 | 870 | $c = ord($str[$i]); |
837 | 871 | if ($c > 128) { |
838 | - if (($c >= 254)) |
|
839 | - return false; |
|
840 | - elseif ($c >= 252) |
|
841 | - $bits = 6; |
|
842 | - elseif ($c >= 248) |
|
843 | - $bits = 5; |
|
844 | - elseif ($c >= 240) |
|
845 | - $bits = 4; |
|
846 | - elseif ($c >= 224) |
|
847 | - $bits = 3; |
|
848 | - elseif ($c >= 192) |
|
849 | - $bits = 2; |
|
850 | - else |
|
851 | - return false; |
|
852 | - if (($i + $bits) > $len) |
|
853 | - return false; |
|
872 | + if (($c >= 254)) { |
|
873 | + return false; |
|
874 | + } elseif ($c >= 252) { |
|
875 | + $bits = 6; |
|
876 | + } elseif ($c >= 248) { |
|
877 | + $bits = 5; |
|
878 | + } elseif ($c >= 240) { |
|
879 | + $bits = 4; |
|
880 | + } elseif ($c >= 224) { |
|
881 | + $bits = 3; |
|
882 | + } elseif ($c >= 192) { |
|
883 | + $bits = 2; |
|
884 | + } else { |
|
885 | + return false; |
|
886 | + } |
|
887 | + if (($i + $bits) > $len) { |
|
888 | + return false; |
|
889 | + } |
|
854 | 890 | while ($bits > 1) { |
855 | 891 | $i++; |
856 | 892 | $b = ord($str[$i]); |
857 | - if ($b < 128 || $b > 191) |
|
858 | - return false; |
|
893 | + if ($b < 128 || $b > 191) { |
|
894 | + return false; |
|
895 | + } |
|
859 | 896 | $bits--; |
860 | 897 | } |
861 | 898 | } |
@@ -1175,8 +1212,9 @@ discard block |
||
1175 | 1212 | function save($filepath = '') |
1176 | 1213 | { |
1177 | 1214 | $ret = $this->root->innertext(); |
1178 | -if ($filepath !== '') |
|
1215 | +if ($filepath !== '') { |
|
1179 | 1216 | file_put_contents($filepath, $ret, LOCK_EX); |
1217 | +} |
|
1180 | 1218 | return $ret; |
1181 | 1219 | } |
1182 | 1220 | |
@@ -1195,9 +1233,10 @@ discard block |
||
1195 | 1233 | $n = null; |
1196 | 1234 | } |
1197 | 1235 | // This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear. |
1198 | -if (isset($this->children)) |
|
1236 | +if (isset($this->children)) { |
|
1199 | 1237 | foreach ($this->children as $n) { |
1200 | 1238 | $n->clear(); |
1239 | +} |
|
1201 | 1240 | $n = null; |
1202 | 1241 | } |
1203 | 1242 | if (isset($this->parent)) { |
@@ -1249,9 +1288,10 @@ discard block |
||
1249 | 1288 | $this->root->_[HDOM_INFO_BEGIN] = -1; |
1250 | 1289 | $this->root->nodetype = HDOM_TYPE_ROOT; |
1251 | 1290 | $this->parent = $this->root; |
1252 | -if ($this->size > 0) |
|
1291 | +if ($this->size > 0) { |
|
1253 | 1292 | $this->char = $this->doc[0]; |
1254 | 1293 | } |
1294 | +} |
|
1255 | 1295 | |
1256 | 1296 | // parse html content |
1257 | 1297 | protected function parse() |
@@ -1360,8 +1400,9 @@ discard block |
||
1360 | 1400 | $tag = $this->copy_until_char('>'); |
1361 | 1401 | |
1362 | 1402 | // skip attributes in end tag |
1363 | - if (($pos = strpos($tag, ' ')) !== false) |
|
1364 | - $tag = substr($tag, 0, $pos); |
|
1403 | + if (($pos = strpos($tag, ' ')) !== false) { |
|
1404 | + $tag = substr($tag, 0, $pos); |
|
1405 | + } |
|
1365 | 1406 | |
1366 | 1407 | $parent_lower = strtolower($this->parent->tag); |
1367 | 1408 | $tag_lower = strtolower($tag); |
@@ -1371,23 +1412,25 @@ discard block |
||
1371 | 1412 | $this->parent->_[HDOM_INFO_END] = 0; |
1372 | 1413 | $org_parent = $this->parent; |
1373 | 1414 | |
1374 | - while (($this->parent->parent) && strtolower($this->parent->tag) !== $tag_lower) |
|
1375 | - $this->parent = $this->parent->parent; |
|
1415 | + while (($this->parent->parent) && strtolower($this->parent->tag) !== $tag_lower) { |
|
1416 | + $this->parent = $this->parent->parent; |
|
1417 | + } |
|
1376 | 1418 | |
1377 | 1419 | if (strtolower($this->parent->tag) !== $tag_lower) { |
1378 | 1420 | $this->parent = $org_parent; // restore origonal parent |
1379 | - if ($this->parent->parent) |
|
1380 | - $this->parent = $this->parent->parent; |
|
1421 | + if ($this->parent->parent) { |
|
1422 | + $this->parent = $this->parent->parent; |
|
1423 | + } |
|
1381 | 1424 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
1382 | 1425 | return $this->as_text_node($tag); |
1383 | 1426 | } |
1384 | - } |
|
1385 | - else if (($this->parent->parent) && isset($this->block_tags[$tag_lower])) { |
|
1427 | + } else if (($this->parent->parent) && isset($this->block_tags[$tag_lower])) { |
|
1386 | 1428 | $this->parent->_[HDOM_INFO_END] = 0; |
1387 | 1429 | $org_parent = $this->parent; |
1388 | 1430 | |
1389 | - while (($this->parent->parent) && strtolower($this->parent->tag) !== $tag_lower) |
|
1390 | - $this->parent = $this->parent->parent; |
|
1431 | + while (($this->parent->parent) && strtolower($this->parent->tag) !== $tag_lower) { |
|
1432 | + $this->parent = $this->parent->parent; |
|
1433 | + } |
|
1391 | 1434 | |
1392 | 1435 | if (strtolower($this->parent->tag) !== $tag_lower) { |
1393 | 1436 | $this->parent = $org_parent; // restore origonal parent |
@@ -1397,13 +1440,15 @@ discard block |
||
1397 | 1440 | } else if (($this->parent->parent) && strtolower($this->parent->parent->tag) === $tag_lower) { |
1398 | 1441 | $this->parent->_[HDOM_INFO_END] = 0; |
1399 | 1442 | $this->parent = $this->parent->parent; |
1400 | - } else |
|
1401 | - return $this->as_text_node($tag); |
|
1443 | + } else { |
|
1444 | + return $this->as_text_node($tag); |
|
1445 | + } |
|
1402 | 1446 | } |
1403 | 1447 | |
1404 | 1448 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
1405 | - if ($this->parent->parent) |
|
1406 | - $this->parent = $this->parent->parent; |
|
1449 | + if ($this->parent->parent) { |
|
1450 | + $this->parent = $this->parent->parent; |
|
1451 | + } |
|
1407 | 1452 | |
1408 | 1453 | $this->char = ( ++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
1409 | 1454 | return true; |
@@ -1426,8 +1471,9 @@ discard block |
||
1426 | 1471 | $node->nodetype = HDOM_TYPE_UNKNOWN; |
1427 | 1472 | $node->tag = 'unknown'; |
1428 | 1473 | } |
1429 | - if ($this->char === '>') |
|
1430 | - $node->_[HDOM_INFO_TEXT].='>'; |
|
1474 | + if ($this->char === '>') { |
|
1475 | + $node->_[HDOM_INFO_TEXT].='>'; |
|
1476 | + } |
|
1431 | 1477 | $this->link_nodes($node, true); |
1432 | 1478 | $this->char = ( ++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
1433 | 1479 | return true; |
@@ -1449,8 +1495,9 @@ discard block |
||
1449 | 1495 | return true; |
1450 | 1496 | } |
1451 | 1497 | |
1452 | - if ($this->char === '>') |
|
1453 | - $node->_[HDOM_INFO_TEXT].='>'; |
|
1498 | + if ($this->char === '>') { |
|
1499 | + $node->_[HDOM_INFO_TEXT].='>'; |
|
1500 | + } |
|
1454 | 1501 | $this->link_nodes($node, false); |
1455 | 1502 | $this->char = ( ++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
1456 | 1503 | return true; |
@@ -1511,8 +1558,9 @@ discard block |
||
1511 | 1558 | if ($name !== '/' && $name !== '') { |
1512 | 1559 | $space[1] = $this->copy_skip($this->token_blank); |
1513 | 1560 | $name = $this->restore_noise($name); |
1514 | - if ($this->lowercase) |
|
1515 | - $name = strtolower($name); |
|
1561 | + if ($this->lowercase) { |
|
1562 | + $name = strtolower($name); |
|
1563 | + } |
|
1516 | 1564 | if ($this->char === '=') { |
1517 | 1565 | $this->char = ( ++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
1518 | 1566 | $this->parse_attr($node, $name, $space); |
@@ -1520,14 +1568,17 @@ discard block |
||
1520 | 1568 | //no value attr: nowrap, checked selected... |
1521 | 1569 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO; |
1522 | 1570 | $node->attr[$name] = true; |
1523 | - if ($this->char != '>') |
|
1524 | - $this->char = $this->doc[--$this->pos]; // prev |
|
1571 | + if ($this->char != '>') { |
|
1572 | + $this->char = $this->doc[--$this->pos]; |
|
1573 | + } |
|
1574 | + // prev |
|
1525 | 1575 | } |
1526 | 1576 | $node->_[HDOM_INFO_SPACE][] = $space; |
1527 | 1577 | $space = array($this->copy_skip($this->token_blank), '', ''); |
1528 | - } else |
|
1529 | - break; |
|
1530 | -} while ($this->char !== '>' && $this->char !== '/'); |
|
1578 | + } else { |
|
1579 | + break; |
|
1580 | + } |
|
1581 | + } while ($this->char !== '>' && $this->char !== '/'); |
|
1531 | 1582 | |
1532 | 1583 | $this->link_nodes($node, true); |
1533 | 1584 | $node->_[HDOM_INFO_ENDSPACE] = $space[0]; |
@@ -1538,9 +1589,10 @@ discard block |
||
1538 | 1589 | $node->_[HDOM_INFO_END] = 0; |
1539 | 1590 | } else { |
1540 | 1591 | // reset parent |
1541 | - if (!isset($this->self_closing_tags[strtolower($node->tag)])) |
|
1542 | - $this->parent = $node; |
|
1543 | -} |
|
1592 | + if (!isset($this->self_closing_tags[strtolower($node->tag)])) { |
|
1593 | + $this->parent = $node; |
|
1594 | + } |
|
1595 | + } |
|
1544 | 1596 | $this->char = ( ++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
1545 | 1597 | // If it's a BR tag, we need to set it's text to the default text. |
1546 | 1598 | // This way when we see it in plaintext, we can generate formatting that the user wants. |
@@ -1621,8 +1673,9 @@ discard block |
||
1621 | 1673 | $len = strspn($this->doc, $chars, $pos); |
1622 | 1674 | $this->pos += $len; |
1623 | 1675 | $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
1624 | -if ($len === 0) |
|
1676 | +if ($len === 0) { |
|
1625 | 1677 | return ''; |
1678 | +} |
|
1626 | 1679 | return substr($this->doc, $pos, $len); |
1627 | 1680 | } |
1628 | 1681 | |
@@ -1637,8 +1690,9 @@ discard block |
||
1637 | 1690 | |
1638 | 1691 | protected function copy_until_char($char) |
1639 | 1692 | { |
1640 | -if ($this->char === null) |
|
1693 | +if ($this->char === null) { |
|
1641 | 1694 | return ''; |
1695 | +} |
|
1642 | 1696 | |
1643 | 1697 | if (($pos = strpos($this->doc, $char, $this->pos)) === false) { |
1644 | 1698 | $ret = substr($this->doc, $this->pos, $this->size - $this->pos); |
@@ -1647,8 +1701,9 @@ discard block |
||
1647 | 1701 | return $ret; |
1648 | 1702 | } |
1649 | 1703 | |
1650 | -if ($pos === $this->pos) |
|
1704 | +if ($pos === $this->pos) { |
|
1651 | 1705 | return ''; |
1706 | +} |
|
1652 | 1707 | $pos_old = $this->pos; |
1653 | 1708 | $this->char = $this->doc[$pos]; |
1654 | 1709 | $this->pos = $pos; |
@@ -1657,8 +1712,9 @@ discard block |
||
1657 | 1712 | |
1658 | 1713 | protected function copy_until_char_escape($char) |
1659 | 1714 | { |
1660 | -if ($this->char === null) |
|
1715 | +if ($this->char === null) { |
|
1661 | 1716 | return ''; |
1717 | +} |
|
1662 | 1718 | |
1663 | 1719 | $start = $this->pos; |
1664 | 1720 | while (1) { |
@@ -1669,8 +1725,9 @@ discard block |
||
1669 | 1725 | return $ret; |
1670 | 1726 | } |
1671 | 1727 | |
1672 | - if ($pos === $this->pos) |
|
1673 | - return ''; |
|
1728 | + if ($pos === $this->pos) { |
|
1729 | + return ''; |
|
1730 | + } |
|
1674 | 1731 | |
1675 | 1732 | if ($this->doc[$pos - 1] === '\\') { |
1676 | 1733 | $start = $pos + 1; |
@@ -378,6 +378,11 @@ |
||
378 | 378 | * Returns an string value |
379 | 379 | */ |
380 | 380 | |
381 | +/** |
|
382 | + * @param string $url_qry |
|
383 | + * @param string $module |
|
384 | + * @param string $related_module |
|
385 | + */ |
|
381 | 386 | function getRelatedTableHeaderNavigation($navigation_array, $url_qry, $module, $related_module, $recordid) |
382 | 387 | { |
383 | 388 | $log = LoggerManager::getInstance(); |
@@ -194,15 +194,15 @@ discard block |
||
194 | 194 | |
195 | 195 | //added to fix #5135 |
196 | 196 | if (AppRequest::get('from_homepage') == 'upcoming_activities' || AppRequest::get('from_homepage') == 'pending_activities') { |
197 | - $query.=' LEFT OUTER JOIN vtiger_recurringevents ON vtiger_recurringevents.activityid=vtiger_activity.activityid'; |
|
197 | + $query .= ' LEFT OUTER JOIN vtiger_recurringevents ON vtiger_recurringevents.activityid=vtiger_activity.activityid'; |
|
198 | 198 | } |
199 | 199 | //end |
200 | 200 | $instance = CRMEntity::getInstance($module); |
201 | - $query.=" WHERE vtiger_crmentity.deleted = 0 && activitytype != 'Emails' "; |
|
201 | + $query .= " WHERE vtiger_crmentity.deleted = 0 && activitytype != 'Emails' "; |
|
202 | 202 | $securityParameter = $instance->getUserAccessConditionsQuerySR($module, $current_user); |
203 | 203 | if ($securityParameter != '') |
204 | - $query.= $securityParameter; |
|
205 | - $query.= ' ' . $where; |
|
204 | + $query .= $securityParameter; |
|
205 | + $query .= ' ' . $where; |
|
206 | 206 | break; |
207 | 207 | Case "Emails": |
208 | 208 | $query = "SELECT DISTINCT vtiger_crmentity.crmid, vtiger_crmentity.smownerid, |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | $chars = preg_split('/(&[^;\s]+;)|/', $str, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE); |
617 | 617 | $html_length = count($chars); |
618 | 618 | // check if we can predict the return value and save some processing time |
619 | - if (($html_length === 0) || ( $start >= $html_length) || ( isset($length) && ( $length <= -$html_length))) |
|
619 | + if (($html_length === 0) || ($start >= $html_length) || (isset($length) && ($length <= -$html_length))) |
|
620 | 620 | return ""; |
621 | 621 | |
622 | 622 | //calculate start position |
@@ -200,8 +200,9 @@ discard block |
||
200 | 200 | $instance = CRMEntity::getInstance($module); |
201 | 201 | $query.=" WHERE vtiger_crmentity.deleted = 0 && activitytype != 'Emails' "; |
202 | 202 | $securityParameter = $instance->getUserAccessConditionsQuerySR($module, $current_user); |
203 | - if ($securityParameter != '') |
|
204 | - $query.= $securityParameter; |
|
203 | + if ($securityParameter != '') { |
|
204 | + $query.= $securityParameter; |
|
205 | + } |
|
205 | 206 | $query.= ' ' . $where; |
206 | 207 | break; |
207 | 208 | Case "Emails": |
@@ -355,18 +356,21 @@ discard block |
||
355 | 356 | $start = $_SESSION['rlvs'][$module][$related]['start']; |
356 | 357 | } |
357 | 358 | } |
358 | - if (AppRequest::has('viewname') && AppRequest::get('viewname') != '') |
|
359 | - $lv_array['viewname'] = AppRequest::get('viewname'); |
|
359 | + if (AppRequest::has('viewname') && AppRequest::get('viewname') != '') { |
|
360 | + $lv_array['viewname'] = AppRequest::get('viewname'); |
|
361 | + } |
|
360 | 362 | |
361 | - if ($related == '') |
|
362 | - $_SESSION['lvs'][AppRequest::get('module')] = $lv_array; |
|
363 | - else |
|
364 | - $_SESSION['rlvs'][$module][$related] = $lv_array; |
|
363 | + if ($related == '') { |
|
364 | + $_SESSION['lvs'][AppRequest::get('module')] = $lv_array; |
|
365 | + } else { |
|
366 | + $_SESSION['rlvs'][$module][$related] = $lv_array; |
|
367 | + } |
|
365 | 368 | |
366 | 369 | if ($start < ceil($noofrows / $max_ent) && $start != '') { |
367 | 370 | $start = ceil($noofrows / $max_ent); |
368 | - if ($related == '') |
|
369 | - $_SESSION['lvs'][$currentModule]['start'] = $start; |
|
371 | + if ($related == '') { |
|
372 | + $_SESSION['lvs'][$currentModule]['start'] = $start; |
|
373 | + } |
|
370 | 374 | } |
371 | 375 | } |
372 | 376 | /* * Function to get the table headers for related listview |
@@ -389,8 +393,9 @@ discard block |
||
389 | 393 | |
390 | 394 | $relatedListResult = $adb->pquery('SELECT * FROM vtiger_relatedlists WHERE tabid=? AND |
391 | 395 | related_tabid=?', array($tabid, $relatedTabId)); |
392 | - if (empty($relatedListResult)) |
|
393 | - return; |
|
396 | + if (empty($relatedListResult)) { |
|
397 | + return; |
|
398 | + } |
|
394 | 399 | $relatedListRow = $adb->fetchByAssoc($relatedListResult); |
395 | 400 | $header = $relatedListRow['label']; |
396 | 401 | $actions = $relatedListRow['actions']; |
@@ -439,11 +444,12 @@ discard block |
||
439 | 444 | } |
440 | 445 | $output .= '</td>'; |
441 | 446 | $log->debug("Exiting getTableHeaderNavigation method ..."); |
442 | - if ($navigation_array['first'] == '') |
|
443 | - return; |
|
444 | - else |
|
445 | - return $output; |
|
446 | -} |
|
447 | + if ($navigation_array['first'] == '') { |
|
448 | + return; |
|
449 | + } else { |
|
450 | + return $output; |
|
451 | + } |
|
452 | + } |
|
447 | 453 | /* Function to get the Entity Id of a given Entity Name */ |
448 | 454 | |
449 | 455 | function getEntityId($module, $entityName) |
@@ -473,23 +479,26 @@ discard block |
||
473 | 479 | $entityId = $adb->query_result($result, 0, $entityidfield); |
474 | 480 | } |
475 | 481 | } |
476 | - if (!empty($entityId)) |
|
477 | - return $entityId; |
|
478 | - else |
|
479 | - return 0; |
|
480 | -} |
|
482 | + if (!empty($entityId)) { |
|
483 | + return $entityId; |
|
484 | + } else { |
|
485 | + return 0; |
|
486 | + } |
|
487 | + } |
|
481 | 488 | |
482 | 489 | function decode_html($str) |
483 | 490 | { |
484 | 491 | $defaultCharset = AppConfig::main('default_charset'); |
485 | - if (empty($default_charset)) |
|
486 | - $defaultCharset = 'UTF-8'; |
|
492 | + if (empty($default_charset)) { |
|
493 | + $defaultCharset = 'UTF-8'; |
|
494 | + } |
|
487 | 495 | // Direct Popup action or Ajax Popup action should be treated the same. |
488 | - if (AppRequest::get('action') == 'Popup' || (AppRequest::has('action') && AppRequest::get('file') == 'Popup')) |
|
489 | - return html_entity_decode($str); |
|
490 | - else |
|
491 | - return html_entity_decode($str, ENT_QUOTES, $defaultCharset); |
|
492 | -} |
|
496 | + if (AppRequest::get('action') == 'Popup' || (AppRequest::has('action') && AppRequest::get('file') == 'Popup')) { |
|
497 | + return html_entity_decode($str); |
|
498 | + } else { |
|
499 | + return html_entity_decode($str, ENT_QUOTES, $defaultCharset); |
|
500 | + } |
|
501 | + } |
|
493 | 502 | |
494 | 503 | function popup_decode_html($str) |
495 | 504 | { |
@@ -602,22 +611,25 @@ discard block |
||
602 | 611 | |
603 | 612 | function html_substr($str, $start, $length = NULL) |
604 | 613 | { |
605 | - if ($length === 0) |
|
606 | - return ""; |
|
614 | + if ($length === 0) { |
|
615 | + return ""; |
|
616 | + } |
|
607 | 617 | //check if we can simply use the built-in functions |
608 | 618 | if (strpos($str, '&') === false) { //No entities. Use built-in functions |
609 | - if ($length === NULL) |
|
610 | - return substr($str, $start); |
|
611 | - else |
|
612 | - return substr($str, $start, $length); |
|
619 | + if ($length === NULL) { |
|
620 | + return substr($str, $start); |
|
621 | + } else { |
|
622 | + return substr($str, $start, $length); |
|
623 | + } |
|
613 | 624 | } |
614 | 625 | |
615 | 626 | // create our array of characters and html entities |
616 | 627 | $chars = preg_split('/(&[^;\s]+;)|/', $str, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE); |
617 | 628 | $html_length = count($chars); |
618 | 629 | // check if we can predict the return value and save some processing time |
619 | - if (($html_length === 0) || ( $start >= $html_length) || ( isset($length) && ( $length <= -$html_length))) |
|
620 | - return ""; |
|
630 | + if (($html_length === 0) || ( $start >= $html_length) || ( isset($length) && ( $length <= -$html_length))) { |
|
631 | + return ""; |
|
632 | + } |
|
621 | 633 | |
622 | 634 | //calculate start position |
623 | 635 | if ($start >= 0) { |
@@ -626,9 +638,10 @@ discard block |
||
626 | 638 | $start = max($start, -$html_length); |
627 | 639 | $real_start = $chars[$html_length + $start][1]; |
628 | 640 | } |
629 | - if (!isset($length)) // no $length argument passed, return all remaining characters |
|
641 | + if (!isset($length)) { |
|
642 | + // no $length argument passed, return all remaining characters |
|
630 | 643 | return substr($str, $real_start); |
631 | - else if ($length > 0) { // copy $length chars |
|
644 | + } else if ($length > 0) { // copy $length chars |
|
632 | 645 | if ($start + $length >= $html_length) { // return all remaining characters |
633 | 646 | return substr($str, $real_start); |
634 | 647 | } else { //return $length characters |
@@ -18,6 +18,9 @@ discard block |
||
18 | 18 | $__cache_vtiger_imagepath = []; |
19 | 19 | } |
20 | 20 | |
21 | +/** |
|
22 | + * @param string $imagename |
|
23 | + */ |
|
21 | 24 | function vtiger_imageurl($imagename, $themename) |
22 | 25 | { |
23 | 26 | global $__cache_vtiger_imagepath; |
@@ -200,6 +203,9 @@ discard block |
||
200 | 203 | } |
201 | 204 | } |
202 | 205 | |
206 | +/** |
|
207 | + * @param string $varname |
|
208 | + */ |
|
203 | 209 | function __vtlib_get_modulevar_value($module, $varname) |
204 | 210 | { |
205 | 211 | $mod_var_mapping = Array( |
@@ -497,7 +503,6 @@ discard block |
||
497 | 503 | /** |
498 | 504 | * Purify (Cleanup) malicious snippets of code from the input |
499 | 505 | * |
500 | - * @param String $value |
|
501 | 506 | * @param Boolean $ignore Skip cleaning of the input |
502 | 507 | * @return String |
503 | 508 | */ |
@@ -156,10 +156,11 @@ discard block |
||
156 | 156 | $old_dieOnError = $adb->dieOnError; |
157 | 157 | $adb->dieOnError = false; |
158 | 158 | |
159 | - if ($enable_disable === true) |
|
160 | - $enable_disable = 1; |
|
161 | - else if ($enable_disable === false) |
|
162 | - $enable_disable = 0; |
|
159 | + if ($enable_disable === true) { |
|
160 | + $enable_disable = 1; |
|
161 | + } else if ($enable_disable === false) { |
|
162 | + $enable_disable = 0; |
|
163 | + } |
|
163 | 164 | |
164 | 165 | $adb->pquery('UPDATE vtiger_language set active = ? WHERE prefix = ?', Array($enable_disable, $langprefix)); |
165 | 166 | |
@@ -195,8 +196,9 @@ discard block |
||
195 | 196 | |
196 | 197 | $checkfor = Array('table_name', 'table_index', 'related_tables', 'popup_fields', 'IsCustomModule'); |
197 | 198 | foreach ($checkfor as $check) { |
198 | - if (!isset($focus->$check)) |
|
199 | - $focus->$check = __vtlib_get_modulevar_value($module, $check); |
|
199 | + if (!isset($focus->$check)) { |
|
200 | + $focus->$check = __vtlib_get_modulevar_value($module, $check); |
|
201 | + } |
|
200 | 202 | } |
201 | 203 | } |
202 | 204 | |
@@ -356,8 +358,9 @@ discard block |
||
356 | 358 | function vtlib_tosingular($text) |
357 | 359 | { |
358 | 360 | $lastpos = strripos($text, 's'); |
359 | - if ($lastpos == strlen($text) - 1) |
|
360 | - return substr($text, 0, -1); |
|
361 | + if ($lastpos == strlen($text) - 1) { |
|
362 | + return substr($text, 0, -1); |
|
363 | + } |
|
361 | 364 | return $text; |
362 | 365 | } |
363 | 366 | |
@@ -377,8 +380,9 @@ discard block |
||
377 | 380 | $roleresCount = $adb->num_rows($roleres); |
378 | 381 | $allroles = []; |
379 | 382 | if ($roleresCount) { |
380 | - for ($index = 0; $index < $roleresCount; ++$index) |
|
381 | - $allroles[] = $adb->query_result($roleres, $index, 'roleid'); |
|
383 | + for ($index = 0; $index < $roleresCount; ++$index) { |
|
384 | + $allroles[] = $adb->query_result($roleres, $index, 'roleid'); |
|
385 | + } |
|
382 | 386 | } |
383 | 387 | sort($allroles); |
384 | 388 | |
@@ -401,8 +405,9 @@ discard block |
||
401 | 405 | foreach ($picklistval_roles as $picklistval => $pickvalroles) { |
402 | 406 | sort($pickvalroles); |
403 | 407 | $diff = array_diff($pickvalroles, $allroles); |
404 | - if (empty($diff)) |
|
405 | - $allrolevalues[] = $picklistval; |
|
408 | + if (empty($diff)) { |
|
409 | + $allrolevalues[] = $picklistval; |
|
410 | + } |
|
406 | 411 | } |
407 | 412 | |
408 | 413 | $log->debug('Exiting ' . __METHOD__ . ' method ...'); |
@@ -479,8 +484,9 @@ discard block |
||
479 | 484 | $tmpfile = 'vtiger' . time() . '-' . rand(1, 1000) . '.tmp'; |
480 | 485 | // Continue the loop unless we find a name that does not exists already. |
481 | 486 | $usefilename = "$dirpath/$tmpfile"; |
482 | - if (!file_exists($usefilename)) |
|
483 | - break; |
|
487 | + if (!file_exists($usefilename)) { |
|
488 | + break; |
|
489 | + } |
|
484 | 490 | } while (true); |
485 | 491 | $fh = @fopen($usefilename, 'a'); |
486 | 492 | if ($fh) { |
@@ -522,8 +528,9 @@ discard block |
||
522 | 528 | if (!$ignore) { |
523 | 529 | // Initialize the instance if it has not yet done |
524 | 530 | if ($__htmlpurifier_instance == false) { |
525 | - if (empty($use_charset)) |
|
526 | - $use_charset = 'UTF-8'; |
|
531 | + if (empty($use_charset)) { |
|
532 | + $use_charset = 'UTF-8'; |
|
533 | + } |
|
527 | 534 | |
528 | 535 | include_once ('libraries/htmlpurifier/library/HTMLPurifier.auto.php'); |
529 | 536 | |
@@ -590,8 +597,9 @@ discard block |
||
590 | 597 | if (!$ignore) { |
591 | 598 | // Initialize the instance if it has not yet done |
592 | 599 | if ($htmlPurifierForHtml == false) { |
593 | - if (empty($use_charset)) |
|
594 | - $use_charset = 'UTF-8'; |
|
600 | + if (empty($use_charset)) { |
|
601 | + $use_charset = 'UTF-8'; |
|
602 | + } |
|
595 | 603 | |
596 | 604 | include_once ('libraries/htmlpurifier/library/HTMLPurifier.auto.php'); |
597 | 605 |
@@ -48,6 +48,9 @@ |
||
48 | 48 | return $row; |
49 | 49 | } |
50 | 50 | |
51 | + /** |
|
52 | + * @param boolean $t |
|
53 | + */ |
|
51 | 54 | public static function sanitizeData($newRow, $meta, $t = null) |
52 | 55 | { |
53 | 56 |
@@ -24,8 +24,9 @@ discard block |
||
24 | 24 | $fieldColumnMapping = $meta->getFieldColumnMapping(); |
25 | 25 | $columnFieldMapping = array_flip($fieldColumnMapping); |
26 | 26 | foreach ($row as $col => $val) { |
27 | - if (array_key_exists($col, $columnFieldMapping)) |
|
28 | - $newRow[$columnFieldMapping[$col]] = $val; |
|
27 | + if (array_key_exists($col, $columnFieldMapping)) { |
|
28 | + $newRow[$columnFieldMapping[$col]] = $val; |
|
29 | + } |
|
29 | 30 | } |
30 | 31 | $newRow = DataTransform::sanitizeData($newRow, $meta, true); |
31 | 32 | return $newRow; |
@@ -149,8 +150,9 @@ discard block |
||
149 | 150 | $allFields = $meta->getFieldColumnMapping(); |
150 | 151 | $newRow = []; |
151 | 152 | foreach ($allFields as $field => $col) { |
152 | - if (isset($row[$field])) |
|
153 | - $newRow[$field] = $row[$field]; |
|
153 | + if (isset($row[$field])) { |
|
154 | + $newRow[$field] = $row[$field]; |
|
155 | + } |
|
154 | 156 | } |
155 | 157 | if (isset($row[$recordString])) { |
156 | 158 | $newRow[$recordString] = $row[$recordString]; |