Example #1
0
 /**
  * @param XMLFilenameProcessor $xmlModuleName
  * @param Object $customArgs
  * @return void
  * @desc Add custom setup elements
  */
 public function Setup($xmlModuleName, $customArgs)
 {
     $this->_start = microtime(true);
     $this->_xmlModuleName = $xmlModuleName;
     $this->_context = Context::getInstance();
     $this->_cacheFile = new CacheFilenameProcessor($this->_xmlModuleName->ToString());
     $this->_action = $this->_context->get("action");
     if ($this->_action == "") {
         $this->_action = $this->_context->get("acao");
     }
     $this->CustomSetup($customArgs);
     $this->defaultXmlnukeDocument = new XmlnukeDocument();
     $this->_url = new XmlnukeManageUrl(URLTYPE::MODULE, $this->_xmlModuleName->ToString());
     $this->_moduleName = $this->_xmlModuleName->ToString();
 }
Example #2
0
 public function CreatePage()
 {
     parent::CreatePage();
     $onlyGroup = $this->_context->get("onlygroup") != "";
     $urlXml = "module:Xmlnuke.Admin.ManageXML";
     $urlGrp = "module:Xmlnuke.Admin.ManageGroup";
     $this->myWords = $this->WordCollection();
     $this->setTitlePage($this->myWords->Value("TITLE"));
     $this->setHelp($this->myWords->Value("DESCRIPTION"));
     if (!$onlyGroup) {
         $this->addMenuOption($this->myWords->Value("EDITALLXML"), $urlXml . "?id=_all");
         $this->addMenuOption($this->myWords->Value("NEWXML"), $urlXml);
     }
     $this->addMenuOption($this->myWords->Value("NEWGROUP"), $urlGrp);
     // Open Index File
     $indexFile = new XMLFilenameProcessor("index");
     //XmlDocument
     $index = $this->_context->getXMLDataBase()->getDocument($indexFile->FullQualifiedName(), null);
     $groupList = XmlUtil::SelectNodes($index->documentElement, "group");
     $table = new XmlTableCollection();
     foreach ($groupList as $node) {
         $groupText = XmlUtil::SelectSingleNode($node, "title")->nodeValue;
         $groupId = XmlUtil::SelectSingleNode($node, "id")->nodeValue;
         $row = new XmlTableRowCollection();
         $col = new XmlTableColumnCollection();
         $anchor = new XmlAnchorCollection($urlGrp . "?id=" . $groupId, "");
         $anchor->addXmlnukeObject(new XmlnukeText($this->myWords->Value("TXT_EDIT"), true, false, false));
         $col->addXmlnukeObject($anchor);
         $row->addXmlnukeObject($col);
         $col = new XmlTableColumnCollection();
         $anchor = new XmlAnchorCollection($urlGrp . "?id=" . $groupId . "&action=delete", "");
         $anchor->addXmlnukeObject(new XmlnukeText($this->myWords->Value("TXT_DELETE"), true, false, false));
         $col->addXmlnukeObject($anchor);
         $row->addXmlnukeObject($col);
         $col = new XmlTableColumnCollection();
         $col->addXmlnukeObject(new XmlnukeText($groupText, true, false, false));
         $row->addXmlnukeObject($col);
         $table->addXmlnukeObject($row);
         if (!$onlyGroup) {
             $fileList = XmlUtil::SelectNodes($index->documentElement, "group[id='" . $groupId . "']/page");
             foreach ($fileList as $nodeFile) {
                 $fileText = XmlUtil::SelectSingleNode($nodeFile, "title")->nodeValue;
                 $fileId = XmlUtil::SelectSingleNode($nodeFile, "id")->nodeValue;
                 $fileAbstract = XmlUtil::SelectSingleNode($nodeFile, "summary")->nodeValue;
                 $row = new XmlTableRowCollection();
                 $col = new XmlTableColumnCollection();
                 $anchor = new XmlAnchorCollection($urlXml . "?id=" . $fileId, "");
                 $anchor->addXmlnukeObject(new XmlnukeText($this->myWords->Value("TXT_EDIT")));
                 $col->addXmlnukeObject($anchor);
                 $row->addXmlnukeObject($col);
                 $col = new XmlTableColumnCollection();
                 $anchor = new XmlAnchorCollection($urlXml . "?id=" . $fileId . "&action=delete", "");
                 $anchor->addXmlnukeObject(new XmlnukeText($this->myWords->Value("TXT_DELETE")));
                 $col->addXmlnukeObject($anchor);
                 $row->addXmlnukeObject($col);
                 $col = new XmlTableColumnCollection();
                 $col->addXmlnukeObject(new XmlnukeText($fileText));
                 $col->addXmlnukeObject(new XmlnukeBreakLine());
                 $col->addXmlnukeObject(new XmlnukeText($fileAbstract, false, true, false));
                 $row->addXmlnukeObject($col);
                 $table->addXmlnukeObject($row);
             }
         }
     }
     $block = new XmlBlockCollection($this->myWords->Value("WORKINGAREA"), BlockPosition::Center);
     $paragraph = new XmlParagraphCollection();
     $paragraph->addXmlnukeObject($table);
     $block->addXmlnukeObject($paragraph);
     $this->defaultXmlnukeDocument->addXmlnukeObject($block);
     return $this->defaultXmlnukeDocument->generatePage();
 }
