Comments: on this page. Click to read or post your own.

Class File

Description

This class handles the representation of a File within Sapphire Note: The files are stored in the "/assets/" directory, but sapphire looks at the db object to gather information about a file such as URL

It then uses this for all processing functions (like image manipulation)

Located in /sapphire/filesystem/File.php (line 11)

Object
   |
   --ViewableData
      |
      --DataObject
         |
         --File
Direct descendents
Class Description
Folder Represents a folder in the assets directory.
Image Represents an image attached to a page.
Variable Summary
static mixed $belongs_many_many
static array $cache_file_fields
static mixed $db
static mixed $default_sort
static mixed $extensions
static mixed $has_one
static mixed $indexes
static mixed $plural_name
static mixed $singular_name
Method Summary
static void find ( $filename)
static void format_size ( $size)
static string get_file_extension (string $filename)
void appCategory ()
void autosetFilename ()
void CMSThumbnail ()
void collateDescendants (condition $condition, collator &$collator)
void DeleteLink ()
void flushCache ()
void getAbsoluteSize ()
string getAbsoluteURL ()
void getExtension ()
void getFilename ()
string getFileType ()
void getFullPath ()
void getLinkedURL ()
void getRelativePath ()
void getSize ()
string getURL ()
void Icon ()
void instance_get ([ $filter = ""], [ $sort = ""], [ $join = ""], [ $limit = ""], [ $containerClass = "DataObjectSet"], [ $having = ""])
void Link ([ $action = null])
Boolean|string loadUploaded ($tmpFile $tmpFile)
void onBeforeDelete ()
void onBeforeWrite ()
void RelativeLink ([ $action = null])
void resetFilename ([$renamePhysicalFile $renamePhysicalFile = true])
void setField ( $field,  $value)
void setFilename ( $val)
void setName ( $name)
void setParentID ( $parentID)
void TreeTitle ()
void updateLinks ( $old,  $new)
void userCanEdit ()
Variables
static mixed $belongs_many_many = array(
"BackLinkTracking" => "SiteTree",
)
(line 40)

Redefinition of:
DataObject::$belongs_many_many
The inverse side of a many-many relationship.
static array $cache_file_fields = null (line 50)

Cached result of a "SHOW FIELDS" call in instance_get() for performance reasons.

  • access: protected
static mixed $db = array(
"Name" => "Varchar(255)",
"Title" => "Varchar(255)",
"Filename" => "Varchar(255)",
"Content" => "Text",
"Sort" => "Int"
)
(line 19)

Redefinition of:
DataObject::$db
Database field definitions.

Redefined in descendants as:
static mixed $default_sort = "Name" (line 13)

Redefinition of:
DataObject::$default_sort
The default sort expression. This will be inserted in the ORDER BY clause of a SQL query if no other sort expression is provided.
static mixed $extensions = array(
"Hierarchy",
)
(line 36)

Redefinition of:
Object::$extensions
Extensions to be used on this object. An array of extension names and parameters eg:
static mixed $has_one = array(
"Parent" => "File",
"Owner" => "Member"
)
(line 31)

Redefinition of:
DataObject::$has_one
one-to-one relationship definitions.
static mixed $indexes = array(
"SearchFields" => "fulltext (Filename,Title,Content)",
)
(line 27)

Redefinition of:
DataObject::$indexes
If a field is in this array, then create a database index on that field. This is a map from fieldname to index type.
static mixed $plural_name = "Files" (line 17)

Redefinition of:
DataObject::$plural_name
Human-readable pluaral name
static mixed $singular_name = "File" (line 15)

Redefinition of:
DataObject::$singular_name
Human-readable singular name.

Inherited Variables

Inherited from DataObject

