Completed
Pull Request — develop (#689)
by
unknown
07:48
created
manager/includes/document.parser.class.inc.php 1 patch
Braces   +53 added lines, -23 removed lines patch added patch discarded remove patch
@@ -701,13 +701,15 @@  discard block
 block discarded – undo
701 701
             $this->virtualDir = '';
702 702
         }
703 703
 
704
-        if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) { /* we got an ID returned, check to make sure it's not an alias */
704
+        if (preg_match('@^[1-9][0-9]*$@', $q) && !isset($this->documentListing[$q])) {
705
+/* we got an ID returned, check to make sure it's not an alias */
705 706
             /* FS#476 and FS#308: check that id is valid in terms of virtualDir structure */
706 707
             if ($this->config['use_alias_path'] == 1) {
707 708
                 if (($this->virtualDir != '' && !isset($this->documentListing[$this->virtualDir . '/' . $q]) || ($this->virtualDir == '' && !isset($this->documentListing[$q]))) && (($this->virtualDir != '' && isset($this->documentListing[$this->virtualDir]) && in_array($q, $this->getChildIds($this->documentListing[$this->virtualDir], 1))) || ($this->virtualDir == '' && in_array($q, $this->getChildIds(0, 1))))) {
708 709
                     $this->documentMethod = 'id';
709 710
                     return $q;
710
-                } else { /* not a valid id in terms of virtualDir, treat as alias */
711
+                } else {
712
+/* not a valid id in terms of virtualDir, treat as alias */
711 713
                     $this->documentMethod = 'alias';
712 714
                     return $q;
713 715
                 }
@@ -715,7 +717,8 @@  discard block
 block discarded – undo
715 717
                 $this->documentMethod = 'id';
716 718
                 return $q;
717 719
             }
718
-        } else { /* we didn't get an ID back, so instead we assume it's an alias */
720
+        } else {
721
+/* we didn't get an ID back, so instead we assume it's an alias */
719 722
             if ($this->config['friendly_alias_urls'] != 1) {
720 723
                 $q = $qOrig;
721 724
             }
@@ -1088,7 +1091,8 @@  discard block
 block discarded – undo
1088 1091
         $where = "pub_date <= {$timeNow} AND pub_date!=0 AND published=0";
1089 1092
         $result_pub = $this->db->select('id', '[+prefix+]site_content', $where);
1090 1093
         $this->db->update($field, '[+prefix+]site_content', $where);
1091
-        if ($this->db->getRecordCount($result_pub) >= 1) { //Event Published doc
1094
+        if ($this->db->getRecordCount($result_pub) >= 1) {
1095
+//Event Published doc
1092 1096
             while ($row_unpub = $this->db->getRow($result_pub)) {
1093 1097
                 $this->invokeEvent("OnDocPublished", array(
1094 1098
                     "docid" => $row_unpub['id']
@@ -1101,7 +1105,8 @@  discard block
 block discarded – undo
1101 1105
         $where = "unpub_date <= {$timeNow} AND unpub_date!=0 AND published=1";
1102 1106
         $result_unpub = $this->db->select('id', '[+prefix+]site_content', $where);
1103 1107
         $this->db->update($field, '[+prefix+]site_content', $where);
1104
-        if ($this->db->getRecordCount($result_unpub) >= 1) { //Event unPublished doc
1108
+        if ($this->db->getRecordCount($result_unpub) >= 1) {
1109
+//Event unPublished doc
1105 1110
             while ($row_unpub = $this->db->getRow($result_unpub)) {
1106 1111
                 $this->invokeEvent("OnDocUnPublished", array(
1107 1112
                     "docid" => $row_unpub['id']
@@ -1188,10 +1193,18 @@  discard block
 block discarded – undo
1188 1193
             return array();
1189 1194
         }
1190 1195
         $spacer = md5('<<<EVO>>>');
1191
-        if ($left === '{{' && strpos($content, ';}}') !== false) $content = str_replace(';}}', sprintf(';}%s}', $spacer), $content);
1192
-        if ($left === '{{' && strpos($content, '{{}}') !== false) $content = str_replace('{{}}', sprintf('{%$1s{}%$1s}', $spacer), $content);
1193
-        if ($left === '[[' && strpos($content, ']]]]') !== false) $content = str_replace(']]]]', sprintf(']]%s]]', $spacer), $content);
1194
-        if ($left === '[[' && strpos($content, ']]]') !== false) $content = str_replace(']]]', sprintf(']%s]]', $spacer), $content);
1196
+        if ($left === '{{' && strpos($content, ';}}') !== false) {
1197
+            $content = str_replace(';}}', sprintf(';}%s}', $spacer), $content);
1198
+        }
1199
+        if ($left === '{{' && strpos($content, '{{}}') !== false) {
1200
+            $content = str_replace('{{}}', sprintf('{%$1s{}%$1s}', $spacer), $content);
1201
+        }
1202
+        if ($left === '[[' && strpos($content, ']]]]') !== false) {
1203
+            $content = str_replace(']]]]', sprintf(']]%s]]', $spacer), $content);
1204
+        }
1205
+        if ($left === '[[' && strpos($content, ']]]') !== false) {
1206
+            $content = str_replace(']]]', sprintf(']%s]]', $spacer), $content);
1207
+        }
1195 1208
 
1196 1209
         $pos['<![CDATA['] = strpos($content, '<![CDATA[');
1197 1210
         $pos[']]>'] = strpos($content, ']]>');
@@ -1244,7 +1257,8 @@  discard block
 block discarded – undo
1244 1257
                         }
1245 1258
                     }
1246 1259
 
1247
-                    if (!in_array($fetch, $tags)) {  // Avoid double Matches
1260
+                    if (!in_array($fetch, $tags)) {
1261
+// Avoid double Matches
1248 1262
                         $tags[] = $fetch; // Fetch
1249 1263
                     };
1250 1264
                     $fetch = ''; // and reset
@@ -1262,7 +1276,9 @@  discard block
 block discarded – undo
1262 1276
             }
1263 1277
         }
1264 1278
         foreach ($tags as $i => $tag) {
1265
-            if (strpos($tag, $spacer) !== false) $tags[$i] = str_replace($spacer, '', $tag);
1279
+            if (strpos($tag, $spacer) !== false) {
1280
+                $tags[$i] = str_replace($spacer, '', $tag);
1281
+            }
1266 1282
         }
1267 1283
         return $tags;
1268 1284
     }
@@ -1302,7 +1318,10 @@  discard block
 block discarded – undo
1302 1318
         }
1303 1319
 
1304 1320
         foreach ($matches[1] as $i => $key) {
1305
-            if (strpos($key, '[+') !== false) continue; // Allow chunk {{chunk?&param=`xxx`}} with [*tv_name_[+param+]*] as content
1321
+            if (strpos($key, '[+') !== false) {
1322
+                continue;
1323
+            }
1324
+            // Allow chunk {{chunk?&param=`xxx`}} with [*tv_name_[+param+]*] as content
1306 1325
             if (substr($key, 0, 1) == '#') {
1307 1326
                 $key = substr($key, 1);
1308 1327
             } // remove # for QuickEdit format
@@ -2027,7 +2046,8 @@  discard block
 block discarded – undo
2027 2046
      * @return mixed|string
2028 2047
      */
2029 2048
     public function _getSGVar($value)
2030
-    { // Get super globals
2049
+    {
2050
+// Get super globals
2031 2051
         $key = $value;
2032 2052
         $_ = $this->config['enable_filter'];
2033 2053
         $this->config['enable_filter'] = 1;
@@ -2431,7 +2451,8 @@  discard block
 block discarded – undo
2431 2451
         if ($this->config['friendly_urls'] == 1) {
2432 2452
             $aliases = array();
2433 2453
             if (is_array($this->documentListing)) {
2434
-                foreach ($this->documentListing as $path => $docid) { // This is big Loop on large site!
2454
+                foreach ($this->documentListing as $path => $docid) {
2455
+// This is big Loop on large site!
2435 2456
                     $aliases[$docid] = $path;
2436 2457
                     $isfolder[$docid] = $this->aliasListing[$docid]['isfolder'];
2437 2458
                 }
@@ -2464,7 +2485,7 @@  discard block
 block discarded – undo
2464 2485
             $isfriendly = ($this->config['friendly_alias_urls'] == 1 ? 1 : 0);
2465 2486
             $pref = $this->config['friendly_url_prefix'];
2466 2487
             $suff = $this->config['friendly_url_suffix'];
2467
-            $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff) {
2488
+            $documentSource = preg_replace_callback($in, function ($m) use ($aliases, $isfolder, $isfriendly, $pref, $suff){
2468 2489
                 global $modx;
2469 2490
                 $thealias = $aliases[$m[1]];
2470 2491
                 $thefolder = $isfolder[$m[1]];
@@ -4240,7 +4261,8 @@  discard block
 block discarded – undo
4240 4261
         if (isset ($this->snippetCache[$snippetName])) {
4241 4262
             $snippet = $this->snippetCache[$snippetName];
4242 4263
             $properties = !empty($this->snippetCache[$snippetName . "Props"]) ? $this->snippetCache[$snippetName . "Props"] : '';
4243
-        } else { // not in cache so let's check the db
4264
+        } else {
4265
+// not in cache so let's check the db
4244 4266
             $sql = "SELECT ss.`name`, ss.`snippet`, ss.`properties`, sm.properties as `sharedproperties` FROM " . $this->getFullTableName("site_snippets") . " as ss LEFT JOIN " . $this->getFullTableName('site_modules') . " as sm on sm.guid=ss.moduleguid WHERE ss.`name`='" . $this->db->escape($snippetName) . "'  AND ss.disabled=0;";
4245 4267
             $result = $this->db->query($sql);
4246 4268
             if ($this->db->getRecordCount($result) == 1) {
@@ -5224,12 +5246,16 @@  discard block
 block discarded – undo
5224 5246
             return '';
5225 5247
         } // nothing to register
5226 5248
         if (!is_array($options)) {
5227
-            if (is_bool($options))  // backward compatibility with old plaintext parameter
5249
+            if (is_bool($options)) {
5250
+                // backward compatibility with old plaintext parameter
5228 5251
             {
5229 5252
                 $options = array('plaintext' => $options);
5230
-            } elseif (is_string($options)) // Also allow script name as 2nd param
5253
+            }
5254
+            } elseif (is_string($options)) {
5255
+                // Also allow script name as 2nd param
5231 5256
             {
5232 5257
                 $options = array('name' => $options);
5258
+            }
5233 5259
             } else {
5234 5260
                 $options = array();
5235 5261
             }
@@ -5241,7 +5267,8 @@  discard block
 block discarded – undo
5241 5267
         unset($overwritepos); // probably unnecessary--just making sure
5242 5268
 
5243 5269
         $useThisVer = true;
5244
-        if (isset($this->loadedjscripts[$key])) { // a matching script was found
5270
+        if (isset($this->loadedjscripts[$key])) {
5271
+// a matching script was found
5245 5272
             // if existing script is a startup script, make sure the candidate is also a startup script
5246 5273
             if ($this->loadedjscripts[$key]['startup']) {
5247 5274
                 $startup = true;
@@ -5261,7 +5288,8 @@  discard block
 block discarded – undo
5261 5288
                     // overwrite the old script (the position may be important for dependent scripts)
5262 5289
                     $overwritepos = $this->loadedjscripts[$key]['pos'];
5263 5290
                 }
5264
-            } else { // Use the original version
5291
+            } else {
5292
+// Use the original version
5265 5293
                 if ($startup == true && $this->loadedjscripts[$key]['startup'] == false) {
5266 5294
                     // need to move the exisiting script to the head
5267 5295
                     $version = $this->loadedjscripts[$key][$version];
@@ -5386,7 +5414,8 @@  discard block
 block discarded – undo
5386 5414
         }
5387 5415
 
5388 5416
         $results = null;
5389
-        foreach ($this->pluginEvent[$evtName] as $pluginName) { // start for loop
5417
+        foreach ($this->pluginEvent[$evtName] as $pluginName) {
5418
+// start for loop
5390 5419
             if ($this->dumpPlugins) {
5391 5420
                 $eventtime = $this->getMicroTime();
5392 5421
             }
@@ -5934,7 +5963,8 @@  discard block
 block discarded – undo
5934 5963
      * @return bool
5935 5964
      */
5936 5965
     public function isSafeCode($phpcode = '', $safe_functions = '')
5937
-    { // return true or false
5966
+    {
5967
+// return true or false
5938 5968
         if ($safe_functions == '') {
5939 5969
             return false;
5940 5970
         }
@@ -6350,7 +6380,7 @@  discard block
 block discarded – undo
6350 6380
             $args = array_pad(array(), $_, '$var');
6351 6381
             $args = implode(", ", $args);
6352 6382
             $modx = &$this;
6353
-            $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val) {
6383
+            $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val){
6354 6384
                 $arg = $val['args'][$tmp - 1];
6355 6385
                 switch (true) {
6356 6386
                     case is_null($arg):
Please login to merge, or discard this patch.