Example #3
0
 /**
  *@param XMLFilenameProcessor $xmlFile
  *@desc Save XML String to file
  */
 public function SaveTo($xmlFile)
 {
     $xmlFile->getContext()->getXMLDataBase()->saveDocument($xmlFile->FullQualifiedName(), $this->getDomObject());
 }
Example #4
0
 /**
  * Enter description here...
  *
  * @param XmlnukeDocument $xmlnukeDoc
  */
 protected function Find()
 {
     $myWords = $this->WordCollection();
     $xmlnukeDB = $this->_context->getXMLDataBase();
     $arr = $xmlnukeDB->searchDocuments($this->txtSearch, $this->_context->get("checkAll") != "");
     $blockCenter = new XmlBlockCollection($myWords->Value("BLOCKRESULT"), BlockPosition::Center);
     $this->_document->addXmlnukeObject($blockCenter);
     if ($arr == null) {
         $paragraph = new XmlParagraphCollection();
         $paragraph->addXmlnukeObject(new XmlnukeText($myWords->Value("NOTFOUND")));
         $blockCenter->addXmlnukeObject($paragraph);
     } else {
         $nodeTitleList = array("/meta/title");
         $nodeAbstractList = array("/meta/abstract");
         $configSearchFile = new AnydatasetFilenameProcessor("_configsearch");
         $configSearch = new AnyDataset($configSearchFile->FullQualifiedNameAndPath());
         $iterator = $configSearch->getIterator();
         while ($iterator->hasNext()) {
             $singleRow = $iterator->moveNext();
             $nodeTitleList[] = $sr->getField("nodetitle");
             $nodeAbstractList[] = $sr->getField("nodeabstract");
         }
         foreach ($arr as $s) {
             $singleName = FilenameProcessor::StripLanguageInfo($s);
             try {
                 $file = new XMLFilenameProcessor($singleName);
                 $docResult = $this->_context->getXMLDataBase()->getDocument($file->FullQualifiedName(), null);
                 $nodeResult = $this->getNode($nodeTitleList, $docResult);
                 $titulo = $nodeResult == null ? $myWords->Value("NOTITLE") : $nodeResult->nodeValue;
                 $nodeResult = $this->getNode($nodeAbstractList, $docResult);
                 $abstr = $nodeResult == null ? "" : $nodeResult->nodeValue;
                 $paragraph = new XmlParagraphCollection();
                 $blockCenter->addXmlnukeObject($paragraph);
                 $href = new XmlAnchorCollection("engine:xmlnuke?xml={$singleName}", "");
                 $href->addXmlnukeObject(new XmlnukeText($titulo));
                 $paragraph->addXmlnukeObject($href);
                 $paragraph->addXmlnukeObject(new XmlnukeText(" ["));
                 $href = new XmlAnchorCollection("engine:xmlnuke?xml={$singleName}&xsl=rawxml", "");
                 $href->addXmlnukeObject(new XmlnukeText($myWords->Value("VIEWXML")));
                 $paragraph->addXmlnukeObject($href);
                 $paragraph->addXmlnukeObject(new XmlnukeText("]"));
                 $paragraph->addXmlnukeObject(new XmlnukeBreakLine());
                 $paragraph->addXmlnukeObject(new XmlnukeText($abstr));
             } catch (Exception $e) {
                 $paragraph = new XmlParagraphCollection();
                 $paragraph->addXmlnukeObject(new XmlnukeText($s . " (" . $myWords->Value("NOTITLE") . ")"));
                 $blockCenter->addXmlnukeObject($paragraph);
             }
         }
         $paragraph = new XmlParagraphCollection();
         $paragraph->addXmlnukeObject(new XmlnukeText($myWords->Value("DOCFOUND", sizeof($arr))));
         $blockCenter->addXmlnukeObject($paragraph);
     }
 }
