@@ -53,6 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Get type of package (as specified in manifest) |
56 | + * @return string |
|
56 | 57 | */ |
57 | 58 | public function type() |
58 | 59 | { |
@@ -393,6 +394,7 @@ discard block |
||
393 | 394 | /** |
394 | 395 | * Cache the field instance for re-use |
395 | 396 | * @access private |
397 | + * @param Field $fieldInstance |
|
396 | 398 | */ |
397 | 399 | public function __AddModuleFieldToCache($moduleInstance, $fieldname, $fieldInstance) |
398 | 400 | { |
@@ -674,6 +676,8 @@ discard block |
||
674 | 676 | /** |
675 | 677 | * Import Blocks of the module |
676 | 678 | * @access private |
679 | + * @param \SimpleXMLElement $modulenode |
|
680 | + * @param Module $moduleInstance |
|
677 | 681 | */ |
678 | 682 | public function import_Blocks($modulenode, $moduleInstance) |
679 | 683 | { |
@@ -717,6 +721,7 @@ discard block |
||
717 | 721 | /** |
718 | 722 | * Import Fields of the module |
719 | 723 | * @access private |
724 | + * @param Block $blockInstance |
|
720 | 725 | */ |
721 | 726 | public function import_Fields($blocknode, $blockInstance, $moduleInstance) |
722 | 727 | { |
@@ -807,6 +812,8 @@ discard block |
||
807 | 812 | /** |
808 | 813 | * Import Custom views of the module |
809 | 814 | * @access private |
815 | + * @param \SimpleXMLElement $modulenode |
|
816 | + * @param Module $moduleInstance |
|
810 | 817 | */ |
811 | 818 | public function import_CustomViews($modulenode, $moduleInstance) |
812 | 819 | { |
@@ -851,6 +858,8 @@ discard block |
||
851 | 858 | /** |
852 | 859 | * Import Sharing Access of the module |
853 | 860 | * @access private |
861 | + * @param \SimpleXMLElement $modulenode |
|
862 | + * @param Module $moduleInstance |
|
854 | 863 | */ |
855 | 864 | public function import_SharingAccess($modulenode, $moduleInstance) |
856 | 865 | { |
@@ -867,6 +876,8 @@ discard block |
||
867 | 876 | /** |
868 | 877 | * Import Events of the module |
869 | 878 | * @access private |
879 | + * @param \SimpleXMLElement $modulenode |
|
880 | + * @param Module $moduleInstance |
|
870 | 881 | */ |
871 | 882 | public function import_Events($modulenode, $moduleInstance) |
872 | 883 | { |
@@ -899,6 +910,8 @@ discard block |
||
899 | 910 | /** |
900 | 911 | * Import actions of the module |
901 | 912 | * @access private |
913 | + * @param \SimpleXMLElement $modulenode |
|
914 | + * @param Module $moduleInstance |
|
902 | 915 | */ |
903 | 916 | public function import_Actions($modulenode, $moduleInstance) |
904 | 917 | { |
@@ -925,6 +938,8 @@ discard block |
||
925 | 938 | /** |
926 | 939 | * Import related lists of the module |
927 | 940 | * @access private |
941 | + * @param \SimpleXMLElement $modulenode |
|
942 | + * @param Module $moduleInstance |
|
928 | 943 | */ |
929 | 944 | public function import_RelatedLists($modulenode, $moduleInstance) |
930 | 945 | { |
@@ -1004,6 +1019,7 @@ discard block |
||
1004 | 1019 | /** |
1005 | 1020 | * Import cron jobs of the module. |
1006 | 1021 | * @access private |
1022 | + * @param \SimpleXMLElement $modulenode |
|
1007 | 1023 | */ |
1008 | 1024 | public function import_CronTasks($modulenode) |
1009 | 1025 | { |
@@ -1022,6 +1038,9 @@ discard block |
||
1022 | 1038 | } |
1023 | 1039 | } |
1024 | 1040 | |
1041 | + /** |
|
1042 | + * @param \SimpleXMLElement $modulenode |
|
1043 | + */ |
|
1025 | 1044 | public function import_update($modulenode) |
1026 | 1045 | { |
1027 | 1046 | $dirName = 'cache/updates'; |
@@ -101,8 +101,9 @@ discard block |
||
101 | 101 | { |
102 | 102 | $xpathres = $this->xpath($path); |
103 | 103 | foreach ($xpathres as $pathkey => $pathvalue) { |
104 | - if ($pathkey == $path) |
|
105 | - return $pathvalue; |
|
104 | + if ($pathkey == $path) { |
|
105 | + return $pathvalue; |
|
106 | + } |
|
106 | 107 | } |
107 | 108 | return false; |
108 | 109 | } |
@@ -121,13 +122,15 @@ discard block |
||
121 | 122 | |
122 | 123 | if ($packagetype) { |
123 | 124 | $lcasetype = strtolower($packagetype); |
124 | - if ($lcasetype == 'language') |
|
125 | - return true; |
|
125 | + if ($lcasetype == 'language') { |
|
126 | + return true; |
|
127 | + } |
|
126 | 128 | } |
127 | 129 | if ($packagetype) { |
128 | 130 | $lcasetype = strtolower($packagetype); |
129 | - if ($lcasetype == 'layout') |
|
130 | - return true; |
|
131 | + if ($lcasetype == 'layout') { |
|
132 | + return true; |
|
133 | + } |
|
131 | 134 | } |
132 | 135 | return false; |
133 | 136 | } |
@@ -146,8 +149,9 @@ discard block |
||
146 | 149 | |
147 | 150 | if ($packagetype) { |
148 | 151 | $lcasetype = strtolower($packagetype); |
149 | - if ($lcasetype == 'extension') |
|
150 | - return true; |
|
152 | + if ($lcasetype == 'extension') { |
|
153 | + return true; |
|
154 | + } |
|
151 | 155 | } |
152 | 156 | return false; |
153 | 157 | } |
@@ -163,8 +167,9 @@ discard block |
||
163 | 167 | |
164 | 168 | if ($packagetype) { |
165 | 169 | $lcasetype = strtolower($packagetype); |
166 | - if ($lcasetype == 'update') |
|
167 | - return true; |
|
170 | + if ($lcasetype == 'update') { |
|
171 | + return true; |
|
172 | + } |
|
168 | 173 | } |
169 | 174 | return false; |
170 | 175 | } |
@@ -183,8 +188,9 @@ discard block |
||
183 | 188 | |
184 | 189 | if ($packagetype) { |
185 | 190 | $lcasetype = strtolower($packagetype); |
186 | - if ($lcasetype == 'layout') |
|
187 | - return true; |
|
191 | + if ($lcasetype == 'layout') { |
|
192 | + return true; |
|
193 | + } |
|
188 | 194 | } |
189 | 195 | return false; |
190 | 196 | } |
@@ -227,8 +233,9 @@ discard block |
||
227 | 233 | public function getParameters() |
228 | 234 | { |
229 | 235 | $parameters = []; |
230 | - if (empty($this->_modulexml->parameters)) |
|
231 | - return $parameters; |
|
236 | + if (empty($this->_modulexml->parameters)) { |
|
237 | + return $parameters; |
|
238 | + } |
|
232 | 239 | foreach ($this->_modulexml->parameters->parameter as $parameter) { |
233 | 240 | $parameters[] = $parameter; |
234 | 241 | } |
@@ -338,17 +345,21 @@ discard block |
||
338 | 345 | } |
339 | 346 | |
340 | 347 | $validzip = false; |
341 | - if ($manifestxml_found && $languagefile_found && $moduleVersionFound) |
|
342 | - $validzip = true; |
|
348 | + if ($manifestxml_found && $languagefile_found && $moduleVersionFound) { |
|
349 | + $validzip = true; |
|
350 | + } |
|
343 | 351 | |
344 | - if ($manifestxml_found && $layoutfile_found && $moduleVersionFound) |
|
345 | - $validzip = true; |
|
352 | + if ($manifestxml_found && $layoutfile_found && $moduleVersionFound) { |
|
353 | + $validzip = true; |
|
354 | + } |
|
346 | 355 | |
347 | - if ($manifestxml_found && $languagefile_found && $extensionfile_found && $moduleVersionFound) |
|
348 | - $validzip = true; |
|
356 | + if ($manifestxml_found && $languagefile_found && $extensionfile_found && $moduleVersionFound) { |
|
357 | + $validzip = true; |
|
358 | + } |
|
349 | 359 | |
350 | - if ($manifestxml_found && $updatefile_found && $moduleVersionFound) |
|
351 | - $validzip = true; |
|
360 | + if ($manifestxml_found && $updatefile_found && $moduleVersionFound) { |
|
361 | + $validzip = true; |
|
362 | + } |
|
352 | 363 | |
353 | 364 | if ($validzip) { |
354 | 365 | if (!empty($this->_modulexml->license)) { |
@@ -365,8 +376,9 @@ discard block |
||
365 | 376 | } |
366 | 377 | } |
367 | 378 | } |
368 | - if ($unzip) |
|
369 | - $unzip->close(); |
|
379 | + if ($unzip) { |
|
380 | + $unzip->close(); |
|
381 | + } |
|
370 | 382 | return $validzip; |
371 | 383 | } |
372 | 384 | |
@@ -376,8 +388,9 @@ discard block |
||
376 | 388 | */ |
377 | 389 | public function getModuleNameFromZip($zipfile) |
378 | 390 | { |
379 | - if (!$this->checkZip($zipfile)) |
|
380 | - return null; |
|
391 | + if (!$this->checkZip($zipfile)) { |
|
392 | + return null; |
|
393 | + } |
|
381 | 394 | return (string) $this->_modulexml->name; |
382 | 395 | } |
383 | 396 | |
@@ -453,8 +466,9 @@ discard block |
||
453 | 466 | $unzip->unzip("$module.png", 'layouts/' . \Vtiger_Viewer::getDefaultLayoutName() . "/skins/images/$module.png"); |
454 | 467 | } |
455 | 468 | |
456 | - if ($unzip) |
|
457 | - $unzip->close(); |
|
469 | + if ($unzip) { |
|
470 | + $unzip->close(); |
|
471 | + } |
|
458 | 472 | } |
459 | 473 | return $module; |
460 | 474 | } |
@@ -642,8 +656,9 @@ discard block |
||
642 | 656 | */ |
643 | 657 | public function import_Tables($modulenode) |
644 | 658 | { |
645 | - if (empty($modulenode->tables) || empty($modulenode->tables->table)) |
|
646 | - return; |
|
659 | + if (empty($modulenode->tables) || empty($modulenode->tables->table)) { |
|
660 | + return; |
|
661 | + } |
|
647 | 662 | $adb = \PearDatabase::getInstance(); |
648 | 663 | $adb->query('SET FOREIGN_KEY_CHECKS = 0;'); |
649 | 664 | |
@@ -677,8 +692,9 @@ discard block |
||
677 | 692 | */ |
678 | 693 | public function import_Blocks($modulenode, $moduleInstance) |
679 | 694 | { |
680 | - if (empty($modulenode->blocks) || empty($modulenode->blocks->block)) |
|
681 | - return; |
|
695 | + if (empty($modulenode->blocks) || empty($modulenode->blocks->block)) { |
|
696 | + return; |
|
697 | + } |
|
682 | 698 | foreach ($modulenode->blocks->block as $blocknode) { |
683 | 699 | $blockInstance = $this->import_Block($modulenode, $moduleInstance, $blocknode); |
684 | 700 | $this->import_Fields($blocknode, $blockInstance, $moduleInstance); |
@@ -697,8 +713,9 @@ discard block |
||
697 | 713 | $blockInstance->label = $blocklabel; |
698 | 714 | if (isset($blocknode->sequence) && isset($blocknode->display_status)) { |
699 | 715 | $blockInstance->sequence = strval($blocknode->sequence); |
700 | - if ($blockInstance->sequence = "") |
|
701 | - $blockInstance->sequence = NULL; |
|
716 | + if ($blockInstance->sequence = "") { |
|
717 | + $blockInstance->sequence = NULL; |
|
718 | + } |
|
702 | 719 | $blockInstance->showtitle = strval($blocknode->show_title); |
703 | 720 | $blockInstance->visible = strval($blocknode->visible); |
704 | 721 | $blockInstance->increateview = strval($blocknode->create_view); |
@@ -720,8 +737,9 @@ discard block |
||
720 | 737 | */ |
721 | 738 | public function import_Fields($blocknode, $blockInstance, $moduleInstance) |
722 | 739 | { |
723 | - if (empty($blocknode->fields) || empty($blocknode->fields->field)) |
|
724 | - return; |
|
740 | + if (empty($blocknode->fields) || empty($blocknode->fields->field)) { |
|
741 | + return; |
|
742 | + } |
|
725 | 743 | |
726 | 744 | foreach ($blocknode->fields->field as $fieldnode) { |
727 | 745 | $fieldInstance = $this->import_Field($blocknode, $blockInstance, $moduleInstance, $fieldnode); |
@@ -752,17 +770,21 @@ discard block |
||
752 | 770 | $fieldInstance->displaytype = $fieldnode->displaytype; |
753 | 771 | $fieldInstance->info_type = $fieldnode->info_type; |
754 | 772 | |
755 | - if (!empty($fieldnode->fieldparams)) |
|
756 | - $fieldInstance->fieldparams = $fieldnode->fieldparams; |
|
773 | + if (!empty($fieldnode->fieldparams)) { |
|
774 | + $fieldInstance->fieldparams = $fieldnode->fieldparams; |
|
775 | + } |
|
757 | 776 | |
758 | - if (!empty($fieldnode->helpinfo)) |
|
759 | - $fieldInstance->helpinfo = $fieldnode->helpinfo; |
|
777 | + if (!empty($fieldnode->helpinfo)) { |
|
778 | + $fieldInstance->helpinfo = $fieldnode->helpinfo; |
|
779 | + } |
|
760 | 780 | |
761 | - if (isset($fieldnode->masseditable)) |
|
762 | - $fieldInstance->masseditable = $fieldnode->masseditable; |
|
781 | + if (isset($fieldnode->masseditable)) { |
|
782 | + $fieldInstance->masseditable = $fieldnode->masseditable; |
|
783 | + } |
|
763 | 784 | |
764 | - if (isset($fieldnode->columntype) && !empty($fieldnode->columntype)) |
|
765 | - $fieldInstance->columntype = strval($fieldnode->columntype); |
|
785 | + if (isset($fieldnode->columntype) && !empty($fieldnode->columntype)) { |
|
786 | + $fieldInstance->columntype = strval($fieldnode->columntype); |
|
787 | + } |
|
766 | 788 | |
767 | 789 | if (!empty($fieldnode->tree_template)) { |
768 | 790 | $templateid = $fieldInstance->setTreeTemplate($fieldnode->tree_template, $moduleInstance); |
@@ -810,8 +832,9 @@ discard block |
||
810 | 832 | */ |
811 | 833 | public function import_CustomViews($modulenode, $moduleInstance) |
812 | 834 | { |
813 | - if (empty($modulenode->customviews) || empty($modulenode->customviews->customview)) |
|
814 | - return; |
|
835 | + if (empty($modulenode->customviews) || empty($modulenode->customviews->customview)) { |
|
836 | + return; |
|
837 | + } |
|
815 | 838 | foreach ($modulenode->customviews->customview as $customviewnode) { |
816 | 839 | $this->import_CustomView($modulenode, $moduleInstance, $customviewnode); |
817 | 840 | } |
@@ -854,8 +877,9 @@ discard block |
||
854 | 877 | */ |
855 | 878 | public function import_SharingAccess($modulenode, $moduleInstance) |
856 | 879 | { |
857 | - if (empty($modulenode->sharingaccess)) |
|
858 | - return; |
|
880 | + if (empty($modulenode->sharingaccess)) { |
|
881 | + return; |
|
882 | + } |
|
859 | 883 | |
860 | 884 | if (!empty($modulenode->sharingaccess->default)) { |
861 | 885 | foreach ($modulenode->sharingaccess->default as $defaultnode) { |
@@ -885,8 +909,9 @@ discard block |
||
885 | 909 | */ |
886 | 910 | public function import_Actions($modulenode, $moduleInstance) |
887 | 911 | { |
888 | - if (empty($modulenode->actions) || empty($modulenode->actions->action)) |
|
889 | - return; |
|
912 | + if (empty($modulenode->actions) || empty($modulenode->actions->action)) { |
|
913 | + return; |
|
914 | + } |
|
890 | 915 | foreach ($modulenode->actions->action as $actionnode) { |
891 | 916 | $this->import_Action($modulenode, $moduleInstance, $actionnode); |
892 | 917 | } |
@@ -899,10 +924,11 @@ discard block |
||
899 | 924 | public function import_Action($modulenode, $moduleInstance, $actionnode) |
900 | 925 | { |
901 | 926 | $actionstatus = $actionnode->status; |
902 | - if ($actionstatus == 'enabled') |
|
903 | - $moduleInstance->enableTools($actionnode->name); |
|
904 | - else |
|
905 | - $moduleInstance->disableTools($actionnode->name); |
|
927 | + if ($actionstatus == 'enabled') { |
|
928 | + $moduleInstance->enableTools($actionnode->name); |
|
929 | + } else { |
|
930 | + $moduleInstance->disableTools($actionnode->name); |
|
931 | + } |
|
906 | 932 | } |
907 | 933 | |
908 | 934 | /** |
@@ -967,8 +993,9 @@ discard block |
||
967 | 993 | */ |
968 | 994 | public function import_CustomLinks($modulenode, $moduleInstance) |
969 | 995 | { |
970 | - if (empty($modulenode->customlinks) || empty($modulenode->customlinks->customlink)) |
|
971 | - return; |
|
996 | + if (empty($modulenode->customlinks) || empty($modulenode->customlinks->customlink)) { |
|
997 | + return; |
|
998 | + } |
|
972 | 999 | |
973 | 1000 | foreach ($modulenode->customlinks->customlink as $customlinknode) { |
974 | 1001 | $handlerInfo = null; |
@@ -990,8 +1017,9 @@ discard block |
||
990 | 1017 | */ |
991 | 1018 | public function import_CronTasks($modulenode) |
992 | 1019 | { |
993 | - if (empty($modulenode->crons) || empty($modulenode->crons->cron)) |
|
994 | - return; |
|
1020 | + if (empty($modulenode->crons) || empty($modulenode->crons->cron)) { |
|
1021 | + return; |
|
1022 | + } |
|
995 | 1023 | foreach ($modulenode->crons->cron as $cronTask) { |
996 | 1024 | if (empty($cronTask->status)) { |
997 | 1025 | $cronTask->status = Cron::$STATUS_DISABLED; |
@@ -1052,8 +1080,9 @@ discard block |
||
1052 | 1080 | */ |
1053 | 1081 | public function importInventory() |
1054 | 1082 | { |
1055 | - if (empty($this->_modulexml->inventory) || empty($this->_modulexml->inventory->fields->field)) |
|
1056 | - return false; |
|
1083 | + if (empty($this->_modulexml->inventory) || empty($this->_modulexml->inventory->fields->field)) { |
|
1084 | + return false; |
|
1085 | + } |
|
1057 | 1086 | $module = (string) $this->moduleInstance->name; |
1058 | 1087 | |
1059 | 1088 | $inventoryInstance = \Vtiger_Inventory_Model::getInstance($module); |
@@ -28,6 +28,7 @@ |
||
28 | 28 | /** |
29 | 29 | * Initialize Import |
30 | 30 | * @access private |
31 | + * @param boolean $overwrite |
|
31 | 32 | */ |
32 | 33 | public function initImport($zipfile, $overwrite) |
33 | 34 | { |
@@ -84,8 +84,9 @@ discard block |
||
84 | 84 | foreach ($filelist as $filename => $fileinfo) { |
85 | 85 | if (!$unzip->isdir($filename)) { |
86 | 86 | |
87 | - if (strpos($filename, '/') === false) |
|
88 | - continue; |
|
87 | + if (strpos($filename, '/') === false) { |
|
88 | + continue; |
|
89 | + } |
|
89 | 90 | |
90 | 91 | $targetdir = substr($filename, 0, strripos($filename, '/')); |
91 | 92 | $targetfile = basename($filename); |
@@ -146,8 +147,9 @@ discard block |
||
146 | 147 | } |
147 | 148 | } |
148 | 149 | } |
149 | - if ($unzip) |
|
150 | - $unzip->close(); |
|
150 | + if ($unzip) { |
|
151 | + $unzip->close(); |
|
152 | + } |
|
151 | 153 | |
152 | 154 | self::register($prefix, $label, $name); |
153 | 155 |
@@ -112,6 +112,7 @@ |
||
112 | 112 | /** |
113 | 113 | * Clean up the input to be used as a regex |
114 | 114 | * @access private |
115 | + * @param string $value |
|
115 | 116 | */ |
116 | 117 | public function __formatAsRegex($value) |
117 | 118 | { |
@@ -70,8 +70,9 @@ discard block |
||
70 | 70 | unset($this->tplvars); |
71 | 71 | |
72 | 72 | $this->tplvars = []; |
73 | - foreach ($restorevars as $key => $val) |
|
74 | - $this->assign($key, $val); |
|
73 | + foreach ($restorevars as $key => $val) { |
|
74 | + $this->assign($key, $val); |
|
75 | + } |
|
75 | 76 | } |
76 | 77 | |
77 | 78 | /** |
@@ -82,8 +83,9 @@ discard block |
||
82 | 83 | */ |
83 | 84 | public function merge($instring, $avoidLookup = false) |
84 | 85 | { |
85 | - if (empty($instring)) |
|
86 | - return $instring; |
|
86 | + if (empty($instring)) { |
|
87 | + return $instring; |
|
88 | + } |
|
87 | 89 | |
88 | 90 | if (!$avoidLookup) { |
89 | 91 |
@@ -20,6 +20,7 @@ discard block |
||
20 | 20 | * Helper function to log messages |
21 | 21 | * @param String Message to log |
22 | 22 | * @param Boolean true appends linebreak, false to avoid it |
23 | + * @param string $message |
|
23 | 24 | * @access private |
24 | 25 | */ |
25 | 26 | static function log($message, $delim = true) |
@@ -30,6 +31,7 @@ discard block |
||
30 | 31 | /** |
31 | 32 | * Initialize webservice for the given module |
32 | 33 | * @param Module Instance of the module. |
34 | + * @param Module $moduleInstance |
|
33 | 35 | */ |
34 | 36 | static function initialize($moduleInstance) |
35 | 37 | { |
@@ -45,6 +47,7 @@ discard block |
||
45 | 47 | /** |
46 | 48 | * Initialize webservice for the given module |
47 | 49 | * @param Module Instance of the module. |
50 | + * @param Module $moduleInstance |
|
48 | 51 | */ |
49 | 52 | static function uninitialize($moduleInstance) |
50 | 53 | { |
@@ -69,6 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | /** |
71 | 71 | * Normalize the directory path separators. |
72 | + * @param string $path |
|
72 | 73 | */ |
73 | 74 | public function __normalizePath($path) |
74 | 75 | { |
@@ -79,6 +80,7 @@ discard block |
||
79 | 80 | |
80 | 81 | /** |
81 | 82 | * Copy the directory on the disk into zip file. |
83 | + * @param string $zipdirname |
|
82 | 84 | */ |
83 | 85 | public function copyDirectoryFromDisk($dirname, $zipdirname = null, $excludeList = null, $basedirname = null) |
84 | 86 | { |
@@ -50,8 +50,9 @@ discard block |
||
50 | 50 | if ($search_index === 0) { |
51 | 51 | $startindex = strlen($base_realpath) + 1; |
52 | 52 | // On windows $base_realpath ends with / and On Linux it will not have / at end! |
53 | - if (strrpos($base_realpath, '/') == strlen($base_realpath) - 1) |
|
54 | - $startindex -= 1; |
|
53 | + if (strrpos($base_realpath, '/') == strlen($base_realpath) - 1) { |
|
54 | + $startindex -= 1; |
|
55 | + } |
|
55 | 56 | $relpath = substr($src_realpath, $startindex); |
56 | 57 | } |
57 | 58 | return $relpath; |
@@ -62,8 +63,9 @@ discard block |
||
62 | 63 | */ |
63 | 64 | public function __fixDirSeparator($path) |
64 | 65 | { |
65 | - if ($path != '' && (strripos($path, '/') != strlen($path) - 1)) |
|
66 | - $path .= '/'; |
|
66 | + if ($path != '' && (strripos($path, '/') != strlen($path) - 1)) { |
|
67 | + $path .= '/'; |
|
68 | + } |
|
67 | 69 | return $path; |
68 | 70 | } |
69 | 71 | |
@@ -72,8 +74,9 @@ discard block |
||
72 | 74 | */ |
73 | 75 | public function __normalizePath($path) |
74 | 76 | { |
75 | - if ($path && strpos($path, '\\') !== false) |
|
76 | - $path = preg_replace("/\\\\/", "/", $path); |
|
77 | + if ($path && strpos($path, '\\') !== false) { |
|
78 | + $path = preg_replace("/\\\\/", "/", $path); |
|
79 | + } |
|
77 | 80 | return $path; |
78 | 81 | } |
79 | 82 | |
@@ -83,18 +86,21 @@ discard block |
||
83 | 86 | public function copyDirectoryFromDisk($dirname, $zipdirname = null, $excludeList = null, $basedirname = null) |
84 | 87 | { |
85 | 88 | $dir = opendir($dirname); |
86 | - if (strripos($dirname, '/') != strlen($dirname) - 1) |
|
87 | - $dirname .= '/'; |
|
89 | + if (strripos($dirname, '/') != strlen($dirname) - 1) { |
|
90 | + $dirname .= '/'; |
|
91 | + } |
|
88 | 92 | |
89 | - if ($basedirname === null) |
|
90 | - $basedirname = realpath($dirname); |
|
93 | + if ($basedirname === null) { |
|
94 | + $basedirname = realpath($dirname); |
|
95 | + } |
|
91 | 96 | |
92 | 97 | while (false !== ($file = readdir($dir))) { |
93 | 98 | if ($file != '.' && $file != '..' && |
94 | 99 | $file != '.svn' && $file != 'CVS') { |
95 | 100 | // Exclude the file/directory |
96 | - if (!empty($excludeList) && in_array("$dirname$file", $excludeList)) |
|
97 | - continue; |
|
101 | + if (!empty($excludeList) && in_array("$dirname$file", $excludeList)) { |
|
102 | + continue; |
|
103 | + } |
|
98 | 104 | |
99 | 105 | if (is_dir("$dirname$file")) { |
100 | 106 | $this->copyDirectoryFromDisk("$dirname$file", $zipdirname, $excludeList, $basedirname); |
@@ -98,7 +98,6 @@ |
||
98 | 98 | * @param string $pubkey A public key for reCAPTCHA |
99 | 99 | * @param string $error The error given by reCAPTCHA (optional, default is null) |
100 | 100 | * @param boolean $use_ssl Should the request be made over ssl? (optional, default is false) |
101 | - |
|
102 | 101 | * @return string - The HTML to be embedded in the user's form. |
103 | 102 | */ |
104 | 103 | function recaptcha_get_html($pubkey, $error = null, $use_ssl = false) |
@@ -77,7 +77,7 @@ |
||
77 | 77 | $http_request .= $req; |
78 | 78 | |
79 | 79 | $response = ''; |
80 | - if (false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) )) { |
|
80 | + if (false == ($fs = @fsockopen($host, $port, $errno, $errstr, 10))) { |
|
81 | 81 | die('Could not open socket'); |
82 | 82 | } |
83 | 83 |
@@ -47,8 +47,9 @@ discard block |
||
47 | 47 | function _recaptcha_qsencode($data) |
48 | 48 | { |
49 | 49 | $req = ""; |
50 | - foreach ($data as $key => $value) |
|
51 | - $req .= $key . '=' . urlencode(stripslashes($value)) . '&'; |
|
50 | + foreach ($data as $key => $value) { |
|
51 | + $req .= $key . '=' . urlencode(stripslashes($value)) . '&'; |
|
52 | + } |
|
52 | 53 | |
53 | 54 | // Cut the last '&' |
54 | 55 | $req = substr($req, 0, strlen($req) - 1); |
@@ -83,8 +84,10 @@ discard block |
||
83 | 84 | |
84 | 85 | fwrite($fs, $http_request); |
85 | 86 | |
86 | - while (!feof($fs)) |
|
87 | - $response .= fgets($fs, 1160); // One TCP-IP packet |
|
87 | + while (!feof($fs)) { |
|
88 | + $response .= fgets($fs, 1160); |
|
89 | + } |
|
90 | + // One TCP-IP packet |
|
88 | 91 | fclose($fs); |
89 | 92 | $response = explode("\r\n\r\n", $response, 2); |
90 | 93 |
@@ -206,6 +206,9 @@ discard block |
||
206 | 206 | } |
207 | 207 | /* Mailhide related code */ |
208 | 208 | |
209 | +/** |
|
210 | + * @param string $ky |
|
211 | + */ |
|
209 | 212 | function _recaptcha_aes_encrypt($val, $ky) |
210 | 213 | { |
211 | 214 | if (!function_exists("mcrypt_encrypt")) { |
@@ -217,6 +220,9 @@ discard block |
||
217 | 220 | return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); |
218 | 221 | } |
219 | 222 | |
223 | +/** |
|
224 | + * @param string $x |
|
225 | + */ |
|
220 | 226 | function _recaptcha_mailhide_urlbase64($x) |
221 | 227 | { |
222 | 228 | return strtr(base64_encode($x), '+/', '-_'); |
@@ -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 | } |
@@ -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; |
@@ -66,6 +66,9 @@ discard block |
||
66 | 66 | // helper functions |
67 | 67 | // ----------------------------------------------------------------------------- |
68 | 68 | // get html dom from file |
69 | +/** |
|
70 | + * @param string $url |
|
71 | + */ |
|
69 | 72 | function file_get_html($url, $use_include_path = false, $context = null, $offset = -1, $maxLen = -1, $lowercase = true, $forceTagsClosed = true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT) |
70 | 73 | { |
71 | 74 | // We DO force the tags to be terminated. |
@@ -120,6 +123,9 @@ discard block |
||
120 | 123 | public $tag_start = 0; |
121 | 124 | private $dom = null; |
122 | 125 | |
126 | + /** |
|
127 | + * @param simple_html_dom $dom |
|
128 | + */ |
|
123 | 129 | public function __construct($dom) |
124 | 130 | { |
125 | 131 | $this->dom = $dom; |
@@ -1552,6 +1558,10 @@ discard block |
||
1552 | 1558 | } |
1553 | 1559 | |
1554 | 1560 | // parse attributes |
1561 | +/** |
|
1562 | + * @param simple_html_dom_node $node |
|
1563 | + * @param string[] $space |
|
1564 | + */ |
|
1555 | 1565 | protected function parse_attr($node, $name, &$space) |
1556 | 1566 | { |
1557 | 1567 | // Per sourceforge: http://sourceforge.net/tracker/?func=detail&aid=3061408&group_id=218559&atid=1044037 |
@@ -1588,6 +1598,10 @@ discard block |
||
1588 | 1598 | } |
1589 | 1599 | |
1590 | 1600 | // link node's parent |
1601 | +/** |
|
1602 | + * @param simple_html_dom_node $node |
|
1603 | + * @param boolean $is_child |
|
1604 | + */ |
|
1591 | 1605 | protected function link_nodes(&$node, $is_child) |
1592 | 1606 | { |
1593 | 1607 | $node->parent = $this->parent; |
@@ -1598,6 +1612,9 @@ discard block |
||
1598 | 1612 | } |
1599 | 1613 | |
1600 | 1614 | // as a text node |
1615 | +/** |
|
1616 | + * @param string $tag |
|
1617 | + */ |
|
1601 | 1618 | protected function as_text_node($tag) |
1602 | 1619 | { |
1603 | 1620 | $node = new simple_html_dom_node($this); |
@@ -1608,12 +1625,18 @@ discard block |
||
1608 | 1625 | return true; |
1609 | 1626 | } |
1610 | 1627 | |
1628 | +/** |
|
1629 | + * @param string $chars |
|
1630 | + */ |
|
1611 | 1631 | protected function skip($chars) |
1612 | 1632 | { |
1613 | 1633 | $this->pos += strspn($this->doc, $chars, $this->pos); |
1614 | 1634 | $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next |
1615 | 1635 | } |
1616 | 1636 | |
1637 | +/** |
|
1638 | + * @param string $chars |
|
1639 | + */ |
|
1617 | 1640 | protected function copy_skip($chars) |
1618 | 1641 | { |
1619 | 1642 | $pos = $this->pos; |
@@ -1625,6 +1648,9 @@ discard block |
||
1625 | 1648 | return substr($this->doc, $pos, $len); |
1626 | 1649 | } |
1627 | 1650 | |
1651 | +/** |
|
1652 | + * @param string $chars |
|
1653 | + */ |
|
1628 | 1654 | protected function copy_until($chars) |
1629 | 1655 | { |
1630 | 1656 | $pos = $this->pos; |
@@ -1634,6 +1660,9 @@ discard block |
||
1634 | 1660 | return substr($this->doc, $pos, $len); |
1635 | 1661 | } |
1636 | 1662 | |
1663 | +/** |
|
1664 | + * @param string $char |
|
1665 | + */ |
|
1637 | 1666 | protected function copy_until_char($char) |
1638 | 1667 | { |
1639 | 1668 | if ($this->char === null) |
@@ -1654,6 +1683,9 @@ discard block |
||
1654 | 1683 | return substr($this->doc, $pos_old, $pos - $pos_old); |
1655 | 1684 | } |
1656 | 1685 | |
1686 | +/** |
|
1687 | + * @param string $char |
|
1688 | + */ |
|
1657 | 1689 | protected function copy_until_char_escape($char) |
1658 | 1690 | { |
1659 | 1691 | if ($this->char === null) |
@@ -1685,6 +1717,9 @@ discard block |
||
1685 | 1717 | |
1686 | 1718 | // remove noise from html content |
1687 | 1719 | // save the noise in the $this->noise array. |
1720 | +/** |
|
1721 | + * @param string $pattern |
|
1722 | + */ |
|
1688 | 1723 | protected function remove_noise($pattern, $remove_tag = false) |
1689 | 1724 | { |
1690 | 1725 | global $debugObject; |
@@ -1712,6 +1747,9 @@ discard block |
||
1712 | 1747 | } |
1713 | 1748 | |
1714 | 1749 | // restore noise to html content |
1750 | +/** |
|
1751 | + * @param string|null $text |
|
1752 | + */ |
|
1715 | 1753 | function restore_noise($text) |
1716 | 1754 | { |
1717 | 1755 | global $debugObject; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $moduleTableIndexList = $meta->getEntityTableIndexList(); |
121 | 121 | foreach ($tableList as $index => $tableName) { |
122 | 122 | if ($tableName != $tableList[0]) { |
123 | - $sql .=' INNER JOIN ' . $tableName . ' ON ' . $tableList[0] . '.' . |
|
123 | + $sql .= ' INNER JOIN ' . $tableName . ' ON ' . $tableList[0] . '.' . |
|
124 | 124 | $moduleTableIndexList[$tableList[0]] . '=' . $tableName . '.' . |
125 | 125 | $moduleTableIndexList[$tableName]; |
126 | 126 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | //If module is Leads and if you are not selected any leads fields then query failure is happening. |
129 | 129 | //By default we are checking where condition on base table. |
130 | 130 | if ($module == 'Leads' && !in_array('vtiger_leaddetails', $tableList)) { |
131 | - $sql .=' INNER JOIN vtiger_leaddetails ON vtiger_leaddetails.leadid = vtiger_crmentity.crmid'; |
|
131 | + $sql .= ' INNER JOIN vtiger_leaddetails ON vtiger_leaddetails.leadid = vtiger_crmentity.crmid'; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | $sql .= ' WHERE'; |
@@ -209,8 +209,9 @@ discard block |
||
209 | 209 | $needle = '$' . strtolower($this->module) . '-' . $parentFieldColumnMapping[$params['field']] . ':' . $column . '$'; |
210 | 210 | $this->processedDescription = str_replace($needle, $values[array_search($column, $fieldColumnMapping)], $this->processedDescription); |
211 | 211 | } |
212 | - if (!$params['owner']) |
|
213 | - $this->processedmodules[$module] = true; |
|
212 | + if (!$params['owner']) { |
|
213 | + $this->processedmodules[$module] = true; |
|
214 | + } |
|
214 | 215 | } |
215 | 216 | } |
216 | 217 | } |
@@ -253,7 +254,8 @@ discard block |
||
253 | 254 | $rows = $adb->num_rows($res); |
254 | 255 | if ($rows > 0) { |
255 | 256 | return true; |
256 | - } else |
|
257 | - return false; |
|
257 | + } else { |
|
258 | + return false; |
|
259 | + } |
|
258 | 260 | } |
259 | 261 | } |