From e5d5be0790c79e3d665528efac0d11513e0ac27f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Pre=C3=9Fl?= Date: Tue, 20 Jun 2017 01:08:03 +0200 Subject: [PATCH] some changes --- ConnectTool.php | 146 ++++- ContentElement/NavigationElement.php | 38 ++ Controller/ConnectionController.php | 11 +- EventListener/CombinerListener.php | 11 +- EventListener/ContentListener.php | 88 ++- EventListener/FrontendTemplateListener.php | 21 +- EventListener/PageListener.php | 50 +- FrontendModule/NavigationModule.php | 512 +++++++++++++++++- Helper/BasicHelper.php | 58 ++ Helper/ContentHelper.php | 5 + Page/RegularRedirectPage.php | 10 +- Resources/config/master-connection.json | 3 +- Resources/contao/config/config.php | 10 +- Resources/contao/dca/tl_article.php | 54 +- Resources/contao/dca/tl_content.php | 21 +- Resources/contao/languages/de/tl_article.xlf | 10 + Resources/contao/languages/de/tl_news.xlf | 127 +++++ .../templates/elements/ce_navigation.html5 | 1 + .../templates/navigation/nav_default.html5 | 10 + .../templates/navigation/nav_fullpage.html5 | 13 + Resources/public/css/backend/backend.css | 1 + .../public/javascript/ScrollMagic.min.js | 2 + Resources/public/javascript/barba.min.js | 1 + Resources/public/javascript/fakeLoader.min.js | 1 + .../javascript/greensock/TimelineLite.min.js | 12 + .../javascript/greensock/TimelineMax.min.js | 12 + .../javascript/greensock/TweenLite.min.js | 12 + .../javascript/greensock/TweenMax.min.js | 17 + .../greensock/easing/EasePack.min.js | 12 + .../javascript/greensock/jquery.gsap.min.js | 14 + .../greensock/plugins/AttrPlugin.min.js | 12 + .../greensock/plugins/BezierPlugin.min.js | 12 + .../greensock/plugins/CSSPlugin.min.js | 13 + .../greensock/plugins/CSSRulePlugin.min.js | 12 + .../greensock/plugins/ColorPropsPlugin.min.js | 12 + .../plugins/DirectionalRotationPlugin.min.js | 12 + .../greensock/plugins/EaselPlugin.min.js | 12 + .../greensock/plugins/EndArrayPlugin.min.js | 12 + .../greensock/plugins/KineticPlugin.min.js | 12 + .../greensock/plugins/RaphaelPlugin.min.js | 12 + .../greensock/plugins/RoundPropsPlugin.min.js | 12 + .../greensock/plugins/ScrollToPlugin.min.js | 12 + .../greensock/plugins/TextPlugin.min.js | 12 + .../greensock/utils/Draggable.min.js | 14 + .../javascript/jquery/iido/IIDO.Content.js | 117 ++++ .../javascript/jquery/iido/IIDO.Page.js | 471 ++++++++++++---- .../jquery/jquery.ScrollMagic.min.js | 2 + .../javascript/jquery/jquery.lettering.min.js | 12 + .../javascript/jquery/jquery.number.min.js | 2 + .../jquery/jquery.ui.touch-punch.min.js | 11 + .../javascript/jquery/jquery.viewport.mini.js | 1 + .../javascript/jquery/src/jquery.lettering.js | 72 +++ .../public/javascript/lib/velocity.min.js | 4 + .../public/javascript/masonry.pkgd.min.js | 9 + .../scrollmagic/animation.gsap.min.js | 2 + .../scrollmagic/animation.velocity.min.js | 2 + .../scrollmagic/debug.addIndicators.min.js | 2 + .../scrollmagic/jquery.ScrollMagic.min.js | 2 + Resources/views/locked.html.twig | 9 + Table/AllTables.php | 14 +- Table/ContentTable.php | 32 +- Table/PageTable.php | 102 ++-- composer.json | 2 +- 63 files changed, 2122 insertions(+), 200 deletions(-) create mode 100644 ContentElement/NavigationElement.php create mode 100644 Resources/contao/languages/de/tl_news.xlf create mode 100644 Resources/contao/templates/elements/ce_navigation.html5 create mode 100644 Resources/contao/templates/navigation/nav_default.html5 create mode 100644 Resources/contao/templates/navigation/nav_fullpage.html5 create mode 100755 Resources/public/javascript/ScrollMagic.min.js create mode 100644 Resources/public/javascript/fakeLoader.min.js create mode 100755 Resources/public/javascript/greensock/TimelineLite.min.js create mode 100755 Resources/public/javascript/greensock/TimelineMax.min.js create mode 100755 Resources/public/javascript/greensock/TweenLite.min.js create mode 100755 Resources/public/javascript/greensock/TweenMax.min.js create mode 100755 Resources/public/javascript/greensock/easing/EasePack.min.js create mode 100755 Resources/public/javascript/greensock/jquery.gsap.min.js create mode 100755 Resources/public/javascript/greensock/plugins/AttrPlugin.min.js create mode 100755 Resources/public/javascript/greensock/plugins/BezierPlugin.min.js create mode 100755 Resources/public/javascript/greensock/plugins/CSSPlugin.min.js create mode 100755 Resources/public/javascript/greensock/plugins/CSSRulePlugin.min.js create mode 100755 Resources/public/javascript/greensock/plugins/ColorPropsPlugin.min.js create mode 100755 Resources/public/javascript/greensock/plugins/DirectionalRotationPlugin.min.js create mode 100755 Resources/public/javascript/greensock/plugins/EaselPlugin.min.js create mode 100755 Resources/public/javascript/greensock/plugins/EndArrayPlugin.min.js create mode 100755 Resources/public/javascript/greensock/plugins/KineticPlugin.min.js create mode 100755 Resources/public/javascript/greensock/plugins/RaphaelPlugin.min.js create mode 100755 Resources/public/javascript/greensock/plugins/RoundPropsPlugin.min.js create mode 100755 Resources/public/javascript/greensock/plugins/ScrollToPlugin.min.js create mode 100755 Resources/public/javascript/greensock/plugins/TextPlugin.min.js create mode 100755 Resources/public/javascript/greensock/utils/Draggable.min.js create mode 100644 Resources/public/javascript/jquery/iido/IIDO.Content.js create mode 100755 Resources/public/javascript/jquery/jquery.ScrollMagic.min.js create mode 100755 Resources/public/javascript/jquery/jquery.lettering.min.js create mode 100644 Resources/public/javascript/jquery/jquery.number.min.js create mode 100644 Resources/public/javascript/jquery/jquery.ui.touch-punch.min.js create mode 100644 Resources/public/javascript/jquery/jquery.viewport.mini.js create mode 100755 Resources/public/javascript/jquery/src/jquery.lettering.js create mode 100755 Resources/public/javascript/lib/velocity.min.js create mode 100644 Resources/public/javascript/masonry.pkgd.min.js create mode 100755 Resources/public/javascript/scrollmagic/animation.gsap.min.js create mode 100755 Resources/public/javascript/scrollmagic/animation.velocity.min.js create mode 100755 Resources/public/javascript/scrollmagic/debug.addIndicators.min.js create mode 100755 Resources/public/javascript/scrollmagic/jquery.ScrollMagic.min.js create mode 100644 Resources/views/locked.html.twig diff --git a/ConnectTool.php b/ConnectTool.php index a39de9d..ffa9fc5 100644 --- a/ConnectTool.php +++ b/ConnectTool.php @@ -158,7 +158,7 @@ public function connectionLost() { $arrData = $this->testConnection(); - if( key_exists("ERROR", $arrData) ) + if( is_array($arrData) && key_exists("ERROR", $arrData) ) { if( $arrData[ 'ERROR' ] === $this->container->get("translator")->trans("connection_failed") ) { @@ -166,6 +166,11 @@ public function connectionLost() } } + if( !is_array($arrData) ) + { + return $arrData; + } + return false; } @@ -381,6 +386,12 @@ public function getData($returnAsArray = false) } $objData = json_decode($arrData, $returnAsArray); + $clientID = $this->getConfig( "clientID" ); + + if( !$clientID ) + { + $this->persistConfig("clientID", (($returnAsArray) ? $objData['clientID'] : $objData->clientID) ); + } return $objData; } @@ -391,14 +402,51 @@ public function getActionData( $actionName, array $actionParams = array(), $retu { if( $actionName == "checkPassword" ) { -// $this->setPassword( $actionParams['pwd'] ); + $this->setPassword( $actionParams['pwd'] ); unset( $actionParams['pwd'] ); } - $connectionUrl = $this->getConnectionUrl() . '&act=' . $actionName . (count($actionParams)?'&':'') . implode('&', $actionParams); - $arrData = @file_get_contents( $connectionUrl ); +// $opts = array +// ( +// 'http'=>array +// ( +// 'method'=>"GET", +// 'header'=>"Cache-Control: no-store, no-cache, must-revalidate, max-age=0\r\n" . +// "Cache-Control: post-check=0, pre-check=0\r\n" . +// "Pragma: no-cache\r\n" . +// "Content-Type: application/json;charset=utf-8" +// ) +// ); + +// $context = stream_context_create($opts); + + $arrParams = array(); + + if( count($actionParams) ) + { + foreach($actionParams as $paramKey => $paramValue) + { + $param = $paramKey . '=' . $paramValue; + + if( is_numeric($paramKey) ) + { + $param = $paramValue; + } + + $arrParams[] = $param; + } + } + + $connectionUrl = $this->getConnectionUrl() . '&act=' . $actionName . (count($arrParams)?'&':'') . implode('&', $arrParams); +// $arrData = trim(file_get_contents( $connectionUrl, false, $context ), "\xEF\xBB\xBF"); + $arrData = file_get_contents( $connectionUrl ); $return = false; +//echo "
";
+//print_r( $connectionUrl );
+//        print_r( $arrData );
+//echo "
"; +//print_r( parse) if( !$arrData ) { if( !$returnBoolean ) @@ -409,6 +457,19 @@ public function getActionData( $actionName, array $actionParams = array(), $retu else { $return = json_decode($arrData, $returnAsArray); + + if( !is_array($return) && !is_object($return) ) + { + $return = json_decode($return, $returnAsArray); + } + } + + if( $returnBoolean ) + { + if( key_exists('ERROR', $return) ) + { + return false; + } } return $returnBoolean ? true : $return; @@ -482,7 +543,7 @@ protected function getPassword() - public function setUpFiles( $arrFiles ) + public function setUpFilesFolder( $arrFiles ) { $arrFolders = array(); @@ -499,6 +560,11 @@ public function setUpFiles( $arrFiles ) $objFolder = new \Folder( $strFolderPath ); } +// if( $objFolder ) +// { +// $objFolder->protected = +// } + $arrFolders[] = $objFolder->path; if( is_array($arrSubfolders) && count($arrSubfolders) && $objFolder && is_dir( $this->rootDir . '/../' . $objFolder->path) ) @@ -548,6 +614,9 @@ public function createNewOneModelEntry($modelName, array $arrModelValue, array $ { if( is_array($arrModelValue) && count($arrModelValue) ) { + $request = $this->container->get('request_stack')->getCurrentRequest(); + $customerAlias = $request->request->get('customer_alias'); + $modelClass = '\\' . $modelName . 'Model'; $objModel = new $modelClass(); @@ -560,6 +629,14 @@ public function createNewOneModelEntry($modelName, array $arrModelValue, array $ $valueVarValue = $this->replaceVars( $valueVarValue); + if( $valueVar == "password" ) + { + if( !preg_match('/^[a-f0-9]{32}$/', $valueVarValue) ) + { + $valueVarValue = md5( $valueVarValue ); + } + } + $objModel->$valueVar = $valueVarValue; } @@ -575,10 +652,42 @@ public function createNewOneModelEntry($modelName, array $arrModelValue, array $ $value = $this->replaceVars( $value); + if( $key == "password" ) + { + if( !preg_match('/^[a-f0-9]{32}$/', $value) ) + { + $value = md5( $value ); + } + } + $objModel->$key = $value; } } + if( $modelName === "Theme" ) + { + $objModel->templates = 'templates/' . $customerAlias; + + $arrFolders = array(); + $objMasterFolder = \FilesModel::findByPath("files/master"); + $objCustomerFolder = \FilesModel::findByPath("files/" . $customerAlias ); + + if( $objMasterFolder ) + { + $arrFolders[] = $objMasterFolder->uuid; + } + + if( $objCustomerFolder ) + { + $arrFolders[] = $objCustomerFolder->uuid; + } + + if( count($arrFolders) ) + { + $objModel->folders = serialize($arrFolders); + } + } + return $objModel->save(); } @@ -819,6 +928,11 @@ public function replaceVars( $varValue ) { $varValue = $request->request->get("customer_name"); } + + if( $arrParts[1] === "websiteTitle" ) + { + $varValue = $this->renderTitleString( $varValue ); + } } elseif( $arrParts[0] == "cms" ) { @@ -858,4 +972,26 @@ public function isConnectToolInitialized() { return $this->getConfig("iido_initSystem"); } + + + + protected function renderTitleString( $strTitle ) + { + $strTitle = preg_replace(array('/ä/', '/ö/', '/ü/', '/Ä/', '/Ö/', '/Ü/'), array(';ae;', ';oe;', ';ue;', ';AE;', ';OE;', ';UE;'), $strTitle); + $strTitle = preg_replace('/ß/', ';ss;', $strTitle); + $strTitle = preg_replace('/ /', '+', $strTitle); + + return $strTitle; + } + + + + protected function getFilesFromMaster( $arrFolders ) + { + $arrData = $this->getActionData("getFolderFiles", array('foldersPath'=>implode(",", $arrFolders))); + + echo "
";
+        print_r( $arrData->files );
+        exit;
+    }
 }
diff --git a/ContentElement/NavigationElement.php b/ContentElement/NavigationElement.php
new file mode 100644
index 0000000..8df6242
--- /dev/null
+++ b/ContentElement/NavigationElement.php
@@ -0,0 +1,38 @@
+
+ */
+class NavigationElement extends \ContentElement
+{
+
+    /**
+     * Template
+     * @var string
+     */
+    protected $strTemplate = 'ce_navigation';
+
+
+    /**
+     * Generate the content element
+     */
+    protected function compile()
+    {
+        $this->Template->content = BasicHelper::renderNavigation( $this->navModule, 'main', $this->cssID[1] );
+    }
+}
diff --git a/Controller/ConnectionController.php b/Controller/ConnectionController.php
index fcef6da..37b5b2c 100644
--- a/Controller/ConnectionController.php
+++ b/Controller/ConnectionController.php
@@ -290,22 +290,24 @@ private function setUpClient( $connectTool )
 
         $arrData = $connectTool->getActionData("getContaoInit", array('themeID=' . $themeID) );
 
-        $connectTool->setUpFiles( $arrData->files );
+        $connectTool->setUpFilesFolder( $arrData->folders );
         $connectTool->setUpTemplates( $arrData->templates );
 
+//        $connectTool->getFilesFromMaster( $arrData->files );
+
         $arrTheme   = (array) $arrData->theme;
         unset($arrTheme['layouts']);
         unset($arrTheme['modules']);
         unset($arrTheme['imageSizes']);
         unset($arrTheme['imageSizeItems']);
 
-        $connectTool->createNewOneModelEntry("Theme", $arrTheme, array('master_ID', $themeID));
+        $connectTool->createNewOneModelEntry("Theme", $arrTheme, array('master_ID' => $themeID));
 
         // Create Layouts
-        $connectTool->createNewModelEntry("Layout", (array) $arrData->theme->layouts, array('master_ID', 'field_id'));
+        $connectTool->createNewModelEntry("Layout", (array) $arrData->theme->layouts, array('master_ID' => 'field_id'));
 
         // Create Modules
-        $connectTool->createNewModelEntry("Module", (array) $arrData->theme->modules, array('master_ID', 'field_id'));
+        $connectTool->createNewModelEntry("Module", (array) $arrData->theme->modules, array('master_ID' => 'field_id'));
 
         // Create Image Sizes
         $connectTool->createNewModelEntry("ImageSize", (array) $arrData->theme->imageSizes);
@@ -368,6 +370,7 @@ private function setUpClient( $connectTool )
         }
 
         $connectTool->persistConfig( 'iido_initSystem', TRUE);
