/**
  * Returns the form definitions for the step
  *
  * @param FormDefinition $formDefinition
  * @return void
  */
 protected function buildForm(FormDefinition $formDefinition)
 {
     $page1 = $formDefinition->createPage('page1');
     $page1->setRenderingOption('header', 'Create administrator account');
     $introduction = $page1->createElement('introduction', 'Neos.Form:StaticText');
     $introduction->setProperty('text', 'Enter the personal data and credentials for your backend account:');
     $personalSection = $page1->createElement('personalSection', 'Neos.Form:Section');
     $personalSection->setLabel('Personal Data');
     $firstName = $personalSection->createElement('firstName', 'Neos.Form:SingleLineText');
     $firstName->setLabel('First name');
     $firstName->addValidator(new NotEmptyValidator());
     $firstName->addValidator(new StringLengthValidator(array('minimum' => 1, 'maximum' => 255)));
     $lastName = $personalSection->createElement('lastName', 'Neos.Form:SingleLineText');
     $lastName->setLabel('Last name');
     $lastName->addValidator(new NotEmptyValidator());
     $lastName->addValidator(new StringLengthValidator(array('minimum' => 1, 'maximum' => 255)));
     $credentialsSection = $page1->createElement('credentialsSection', 'Neos.Form:Section');
     $credentialsSection->setLabel('Credentials');
     $username = $credentialsSection->createElement('username', 'Neos.Form:SingleLineText');
     $username->setLabel('Username');
     $username->addValidator(new NotEmptyValidator());
     $username->addValidator(new UserDoesNotExistValidator());
     $password = $credentialsSection->createElement('password', 'Neos.Form:PasswordWithConfirmation');
     $password->addValidator(new NotEmptyValidator());
     $password->addValidator(new StringLengthValidator(array('minimum' => 6, 'maximum' => 255)));
     $password->setLabel('Password');
     $password->setProperty('passwordDescription', 'At least 6 characters');
     $formDefinition->setRenderingOption('skipStepNotice', 'If you skip this step make sure that you have an existing user or create one with the user:create command');
 }
