Пример #1
0
 /**
  * Add EditList to site
  *
  * @param XmlBlockCollection $this->_mainBlock
  * @param string $site
  * @param AnyDataset $dataset
  */
 protected function AddEditListToSite($block, $site, $dataset)
 {
     $para = new XmlParagraphCollection();
     $this->_mainBlock->addXmlnukeObject($para);
     $this->url->addParam("editsite", $site);
     $editList = new XmlEditList($this->_context, $this->myWords->Value("EDITLIST_TITLE", $site), $this->url->getUrl(), true, false, true, true);
     $editList->setDataSource($dataset->getIterator());
     $listField = new EditListField();
     $listField->editlistName = "";
     $listField->fieldData = "role";
     $editList->addEditListField($listField);
     $listField = new EditListField();
     $listField->editlistName = $this->myWords->Value("EDITLIST_ROLES");
     $listField->fieldData = $this->user->getRolesTable()->Role;
     $editList->addEditListField($listField);
     $listField = new EditListField();
     $listField->editlistName = $this->myWords->Value("EDITLIST_SITES");
     $listField->fieldData = $this->user->getRolesTable()->Site;
     $editList->addEditListField($listField);
     $para->addXmlnukeObject($editList);
 }
Пример #2
0
 public function CreatePage()
 {
     parent::CreatePage();
     // Doesnt necessary get PX, because PX is protected!
     $users = $this->getUsersDatabase();
     //anydataset.SingleRow user;
     $action = strtolower($this->_action);
     $uid = $this->_context->get("valueid");
     $this->myWords = $this->WordCollection();
     $this->setTitlePage($this->myWords->Value("TITLE"));
     $this->setHelp($this->myWords->Value("DESCRIPTION"));
     $this->addMenuOption($this->myWords->Value("NEWUSER"), $this->url, null);
     $this->addMenuOption($this->myWords->Value("ADDROLE"), "module:Xmlnuke.Admin.manageusersgroups", null);
     // --------------------------------------
     // CHECK ACTION
     // --------------------------------------
     $exec = false;
     if ($action != "" && $action != "move") {
         $message = new XmlParagraphCollection();
         if ($action == "newuser") {
             if (!$users->addUser($this->_context->get("name"), $this->_context->get("login"), $this->_context->get("email"), $this->_context->get("password"))) {
                 $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("USEREXIST"), true));
             } else {
                 if ($this->isUserAdmin()) {
                     $user = $users->getUserName($this->_context->get("login"));
                     $user->setField($users->getUserTable()->admin, $this->_context->get("admin"));
                     $users->Save();
                 }
                 $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("CREATED"), true));
             }
             $exec = true;
         }
         if ($action == "update") {
             $user = $users->getById($uid);
             $user->setField($users->getUserTable()->name, $this->_context->get("name"));
             $user->setField($users->getUserTable()->email, $this->_context->get("email"));
             if ($this->isUserAdmin()) {
                 $user->setField($users->getUserTable()->admin, $this->_context->get("admin"));
             }
             $users->Save();
             $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("UPDATE"), true));
             $exec = true;
         }
         if ($action == "changepassword") {
             $user = $users->getById($uid);
             $user->setField($users->getUserTable()->password, $users->getSHAPassword($this->_context->get("password")));
             $users->Save();
             $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("CHANGEPASSWORD"), true));
             $exec = true;
         }
         if ($action == "delete") {
             if ($users->removeUserName($uid)) {
                 $users->Save();
                 $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("DELETE"), true));
                 $uid = "";
             } else {
                 $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("ERRO"), true));
             }
             $exec = true;
         }
         if ($action == "addrole") {
             $users->addPropertyValueToUser($uid, $this->_context->get("role"), UserProperty::Role);
             $users->Save();
             $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("ROLEADDED"), true));
             $exec = true;
         }
         if ($action == "removerole") {
             $users->removePropertyValueFromUser($uid, $this->_context->get("role"), UserProperty::Role);
             $users->Save();
             $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("ROLEREMOVED"), true));
             $exec = true;
         }
         if ($action == "addcustomvalue") {
             $users->addPropertyValueToUser($uid, $this->_context->get("customvalue"), $this->_context->get("customfield"));
             $users->Save();
             $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("CUSTOMFIELDUPDATED"), true));
             $exec = true;
         }
         if ($action == "removecustomvalue") {
             $users->removePropertyValueFromUser($uid, $this->_context->get("customvalue"), $this->_context->get("customfield"));
             $users->Save();
             $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("CUSTOMFIELDREMOVED"), true));
             $exec = true;
         }
         if ($exec) {
             $block = new XmlBlockCollection($this->myWords->Value("WORKINGAREA"), BlockPosition::Center);
             $block->addXmlnukeObject($message);
             $this->defaultXmlnukeDocument->addXmlnukeObject($block);
         }
     }
     // --------------------------------------
     // LIST USERS
     // --------------------------------------
     $block = new XmlBlockCollection($this->myWords->Value("USERS"), BlockPosition::Center);
     $itf = new IteratorFilter();
     if (!$this->isUserAdmin()) {
         $itf->addRelation("admin", Relation::NOT_EQUAL, "yes");
     }
     if ($this->_context->get("pesquser") != "") {
         $itf->startGroup();
         $itf->addRelationOr($users->getUserTable()->username, Relation::CONTAINS, $this->_context->get("pesquser"));
         $itf->addRelationOr($users->getUserTable()->name, Relation::CONTAINS, $this->_context->get("pesquser"));
         $itf->addRelationOr($users->getUserTable()->email, Relation::CONTAINS, $this->_context->get("pesquser"));
         $itf->endGroup();
     }
     $it = $users->getIterator($itf);
     $formpesq = new XmlFormCollection($this->_context, $this->url, $this->myWords->Value("TITLEPESQUSER"));
     $formpesq->setFormName("form-label-top");
     $textbox = new XmlInputTextBox($this->myWords->Value("PESQUSER"), "pesquser", $this->_context->get("pesquser"));
     $textbox->setDataType(INPUTTYPE::TEXT);
     $formpesq->addXmlnukeObject($textbox);
     $textbox->setRequired(true);
     $boxButton = new XmlInputButtons();
     $boxButton->addSubmit($this->myWords->Value("GOSEARCH"), "");
     $formpesq->addXmlnukeObject($boxButton);
     $block->addXmlnukeObject($formpesq);
     $editlist = new XmlEditList($this->_context, $this->myWords->Value("USERS"), $this->url, true, false, true, true);
     $editlist->setDataSource($it);
     $editlist->setPageSize(20, 0);
     $editlist->setEnablePage(true);
     $field = new EditListField();
     $field->fieldData = $users->getUserTable()->id;
     $editlist->addEditListField($field);
     $field = new EditListField();
     $field->fieldData = $users->getUserTable()->username;
     $field->editlistName = $this->myWords->Value("TXT_LOGIN");
     $editlist->addEditListField($field);
     $field = new EditListField();
     $field->fieldData = $users->getUserTable()->name;
     $field->editlistName = $this->myWords->Value("TXT_NAME");
     $editlist->addEditListField($field);
     $field = new EditListField();
     $field->fieldData = $users->getUserTable()->email;
     $field->editlistName = $this->myWords->Value("TXT_EMAIL");
     $editlist->addEditListField($field);
     $field = new EditListField();
     $field->fieldData = $users->getUserTable()->admin;
     $field->editlistName = $this->myWords->Value("TITADM");
     $editlist->addEditListField($field);
     $block->addXmlnukeObject($editlist);
     $this->defaultXmlnukeDocument->addXmlnukeObject($block);
     // --------------------------------------
     // EDIT AREA
     // --------------------------------------
     if ($action == "new" || $action == "newuser" || $action == "" || $action == "move" || $action == "delete") {
         $this->NewUser();
     } else {
         $this->EditUser($users, $uid);
     }
     return $this->defaultXmlnukeDocument->generatePage();
 }
