PageRenderTime 52ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/manager/cacheextender/files/document.parser.class.inc.insert.php

https://github.com/Advanc8d/modx.evo.custom
PHP | 67 lines | 51 code | 6 blank | 10 comment | 12 complexity | 02870b0b3aea5a4c30ece55953619909 MD5 | raw file
Possible License(s): BSD-3-Clause, MIT
  1. /*
  2. * Modified by thebat053
  3. * CacheExtender 0.1a
  4. * CacheExtender revision:<cacheextender_revision>
  5. */
  6. var $cacheExtender = true; //modified by thebat053
  7. function rewriteUrls($documentSource) {
  8. // rewrite the urls
  9. if ($this->config['friendly_urls'] == 1) {
  10. $in= '!\[\~([0-9]+)\~\]!ise'; // Use preg_replace with /e to make it evaluate PHP
  11. preg_match_all ($in, $documentSource, $matches);
  12. $aliases= array ();
  13. foreach ($matches[1] as $match){
  14. $item = $this->aliasListing[$match];
  15. $aliases[$match]= (strlen($item['path']) > 0 ? $item['path'] . '/' : '') . $item['alias'];
  16. }
  17. $isfriendly= ($this->config['friendly_alias_urls'] == 1 ? 1 : 0);
  18. $pref= $this->config['friendly_url_prefix'];
  19. $suff= $this->config['friendly_url_suffix'];
  20. $thealias= '$aliases[\\1]';
  21. $found_friendlyurl= "\$this->makeFriendlyURL('$pref','$suff',$thealias)";
  22. $not_found_friendlyurl= "\$this->makeFriendlyURL('$pref','$suff','" . '\\1' . "')";
  23. $out= "({$isfriendly} && isset({$thealias}) ? {$found_friendlyurl} : {$not_found_friendlyurl})";
  24. $documentSource= preg_replace($in, $out, $documentSource);
  25. } else {
  26. $in= '!\[\~([0-9]+)\~\]!is';
  27. $out= "index.php?id=" . '\1';
  28. $documentSource= preg_replace($in, $out, $documentSource);
  29. }
  30. return $documentSource;
  31. }
  32. function getChildIds($id, $depth = 10, $children = array(), $strictchilds = null){
  33. if(!is_array($id))
  34. $id = array($id);
  35. foreach($id as $chid){
  36. $children += $this->getChildIdsRec($chid, $depth, array(), $strictchilds);
  37. }
  38. return $children;
  39. }
  40. function getChildIdsRec($id, $depth, $children = array(), $strictchilds = null) {
  41. // Get all the children for this parent node
  42. if (isset($this->documentMap_cache[$id])) {
  43. $depth--;
  44. $tmp = $this->documentMap_cache[$id];
  45. foreach ($tmp as $childId) {
  46. if($strictchilds)
  47. if(!in_array($childId, $strictchilds))
  48. continue;
  49. $pkey = (strlen($this->aliasListing[$childId]['path']) ? "{$this->aliasListing[$childId]['path']}/" : '') . $this->aliasListing[$childId]['alias'];
  50. if (!strlen($pkey)) $pkey = "{$childId}";
  51. $children[$pkey] = $childId;
  52. if ($depth || $depth < 0) {
  53. $children += $this->getChildIdsRec($childId, $depth, array(), $strictchilds);
  54. }
  55. }
  56. }
  57. return $children;
  58. }
  59. /*
  60. * End of modification
  61. */