/**
  * Creates a option field for the provided permission
  * @param zibo\library\security\model\Permission $permission
  * @return zibo\library\html\form\field\Field
  */
 public function createField(Permission $permission = null)
 {
     $name = $this->name . '[' . $this->role->getRoleName() . ']';
     $field = $this->fieldFactory->createField(FieldFactory::TYPE_OPTION, $name, $permission);
     $field->setKeyDecorator(new PermissionCodeDecorator());
     $field->setIsMultiple(true);
     return $field;
 }
 /**
  * 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);
 }
 /**
  * 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 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 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);
 }
 /**
  * Construct a new form
  * @param string $action action where this form will point to
  * @return null
  */
 public function __construct($action)
 {
     parent::__construct($action, self::NAME);
     $factory = FieldFactory::getInstance();
     $this->addField($factory->createField(FieldFactory::TYPE_TEXT, self::FIELD_COMMENT));
     $this->addField($factory->createSubmitField(self::FIELD_SUBMIT, self::TRANSLATION_SUBMIT));
 }
Exemple #7
0
 /**
  * Construct this form
  * @param string $action url where this form will point to
  * @param joppa\model\Site $site
  * @return null
  */
 public function __construct($action, Site $site)
 {
     parent::__construct($action, $site->node, $site->node);
     $defaultNode = null;
     if ($site->defaultNode) {
         if (is_numeric($site->defaultNode)) {
             $defaultNode = $site->defaultNode;
         } else {
             $defaultNode = $site->defaultNode->id;
         }
     }
     $factory = FieldFactory::getInstance();
     $defaultNodeField = $factory->createField(FieldFactory::TYPE_LIST, self::FIELD_DEFAULT_NODE, $defaultNode);
     $defaultNodeField->setOptions($this->getDefaultNodeOptions($site->node));
     $localizationMethodField = $factory->createField(FieldFactory::TYPE_LIST, self::FIELD_LOCALIZATION_METHOD, $site->localizationMethod);
     $localizationMethodField->setOptions($this->getLocalizationMethodOptions());
     if ($site->id) {
         $localizationMethodField->setIsDisabled(true);
     }
     $this->addField($factory->createField(FieldFactory::TYPE_HIDDEN, self::FIELD_SITE_ID, $site->id));
     $this->addField($factory->createField(FieldFactory::TYPE_HIDDEN, self::FIELD_SITE_VERSION, $site->version));
     $this->addField($defaultNodeField);
     $this->addField($localizationMethodField);
     $this->addField($factory->createField(FieldFactory::TYPE_STRING, self::FIELD_BASE_URL, $site->baseUrl));
 }
 /**
  * Construct this form
  * @param string $action url where this form will point to
  * @param joppa\model\Node $node Node to retrieve the node list
  * @param string $nodeId node id to set to the form
  * @param string $url url to set to the form
  * @return null
  */
 public function __construct($action, $node, $nodeId = null, $url = null)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SAVE);
     if ($url) {
         $redirectType = self::REDIRECT_TYPE_URL;
     } else {
         $redirectType = self::REDIRECT_TYPE_NODE;
     }
     $modelManager = ModelManager::getInstance();
     $factory = FieldFactory::getInstance();
     $siteModel = $modelManager->getModel(SiteModel::NAME);
     $nodeModel = $modelManager->getModel(NodeModel::NAME);
     $nodeTree = $siteModel->getNodeTreeForNode($node->id, null, null, null, true, false);
     $nodeList = $nodeModel->createListFromNodeTree($nodeTree);
     if (isset($nodeList[$node->id])) {
         unset($nodeList[$node->id]);
     }
     $redirectTypeField = $factory->createField(FieldFactory::TYPE_OPTION, self::FIELD_REDIRECT_TYPE, $redirectType);
     $redirectTypeField->setOptions($this->getRedirectTypeOptions());
     $nodeField = $factory->createField(FieldFactory::TYPE_LIST, self::FIELD_NODE, $nodeId);
     $nodeField->setOptions($nodeList);
     $urlField = $factory->createField(FieldFactory::TYPE_STRING, self::FIELD_URL, $url);
     $this->addField($redirectTypeField);
     $this->addField($nodeField);
     $this->addField($urlField);
 }
 /**
  * Construct this form
  * @param string $action url where this form will point to
  * @param string $query optional search query to preset the form
  * @return null
  */
 public function __construct($action, $query = null)
 {
     parent::__construct($action, self::NAME);
     $factory = FieldFactory::getInstance();
     $this->addField($factory->createField(FieldFactory::TYPE_STRING, self::FIELD_QUERY, $query));
     $this->addField($factory->createSubmitField(self::FIELD_SEARCH, self::TRANSLATION_SEARCH));
 }
 /**
  * Prepares the wizard form for this step
  * @return null
  */
 public function prepareForm()
 {
     $modelTable = $this->wizard->getModelTable();
     $modelClass = $this->wizard->getVariable(BuilderWizard::VARIABLE_MODEL_CLASS);
     $dataClass = $this->wizard->getVariable(BuilderWizard::VARIABLE_DATA_CLASS);
     $modelName = null;
     $isLogged = null;
     $willBlockDelete = null;
     if ($modelTable) {
         $modelName = $modelTable->getName();
         $isLogged = $modelTable->isLogged();
         $willBlockDelete = $modelTable->willBlockDeleteWhenUsed();
     }
     if (!$isLogged) {
         $isLogged = false;
     }
     if (!$willBlockDelete) {
         $willBlockDelete = false;
     }
     $fieldFactory = FieldFactory::getInstance();
     $modelNameField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_MODEL_NAME, $modelName);
     $modelNameField->addValidator(new RegexValidator(array(RegexValidator::OPTION_REGEX => ModelTable::REGEX_NAME)));
     $modelNameField->setIsDisabled(!$this->wizard->isNewModel());
     $isLoggedField = $fieldFactory->createField(FieldFactory::TYPE_BOOLEAN, self::FIELD_IS_LOGGED, $isLogged);
     $willBlockDeleteField = $fieldFactory->createField(FieldFactory::TYPE_BOOLEAN, self::FIELD_WILL_BLOCK_DELETE, $willBlockDelete);
     $modelClassField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_MODEL_CLASS, $modelClass);
     $modelClassField->addValidator(new ClassValidator(array(ClassValidator::OPTION_REQUIRED => false, ClassValidator::OPTION_CLASS => ModelManager::INTERFACE_MODEL)));
     $dataClassField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_DATA_CLASS, $dataClass);
     $dataClassField->addValidator(new ClassValidator(array(ClassValidator::OPTION_REQUIRED => false)));
     $this->wizard->addField($modelNameField);
     $this->wizard->addField($isLoggedField);
     $this->wizard->addField($willBlockDeleteField);
     $this->wizard->addField($modelClassField);
     $this->wizard->addField($dataClassField);
 }
 /**
  * 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 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);
 }
 /**
  * Constructs a new editor form
  * @param string $action URL where this form will point to
  * @param zibo\library\filesystem\File $path File to edit or to create a new file, the directory of the new file
  * @return null
  */
 public function __construct($action, File $path = null, $name = null, $content = null)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SUBMIT, $path);
     $fieldFactory = FieldFactory::getInstance();
     $contentField = $fieldFactory->createField(FieldFactory::TYPE_TEXT, self::FIELD_CONTENT, $content);
     $this->addField($contentField);
     $this->setValue(self::FIELD_NAME, $name);
 }
 /**
  * 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 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);
 }
 /**
  * Construct a Google search form
  * @return null
  */
 public function __construct()
 {
     parent::__construct(self::ACTION, self::NAME);
     $this->setMethod(Form::METHOD_GET);
     $this->setAttribute('target', '_blank');
     $factory = FieldFactory::getInstance();
     $this->addField($factory->createField(FieldFactory::TYPE_STRING, self::FIELD_QUERY));
     $this->addField($factory->createSubmitField(self::FIELD_SUBMIT, self::TRANSLATION_SUBMIT));
 }
 /**
  * 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 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());
 }
 /**
  * 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());
 }
 /**
  * Construct this form
  * @param string $action url where this form will point to
  * @param int $nodeId id of the node which contains a search result widget
  * @return null
  */
 public function __construct($action, $nodeId = null)
 {
     parent::__construct($action, self::NAME);
     $factory = FieldFactory::getInstance();
     $nodeField = $factory->createField(FieldFactory::TYPE_LIST, self::FIELD_NODE, $nodeId);
     $nodeField->setOptions($this->getNodeOptions());
     $this->addField($nodeField);
     $this->addField($factory->createSubmitField(self::FIELD_SAVE, self::TRANSLATION_SAVE));
     $this->addField($factory->createSubmitField(self::FIELD_CANCEL, self::TRANSLATION_CANCEL));
 }
 /**
  * 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, $node, $properties);
     $translator = I18n::getInstance()->getTranslator();
     $fieldFactory = FieldFactory::getInstance();
     $parameterId = $properties->getParameterId();
     $parameterIdField = $fieldFactory->createField(FieldFactory::TYPE_OPTION, self::FIELD_PARAMETER_ID, $parameterId);
     $parameterIdField->setOptions($this->getParameterIdOptions($translator));
     $this->addField($parameterIdField);
 }
 /**
  * Constructs a new localize panel form
  * @return null
  */
 public function __construct()
 {
     $request = Zibo::getInstance()->getRequest();
     $factory = FieldFactory::getInstance();
     parent::__construct($request->getBaseUrl() . Request::QUERY_SEPARATOR . Module::ROUTE_LOCALIZE, self::NAME);
     $this->removeFromClass(Form::STYLE_FORM);
     $localeCode = LocalizeController::getLocale();
     $localeField = $factory->createField(FieldFactory::TYPE_LOCALE, self::FIELD_LOCALE, $localeCode);
     $this->addField($localeField);
 }
 /**
  * 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);
 }
 /**
  * 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);
 }
 /**
  * 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);
 }
 /**
  * Construct this form
  * @param string $action url where this form will point to
  * @param array $contentTypes Array with the name of searchable content types
  * @return null
  */
 public function __construct($action, array $contentTypes = null)
 {
     parent::__construct($action, self::NAME);
     $factory = FieldFactory::getInstance();
     $contentTypesField = $factory->createField(FieldFactory::TYPE_LIST, self::FIELD_CONTENT_TYPES, $contentTypes);
     $contentTypesField->setOptions($this->getSearchableContentTypeOptions());
     $contentTypesField->setIsMultiple(true);
     $this->addField($contentTypesField);
     $this->addField($factory->createSubmitField(self::FIELD_SAVE, self::TRANSLATION_SAVE));
     $this->addField($factory->createSubmitField(self::FIELD_CANCEL, self::TRANSLATION_CANCEL));
 }
 /**
  * Constructs a new subscribe form
  * @param string $action URL where this form will point to
  * @return null
  */
 public function __construct($action)
 {
     parent::__construct($action, self::NAME);
     $this->appendToClass('data');
     $fieldFactory = FieldFactory::getInstance();
     $emailField = $fieldFactory->createField(FieldFactory::TYPE_EMAIL, self::FIELD_EMAIL);
     $subscribeButton = $fieldFactory->createSubmitField(self::BUTTON_SUBSCRIBE, self::TRANSLATION_SUBSCRIBE);
     $this->addField($emailField);
     $this->addField($subscribeButton);
     $validatorFactory = ValidationFactory::getInstance();
     $this->addValidator(self::FIELD_EMAIL, $validatorFactory->createValidator('required'));
 }
 /**
  * Decorates the cell with the option for the File
  * @param zibo\library\html\table\Cell $cell Cell to decorate
  * @param zibo\library\html\table\Row $row Row of the cell to decorate
  * @param integer $rowNumber Number of the current row
  * @param array $remainingValues Array containing the values of the remaining rows of the table
  * @return null
  */
 public function decorate(Cell $cell, Row $row, $rowNumber, array $remainingValues)
 {
     $file = $cell->getValue();
     if (!$file instanceof File) {
         return;
     }
     $fieldFactory = FieldFactory::getInstance();
     $field = $fieldFactory->createField(FieldFactory::TYPE_OPTION, ExtendedTable::FIELD_ID, $file->getPath());
     $field->setIsMultiple(true);
     $cell->appendToClass(FileActionDecorator::CLASS_ACTION);
     $cell->setValue($field->getHtml());
 }
 /**
  * Constructs a new properties form for the contact widget
  * @param unknown_type $action
  * @param unknown_type $recipient
  * @param unknown_type $subject
  */
 public function __construct($action, $recipient, $subject)
 {
     parent::__construct($action, self::NAME, self::TRANSLATION_SUBMIT);
     $fieldFactory = FieldFactory::getInstance();
     $recipientField = $fieldFactory->createField(FieldFactory::TYPE_EMAIL, self::FIELD_RECIPIENT, $recipient);
     $subjectField = $fieldFactory->createField(FieldFactory::TYPE_STRING, self::FIELD_SUBJECT, $subject);
     $this->addField($recipientField);
     $this->addField($subjectField);
     $requiredValidator = new RequiredValidator();
     $this->addValidator(self::FIELD_RECIPIENT, $requiredValidator);
     $this->addValidator(self::FIELD_SUBJECT, $requiredValidator);
 }
 /**
  * Constructs a new cron process form
  * @param string $action URL where this form will point to
  * @param boolean $isRunning Flag to see if the cron process is currently running
  * @return null
  */
 public function __construct($action, $isRunning)
 {
     parent::__construct($action, self::NAME);
     $fieldFactory = FieldFactory::getInstance();
     if ($isRunning) {
         $translationKey = self::TRANSLATION_STOP;
     } else {
         $translationKey = self::TRANSLATION_START;
     }
     $submitButton = $fieldFactory->createSubmitField(self::BUTTON_SUBMIT, $translationKey);
     $this->addField($submitButton);
 }