+        $connectTool->persistConfig( 'clientID', $arrData->clientID);
 
         return $this->getRedirectResponse();
     }
diff --git a/EventListener/CombinerListener.php b/EventListener/CombinerListener.php
index cfbbbd1..6420344 100644
--- a/EventListener/CombinerListener.php
+++ b/EventListener/CombinerListener.php
@@ -108,7 +108,7 @@ public function getCustomizeCombinedFile($strContent, $strKey, $strMode, &$arrFi
 //                            {
 //                                $varName .= '_' . $objCurPage->alias;
 //                            }
-                            $varValue = preg_replace('/#/', '#', $varValue);
+                            $varValue = preg_replace(array('/#/', '/(/', '/)/'), array('#', '(', ')'), $varValue);
                         }
 
                         $strContent = preg_replace('/\/\*#' . $varName . '#\*\/' . $add . '/', $varValue, $strContent);
@@ -124,9 +124,12 @@ public function getCustomizeCombinedFile($strContent, $strKey, $strMode, &$arrFi
         {
             if( $isInFiles || $isInBundle )
             {
-                $objMinify = new Minify\JS();
-                $objMinify->add( $strContent );
-                $strContent = $objMinify->minify();
+                if( !preg_match('/min' . \Combiner::JS . '$/', trim($arrFile['name'])) )
+                {
+                    $objMinify = new Minify\JS();
+                    $objMinify->add( $strContent );
+                    $strContent = $objMinify->minify();
+                }
             }
         }
 
diff --git a/EventListener/ContentListener.php b/EventListener/ContentListener.php
index b33e8e2..f15920c 100644
--- a/EventListener/ContentListener.php
+++ b/EventListener/ContentListener.php
@@ -71,6 +71,7 @@ public function getCustomizeContentElement($objRow, $strBuffer, &$objElement)
         global $objPage;
 
         $elementClass   = $objRow->typePrefix . $objRow->type;
+        $cssID          = \StringUtil::deserialize($objRow->cssID, TRUE);
 
         if( $objRow->type == "module" )
         {
@@ -131,6 +132,11 @@ public function getCustomizeContentElement($objRow, $strBuffer, &$objElement)
                     $strBuffer = Helper::generateImageHoverTags( $strBuffer, $objRow );
                 }
             }