Example #5
0
 public function CreatePage()
 {
     parent::CreatePage();
     // Doesnt necessary get PX, because PX is protected!
     $deleteMode = false;
     //Strings
     $action = strtolower($this->_action);
     $id = $this->_context->get("id");
     $group = $this->_context->get("group");
     $contents = "";
     $titleIndex = $this->_context->get("titleIndex");
     $summaryIndex = $this->_context->get("summaryIndex");
     $groupKeyword = $this->_context->get("groupKeyword");
     $myWords = $this->WordCollection();
     $this->setHelp($myWords->Value("DESCRIPTION"));
     $this->setTitlePage($myWords->Value("TITLE"));
     //XmlNode
     $block = $this->_px->addBlockCenter($myWords->Value("WORKINGAREA"));
     $this->addMenuOption($myWords->Value("TXT_BACK"), "module:Xmlnuke.Admin.ListXML");
     /*
     XmlNode paragraph;
     XmlNode form;
     XmlNode boxButton;
     XmlNode editNode; // (For Index)
     processor.XMLFilenameProcessor xmlFile;
     */
     // Open Index File
     $indexFile = new XMLFilenameProcessor("index");
     //XmlDocument
     $index = $this->_context->getXMLDataBase()->getDocument($indexFile->FullQualifiedName(), null);
     // --------------------------------------
     // CHECK ACTION
     // --------------------------------------
     if ($action == "edit" || $action == "new") {
         $contents = $this->_context->get("contents");
         $contents = stripslashes($contents);
         $this->_context->setSession("texto", $contents);
         /*echo "<PRE>";
         		echo htmlentities($contents);
         		echo "</PRE>";*/
         try {
             $title = "";
             $summary = "";
             //XmlNode $node;
             // Get edited XML and update info about INDEX.
             //XmlDocument
             $xml = XmlUtil::CreateXmlDocumentFromStr($contents);
             //$node = XmlUtil::SelectSingleNode($xml->documentElement, "/page/meta/title");
             $node = XmlUtil::SelectSingleNode($xml->documentElement, "meta/title");
             if ($node != null) {
                 $title = $node->nodeValue;
             }
             //$node = XmlUtil::SelectSingleNode($xml->documentElement,"/page/meta/abstract");
             $node = XmlUtil::SelectSingleNode($xml->documentElement, "meta/abstract");
             if ($node != null) {
                 $summary = $node->nodeValue;
             }
             //$node = XmlUtil::SelectSingleNode($xml->documentElement,"/page/meta/modified");
             $node = XmlUtil::SelectSingleNode($xml->documentElement, "meta/modified");
             if ($node != null) {
                 $node->nodeValue = date("D M j Y G:i:s");
             }
             //$node = XmlUtil::SelectSingleNode($xml->documentElement,"/page/meta/groupkeyword");
             $node = XmlUtil::SelectSingleNode($xml->documentElement, "meta/groupkeyword");
             if ($node != null) {
                 $node->nodeValue = $groupKeyword;
             }
             if ($id != "_all") {
                 if ($action == "edit") {
                     //$editNode = XmlUtil::SelectSingleNode($index->documentElement, "/xmlindex/group[id='" . $group . "']/page[id='" . $id . "']");
                     $editNode = XmlUtil::SelectSingleNode($index->documentElement, "group[id='" . $group . "']/page[id='" . $id . "']");
                     if ($titleIndex == "") {
                         $titleIndex = $title;
                     }
                     XmlUtil::SelectSingleNode($editNode, "title")->nodeValue = $titleIndex;
                     if ($summaryIndex == "") {
                         $summaryIndex = $summary;
                     }
                     XmlUtil::SelectSingleNode($editNode, "summary")->nodeValue = $summaryIndex;
                 } else {
                     //$editNode = XmlUtil::SelectSingleNode($index->documentElement,"/xmlindex/group[id='" . $group . "']");
                     $editNode = XmlUtil::SelectSingleNode($index->documentElement, "group[id='" . $group . "']");
                     $newNode = XmlUtil::CreateChild($editNode, "page", "");
                     XmlUtil::CreateChild($newNode, "id", $id);
                     XmlUtil::CreateChild($newNode, "title", $title);
                     XmlUtil::CreateChild($newNode, "summary", $summary);
                     $titleIndex = $title;
                     $summaryIndex = $summary;
                 }
             }
             $xmlFile = new XMLFilenameProcessor($id);
             $this->_context->getXMLDataBase()->saveDocumentXML($xmlFile->FullQualifiedName(), $xml);
             $this->_context->getXMLDataBase()->saveDocumentXML($indexFile->FullQualifiedName(), $index);
             $this->_context->getXMLDataBase()->saveIndex();
             $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);
         }
     }
     // Get the group from the Index and Update Edit Fields
     //$editNode = XmlUtil::SelectSingleNode( $index->documentElement,"/xmlindex/group[page[id='" . $id . "']]/id");
     $editNode = XmlUtil::SelectSingleNode($index->documentElement, "group[page[id='" . $id . "']]/id");
     if ($editNode != null) {
         $group = $editNode->nodeValue;
         //$editNode = XmlUtil::SelectSingleNode($index->documentElement,"/xmlindex/group[id='" . $group . "']/page[id='" . $id . "']");
         $editNode = XmlUtil::SelectSingleNode($index->documentElement, "group[id='" . $group . "']/page[id='" . $id . "']");
         $titleIndex = XmlUtil::SelectSingleNode($editNode, "title")->nodeValue;
         $summaryIndex = XmlUtil::SelectSingleNode($editNode, "summary")->nodeValue;
     }
     if ($action == "delete") {
         $paragraph = $this->_px->addParagraph($block);
         $this->_px->addHref($paragraph, "module:Xmlnuke.Admin.ManageXML?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);
         //$editNode = XmlUtil::SelectSingleNode($index->documentElement,"/xmlindex/group[id='" . $group . "']");
         $editNode = XmlUtil::SelectSingleNode($index->documentElement, "group[id='" . $group . "']");
         $delNode = XmlUtil::SelectSingleNode($editNode, "page[id='" . $id . "']");
         if ($delNode != null) {
             $editNode->removeChild($delNode);
         }
         $this->_context->getXMLDataBase()->saveDocumentXML($indexFile->FullQualifiedName(), $index);
         //util.FileUtil.DeleteFile(new processor.XMLFilenameProcessor(_context.get("id"), this._context));
         $this->_context->getXMLDataBase()->saveIndex();
         $this->_px->addBold($paragraph, $myWords->Value("DELETED"));
         $deleteMode = true;
     }
     // --------------------------------------
     // EDIT XML PAGE
     // --------------------------------------
     // If doesnt have an ID, list all pages or add new!
     if ($id == "") {
         $action = "new";
     } else {
         $this->addMenuOption($myWords->Value("PREVIEWMENU"), "engine:xmlnuke?xml=" . $id . "&xsl=[param:xsl]&lang=[param:lang]", "preview");
         $this->addMenuOption($myWords->Value("NEWXMLMENU"), "module:Xmlnuke.Admin.ManageXML", null);
         $langAvail = $this->_context->LanguagesAvailable();
         $processorFile = new XMLFilenameProcessor($id);
         foreach (array_keys($langAvail) as $key) {
             if ($key != strtolower($this->_context->Language()->getName())) {
             }
             $repositorio = new XmlnukeDB($this->_context->XmlHashedDir(), $this->_context->XmlPath(), $key);
             $fileToCheck = $processorFile->FullName($id, "", $key) . $processorFile->Extension();
             if ($repositorio->existsDocument($fileToCheck)) {
                 $this->addMenuOption($myWords->ValueArgs("EDITXMLMENU", array($langAvail[$key])), "module:Xmlnuke.Admin.ManageXML?id=" . $id . "&lang=" . $key, null);
             } else {
                 $this->addMenuOption($myWords->ValueArgs("CREATEXMLMENU", array($langAvail[$key])), "module:Xmlnuke.Admin.ManageXML?id=" . $id . "&lang=" . $key, null);
             }
         }
         $action = "edit";
     }
     // Show form to Edit/Insert
     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.ManageXML", "", "form", true);
         $xmlExist = true;
         if ($id != "") {
             $xmlTestExist = new XMLFilenameProcessor($id);
             $xmlExist = $this->_context->getXMLDataBase()->existsDocument($xmlTestExist->FullQualifiedName());
         }
         $canUseNew = $action != "new" && !$xmlExist;
         //Trecho acrescentado para manter o conteudo do textarea mesmo no caso de erro.
         $contents = $this->_context->getSession("texto");
         //echo $contents;
         if ($action == "new" || $canUseNew) {
             $action = "new";
             // This is necessary, because user can Create a predefined ID...
             if (!$canUseNew || $id == "") {
                 $this->_px->addTextBox($form, $myWords->Value("XMLBOX"), "id", "", 20, true, INPUTTYPE::TEXT);
             } else {
                 $this->_px->addLabelField($form, $myWords->Value("XMLBOX"), $id);
                 $this->_px->addHidden($form, "id", $id);
             }
             $this->_px->addLabelField($form, $myWords->Value("LANGUAGEBOX"), strtolower($this->_context->Language()->getName()));
             //if($contents!="")
             //{
             $contents = "<page>\n" . "  <meta>\n" . "    <title>Put your title here</title>\n" . "    <abstract>Put page abstract informations here</abstract>\n" . "    <created>" . date("D M j Y G:i:s") . "</created>\n" . "    <modified/>\n" . "    <keyword>xmlnuke</keyword>\n" . "    <groupkeyword>all</groupkeyword>\n" . "  </meta>\n" . "  <blockcenter>\n" . "    <title>Block Title</title>\n" . "    <body>\n" . "      <p>This is the first paragraph</p>\n" . "    </body>\n" . "  </blockcenter>\n" . "</page>\n";
             //}
             session_unregister("texto");
         } else {
             $this->_px->addLabelField($form, $myWords->Value("LANGUAGEBOX"), strtolower($this->_context->Language()->getName()));
             $this->_px->addHidden($form, "id", $id);
             $xmlFile = new XMLFilenameProcessor($id);
             //XmlDocument
             $xml = $this->_context->getXMLDataBase()->getDocument($xmlFile->FullQualifiedName(), null);
             //if($contents!="")
             $contents = str_replace("&amp;", "&", XmlUtil::GetFormattedDocument($xml));
             $editNode = XmlUtil::SelectSingleNode($xml->documentElement, "meta/groupkeyword");
             if ($editNode != null) {
                 $groupKeyword = $editNode->nodeValue;
             }
             session_unregister("texto");
         }
         if ($id != "_all") {
             $this->_px->addCaption($form, $myWords->Value("SITEMAPINFO"));
             $this->_px->addTextBox($form, $myWords->Value("INDEXBOX"), "titleIndex", $titleIndex, 60, true, INPUTTYPE::TEXT);
             $selectNode = $this->_px->addSelect($form, $myWords->Value("LISTEDBOX"), "group");
             $this->_px->addTextBox($form, $myWords->Value("INDEXSUMMARYBOX"), "summaryIndex", $summaryIndex, 60, true, INPUTTYPE::TEXT);
             $this->_px->addCaption($form, $myWords->Value("PAGEINFO"));
             //XmlNode
             $selectPageNode = $this->_px->addSelect($form, $myWords->Value("SHOWMENUBOX"), "groupKeyword");
             $this->_px->addOption($selectPageNode, $myWords->Value("NOTLISTEDOPTION"), "-", null);
             //XmlNodeList
             //$groupList = XmlUtil::SelectNodes($index->documentElement,"/xmlindex/group");
             $groupList = XmlUtil::SelectNodes($index->documentElement, "/group");
             foreach ($groupList as $node) {
                 $value = XmlUtil::SelectSingleNode($node, "title")->nodeValue;
                 $this->_px->addOption($selectNode, XmlUtil::SelectSingleNode($node, "title")->nodeValue . " (" . XmlUtil::SelectSingleNode($node, "/id")->nodeValue . ")", XmlUtil::SelectSingleNode($node, "/id")->nodeValue, XmlUtil::SelectSingleNode($node, "/id")->nodeValue == $group);
                 $this->_px->addOption($selectPageNode, XmlUtil::SelectSingleNode($node, "title")->nodeValue . " (" . XmlUtil::SelectSingleNode($node, "/keyword")->nodeValue . ")", XmlUtil::SelectSingleNode($node, "/keyword")->nodeValue, XmlUtil::SelectSingleNode($node, "/keyword")->nodeValue == $groupKeyword);
             }
         }
         $this->_px->addHidden($form, "action", $action);
         $this->_px->addCaption($form, $myWords->Value("XMLEDITINFO"));
         $this->_px->addMemo($form, $myWords->Value("XMLCONTENTBOX"), "contents", $contents, 80, 30, "soft");
         $boxButton = $this->_px->addBoxButtons($form);
         $this->_px->addSubmit($boxButton, "", $myWords->Value("TXT_SAVE"));
     }
     return $this->_px;
 }
