Skip to content

Commit

Permalink
Merge pull request #18 from jmverges/welcomeModule
Browse files Browse the repository at this point in the history
[FEATURE] Site module
  • Loading branch information
bjo3rnf committed Nov 7, 2015
2 parents fb950bf + 8cf9934 commit 9f1f4e1
Show file tree
Hide file tree
Showing 15 changed files with 370 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Classes/Command/SiteCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace FluidTYPO3\Site\Command;

/*
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
* This file is part of the FluidTYPO3/Site project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
Expand Down
92 changes: 92 additions & 0 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php
namespace FluidTYPO3\Site\Controller;

/*
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/

use FluidTYPO3\Builder\Analysis\Fluid\TemplateAnalyzer;
use FluidTYPO3\Builder\Analysis\Metric;
use FluidTYPO3\Builder\Result\ParserResult;
use FluidTYPO3\Builder\Service\ExtensionService;
use FluidTYPO3\Builder\Service\SyntaxService;
use FluidTYPO3\Builder\Utility\ExtensionUtility;
use FluidTYPO3\Site\Service\EnterpriseLevelEnumeration;
use FluidTYPO3\Site\Service\KickStarterService;
use TYPO3\CMS\Backend\Template\DocumentTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;

/**
* Class BackendController
* @package FluidTYPO3\Site\Controller
*/
class BackendController extends ActionController {



/**
* @var KickStarterService
*/
protected $kickStarterService;


/**
* @param KickStarterService $kickStarterService
* @return void
*/
public function injectKickStarterService(KickStarterService $kickStarterService) {
$this->kickStarterService = $kickStarterService;
}

/**
* @param string $view
* @return void
*/
public function indexAction($view = 'Index') {
$extensions = [
EnterpriseLevelEnumeration::BY_DEFAULT => EnterpriseLevelEnumeration::BY_DEFAULT,
EnterpriseLevelEnumeration::MINIMALIST => EnterpriseLevelEnumeration::MINIMALIST,
EnterpriseLevelEnumeration::SMALL => EnterpriseLevelEnumeration::SMALL,
EnterpriseLevelEnumeration::MEDIUM => EnterpriseLevelEnumeration::MEDIUM,
EnterpriseLevelEnumeration::LARGE => EnterpriseLevelEnumeration::LARGE
];

$this->view->assign('csh', BackendUtility::wrapInHelp('site', 'modules'));
$this->view->assign('view', $view);
$this->view->assign('extensionSelectorOptions', $extensions);

}

/**
* @param string $mass
* @param bool $makeResources
* @param bool $makeMountPoint
* @param string $extensionKey
* @param null $author
* @param null $title
* @param null $description
* @param bool $useVhs
* @param bool $useFluidcontentCore
* @param bool $pages
* @param bool $content
* @param bool $backend
* @param bool $controllers
*/
public function buildSiteAction($mass = EnterpriseLevelEnumeration::BY_DEFAULT, $makeResources = TRUE, $makeMountPoint = TRUE, $extensionKey = NULL, $author = NULL, $title = NULL, $description = NULL, $useVhs = TRUE, $useFluidcontentCore = TRUE, $pages = TRUE, $content = TRUE, $backend = FALSE, $controllers = TRUE) {
$view = 'buildSite';
$this->view->assign('csh', BackendUtility::wrapInHelp('builder', 'modules'));
$this->view->assign('view', $view);
$output = $this->kickStarterService->generateFluidPoweredSite($mass, $makeResources, $makeMountPoint, $extensionKey, $author, $title, $description, $useVhs, $useFluidcontentCore, $pages, $content, $backend, $controllers);
$this->view->assign('output', $output);
}




}
116 changes: 77 additions & 39 deletions Classes/Service/KickStarterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extensionmanager\Utility\ListUtility;

