[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/templates/ -> common_top.php (source)

   1  <?php
   2  /*
   3  Contributed by: <-- R O B --> La Rochelle France
   4  Released under the GNU General Public License
   5  2004/01/29
   6  
   7  Automaticly shows all templates folders except the ones starting with an underscore
   8  (i.e.: "_my-secret-template-dir/")
   9  Just copy this file to your templates directory,
  10  and include it in your main_page.tpl.php files for example.
  11  */
  12  ?>
  13  <?php
  14  if ((TEMPLATE_SWITCHING_ALLOWED == 'true') && (TEMPLATE_SWITCHING_MENU == 'true'))
  15  {
  16    echo '<div id="templateSwitcher" style="text-align: center; margin: 0px auto; font-size: 12px; border-top: 1px solid #777; border-bottom: 1px solid #777; background: #c0c0c0;">';
  17    echo 'Switch template:';
  18    $dir =  getcwd()."/templates/" ; /* get the current path and add "/templates/" to the end */
  19    if (is_dir($dir))
  20    {
  21      /* check if the path is a directory */
  22      if ($dh = opendir($dir))
  23      {
  24        /* create a file system object ($dh) */
  25        while (($file = readdir($dh)) !== false)
  26          {
  27            /* repeat with all the files in the directory */
  28            if(filetype($dir . $file) == "dir")
  29            {
  30              /* if the file in the directory is a folder */
  31              if($file != "..")
  32              {
  33                /* if the folder isn't called ".." (this is not a folder as such, I think its to go up one level?) */
  34                $firstchar = substr($file, 0, 1); // get the first character of the folder's name
  35                if(($firstchar != "_")&&($firstchar != "."))
  36                {
  37                  /* this means that any folder starting with "_" won't be displayed, allows to have secret template in the directory */
  38                  $ts_template_array[]= $file;              }
  39              }
  40            }
  41          }
  42        closedir($dh); /* close the file sytem object */
  43      }
  44    }
  45  if (is_array ($ts_template_array)) sort ($ts_template_array,SORT_STRING);
  46  foreach ($ts_template_array as $file) {
  47    echo "<a style=\"color: blue; text-decoration: underline; margin: 5px;\" href=\"" . tep_href_link('index.php', 'tplDir='.$file) . "\">$file</a>"; 
  48  }  
  49  echo '<br>Current template directory: ' .  '<span style="color: #f35c00; font-weight: bold;">' . DIR_WS_TEMPLATES . '</span>';
  50  echo '</div>';
  51  }
  52  ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7