DataObject::$ancestry
DataObject::$api_access
DataObject::$brokenOnDelete
DataObject::$brokenOnWrite
DataObject::$cache_get_one
DataObject::$casting
DataObject::$changed
DataObject::$componentCache
DataObject::$components
DataObject::$defaults
DataObject::$default_records
DataObject::$destroyed
DataObject::$field_labels
DataObject::$has_many
DataObject::$many_many
DataObject::$many_many_extraFields
DataObject::$original
DataObject::$record
DataObject::$searchable_fields
DataObject::$summary_fields

Inherited from ViewableData

ViewableData::$castingHelperPair_cache
ViewableData::$customisedObj
ViewableData::$failover
ViewableData::$iteratorPos
ViewableData::$iteratorTotalItems
ViewableData::$namedAs
ViewableData::$parent
ViewableData::$_natural_cache
ViewableData::$_object_cache
ViewableData::$_xml_cache

Inherited from Object

Object::$builtInMethods
Object::$class
Object::$classConstructed
Object::$extension_instances
Object::$extraMethods
Object::$extraStatics
Object::$statics
Object::$static_cached
Methods
static method find (line 89)
static void find ( $filename)
  • $filename
static method format_size (line 455)
  • access: public
static void format_size ( $size)
  • $size
static method get_file_extension (line 412)

Gets the extension of a filepath or filename, by stripping away everything before the last "dot".

  • access: public
static string get_file_extension (string $filename)
  • string $filename
appCategory (line 105)
  • access: public
void appCategory ()
autosetFilename (line 289)

Set the Filename field without manipulating the filesystem.

  • access: protected
void autosetFilename ()

Redefined in descendants as:
CMSThumbnail (line 127)
void CMSThumbnail ()

Redefined in descendants as:
collateDescendants (line 198)

Collate selected descendants of this page.

$condition will be evaluated on each descendant, and if it is succeeds, that item will be added to the $collator array.

  • access: public
void collateDescendants (condition $condition, collator &$collator)
  • condition $condition: The PHP condition to be evaluated. The page will be called $item
  • collator &$collator: An array, passed by reference, to collect all of the matching descendants.
deleteDatabaseOnly (line 168)

Delete the database record (recursively for folders) without touching the filesystem

  • access: public
void deleteDatabaseOnly ()

Redefined in descendants as:
DeleteLink (line 379)
void DeleteLink ()
flushCache (line 527)
  • access: public
void flushCache ()

Redefinition of:
DataObject::flushCache()
Flush the cached results for all relations (has_one, has_many, many_many)
getAbsoluteSize (line 467)

returns the size in bytes with no extensions for calculations.

void getAbsoluteSize ()
getAbsoluteURL (line 330)

Gets the absolute URL accessible through the web.

string getAbsoluteURL ()
getExtension (line 401)
void getExtension ()
getFilename (line 383)
void getFilename ()
getFileType (line 422)

Return the type of file for the given extension on the current file name.

string getFileType ()
getFullPath (line 351)
void getFullPath ()
getLinkedURL (line 347)

Return the last 50 characters of the URL

void getLinkedURL ()
getRelativePath (line 363)
void getRelativePath ()

Redefined in descendants as:
getSize (line 449)

Returns the size of the file type in an appropriate format.

void getSize ()
getURL (line 340)

Gets the absolute URL accessible through the web.

string getURL ()

Redefined in descendants as:
Icon (line 135)

Return the URL of an icon for the file type

void Icon ()
instance_get (line 492)

We've overridden the DataObject::get function for File so that the very large content field is excluded!

  • deprecated: alternative_instance_get()
  • todo: Admittedly this is a bit of a hack; but we need a way of ensuring that large TEXT fields don't stuff things up for the rest of us. Perhaps a separate search table would be a better way of approaching this?
  • access: public
void instance_get ([ $filter = ""], [ $sort = ""], [ $join = ""], [ $limit = ""], [ $containerClass = "DataObjectSet"], [ $having = ""])
  • $filter
  • $sort
  • $join
  • $limit
  • $containerClass
  • $having

Redefinition of:
DataObject::instance_get()
The internal function that actually performs the querying for get().
Link (line 52)
void Link ([ $action = null])
  • $action
