Changeset 64093 for modules/sapphire

Show
Ignore:
Timestamp:
12/10/08 00:16:03 (8 weeks ago)
Author:
ajshort
Message:

ENHANCEMENT: Updated SSViewer to allow any character except ) inside the arguments of a function within a control block
API CHANGE: Refactored ContentController::ChildrenOf?() and ContentController::Page() to use SiteTree::get_by_link()
MINOR: Added slightly more documentation to SSViewer

Location:
modules/sapphire/branches/nestedurls/core
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • modules/sapphire/branches/nestedurls/core/control/ContentController.php

    r63586 r64093  
    3434        //----------------------------------------------------------------------------------// 
    3535        // These flexible data methods remove the need for custom code to do simple stuff 
    36  
    37         /* 
     36         
     37        /** 
    3838         * 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 
    4042         */ 
    4143        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); 
    4545                if(!$parent && is_numeric($parentRef)) $parent = DataObject::get_by_id('SiteTree', $SQL_parentRef); 
     46                 
    4647                if($parent) { 
    4748                        return $parent->Children(); 
     
    4950                        user_error("Error running <% control ChildrenOf($parentRef) %>: page '$parentRef' couldn't be found", E_USER_WARNING); 
    5051                } 
    51  
    52         } 
    53  
     52                 
     53        } 
     54         
     55        /** 
     56         * Get a page by its link 
     57         * 
     58         * @param string $url 
     59         * @return SiteTree 
     60         */ 
    5461        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         
    5965        public function init() { 
    6066                parent::init(); 
  • modules/sapphire/branches/nestedurls/core/SSViewer.php

    r63742 r64093  
    376376                $content = ereg_replace('<!-- +pc +([A-Za-z0-9_(),]+) +-->', '<' . '% control \\1 %' . '>', $content); 
    377377                $content = ereg_replace('<!-- +pc_end +-->', '<' . '% end_control %' . '>', $content); 
    378  
     378                 
     379                // <% control Foo %> 
    379380                $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 %> 
    380382                $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); 
    387391                $content = ereg_replace('<' . '% +end_control +%' . '>', '<? } $item = array_pop($itemStack); ?>', $content); 
    388392                $content = ereg_replace('<' . '% +debug +%' . '>', '<? Debug::show($item) ?>', $content);