/** * * @param Context $context * @param string $appName * @param bool $saveToUser */ public function __construct($appName, $saveToUser = false) { $this->_context = Context::getInstance(); $this->_saveToUser = $saveToUser; $this->_appName = $appName; if ($saveToUser) { $users = $this->_context->getUsersDatabase(); $this->_user = $users->getUserName($saveToUser); if ($this->_user == null) { throw new NotAuthenticatedException("You have to be authenticated to access this feature"); } } $oauthFile = new AnydatasetFilenameProcessor("_oauthclient10"); $oauthAny = new AnyDataset($oauthFile->FullQualifiedNameAndPath()); $itf = new IteratorFilter(); $itf->addRelation("appname", Relation::EQUAL, $appName); $it = $oauthAny->getIterator($itf); if ($it->hasNext()) { $sr = $it->moveNext(); $this->_consumer_key = $sr->getField("consumer_key"); $this->_consumer_secret = $sr->getField("consumer_secret"); $this->_className = $sr->getField("appclass"); $this->_extraArgs = $sr->getFieldArray("extra_arg"); } else { throw new InvalidArgumentException("Cant find OAuth AppName " . $appName); } }
/** * * @param string $configName */ public function __construct($configName) { $file = new AnydatasetFilenameProcessor("_aws"); $anydata = new AnyDataset($file->FullQualifiedNameAndPath()); $itf = new IteratorFilter(); $itf->addRelation("config", Relation::EQUAL, $configName); $it = $anydata->getIterator($itf); if ($it->hasNext()) { $sr = $it->moveNext(); $this->_accessKey = $sr->getField("access-key"); $this->_secretKey = $sr->getField("secret-key"); $this->_extras = $sr->toArray(); $this->_isValid = true; } }
/** * Enter description here... * * @param XmlBlockCollection $block */ protected function CreateSetup($block) { if ($this->_action == ModuleAction::CreateConfirm) { $p = new XmlParagraphCollection(); if ($this->_context->get("type") != "-anydata-") { try { $tblpoll = $this->_context->get("tbl_poll"); $tblanswer = $this->_context->get("tbl_answer"); $tbllastip = $this->_context->get("tbl_lastip"); $suffix = $this->_context->get("tablesuffix"); $dbdata = new DBDataset($this->_context->get("type")); $results = array(); $results[] = $this->CreateTable($dbdata, "create table {$tblpoll}", "create table {$tblpoll} (name varchar(15), lang char(5), question varchar(150), multiple char(1), showresults char(1), active char(1)) {$suffix}"); $results[] = $this->CreateTable($dbdata, "create table {$tblanswer}", "create table {$tblanswer} (name varchar(15), lang char(5), code int, short varchar(10), answer varchar(50), votes int) {$suffix}"); //$results[] = $this->CreateTable($dbdata, "create table $tbllastip", "create table $tbllastip (name varchar(15), ip varchar(15)) $suffix"); $results[] = $this->CreateTable($dbdata, "add primary key poll", "alter table {$tblpoll} add constraint pk_poll primary key (name, lang);"); $results[] = $this->CreateTable($dbdata, "add primary key answer", "alter table {$tblanswer} add constraint pk_answer primary key (name, lang, code)"); //$results[] = $this->CreateTable($dbdata, "add primary key lastip", "alter table $tbllastip add constraint pk_lastip primary key (name, ip)"); $results[] = $this->CreateTable($dbdata, "add check poll 1", "alter table {$tblpoll} add constraint ck_poll_multiple check (multiple in ('Y', 'N'))"); $results[] = $this->CreateTable($dbdata, "add check poll 2", "alter table {$tblpoll} add constraint ck_poll_showresults check (showresults in ('Y', 'N'))"); $results[] = $this->CreateTable($dbdata, "add check poll 3", "alter table {$tblpoll} add constraint ck_poll_active check (active in ('Y', 'N'))"); $results[] = $this->CreateTable($dbdata, "add foreign key answer", "alter table {$tblanswer} add constraint pk_answer_poll foreign key (name) references {$tblpoll}(name)"); //$results[] = $this->CreateTable($dbdata, "add foreign key lastip", "alter table $tbllastip add constraint pk_lastip_poll foreign key (name) references $tblpoll(name)"); $block->addXmlnukeObject(new XmlEasyList(EasyListType::UNORDEREDLIST, "", $this->myWords->Value("RESULTSQL"), $results)); $poll = new AnydatasetFilenameProcessor("_poll"); $anypoll = new AnyDataset($poll); $anypoll->appendRow(); $anypoll->addField("dbname", $this->_context->get("type")); $anypoll->addField("tbl_poll", $tblpoll); $anypoll->addField("tbl_answer", $tblanswer); $anypoll->addField("tbl_lastip", $tbllastip); $anypoll->Save(); } catch (Exception $ex) { $p->addXmlnukeObject(new XmlnukeText($this->myWords->Value("GOTERROR", $ex->getMessage()))); } } else { $poll = new AnydatasetFilenameProcessor("_poll"); $anypoll = new AnyDataset($poll); $anypoll->appendRow(); $anypoll->addField("dbname", "-anydata-"); $anypoll->Save(); } $p->addXmlnukeObject(new XmlnukeBreakLine()); $p->addXmlnukeObject(new XmlnukeText($this->myWords->Value("CONFIGCREATED"), true)); $block->addXmlnukeObject($p); } else { $p = new XmlParagraphCollection(); $p->addXmlnukeObject(new XmlnukeText($this->myWords->Value("FIRSTTIMEMESSAGE"))); $block->addXmlnukeObject($p); $form = new XmlFormCollection($this->_context, $this->_moduleUrl, $this->myWords->Value("CREATESETUP")); $form->addXmlnukeObject(new XmlInputHidden("action", ModuleAction::CreateConfirm)); $db = array("-anydata-" => $this->myWords->Value("NOTUSEDB")); $anydatafile = new AnydatasetFilenameProcessor("_db"); $anydata = new AnyDataset($anydatafile->FullQualifiedNameAndPath()); $it = $anydata->getIterator(); while ($it->hasNext()) { $sr = $it->moveNext(); $db[$sr->getField("dbname")] = $sr->getField("dbname"); } $form->addXmlnukeObject(new XmlEasyList(EasyListType::SELECTLIST, "type", $this->myWords->Value("FORMCONN"), $db)); $inputGroup = new XmlInputGroup($this->_context, "tabledetail", true); $inputGroup->setVisible(false); $text = new XmlInputTextBox($this->myWords->Value("TABLENAME_POLL"), "tbl_poll", "xmlnuke_poll", 20); $text->setRequired(true); $inputGroup->addXmlnukeObject($text); $text = new XmlInputTextBox($this->myWords->Value("TABLENAME_ANSWER"), "tbl_answer", "xmlnuke_answer", 20); $text->setRequired(true); $inputGroup->addXmlnukeObject($text); $text = new XmlInputTextBox($this->myWords->Value("TABLENAME_LASTIP"), "tbl_lastip", "xmlnuke_lastip", 20); $text->setRequired(true); $inputGroup->addXmlnukeObject($text); $text = new XmlInputTextBox($this->myWords->Value("TABLE_SUFFIX"), "tablesuffix", "TYPE INNODB", 30); $text->setRequired(true); $inputGroup->addXmlnukeObject($text); $form->addXmlnukeObject($inputGroup); $buttons = new XmlInputButtons(); $buttons->addSubmit($this->myWords->Value("CREATESETUPBTN")); $form->addXmlnukeObject($buttons); $block->addXmlnukeObject($form); $javascript = "\n\t\t\t\t// ByJG \n\t\t\t\tfn_addEvent('type', 'change', enableFields);\n\t\t\t\tfunction enableFields(e) {\n\t\t \t\tobj = document.getElementById('type');\n\t\t \t\tshowHide_tabledetail(obj.selectedIndex != 0);\n\t\t\t\t}\n\t\t\t\t"; $this->defaultXmlnukeDocument->addJavaScriptSource($javascript, true); } }
/** * 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); } }
/** * Create Page Method * * @return PageXml */ public function CreatePage() { parent::CreatePage(); $this->_myWords = $this->WordCollection(); $this->defaultXmlnukeDocument->addMenuItem("module:Xmlnuke.Admin.FileManagement", $this->_myWords->Value("FILEMANAGEMENT"), ""); $this->_block = new XmlBlockCollection($this->_myWords->Value("FILEMANAGEMENT"), BlockPosition::Center); $this->setTitlePage($this->_myWords->Value("TITLE")); $this->setHelp($this->_myWords->Value("DESCRIPTION")); $this->defaultXmlnukeDocument->addXmlnukeObject($this->_block); //get the current folder $root = $this->_context->get("folder"); $browser = new XmlFileBrowser($root, $this->_action, $this->_context); //SET FILEBROWSER ACESS LEVEL $processor = new AnydatasetFilenameProcessor("filemanagement"); $processor->setFilenameLocation(ForceFilenameLocation::UseWhereExists); $anyDataSet = new AnyDataset($processor->FullQualifiedNameAndPath()); $ignoreAdmin = false; $it = $anyDataSet->getIterator(); while ($it->hasNext()) { $row = $it->moveNext(); switch ($row->getField("type")) { case "INITIAL_DIR": $initial_dir = $row->getFieldArray("value"); $browser->setSubFoldersPermitted($initial_dir); break; case "VALID_FILE_NEW": $file_new_list = $row->getFieldArray("value"); $browser->setFileNewList($file_new_list); break; case "VALID_FILE_VIEW": $file_view_list = $row->getFieldArray("value"); $browser->setFileViewList($file_view_list); break; case "VALID_FILE_EDIT": $file_edit_list = $row->getFieldArray("value"); $browser->setFileEditList($file_edit_list); break; case "VALID_FILE_DELETE": $file_delete_list = $row->getFieldArray("value"); $browser->setFileDeleteList($file_delete_list); break; case "VALID_FILE_UPLOAD": $file_upload_list = $row->getFieldArray("value"); $browser->setFileUploadList($file_upload_list); break; case "VALID_FILE_MAX_UPLOAD": $file_max_upload = $row->getField("value"); $browser->setFileMaxUpload($file_max_upload); break; case "PERMISSION": $browser->setFileNew($row->getField("file_new")); $browser->setFileView($row->getField("file_view")); $browser->setFileEdit($row->getField("file_edit")); $browser->setFileDelete($row->getField("file_delete")); $browser->setFileUpload($row->getField("file_upload")); $browser->setFolderNew($row->getField("folder_new")); $browser->setFolderView($row->getField("folder_view")); $browser->setFolderEdit($row->getField("folder_edit")); $browser->setFolderDelete($row->getField("folder_delete")); $ignoreAdmin = $row->getField("ignore_admin") == "true"; break; } } if ($this->isUserAdmin() && !$ignoreAdmin) { $browser->setUserType(FileBrownserUserType::ADMIN); } $this->_block->addXmlnukeObject($browser); return $this->defaultXmlnukeDocument->generatePage(); }
/** * Get AnydataSet Poll information * */ protected function getAnyData() { $filepoll = new AnydatasetFilenameProcessor("poll_list"); $this->_anyPoll = new AnyDataset($filepoll->FullQualifiedNameAndPath()); $fileanswer = new AnydatasetFilenameProcessor("poll_" . $this->_poll . "_" . $this->_lang); $this->_anyAnswer = new AnyDataset($fileanswer->FullQualifiedNameAndPath()); }
public static function existsApp($appName) { $oauthFile = new AnydatasetFilenameProcessor("_oauthclient20"); $oauthAny = new AnyDataset($oauthFile->FullQualifiedNameAndPath()); $itf = new IteratorFilter(); $itf->addRelation("appname", Relation::EQUAL, $appName); $it = $oauthAny->getIterator($itf); return $it->hasNext(); }
/** * Gets and array with the best content-type for the page. * It checks the file "contenttype.anydata.xsl" if the property "xmlnuke.CHECKCONTENTTYPE" is true * * The returned array is: * array( * "xsl" => "", * "content-type" => "", * "content-disposition" => "", * "extension" => "" * ) * * @return array */ public function getSuggestedContentType() { if (count($this->_contentType) == 0) { $this->_contentType["xsl"] = $this->getXsl(); $this->_contentType["content-type"] = "text/html"; $this->_contentType["content-disposition"] = ""; $this->_contentType["extension"] = ""; if ($this->get("xmlnuke.CHECKCONTENTTYPE")) { $filename = new AnydatasetFilenameProcessor("contenttype"); $anydataset = new AnyDataset($filename->FullQualifiedNameAndPath()); $itf = new IteratorFilter(); $itf->addRelation("xsl", Relation::EQUAL, $this->getXsl()); $it = $anydataset->getIterator($itf); if ($it->hasNext()) { $sr = $it->moveNext(); $this->_contentType = $sr->getOriginalRawFormat(); } else { $filename = new AnydatasetSetupFilenameProcessor("contenttype"); $anydataset = new AnyDataset($filename->FullQualifiedNameAndPath()); $itf = new IteratorFilter(); $itf->addRelation("xsl", Relation::EQUAL, $this->getXsl()); $it = $anydataset->getIterator($itf); if ($it->hasNext()) { $sr = $it->moveNext(); $this->_contentType = $sr->getOriginalRawFormat(); } } } } return $this->_contentType; }
/** * Enter description here... * */ protected function getStringConnectionsArray() { $processor = new AnydatasetFilenameProcessor("_db"); $processor->UseFileFromAnyLanguage(); $anydata = new AnyDataset($processor->FullQualifiedNameAndPath()); $it = $anydata->getIterator(); $ret = array(); $ret[''] = '-- Default UsersAnydataSet --'; while ($it->hasNext()) { $sr = $it->moveNext(); $ret[$sr->getField("dbname")] = $sr->getField("dbname"); } return $ret; }
/** * */ public function __construct() { parent::__construct("adminmodules"); $this->_filenameLocation = ForceFilenameLocation::SharedPath; }
protected function Opcao9() { $block = new XmlBlockCollection("Exemplo 9: XmlChart", BlockPosition::Center); //XmlnukeBreakLine br = new XmlnukeBreakLine(); $para1 = new XmlParagraphCollection(); $colNodeStr = array(); $colNodeStr[] = "category"; $colNodeStr[] = "title"; $colNodeStr[] = "titlelang"; $colNodeStr[] = "year"; $colNodeStr[] = "price"; $colNodeStr[] = "buyprice"; $colNodeStr[] = "author"; $processor = new AnydatasetFilenameProcessor("sample"); $dataset = new TextFileDataset($processor->PathSuggested() . "sample.csv", $colNodeStr); //$para1->addXmlnukeObject(new XmlnukeText("")); $editlist = new XmlEditList($this->_context, "Text Flat", $this->_url . "?op=9"); $editlist->setReadOnly(true); $editlist->setDataSource($dataset->getIterator()); $para1->addXmlnukeObject($editlist); $chart = new XmlChart($this->_context, "Book Store", $dataset->getIterator(), ChartOutput::Flash, ChartSeriesFormat::Column); $chart->setLegend("category", "#000000", "#C0C0C0"); $chart->addSeries("price", "Sell Price", "#000000"); $chart->addSeries("buyprice", "Buy Price", "#000000"); $para1->addXmlnukeObject($chart); $code = new XmlnukeCode("Code Sample"); $code->AddTextLine("\$chart = new XmlChart("); $code->AddTextLine("\t\t\$this->_context, // Xmlnuke Context"); $code->AddTextLine("\t\t\"Book Store\", // Graph Title"); $code->AddTextLine("\t\t\$dataset->getIterator(), // IteratorInterface Object"); $code->AddTextLine("\t\tChartOutput::Flash, // Graph output format "); $code->AddTextLine("\t\tChartSeriesFormat::Column // Default column type"); $code->AddTextLine(");"); $code->AddTextLine("\$chart->setLegend(\"category\", \"#000000\", \"#C0C0C0\");"); $code->AddTextLine("\$chart->addSeries(\"price\", \"Sell Price\", \"#000000\");"); $para1->addXmlnukeObject($code); $block->addXmlnukeObject($para1); $this->_document->addXmlnukeObject($block); }