diff --git a/BackendModule/ConfigClientModule.php b/BackendModule/ConfigClientModule.php index dc963e1..f8020c1 100644 --- a/BackendModule/ConfigClientModule.php +++ b/BackendModule/ConfigClientModule.php @@ -72,6 +72,18 @@ public function generate() } } + $connection = MasterConnection::getInstance()->testConnection(); + + if( key_exists("ERROR", $connection) ) + { + if( preg_match('/connection failed/', strtolower($connection['ERROR'])) ) + { + $this->strTemplate = 'be_mod_iido_errorMaster'; + \Session::getInstance()->set("iidoMessage", $connection['ERROR']); + return parent::generate(); + } + } + return parent::generate(); } @@ -92,8 +104,13 @@ protected function compile() if( is_array($arrMessage) && count($arrMessage) ) { $strMessage = Message::render($arrMessage); - \Session::getInstance()->remove("iidoMessage"); } + else + { + $strMessage = Message::render( array("error"=>$arrMessage) ); + } + + \Session::getInstance()->remove("iidoMessage"); } $this->Template->masterData = $masterData; diff --git a/Connection/ClientSetup.php b/Connection/ClientSetup.php index 1b8bfd2..e49e835 100644 --- a/Connection/ClientSetup.php +++ b/Connection/ClientSetup.php @@ -180,10 +180,12 @@ protected function setUpContao() $varValue = $this->replaceVars( $varValue ); - $this->Config->update( "\$GLOBALS['TL_CONFIG']['" . $varName . "']", $varValue); + $this->Config->persist( $varName, $varValue); +// $this->Config->update( "\$GLOBALS['TL_CONFIG']['" . $varName . "']", $varValue); } - $this->Config->update( "\$GLOBALS['TL_CONFIG']['']", TRUE); +// $this->Config->update( "\$GLOBALS['TL_CONFIG']['']", TRUE); +// $this->Config->persist( 'iido_initSystem', TRUE); } @@ -366,6 +368,32 @@ protected function replaceVars( $varValue ) $funcName = $arrParts[1]; $varValue = str_replace($strChunk, $funcName(), $varValue); } + elseif( $arrParts[0] == "env" ) + { + $varValue = \Environment::get( $arrParts[1] ); + } + elseif( $arrParts[0] == "config" ) + { + $varValue = \Config::get( $arrParts[1] ); + } + elseif( $arrParts[0] == "cms" ) + { + switch( $arrParts[1] ) + { + case "version": + $packages = System::getContainer()->getParameter('kernel.packages'); + $varValue = $packages['contao/core-bundle']; + break; + + case "bundles": + $varValue = array_keys(System::getContainer()->getParameter('kernel.bundles') ); + break; + + case "packages": + $varValue = System::getContainer()->getParameter('kernel.packages'); + break; + } + } } else { @@ -382,6 +410,14 @@ protected function replaceVars( $varValue ) + public static function replaceStaticVars( $strContent ) + { + $self = new self(); + return $self->replaceVars( $strContent ); + } + + + protected function createPages( array $arrPages, array $arrAddToPage = array() ) { if( is_array($arrPages) && count($arrPages) ) diff --git a/Connection/MasterConnection.php b/Connection/MasterConnection.php index 3673666..bbe25c7 100644 --- a/Connection/MasterConnection.php +++ b/Connection/MasterConnection.php @@ -53,7 +53,14 @@ public static function getInstance() return self::$instance; } - + + + + public function testConnection() + { + return $this->getActionData("testConnection", array(), true); + } + public function setPassword( $pwd ) @@ -80,7 +87,13 @@ public function isPasswordValid() public function getData($returnAsArray = false) { $connectionUrl = $this->getConnectionUrl(); - $arrData = file_get_contents( $connectionUrl ); + $arrData = @file_get_contents( $connectionUrl ); + + if( !$arrData ) + { + return array("ERROR" => 'Connection Failed. Master not available! Please try again later.'); + } + $objData = json_decode($arrData, $returnAsArray); return $objData; @@ -91,7 +104,12 @@ public function getData($returnAsArray = false) public function getActionData( $actionName, array $actionParams = array(), $returnAsArray = false) { $connectionUrl = $this->getConnectionUrl() . '&act=' . $actionName . (count($actionParams)?'&':'') . implode('&', $actionParams); - $arrData = file_get_contents( $connectionUrl ); + $arrData = @file_get_contents( $connectionUrl ); + + if( !$arrData ) + { + return array("ERROR" => 'Connection Failed. Master not available! Please try again later.'); + } return json_decode($arrData, $returnAsArray); } @@ -115,7 +133,7 @@ public function redirectTo( $method = "", array $msg = array() ) if( $method ) { - \Controller::redirect( \Controller::addToUrl("do=iidoConfigContao&method=" . $method) ); + \Controller::redirect( \Controller::addToUrl("do=iidoConfigContao&method=" . $method) ); } else { @@ -135,7 +153,51 @@ public static function redirect( $method = "", array $msg = array() ) protected function getConnectionUrl() { $configData = $this->getConfigData(); - return $configData->domain . $configData->connection->publicPath . $configData->connection->file . '?pwd=' . static::$password; + return $configData->domain . $configData->connection->publicPath . $configData->connection->file . '?pwd=' . static::$password . $this->getConnectionUrlVars( $configData ); + } + + + + protected function getConnectionUrlVars( $configData = NULL ) + { + $requestVars = ""; + + if( $configData === NULL ) + { + $configData = $this->getConfigData(); + } + + foreach( (array) $configData->vars as $varName => $varData ) + { + $varDataParsed = ""; + $varData = \StringUtil::deserialize( $varData ); + + if( is_string($varData) ) + { + $varDataParsed = $varData; + } + else + { + $arrVarData = array(); + + foreach( (array) $varData as $key => $value ) + { + $arrVarData[ $key ] = ClientSetup::replaceStaticVars( $value ); + } + + if( count($arrVarData) ) + { + $varDataParsed = json_encode( $arrVarData ); + } + } + + if( $varDataParsed ) + { + $requestVars .= '&' . $varName . '=' . $varDataParsed; + } + } + + return $requestVars; } @@ -148,7 +210,7 @@ protected function validate( array $arrData ) { if( !\Input::get("method") == "login" ) { - \Controller::redirect( \Controller::addToUrl("do=iidoConfigContao&method=login") ); + \Controller::redirect( \Controller::addToUrl("do=iidoConfigContao&method=login") ); } } } diff --git a/EventListener/PageListener.php b/EventListener/PageListener.php index a38552f..3fd6d64 100644 --- a/EventListener/PageListener.php +++ b/EventListener/PageListener.php @@ -112,9 +112,9 @@ public function generateCustomizePage( \PageModel $objPage, \LayoutModel $objLay // $GLOBALS['TL_JAVASCRIPT'][] = 'web/bundles/' . $folderName . '/javascript/' . $jsPrefix . '/waypoints/inview.min.js|static'; // $GLOBALS['TL_JAVASCRIPT'][] = 'web/bundles/' . $folderName . '/javascript/' . $jsPrefix . '/waypoints/sticky.min.js|static'; - $GLOBALS['TL_JAVASCRIPT'][] = $this->bundlePathPublic . '/javascript/' . $jsPrefix . '/iido/IIDO.Base.js|static'; + $GLOBALS['TL_JAVASCRIPT']['iido_base'] = $this->bundlePathPublic . '/javascript/' . $jsPrefix . '/iido/IIDO.Base.js|static'; // $GLOBALS['TL_JAVASCRIPT'][] = 'web/bundles/' . $folderName . '/javascript/' . $jsPrefix . '/iido/IIDO.Functions.js|static'; - $GLOBALS['TL_JAVASCRIPT'][] = $this->bundlePathPublic . '/javascript/' . $jsPrefix . '/iido/IIDO.Page.js|static'; + $GLOBALS['TL_JAVASCRIPT']['iido_page'] = $this->bundlePathPublic . '/javascript/' . $jsPrefix . '/iido/IIDO.Page.js|static'; // $GLOBALS['TL_JAVASCRIPT'][] = 'web/bundles/' . $folderName . '/javascript/' . $jsPrefix . '/iido/IIDO.Content.js|static'; // if( $objLayout->loadJQueryUI ) @@ -126,7 +126,7 @@ public function generateCustomizePage( \PageModel $objPage, \LayoutModel $objLay if( $footerMode ) { - $GLOBALS['TL_CSS'][] = $this->bundlePathPublic . '/css/footer.css||static'; + $GLOBALS['TL_CSS']['footer'] = $this->bundlePathPublic . '/css/footer.css||static'; } if( $objLayout->loadDomainCSS ) @@ -287,39 +287,42 @@ public function modifyCustomizeFrontendPage($strBuffer, $templateName) { if( preg_match('/open-fullscreen-search/', $strBuffer) ) { - $strModule = \Controller::getFrontendModule( 3 ); - $pregMatch = '([A-Za-z0-9\s\-=",;.:_]{0,})'; + $objModule = \ModuleModel::findOneBy("type", "search"); + + if( $objModule ) + { + $strModule = \Controller::getFrontendModule( $objModule->id ); //6 + $pregMatch = '([A-Za-z0-9\s\-=",;.:_]{0,})'; // if( preg_match('//', $strModule, $arrMatches) ) // { // $strModule = preg_replace('/' . preg_quote($arrMatches[0], '/') . '/', '', $strModule); // $strModule = preg_replace('/<\div>$/', '', trim($strModule)); - // $strModule = preg_replace('/
/', '', $strModule); // $strModule = preg_replace('/<\/div>([\s\n]{0,})<\/form>/', '
', $strModule); - $strModule = preg_replace('//', '$3', $strModule); - - $strModule = preg_replace('/<\/form>/', 'close', $strModule); - - $strBuffer = preg_replace('/<\/body>/', $strModule . '', $strBuffer); + $strModule = preg_replace('//', '$3', $strModule); + $strModule = preg_replace('/<\/form>/', 'close', $strModule); + $strBuffer = preg_replace('/<\/body>/', $strModule . '', $strBuffer); + } } // Mobile Menü $menuOpen = 'navigation'; $menuClose = ''; + $objNavModule = \ModuleModel::findOneBy("type", "navigation"); + // //TODO: set module ID flexible, make a change posible -// $modSearch = \Controller::getFrontendModule( 10 ); -// $modNavi = \Controller::getFrontendModule( 11 ); -// $modSocial = ''; //TODO: Add Socialmedia links + $modSearch = ''; //\Controller::getFrontendModule( 10 ); + $modNavi = \Controller::getFrontendModule( $objNavModule->id ); // 11 + $modSocial = ''; //TODO: Add Socialmedia links -// $menuMobile = ''; + $menuMobile = ''; -// $strBuffer = preg_replace('//', '' . $menuOpen . $menuMobile, $strBuffer); + $strBuffer = preg_replace('//', '' . $menuOpen . $menuMobile, $strBuffer); } return $strBuffer; diff --git a/Resources/config/master-connection.json b/Resources/config/master-connection.json index e424bca..94c2a8a 100644 --- a/Resources/config/master-connection.json +++ b/Resources/config/master-connection.json @@ -6,5 +6,15 @@ "path" : "Resources/public/connection/", "publicPath" : "bundles/iidomaster/connection/", "file" : "connect.php" + }, + + "vars" : + { + "request" : + { + "host" : "##env__host##", + "name" : "##config__websiteTitle##", + "version" : "##cms__version##" + } } } \ No newline at end of file diff --git a/Resources/contao/config/config.php b/Resources/contao/config/config.php index 15d5405..003c598 100644 --- a/Resources/contao/config/config.php +++ b/Resources/contao/config/config.php @@ -72,7 +72,7 @@ $GLOBALS['TL_HOOKS']['getPageStatusIcon'][] = array($listenerName . '.listener.page', 'getCustomizePageStatusIcon'); $GLOBALS['TL_HOOKS']['generatePage'][] = array($listenerName . '.listener.page', 'generateCustomizePage'); -//$GLOBALS['TL_HOOKS']['modifyFrontendPage'][] = array($listenerName . '.listener.page', 'modifyCustomizeFrontendPage'); +$GLOBALS['TL_HOOKS']['modifyFrontendPage'][] = array($listenerName . '.listener.page', 'modifyCustomizeFrontendPage'); $GLOBALS['TL_HOOKS']['getContentElement'][] = array($listenerName . '.listener.content', 'getCustomizeContentElement'); diff --git a/Resources/contao/templates/backend/be_mod_iido_errorMaster.html5 b/Resources/contao/templates/backend/be_mod_iido_errorMaster.html5 new file mode 100644 index 0000000..4cb93ed --- /dev/null +++ b/Resources/contao/templates/backend/be_mod_iido_errorMaster.html5 @@ -0,0 +1,7 @@ +
+ +

