From 8b57dc223dc1bf0f8be6b722aab0703fa94ddaf1 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Tue, 25 Nov 2008 07:49:27 +0000 Subject: [PATCH] MINOR Moved File::find() to the top of the class for consistency with other classes MINOR Added phpDoc comments for File::find() MINOR Removed unused private static $dataobject_select in File git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@66631 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- filesystem/File.php | 47 +++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/filesystem/File.php b/filesystem/File.php index 056e507f9..15bad3e93 100755 --- a/filesystem/File.php +++ b/filesystem/File.php @@ -49,6 +49,28 @@ class File extends DataObject { */ protected static $cache_file_fields = null; + /** + * Find a File object by the given filename. + * @return mixed null if not found, File object of found file + */ + static function find($filename) { + // Get the base file if $filename points to a resampled file + $filename = ereg_replace('_resampled/[^-]+-','',$filename); + + $parts = explode("/", $filename); + $parentID = 0; + $item = null; + + foreach($parts as $part) { + if($part == "assets" && !$parentID) continue; + $item = DataObject::get_one('File', "Name = '$part' AND ParentID = $parentID"); + if(!$item) break; + $parentID = $item->ID; + } + + return $item; + } + function Link($action = null) { return Director::baseURL() . $this->RelativeLink($action); } @@ -138,25 +160,6 @@ class File extends DataObject { return $this->canEdit($member); } - /* - * Find the given file - */ - static function find($filename) { - // Get the base file if $filename points to a resampled file - $filename = ereg_replace('_resampled/[^-]+-','',$filename); - - $parts = explode("/",$filename); - $parentID = 0; - - foreach($parts as $part) { - if($part == "assets" && !$parentID) continue; - $item = DataObject::get_one("File", "Name = '$part' AND ParentID = $parentID"); - if(!$item) break; - $parentID = $item->ID; - } - return $item; - } - public function appCategory() { $ext = $this->Extension; switch($ext) { @@ -535,12 +538,6 @@ class File extends DataObject { } } - /** - * Select clause for DataObject::get('File') operations/ - * Stores an array, suitable for a {@link SQLQuery} object. - */ - private static $dataobject_select; - /** * We've overridden the DataObject::get function for File so that the very large content field * is excluded!