Ignore:
Timestamp:
Apr 25, 2012, 11:45:21 AM (12 years ago)
Author:
flop25
Message:

feature :
-new system of prefilter : using *.pattern.php files

bug :
-sprite updated for 2.4 and css too
-patterns added for 2.4.x

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/floOS/OS_default/themeconf.inc.php

    r11929 r14390  
    4747        }
    4848}
     49
     50
     51// function load_pattern
     52// include the right ***.pattern.php
     53// not compatible 2.2and<2.2
     54
     55function load_pattern()
     56{
     57  global $pattern;
     58  $pwgversion=str_replace('.','',PHPWG_VERSION);
     59  $pwgversion_array=explode('.', PHPWG_VERSION);
     60  if (file_exists($pwgversion.'pattern.php'))
     61  {
     62    include($pwgversion.'.pattern.php');
     63    return true;
     64  }
     65  elseif (file_exists(PHPWG_ROOT_PATH.'themes/OS_default/'.$pwgversion_array[0].$pwgversion_array[1].'x.pattern.php'))
     66  {
     67    include(PHPWG_ROOT_PATH.'themes/OS_default/'.$pwgversion_array[0].$pwgversion_array[1].'x.pattern.php');
     68    return true;
     69  }
     70  else
     71  {
     72    $list_pattern_path=array();
     73    $dir=PHPWG_ROOT_PATH.'themes/OS_default';
     74    $dh = opendir($dir);
     75    while (($file = readdir ($dh)) !== false ) {
     76      if ($file !== '.' && $file !== '..') {
     77        $path =$dir.'/'.$file;
     78        if (!is_dir ($path)) {
     79          if(strpos($file,'pattern.php')!==false) { //On ne prend que les .pattern.php
     80            $list_pattern_path[]=$file;
     81          }
     82        }
     83      }
     84    }
     85    closedir($dh);
     86    $f=0;
     87    for($i = 10; $i >=0; $i--)
     88    {
     89      if (in_array($pwgversion_array[0].$i.'.pattern.php',$list_pattern_path))
     90      {
     91        include($pwgversion_array[0].$i.'.pattern.php');
     92        return true;
     93        $f=1;
     94        break;
     95      }
     96    }
     97    if ($f=0)
     98    {
     99      return false;
     100    }
     101  }
     102 
     103}
     104if(!load_pattern())
     105{
     106  global $page;
     107  $page['errors'][]='Theme not compatible';
     108}
     109
     110
    49111/************************************ index.tpl ************************************/
    50112add_event_handler('loc_end_index', 'OS_default_index');
     
    56118function OS_default_prefilter_index($content, &$smarty)
    57119{
    58   $search = '#<div id="content" class="content">#'; 
    59   $replacement = '<div id="content" class="content">
    60   <table id="table_content" border="0" cellspacing="0" cellpadding="0">
    61     <tr>
    62       <td id="section_up_left">&nbsp;</td>
    63       <td id="section_up">
    64 ';
    65   $content = preg_replace($search, $replacement, $content);
    66 
    67   $search = '#</div>\{\* <\!-- titrePage --> \*\}#'; 
    68   $replacement = '';
    69   $content = preg_replace($search, $replacement, $content);
    70        
    71   $search = '#<h2>\{\$TITLE\}</h2>#'; 
    72   $replacement = '<h2>{$TITLE}</h2>
    73         </div>{* <!-- titrePage --> *} 
    74           </td>
    75       <td id="section_up_right">&nbsp;</td>
    76     </tr>
    77     <tr>
    78       <td id="section_left">&nbsp;</td>
    79       <td id="section_in">';
    80   $content = preg_replace($search, $replacement, $content);
    81        
    82   $search = '#\{if \!empty\(\$PLUGIN_INDEX_CONTENT_END\)\}\{\$PLUGIN_INDEX_CONTENT_END\}\{/if\}#'; 
    83   $replacement = '{if !empty($PLUGIN_INDEX_CONTENT_END)}{$PLUGIN_INDEX_CONTENT_END}{/if}
    84       </td>
    85           <td id="section_right">&nbsp;</td>
    86     </tr>
    87     <tr>
    88       <td id="section_bottom_left">&nbsp;</td>
    89       <td id="section_bottom" >&nbsp;</td>
    90       <td id="section_bottom_right" >&nbsp;</td>
    91     </tr>
    92   </table>
    93 ';
    94   return preg_replace($search, $replacement, $content);
     120  global $pattern;
     121  $r=$pattern['OS_default_prefilter_index']['R'];
     122  $ps=$pattern['OS_default_prefilter_index']['S'];
     123  foreach($r as $i => $pr)
     124  {
     125    $content = str_replace($ps[$i], $pr, $content);
     126  }
     127  return $content;
    95128}
    96129
     
    104137function OS_default_prefilter_picture($content, &$smarty)
    105138{
    106   $search = '#<div id="imageInfos">.*<table id="standard" class="infoTable">#s'; 
    107   $replacement = '<table id="standard" class="infoTable">';
    108   return preg_replace($search, $replacement, $content);
     139  global $pattern;
     140  $r=$pattern['OS_default_prefilter_picture']['R'];
     141  $ps=$pattern['OS_default_prefilter_picture']['S'];
     142  foreach($r as $i => $pr)
     143  {
     144    $content = preg_replace($ps[$i], $pr, $content);
     145  }
     146  return $content;
    109147}
    110148
    111 
    112 
    113149?>
Note: See TracChangeset for help on using the changeset viewer.