4 # FILE: VocabularyFactory.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 --------------------------------------------------
34 # load vocabularies (if any)
35 $Vocabularies = array();
36 $VocFileNames = $this->GetFileList();
37 foreach ($VocFileNames as $FileName)
42 # sort vocabularies by name
43 function SORT_VocabularyFactory_GetVocabularies($VocA, $VocB)
45 $NameA = $VocA->Name();
46 $NameB = $VocB->Name();
47 return ($NameA == $NameB) ? 0 : (($NameA < $NameB) ? -1 : 1);
49 usort($Vocabularies,
"SORT_VocabularyFactory_GetVocabularies");
51 # return array of vocabularies to caller
62 # for each available vocabulary file
64 $VocFileNames = $this->GetFileList();
65 foreach ($VocFileNames as $FileName)
67 # if hash for vocabulary file matches specified hash
70 # load vocabulary and stop searching file list
76 # return matching vocabulary (if any) to caller
80 # ---- PRIVATE INTERFACE -------------------------------------------------
84 private function GetFileList()
86 # read in list of vocabulary files
88 if (is_dir($this->Path))
90 $AllFiles = scandir($this->Path);
91 foreach ($AllFiles as $FileName)
93 if (preg_match(
"/\\.voc\$/i", $FileName))
95 $VocFiles[] = realpath($this->Path.
"/".$FileName);