loadUploaded (line 156)

Save an file passed from a form post into this object.

DEPRECATED Please instanciate an Upload-object instead and pass the file via {Upload->loadIntoFile()}.

  • return: Either success or error-message.
Boolean|string loadUploaded ($tmpFile $tmpFile)
  • $tmpFile $tmpFile: array Indexed array that PHP generated for every file it uploads.

Redefined in descendants as:
onBeforeDelete (line 69)

Event handler called before deleting from the database.

You can overload this to clean up or otherwise process data before delete this record. Don't forget to call parent::onBeforeDelete(), though!

  • access: protected
void onBeforeDelete ()

Redefinition of:
DataObject::onBeforeDelete()
Event handler called before deleting from the database.

Redefined in descendants as:
onBeforeWrite (line 177)

Event handler called before deleting from the database.

You can overload this to clean up or otherwise process data before delete this record. Don't forget to call parent::onBeforeDelete(), though!

  • access: protected
void onBeforeWrite ()

Redefinition of:
DataObject::onBeforeWrite()
Event handler called before writing to the database.
RelativeLink (line 56)
void RelativeLink ([ $action = null])
  • $action
resetFilename (line 259)

Change a filename, moving the file if appropriate.

  • access: protected
void resetFilename ([$renamePhysicalFile $renamePhysicalFile = true])
  • $renamePhysicalFile $renamePhysicalFile: Set this to false if you don't want to rename the physical file. Used when calling resetFilename() on the children of a folder.

Redefined in descendants as:
setField (line 293)
void setField ( $field,  $value)
  • $field
  • $value

Redefinition of:
DataObject::setField()
Set the value of the field Called by __set() and any setFieldName() methods you might create.
setFilename (line 391)
void setFilename ( $val)
  • $val
setName (line 212)

Setter function for Name.

Automatically sets a default title.

void setName ( $name)
  • $name
setParentID (line 315)
void setParentID ( $parentID)
  • $parentID
TreeTitle (line 60)
void TreeTitle ()
updateLinks (line 300)

Rewrite links to the $old file to now point to the $new file

  • access: protected
void updateLinks ( $old,  $new)
  • $old
  • $new
userCanEdit (line 523)

Stub, overridden by Folder

void userCanEdit ()

Redefined in descendants as:

Inherited Methods

Inherited From DataObject

DataObject::__construct()
DataObject::baseTable()
DataObject::buildDataObjectSet()
DataObject::buildSQL()
DataObject::can()
DataObject::canCreate()
DataObject::canDelete()
DataObject::canEdit()
DataObject::canView()
DataObject::castedUpdate()
DataObject::context_obj()
DataObject::createComponent()
DataObject::customDatabaseFields()
DataObject::data()
DataObject::databaseFields()
DataObject::databaseIndexes()
DataObject::db()
DataObject::dbObject()
DataObject::debug()
DataObject::defaultSearchFilters()
DataObject::defineMethods()
DataObject::delete()
DataObject::delete_by_id()
DataObject::destroy()
DataObject::disable_subclass_access()
DataObject::duplicate()
DataObject::enable_subclass_access()
DataObject::exists()
DataObject::extendedSQL()
DataObject::fieldExists()
DataObject::fieldLabel()
DataObject::fieldLabels()
DataObject::filledOut()
DataObject::flushCache()
DataObject::forceChange()
DataObject::get()
DataObject::getAllFields()
DataObject::getChangedFields()
DataObject::getClassAncestry()
DataObject::getCMSFields()
DataObject::getComponent()
DataObject::getComponentJoinField()
DataObject::getComponents()
DataObject::getComponentsQuery()
DataObject::getDefaultSearchContext()
DataObject::getField()
DataObject::getFrontEndFields()
DataObject::getManyManyComponents()
DataObject::getManyManyComponentsQuery()
DataObject::getManyManyFilter()
DataObject::getManyManyJoin()
DataObject::getReverseAssociation()
DataObject::getTitle()
DataObject::get_by_id()
DataObject::get_by_url()
DataObject::get_one()
DataObject::hasDatabaseField()
DataObject::hasField()
DataObject::hasOwnTableDatabaseField()
DataObject::has_many()
DataObject::has_one()
DataObject::i18n_plural_name()
DataObject::i18n_singular_name()
DataObject::inheritedDatabaseFields()
DataObject::instance_get()
DataObject::instance_get_one()
DataObject::isEmpty()
DataObject::isInDB()
DataObject::listOfFields()
DataObject::many_many()
DataObject::merge()
DataObject::newClassInstance()
DataObject::onAfterWrite()
DataObject::onBeforeDelete()
DataObject::onBeforeWrite()
DataObject::plural_name()
DataObject::populateDefaults()
DataObject::relObject()
DataObject::requireDefaultRecords()
DataObject::requireTable()
DataObject::scaffoldFormFields()
DataObject::scaffoldSearchFields()
DataObject::searchableFields()
DataObject::setCastedField()
DataObject::setClassName()
DataObject::setComponent()
DataObject::setField()
DataObject::set_context_obj()
DataObject::singular_name()
DataObject::summaryFields()
DataObject::toMap()
DataObject::update()
DataObject::validate()
DataObject::write()
DataObject::writeComponents()
DataObject::writeWithoutVersion()