Verbindungsfehler!

+ + message ?> + +
\ No newline at end of file diff --git a/Resources/contao/templates/navigation/nav_mobile.html5 b/Resources/contao/templates/navigation/nav_mobile.html5 new file mode 100644 index 0000000..fb556b1 --- /dev/null +++ b/Resources/contao/templates/navigation/nav_mobile.html5 @@ -0,0 +1,20 @@ +expand'; + +?> + diff --git a/Resources/public/css/footer.css b/Resources/public/css/footer.css new file mode 100644 index 0000000..458a888 --- /dev/null +++ b/Resources/public/css/footer.css @@ -0,0 +1 @@ +html,body{height:100%;min-height:100%;}#page{min-height:100%;}#outer{height:100%;padding:0;}body.footerbottompage.footer-in-background #wrapper.has-shadow {-webkit-box-shadow:0 0 20px rgba(0, 0, 0, 0.35);-moz-box-shadow:0 0 20px rgba(0, 0, 0, 0.35);box-shadow:0 0 20px rgba(0, 0, 0, 0.35);}body.footerbottompage.footer-in-background footer.fixed-bottom.has-shadow{bottom:0;height:155px;}body.footerbottompage.footer-in-background footer.has-shadow{-webkit-box-shadow:inset 0 0 20px rgba(0, 0, 0, 0.35);-moz-box-shadow:inset 0 0 20px rgba(0, 0, 0, 0.35);box-shadow:inset 0 0 20px rgba(0, 0, 0, 0.35);}body.footerbottompage.footer-in-background footer.has-shadow+.footer-bottom-line{display:none;}footer.fixed-bottom{position:fixed;left:0;right:0;bottom:0;}body.footerbottompage.footer-in-background #wrapper{position:relative;background:#fff;z-index:1;} \ No newline at end of file