예제 #1
0
 /**
  * Construct this form
  * @param string $action url where this form will point to
  * @param boolean $isPublished
  * @return null
  */
 public function __construct($action, $isPublished)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SAVE);
     $factory = FieldFactory::getInstance();
     $isPublishedField = $factory->createField(FieldFactory::TYPE_BOOLEAN, self::FIELD_IS_PUBLISHED, $isPublished);
     $this->addField($isPublishedField);
 }
예제 #2
0
 /**
  * Constructs a new module upload form
  * @param string $action URL where this form will point to
  * @return null
  */
 public function __construct($action)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SUBMIT);
     $factory = FieldFactory::getInstance();
     $this->addField($factory->createField(FieldFactory::TYPE_FILE, self::FIELD_MODULE));
     $this->addValidator(self::FIELD_MODULE, new RequiredValidator());
 }
 /**
  * Constructs a new properties form
  * @param string $action URL where this form will point to
  * @param joppa\model\Node $node
  * @param joppa\content\model\ContentProperties $properties
  * @return null
  */
 public function __construct($action, Node $node, ContentProperties $properties)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SAVE);
     $translator = I18n::getInstance()->getTranslator();
     $modelManager = ModelManager::getInstance();
     $fieldFactory = FieldFactory::getInstance();
     $model = $properties->getModelName();
     $fields = $properties->getModelFields();
     $recursiveDepth = $properties->getRecursiveDepth();
     $includeUnlocalized = $properties->getIncludeUnlocalized();
     $view = $properties->getView();
     $modelField = $fieldFactory->createField(FieldFactory::TYPE_LIST, self::FIELD_MODEL, $model);
     $modelField->setOptions($this->getModelOptions($modelManager));
     $modelField->addEmpty();
     $fieldsField = $fieldFactory->createField(FieldFactory::TYPE_LIST, self::FIELD_FIELDS, $fields);
     $fieldsField->setOptions(self::getModelFieldOptions($modelManager, $model));
     $fieldsField->setIsMultiple(true);
     $recursiveDepthField = $fieldFactory->createField(FieldFactory::TYPE_LIST, self::FIELD_RECURSIVE_DEPTH, $recursiveDepth);
     $recursiveDepthField->setOptions($this->getNumericOptions(0, 5));
     $includeUnlocalizedField = $fieldFactory->createField(FieldFactory::TYPE_LIST, self::FIELD_INCLUDE_UNLOCALIZED, $includeUnlocalized);
     $includeUnlocalizedField->setOptions($this->getIncludeUnlocalizedOptions($translator));
     $viewField = $fieldFactory->createField(FieldFactory::TYPE_LIST, self::FIELD_VIEW, $view);
     $viewField->setOptions($this->getViewOptions($translator));
     $this->addField($modelField);
     $this->addField($fieldsField);
     $this->addField($recursiveDepthField);
     $this->addField($includeUnlocalizedField);
     $this->addField($viewField);
 }
예제 #4
0
 /**
  * Constructs a new forum category order form
  * @param string $action URL where this form will point to
  * @return null
  */
 public function __construct($action)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SAVE);
     $fieldFactory = FieldFactory::getInstance();
     $fieldOrder = $fieldFactory->createField(FieldFactory::TYPE_HIDDEN, self::FIELD_ORDER);
     $this->addField($fieldOrder);
 }
 /**
  * Constructs a new forum preview properties form
  * @param string $action URL where this form will point to
  * @param integer $posts Number of posts to preset the form
  * @return null
  */
 public function __construct($action, $posts)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SAVE);
     $fieldFactory = FieldFactory::getInstance();
     $postsField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_POSTS, $posts);
     $this->addField($postsField);
 }
예제 #6
0
 /**
  * Constructs a new authentication form
  * @param string $action URL where this form will point to
  * @return null
  */
 public function __construct($action)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SUBMIT);
     $factory = FieldFactory::getInstance();
     $fieldUsername = $factory->createField(FieldFactory::TYPE_STRING, self::FIELD_USERNAME);
     $fieldUsername->addValidator(new RequiredValidator());
     $this->addField($fieldUsername);
 }
