mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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
This commit is contained in:
parent
ed3ac6924f
commit
8b57dc223d
@ -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!
|
||||
|
Loading…
x
Reference in New Issue
Block a user