<?php
/*
  www.oscGold.com (C) Kamelia-Net Jacek Krysiak
  modul oscGold wer 4.0
*/
?>
<?php
if ((TEMPLATE_SWITCHING_ALLOWED == 'true') && (TEMPLATE_SWITCHING_MENU == 'true'))
{
  echo '<div id="templateSwitcher" style="text-align: center; margin: 2px auto; font-size: 12px; font-family: Tahoma, Arial; border-top: 1px solid #777; border-bottom: 1px solid #777; background: #efefef; padding:4px;">';
  echo '<center>';
  echo '<span style="font-size: 13px; font-family: Tahoma, Arial; font-weight:bold">';
  echo 'Dostępne szablony sklepu:<br>';
  echo '</span>'; 
  $dir =  getcwd()."/templates/" ; /* get the current path and add "/templates/" to the end */
  if (is_dir($dir))
  {
    /* check if the path is a directory */
    if ($dh = opendir($dir))
    {
      /* create a file system object ($dh) */
      while (($file = readdir($dh)) !== false)
        {
          /* repeat with all the files in the directory */
          if(filetype($dir . $file) == "dir")
          {
            /* if the file in the directory is a folder */
            if($file != "..")
            {
              /* if the folder isn't called ".." (this is not a folder as such, I think its to go up one level?) */
              $firstchar = substr($file, 0, 1); // get the first character of the folder's name
              if(($firstchar != "_")&&($firstchar != "."))
              {
                /* this means that any folder starting with "_" won't be displayed, allows to have secret template in the directory */
                $ts_template_array[]= $file;              }
            }
          }
        }
      closedir($dh); /* close the file sytem object */
    }
  }
if (is_array ($ts_template_array)) sort ($ts_template_array,SORT_STRING);
foreach ($ts_template_array as $file) {
  echo "<a style=\"color: blue; margin: 5px;\" href=\"" . tep_href_link('index.php', 'tplDir='.$file) . "\">$file</a>"; 
}  
echo '</center></div>';
}
?>