예제 #7
0
 /**
  * Constructs a new model import form
  * @param string $action URL where this form will point to
  * @return null
  */
 public function __construct($action)
 {
     parent::__construct($action, self::NAME);
     $fieldFactory = FieldFactory::getInstance();
     $fieldFile = $fieldFactory->createField(FieldFactory::TYPE_FILE, self::FIELD_FILE);
     $fieldFile->addValidator(new RequiredValidator());
     $this->addField($fieldFile);
 }
 /**
  * Constructs a new properties form for a login widget
  * @param string $action URL where this form will point to
  * @param string $redirect Value for the redirect field
  * @return null
  */
 public function __construct($action, $redirect)
 {
     parent::__construct($action, self::NAME);
     $fieldFactory = FieldFactory::getInstance();
     $redirectOptions = LoginWidget::getRedirectOptions();
     $redirectField = $fieldFactory->createField(FieldFactory::TYPE_LIST, self::FIELD_REDIRECT, $redirect);
     $redirectField->setOptions($redirectOptions);
     $this->addField($redirectField);
 }
 /**
  * Constructs a new HTML widget form
  * @param string $action URL where this form should point to
  * @param string $locale Locale code
  * @param string $content Content
  * @return null
  */
 public function __construct($action, $locale, $content)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SUBMIT);
     $fieldFactory = FieldFactory::getInstance();
     $localeField = $fieldFactory->createField(FieldFactory::TYPE_HIDDEN, self::FIELD_LOCALE, $locale);
     $contentField = $fieldFactory->createField(FieldFactory::TYPE_TEXT, self::FIELD_CONTENT, $content);
     $this->addField($localeField);
     $this->addField($contentField);
 }
 /**
  * Constructs a new forum category form
  * @param string $action URL where this form will point to
  * @return null
  */
 public function __construct($action, $topicsPerPage, $postsPerPage)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SAVE);
     $fieldFactory = FieldFactory::getInstance();
     $topicsPerPageField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_TOPICS_PER_PAGE, $topicsPerPage);
     $postsPerPageField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_POSTS_PER_PAGE, $postsPerPage);
     $this->addField($topicsPerPageField);
     $this->addField($postsPerPageField);
 }
예제 #11
0
 /**
  * Constructs a new authentication form
  * @param string $action URL where this form will point to
  * @return null
  */
 public function __construct($action)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_LOGIN);
     $factory = FieldFactory::getInstance();
     $this->addField($factory->createField(FieldFactory::TYPE_STRING, SecurityManager::USERNAME));
     $this->addField($factory->createField(FieldFactory::TYPE_PASSWORD, SecurityManager::PASSWORD));
     $requiredValidator = new RequiredValidator();
     $this->addValidator(SecurityManager::USERNAME, $requiredValidator);
     $this->addValidator(SecurityManager::PASSWORD, $requiredValidator);
 }
예제 #12
0
 /**
  * Constructs a new password reset form
  * @param string $action URL where this form will point to
  * @return null
  */
 public function __construct($action)
 {
     parent::__construct($action, self::NAME);
     $fieldFactory = FieldFactory::getInstance();
     $usernameField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_USERNAME);
     $emailField = $fieldFactory->createField(FieldFactory::TYPE_EMAIL, self::FIELD_EMAIL);
     $this->addField($usernameField);
     $this->addField($emailField);
     $this->addFormValidator(new ResetPasswordFormValidator());
 }
예제 #13
0
 /**
  * Construct this form
  * @param string $action url where this form will point to
  * @param joppa\model\NodeSettings the node settings which this form represents
  */
 public function __construct($action, NodeSettings $nodeSettings)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SAVE);
     $this->nodeSettings = $nodeSettings;
     $factory = FieldFactory::getInstance();
     $this->addField($factory->createField(FieldFactory::TYPE_HIDDEN, self::FIELD_ID));
     $this->addField($factory->createField(FieldFactory::TYPE_TEXT, self::FIELD_SETTINGS));
     $this->setValue(self::FIELD_ID, $this->nodeSettings->getNode()->id);
     $this->setValue(self::FIELD_SETTINGS, $this->nodeSettings->getIniString());
 }
예제 #14
0
 /**
  * Constructs a new upload form
  * @param string $action URL where this form will point to
  * @param zibo\library\filesystem\File $uploadPath Path to upload to
  * @return null
  */
 public function __construct($action, File $uploadPath)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SUBMIT);
     $fieldFactory = FieldFactory::getInstance();
     $fileField = $fieldFactory->createField(FieldFactory::TYPE_FILE, self::FIELD_FILE);
     $fileField->addValidator(new RequiredValidator());
     $fileField->setIsMultiple(true);
     $fileField->setUploadPath($uploadPath);
     $fileField->setWillOverwrite(true);
     $this->addField($fileField);
 }
