4 # FILE: FileFactory.php
6 # Part of the Collection Workflow Integration System
7 # Copyright 2007-2009 Edward Almasy and Internet Scout
8 # http://scout.wisc.edu
16 # ---- PUBLIC INTERFACE --------------------------------------------------
21 # set up item factory base class
25 # retrieve all files (names or objects) for specified resource
26 # (array index is file IDs)
29 # start out assuming that no files will be found
30 $ReturnValue = array();
32 # sanitize resource ID or grab it from object
33 $ResourceOrResourceId = is_object($ResourceOrResourceId)
34 ? $ResourceOrResourceId->Id() : intval($ResourceOrResourceId);
36 # retrieve names and IDs of files associated with resource
38 "SELECT FileId, FileName FROM Files"
39 .
" WHERE ResourceId = ".$ResourceOrResourceId
41 .($this->FieldId ?
"=".$this->FieldId :
">0"));
42 $FileNames = $this->DB->FetchColumn(
"FileName",
"FileId");
45 if (count($FileNames))
47 # if caller asked us to return objects
51 foreach ($FileNames as $FileId => $FileName)
53 # create file object and add it to array
54 $ReturnValue[$FileId] =
new File($FileId);
59 # return array of file names with IDs as index
60 $ReturnValue = $FileNames;
64 # return resulting array of files or file names to caller
68 # create copy of File and return to caller
71 return new File($FileToCopy->GetNameOfStoredFile(),
72 $FileToCopy->ResourceId(),
73 $FileToCopy->FieldId(),
78 # ---- PRIVATE INTERFACE -------------------------------------------------