Beispiel #1
0
 /**
  *
  * @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);
     }
 }
Beispiel #2
0
 /**
  *
  * @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;
     }
 }
Beispiel #3
0
 /**
  * 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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #5
0
 /**
  * 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();
 }
Beispiel #6
0
 /**
  * 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());
 }
Beispiel #7
0
 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();
 }
Beispiel #8
0
 /**
  * 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;
 }
Beispiel #9
0
 /**
  * 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;
 }
Beispiel #10
0
 /**
  * Edit DataBase
  *
  */
 protected function actionEditDB()
 {
     $blockCenter = new XmlBlockCollection($this->_myWords->Value("DATABASE"), BlockPosition::Center);
     $breakline = new XmlnukeBreakLine();
     $paragraph = new XmlParagraphCollection();
     $paragraph->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("DATABASETEXT")));
     $paragraph->addXmlnukeObject($breakline);
     $secop = $this->_context->get("secop");
     // Menu
     $form = new XmlFormCollection($this->_context, $this->_url . "?op=5", "Menu");
     $optionlist = array();
     $optionlist[""] = "-- Selecione --";
     $optionlist["setup"] = "Configurar a Conexão";
     $optionlist["test"] = "Testar a conexão";
     $optionlist["create"] = "Create Sample Table";
     $optionlist["edit"] = "Edit Sample Table";
     $list = new XmlEasyList(EasyListType::SELECTLIST, "secop", "Selecione a Ação", $optionlist, $secop);
     $form->addXmlnukeObject($list);
     $btnmenu = new XmlInputButtons();
     $btnmenu->addSubmit("Selecionar");
     $form->addXmlnukeObject($btnmenu);
     $blockCenter->addXmlnukeObject($form);
     // Opções:
     switch ($secop) {
         case "setup":
             $formsetup = new XmlFormCollection($this->_context, $this->_url . "?op=5", "Editar Conexão");
             $formsetup->addXmlnukeObject(new XmlInputHidden("secop", "setupconf"));
             $text = new XmlInputTextBox("Connection String", "connection", "adodriver://*****:*****@server/datasource");
             $text->setRequired(true);
             $formsetup->addXmlnukeObject($text);
             $btn = new XmlInputButtons();
             $btn->addSubmit("Salvar");
             $formsetup->addXmlnukeObject($btn);
             $blockCenter->addXmlnukeObject($formsetup);
             break;
         case "setupconf":
             $filename = new AnydatasetFilenameProcessor("_db");
             $anydata = new AnyDataset($filename->FullQualifiedNameAndPath());
             $itf = new IteratorFilter();
             $itf->addRelation("dbname", Relation::EQUAL, "sampledb");
             $it = $anydata->getIterator($itf);
             if ($it->hasNext()) {
                 $sr = $it->moveNext();
                 $sr->setField("dbtype", "dsn");
                 $sr->setField("dbconnectionstring", $this->_context->get("connection"));
             } else {
                 $anydata->appendRow();
                 $anydata->addField("dbname", "sampledb");
                 $anydata->addField("dbtype", "dsn");
                 $anydata->addField("dbconnectionstring", $this->_context->get("connection"));
             }
             $anydata->Save();
             $paragraph->addXmlnukeObject(new XmlnukeText("Updated!", true));
             break;
         case "test":
             $db = new DBDataset("sampledb");
             $db->TestConnection();
             $paragraph->addXmlnukeObject(new XmlnukeText("I suppose it is fine the connection string!", true));
             break;
         case "create":
             $db = new DBDataset("sampledb");
             $sql = "create table sample (fieldkey integer, fieldname varchar(20))";
             $db->execSQL($sql);
             $db->TestConnection();
             $paragraph->addXmlnukeObject(new XmlnukeText("Table Created!", true));
             break;
         case "edit":
             // Cria um acesso a $crud
             $pageFields = new CrudFieldCollection();
             $fieldPage = new CrudField();
             $fieldPage->fieldName = "fieldkey";
             $fieldPage->key = true;
             $fieldPage->dataType = INPUTTYPE::NUMBER;
             $fieldPage->fieldCaption = "Código";
             $fieldPage->fieldXmlInput = XmlInputObjectType::TEXTBOX;
             $fieldPage->visibleInList = true;
             $fieldPage->editable = true;
             $fieldPage->required = true;
             $fieldPage->rangeMin = "100";
             $fieldPage->rangeMax = "999";
             $pageFields->addCrudField($fieldPage);
             $fieldPage = new CrudField();
             $fieldPage->fieldName = "fieldname";
             $fieldPage->key = false;
             $fieldPage->dataType = INPUTTYPE::TEXT;
             $fieldPage->fieldCaption = "Name";
             $fieldPage->fieldXmlInput = XmlInputObjectType::TEXTBOX;
             $fieldPage->visibleInList = true;
             $fieldPage->editable = true;
             $fieldPage->required = true;
             $fieldPage->maxLength = 20;
             $pageFields->addCrudField($fieldPage);
             $crud = new XmlnukeCrudDB($this->_context, $pageFields, "Edição teste usando Banco de Dados", $this->_url . "?op=5", null, "sample", "sampledb");
             $crud->setPageSize(3, 0);
             $crud->addParameter("secop", "edit");
             $paragraph->addXmlnukeObject($crud);
             break;
     }
     $blockCenter->addXmlnukeObject($paragraph);
     $this->_document->addXmlnukeObject($blockCenter);
 }