예제 #15
0
 /**
  * Sets the submitted values to the provided data object
  * @return null
  * @throws zibo\ZiboException when the form is not submitted
  */
 public function isSubmitted()
 {
     if ($this->isSubmitted !== null) {
         return $this->isSubmitted;
     }
     if (!parent::isSubmitted()) {
         return false;
     }
     $this->setFormValuesToData();
     return true;
 }
예제 #16
0
 /**
  * Construct this form
  * @param string $action url where this form will point to
  * @param joppa\text\model\data\TextData $text The text to edit
  * @return null
  */
 public function __construct($action, TextData $text)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SAVE);
     $fieldFactory = FieldFactory::getInstance();
     $idField = $fieldFactory->createField(FieldFactory::TYPE_HIDDEN, self::FIELD_ID, $text->id);
     $textField = $fieldFactory->createField(FieldFactory::TYPE_WYSIWYG, self::FIELD_TEXT, $text->text);
     $versionField = $fieldFactory->createField(FieldFactory::TYPE_HIDDEN, self::FIELD_VERSION, $text->version);
     $this->addField($idField);
     $this->addField($textField);
     $this->addField($versionField);
 }
 public function __construct($action, $subject = null, $message = null)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SUBMIT);
     $requiredValidator = new RequiredValidator();
     $fieldFactory = FieldFactory::getInstance();
     $subjectField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_SUBJECT, $subject);
     $subjectField->addValidator($requiredValidator);
     $messageField = $fieldFactory->createField(FieldFactory::TYPE_TEXT, self::FIELD_MESSAGE, $message);
     $messageField->addValidator($requiredValidator);
     $this->addField($subjectField);
     $this->addField($messageField);
 }
예제 #18
0
 /**
  * Constructs a new spider form
  * @param string $action URL where this form will point to
  * @param string $url URL to set in the form
  * @return null
  */
 public function __construct($action, $url = null, $delay = 100)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SUBMIT, self::TRANSLATION_CANCEL);
     $fieldFactory = FieldFactory::getInstance();
     $urlField = $fieldFactory->createField(FieldFactory::TYPE_WEBSITE, self::FIELD_URL, $url);
     $urlField->addValidator(new RequiredValidator());
     $delayField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_DELAY, $delay);
     $delayField->addValidator(new MinMaxValidator(array(MinMaxValidator::OPTION_MINIMUM => 0, MinMaxValidator::OPTION_MAXIMUM => 999999)));
     $ignoreField = $fieldFactory->createField(FieldFactory::TYPE_TEXT, self::FIELD_IGNORE);
     $this->addField($urlField);
     $this->addField($delayField);
     $this->addField($ignoreField);
 }
예제 #19
0
 /**
  * Constructs a new password form
  * @param string $action URL where this form will point to
  * @return null
  */
 public function __construct($action)
 {
     parent::__construct($action, self::NAME);
     $fieldFactory = FieldFactory::getInstance();
     $requiredValidator = new RequiredValidator();
     $passwordField = $fieldFactory->createField(FieldFactory::TYPE_PASSWORD, self::FIELD_PASSWORD);
     $passwordField->addValidator($requiredValidator);
     $passwordConfirmField = $fieldFactory->createField(FieldFactory::TYPE_PASSWORD, self::FIELD_PASSWORD_CONFIRM);
     $passwordConfirmField->addValidator($requiredValidator);
     $this->addField($passwordField);
     $this->addField($passwordConfirmField);
     $this->addFormValidator(new NewPasswordFormValidator());
 }
