AntonLV 9 سال پیش
والد
کامیت
0575bbeae3

+ 42 - 0
inc/classes/BxDolTemplate.php

@@ -784,6 +784,16 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
             $this->aPage['js_images'][$sKey] = $sUrl;
         }
     }
+	/**
+	 * Add CSS style.
+	 *
+	 * @param string $sName CSS class name.
+	 * @param string $sContent CSS class styles.
+	 */
+	function addCssStyle($sName, $sContent)
+	{
+		$this->aPage['css_styles'][$sName] = $sContent;
+	}
     /**
      * Set page keywords.
      *
@@ -1160,6 +1170,18 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
             $sContent = $this->parseHtmlByName('default.html', $aVariables, $this->_sKeyWrapperHtml, BX_DOL_TEMPLATE_CHECK_IN_BOTH);
 
         //--- Add CSS and JS at the very last ---//
+        if(strpos($sContent, '<bx_include_css_styles />') !== false) {
+            $aStyles = array(
+                'display' => 'none !important'
+            );
+
+            if(isLogged())
+                $this->addCssStyle('.bx-hide-when-logged-in', $aStyles);
+            else
+                $this->addCssStyle('.bx-hide-when-logged-out', $aStyles);
+
+            $sContent = str_replace('<bx_include_css_styles />', $this->includeCssStyles(), $sContent);
+        }
 
         if(strpos($sContent , '<bx_include_css_system />') !== false) {
             $sContent = str_replace('<bx_include_css_system />', $this->includeFiles('css', true), $sContent);
@@ -1817,6 +1839,26 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
     {
         return "<style>" . $sCode . "</style>";
     }
+	/**
+     *  Include CSS style(s) in the page's head section.
+     */
+	function includeCssStyles()
+	{
+		$sResult = "";
+		if(empty($this->aPage['css_styles']) || !is_array($this->aPage['css_styles']))
+			return $sResult;
+
+		foreach($this->aPage['css_styles'] as $sName => $aContent) {
+			$sContent = "";
+			if(!empty($aContent) && is_array($aContent))
+				foreach($aContent as $sStyleName => $sStyleValue)
+					$sContent .= "\t" . $sStyleName . ": " . $sStyleValue . ";\r\n";
+
+			$sResult .= $sName . " {\r\n" . $sContent . "}\r\n";
+		}
+
+		return !empty($sResult) ? $this->_wrapInTagCssCode($sResult) : '';
+	}
     /**
      * Include CSS/JS file(s) attached to the page in its head section.
      * @see the method is system and would be called automatically.

+ 1 - 0
modules/boonex/decorous/data/template/system/_header.html

@@ -13,6 +13,7 @@
 
     <meta http-equiv="Content-Style-Type" content="text/css" />
 
+    <bx_include_css_styles />
     <bx_include_css_system />
     <bx_include_css />
 

+ 1 - 0
modules/boonex/ocean/data/template/system/_header.html

@@ -13,6 +13,7 @@
 
     <meta http-equiv="Content-Style-Type" content="text/css" />
 
+    <bx_include_css_styles />
     <bx_include_css_system />
     <bx_include_css />
     <link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,400,600' rel='stylesheet' type='text/css' />

+ 1 - 0
modules/boonex/protean/data/template/system/_header.html

@@ -13,6 +13,7 @@
 
     <meta http-equiv="Content-Style-Type" content="text/css" />
 
+    <bx_include_css_styles />
     <bx_include_css_system />
     <bx_include_css />
 

+ 1 - 0
studio/template/_header.html

@@ -9,6 +9,7 @@
         __meta_info__
 	    __page_robots__
 
+        <bx_include_css_styles />
         <bx_include_css_system />
         <bx_include_css />
 

+ 1 - 0
template/_header.html

@@ -13,6 +13,7 @@
 
     <meta http-equiv="Content-Style-Type" content="text/css" />
 
+    <bx_include_css_styles />
     <bx_include_css_system />
     <bx_include_css />