Exemplo n.º 1
0
 public function CreatePage()
 {
     parent::CreatePage();
     // Doesnt necessary get PX, because PX is protected!
     $myWords = $this->WordCollection();
     $forceReset = false;
     // Get parameters to define type of edit
     $catId = $this->_context->get("ci");
     $type = $this->_context->get("t");
     if ($type == "") {
         if ($this->_action == XmlnukeCrudBase::ACTION_VIEW) {
             $type = "FILE";
             $catId = $this->_context->get("valueid");
             $catIdAr = explode("|", $catId);
             $catId = $catIdAr[1];
             $forceReset = true;
         } else {
             $type = "CATEGORY";
         }
     }
     $block = new XmlBlockCollection($myWords->Value("TITLE"), BlockPosition::Center);
     $this->setTitlePage($myWords->Value("TITLE"));
     $this->setHelp($myWords->Value("DESCRIPTION"));
     $this->defaultXmlnukeDocument->addXmlnukeObject($block);
     // Download File
     $downloadFile = new AnydatasetFilenameProcessor("_download");
     $fields = new CrudFieldCollection();
     // Create Process Page Fields
     $field = CrudField::FactoryMinimal("TYPE", $myWords->Value("FORMTYPE"), 20, false, true);
     $field->key = true;
     $field->editable = false;
     $field->dataType = INPUTTYPE::UPPERASCII;
     $field->defaultValue = $type;
     $fields->addCrudField($field);
     $field = CrudField::FactoryMinimal("cat_id", $myWords->Value("FORMCATEGORY"), 20, true, true);
     $field->key = $type == "CATEGORY";
     $field->editable = $type == "CATEGORY";
     $field->defaultValue = $catId;
     $fields->addCrudField($field);
     if ($type == "FILE") {
         $field = CrudField::FactoryMinimal("file_id", $myWords->Value("FORMFILE"), 20, true, true);
         $field->key = $type == "FILE";
         $fields->addCrudField($field);
     }
     $field = CrudField::FactoryMinimal("name", $myWords->Value("LABEL_NAME"), 20, true, true);
     $field->maxLength = 40;
     $fields->addCrudField($field);
     $field = CrudField::FactoryMinimal("description", $myWords->Value("FORMDESCRIPTION"), 40, true, true);
     $field->maxLength = 500;
     $fields->addCrudField($field);
     $langs = $this->_context->LanguagesAvailable();
     foreach ($langs as $key => $desc) {
         $field = CrudField::FactoryMinimal("name_" . $key, $myWords->Value("LABEL_NAME") . $desc, 20, false, false);
         $field->maxLength = 40;
         $fields->addCrudField($field);
         $field = CrudField::FactoryMinimal("description_" . $key, $myWords->Value("FORMDESCRIPTION") . $desc, 40, false, false);
         $field->maxLength = 500;
         $fields->addCrudField($field);
     }
     if ($type == "FILE") {
         $field = CrudField::FactoryMinimal("url", $myWords->Value("FORMURL"), 40, true, true);
         $field->maxLength = 40;
         $fields->addCrudField($field);
         $field = CrudField::FactoryMinimal("seemore", $myWords->Value("FORMSEEMORE"), 40, false, true);
         $field->maxLength = 40;
         $fields->addCrudField($field);
         $field = CrudField::FactoryMinimal("emailto", $myWords->Value("FORMEMAILTO"), 40, false, true);
         $field->maxLength = 50;
         $field->dataType = INPUTTYPE::EMAIL;
         $fields->addCrudField($field);
     }
     // Write custom message
     if ($this->_action == XmlnukeCrudBase::ACTION_LIST || $this->_action == XmlnukeCrudBase::ACTION_MSG || $forceReset) {
         $p = new XmlParagraphCollection();
         if ($type == "CATEGORY") {
             $p->addXmlnukeObject(new XmlnukeText($myWords->Value("NOTE_CATEGORY")));
         } else {
             $href = new XmlAnchorCollection("module:Xmlnuke.Admin.download");
             $href->addXmlnukeObject(new XmlnukeText($myWords->Value("NOTE_FILE", $catId)));
             $p->addXmlnukeObject($href);
         }
         $block->addXmlnukeObject($p);
     }
     // Show Process Page State
     $itf = new IteratorFilter();
     $itf->addRelation("TYPE", Relation::EQUAL, $type);
     if ($type == "FILE") {
         $itf->addRelation("cat_id", Relation::EQUAL, $catId);
     }
     $processor = new XmlnukeCrudAnydata($this->_context, $fields, $myWords->Value("TITLE_" . $type, $catId), "module:Xmlnuke.Admin.download", null, $downloadFile, $itf);
     if ($forceReset) {
         $processor->forceCurrentAction(XmlnukeCrudBase::ACTION_LIST);
     }
     if ($type == "FILE") {
         $processor->addParameter("t", $type);
         $processor->addParameter("ci", $catId);
     }
     $block->addXmlnukeObject($processor);
     return $this->defaultXmlnukeDocument;
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
0
 /**
  * Enter description here...
  *
  * @param XmlBlockCollection $block
  * @param string $pollname
  */
 protected function ListAnswers($block, $pollname, $lang)
 {
     $yesno = array("Y" => $this->myWords->Value("YES"), "N" => $this->myWords->Value("NO"));
     $processfields = new CrudFieldCollection();
     $field = CrudField::FactoryMinimal("name", $this->myWords->Value("POLLNAME"), 15, true, true);
     $field->key = true;
     $field->editable = $this->_context->get("acao") == XmlnukeCrudBase::ACTION_NEW_CONFIRM;
     $field->defaultValue = $pollname;
     $processfields->addCrudField($field);
     $field = CrudField::FactoryMinimal("lang", $this->myWords->Value("POLLLANG"), 5, true, true);
     $field->key = true;
     $field->editable = $this->_context->get("acao") == XmlnukeCrudBase::ACTION_NEW_CONFIRM;
     $field->fieldXmlInput = XmlInputObjectType::SELECTLIST;
     $field->arraySelectList = $this->_context->LanguagesAvailable();
     $field->defaultValue = $lang;
     $processfields->addCrudField($field);
     $field = CrudField::FactoryMinimal("code", $this->myWords->Value("ANSWERCODE"), 3, true, true);
     $field->key = true;
     $field->dataType = INPUTTYPE::NUMBER;
     $processfields->addCrudField($field);
     $field = CrudField::FactoryMinimal("short", $this->myWords->Value("SHORTTEXT"), 10, true, true);
     $processfields->addCrudField($field);
     $field = CrudField::FactoryMinimal("answer", $this->myWords->Value("ANSWERTEXT"), 50, true, true);
     $processfields->addCrudField($field);
     $field = CrudField::FactoryMinimal("votes", $this->myWords->Value("ANSWERVOTES"), 3, true, true);
     $field->editable = false;
     $field->defaultValue = 0;
     $field->dataType = INPUTTYPE::NUMBER;
     $processfields->addCrudField($field);
     if ($this->_isdb) {
         $crud = new XmlnukeCrudDB($this->_context, $processfields, $this->myWords->Value("AVAILABLEANSWER", $pollname), $this->_moduleUrl, null, $this->_tblanswer, $this->_connection);
         $crud->setFilter("name = '" . $pollname . "' and lang='" . $lang . "'");
     } else {
         $anydatafile = new AnydatasetFilenameProcessor("poll_" . $pollname . "_" . $lang);
         $crud = new XmlnukeCrudAnydata($this->_context, $processfields, $this->myWords->Value("AVAILABLEANSWER", $pollname), $this->_moduleUrl, null, $anydatafile);
     }
     $crud->addParameter("op", "answernav");
     $crud->addParameter("curpoll", $pollname);
     $crud->addParameter("curlang", $lang);
     $block->addXmlnukeObject($crud);
 }
Exemplo n.º 4
0
 /**
  * Edit AnydataSet
  *
  */
 protected function actionEditAnydataSet()
 {
     $blockCenter = new XmlBlockCollection($this->_myWords->Value("ANYDATASET"), BlockPosition::Center);
     $breakline = new XmlnukeBreakLine();
     $paragraph = new XmlParagraphCollection();
     $paragraph->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("DESCANYDATASETTEXT")));
     $paragraph->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("DESCANYDATASETTEXT2"), true, false, false));
     $paragraph->addXmlnukeObject($breakline);
     $pageField = new CrudFieldCollection();
     $fieldPage = new CrudField();
     $fieldPage->fieldName = "code";
     $fieldPage->key = true;
     $fieldPage->dataType = INPUTTYPE::NUMBER;
     $fieldPage->fieldCaption = $this->_myWords->Value("CODE");
     $fieldPage->fieldXmlInput = XmlInputObjectType::TEXTBOX;
     $fieldPage->visibleInList = true;
     $fieldPage->editable = true;
     $fieldPage->required = true;
     $fieldPage->rangeMin = "100";
     $fieldPage->rangeMax = "10000";
     $pageField->addCrudField($fieldPage);
     $fieldPage = new CrudField();
     $fieldPage->fieldName = "name";
     $fieldPage->key = false;
     $fieldPage->dataType = INPUTTYPE::TEXT;
     $fieldPage->fieldCaption = $this->_myWords->Value("TXT_NAME");
     $fieldPage->fieldXmlInput = XmlInputObjectType::TEXTBOX;
     $fieldPage->visibleInList = true;
     $fieldPage->editable = true;
     $fieldPage->required = true;
     $pageField->addCrudField($fieldPage);
     $fieldPage = new CrudField();
     $fieldPage->fieldName = "email";
     $fieldPage->key = false;
     $fieldPage->dataType = INPUTTYPE::EMAIL;
     $fieldPage->fieldCaption = $this->_myWords->Value("TXT_EMAIL");
     $fieldPage->fieldXmlInput = XmlInputObjectType::TEXTBOX;
     $fieldPage->visibleInList = true;
     $fieldPage->editable = true;
     $fieldPage->required = true;
     $pageField->addCrudField($fieldPage);
     $fieldPage = new CrudField();
     $fieldPage->fieldName = "data";
     $fieldPage->key = false;
     $fieldPage->dataType = INPUTTYPE::DATE;
     $fieldPage->fieldCaption = $this->_myWords->Value("DATE");
     $fieldPage->fieldXmlInput = XmlInputObjectType::TEXTBOX;
     $fieldPage->visibleInList = false;
     $fieldPage->editable = true;
     $fieldPage->required = true;
     $fieldPage->size = 10;
     $pageField->addCrudField($fieldPage);
     $fieldPage = new CrudField();
     $fieldPage->fieldName = "Memo";
     $fieldPage->key = false;
     $fieldPage->dataType = INPUTTYPE::TEXT;
     $fieldPage->fieldCaption = $this->_myWords->Value("MEMO");
     $fieldPage->fieldXmlInput = XmlInputObjectType::MEMO;
     $fieldPage->visibleInList = false;
     $fieldPage->editable = true;
     $fieldPage->required = false;
     $pageField->addCrudField($fieldPage);
     $crud = new XmlnukeCrudAnydata($this->_context, $pageField, $this->_myWords->Value("EDITDB"), $this->_url . "?op=4", null, new AnydatasetFilenameProcessor("sample"));
     $crud->setPageSize(3, 0);
     $paragraph->addXmlnukeObject($crud);
     $blockCenter->addXmlnukeObject($paragraph);
     $this->_document->addXmlnukeObject($blockCenter);
 }