예제 #20
0
 /**
  * Constructs a new model filter form
  * @param string $action URL where this form will point to
  * @return null
  */
 public function __construct($action, array $include = null)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_FILTER);
     $translator = I18n::getInstance()->getTranslator();
     $includeOptions = array(self::INCLUDE_CUSTOM => $translator->translate(self::TRANSLATION_CUSTOM), self::INCLUDE_MODULE => $translator->translate(self::TRANSLATION_MODULE), self::INCLUDE_LOCALIZED => $translator->translate(self::TRANSLATION_LOCALIZED), self::INCLUDE_LINK => $translator->translate(self::TRANSLATION_LINK));
     if ($include == null) {
         $include = array(self::INCLUDE_CUSTOM => self::INCLUDE_CUSTOM, self::INCLUDE_MODULE => self::INCLUDE_MODULE);
     }
     $fieldFactory = FieldFactory::getInstance();
     $fieldInclude = $fieldFactory->createField(FieldFactory::TYPE_OPTION, self::FIELD_INCLUDE, $include);
     $fieldInclude->setIsMultiple(true);
     $fieldInclude->setOptions($includeOptions);
     $this->addField($fieldInclude);
 }
예제 #21
0
 /**
  * Constructs a new forum post form
  * @param string $action URL where this form will point to
  * @param joppa\forum\model\data\ForumPostData $post The post to preset the form
  * @param zibo\library\emoticons\EmoticonParser $emoticonParser Emoticon parser for the BBCode field
  * @return null
  */
 public function __construct($action, ForumPostData $post, EmoticonParser $emoticonParser = null)
 {
     parent::__construct($action, self::NAME);
     $fieldFactory = FieldFactory::getInstance();
     $idField = $fieldFactory->createField(FieldFactory::TYPE_HIDDEN, self::FIELD_ID, $post->id);
     $subjectField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_SUBJECT, $post->subject);
     $messageField = $fieldFactory->createField(self::TYPE_FIELD_MESSAGE, self::FIELD_MESSAGE, $post->message);
     $messageField->setEmoticonParser($emoticonParser);
     $previewButton = $fieldFactory->createSubmitField(self::BUTTON_PREVIEW, self::TRANSLATION_PREVIEW);
     $this->addField($idField);
     $this->addField($subjectField);
     $this->addField($messageField);
     $this->addField($previewButton);
 }
예제 #22
0
 /**
  * Constructs a new connection form
  * @param string $formAction URL where this form will point to
  * @param string $name Name of the connection
  * @param string $dsn DSN string
  * @param string $oldName Old name of the connection
  * @return null
  */
 public function __construct($formAction, $name = null, $dsn = null, $oldName = null)
 {
     parent::__construct($formAction, self::NAME, self::TRANSLATION_SAVE);
     $fieldFactory = FieldFactory::getInstance();
     $nameField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_NAME, $name);
     $dsnField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_DSN, $dsn);
     $oldNameField = $fieldFactory->createField(FieldFactory::TYPE_HIDDEN, self::FIELD_OLD_NAME, $oldName);
     $this->addField($nameField);
     $this->addField($dsnField);
     $this->addField($oldNameField);
     $validationFactory = ValidationFactory::getInstance();
     $nameField->addValidator($validationFactory->createValidator('required'));
     $nameField->addValidator($validationFactory->createValidator('regex', array('regex' => self::VALIDATION_NAME_REGEX, 'message' => self::TRANSLATION_VALIDATION_NAME)));
     $dsnField->addValidator($validationFactory->createValidator('dsn'));
 }
예제 #23
0
 /**
  * Constructs a new forum category form
  * @param string $action URL where this form will point to
  * @param joppa\forum\model\data\ForumCategoryData $category Forum category to preset the form
  * @return null
  */
 public function __construct($action, ForumCategoryData $category = null)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SAVE);
     $fieldFactory = FieldFactory::getInstance();
     $id = null;
     $name = null;
     if ($category) {
         $id = $category->id;
         $name = $category->name;
     }
     $idField = $fieldFactory->createField(FieldFactory::TYPE_HIDDEN, self::FIELD_ID, $id);
     $nameField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_NAME, $name);
     $this->addField($idField);
     $this->addField($nameField);
 }
 /**
  * Construct this form
  * @param string $action action where this form will point to
  * @param int $level Level of the heading
  * @param int $styleClass Style class for the heading
  * @param int $styleId Style id for the heading
  * @return null
  */
 public function __construct($action, $level = null, $styleClass = null, $styleId = null)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SAVE);
     $factory = FieldFactory::getInstance();
     $levels = array();
     for ($i = 1; $i <= 5; $i++) {
         $levels[$i] = $i;
     }
     $levelField = $factory->createField(FieldFactory::TYPE_LIST, self::FIELD_LEVEL, $level);
     $levelField->setOptions($levels);
     $styleClassField = $factory->createField(FieldFactory::TYPE_STRING, self::FIELD_STYLE_CLASS, $styleClass);
     $styleIdField = $factory->createField(FieldFactory::TYPE_STRING, self::FIELD_STYLE_ID, $styleId);
     $this->addField($levelField);
     $this->addField($styleClassField);
     $this->addField($styleIdField);
 }
