Merged revisions 48425 via svnmerge from

svn://svn.silverstripe.com/silverstripe/modules/sapphire/branches/2.1.0-rc3oriwave2

........
  r48425 | sminnee | 2008-01-22 17:16:41 +1300 (Tue, 22 Jan 2008) | 3 lines
  
  Updated AssetAdmin to use TreeTitle() in place of Title for tree generation
  > Updated TreeTitle() to allow use of alternateTreeTitle() in decorator
  > Updated File to allow the insertion of extra columns by decorator
........


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@49799 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-02-19 00:50:17 +00:00
parent 49db7da7c6
commit b10974b553

View File

@ -287,7 +287,8 @@ class File extends DataObject {
}
function TreeTitle() {
return $this->Title;
if($this->hasMethod('alternateTreeTitle')) return $this->alternateTreeTitle();
else return $this->Title;
}
/**
@ -594,6 +595,13 @@ class File extends DataObject {
echo "<p>Done!";
}
/**
* 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!
@ -607,8 +615,23 @@ class File extends DataObject {
$query = $this->extendedSQL($filter, $sort, $limit, $join, $having);
$baseTable = reset($query->from);
$query->select = array("$baseTable.ID","$baseTable.ClassName","$baseTable.Created","$baseTable.LastEdited","$baseTable.Name","$baseTable.Title","$baseTable.Content","$baseTable.ParentID","$baseTable.Filename","if($baseTable.ClassName,$baseTable.ClassName,'File') AS RecordClassName");
// Work out which columns we're actually going to select
// In short, we select everything except File.Content
if(!self::$dataobject_select) {
self::$dataobject_select = array();
foreach($query->select as $item) {
if($item == "`File`.*") {
$fileColumns = DB::query("SHOW FIELDS IN `File`")->column();
$columnsToAdd = array_diff($fileColumns, array('Content'));
foreach($columnsToAdd as $otherItem) self::$dataobject_select[] = '`File`.' . $otherItem;
} else {
self::$dataobject_select[] = $item;
}
}
}
$query->select = self::$dataobject_select;
$records = $query->execute();
$ret = $this->buildDataObjectSet($records, $containerClass);