Changeset 64093 for modules/sapphire
- Timestamp:
- 12/10/08 00:16:03 (8 weeks ago)
- Location:
- modules/sapphire/branches/nestedurls/core
- Files:
-
- 2 modified
-
control/ContentController.php (modified) (2 diffs)
-
SSViewer.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
modules/sapphire/branches/nestedurls/core/control/ContentController.php
r63586 r64093 34 34 //----------------------------------------------------------------------------------// 35 35 // These flexible data methods remove the need for custom code to do simple stuff 36 37 /* 36 37 /** 38 38 * Return the children of the given page. 39 * $parentRef can be a page number or a URLSegment 39 * 40 * @param string|int $parentRef a page link or a page ID 41 * @return SiteTree 40 42 */ 41 43 public function ChildrenOf($parentRef) { 42 $SQL_parentRef = Convert::raw2sql($parentRef); 43 $parent = DataObject::get_one('SiteTree', "URLSegment = '$SQL_parentRef'"); 44 44 $parent = SiteTree::get_by_link($parentRef); 45 45 if(!$parent && is_numeric($parentRef)) $parent = DataObject::get_by_id('SiteTree', $SQL_parentRef); 46 46 47 if($parent) { 47 48 return $parent->Children(); … … 49 50 user_error("Error running <% control ChildrenOf($parentRef) %>: page '$parentRef' couldn't be found", E_USER_WARNING); 50 51 } 51 52 } 53 52 53 } 54 55 /** 56 * Get a page by its link 57 * 58 * @param string $url 59 * @return SiteTree 60 */ 54 61 public function Page($url) { 55 $SQL_url = Convert::raw2sql($url); 56 return DataObject::get_one('SiteTree', "URLSegment = '$SQL_url'"); 57 } 58 62 return SiteTree::get_by_link($url); 63 } 64 59 65 public function init() { 60 66 parent::init(); -
modules/sapphire/branches/nestedurls/core/SSViewer.php
r63742 r64093 376 376 $content = ereg_replace('<!-- +pc +([A-Za-z0-9_(),]+) +-->', '<' . '% control \\1 %' . '>', $content); 377 377 $content = ereg_replace('<!-- +pc_end +-->', '<' . '% end_control %' . '>', $content); 378 378 379 // <% control Foo %> 379 380 $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+) +%' . '>', '<? array_push($itemStack, $item); if($loop = $item->obj("\\1")) foreach($loop as $key => $item) { ?>', $content); 381 // <% control Foo.Bar %> 380 382 $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+)\\.([A-Za-z0-9_]+) +%' . '>', '<? array_push($itemStack, $item); if(($loop = $item->obj("\\1")) && ($loop = $loop->obj("\\2"))) foreach($loop as $key => $item) { ?>', $content); 381 382 $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+)\\.([A-Za-z0-9_]+)\\(([A-Za-z0-9_-]+)\\) +%' . '>', '<? array_push($itemStack, $item); if(($loop = $item->obj("\\1")) && ($loop = $loop->obj("\\2", array("\\3")))) foreach($loop as $key => $item) { ?>', $content); 383 384 $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+)\\(([A-Za-z0-9_-]+)\\) +%' . '>', '<? array_push($itemStack, $item); if($loop = $item->obj("\\1", array("\\2"))) foreach($loop as $key => $item) { ?>', $content); 385 $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+)\\(([A-Za-z0-9_-]+), *([A-Za-z0-9_-]+)\\) +%' . '>', '<? array_push($itemStack, $item); if($loop = $item->obj("\\1", array("\\2","\\3"))) foreach($loop as $key => $item) { ?>', $content); 386 $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+)\\(([A-Za-z0-9_-]+), *([A-Za-z0-9_-]+), *([A-Za-z0-9_-]+)\\) +%' . '>', '<? array_push($itemStack, $item); if($loop = $item->obj("\\1", array("\\2", "\\3", "\\4"))) foreach($loop as $key => $item) { ?>', $content); 383 // <% control Foo.Bar(Baz) %> 384 $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+)\\.([A-Za-z0-9_]+)\\(([^)]+)\\) +%' . '>', '<? array_push($itemStack, $item); if(($loop = $item->obj("\\1")) && ($loop = $loop->obj("\\2", array("\\3")))) foreach($loop as $key => $item) { ?>', $content); 385 // <% control Foo(Bar) %> 386 $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+)\\(([^)]+)\\) +%' . '>', '<? array_push($itemStack, $item); if($loop = $item->obj("\\1", array("\\2"))) foreach($loop as $key => $item) { ?>', $content); 387 // <% control Foo(Bar, Baz) %> 388 $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+)\\(([^)]+), *([^)]+)\\) +%' . '>', '<? array_push($itemStack, $item); if($loop = $item->obj("\\1", array("\\2","\\3"))) foreach($loop as $key => $item) { ?>', $content); 389 // <% control Foo(Bar, Baz, Buz) %> 390 $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+)\\(([^)]+), *([^)]+), *([^)]+)\\) +%' . '>', '<? array_push($itemStack, $item); if($loop = $item->obj("\\1", array("\\2", "\\3", "\\4"))) foreach($loop as $key => $item) { ?>', $content); 387 391 $content = ereg_replace('<' . '% +end_control +%' . '>', '<? } $item = array_pop($itemStack); ?>', $content); 388 392 $content = ereg_replace('<' . '% +debug +%' . '>', '<? Debug::show($item) ?>', $content);