+
+            if( preg_match('/first-p-big/', $cssID[1]) )
+            {
+                $strBuffer = preg_replace('/

(.*)<\/p>/', '

$1

', $strBuffer, 1); + } } elseif( $objRow->type == "gallery" ) @@ -144,11 +150,87 @@ public function getCustomizeContentElement($objRow, $strBuffer, &$objElement) $strBuffer = preg_replace('/class="' . $elementClass . '/', 'class="' . $elementClass . ' content-element', $strBuffer); - $strBuffer = preg_replace('/
', $strBuffer, -1, $count); +// $strBuffer = preg_replace('/
', $strBuffer, -1, $count); + +// if( $count ) +// { +// $strBuffer = $strBuffer . '
'; +// } - if( $count ) + preg_match_all('/class="ce_([A-Za-z0-9\s\-_\{\}]{0,})"/', $strBuffer, $arrClassMatches); + + if( is_array($arrClassMatches) && is_array($arrClassMatches[0]) && count($arrClassMatches[0]) ) { - $strBuffer = $strBuffer . '
'; + $strClass = "ce_" . $arrClassMatches[1][0]; + $strNewClass = $strClass; + $arrClass = explode(" ", $strClass); + $arrAttributes = array(); + + foreach($arrClass as $strClassName) + { + if( preg_match('/^v_/', $strClassName) ) + { + $arrClasses = array(); + $arrParts = array(); + $cAttributeName = ""; + $attributeName = ""; + $value = ""; + + if( preg_match('/^v_ma/', $strClassName) ) + { + $cAttributeName = "m"; + $attributeName = "margin"; + + $property = substr($strClassName, 5); + $arrParts = explode("_", $property); + $value = $arrParts[0]; + } + + if( count($arrParts) > 1 ) + { + $value = $arrParts[1]; + + switch( $arrParts[0] ) + { + case "t": + case "to": + $cAttributeName .= 't'; + $attributeName .= '-top'; + break; + + case "b": + case "bo": + $cAttributeName .= 'b'; + $attributeName .= '-bottom'; + break; + + case "l": + case "le": + $cAttributeName .= 'l'; + $attributeName .= '-left'; + break; + + case "r": + case "ri": + $cAttributeName .= 'r'; + $attributeName .= '-right'; + break; + } + } + + $strNewClass = preg_replace('/ ' . $strClassName . '/', '', $strNewClass); + +// $arrClasses[] = 'd' . $cAttributeName; +// $arrAttributes[] = 'data-' . $attributeName . '="' . $value . '"'; + $arrAttributes[] = $attributeName . ':' . $value . 'px;'; + } + } + + if( count($arrAttributes) ) + { +// $strBuffer = preg_replace('/class="' . $strClass . '"/', 'class="' . $strClass . ' ' . implode(" ", $arrClasses) . '" ' . implode(" ", $arrAttributes), $strBuffer); + $strBuffer = preg_replace('/class="' . $strClass . '"/', 'class="' . $strNewClass . '" style="' . implode("", $arrAttributes) . '"', $strBuffer); + } } return $strBuffer; diff --git a/EventListener/FrontendTemplateListener.php b/EventListener/FrontendTemplateListener.php index e2fc127..a06a9f6 100644 --- a/EventListener/FrontendTemplateListener.php +++ b/EventListener/FrontendTemplateListener.php @@ -88,7 +88,7 @@ public function parseCustomizeFrontendTemplate($strContent, $strTemplate) $objArticle = \ArticleModel::findByIdOrAlias( $idOrAlias ); } - + // if( strlen($articleID) ) // { // $strContent = preg_replace('/id="'. $articleID . '"/', 'id="' . $objArticle->alias . '"', $strContent); @@ -374,6 +374,7 @@ public function parseCustomizeFrontendTemplate($strContent, $strTemplate) } $arrAttributes[] = 'data-menu="' . $inMenu . '"'; + $arrAttributes[] = 'data-anchor="' . $objArticle->alias . '"'; } if( is_array($articleClass) && count($articleClass) > 0 ) @@ -404,8 +405,20 @@ public function parseCustomizeFrontendTemplate($strContent, $strTemplate) if( $objArticle->inColumn === "main") { - $strContent = preg_replace('/
', $strContent); - $strContent = $strContent . '
'; + $divTableStart = ""; + $divTableEnd = ""; + + if( $objArticle->textMiddle && $isFullpage ) + { + $divTableStart = '
'; + $divTableEnd = '
'; + } + + $strContent = preg_replace('/
' . $divTableStart, $strContent); + $strContent = $strContent . $divTableEnd . '
'; + +// $strContent = preg_replace('/
', $strContent); +// $strContent = $strContent . '
'; if( $objParentPage->subPagesHasBacklink && !$objPage->thisPageHasNoBacklink && preg_match('/last/', $arrMatches[1][0]) ) { @@ -650,7 +663,7 @@ public function outputCustomizeFrontendTemplate($strBuffer, $strTemplate) $strBuffer = preg_replace('/nav-sub/', 'nav-sub has-bg-left', $strBuffer); $strBuffer = preg_replace('//', '
', $strBuffer); } - + if( preg_match('/homepage/', $objPage->cssClass) ) { $strBuffer = preg_replace('/
([A-Za-z0-9öäüÖÄÜß&!?\-\n\s_.,;:<>="\{\}\(\)\/]{0,})<\/div>([\s]{0,})type == "regular_redirect" ) { $strImage = preg_replace('/^web\//', '', $this->bundlePathPublic) . '/images/pages/' . $strImage; } @@ -80,6 +80,7 @@ public function generateCustomizePage( \PageModel $objPage, \LayoutModel $objLay $strStyles = ''; $objArticle = \ArticleModel::findPublishedByPidAndColumn($objPage->id, "main"); $objTheme = \ThemeModel::findByPk( $objLayout->pid ); + $bundles = array_keys(\System::getContainer()->getParameter('kernel.bundles')); $config = \Config::getInstance(); $jsPrefix = 'mootools'; @@ -113,6 +114,28 @@ public function generateCustomizePage( \PageModel $objPage, \LayoutModel $objLay $GLOBALS['TL_JAVASCRIPT']['fullpage'] = $this->bundlePathPublic . '/javascript/' . $jsPrefix . '/jquery.fullPage.min.js|static'; } + if( $footerMode ) + { + $GLOBALS['TL_CSS']['footer'] = $this->bundlePathPublic . '/css/footer.css||static'; + } + + $GLOBALS['TL_JAVASCRIPT']['j_gsap'] = $this->bundlePathPublic . '/javascript/greensock/jquery.gsap.min.js|static'; + $GLOBALS['TL_JAVASCRIPT']['tweenlite'] = $this->bundlePathPublic . '/javascript/greensock/TweenMax.min.js|static'; + + if( in_array('RockSolidSliderBundle', $bundles) && $objRootPage->enablePageFadeEffect ) + { + $assetsDir = 'web/bundles/rocksolidslider'; + + $GLOBALS['TL_JAVASCRIPT']['rocksolid_slider'] = $assetsDir . '/js/rocksolid-slider.min.js|static'; + $GLOBALS['TL_CSS']['rocksolid_slider'] = $assetsDir . '/css/rocksolid-slider.min.css||static'; + + $skinPath = $assetsDir . '/css/default-skin.min.css'; + if (file_exists(TL_ROOT . '/' . $skinPath)) + { + $GLOBALS['TL_CSS']['rocksolid_slider_default'] = $skinPath . '||static'; + } + } + $this->addDefaultStylesheets(); if( $jsPrefix == "jquery" ) @@ -141,11 +164,6 @@ public function generateCustomizePage( \PageModel $objPage, \LayoutModel $objLay $GLOBALS['TL_JAVASCRIPT']['barba'] = $this->bundlePathPublic . '/javascript/barba.min.js|static'; } - if( $footerMode ) - { - $GLOBALS['TL_CSS']['footer'] = $this->bundlePathPublic . '/css/footer.css||static'; - } - if( $objLayout->loadDomainCSS ) { $objRootPage = \PageModel::findByPk( $objPage->rootId ); @@ -301,6 +319,8 @@ public function generateCustomizePage( \PageModel $objPage, \LayoutModel $objLay { $objPage->cssClass = $objPage->cssClass . ((strlen($objPage->cssClass)) ? ' ' : '') . implode(" ", $arrBodyClasses); } + + Helper::checkForUniqueScripts(); } @@ -496,7 +516,7 @@ protected function createDefaultStylesheet( $arrBodyClasses ) if( strlen(trim($strOnlyStyles)) ) { - $objFile->append($strOnlyStyles, ''); + $objFile->append($strStyle, ''); } } @@ -510,13 +530,20 @@ protected function createDefaultStylesheet( $arrBodyClasses ) $objFile->delete(); } } - - if( file_exists($this->rootDir . '/assets/css/page-styles.css') ) + } + else + { + if( $objFile->exists() ) { - $GLOBALS['TL_CSS']['custom_page-styles'] = 'assets/css/page-styles.css||static'; + $objFile->delete(); } } + if( file_exists($this->rootDir . '/assets/css/page-styles.css') ) + { + $GLOBALS['TL_CSS']['custom_page-styles'] = 'assets/css/page-styles.css||static'; + } + if( file_exists($this->rootDir . '/files/' . $objRootPage->alias . '/css/theme.css') ) { $GLOBALS['TL_CSS']['custom_theme'] = 'files/' . $objRootPage->alias . '/css/theme.css||static'; @@ -582,6 +609,7 @@ protected function addDefaultStylesheets() 'layout.css', 'navigation.css', 'content.css', + 'style.css', 'styles.css', 'page.css', 'responsive.css' diff --git a/FrontendModule/NavigationModule.php b/FrontendModule/NavigationModule.php index e5acd23..f885429 100644 --- a/FrontendModule/NavigationModule.php +++ b/FrontendModule/NavigationModule.php @@ -31,7 +31,22 @@ class NavigationModule extends \ModuleNavigation */ public function generate() { - return parent::generate(); + global $objPage; + + $strBuffer = parent::generate(); + + if( !strlen($strBuffer) && preg_match('/nav-sub/', $this->cssID[1]) ) + { + $objArticle = \ArticleModel::findPublishedByPidAndColumn( $objPage->id, "main", array("order"=>"sorting")); + $objFirstArticle = $objArticle->first(); + + if( $objFirstArticle && $objFirstArticle->bgImage && !preg_match('/homepage/', $objPage->cssClass)) + { + $strBuffer = '
'; + } + } + + return $strBuffer; } @@ -40,6 +55,10 @@ public function generate() */ protected function compile() { + parent::compile(); + $this->renderRealMenu(); + return; + /* @var \PageModel $objPage */ global $objPage; parent::compile(); @@ -55,7 +74,7 @@ protected function compile() $arrPageItems2 = array(); - if( $this->levelOffset == 2 && $objPage->submenuNoPages ) + if( $this->levelOffset >= 1 && $objPage->submenuNoPages ) { $arrCurrentSubPages = array(); @@ -250,6 +269,11 @@ protected function compile() } } + if( $arrPageItem['object']->type == "redirect" ) + { + $strItem = preg_replace('/submenuNewsArchive, '1'), array("order"=>"headline ASC") )->fetchAll(); + $arrSubitems = \NewsModel::findBy( array('pid=?', 'published=?'), array($objParentPage->submenuNewsArchive, '1'), array("order"=>"sorting") )->fetchAll(); $from = "news"; break; } @@ -412,6 +436,11 @@ protected function renderSubNavigation( $arrParentPage, $level ) $strClass .= ' submenu'; } + if( $arrSubitem['type'] == "external" ) + { + $strClass .= ' external-link'; + } + $row['isActive'] = $isActive; $row['isTrail'] = false; $row['subitems'] = $strSubItems; @@ -435,4 +464,481 @@ protected function renderSubNavigation( $arrParentPage, $level ) return $strContent; } + + + + public function renderRealMenu() + { + /* @var \PageModel $objPage */ + global $objPage; + + $arrItems = array(); + + // Set the trail and level + if ($this->defineRoot && $this->rootPage > 0) + { + $trail = array($this->rootPage); + $level = 0; + } + else + { + $trail = $objPage->trail; + $level = ($this->levelOffset > 0) ? $this->levelOffset : 0; + } + + $lang = null; + $host = null; + + // Overwrite the domain and language if the reference page belongs to a differnt root page (see #3765) + if ($this->defineRoot && $this->rootPage > 0) + { + $objRootPage = \PageModel::findWithDetails($this->rootPage); + + // Set the language + if (\Config::get('addLanguageToUrl') && $objRootPage->rootLanguage != $objPage->rootLanguage) + { + $lang = $objRootPage->rootLanguage; + } + + // Set the domain + if ($objRootPage->rootId != $objPage->rootId && $objRootPage->domain != '' && $objRootPage->domain != $objPage->domain) + { + $host = $objRootPage->domain; + } + } + + if( $level > count($trail) ) + { + $strItems = $this->getPages( $objPage->id, 1, $host, $lang ); + } + else + { + if( $this->name == "Navigation Sub" && $level == 1 && count($trail) > 2 ) + { + $level++; + } + + $strItems = $this->getPages( $trail[ $level ], 1, $host, $lang ); + } + + $this->Template->items = $strItems; + } + + + protected function getPages( $pid, $level=1, $host=null, $language=null, $type = '' ) + { + /* @var \PageModel $objPage */ + global $objPage; + + $objParentPage = false; + + if( $pid > 0 ) + { + $objParentPage = \PageModel::findByPk( $pid ); + + if( $type == "article" ) + { + $objParentPage = \ArticleModel::findByPk( $pid ); + + if( $objParentPage->submenuSRC ) + { + $objParentPage->submenuNoPages = true; + } + } + } + + // Layout template fallback + if ($this->navigationTpl == '') + { + $this->navigationTpl = 'nav_default'; + } + + /** @var \FrontendTemplate|object $objTemplate */ + $objTemplate = new \FrontendTemplate( $this->navigationTpl ); + + $objTemplate->pid = $pid; + $objTemplate->type = get_class($this); + $objTemplate->cssID = $this->cssID; + $objTemplate->level = 'level_' . $level++; + + if( preg_match('/article-menu/', $this->cssID[1]) ) + { + $objTemplate->level .=' article-submenu'; + } + + if( $objParentPage->submenuSRC == "articles" && !preg_match('/article-submenu/', $objTemplate->level) && $objPage->id == $objParentPage->id ) + { + $objTemplate->level .=' article-menu'; + } + + $arrItems = array(); + $groups = array(); + + if( $objParentPage && $objParentPage->submenuNoPages && (!$objParentPage->submenuPageCombination || ($objParentPage->submenuPageCombination && $objParentPage->submenuPageOrder === "pagesAfter")) ) + { + switch( $objParentPage->submenuSRC ) + { + case "articles": + $arrItems = $this->getArticlePages( $objParentPage, $level, $host, $language ); + break; + + case "news": + $arrItems = $this->getNewsPages( $objParentPage, $level, $host, $language ); + break; + } + } + + if( !$objParentPage->submenuNoPages || ($objParentPage->submenuNoPages && $objParentPage->submenuPageCombination) ) + { + $objPages = \PageModel::findPublishedSubpagesWithoutGuestsByPid( $pid, $this->showHidden ); + + if( $objPages ) + { + while( $objPages->next() ) + { + $objItem = $objPages->current(); + + $trail = in_array($objItem->id, $objPage->trail); + $href = null; + $subitems = ''; + $_groups = \StringUtil::deserialize( $objItem->groups ); + + // Override the domain (see #3765) + if ($host !== null) + { + $objItem->domain = $host; + } + + // Do not show protected pages unless a front end user is logged in + if (!$objItem->protected || (is_array($_groups) && count(array_intersect($_groups, $groups))) || $this->showProtected || ($this instanceof \ModuleSitemap && $objItem->sitemap == 'map_always')) + { + // Check whether there will be subpages + if( (!$this->showLevel || $this->showLevel >= $level || (!$this->hardLimit && ($objPage->id == $objItem->id || in_array($objPage->id, $this->Database->getChildRecords($objItem->id, 'tl_page'))))) ) + { + $subitems = $this->getPages($objItem->id, $level, $host, $language); + } + + $arrItem = $this->setItemRow($objPages->row(), $objItem, "page", $subitems); + + $arrItems[] = $arrItem; + } + } + } + } + + + if( $objParentPage && $objParentPage->submenuNoPages && $objParentPage->submenuPageCombination && $objParentPage->submenuPageOrder === "pagesBefore" ) + { + switch( $objParentPage->submenuSRC ) + { + case "articles": + $arrItems = array_merge($arrItems, $this->getArticlePages( $objParentPage, $level, $host, $language ) ); + break; + + case "news": + $arrItems = array_merge($arrItems, $this->getNewsPages( $objParentPage, $level, $host, $language ) ); + break; + } + } + + if( count($arrItems) === 1) + { + if( $arrItems[0]['id'] == $objPage->id ) + { + return ''; + } + } + +// if( $objPage->hide && $level > 0) +// { +// if( $objPage->trail[ $level ] == $objPage->id ) +// if( $objPage ) +// { +// return ''; +// } +// } + + + // Add classes first and last + if (!empty($arrItems)) + { + $last = count($arrItems) - 1; + + $arrItems[0]['class'] = trim($arrItems[0]['class'] . ' first'); + $arrItems[$last]['class'] = trim($arrItems[$last]['class'] . ' last'); + } + + $objTemplate->items = $arrItems; + + $hasSubitems = false; + foreach( $arrItems as $arrItem) + { + if( strlen($arrItem['subitems']) ) + { + $hasSubitems = true; + } + } + + if( !$hasSubitems ) + { + $objTemplate->level = trim( $objTemplate->level . ' last-level'); + } + + return !empty($arrItems) ? $objTemplate->parse() : ''; + } + + + + protected function getArticlePages( \PageModel $objParentPage, $level, $host=null, $language=null ) + { + $arrItems = array(); + $objArticles = \ArticleModel::findPublishedByPidAndColumn($objParentPage->id, "main"); + + if( $objArticles ) + { + while( $objArticles->next() ) + { + $objItem = $objArticles->current(); + + if( $objItem->hideInMenu || !$objItem->published ) + { + continue; + } + + $subitems = ''; + + if( $objItem->submenuSRC ) + { + $subitems = $this->getPages( $objItem->id, $level, $host, $language, "article" ); + } + + $arrItem = $this->setItemRow($objArticles->row(), $objItem, "article", $subitems); + + if( !empty($arrItem) ) + { + $arrItems[] = $arrItem; + } + } + } + + return $arrItems; + } + + + + protected function getNewsPages( $objParent, $level, $host=null, $language=null) + { + $arrItems = array(); + + $objNews = \NewsModel::findPublishedByPid( $objParent->submenuNewsArchive, 0, array('order'=>'sorting') ); + + if( $objNews ) + { + while( $objNews->next() ) + { + $objItem = $objNews->current(); + + if( !$objItem->published ) + { + continue; + } + + $arrItem = $this->setItemRow($objNews->row(), $objItem, 'news'); + + $arrItems[] = $arrItem; + } + } + + + return $arrItems; + } + + + +// protected function getSubPages( $objItem ) +// { +// echo "
"; print_r( $arrItem ); exit;
+//    }
+
+
+
+    protected function setItemRow( $arrItem, $objItem, $type, $subitems = '', $arrVars = array() )
+    {
+        global $objPage;
+
+        $language       = \System::getContainer()->get('request_stack')->getCurrentRequest()->getLocale();
+
+        $strTitle       = ContentHelper::renderText( $objItem->title );
+        $strPageTitle   = ContentHelper::renderText( $objItem->pageTitle?:$objItem->title );
+        $isActive       = false;
+        $isTrail        = false;
+        $href           = '';
+        $strClass       = '';
+
+        if( $type == "page" )
+        {
+            $trail      = in_array($objItem->id, $objPage->trail);
+
+            // Get href
+            switch ($objItem->type)
+            {
+                case 'redirect':
+                    $href = $objItem->url;
+
+                    if (strncasecmp($href, 'mailto:', 7) === 0)
+                    {
+                        $href = \StringUtil::encodeEmail($href);
+                    }
+                    break;
+
+                case 'forward':
+                    if ($objItem->jumpTo)
+                    {
+                        /** @var ˜PageModel $objNext */
+                        $objNext = $objItem->getRelated('jumpTo');
+                    }
+                    else
+                    {
+                        $objNext = \PageModel::findFirstPublishedRegularByPid($objItem->id);
+                    }
+
+                    // Hide the link if the target page is invisible
+                    if (!($objNext instanceof \PageModel) || !$objNext->published || ($objNext->start != '' && $objNext->start > time()) || ($objNext->stop != '' && $objNext->stop < time()))
+                    {
+                        return array();
+                    }
+
+                    $href = $objNext->getFrontendUrl();
+                    break;
+
+                default:
+                    $href = $objItem->getFrontendUrl();
+                    break;
+            }
+
+            // Active page
+            if (($objPage->id == $objItem->id || $objItem->type == 'forward' && $objPage->id == $objItem->jumpTo) && !($this instanceof \ModuleSitemap) && $href == \Environment::get('request'))
+            {
+                // Mark active forward pages (see #4822)
+                $strClass = (($objItem->type == 'forward' && $objPage->id == $objItem->jumpTo) ? 'forward' . ($trail ? ' trail' : '') : 'active') . (($subitems != '') ? ' submenu' : '') . ($objItem->protected ? ' protected' : '') . (($objItem->cssClass != '') ? ' ' . $objItem->cssClass : '');
+
+                $isActive = true;
+                $isTrail = false;
+            }
+
+            // Regular page
+            else
+            {
+                $strClass = (($subitems != '') ? 'submenu' : '') . ($objItem->protected ? ' protected' : '') . ($trail ? ' trail' : '') . (($objItem->cssClass != '') ? ' ' . $objItem->cssClass : '');
+
+                // Mark pages on the same level (see #2419)
+                if ($objItem->pid == $objPage->pid)
+                {
+                    $strClass .= ' sibling';
+                }
+
+                $isActive = false;
+                $isTrail = $trail;
+            }
+        }
+        elseif( $type == "article" )
+        {
+            $langPartName   = 'artikel';
+
+            if( $language == "en" )
+            {
+                $langPartName = 'article';
+            }
+
+            $activeArticle  = \Input::get( $langPartName );
+
+            if( $activeArticle == $objItem->alias )
+            {
+                $isActive = true;
+            }
+
+            $strTitle       = ContentHelper::renderText($objItem->navTitle?:$objItem->title );
+            $strPageTitle   = $strTitle;
+
+            $objParentPage  = \PageModel::findByPk( $objItem->pid );
+            $href           = $objParentPage->getFrontendUrl('/' . $langPartName . '/' . $objItem->alias);
+            $strClass       = deserialize($objItem->cssID, true)[1] . ' article-link';
+
+            if( strlen($subitems) )
+            {
+                if( $objItem->submenuSRC === "news" )
+                {
+                    $activeAlias = \Input::get("auto_item");
+
+                    if( $activeAlias )
+                    {
+                        $objActiveNews = \NewsModel::findByIdOrAlias( $activeAlias );
+
+                        if( $objActiveNews && $objActiveNews->pid == $objItem->submenuNewsArchive )
+                        {
+                            $isTrail = true;
+                            $strClass .= ' trail';
+                        }
+                    }
+                }
+            }
+        }
+        elseif( $type == "news" )
+        {
+            $strTitle       = ContentHelper::renderText( $objItem->headline );
+            $strPageTitle   = $strTitle;
+
+            $activeAlias = \Input::get("auto_item");
+
+            if( $activeAlias == $objItem->alias )
+            {
+                $isActive = true;
+            }
+
+            $href           = \News::generateNewsUrl( $objItem, false);
+            $strClass       = $objItem->cssClass . ' news-link';
+        }
+
+        if( strlen($subitems) )
+        {
+            if( !preg_match('/submenu/', $strClass) )
+            {
+                $strClass .= ' submenu';
+            }
+        }
+
+        if( preg_match('/(
|{{br}})/', $strTitle) ) + { + $strClass .= ' double-line'; + } + + + $arrItem['isActive'] = $isActive; + $arrItem['isTrail'] = $isTrail; + $arrItem['subitems'] = $subitems; + $arrItem['class'] = trim($strClass); + $arrItem['title'] = \StringUtil::specialchars($strTitle, true); + $arrItem['pageTitle'] = \StringUtil::specialchars($strPageTitle, true); + $arrItem['link'] = $strTitle; + $arrItem['href'] = $href; + $arrItem['nofollow'] = (strncmp($objItem->robots, 'noindex,nofollow', 16) === 0); + $arrItem['target'] = ''; + $arrItem['description'] = str_replace(array("\n", "\r"), array(' ' , ''), $objItem->description); + + // Override the link target + if ($objItem->type == 'redirect' && $objItem->target) + { + $arrItem['target'] = ' target="_blank"'; + } + + if( count($arrVars) ) + { + foreach($arrVars as $varName => $varValue ) + { + $arrItem[ $varName ] = $varValue; + } + } + + return $arrItem; + } } diff --git a/Helper/BasicHelper.php b/Helper/BasicHelper.php index 94e2471..7a3b8d5 100644 --- a/Helper/BasicHelper.php +++ b/Helper/BasicHelper.php @@ -744,4 +744,62 @@ public static function renderFilterName( $filterName ) return trim($filterName); } + + + + public static function renderNavigation( $navModuleID, $strColumn = 'main', $strClasses = "" ) + { + global $objPage; + + $strBuffer = ''; + $objModule = \ModuleModel::findByPk( $navModuleID ); + + if ($objModule ) + { + $strClass = \Module::findClass( $objModule->type ); + + if (class_exists($strClass)) + { + $objModule->typePrefix = 'ce_'; + + if( $objModule->type == "booknav" ) + { + $objModule->rootPage = $objPage->rootId; + } + $cssID = \StringUtil::deserialize($objModule->cssID, TRUE); + + if( !strlen($cssID[1]) ) + { + $cssID = \StringUtil::deserialize($objClass->cssID, TRUE); + } + + /** @var \Module $objModule */ + $objModule = new $strClass($objModule, $strColumn); + $objModule->cssID = array($cssID[0], $strClasses?:$cssID[1]?:'nav-main'); + + $strBuffer = $objModule->generate(); + + if( $objModule->type == "booknav" ) + { + $strBuffer = preg_replace(array('/ (>|>)<\/a>/', '/>(<|<) /'), array('', '>'), $strBuffer); + $strBuffer = preg_replace('/([A-Za-z0-9\-\söäüÖÄÜß]{0,})<\/a>/', '$2', $strBuffer); + + preg_match_all('/