3 # FILE: VocabularyFactory.php
5 # Part of the Collection Workflow Integration System (CWIS)
6 # Copyright 2007-2013 Edward Almasy and Internet Scout Research Group
7 # http://scout.wisc.edu/cwis/
15 # ---- PUBLIC INTERFACE --------------------------------------------------
33 # load vocabularies (if any)
34 $Vocabularies = array();
35 $VocFileNames = $this->GetFileList();
36 foreach ($VocFileNames as $FileName)
41 # sort vocabularies by name
42 $SortFunction = create_function(
'$VocA, $VocB',
'
43 $NameA = $VocA->Name();
44 $NameB = $VocB->Name();
45 return ($NameA == $NameB) ? 0 : (($NameA < $NameB) ? -1 : 1);
47 usort($Vocabularies, $SortFunction);
49 # return array of vocabularies to caller
61 # for each available vocabulary file
63 $VocFileNames = $this->GetFileList();
64 foreach ($VocFileNames as $FileName)
66 # if hash for vocabulary file matches specified hash
69 # load vocabulary and stop searching file list
75 # return matching vocabulary (if any) to caller
80 # ---- PRIVATE INTERFACE -------------------------------------------------
89 private function GetFileList()
92 if (is_dir($this->Path))
94 $AllFiles = scandir($this->Path);
95 foreach ($AllFiles as $FileName)
97 if (preg_match(
"/\\.voc\$/i", $FileName))
99 $VocFiles[] = realpath($this->Path.
"/".$FileName);
static HashForFile($FileName=NULL)
Get hash string for specified vocabulary file name.
GetVocabularies()
load vocabulary objects from files
VocabularyFactory($Path)
object constructor
GetVocabularyByHash($Hash)
retrieve vocabulary object based on hash string
Factory for manipulating Vocabulary objects.