public function Format($row, $fieldname, $value) { $files = $this->_context->getUploadFileNames(); if ($files[$fieldname] != "") { $fileProcessor = new UploadFilenameProcessor($this->_saveAs); $fileProcessor->setFilenameLocation(ForceFilenameLocation::DefinePath, FileUtil::GetTempDir()); // Save the files in a temporary directory $result = $this->_context->processUpload($fileProcessor, false, $fieldname); // Get a way to rename the files $fileinfo = pathinfo($result[0]); if ($this->_saveAs != "*") { $path_parts = pathinfo($this->_saveAs); } else { $path_parts = pathinfo($result[0]); } $newName = $this->_path . FileUtil::Slash() . $path_parts['filename'] . "." . $fileinfo["extension"]; // Put the image in the right place if (strpos(".jpg.gif.jpeg.png", "." . $fileinfo["extension"]) === false) { rename($result[0], $newName); } else { if ($this->_width > 0 || $this->_height > 0) { $image = new ImageUtil($result[0]); $image->resizeAspectRatio($this->_width, $this->_height, 255, 255, 255)->save($newName); } else { rename($result[0], $newName); } } return $newName; } else { return $row->getField($fieldname); } }
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; }
/** * * @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; } }
protected function autoLoad_UserProjects($className) { $class = str_replace('\\', '/', $className[0] == '\\' ? substr($className, 1) : $className); foreach (AutoLoad::$_folders[AutoLoad::USER_PROJECTS] as $libName => $libDir) { $file = $libDir . '/' . $class; $file = file_exists("{$file}.php") ? "{$file}.php" : (file_exists("{$file}.class.php") ? "{$file}.class.php" : null); if (!empty($file) && \Xmlnuke\Util\FileUtil::isReadable($file)) { require_once $file; return; } } return; }
/** *@param XMLFilenameProcessor $xmlfilename *@param string $path *@param string $strfilename *@return void *@desc *PageXml Constructor. Empty page. and PageXml Constructor. Create from XML. *PageXml Constructor. Create from file name and path. Do not use with XmlnukeDB repository. */ public function __construct($xmlfilename = null, $path = null, $strfilename = null) { if ($xmlfilename == null && $path == null && $strfilename == null) { $auxStr = "<page>\r\n" . "<meta>\r\n" . "<title/>\r\n" . "<abstract/>\r\n" . "<created>" . date("D M j Y G:i:s") . "</created>\r\n" . "<modified>" . date("D M j Y G:i:s") . "</modified>\r\n" . "<keyword>XMLSite ByJG</keyword>\r\n" . "<groupkeyword/>\r\n" . "</meta>\r\n" . "<group>\r\n" . "<id>__DEFAULT__</id>\r\n" . "<title/>\r\n" . "<keyword>all</keyword>\r\n" . "</group>\r\n" . "</page>"; $this->_xmlDoc = XmlUtil::CreateXmlDocumentFromStr($auxStr); $xpath = new DOMXPath($this->_xmlDoc); $this->_nodePage = $this->_xmlDoc->getElementsByTagName("page")->item(0); $this->_nodeGroup = $xpath->query("/page/group")->item(0); } else { if ($xmlfilename != null && $path == null && $strfilename == null) { $this->_xmlDoc = $xmlfilename->getContext()->getXMLDataBase()->getDocument($xmlfilename->FullQualifiedName()); } else { if ($xmlfilename == null && $path != null && $strfilename != null) { $xmlDoc = XmlUtil::CreateXmlDocument(); $xmlDoc->Load(FileUtil::AdjustSlashes($path . FileUtil::Slash() . $strfilename)); } } } }
/** * Create and show the list of Xsl Templates * * @param String $caption * @param XmlParagraphCollection $paragraph * @param Array $filelist * @param Array $xslUsed * @param XSLFilenameProcessor $xsl */ private function generateList($caption, $paragraph, $filelist, $xslUsed, $xsl) { $paragraph->addXmlnukeObject(new XmlnukeText($caption, true)); $listCollection = new XmlListCollection(XmlListType::UnorderedList); $paragraph->addXmlnukeObject($listCollection); foreach ($filelist as $file) { $xslname = FileUtil::ExtractFileName($file); $xslname = $xsl->removeLanguage($xslname); if (!in_array($xslname, $xslUsed)) { $objectList = new XmlnukeSpanCollection(); $listCollection->addXmlnukeObject($objectList); $xslUsed[] = $xslname; if ($xslname == "index") { $anchor = new XmlAnchorCollection("engine:xmlnuke?xml=index&xsl=index"); $anchor->addXmlnukeObject(new XmlnukeText($xslname, true)); $objectList->addXmlnukeObject($anchor); } else { $anchor = new XmlAnchorCollection("module:Xmlnuke.XSLTheme?xsl=" . $xslname); $anchor->addXmlnukeObject(new XmlnukeText($xslname, true)); $objectList->addXmlnukeObject($anchor); } } } }
/** *@param *@return string *@desc */ public function PrivatePath() { return FileUtil::Slash($this->_context->CurrentSitePath(false), "snippet"); }
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; }
public function saveDocumentStream($documentName, $stream) { $xml = new DOMDocument(); $xmlstr = FileUtil::QuickFileRead($this->_persistUtil->getFullFileName($documentName)); $this->saveDocumentStr($documentName, $xmlstr); }
/** *@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; }
/** *@desc Transform an XMLDocument object with an XSLFile *@param DOMDocument $xml *@param XSLFilenameProcessor $xslFile XSL File *@return string - The transformation string */ public function TransformDocument($xml, $xslFile) { // Add a custom XML based on attribute xmlobjet inside root // Example: // <page xmlobject="plugin.name(param1, param2)"> $pattern = "/(?P<plugin>.*?)\\s*\\((?P<param>([#']?.*?[#']?\\s*,?\\s*)+)?\\)/"; $xmlRoot = $xml->documentElement; $xmlRootAttributes = $xmlRoot->attributes; if ($xmlRootAttributes != null) { foreach ($xmlRootAttributes as $attr) { if ($attr->nodeName == "xmlobject") { $match = preg_match_all($pattern, $attr->value, $matches); for ($iCount = 0; $iCount < $match; $iCount++) { $param = explode(",", $matches["param"][$iCount]); for ($i = 0; $i <= 4; $i++) { if (count($param) < $i + 1) { $param[] = null; } elseif ($param[$i] == "#CONTEXT#") { $param[$i] = $this->_context; } else { $param[$i] = trim($param[$i]); } } $className = str_replace('.', '\\', $matches["plugin"][$iCount]); if ($className[0] != '\\') { $className = "\\{$className}"; } $plugin = new $className($param[0], $param[1], $param[2], $param[3], $param[4]); if ($plugin instanceof IXmlnukeDocumentObject) { $plugin->generateObject($xmlRoot); } else { $handler = new ObjectHandler($xmlRoot, $plugin); $handler->CreateObjectFromModel(); } } } else { if ($attr->nodeName == 'xsl') { $xslFile = new XSLFilenameProcessor($attr->value); } } } } // Check if there is no XSL template if ($this->_outputResult != OutputData::Xslt) { if ($this->_extractNodes == "") { $outDocument = $xml; } else { $nodes = XmlUtil::selectNodes($xml->documentElement, "/" . $this->_extractNodes); $retDocument = XmlUtil::CreateXmlDocumentFromStr("<" . $this->_extractNodesRoot . "/>", false); $nodeRoot = $retDocument->documentElement; XmlUtil::AddAttribute($nodeRoot, "xpath", $this->_extractNodes); foreach ($nodes as $node) { $nodeToAdd = XmlUtil::CreateChild($nodeRoot, $node->nodeName, ""); $attributes = $node->attributes; foreach ($attributes as $value) { XmlUtil::AddAttribute($nodeToAdd, $value->nodeName, $value->nodeValue); } XmlUtil::AddNodeFromNode($nodeToAdd, $node); } $outDocument = $retDocument; } if ($this->_outputResult == OutputData::Json) { return ObjectHandler::xml2json($outDocument, $this->_extraParams["json_function"]); } else { return $outDocument->saveXML(); } } $this->_context->setXsl($xslFile->ToString()); // Set up a transform object with the XSLT file //XslTransform xslTran = new XslTransform(); $xslTran = new XSLTProcessor(); $snippetProcessor = new SnippetProcessor($xslFile); //Uri try { $uri = $snippetProcessor->getUriFromXsl($xslFile, $this->_context); } catch (XMLNukeException $ex) { throw new EngineException("Cannot load XSL file. The following error occured: " . $ex->getMessage(), 751); } //Process smipets and put teh xsl StyleShet try { $xsl = $snippetProcessor->IncludeSnippet($uri); } catch (XMLNukeException $ex) { throw new EngineException("Cannot load XSL cache file. The following error occured: " . $ex->getMessage(), 752); } $xsl = FileUtil::fixUTF8($xsl); $xslDom = new DOMDocument(); $xslDom->loadXML($xsl); $xslTran->importStyleSheet($xslDom); // Create Argument List $xslTran->setParameter("", "xml", $this->_context->getXml()); $xslTran->setParameter("", "xsl", $this->_context->getXsl()); $xslTran->setParameter("", "site", '_all'); $xslTran->setParameter("", "lang", $this->_context->Language()->getName()); $xslTran->setParameter("", "module", $this->_context->getModule()); $xslTran->setParameter("", "transformdate", date("Y-m-d H:i:s")); $xslTran->setParameter("", "urlbase", $this->_context->get("xmlnuke.URLBASE")); $xslTran->setParameter("", "engine", "PHP"); $xslTran->setParameter("", "url", $this->_context->getServerName(false, true) . $this->_context->get('REQUEST_URI')); //Transform and output $xtw = $xslTran->transformToXML($xml); $xhtml = new DOMDocument(); $xhtml->loadXML($xtw); // Reload XHTML result to process PARAM and HREFs $paramProcessor = new ParamProcessor(); $paramProcessor->AdjustToFullLink($xhtml, "A", "HREF"); $paramProcessor->AdjustToFullLink($xhtml, "FORM", "ACTION"); $paramProcessor->AdjustToFullLink($xhtml, "AREA", "HREF"); $paramProcessor->AdjustToFullLink($xhtml, "LINK", "HREF"); if ($this->_context->get("xmlnuke.ENABLEPARAMPROCESSOR")) { $paramProcessor->ProcessParameters($xhtml); } // ATENCAO: O codigo gerado pelo saveXML faz com que elementos vazios sejam // comprimidos. Exemplo: <table /> // para o HTML isso eh ruim. Logo o metodo deve ser saveHTML que deixa o tag // assim: <table></table> $arrCt = $this->_context->getSuggestedContentType(); if ($arrCt["content-type"] == "text/html") { return FileUtil::fixUTF8(strtr($xhtml->saveHTML(), array("></br>" => "/>"))); } else { return FileUtil::fixUTF8($xhtml->saveXML()); } }
/** * Process a document Upload * * @param UploadFilenameProcessor $filenameProcessor * @param bool $useProcessorForName * @param string|array $field Contain the filename properties (if Array, or $filename if string) * @param array Valid Extensions * @return Array Filename saved. */ public function processUpload($filenameProcessor, $useProcessorForName, $field = null) { if (!$filenameProcessor instanceof UploadFilenameProcessor) { throw new UploadUtilException("processUpload must receive a UploadFilenameProcessor class"); } else { if (is_null($field)) { $ret = array(); foreach ($_FILES as $file => $property) { $ret[] = $this->processUpload($filenameProcessor, $useProcessorForName, $property); } return $ret; } else { if (is_string($field)) { $ret = array(); $ret[] = $this->processUpload($filenameProcessor, $useProcessorForName, $_FILES[$field]); return $ret; } else { if (is_array($field)) { if ($useProcessorForName) { $uploadfile = $filenameProcessor->FullQualifiedNameAndPath(); } else { $uploadfile = $filenameProcessor->PathSuggested() . FileUtil::Slash() . $field["name"]; } if (move_uploaded_file($field['tmp_name'], $uploadfile)) { return $uploadfile; } else { $message = "Unknow error: " . $field['error']; switch ($field['error']) { case UPLOAD_ERR_CANT_WRITE: $message = "Can't write"; break; case UPLOAD_ERR_EXTENSION: $message = "Extension is not permitted"; break; case UPLOAD_ERR_FORM_SIZE: $message = "Max post size reached"; break; case UPLOAD_ERR_INI_SIZE: $message = "Max system size reached"; break; case UPLOAD_ERR_NO_FILE: $message = "No file was uploaded"; break; case UPLOAD_ERR_NO_TMP_DIR: $message = "No temp dir"; break; case UPLOAD_ERR_PARTIAL: $message = "The uploaded file was only partially uploaded"; break; } throw new UploadUtilException($message); } } else { throw new UploadUtilException("Something is wrong with Upload file."); } } } } }
/** * * @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(); }
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; }
/** *@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; } } }
/** *@param XSLFilenameProcessor $xslFile *@param Context $context *@return Uri *@desc */ public static function getUriFromXsl($xslFile, $context) { //System.Uri uri = snippetProcessor.ResolveUri(null, xslFile.FullQualifiedNameAndPath()); if (!$xslFile->Exists()) { if (!$xslFile->UseFileFromAnyLanguage()) { throw new EngineException("XSL document \"" . $xslFile->FullQualifiedName() . "\" not found in local site or shared locations.", 754); } } return FileUtil::getUriFromFile($xslFile->FullQualifiedNameAndPath()); }
public function __construct($language, $langstr = null) { if ($langstr == null) { $langstr = array(); } $this->_name = $language; $systemLocale = $this->getIsoName(); $options = array($systemLocale . ".UTF8", $systemLocale . ".UTF-8", $systemLocale . ".utf8", $systemLocale . ".utf-8", $systemLocale, $language, $this->_name); $this->_cultureActive = setlocale(LC_ALL, $options); // Try to load in Windows if failed before if (!$this->_cultureActive) { $row = LocaleFactory::getInfoLocaleDB('shortname', $this->getName()); $langstr = $row->getFieldArray("langstr"); $iLang = 0; while (!$this->_cultureActive && $iLang < count($langstr)) { $this->_cultureActive = setlocale(LC_ALL, $langstr[$iLang]); $iLang++; } } if (!$this->_cultureActive) { $firstPart = substr($language, 0, 2); if (FileUtil::isWindowsOS()) { $complement = ""; } else { $complement = "Only the languages available in 'locale -a' can be setted. On debian try execute 'apt-get install language-pack-{$firstPart}'."; } echo "<br/>\n<b>Warning: </b> The culture language '{$language}' was not found. {$complement}\n<br/>"; // I cant call the context here because it's call CultureInfo but the context is not complete yet. //$context = Context::getInstance(); //$context->WriteWarningMessage (""); } $this->_localeConv = localeConv(); #if (stripos(PHP_OS, 'win') !== false) #{ # $this->_localeConv["currency_symbol"] = utf8_encode($this->_localeConv["currency_symbol"]); #} #Debug::PrintValue($this->_localeConv, $langstr, $this->getRegionalMonthNames()); }
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("&", "&", 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; }
/** *@param *@return string *@desc Implementing */ public function SharedPath() { return FileUtil::Slash($this->_context->SharedRootPath(), "xsl"); }
/** *@param *@return string *@desc Implementing */ public function PrivatePath() { return FileUtil::Slash($this->_context->XmlPath(false), $this->getLanguageId()); }
/** *@return string *@desc Path to private directory */ public function PrivatePath() { return FileUtil::Slash($this->_context->CurrentSitePath(), "upload"); }
/** *@param *@return string *@desc */ public function SharedPath() { return $this->_context->SharedRootPath() . "setup" . FileUtil::Slash(); }
/** *@param string $xml *@param string $xsl *@param string $languageId *@return string *@desc */ public function FullName($xml, $xsl, $languageId) { return str_replace(FileUtil::Slash(), "#", $xsl . "." . $languageId . "." . $xml); }
public function saveDocument($documentName, $xml, $btree) { $btree = BTreeUtil::navigateNodes($xml->documentElement, $documentName . "#/", $btree); $documentName = self::getFullFileName($documentName); FileUtil::ForceDirectories(self::getPathFromFile($documentName)); $xml->normalize(); XmlUtil::SaveXmlDocument($xml, $documentName); return $btree; }
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(); }
/** *@return string *@desc Path to private directory */ public function PrivatePath() { // SystemRootPath is necessary to effort XMLNuke DATA directory may be located everywhere. return "lib" . FileUtil::Slash() . $this->_subpath; }
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); }