Example #6
0
 /**
  *@desc Get a XMLDocument from a XMLFile
  *@param XMLFilenameProcessor $xmlFile XML File
  *@return DOMDocument
  */
 public function getXmlDocument($xmlFile)
 {
     $this->_context->setXml($xmlFile->ToString());
     // Load XMLDocument and add ALL and INDEX nodes
     $xmlDoc = new DOMDocument();
     try {
         if (!($xmlFile->getFilenameLocation() == ForceFilenameLocation::PathFromRoot)) {
             $xmlDoc = $this->_context->getXMLDataBase()->getDocument($xmlFile->FullQualifiedName(), null);
         } else {
             $xmlDoc = XmlUtil::CreateXmlDocumentFromFile($xmlFile->FullQualifiedNameAndPath());
         }
     } catch (Exception $ex) {
         $xmlFileNotFound = new XMLFilenameProcessor("notfound");
         if ($this->_context->getXMLDataBase()->existsDocument($xmlFileNotFound->FullQualifiedName())) {
             $xmlDoc = $this->_context->getXMLDataBase()->getDocument($xmlFileNotFound->FullQualifiedName(), null);
         } else {
             throw $ex;
         }
     }
     $xmlRootNode = $xmlDoc->getElementsByTagName("page")->item(0);
     if ($xmlRootNode != null) {
         $this->addXMLDefault($xmlRootNode);
     }
     return $xmlDoc;
 }