Refactorize a little. re #127
This commit is contained in:
parent
1c50ed49fe
commit
ebbd830a33
48
base.php
48
base.php
|
@ -805,20 +805,37 @@ class PageAbout extends Page
|
|||
|
||||
class PageCustomize extends Page
|
||||
{
|
||||
private function isChecked ($key, $testedValue = NULL) {
|
||||
private function isChecked ($key, $testedValue = 1) {
|
||||
$value = getCurrentOption ($key);
|
||||
if (!is_null ($testedValue)) {
|
||||
if (is_array ($value)) {
|
||||
if (in_array ($testedValue, $value)) {
|
||||
return "checked='checked'";
|
||||
}
|
||||
} else {
|
||||
if ($value == 1) {
|
||||
if ($value == $testedValue) {
|
||||
return "checked='checked'";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private function isSelected ($key, $value) {
|
||||
if (getCurrentOption ($key) == $value) {
|
||||
return "selected='selected'";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private function getStyleList () {
|
||||
$result = array ();
|
||||
foreach (glob ("styles/style-*.css") as $filename) {
|
||||
if (preg_match ('/styles\/style-(.*?)\.css/', $filename, $m)) {
|
||||
array_push ($result, $m [1]);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function InitializeContent ()
|
||||
{
|
||||
$this->title = localize ("customize.title");
|
||||
|
@ -833,27 +850,14 @@ class PageCustomize extends Page
|
|||
$content = "";
|
||||
if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) {
|
||||
$content .= '<select id="style" onchange="updateCookie (this);">';
|
||||
foreach ($this-> getStyleList () as $filename) {
|
||||
$content .= "<option value='{$filename}' " . $this->isSelected ("style", $filename) . ">{$filename}</option>";
|
||||
}
|
||||
foreach (glob ("styles/style-*.css") as $filename) {
|
||||
if (preg_match ('/styles\/style-(.*?)\.css/', $filename, $m)) {
|
||||
$filename = $m [1];
|
||||
}
|
||||
$selected = "";
|
||||
if (getCurrentOption ("style") == $filename) {
|
||||
if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) {
|
||||
$selected = "selected='selected'";
|
||||
} else {
|
||||
$selected = "checked='checked'";
|
||||
}
|
||||
}
|
||||
if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) {
|
||||
$content .= "<option value='{$filename}' {$selected}>{$filename}</option>";
|
||||
} else {
|
||||
$content .= "<input type='radio' onchange='updateCookieFromCheckbox (this);' id='style-{$filename}' name='style' value='{$filename}' {$selected} /><label for='style-{$filename}'> {$filename} </label>";
|
||||
}
|
||||
}
|
||||
if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) {
|
||||
$content .= '</select>';
|
||||
} else {
|
||||
foreach ($this-> getStyleList () as $filename) {
|
||||
$content .= "<input type='radio' onchange='updateCookieFromCheckbox (this);' id='style-{$filename}' name='style' value='{$filename}' " . $this->isChecked ("style", $filename) . " /><label for='style-{$filename}'> {$filename} </label>";
|
||||
}
|
||||
}
|
||||
array_push ($this->entryArray, new Entry (localize ("customize.style"), "",
|
||||
$content, "text",
|
||||
|
|
Loading…
Reference in a new issue