示例#1
0
 /**
  * load and parse given file.
  * 
  * @param string $name Name of file to load.
  * 
  * @return IAcitive Loaded activity.
  */
 public function parse($name)
 {
     $file_type = end(explode(".", $name));
     $class = '\\utils\\parser\\' . $file_type;
     $parser = new \utils\parser\context(new $class());
     return $parser->algorithm(DIR_UPLOAD . $name);
 }
示例#2
0
 /**
  * Create IActive object from each uploaded file.
  * 
  * @return void
  */
 public function loadFiles()
 {
     try {
         if (!empty($_SESSION["names"])) {
             $files = $_SESSION["names"];
             foreach ($files as $id => $file) {
                 $file_type = end(explode(".", $file));
                 $class = '\\utils\\parser\\' . $file_type;
                 $parser = new \utils\parser\context(new $class());
                 $this->activity[] = $parser->algorithm(DIR_UPLOAD . $file);
             }
             // insert loaded data into database
             //			$save = new \utils\data\zapisz();
             //			foreach($this->aktivity as $aktiv) {
             //				$save->templateMethod($aktiv);
             //			}
         } else {
             throw new \Exception("There is no files");
         }
     } catch (\Exception $e) {
         $catcher = new \catcher($e);
         $catcher->show();
     }
 }