Example #2
0
 /**
  * Returns the form definitions for the step
  *
  * @param \Neos\Form\Core\Model\FormDefinition $formDefinition
  * @return void
  */
 protected function buildForm(\Neos\Form\Core\Model\FormDefinition $formDefinition)
 {
     $page1 = $formDefinition->createPage('page1');
     $page1->setRenderingOption('header', 'Setup complete');
     $title = $page1->createElement('connectionSection', 'Neos.Form:Section');
     $title->setLabel('Congratulations');
     $success = $title->createElement('success', 'Neos.Form:StaticText');
     $success->setProperty('text', 'You successfully completed the setup');
     $success->setProperty('elementClassAttribute', 'alert alert-success');
     $link = $title->createElement('link', 'Neos.Setup:LinkElement');
     $link->setLabel('Go to the homepage');
     $link->setProperty('href', '/');
     $link->setProperty('elementClassAttribute', 'btn btn-large btn-primary');
     $info = $title->createElement('info', 'Neos.Form:StaticText');
     $info->setProperty('text', 'If the homepage doesn\'t work, you might need configure routing in Configuration/Routes.yaml');
     $info->setProperty('elementClassAttribute', 'alert alert-info');
     $loggedOut = $page1->createElement('loggedOut', 'Neos.Form:StaticText');
     $loggedOut->setProperty('text', 'You have automatically been logged out for security reasons since this is the final step. Refresh the page to log in again if you missed something.');
     $loggedOut->setProperty('elementClassAttribute', 'alert alert-info');
 }
 /**
  * Returns the form definitions for the step
  *
  * @param FormDefinition $formDefinition
  * @return void
  */
 protected function buildForm(FormDefinition $formDefinition)
 {
     $page1 = $formDefinition->createPage('page1');
     $page1->setRenderingOption('header', 'Setup complete');
     $congratulations = $page1->createElement('congratulationsSection', 'Neos.Form:Section');
     $congratulations->setLabel('Congratulations');
     $success = $congratulations->createElement('success', 'Neos.Form:StaticText');
     $success->setProperty('text', 'You have successfully installed Neos! If you need help getting started, please refer to the Neos documentation.');
     $success->setProperty('elementClassAttribute', 'alert alert-success');
     $docs = $congratulations->createElement('docsLink', 'Neos.Setup:LinkElement');
     $docs->setLabel('Read the documentation');
     $docs->setProperty('href', 'https://neos.readthedocs.org/');
     $docs->setProperty('target', '_blank');
     $contextEnv = Bootstrap::getEnvironmentConfigurationSetting('FLOW_CONTEXT') ?: 'Development';
     $applicationContext = new ApplicationContext($contextEnv);
     if (!$applicationContext->isProduction()) {
         $context = $page1->createElement('contextSection', 'Neos.Form:Section');
         $context->setLabel('Define application context');
         $contextInfo = $context->createElement('contextInfo', 'Neos.Form:StaticText');
         $contextInfo->setProperty('text', 'Your Neos installation is currently not running in "Production" context. If you want to experience Neos with its full speed, you should now change your FLOW_CONTEXT environment variable to "Production".');
         $contextDocs = $context->createElement('contextDocsLink', 'Neos.Setup:LinkElement');
         $contextDocs->setLabel('Read about application contexts');
         $contextDocs->setProperty('href', 'http://flowframework.readthedocs.org/en/stable/TheDefinitiveGuide/PartIII/Bootstrapping.html#the-typo3-flow-application-context');
         $contextDocs->setProperty('target', '_blank');
     }
     $frontend = $page1->createElement('frontendSection', 'Neos.Form:Section');
     $frontend->setLabel('View the site');
     $link = $frontend->createElement('link', 'Neos.Setup:LinkElement');
     $link->setLabel('Go to the frontend');
     $link->setProperty('href', '/');
     $link->setProperty('elementClassAttribute', 'btn btn-large btn-primary');
     $backend = $page1->createElement('backendSection', 'Neos.Form:Section');
     $backend->setLabel('Start editing');
     $backendLink = $backend->createElement('backendLink', 'Neos.Setup:LinkElement');
     $backendLink->setLabel('Go to the backend');
     $backendLink->setProperty('href', '/neos');
     $backendLink->setProperty('elementClassAttribute', 'btn btn-large btn-primary');
     $loggedOut = $page1->createElement('loggedOut', 'Neos.Form:StaticText');
     $loggedOut->setProperty('text', 'You have automatically been logged out for security reasons since this is the final step. Refresh the page to log in again if you missed something.');
     $loggedOut->setProperty('elementClassAttribute', 'alert alert-info');
 }
    /**
     * {@inheritdoc}
     */
    protected function buildForm(FormDefinition $formDefinition)
    {
        $page1 = $formDefinition->createPage('page1');
        $page1->setRenderingOption('header', 'Neos requirements check');
        $imageSection = $page1->createElement('connectionSection', 'Neos.Form:Section');
        $imageSection->setLabel('Image Manipulation');
        $formElement = $imageSection->createElement('imageLibrariesInfo', 'Neos.Form:StaticText');
        $formElement->setProperty('text', 'We checked for supported image manipulation libraries on your server.
		Only one is needed and we select the best one available for you.
		Using GD in production environment is not recommended as it has some issues and can easily lead to blank pages due to memory exhaustion.');
        $formElement->setProperty('elementClassAttribute', 'alert alert-primary');
        $foundImageHandler = false;
        foreach (array('gd', 'gmagick', 'imagick') as $extensionName) {
            $formElement = $imageSection->createElement($extensionName, 'Neos.Form:StaticText');
            if (extension_loaded($extensionName)) {
                $unsupportedFormats = $this->findUnsupportedImageFormats($extensionName);
                if (count($unsupportedFormats) === 0) {
                    $formElement->setProperty('text', 'PHP extension "' . $extensionName . '" is installed');
                    $formElement->setProperty('elementClassAttribute', 'alert alert-info');
                    $foundImageHandler = $extensionName;
                } else {
                    $formElement->setProperty('text', 'PHP extension "' . $extensionName . '" is installed but lacks support for ' . implode(', ', $unsupportedFormats));
                    $formElement->setProperty('elementClassAttribute', 'alert alert-default');
                }
            } else {
                $formElement->setProperty('text', 'PHP extension "' . $extensionName . '" is not installed');
                $formElement->setProperty('elementClassAttribute', 'alert alert-default');
            }
        }
        if ($foundImageHandler === false) {
            $formElement = $imageSection->createElement('noImageLibrary', 'Neos.Form:StaticText');
            $formElement->setProperty('text', 'No suitable PHP extension for image manipulation was found. You can continue the setup but be aware that Neos might not work correctly without one of these extensions.');
            $formElement->setProperty('elementClassAttribute', 'alert alert-error');
        } else {
            $formElement = $imageSection->createElement('configuredImageLibrary', 'Neos.Form:StaticText');
            $formElement->setProperty('text', 'Neos will be configured to use extension "' . $foundImageHandler . '"');
            $formElement->setProperty('elementClassAttribute', 'alert alert-success');
            $hiddenField = $imageSection->createElement('imagineDriver', 'Neos.Form:HiddenField');
            $hiddenField->setDefaultValue(ucfirst($foundImageHandler));
        }
    }
Example #5
0
 /**
  * Returns the form definitions for the step
  *
  * @param FormDefinition $formDefinition
  * @return void
  */
 protected function buildForm(FormDefinition $formDefinition)
 {
     $page1 = $formDefinition->createPage('page1');
     $page1->setRenderingOption('header', 'Configure database');
     $introduction = $page1->createElement('introduction', 'Neos.Form:StaticText');
     $introduction->setProperty('text', 'Please enter database details below:');
     $connectionSection = $page1->createElement('connectionSection', 'Neos.Form:Section');
     $connectionSection->setLabel('Connection');
     $databaseDriver = $connectionSection->createElement('driver', 'Neos.Form:SingleSelectDropdown');
     $databaseDriver->setLabel('DB Driver');
     $databaseDriver->setProperty('options', $this->getAvailableDrivers());
     $databaseDriver->setDefaultValue(Arrays::getValueByPath($this->distributionSettings, 'Neos.Flow.persistence.backendOptions.driver'));
     $databaseDriver->addValidator(new NotEmptyValidator());
     $databaseUser = $connectionSection->createElement('user', 'Neos.Form:SingleLineText');
     $databaseUser->setLabel('DB Username');
     $databaseUser->setDefaultValue(Arrays::getValueByPath($this->distributionSettings, 'Neos.Flow.persistence.backendOptions.user'));
     $databaseUser->addValidator(new NotEmptyValidator());
     $databasePassword = $connectionSection->createElement('password', 'Neos.Form:Password');
     $databasePassword->setLabel('DB Password');
     $databasePassword->setDefaultValue(Arrays::getValueByPath($this->distributionSettings, 'Neos.Flow.persistence.backendOptions.password'));
     $databaseHost = $connectionSection->createElement('host', 'Neos.Form:SingleLineText');
     $databaseHost->setLabel('DB Host');
     $defaultHost = Arrays::getValueByPath($this->distributionSettings, 'Neos.Flow.persistence.backendOptions.host');
     if ($defaultHost === null) {
         $defaultHost = '127.0.0.1';
     }
     $databaseHost->setDefaultValue($defaultHost);
     $databaseHost->addValidator(new NotEmptyValidator());
     $databaseSection = $page1->createElement('databaseSection', 'Neos.Form:Section');
     $databaseSection->setLabel('Database');
     $databaseName = $databaseSection->createElement('dbname', 'Neos.Setup:DatabaseSelector');
     $databaseName->setLabel('DB Name');
     $databaseName->setProperty('driverDropdownFieldId', $databaseDriver->getUniqueIdentifier());
     $databaseName->setProperty('userFieldId', $databaseUser->getUniqueIdentifier());
     $databaseName->setProperty('passwordFieldId', $databasePassword->getUniqueIdentifier());
     $databaseName->setProperty('hostFieldId', $databaseHost->getUniqueIdentifier());
     $databaseName->setDefaultValue(Arrays::getValueByPath($this->distributionSettings, 'Neos.Flow.persistence.backendOptions.dbname'));
     $databaseName->addValidator(new NotEmptyValidator());
 }
Example #6
0
 /**
  * Helper to be called by every AbstractFormFactory after everything has been built to trigger the "onBuildingFinished"
  * template method on all form elements.
  *
  * @param \Neos\Form\Core\Model\FormDefinition $form
  * @return void
  * @api
  */
 protected function triggerFormBuildingFinished(\Neos\Form\Core\Model\FormDefinition $form)
 {
     foreach ($form->getRenderablesRecursively() as $renderable) {
         $renderable->onBuildingFinished();
     }
 }
Example #7
0
 /**
  * @test
  */
 public function arrayAccessReturnsDefaultValuesIfSet()
 {
     $formDefinition = new FormDefinition('foo');
     $page1 = new Page('p1');
     $formDefinition->addPage($page1);
     $element1 = new \Neos\Form\FormElements\GenericFormElement('foo', 'Bar');
     $page1->addElement($element1);
     $element1->setDefaultValue('My Default');
     $formRuntime = $this->createFormRuntime($formDefinition);
     $formState = new \Neos\Form\Core\Runtime\FormState();
     $formRuntime->_set('formState', $formState);
     $this->assertSame($formState, $formRuntime->getFormState());
     $this->assertSame('My Default', $formRuntime['foo']);
     $formRuntime['foo'] = 'Overridden';
     $this->assertSame('Overridden', $formRuntime['foo']);
     $formRuntime['foo'] = null;
     $this->assertSame('My Default', $formRuntime['foo']);
     $formRuntime['foo'] = 'Overridden2';
     $this->assertSame('Overridden2', $formRuntime['foo']);
     unset($formRuntime['foo']);
     $this->assertSame('My Default', $formRuntime['foo']);
     $this->assertSame(null, $formRuntime['nonExisting']);
 }
Example #8
0
 /**
  * Get the label which shall be displayed next to the form element
  *
  * @return string
  * @api
  */
 public function getLabel()
 {
     return $this->formDefinition->getLabel();
 }
Example #9
0
 /**
  * @test
  * @dataProvider getUniqueIdentifierReplacesSpecialCharactersByUnderscoresProvider
  * @param string $formIdentifier
  * @param string $elementIdentifier
  * @param string $expectedResult
  */
 public function getUniqueIdentifierReplacesSpecialCharactersByUnderscores($formIdentifier, $elementIdentifier, $expectedResult)
 {
     $formDefinition = new FormDefinition($formIdentifier);
     $myFormElement = $this->getFormElement(array($elementIdentifier, 'Neos.Form:MyType'));
     $page = new Page('somePage');
     $formDefinition->addPage($page);
     $page->addElement($myFormElement);
     $this->assertSame($expectedResult, $myFormElement->getUniqueIdentifier());
 }
 /**
  * Returns the form definitions for the step
  *
  * @param FormDefinition $formDefinition
  * @return void
  */
 protected function buildForm(FormDefinition $formDefinition)
 {
     $page1 = $formDefinition->createPage('page1');
     $page1->setRenderingOption('header', 'Create a new site');
     $introduction = $page1->createElement('introduction', 'Neos.Form:StaticText');
     $introduction->setProperty('text', 'There are two ways of creating a site. Choose between the following:');
     $importSection = $page1->createElement('import', 'Neos.Form:Section');
     $importSection->setLabel('Import a site from an existing site package');
     $sitePackages = array();
     foreach ($this->packageManager->getFilteredPackages('available', null, 'neos-site') as $package) {
         $sitePackages[$package->getPackageKey()] = $package->getPackageKey();
     }
     if (count($sitePackages) > 0) {
         $site = $importSection->createElement('site', 'Neos.Form:SingleSelectDropdown');
         $site->setLabel('Select a site package');
         $site->setProperty('options', $sitePackages);
         $site->addValidator(new NotEmptyValidator());
         $sites = $this->siteRepository->findAll();
         if ($sites->count() > 0) {
             $prune = $importSection->createElement('prune', 'Neos.Form:Checkbox');
             $prune->setLabel('Delete existing sites');
         }
     } else {
         $error = $importSection->createElement('noSitePackagesError', 'Neos.Form:StaticText');
         $error->setProperty('text', 'No site packages were available, make sure you have an active site package');
         $error->setProperty('elementClassAttribute', 'alert alert-warning');
     }
     if ($this->packageManager->isPackageActive('Neos.SiteKickstarter')) {
         $separator = $page1->createElement('separator', 'Neos.Form:StaticText');
         $separator->setProperty('elementClassAttribute', 'section-separator');
         $newPackageSection = $page1->createElement('newPackageSection', 'Neos.Form:Section');
         $newPackageSection->setLabel('Create a new site package with a dummy site');
         $packageName = $newPackageSection->createElement('packageKey', 'Neos.Form:SingleLineText');
         $packageName->setLabel('Package Name (in form "Vendor.DomainCom")');
         $packageName->addValidator(new PackageKeyValidator());
         $siteName = $newPackageSection->createElement('siteName', 'Neos.Form:SingleLineText');
         $siteName->setLabel('Site Name (e.g. "domain.com")');
     } else {
         $error = $importSection->createElement('neosKickstarterUnavailableError', 'Neos.Form:StaticText');
         $error->setProperty('text', 'The Neos Kickstarter package (Neos.SiteKickstarter) is not installed, install it for kickstarting new sites (using "composer require typo3/neos-kickstarter")');
         $error->setProperty('elementClassAttribute', 'alert alert-warning');
     }
     $explanation = $page1->createElement('explanation', 'Neos.Form:StaticText');
     $explanation->setProperty('text', 'Notice the difference between a site package and a site. A site package is a Flow package that can be used for creating multiple site instances.');
     $explanation->setProperty('elementClassAttribute', 'alert alert-info');
     $step = $this;
     $callback = function (FinisherContext $finisherContext) use($step) {
         $step->importSite($finisherContext);
     };
     $this->closureFinisher = new ClosureFinisher();
     $this->closureFinisher->setOption('closure', $callback);
     $formDefinition->addFinisher($this->closureFinisher);
     $formDefinition->setRenderingOption('skipStepNotice', 'You can always import a site using the site:import command');
 }
Example #11
0
 /**
  * @test
  * @expectedException \Neos\Form\Exception\FinisherPresetNotFoundException
  */
 public function createFinisherThrowsExceptionIfFinisherPresetNotFound()
 {
     $formDefinition = new FormDefinition('foo1');
     $formDefinition->createFinisher('asdf');
 }