Example #1
0
 /**
  * @todo document this function
  * @todo This and other methods share a lot of directory traversal
  * functionality, which could be split out somehow.
  * @todo actually, this should be implemented using a registry
  */
 public function getSupportedLanguages($return_human = false)
 {
     $languages = array();
     $ignore = array('.', '..', 'CVS');
     $dh = opendir(GESHI_LANGUAGES_ROOT);
     while (false !== ($dir = readdir($dh))) {
         if (in_array($dir, $ignore) || is_file(GESHI_LANGUAGES_ROOT . $dir)) {
             continue;
         }
         // Check the directory for the dialect files
         $ldh = opendir(GESHI_LANGUAGES_ROOT . $dir);
         while (false !== ($file = readdir($ldh))) {
             if (in_array($file, $ignore) || is_dir(GESHI_LANGUAGES_ROOT . "{$dir}/{$file}") || substr($file, -4) != '.php') {
                 continue;
             }
             // Found a language file
             $file = substr($file, 0, -4);
             if ('common' == $file || 'class' == substr($file, 0, 5)) {
                 continue;
             }
             if ($return_human) {
                 $languages["{$dir}/{$file}"] = GeSHi::getHumanLanguageName("{$dir}/{$file}");
             } else {
                 $languages[] = "{$dir}/{$file}";
             }
         }
     }
     return $languages;
 }