예제 #25
0
 /**
  * Constructs a new form
  * @param string $action URL where this form will point to
  * @param string $name Name of the form
  * @param string $translationSubmit Translation key for the submit button
  * @param zibo\library\filesystem\File $path Path of the file or directory
  * @return null
  */
 public function __construct($action, $name, $translationSubmit, File $path = null)
 {
     parent::__construct($action, $name, $translationSubmit);
     $pathValue = '.';
     if ($path != null) {
         $pathValue = $path->getPath();
     }
     $fieldFactory = FieldFactory::getInstance();
     $requiredValidator = new RequiredValidator();
     $pathField = $fieldFactory->createField(FieldFactory::TYPE_HIDDEN, self::FIELD_PATH, $pathValue);
     $pathField->addValidator($requiredValidator);
     $nameField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_NAME);
     $nameField->addValidator($requiredValidator);
     $this->addField($pathField);
     $this->addField($nameField);
 }
 /**
  * Construct this form
  * @param string $action action where this form will point to
  * @param int $rootNodeId id of the root node for the parent field
  * @param int $parent id of the root node for this menu
  * @param int $depth number of levels this menu will go
  * @param boolean $showTitle flag to determine whether to show a title or not
  * @return null
  */
 public function __construct($action, Node $node, $parent, $depth, $showTitle)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SAVE);
     $factory = FieldFactory::getInstance();
     $parentField = $factory->createField(FieldFactory::TYPE_LIST, self::FIELD_PARENT, $parent);
     $parentField->setOptions($this->getParentOptions($node));
     $depths = array();
     for ($i = 0; $i <= 10; $i++) {
         $depths[$i] = $i;
     }
     $depthField = $factory->createField(FieldFactory::TYPE_LIST, self::FIELD_DEPTH, $depth);
     $depthField->setOptions($depths);
     $this->addField($parentField);
     $this->addField($depthField);
     $this->addField($factory->createField(FieldFactory::TYPE_BOOLEAN, self::FIELD_SHOW_TITLE, $showTitle));
 }
 /**
  * Construct this form
  * @param string $action url where this form will point to
  * @param int $rootNodeId id of the root node for the filter field
  * @param string $label Label for the breadcrumbs
  * @param mixed $filter value for the filter field
  * @param string $styleId value for the style id field
  * @return null
  */
 public function __construct($action, $rootNodeId, $label, $filter, $styleId = null)
 {
     parent::__construct($action, self::NAME);
     $factory = FieldFactory::getInstance();
     $siteModel = ModelManager::getInstance()->getModel(SiteModel::NAME);
     $nodeModel = ModelManager::getInstance()->getModel(NodeModel::NAME);
     $nodeTree = $siteModel->getNodeTreeForNode($rootNodeId, null, null, null, true, false);
     $nodeList = $nodeModel->createListFromNodeTree($nodeTree);
     $labelField = $factory->createField(FieldFactory::TYPE_STRING, self::FIELD_LABEL, $label);
     $filterField = $factory->createField(FieldFactory::TYPE_LIST, self::FIELD_FILTER, $filter);
     $filterField->setOptions($nodeList);
     $filterField->setIsMultiple(true);
     $styleIdField = $factory->createField(FieldFactory::TYPE_STRING, self::FIELD_STYLE_ID, $styleId);
     $this->addField($labelField);
     $this->addField($filterField);
     $this->addField($styleIdField);
 }
예제 #28
0
 /**
  * Constructs a new password form
  * @param string $action URL where this form will point to
  * @return null
  */
 public function __construct($action)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SUBMIT);
     $fieldFactory = FieldFactory::getInstance();
     $requiredValidator = new RequiredValidator();
     $usernameField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_USERNAME);
     $usernameField->addValidator($requiredValidator);
     $emailField = $fieldFactory->createField(FieldFactory::TYPE_EMAIL, self::FIELD_EMAIL);
     $emailField->addValidator($requiredValidator);
     $passwordField = $fieldFactory->createField(FieldFactory::TYPE_PASSWORD, self::FIELD_PASSWORD);
     $passwordField->addValidator($requiredValidator);
     $passwordConfirmField = $fieldFactory->createField(FieldFactory::TYPE_PASSWORD, self::FIELD_PASSWORD_CONFIRM);
     $passwordConfirmField->addValidator($requiredValidator);
     $this->addField($usernameField);
     $this->addField($emailField);
     $this->addField($passwordField);
     $this->addField($passwordConfirmField);
     $this->addFormValidator(new NewPasswordFormValidator());
 }
