Advertisement
jooag

Joomla 3.0 modules.php and static variables - caching error

Nov 6th, 2012
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.18 KB | None | 0 0
  1. <?php
  2. defined('_JEXEC') or die;
  3. ### Joomla Template - Workframe
  4. ### www.joomla-agentur.de
  5. ?>
  6. <?php
  7. function modChrome_jooag( $module, &$params, &$attribs ){
  8.     //Variablen die benötigt werden
  9.     $doc = JFactory::getDocument();
  10.     $modCountSum = $doc->countModules($attribs['name']);
  11.     $modPosition = $module->position;//$module -> id title name
  12.     $modPerRow = $doc->params->get('modulesPerRow');
  13.     $spanCustom = '';
  14.     $spanOffset = '';
  15.     //Variablen die innerhalb der Funktion gespeichert werden müssen
  16.     static $modCount;
  17.     static $spanMatrix;
  18.     $modCount++;
  19.     //Titel nach [modus_xx] Filtern
  20.     if($modCount == 1){$spanMatrix = array();}
  21.     preg_match_all("/^(.*\[)(.*)(\])/", $module->title, $betweenBrackets);
  22.    
  23.     if(isset($betweenBrackets[2][0])== false){$betweenBrackets = array ( "2"  => array("0" => ' [empty] '));}
  24.    
  25.     $titleSuffix = explode('|',$betweenBrackets[2][0]);
  26.     foreach($titleSuffix as $options){
  27.         if(preg_match('/preset/',$options) and $modCount == 1){
  28.             $titleGridResult = explode("_",$options);
  29.             $moduleMode = $titleGridResult[0];
  30.             $modGrids = $titleGridResult[1];
  31.         }
  32.         if(preg_match('/span/',$options)){
  33.             $spanCustom = $options;
  34.         }
  35.         if(preg_match('/offset/',$options)){
  36.             $spanOffset = $options;
  37.         }
  38.     }
  39.  
  40.     if($modCount == 1){
  41.         //Modulaufteilung nach Anzahl
  42.         if($modCountSum > $modPerRow){$newModulesPerRow = $modPerRow;}
  43.         if($modCountSum <= $modPerRow || $modPerRow == 0){$newModulesPerRow = $modCountSum;}
  44.        
  45.         for($i=1; $i <= $modCountSum; $i++){
  46.             $spanMatrix[$modPosition][$i] = 12 / $newModulesPerRow;
  47.         }
  48.         //Left & Right Calculating
  49.         if($modPosition == 'left' || $modPosition == 'right'){
  50.             for($i=1; $i <= $modCountSum; $i++){
  51.                 $spanMatrix[$modPosition][$i] = $doc->params->get($modPosition.'Span');
  52.             }
  53.         }
  54.         //Mode: Preset
  55.         if(isset($moduleMode)){
  56.             $mG = $modGrids.',';
  57.             $modGrids = explode(",",'0,'.$mG.$mG.$mG.$mG.$mG.$mG.$mG.$mG.$mG.$mG.$mG.$mG.$mG.$mG.$mG.$mG.$mG.$mG.$mG.$mG.$mG.$mG.$mG.$mG.$mG); 
  58.             for($i=1; $i <= 12; $i++){
  59.                 $spanMatrix[$modPosition][$i] = $modGrids[$i];
  60.             }
  61.         }
  62.         //Abrunden
  63.         for($i=1; $i <= $modCountSum; $i++){
  64.             $spanMatrix[$modPosition][$i] = ceil($spanMatrix["$modPosition"][$i]);
  65.         }
  66.     }
  67.     //Module Mode Detection for the reft and right module
  68.     $modDef = array('left','right');   
  69.  
  70.     //AUSGABE MODULE - ALL
  71.     if($modCount == 1 and in_array($modPosition, $modDef) == false){echo '<div class="row'.jooagFluid().' '.$modPosition.'-section">';}
  72.             echo '<div class="span'.$spanMatrix[$modPosition][$modCount].' '.$modPosition.' id'.$modCount.' module '.$params->get('moduleclass_sfx').' '.$spanCustom.' '.$spanOffset.'">';
  73.                 if ($module->showtitle){echo '<h4 class="titlestyle"><i></i>'.preg_replace('/\[(.*)\]/','',$module->title).'</h4>';}
  74.                 echo $module->content;
  75.             echo '</div>';
  76.         if($modCount == $modCountSum and in_array($modPosition, $modDef) == false){$modCount = 0;echo '</div>';}
  77.         if(in_array($modPosition, $modDef)){$modCount = 0;}
  78.  
  79.    
  80.     //NEW row Detection
  81.     $spanSum = '';
  82.     for($i=1; $i <= $modCount; $i++){$spanSum = $spanSum + $spanMatrix[$modPosition][$i];} 
  83.     if(($modCount) % 12 == 0 and $modCount != 0){echo '/div><div class="row'.jooagFluid().' '.$modPosition.'-section">';}
  84. }
  85. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement