Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Commit

Permalink
readdir created theme array, fix to for counter
Browse files Browse the repository at this point in the history
Instead of using a hardcoded array, we are now generating this from CSS
files in the CodeMirror theme folder
Need to count the array length, not 1 less than it (2 places)
  • Loading branch information
mattpass committed Sep 8, 2012
1 parent fe8486d commit c9aca08
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/settings-screen.php
@@ -1,5 +1,4 @@
<?php include("settings.php");?>

<!DOCTYPE html>

<html>
Expand All @@ -19,8 +18,15 @@

<link rel="stylesheet" href="editor.css">
<?php
$themeArray = array("blackboard","cobalt","eclipse","elegant","erlang-dark","lesser-dark","monokai","neat","night","rubyblue","vibrant-ink","xq-dark");
for ($i=0;$i<count($themeArray)-1;$i++) {
$themeArray = array();
$handle = opendir('../'.$ICEcoder["codeMirrorDir"].'/theme/');
while (false !== ($file = readdir($handle))) {
if ($file !== "." && $file != "..") {
array_push($themeArray,basename($file,".css"));
}
}
sort($themeArray);
for ($i=0;$i<count($themeArray);$i++) {
echo '<link rel="stylesheet" href="../'.$ICEcoder["codeMirrorDir"].'/theme/'.$themeArray[$i].'.css">'.PHP_EOL;
}
?>
Expand Down Expand Up @@ -128,7 +134,7 @@
<select onchange="selectTheme();showButton()" id="select" name="theme">
<option<?php if ($ICEcoder["theme"]=="default") {echo ' selected';}; ?>>default</option>
<?php
for ($i=0;$i<count($themeArray)-1;$i++) {
for ($i=0;$i<count($themeArray);$i++) {
$optionSelected = $ICEcoder["theme"]==$themeArray[$i] ? ' selected' : '';
echo '<option'.$optionSelected.'>'.$themeArray[$i].'</option>'.PHP_EOL;
}
Expand Down

0 comments on commit c9aca08

Please sign in to comment.