Ejemplo n.º 1
0
 /**
  *@param string $singlename
  *@return string
  *@desc
  */
 public function __construct($singlename)
 {
     parent::__construct($singlename);
     // The function to manipulate HASHED XML files is in BTREEUTILS...
     // So nothing to change HERE (instead XMLCacheFileName and XSLCacheFileName).
     $this->_filenameLocation = ForceFilenameLocation::PrivatePath;
 }
Ejemplo n.º 2
0
 /**
  * Use singlename like path/to/file/filename.* to get the source file extension
  * @param string $singlename
  * @return void
  */
 public function __construct($singlename = "")
 {
     if ($singlename == "") {
         $singlename = basename(tempnam('/tmp/', 'upload_'));
         parent::__construct($singlename);
         $this->setFilenameLocation(ForceFilenameLocation::DefinePath, "/tmp");
     } else {
         parent::__construct($singlename);
         $this->_filenameLocation = ForceFilenameLocation::PrivatePath;
     }
 }
Ejemplo n.º 3
0
 /**
  *
  * @param string $singlename
  */
 public function __construct($singlename)
 {
     parent::__construct($singlename);
     if ($this->_context->CacheHashedDir()) {
         $this->setFilenameLocation(ForceFilenameLocation::DefinePath, $this->_context->CachePath() . $singlename[0] . FileUtil::Slash() . $singlename[1] . FileUtil::Slash());
         if (!FileUtil::Exists($this->PathSuggested())) {
             FileUtil::ForceDirectories($this->PathSuggested());
         }
     } else {
         $this->_filenameLocation = ForceFilenameLocation::PrivatePath;
     }
 }
Ejemplo n.º 4
0
 /**
  * Use singlename as path/to/file/*.* to get the source file name and extension
  * @param string $singlename
  * @param Context $context
  */
 public function __construct($singlename)
 {
     $parts = pathinfo($singlename);
     if ($parts["dirname"] != '.') {
         $slash = FileUtil::Slash();
         $this->_subpath = $parts["dirname"] . $slash;
         if ($this->_subpath[0] == $slash) {
             $this->_subpath = substr($this->_subpath, 1);
         }
     } else {
         $this->_subpath = '';
     }
     $this->_extension = $parts["extension"];
     if (empty($this->_extension)) {
         $this->_extension = 'jpg';
     }
     $singlename = basename($parts["basename"], $this->Extension());
     parent::__construct($singlename);
 }
Ejemplo n.º 5
0
 /**
  *@param string $singlename
  *@return void
  *@desc
  */
 public function __construct($singlename)
 {
     parent::__construct($singlename);
 }
Ejemplo n.º 6
0
 /**
  *
  * @param FilenameProcessor $file
  * @throws FileUtilException
  */
 public static function DeleteFile($file)
 {
     if ($file instanceof FilenameProcessor) {
         $filename = $file->FullQualifiedNameAndPath();
     } else {
         $filename = $file;
     }
     if (!@unlink($filename)) {
         throw new FileUtilException("Cannot delete the file {$filename}.", 106);
     }
 }
Ejemplo n.º 7
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);
     }
 }
Ejemplo n.º 8
0
 /**
  *@param
  *@return string
  *@desc Implementing
  */
 public function FullName($xml, $xsl, $languageId)
 {
     return parent::addLanguage($xsl, $languageId);
 }
Ejemplo n.º 9
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;
 }
Ejemplo n.º 10
0
 /**
  *
  * @param array $filelist
  * @param FilenameProcessor $proc
  * @return IteratorInterface
  */
 private function getIteratorFromList($filelist, $proc)
 {
     $arResult = array();
     asort($filelist);
     foreach ($filelist as $key => $file) {
         $name = FileUtil::ExtractFileName($file);
         $name = $proc->removeLanguage($name);
         $arResult[$name] = $name;
     }
     $ds = new ArrayDataset($arResult, "singlename");
     return $ds->getIterator();
 }