public function CreatePage() { parent::CreatePage(); // Doesnt necessary get PX, because PX is protected! $myWords = $this->WordCollection(); $this->setHelp($myWords->Value("HELP")); //this.addMenuOption("OK", "module:Xmlnuke.Admin.ManageGroup?action=aqui"); $this->setTitlePage($myWords->Value("TITLE")); $this->addMenuOption($myWords->Value("DELETEBUTTON"), "module:Xmlnuke.Admin.ManageCache?action=erase", null); $this->addMenuOption($myWords->Value("CACHELIST"), "module:Xmlnuke.Admin.ManageCache?action=list", null); $action = strtolower($this->_action); $block = $this->_px->addBlockCenter($myWords->Value("SELECTIONAREA")); //XmlNode paragraph; if ($action == "erase") { FileUtil::DeleteFilesFromPath($this->_cacheFile); FileUtil::DeleteFilesFromPath(new XSLCacheFilenameProcessor("")); $dirs = FileUtil::RetrieveSubFolders($this->_context->CachePath()); foreach ($dirs as $key => $value) { //FileUtil::DeleteDirectory($value); } $paragraph = $this->_px->addParagraph($block); $this->_px->addBold($paragraph, $myWords->Value("DELETED")); } if ($action == "list") { $filelist = array(); $filelist = FileUtil::RetrieveFilesFromFolder($this->_cacheFile->PathSuggested(), null); $paragraph = $this->_px->addUnorderedList($block); //XmlNode item; foreach ($filelist as $file) { $item = $this->_px->addOptionList($paragraph); $this->_px->addText($item, FileUtil::ExtractFileName($file)); } } return $this->_px; }
public function importDocuments($directory, $btree, $saveDocs, $filemask = null) { if ($filemask == null) { $filemask = ".xml"; } $files = FileUtil::RetrieveFilesFromFolder($directory, $filemask); if ($files != null) { foreach ($files as $file) { $doc = XmlUtil::CreateXmlDocumentFromFile($file); if ($saveDocs) { $btree = self::saveDocument(self::getNameFromFile($file), $xmldoc, $btree); } else { $btree = BTreeUtil::navigateNodes($doc->documentElement, self::getNameFromFile($file) . "#/", $btree); } } } if (strpos($directory, ".svn") === false) { $directories = FileUtil::RetrieveSubFolders($directory); if ($directories != null) { foreach ($directories as $dir) { $btree = self::importDocuments($dir, $btree, $saveDocs, $filemask); } } } return $btree; }
/** * Output error message * * @return PageXml object */ public function CreatePage() { $myWords = $this->WordCollection(); $this->defaultXmlnukeDocument = new XmlnukeDocument($myWords->Value("TITLE"), $myWords->Value("ABSTRACT")); $blockcenter = new XmlBlockCollection($myWords->Value("TITLE"), BlockPosition::Center); $this->defaultXmlnukeDocument->addXmlnukeObject($blockcenter); $paragraph = new XmlParagraphCollection(); $blockcenter->addXmlnukeObject($paragraph); $xslUsed = array(); $xsl = new XSLFilenameProcessor(""); $filelist = FileUtil::RetrieveFilesFromFolder($xsl->PrivatePath(), $xsl->Extension()); $this->generateList($myWords->Value("LISTPERSONAL"), $paragraph, $filelist, $xslUsed, $xsl); $filelist = FileUtil::RetrieveFilesFromFolder($xsl->SharedPath(), $xsl->Extension()); $this->generateList($myWords->Value("LISTGENERIC"), $paragraph, $filelist, $xslUsed, $xsl); return $this->defaultXmlnukeDocument->generatePage(); }
public function CreatePage() { parent::CreatePage(); // Doesnt necessary get PX, because PX is protected! $deleteMode = false; $action = strtolower($this->_action); $id = $this->_context->get("id"); $contents = ""; $myWords = $this->WordCollection(); $this->setHelp($myWords->Value("DESCRIPTION")); $this->setTitlePage($myWords->Value("TITLE")); //XmlNodes $block = $this->_px->addBlockCenter($myWords->Value("WORKINGAREA")); /* XmlNode paragraph; XmlNode form; XmlNode boxButton; */ //processor.XSLFilenameProcessor xslFile; // -------------------------------------- // CHECK ACTION // -------------------------------------- if ($action == "edit" || $action == "new") { $contents = $this->_context->get("contents"); $contents = stripslashes($contents); try { // It is necessary only to load the document to check if it is OK. // If OK, use the original raw file $xsl = XmlUtil::CreateXmlDocumentFromStr($contents); $xslFile = new XSLFilenameProcessor($id); FileUtil::QuickFileWrite($xslFile->FullQualifiedNameAndPath(), str_replace("&#", "&#", $contents)); $paragraph = $this->_px->addParagraph($block); FileUtil::DeleteFilesFromPath($this->_cacheFile); FileUtil::DeleteFilesFromPath(new XSLCacheFilenameProcessor("")); $this->_px->addBold($paragraph, $myWords->Value("SAVED")); } catch (Exception $ex) { $paragraph = $this->_px->addParagraph($block); $this->_px->AddErrorMessage($paragraph, $contents, $ex); } } if ($action == "delete") { $paragraph = $this->_px->addParagraph($block); $this->_px->addHref($paragraph, "module:Xmlnuke.Admin.ManageXSL?id=" . $this->_context->get("id") . "&action=confirmdelete", $myWords->Value("CONFIRMDELETE", $this->_context->get("id")), null); $deleteMode = true; } if ($action == "confirmdelete") { $paragraph = $this->_px->addParagraph($block); FileUtil::DeleteFile(new XSLFilenameProcessor($this->_context->get("id"))); $this->_px->addBold($paragraph, $myWords->Value("DELETED")); $deleteMode = true; } // -------------------------------------- // EDIT XSL PAGE // -------------------------------------- // If doesnt have an ID, list all pages or add new! if ($id == "") { //XmlNode list; //XmlNode optlist; $xslFile = new XSLFilenameProcessor("page"); //array $templates = FileUtil::RetrieveFilesFromFolder($xslFile->PathSuggested(), "." . strtolower($this->_context->Language()->getName() . $xslFile->Extension())); $paragraph = $this->_px->addParagraph($block); $this->_px->addText($paragraph, $myWords->Value("SELECTPAGE")); $list = $this->_px->addUnorderedList($paragraph); foreach ($templates as $key) { $optlist = $this->_px->addOptionList($list); //$xslKey = substr($key, strlen($xslFile->PathSuggested())); $xslKey = basename($key); $xslKey = FilenameProcessor::StripLanguageInfo($xslKey); $this->_px->addHref($optlist, "module:Xmlnuke.Admin.ManageXSL?id=" . $xslKey, $xslKey, null); $this->_px->addText($optlist, " ["); $this->_px->addHref($optlist, "module:Xmlnuke.Admin.ManageXSL?id=" . $xslKey . "&action=delete", $myWords->Value("TXT_DELETE"), null); $this->_px->addText($optlist, "]"); } $action = "new"; } else { $this->addMenuOption($myWords->Value("NEWPAGE"), "module:Xmlnuke.Admin.ManageXSL", null); $this->addMenuOption($myWords->Value("PREVIEWPAGE"), "engine:xmlnuke?xml=home&xsl=" . $id . "&lang=" . $this->_context->Language()->getName(), null); //array $langAvail = $this->_context->LanguagesAvailable(); foreach ($langAvail as $key => $value) { if ($key != strtolower($this->_context->Language()->getName())) { } $this->addMenuOption($myWords->ValueArgs("EDITXSLMENU", array($value)), "module:Xmlnuke.Admin.ManageXSL?id=" . $id . "&lang=" . $key, null); } $action = "edit"; } if (!$deleteMode) { $paragraph = $this->_px->addParagraph($block); //XMLNodes $table = $this->_px->addTable($paragraph); $row = $this->_px->addTableRow($table); $col = $this->_px->addTableColumn($row); $form = $this->_px->addForm($col, "module:Xmlnuke.Admin.ManageXSL", "", "form", true); if ($action == "new") { $this->_px->addTextBox($form, $myWords->Value("XSLBOX"), "id", "", 20, true, INPUTTYPE::TEXT); } else { $this->_px->addLabelField($form, $myWords->Value("XSLBOX"), $id); $this->_px->addHidden($form, "id", $id); $xslFile = new XSLFilenameProcessor($id); if (FileUtil::Exists($xslFile->FullQualifiedNameAndPath())) { //XmlDocument $xsl = XmlUtil::CreateXmlDocumentFromFile($xslFile->FullQualifiedNameAndPath()); $contents = XmlUtil::GetFormattedDocument($xsl); } } $this->_px->addLabelField($form, $myWords->Value("LANGUAGEBOX"), strtolower($this->_context->Language()->getName())); $this->_px->addMemo($form, $myWords->Value("LABEL_CONTENT"), "contents", $contents, 80, 30, "soft"); $this->_px->addHidden($form, "action", $action); $boxButton = $this->_px->addBoxButtons($form); $this->_px->addSubmit($boxButton, "", $myWords->Value("TXT_SAVE")); } return $this->_px; }
public function CreatePage() { parent::CreatePage(); // Doesnt necessary get PX, because PX is protected! $this->myWords = $this->WordCollection(); $this->setTitlePage($this->myWords->Value("TITLE")); $this->setHelp($this->myWords->Value("DESCRIPTION")); $this->addMenuOption($this->myWords->Value("NEWLANGUAGEFILE"), "module:Xmlnuke.Admin.EditLanguage?action=new"); $this->addMenuOption($this->myWords->Value("VIEWSHAREDFILES"), "module:Xmlnuke.Admin.EditLanguage?op=1"); $this->addMenuOption($this->myWords->Value("VIEWPRIVATEFILES"), "module:Xmlnuke.Admin.EditLanguage"); $block = new XmlBlockCollection($this->myWords->Value("WORKINGAREA"), BlockPosition::Center); $this->defaultXmlnukeDocument->addXmlnukeObject($block); $op = $this->_context->get("op"); $ed = $this->_context->get("ed"); $langDir = new AnydatasetLangFilenameProcessor(""); if ($op == "") { $filelist = FileUtil::RetrieveFilesFromFolder($langDir->PrivatePath(), $langDir->Extension()); } else { $filelist = FileUtil::RetrieveFilesFromFolder($langDir->SharedPath(), $langDir->Extension()); } $it = $this->getIteratorFromList($filelist, $langDir); if ($this->_action == "") { $editlist = new XmlEditList($this->_context, $this->myWords->Value("FILELIST{$op}"), "module:Xmlnuke.Admin.EditLanguage", true, false, true, false); $field = new EditListField(); $field->editlistName = "#"; $field->fieldData = "key"; $editlist->addEditListField($field); $field = new EditListField(); $field->editlistName = "Language Filename"; $field->fieldData = "singlename"; $editlist->addEditListField($field); $editlist->setDataSource($it); $editlist->addParameter("op", $op); $editlist->setEnablePage(true); $editlist->setPageSize(20, 0); $block->addXmlnukeObject($editlist); } elseif ($this->_action == ModuleAction::Edit || $ed == 1) { if ($ed == 1) { $file = $this->_context->get("file"); } else { $file = $this->_context->get("valueid"); } $langDir = new AnydatasetLangFilenameProcessor($file); $langDir->setFilenameLocation($op == "" ? ForceFilenameLocation::PrivatePath : ForceFilenameLocation::SharedPath); $anydata = new AnyDataset($langDir->FullQualifiedNameAndPath()); $it = $anydata->getIterator(); $sr = $it->moveNext(); $arFields = $sr->getFieldNames(); $i = 0; $CrudFieldCollection = new CrudFieldCollection(); foreach ($arFields as $value) { $process = CrudField::FactoryMinimal($value, $value, 40, $i < 4, true); $process->key = $i == 0; if ($value == "LANGUAGE") { $process->beforeInsertFormatter = $this; } $CrudFieldCollection->addCrudField($process); $i++; } $crud = new XmlnukeCrudAnydata($this->_context, $CrudFieldCollection, $this->myWords->Value("EDITLANGUAGE", $file), "module:Xmlnuke.Admin.EditLanguage", null, $langDir); $crud->addParameter("op", $op); $crud->addParameter("ed", 1); $crud->addParameter("file", $file); $block->addXmlnukeObject($crud); } elseif ($this->_action == ModuleAction::Create) { $form = new XmlFormCollection($this->_context, "module:Xmlnuke.Admin.EditLanguage", $this->myWords->Value("NEWLANGUAGEFILE")); $form->addXmlnukeObject(new XmlInputHidden("action", ModuleAction::CreateConfirm)); $form->addXmlnukeObject(new XmlInputHidden("op", $op)); $form->addXmlnukeObject(new XmlInputTextBox($this->myWords->Value("NEWFILE"), "newfile", "", 30)); $form->addXmlnukeObject(new XmlInputMemo($this->myWords->Value("FIELDS"), "fields", "TITLE\r\nABSTRACT")); $form->addXmlnukeObject(XmlInputButtons::CreateSubmitButton($this->myWords->Value("TXT_SUBMIT"))); $block->addXmlnukeObject($form); } elseif ($this->_action == ModuleAction::CreateConfirm) { $file = $this->_context->get("newfile"); $langDir = new AnydatasetLangFilenameProcessor($file); $langDir->setFilenameLocation($op == "" ? ForceFilenameLocation::PrivatePath : ForceFilenameLocation::SharedPath); $anydata = new AnyDataset($langDir->FullQualifiedNameAndPath()); $fields = explode("\r\n", $this->_context->get("fields")); $langs = $this->_context->LanguagesAvailable(); foreach ($langs as $lang => $dummy) { $anydata->appendRow(); $anydata->addField("lang", $lang); foreach ($fields as $field) { $anydata->addField($field, ""); } } $anydata->Save($langDir); $this->_context->redirectUrl("module:Xmlnuke.Admin.EditLanguage?ed=1&file={$file}"); } $langfile = $this->_context->get("langfile"); $contents = $this->_context->get("contents"); $contents = stripslashes($contents); return $this->defaultXmlnukeDocument; }