Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 protected function Opcao8()
 {
     $block = new XmlBlockCollection("Exemplo 8: TextFileDataset", BlockPosition::Center);
     //XmlnukeBreakLine br = new XmlnukeBreakLine();
     $para1 = new XmlParagraphCollection();
     $txtstr = $this->_context->get("txtstr");
     $regexp = $this->_context->get("regexp");
     $colNodeStr = preg_split("/\n/", $this->_context->get("cols"));
     if ($txtstr != "") {
         $processor = new AnydatasetFilenameProcessor("sample");
         FileUtil::QuickFileWrite($processor->PathSuggested() . "sample.csv", $txtstr);
         $dataset = new TextFileDataset($processor->PathSuggested() . "sample.csv", $colNodeStr, $regexp);
         //$para1->addXmlnukeObject(new XmlnukeText(""));
         $editlist = new XmlEditList($this->_context, "Text Flat", $this->_url . "?op=8");
         $editlist->setReadOnly(true);
         $editlist->setDataSource($dataset->getIterator());
         $para1->addXmlnukeObject($editlist);
     } else {
         $processor = new AnydatasetFilenameProcessor("sample");
         $txtstr = FileUtil::QuickFileRead($processor->PathSuggested() . "sample.csv");
         $regexp = TextFileDataset::CSVFILE;
         $colNodeStr = array();
         $colNodeStr[] = "category";
         $colNodeStr[] = "title";
         $colNodeStr[] = "titlelang";
         $colNodeStr[] = "year";
         $colNodeStr[] = "price";
         $colNodeStr[] = "buyprice";
         $colNodeStr[] = "author";
     }
     // Cria um Formulário
     $form = new XmlFormCollection($this->_context, $this->_url, "Formulário de Edição");
     $form->addXmlnukeObject(new XmlInputHidden("op", "8"));
     $memo = new XmlInputMemo("Text", "txtstr", $txtstr);
     $form->addXmlnukeObject($memo);
     $text = new XmlInputTextBox("Regular Expression", "regexp", $regexp, 40);
     $text->setRequired(true);
     $form->addXmlnukeObject($text);
     $colMemo = new XmlInputMemo("Col Names", "cols", join("\n", $colNodeStr));
     $form->addXmlnukeObject($colMemo);
     $buttons = new XmlInputButtons();
     $buttons->addSubmit("Submit", "bs");
     $form->addXmlnukeObject($buttons);
     $block->addXmlnukeObject($para1);
     $block->addXmlnukeObject($form);
     $this->_document->addXmlnukeObject($block);
 }