3 # FILE: VocabularyFactory.php 5 # Part of the Collection Workflow Integration System (CWIS) 6 # Copyright 2007-2016 Edward Almasy and Internet Scout Research Group 7 # http://scout.wisc.edu/cwis/ 15 # ---- 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 $SortFunction =
function($VocA, $VocB) {
44 $NameA = $VocA->Name();
45 $NameB = $VocB->Name();
46 return ($NameA == $NameB) ? 0 : (($NameA < $NameB) ? -1 : 1);
48 usort($Vocabularies, $SortFunction);
50 # 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 81 # ---- PRIVATE INTERFACE ------------------------------------------------- 90 private function GetFileList()
93 if (is_dir($this->Path))
95 $AllFiles = scandir($this->Path);
96 foreach ($AllFiles as $FileName)
98 if (preg_match(
"/\\.voc\$/i", $FileName))
100 $VocFiles[] = realpath($this->Path.
"/".$FileName);
static HashForFile($FileName=NULL)
Get hash string for specified vocabulary file name.
GetVocabularies()
load vocabulary objects from files
GetVocabularyByHash($Hash)
retrieve vocabulary object based on hash string
Factory for manipulating Vocabulary objects.
__construct($Path)
object constructor