Ejemplo n.º 1
0
 function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
 {
     // see ilStyleExporter::getXmlRepresentation()
     if (preg_match("/<StyleSheetExport><ImagePath>(.+)<\\/ImagePath>/", $a_xml, $hits)) {
         $path = $hits[1];
         $a_xml = str_replace($hits[0], "", $a_xml);
         $a_xml = str_replace("</StyleSheetExport>", "", $a_xml);
     }
     // temp xml-file
     $tmp_file = $this->getImportDirectory() . "/sty_" . $a_id . ".xml";
     file_put_contents($tmp_file, $a_xml);
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $style = new ilObjStyleSheet();
     $style->createFromXMLFile($tmp_file);
     $new_id = $style->getId();
     unlink($tmp_file);
     // images
     if ($path) {
         $source = $this->getImportDirectory() . "/" . $path;
         if (is_dir($source)) {
             $target = $style->getImagesDirectory();
             if (!is_dir($target)) {
                 ilUtil::makeDirParents($target);
             }
             ilUtil::rCopy($source, $target);
         }
     }
     $a_mapping->addMapping("Services/Style", "sty", $a_id, $new_id);
 }
Ejemplo n.º 2
0
 /**
  * clone style sheet (note: styles have no ref ids and return an object id)
  * 
  * @access	public
  * @return	integer		new obj id
  */
 function ilClone()
 {
     global $log, $lng;
     $lng->loadLanguageModule("style");
     $new_obj = new ilObjStyleSheet();
     $new_obj->setTitle($this->getTitle() . " (" . $lng->txt("sty_acopy") . ")");
     $new_obj->setType($this->getType());
     $new_obj->setDescription($this->getDescription());
     $new_obj->create($this->getId());
     $new_obj->writeStyleSetting("disable_auto_margins", $this->lookupStyleSetting("disable_auto_margins"));
     return $new_obj->getId();
 }
Ejemplo n.º 3
0
 /**
  * import style sheet
  */
 function importStyleObject()
 {
     // check file
     $source = $_FILES["stylefile"]["tmp_name"];
     if ($source == 'none' || !$source) {
         $this->ilias->raiseError("No file selected!", $this->ilias->error_obj->MESSAGE);
     }
     // check correct file type
     $info = pathinfo($_FILES["stylefile"]["name"]);
     if (strtolower($info["extension"]) != "zip" && strtolower($info["extension"]) != "xml") {
         $this->ilias->raiseError("File must be a zip or xml file!", $this->ilias->error_obj->MESSAGE);
     }
     $class_name = "ilObjStyleSheet";
     require_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $newObj = new ilObjStyleSheet();
     //$newObj->setTitle();
     //$newObj->setDescription($_POST["style_description"]);
     $newObj->import($_FILES["stylefile"]);
     //$newObj->createFromXMLFile($_FILES["stylefile"]["tmp_name"]);
     // assign style to style sheet folder,
     // if parent is style sheet folder
     if ($_GET["ref_id"] > 0) {
         $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
         if ($fold->getType() == "stys") {
             $fold->addStyle($newObj->getId());
             $fold->update();
             ilObjStyleSheet::_writeStandard($newObj->getId(), "1");
             $this->ctrl->redirectByClass("ilobjstylesettingsgui", "editContentStyles");
         }
     }
     return $newObj->getId();
 }
 /**
  * Import lm from directory
  *
  * @param
  * @return
  */
 function importFromDirectory($a_directory, $a_validate = true)
 {
     global $lng;
     // determine filename of xml file
     $subdir = basename($a_directory);
     $xml_file = $a_directory . "/" . $subdir . ".xml";
     // check directory exists within zip file
     if (!is_dir($a_directory)) {
         return sprintf($lng->txt("cont_no_subdir_in_zip"), $subdir);
     }
     // check whether xml file exists within zip file
     if (!is_file($xml_file)) {
         return sprintf($lng->txt("cont_zip_file_invalid"), $subdir . "/" . $subdir . ".xml");
     }
     // import questions
     $qti_file = $a_directory . "/qti.xml";
     $qtis = array();
     if (is_file($qti_file)) {
         include_once "./Services/QTI/classes/class.ilQTIParser.php";
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
         $result = $qtiParser->startParsing();
         $founditems =& $qtiParser->getFoundItems();
         $testObj = new ilObjTest(0, true);
         if (count($founditems) > 0) {
             $qtiParser = new ilQTIParser($qti_file, IL_MO_PARSE_QTI, 0, "");
             $qtiParser->setTestObject($testObj);
             $result = $qtiParser->startParsing();
             $qtis = array_merge($qtis, $qtiParser->getImportMapping());
         }
     }
     include_once "./Modules/LearningModule/classes/class.ilContObjParser.php";
     $contParser = new ilContObjParser($this, $xml_file, $subdir, $qmapping);
     $contParser->setQuestionMapping($qtis);
     $contParser->startParsing();
     ilObject::_writeImportId($this->getId(), $this->getImportId());
     $this->MDUpdateListener('General');
     // import style
     $style_file = $a_directory . "/style.xml";
     $style_zip_file = $a_directory . "/style.zip";
     if (is_file($style_zip_file)) {
         require_once "./Services/Style/classes/class.ilObjStyleSheet.php";
         $style = new ilObjStyleSheet();
         $style->import($style_zip_file);
         $this->writeStyleSheetId($style->getId());
     } else {
         if (is_file($style_file)) {
             require_once "./Services/Style/classes/class.ilObjStyleSheet.php";
             $style = new ilObjStyleSheet();
             $style->import($style_file);
             $this->writeStyleSheetId($style->getId());
         }
     }
     //		// validate
     if ($a_validate) {
         $mess = $this->validatePages();
     }
     if ($mess == "") {
         // handle internal links to this learning module
         include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
         ilLMPage::_handleImportRepositoryLinks($this->getImportId(), $this->getType(), $this->getRefId());
     }
     return $mess;
 }