Inherited From ViewableData

ViewableData::ATT_val()
ViewableData::BaseHref()
ViewableData::buildCastingHelperCache()
ViewableData::cachedCall()
ViewableData::castingHelper()
ViewableData::castingHelperPair()
ViewableData::castingObjectCreator()
ViewableData::castingObjectCreatorPair()
ViewableData::CSSClasses()
ViewableData::CurrentMember()
ViewableData::CurrentPage()
ViewableData::customise()
ViewableData::Debug()
ViewableData::defineMethods()
ViewableData::escapeTypeForField()
ViewableData::Even()
ViewableData::EvenOdd()
ViewableData::First()
ViewableData::FirstLast()
ViewableData::getField()
ViewableData::getIterator()
ViewableData::getXMLValues()
ViewableData::hasField()
ViewableData::HasPerm()
ViewableData::hasValue()
ViewableData::i18nLocale()
ViewableData::IsAjax()
ViewableData::iteratorProperties()
ViewableData::JS_val()
ViewableData::Last()
ViewableData::Me()
ViewableData::Middle()
ViewableData::MiddleString()
ViewableData::obj()
ViewableData::Odd()
ViewableData::Pos()
ViewableData::RAW_val()
ViewableData::renderWith()
ViewableData::SecurityID()
ViewableData::setCustomisedObj()
ViewableData::setField()
ViewableData::SQL_val()
ViewableData::ThemeDir()
ViewableData::Top()
ViewableData::TotalItems()
ViewableData::val()
ViewableData::XML_val()
ViewableData::__get()
ViewableData::__isset()
ViewableData::__set()

Inherited From Object

Object::__construct()
Object::addMethodsFrom()
Object::addStaticVars()
Object::addWrapperMethod()
Object::add_extension()
Object::allMethodNames()
Object::buildMethodList()
Object::cacheToFile()
Object::cacheToFileWithArgs()
Object::create()
Object::createMethod()
Object::defineMethods()
Object::exists()
Object::extend()
Object::extInstance()
Object::getCustomClass()
Object::hasExtension()
Object::hasMethod()
Object::invokeWithExtensions()
Object::is_a()
Object::loadCache()
Object::parentClass()
Object::sanitiseCachename()
Object::saveCache()
Object::set_stat()
Object::set_uninherited()
Object::stat()
Object::strong_create()
Object::uninherited()
Object::useCustomClass()
Object::__call()
Object::__toString()
blog comments powered by Disqus

Documentation generated on Sun, 19 Oct 2008 06:40:53 +1300 by phpDocumentor 1.3.2