Virtlab:Řídící server/ParserTaskupload.php.inc
Z VirtlabWiki
< Virtlab:Řídící serverVerze z 10:16, 22. 10. 2007; zobrazit aktuální verzi
← Starší verze | Novější verze →
← Starší verze | Novější verze →
Metody
- function __construct($file, $is_file=0)
- public function getShortname()
- public function getTime()
- public function getLongname()
- public function getShortdescription()
- private function getGroup($group)
- public function getGroupExists($group)
- public function getGroupName($group)
- public function getGroupFileCount($group)
- private function getGroupFile($group, $fileidx)
- public function getGroupFileName($group, $fileidx)
- public function getGroupFilePath($group, $fileidx)
- public function getGroupFileExists($group, $fileidx)
Zdrojový kód
<?php class virtlabParserTaskupload { private $parsed = array(); function __construct($file, $is_file=0) { $parser = new virtlabXmlParser(1); if($is_file) $parser->parse($file); else $parser->parse_data($file); $this->parsed = $parser->output; unset($parser); }//konstruktor public function getShortname() { if(isset($this->parsed[0]["attribs"]["NAME"])) return $this->parsed[0]["attribs"]["NAME"]; else return NULL; }//function public function getTime() { if(isset($this->parsed[0]["attribs"]["TIME"])) return $this->parsed[0]["attribs"]["TIME"]; else return NULL; }//function public function getLongname() { if(isset($this->parsed[0]["child"][0]["content"])) return $this->parsed[0]["child"][0]["content"]; else return NULL; }//function public function getShortdescription() { if(isset($this->parsed[0]["child"][1]["content"])) return $this->parsed[0]["child"][1]["content"]; else return NULL; }//function private function getGroup($group) { switch($group) { case "descrip": $idx = 2; break; case "pics": $idx = 3; break; case "preconf": $idx = 4; break; case "postconf":$idx = 5; break; case "topology":$idx = 6; break; default: return NULL; }//switch return $this->parsed[0]["child"][$idx]; }//function public function getGroupExists($group) { $tmp = $this->getGroup($group); if(is_null($tmp)) return NULL; switch($tmp["attribs"]["EXISTS"]) { case "yes": return TRUE; case "no": return FALSE; default: return NULL; }//switch }//function public function getGroupName($group) { $tmp = $this->getGroup($group); if(is_null($tmp)) return NULL; return $tmp["attribs"]["NAME"]; }//function public function getGroupFileCount($group) { $tmp = $this->getGroup($group); if(is_null($tmp)) return NULL; return count($tmp["child"]); }//function private function getGroupFile($group, $fileidx) { $tmp = $this->getGroup($group); if(is_null($tmp)) return NULL; if(!isset($tmp["child"][$fileidx])) return NULL; return $tmp["child"][$fileidx]; }//function public function getGroupFileName($group, $fileidx) { $tmp = $this->getGroupFile($group, $fileidx); if(is_null($tmp)) return NULL; return $tmp["attribs"]["NAME"]; }//function public function getGroupFilePath($group, $fileidx) { $tmp = $this->getGroupFile($group, $fileidx); if(is_null($tmp)) return NULL; return $tmp["attribs"]["FILEPATH"]; }//function public function getGroupFileExists($group, $fileidx) { $tmp = $this->getGroupFile($group, $fileidx); if(is_null($tmp)) return NULL; switch($tmp["attribs"]["EXISTS"]) { case "yes": return TRUE; case "no": return FALSE; default: return NULL; }//switch }//function }//class ?>