/** * * @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; } }
/** *@param string $xslPath *@return string *@desc Return the XSL with snippet to/from cache. */ public function IncludeSnippet($xslPath) { $xslName = $this->_file->ToString() . '.' . strtolower($this->_context->Language()->getName()) . '.xsl'; $cacheEngine = $this->_context->getXSLCacheEngine(); $result = $cacheEngine->get($xslName, 7200); // Create a new stream representing the file to be written to, // and write the stream cache the stream // from the external location to the file (only if doesnt exist) if ($result === false) { $content = ""; $content = file_get_contents($xslPath); try { $cacheEngine->lock($xslName); $iStart = strpos($content, "<xmlnuke-"); while ($iStart !== false) { $iEnd = strpos($content, ">", $iStart + 1); $snippetFile = substr($content, $iStart + 9, $iEnd - $iStart - 10); $snippet = new SnippetFilenameProcessor(trim($snippetFile)); if (!FileUtil::Exists($snippet)) { throw new SnippetNotFoundException("Snippet " . $snippet->FullQualifiedNameAndPath() . " not found"); } $sReadSnippet = file_get_contents($snippet->FullQualifiedNameAndPath()); $content = substr($content, 0, $iStart) . self::LF . $sReadSnippet . substr($content, $iEnd + 1); $iStart = strpos($content, "<xmlnuke-"); } $cacheEngine->unlock($xslName); $cacheEngine->set($xslName, $content); return $content; } catch (Exception $ex) { $cacheEngine->unlock($xslName); $cacheEngine->release($xslName); throw $ex; } } else { // Already in Cache return $result; } }
public static function ResponseCustomContentFromFile($mimeType, $filename, $downloadName = "") { ob_clean(); if (!FileUtil::Exists($filename)) { header("HTTP/1.1 404 Not Found"); header("status: 404"); echo "<h1>404 Not Found</h1>"; echo "Filename " . basename($filename) . " not found!<br>"; } else { if ($downloadName == "") { $downloadName = $filename; } $downloadName = basename($downloadName); header("Content-Disposition: inline; filename=\"" . $downloadName . "\""); header("Content-Type: " . $mimeType . "; name=\"" . $downloadName . "\""); $content = file_get_contents($filename); echo $content; } exit; }
/** *@param AnydatasetBaseFilenameProcessor $langFile *@return void *@desc Load Languages */ public function LoadLanguages($langFile) { $all = $langFile->ToString() == "_all"; if (!$all) { $this->LoadLanguages(new AnydatasetLangFilenameProcessor("_all")); } $this->_loadedFromFile = false; $paths = array(); if ($langFile->getFilenameLocation() == ForceFilenameLocation::UseWhereExists || $langFile->getFilenameLocation() == ForceFilenameLocation::SharedPath) { $paths[] = $langFile->SharedPath(); } if ($langFile->getFilenameLocation() == ForceFilenameLocation::UseWhereExists || $langFile->getFilenameLocation() == ForceFilenameLocation::PrivatePath) { $paths = array_merge($paths, $langFile->PrivatePath()); } foreach ($paths as $path) { $filename = $path . $langFile->FullQualifiedName(); $this->_debugInfo .= $langFile->ToString() . " in " . $filename . ' '; if (!FileUtil::Exists($filename)) { $this->_debugInfo .= "[Does not exists]; \n"; continue; } $this->_debugInfo .= "[Exists]; \n"; $curLang = strtolower($this->_context->Language()->getName()); try { $lang = new AnyDataset($filename); } catch (Exception $e) { throw new EngineException('Can\'t load language file "' . $langFile->FullQualifiedName() . '"! ' . $e->getMessage()); } $itf = new IteratorFilter(); $itf->addRelation("LANGUAGE", Relation::EQUAL, $curLang); //AnyIterator $it = $lang->getIterator($itf); if ($it->hasNext()) { //SingleRow $sr = $it->moveNext(); $names = $sr->getFieldNames(); foreach ($names as $name) { $this->addText($curLang, $name, $sr->getField($name)); } $this->_loadedFromFile = true; } } }
public function CreatePage() { parent::CreatePage(); $this->myWords = $this->WordCollection(); $this->setTitlePage($this->myWords->Value("TITLE")); $this->setHelp($this->myWords->Value("DESCRIPTION")); $block = new XmlBlockCollection($this->myWords->Value("TITLE"), BlockPosition::Center); $this->addMenuItem($this->_moduleUrl, $this->myWords->Value("MENULISTPOLLS"), ""); $this->addMenuItem("module:Xmlnuke.Admin.ManageDBConn", $this->myWords->Value("MENUMANAGEDBCONN"), ""); // Create a NEW config file and SETUP Database $configfile = new AnydatasetFilenameProcessor("_poll"); if (!FileUtil::Exists($configfile)) { $this->CreateSetup($block); } else { $anyconfig = new AnyDataset($configfile->FullQualifiedNameAndPath()); $it = $anyconfig->getIterator(); if ($it->hasNext()) { $sr = $it->moveNext(); $this->_isdb = $sr->getField("dbname") != "-anydata-"; $this->_connection = $sr->getField("dbname"); $this->_tblanswer = $sr->getField("tbl_answer"); $this->_tblpoll = $sr->getField("tbl_poll"); $this->_tbllastip = $sr->getField("tbl_lastip"); } else { $this->CreateSetup($block); $this->defaultXmlnukeDocument->addXmlnukeObject($block); return $this->defaultXmlnukeDocument->generatePage(); } if ($this->_context->get("op") == "") { $this->ListPoll($block); } elseif ($this->_context->get("op") == "answer") { $polldata = explode("|", $this->_context->get("valueid")); $this->ListAnswers($block, $polldata[0], $polldata[1]); } elseif ($this->_context->get("op") == "answernav") { $this->ListAnswers($block, $this->_context->get("curpoll"), $this->_context->get("curlang")); } } $this->defaultXmlnukeDocument->addXmlnukeObject($block); return $this->defaultXmlnukeDocument->generatePage(); }
/** *@param *@return string *@desc */ public function Exists() { return FileUtil::Exists($this->FullQualifiedNameAndPath()); }
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; }
protected function GetAdminModulesList() { if ($this->_adminModulesList == null) { $this->_adminModulesList = array(); // Nodes $rowNode = "group/module"; $colNode = array(); $colNode["group"] = "../@name"; $colNode["name"] = "@name"; $colNode["icon"] = "icon"; $colNode["url"] = "url"; $colNode["command"] = "@command"; // Read from Generic XML $xmlProcessor = new AdminModulesXmlFilenameProcessor(); for ($i = 0; $i < 2; $i++) { if ($i == 0) { $xmlProcessor->setFilenameLocation(ForceFilenameLocation::SharedPath); } else { $xmlProcessor->setFilenameLocation(ForceFilenameLocation::PrivatePath); } $configFile = $xmlProcessor->FullQualifiedNameAndPath(); if (FileUtil::Exists($configFile)) { $config = FileUtil::QuickFileRead($configFile); $dataset = new XmlDataset($config, $rowNode, $colNode); foreach ($dataset->getIterator() as $sr) { if (array_key_exists($sr->getField("group"), $this->_adminModulesList) || $i == 0) { if ($sr->getField("command") != "@hidegroup") { $this->_adminModulesList[$sr->getField("group")][$sr->getField("name")] = array($sr->getField("icon"), $sr->getField("url")); } else { unset($this->_adminModulesList[$sr->getField("group")]); } } else { $x = array(); $x[$sr->getField("group")][$sr->getField("name")] = array($sr->getField("icon"), $sr->getField("url")); $this->_adminModulesList = $x + $this->_adminModulesList; } } } } } return $this->_adminModulesList; }