Пример #3
0
 public function CreatePage()
 {
     parent::CreatePage();
     // Doesnt necessary get PX, because PX is protected!
     $this->myWords = $this->WordCollection();
     $this->setTitlePage($this->myWords->Value("TITLE"));
     $this->setHelp($this->myWords->Value("DESCRIPTION"));
     $this->addMenuOption($this->myWords->Value("NEWLANGUAGEFILE"), "module:Xmlnuke.Admin.EditLanguage?action=new");
     $this->addMenuOption($this->myWords->Value("VIEWSHAREDFILES"), "module:Xmlnuke.Admin.EditLanguage?op=1");
     $this->addMenuOption($this->myWords->Value("VIEWPRIVATEFILES"), "module:Xmlnuke.Admin.EditLanguage");
     $block = new XmlBlockCollection($this->myWords->Value("WORKINGAREA"), BlockPosition::Center);
     $this->defaultXmlnukeDocument->addXmlnukeObject($block);
     $op = $this->_context->get("op");
     $ed = $this->_context->get("ed");
     $langDir = new AnydatasetLangFilenameProcessor("");
     if ($op == "") {
         $filelist = FileUtil::RetrieveFilesFromFolder($langDir->PrivatePath(), $langDir->Extension());
     } else {
         $filelist = FileUtil::RetrieveFilesFromFolder($langDir->SharedPath(), $langDir->Extension());
     }
     $it = $this->getIteratorFromList($filelist, $langDir);
     if ($this->_action == "") {
         $editlist = new XmlEditList($this->_context, $this->myWords->Value("FILELIST{$op}"), "module:Xmlnuke.Admin.EditLanguage", true, false, true, false);
         $field = new EditListField();
         $field->editlistName = "#";
         $field->fieldData = "key";
         $editlist->addEditListField($field);
         $field = new EditListField();
         $field->editlistName = "Language Filename";
         $field->fieldData = "singlename";
         $editlist->addEditListField($field);
         $editlist->setDataSource($it);
         $editlist->addParameter("op", $op);
         $editlist->setEnablePage(true);
         $editlist->setPageSize(20, 0);
         $block->addXmlnukeObject($editlist);
     } elseif ($this->_action == ModuleAction::Edit || $ed == 1) {
         if ($ed == 1) {
             $file = $this->_context->get("file");
         } else {
             $file = $this->_context->get("valueid");
         }
         $langDir = new AnydatasetLangFilenameProcessor($file);
         $langDir->setFilenameLocation($op == "" ? ForceFilenameLocation::PrivatePath : ForceFilenameLocation::SharedPath);
         $anydata = new AnyDataset($langDir->FullQualifiedNameAndPath());
         $it = $anydata->getIterator();
         $sr = $it->moveNext();
         $arFields = $sr->getFieldNames();
         $i = 0;
         $CrudFieldCollection = new CrudFieldCollection();
         foreach ($arFields as $value) {
             $process = CrudField::FactoryMinimal($value, $value, 40, $i < 4, true);
             $process->key = $i == 0;
             if ($value == "LANGUAGE") {
                 $process->beforeInsertFormatter = $this;
             }
             $CrudFieldCollection->addCrudField($process);
             $i++;
         }
         $crud = new XmlnukeCrudAnydata($this->_context, $CrudFieldCollection, $this->myWords->Value("EDITLANGUAGE", $file), "module:Xmlnuke.Admin.EditLanguage", null, $langDir);
         $crud->addParameter("op", $op);
         $crud->addParameter("ed", 1);
         $crud->addParameter("file", $file);
         $block->addXmlnukeObject($crud);
     } elseif ($this->_action == ModuleAction::Create) {
         $form = new XmlFormCollection($this->_context, "module:Xmlnuke.Admin.EditLanguage", $this->myWords->Value("NEWLANGUAGEFILE"));
         $form->addXmlnukeObject(new XmlInputHidden("action", ModuleAction::CreateConfirm));
         $form->addXmlnukeObject(new XmlInputHidden("op", $op));
         $form->addXmlnukeObject(new XmlInputTextBox($this->myWords->Value("NEWFILE"), "newfile", "", 30));
         $form->addXmlnukeObject(new XmlInputMemo($this->myWords->Value("FIELDS"), "fields", "TITLE\r\nABSTRACT"));
         $form->addXmlnukeObject(XmlInputButtons::CreateSubmitButton($this->myWords->Value("TXT_SUBMIT")));
         $block->addXmlnukeObject($form);
     } elseif ($this->_action == ModuleAction::CreateConfirm) {
         $file = $this->_context->get("newfile");
         $langDir = new AnydatasetLangFilenameProcessor($file);
         $langDir->setFilenameLocation($op == "" ? ForceFilenameLocation::PrivatePath : ForceFilenameLocation::SharedPath);
         $anydata = new AnyDataset($langDir->FullQualifiedNameAndPath());
         $fields = explode("\r\n", $this->_context->get("fields"));
         $langs = $this->_context->LanguagesAvailable();
         foreach ($langs as $lang => $dummy) {
             $anydata->appendRow();
             $anydata->addField("lang", $lang);
             foreach ($fields as $field) {
                 $anydata->addField($field, "");
             }
         }
         $anydata->Save($langDir);
         $this->_context->redirectUrl("module:Xmlnuke.Admin.EditLanguage?ed=1&file={$file}");
     }
     $langfile = $this->_context->get("langfile");
     $contents = $this->_context->get("contents");
     $contents = stripslashes($contents);
     return $this->defaultXmlnukeDocument;
 }
