readdir created theme array, fix to for counter

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)
This commit is contained in:
Matt Pass
2012-09-08 15:04:06 +01:00
parent fe8486d456
commit c9aca08d4e

View File

@@ -1,5 +1,4 @@
<?php include("settings.php");?>
<!DOCTYPE html>
<html>
@@ -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;
}
?>
@@ -128,7 +134,7 @@ theme<br>
<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;
}