예제 #29
0
 /**
  * Constructs a new log filter form
  * @param string $action URL where this form will point to
  * @return null
  */
 public function __construct($action, array $include = null, $dataModel = null, $dataId = null, $dataField = null)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_FILTER);
     $translator = I18n::getInstance()->getTranslator();
     $includeOptions = array(LogModel::ACTION_INSERT => LogModel::ACTION_INSERT, LogModel::ACTION_UPDATE => LogModel::ACTION_UPDATE, LogModel::ACTION_DELETE => LogModel::ACTION_DELETE);
     if ($include == null) {
         $include = $includeOptions;
     }
     $fieldFactory = FieldFactory::getInstance();
     $fieldInclude = $fieldFactory->createField(FieldFactory::TYPE_OPTION, self::FIELD_INCLUDE, $include);
     $fieldInclude->setIsMultiple(true);
     $fieldInclude->setOptions($includeOptions);
     $dataModelField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_DATA_MODEL, $dataModel);
     $dataIdField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_DATA_ID, $dataId);
     $dataFieldField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_DATA_FIELD, $dataField);
     $this->addField($fieldInclude);
     $this->addField($dataModelField);
     $this->addField($dataIdField);
     $this->addField($dataFieldField);
 }
예제 #30
0
 /**
  * Constructs a new forum board form
  * @param string $action URL where this form will point to
  * @param joppa\forum\model\data\ForumBoardData $board Board data to preset the form
  */
 public function __construct($action, ForumBoardData $board = null)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SAVE);
     $modelManager = ModelManager::getInstance();
     $categoryModel = $modelManager->getModel(ForumCategoryModel::NAME);
     $profileModel = $modelManager->getModel(ForumProfileModel::NAME);
     $category = null;
     if (!$board) {
         $boardModel = $modelManager->getModel(ForumBoardModel::NAME);
         $board = $boardModel->createData();
     } elseif (isset($board->category->id)) {
         $category = $board->category->id;
     }
     $allowOptions = ForumBoardModel::getAllowOptions();
     $fieldFactory = FieldFactory::getInstance();
     $idField = $fieldFactory->createField(FieldFactory::TYPE_HIDDEN, self::FIELD_ID, $board->id);
     $categoryField = $fieldFactory->createField(FieldFactory::TYPE_LIST, self::FIELD_CATEGORY, $category);
     $categoryField->setOptions($categoryModel->getDataList());
     $nameField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_NAME, $board->name);
     $descriptionField = $fieldFactory->createField(FieldFactory::TYPE_TEXT, self::FIELD_DESCRIPTION, $board->description);
     $allowNewTopicsField = $fieldFactory->createField(FieldFactory::TYPE_LIST, self::FIELD_ALLOW_NEW_TOPICS, $board->allowNewTopics);
     $allowNewTopicsField->setOptions($allowOptions);
     $allowNewPostsField = $fieldFactory->createField(FieldFactory::TYPE_LIST, self::FIELD_ALLOW_NEW_POSTS, $board->allowNewPosts);
     $allowNewPostsField->setOptions($allowOptions);
     $allowViewField = $fieldFactory->createField(FieldFactory::TYPE_LIST, self::FIELD_ALLOW_VIEW, $board->allowView);
     $allowViewField->setOptions($allowOptions);
     $moderatorsField = $fieldFactory->createField(FieldFactory::TYPE_LIST, self::FIELD_MODERATORS, $board->moderators);
     $moderatorsField->setOptions($profileModel->getModeratorList());
     $moderatorsField->setIsMultiple(true);
     $this->addField($idField);
     $this->addField($categoryField);
     $this->addField($nameField);
     $this->addField($descriptionField);
     $this->addField($allowViewField);
     $this->addField($allowNewTopicsField);
     $this->addField($allowNewPostsField);
     $this->addField($moderatorsField);
 }