Ejemplo n.º 1
0
 /**
  * Import 
  */
 function import($a_file)
 {
     parent::create();
     $im_dir = $this->createImportDirectory();
     // handle uploaded files
     if (is_array($a_file)) {
         ilUtil::moveUploadedFile($a_file["tmp_name"], $a_file["name"], $im_dir . "/" . $a_file["name"]);
         $file_name = $a_file["name"];
     } else {
         $pi = pathinfo($a_file);
         $file_name = $pi["basename"];
         copy($a_file, $im_dir . "/" . $file_name);
     }
     $file = pathinfo($file_name);
     // unzip file
     if (strtolower($file["extension"] == "zip")) {
         ilUtil::unzip($im_dir . "/" . $file_name);
         $subdir = basename($file["basename"], "." . $file["extension"]);
         if (!is_dir($im_dir . "/" . $subdir)) {
             $subdir = "style";
             // check style subdir
         }
         $xml_file = $im_dir . "/" . $subdir . "/style.xml";
     } else {
         $xml_file = $im_dir . "/" . $file_name;
     }
     // load information from xml file
     //echo "-$xml_file-";
     $this->createFromXMLFile($xml_file, true);
     // copy images
     $this->createImagesDirectory();
     if (is_dir($im_dir . "/" . $subdir . "/images")) {
         ilUtil::rCopy($im_dir . "/" . $subdir . "/images", $this->getImagesDirectory());
     }
     ilObjStyleSheet::_addMissingStyleClassesToStyle($this->getId());
     $this->read();
     $this->writeCSSFile();
 }