Пример #4
0
 /**
  *@desc
  *@param
  *@return IXmlnukeDocumentObject
  */
 protected function listAllRecords()
 {
     //		XmlEditList $editList
     $editList = new XmlEditList($this->_context, $this->_header, $this->_module, false, false, false, false);
     $editList->setDataSource($this->getAllRecords());
     $editList->setPageSize($this->_qtdRows, $this->_curPage);
     $editList->setEnablePage(true);
     //$editList->addParameter("filter", $this->_filter);
     //$editList->addParameter("sort", $this->_sort);
     foreach ($this->_parameter as $key => $value) {
         $editList->addParameter($key, $value);
     }
     if ($this->_new) {
         $cb = new CustomButtons();
         $cb->action = self::ACTION_NEW;
         $cb->alternateText = $this->_lang->Value("TXT_NEW");
         $cb->icon = "common/editlist/ic_novo.gif";
         $cb->enabled = true;
         $cb->multiple = MultipleSelectType::NONE;
         $editList->setCustomButton($cb);
     }
     if ($this->_view) {
         $cb = new CustomButtons();
         $cb->action = self::ACTION_VIEW;
         $cb->alternateText = $this->_lang->Value("TXT_VIEW");
         $cb->icon = "common/editlist/ic_detalhes.gif";
         $cb->enabled = true;
         $cb->multiple = MultipleSelectType::ONLYONE;
         $editList->setCustomButton($cb);
     }
     if ($this->_edit) {
         $cb = new CustomButtons();
         $cb->action = self::ACTION_EDIT;
         $cb->alternateText = $this->_lang->Value("TXT_EDIT");
         $cb->icon = "common/editlist/ic_editar.gif";
         $cb->enabled = true;
         $cb->multiple = MultipleSelectType::ONLYONE;
         $editList->setCustomButton($cb);
     }
     if ($this->_delete) {
         $cb = new CustomButtons();
         $cb->action = self::ACTION_DELETE;
         $cb->alternateText = $this->_lang->Value("TXT_DELETE");
         $cb->icon = "common/editlist/ic_excluir.gif";
         $cb->enabled = true;
         $cb->multiple = MultipleSelectType::ONLYONE;
         $editList->setCustomButton($cb);
     }
     if ($this->_buttons != null) {
         for ($i = 0, $buttonsLength = sizeof($this->_buttons); $i < $buttonsLength; $i++) {
             //				CustomButtons $cb;
             if ($this->_buttons[$i]->action != "" || $this->_buttons[$i]->url != "") {
                 $cb = new CustomButtons();
                 $cb->action = $this->_buttons[$i]->action;
                 $cb->alternateText = $this->_buttons[$i]->alternateText;
                 $cb->icon = $this->_buttons[$i]->icon;
                 $cb->url = $this->_buttons[$i]->url;
                 $cb->enabled = true;
                 $cb->multiple = $this->_buttons[$i]->multiple;
                 $editList->setCustomButton($cb);
             }
         }
     }
     $fldKey = "";
     for ($i = 0, $current = 0; $i < sizeof($this->_keyIndex); $i++, $current++) {
         $fldKey .= ($fldKey != "" ? "|" : "") . $this->_fields[$this->_keyIndex[$i]]->fieldName;
     }
     $field = new EditListField();
     $field->fieldData = $fldKey;
     $field->editlistName = "#";
     $field->formatter = new CrudPKFormatter();
     $field->fieldType = EditListFieldType::FORMATTER;
     $editList->addEditListField($field);
     for ($i = 0, $fieldLength = sizeof($this->_fields); $i < $fieldLength; $i++, $current++) {
         if ($this->_fields[$i]->visibleInList) {
             $field = new EditListField();
             $field->fieldData = $this->_fields[$i]->fieldName;
             $field->editlistName = $this->_fields[$i]->fieldCaption;
             if ($this->_fields[$i]->fieldXmlInput == XmlInputObjectType::SELECTLIST) {
                 $field->fieldType = EditListFieldType::LOOKUP;
                 $field->arrayLookup = $this->_fields[$i]->arraySelectList;
             } elseif ($this->_fields[$i]->fieldXmlInput == XmlInputObjectType::DUALLIST) {
                 $field->fieldType = EditListFieldType::FORMATTER;
                 $field->formatter = new CrudDualListFormatter($this->_fields[$i]->arraySelectList);
             } else {
                 $field->fieldType = EditListFieldType::TEXT;
             }
             $field->newColumn = $this->_fields[$i]->newColumn;
             if (!is_null($this->_fields[$i]->viewFormatter)) {
                 $field->formatter = $this->_fields[$i]->viewFormatter;
                 $field->fieldType = EditListFieldType::FORMATTER;
             }
             $field = $this->editListFieldCustomize($field, $this->_fields[$i]);
             $editList->addEditListField($field);
         }
     }
     return $editList;
 }
Пример #5
0
 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);
 }