language_path))
{
while (($file = readdir($handle)) !== false)
{
$pos = strpos($file, '.');
if ($pos > 0 && substr($file, $pos) == '.php')
{
$languages[] = substr($file, 0, $pos);
}
}
closedir($handle);
}
// Sort the languages alphabetically
sort($languages);
// Process our current state
if ( !$stage || $stage == 1 )
{
// During stage one we output the form for the user to fill out. Form submission will move us onto stage two.
echo '' . "\n";
echo '
RJ_InsertCode CSS Generator' . "\n";
echo '' . "\n";
echo 'RJ_InsertCode CSS Generator
' . "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . "\n";
}
elseif ( $stage == 2 )
{
// During stage two we output the css file based on the options selected in stage one.
if( $outputAll == "true" )
{
// set the file type and name
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="all_languages.css"');
// print the concatenated style sheets of all the languages
$trimComments = 0;
foreach ($languages as $lang)
{
$geshi->set_language($lang);
$output = $geshi->get_stylesheet(false);
if( $trimComments == 0 )
{
// output with header comments
echo $geshi->get_stylesheet(false);
$trimComments = 1;
}
else
{
// remove header comments on all stylesheets after the first one
echo preg_replace('/^\/\*\*.*?\*\//s', '', $geshi->get_stylesheet(false));
}
}
}
else
{
// set the file type and name
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $selectedLang . '.css"');
// print the style sheet of the selected language
$geshi->set_language($selectedLang);
echo $geshi->get_stylesheet(false);
}
}
?>