class KickStarterService implements SingletonInterface {

Expand Down Expand Up @@ -41,17 +42,17 @@ class KickStarterService implements SingletonInterface {

EnterpriseLevelEnumeration::BY_DEFAULT => array(),
EnterpriseLevelEnumeration::MINIMALIST => array(
'about', 'aboutmodules', 'belog', 'beuser', 'context_help', 'extra_page_cm_options', 'felogin', 'form', 'impexp',
'about', 'aboutmodules', 'belog', 'beuser', 'context_help', 'felogin', 'form', 'impexp',
'info_pagetsconfig', 'info', 'reports', 'setup', 'sys_note', 'viewpage', 'wizard_crpages', 'wizard_sortpages',
'func_wizards', 'func', 'documentation', 'lowlevel', 'perm'
'func', 'documentation', 'lowlevel'
),
EnterpriseLevelEnumeration::SMALL => array(
'about', 'aboutmodules', 'belog', 'beuser', 'context_help', 'extra_page_cm_options', 'impexp', 'info_pagetsconfig',
'wizard_crpages', 'wizard_sortpages', 'func_wizards', 'func', 'documentation', 'lowlevel',
'about', 'aboutmodules', 'belog', 'beuser', 'context_help', 'impexp', 'info_pagetsconfig',
'wizard_crpages', 'wizard_sortpages', 'func', 'documentation', 'lowlevel',
),
EnterpriseLevelEnumeration::MEDIUM => array(
'about', 'aboutmodules', 'context_help', 'impexp', 'info_pagetsconfig', 'wizard_crpages', 'wizard_sortpages',
'func_wizards', 'func', 'documentation'
'func', 'documentation'
),
EnterpriseLevelEnumeration::LARGE => array(
'about', 'aboutmodules', 'context_help', 'documentation'
Expand Down Expand Up @@ -139,28 +140,38 @@ protected function prepareSettings($mass, $makeResources, $makeMountPoint, $exte
public function generateFluidPoweredSite($mass = EnterpriseLevelEnumeration::BY_DEFAULT, $makeResources = TRUE, $makeMountPoint = TRUE, $extensionKey = NULL, $author = NULL, $title = NULL, $description = NULL, $useVhs = TRUE, $useFluidcontentCore = TRUE, $pages = TRUE, $content = TRUE, $backend = FALSE, $controllers = TRUE) {
list($mass, $makeResources, $makeMountPoint, $extensionKey, $author, $title, $description, $useVhs, $useFluidcontentCore, $pages, $content, $backend, $controllers) = $this->prepareSettings($mass, $makeResources, $makeMountPoint, $extensionKey, $author, $title, $description, $useVhs, $useFluidcontentCore, $pages, $content, $backend, $controllers);

if (TRUE === ExtensionManagementUtility::isLoaded($extensionKey)) {
return NULL;
}
$vendorExtensionKey = $extensionKey;
$extensionKey = $this->getExtensionKeyFromVendorExtensionKey($extensionKey);

$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['core'] = array(
'backend' => 'TYPO3\\CMS\\Core\\Cache\\Backend\\NullBackend',
);

if (TRUE === ExtensionManagementUtility::isLoaded('css_styled_content')) {
$this->deleteExtensionAndFiles('css_styled_content');
}
$this->kickstartProviderExtension($extensionKey, $author, $title, $description, $useVhs, $useFluidcontentCore, $pages, $content, $backend, $controllers, $dry, $verbose);

if (FALSE === ExtensionManagementUtility::isLoaded($extensionKey)) {
$this->kickstartProviderExtension($extensionKey, $vendorExtensionKey, $author, $title, $description, $useVhs, $useFluidcontentCore, $pages, $content, $backend, $controllers);
}

if (TRUE === $makeResources) {
$topPageUid = $this->createPageResources($extensionKey);
$topPageUid = $this->createPageResources($vendorExtensionKey);
} else {
$topPageUid = reset($GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('uid', 'pages', "pid = '0'"));
}
$this->createTypoScriptTemplate($topPageUid, $extensionKey);
$this->createTypoScriptTemplate($topPageUid, self::DEFAULT_EXTENSION_TITLE, $extensionKey);
if (TRUE === $makeMountPoint) {
$this->createMountPoint($extensionKey);
}
$this->createDomainRecord($topPageUid);

foreach (array_reverse($this->extensionRemovals[EnterpriseLevelEnumeration::MINIMALIST]) as $installExtensionKey) {
if (FALSE === ExtensionManagementUtility::isLoaded($installExtensionKey)) {
$this->installExtension($installExtensionKey);
}
}

foreach ($this->extensionRemovals[$mass] as $removeExtensionKey) {
$this->uninstallExtension($removeExtensionKey);
}
Expand All @@ -175,9 +186,9 @@ public function generateFluidPoweredSite($mass = EnterpriseLevelEnumeration::BY_
* @param string $extensionKey
* @return integer
*/
protected function createPageResources($extensionKey) {
protected function createPageResources($extensionKey, $defaultTemplate = 'standard') {
syslog(LOG_WARNING, 'Would generate four pages with template selections for ' . $extensionKey);
$template = "'" . $extensionKey . "->Standard'";
$template = "'" . $extensionKey . '->' . $defaultTemplate . "'";
$page1 = $this->createPageInsertionQuery(0, 'Front', 1, $template, $template);
$GLOBALS['TYPO3_DB']->sql_query($page1);
$pages = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('uid', 'pages', '1=1', '', 'crdate DESC');
Expand All @@ -200,11 +211,7 @@ protected function createPageResources($extensionKey) {
* @return string
*/
protected function createPageInsertionQuery($pid, $pageTitle, $isRoot, $selectedThisTemplate, $selectedSubTemplate) {
$query = '
INSERT INTO `pages` (`pid`, `tstamp`, `crdate`, `hidden`, `title`, `doktype`, `is_siteroot`, `backend_layout`,
`backend_layout_next_level`, `tx_fed_page_controller_action`, `tx_fed_page_controller_action_sub`)
VALUES (%d, %d, %d, 1, \'%s\', %s, %s, \'fluidpages__fluidpages\', \'fluidpages__fluidpages\', %s, %s);
';
$query = 'INSERT INTO `pages` (`pid`, `tstamp`, `crdate`, `hidden`, `title`, `doktype`, `is_siteroot`, `backend_layout`, `backend_layout_next_level`, `tx_fed_page_controller_action`, `tx_fed_page_controller_action_sub`) VALUES (%d, %d, %d, 1, \'%s\', %s, %s, \'fluidpages__fluidpages\', \'fluidpages__fluidpages\', %s, %s);';
$query = sprintf($query, $pid, time(), time(), $pageTitle, (string) $isRoot, (string) $isRoot, $selectedThisTemplate, $selectedSubTemplate);
return $query;
}
Expand All @@ -214,12 +221,9 @@ protected function createPageInsertionQuery($pid, $pageTitle, $isRoot, $selected
* @param string $extensionKey
* @return void
*/
protected function createTypoScriptTemplate($topPageUid, $extensionKey) {
$query = '
INSERT INTO `sys_template` (`pid`, `tstamp`, `crdate`, `title`, `sitetitle`, `root`, `include_static_file`)
VALUES (%d, %d, %d, \'ROOT\', \'%s\', 1, \'EXT:fluidcontent_core/Configuration/TypoScript, EXT:%s/Configuration/TypoScript\');
';
$query = sprintf($query, $topPageUid, time(), time(), self::DEFAULT_TYPOSCRIPT_TEMPLATE_TITLE, $extensionKey);
protected function createTypoScriptTemplate($topPageUid, $title, $extensionKey) {
$query = 'INSERT INTO `sys_template` (`pid`, `tstamp`, `crdate`, `title`, `sitetitle`, `root`, `include_static_file`) VALUES (%d, %d, %d, \'ROOT\', \'%s\', 1, \'EXT:fluidcontent_core/Configuration/TypoScript, EXT:%s/Configuration/TypoScript\');';
$query = sprintf($query, $topPageUid, time(), time(), $title, $extensionKey);
$GLOBALS['TYPO3_DB']->sql_query($query);
}

Expand All @@ -228,10 +232,7 @@ protected function createTypoScriptTemplate($topPageUid, $extensionKey) {
* @return void
*/
protected function createDomainRecord($topPageUid) {
$query = '
INSERT INTO `sys_domain` (`pid`, `tstamp`, `crdate`, `domainName`)
VALUES (%d, %d, %d, \'%s\');
';
$query = 'INSERT INTO `sys_domain` (`pid`, `tstamp`, `crdate`, `domainName`) VALUES (%d, %d, %d, \'%s\');';
$query = sprintf($query, $topPageUid, time(), time(), $_SERVER['SERVER_NAME']);
$GLOBALS['TYPO3_DB']->sql_query($query);
}
Expand All @@ -241,12 +242,7 @@ protected function createDomainRecord($topPageUid) {
* @return void
*/
protected function createMountPoint($extensionKey) {
$query = '
INSERT INTO `sys_file_storage` (`pid`, `tstamp`, `crdate`, `name`, `description`, `driver`, `configuration`, `is_default`, `is_browsable`, `is_public`, `is_writable`, `is_online`, `processingfolder`)
VALUES
(0, %d, %d, \'%s assets\', \'Access to site asset files\', \'Local\', \'<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"
?>\n<T3FlexForms>\n <data>\n <sheet index=\"sDEF\">\n <language index=\"lDEF\">\n <field index=\"basePath\">\n <value index=\"vDEF\">%s</value>\n </field>\n <field index=\"pathType\">\n <value index=\"vDEF\">relative</value>\n </field>\n <field index=\"caseSensitive\">\n <value index=\"vDEF\">1</value>\n </field>\n </language>\n </sheet>\n </data>\n</T3FlexForms>\', 0, 1, 1, 1, 1, NULL);
';
$query = 'INSERT INTO `sys_file_storage` (`pid`, `tstamp`, `crdate`, `name`, `description`, `driver`, `configuration`, `is_default`, `is_browsable`, `is_public`, `is_writable`, `is_online`, `processingfolder`) VALUES (0, %d, %d, \'%s assets\', \'Access to site asset files\', \'Local\', \'<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n<T3FlexForms>\n <data>\n <sheet index=\"sDEF\">\n <language index=\"lDEF\">\n <field index=\"basePath\">\n <value index=\"vDEF\">%s</value>\n </field>\n <field index=\"pathType\">\n <value index=\"vDEF\">relative</value>\n </field>\n <field index=\"caseSensitive\">\n <value index=\"vDEF\">1</value>\n </field>\n </language>\n </sheet>\n </data>\n</T3FlexForms>\', 0, 1, 1, 1, 1, NULL);';
$query = sprintf($query, time(), time(), $extensionKey, ExtensionManagementUtility::siteRelPath($extensionKey));
$GLOBALS['TYPO3_DB']->sql_query($query);
}
Expand Down Expand Up @@ -289,15 +285,57 @@ protected function installExtension($extensionKey) {
* @throws \Exception
* @internal param bool $keepBuilder
*/
protected function kickstartProviderExtension($extensionKey, $author, $title, $description, $useVhs, $useFluidcontentCore, $pages, $content, $backend, $controllers) {
protected function kickstartProviderExtension($extensionKey, $vendorExtensionKey, $author, $title, $description, $useVhs, $useFluidcontentCore, $pages, $content, $backend, $controllers) {
/** @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager */
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$extensions = $this->gatherInformation();

if (FALSE === array_key_exists($extensionKey, $extensions)) {
/** @var \FluidTYPO3\Builder\Service\ExtensionService $extensionService */
$extensionService = $objectManager->get('FluidTYPO3\\Builder\\Service\\ExtensionService');
$generator = $extensionService->buildProviderExtensionGenerator($vendorExtensionKey, $author, $title, $description, $controllers, $pages, $content, $backend, $useVhs, $useFluidcontentCore);
$generator->generate();
}

/** @var ListUtility $service */
$service = $objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
$service->reloadAvailableExtensions();

/** @var \TYPO3\CMS\Extensionmanager\Utility\InstallUtility $installUtility */
$installUtility = $objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\InstallUtility');
/** @var \FluidTYPO3\Builder\Service\ExtensionService $extensionService */
$extensionService = $objectManager->get('FluidTYPO3\\Builder\\Service\\ExtensionService');
$generator = $extensionService->buildProviderExtensionGenerator($extensionKey, $author, $title, $description, $controllers, $pages, $content, $backend, $useVhs, $useFluidcontentCore);
$generator->generate();
$installUtility->install($extensionKey);
}

/**
* @return string
*/
protected function getExtensionKeyFromVendorExtensionKey($extensionKey) {
if (FALSE !== strpos($extensionKey, '.')) {
$extensionKey = array_pop(explode('.', $extensionKey));
}
return GeneralUtility::camelCaseToLowerCaseUnderscored($extensionKey);
}


/**
* Gathers Extension Information
*
* @return array
*/
private function gatherInformation() {
/** @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager */
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
/** @var ListUtility $service */
$service = $objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');

$extensionInformation = $service->getAvailableExtensions();
foreach ($extensionInformation as $extensionKey => $info) {
if (TRUE === array_key_exists($extensionKey, $GLOBALS['TYPO3_LOADED_EXT'])) {
$extensionInformation[$extensionKey]['installed'] = 1;
} else {
$extensionInformation[$extensionKey]['installed'] = 0;
}
}
return $extensionInformation;
}
}
17 changes: 17 additions & 0 deletions Resources/Private/Language/Module/locallang_csh.xlf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
<file t3:id="1415814985" source-language="en" datatype="plaintext" original="messages" date="2011-10-17T20:22:37Z" product-name="builder">
<header/>
<body>
<trans-unit id="mlang_tabs_tab" xml:space="preserve">
<source>Kick Starter</source>
</trans-unit>
<trans-unit id="mlang_labels_tablabel" xml:space="preserve">
<source>Kick Starter</source>
</trans-unit>
<trans-unit id="modules.alttitle" xml:space="preserve">
<source>Kick Starter</source>
</trans-unit>
</body>
</file>
</xliff>
44 changes: 44 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0"?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" product-name="builder" date="2015-03-14T22:24:42+01:00">
<header/>
<body>
<trans-unit id="mlang_tabs_tab" xml:space="preserve">
<source>Site</source>
</trans-unit>
<trans-unit id="mlang_labels_tablabel" xml:space="preserve">
<source>Site</source>
</trans-unit>
<trans-unit id="modules.alttitle" xml:space="preserve">
<source>Site</source>
</trans-unit>
<trans-unit id="modules.description" xml:space="preserve">
<source>The Site provides a site</source>
</trans-unit>
<trans-unit id="header.index" xml:space="preserve">
<source>Site - Site Kick Starter</source>
</trans-unit>
<trans-unit id="header.index.title" xml:space="preserve">
<source>Configure a FluidTYPO3 site</source>
</trans-unit>
<trans-unit id="options.mass" xml:space="preserve">
<source>Site enterprise level: If you wish, select the expected size of your site here. Depending on your selection, system extensions will be installed or uninstalled to create a sane default extension collection that suits your site. The "medium" option is approximately the same as the default except without the documentation-related extensions. Choose "large" if your site is targed at multiple editors, languages or otherwise requires many CMS features.</source>
</trans-unit>
<trans-unit id="options.makeResources" xml:space="preserve">
<source>Create resources: Check this checkbox to create a top-level page with preset template selections, three sub-pages, one domain record based on the current host name you use and one root TypoScript record in which the necessary static TypoScript templates are pre-included.</source>
</trans-unit>
<trans-unit id="options.makeMountPoint" xml:space="preserve">
<source>Create FAL mount point: Check this to create a file system mount point allowing you to access your templates and asset files using the "File list" module" and reference your templates and asset files from "file" type fields in your pages and content properties.</source>
</trans-unit>
<trans-unit id="submit.validate" xml:space="preserve">
<source>Submit</source>
</trans-unit>
<trans-unit id="providerextension.name" xml:space="preserve">
<source>Extension Key: We will create for you an extension with this name if the extension is not found in the system.</source>
</trans-unit>



</body>
</file>
</xliff>

0 comments on commit 9f1f4e1

Please sign in to comment.