little code refactoring. re #34
This commit is contained in:
parent
1e165fb574
commit
1c50ed49fe
37
base.php
37
base.php
|
@ -805,33 +805,30 @@ class PageAbout extends Page
|
||||||
|
|
||||||
class PageCustomize extends Page
|
class PageCustomize extends Page
|
||||||
{
|
{
|
||||||
|
private function isChecked ($key, $testedValue = NULL) {
|
||||||
|
$value = getCurrentOption ($key);
|
||||||
|
if (!is_null ($testedValue)) {
|
||||||
|
if (in_array ($testedValue, $value)) {
|
||||||
|
return "checked='checked'";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($value == 1) {
|
||||||
|
return "checked='checked'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
public function InitializeContent ()
|
public function InitializeContent ()
|
||||||
{
|
{
|
||||||
$this->title = localize ("customize.title");
|
$this->title = localize ("customize.title");
|
||||||
$this->entryArray = array ();
|
$this->entryArray = array ();
|
||||||
|
|
||||||
$use_fancybox = "";
|
|
||||||
if (getCurrentOption ("use_fancyapps") == 1) {
|
|
||||||
$use_fancybox = "checked='checked'";
|
|
||||||
}
|
|
||||||
$html_tag_filter = "";
|
|
||||||
if (getCurrentOption ("html_tag_filter") == 1) {
|
|
||||||
$html_tag_filter = "checked='checked'";
|
|
||||||
}
|
|
||||||
|
|
||||||
$ignored_categories = array ();
|
|
||||||
$ignoredBaseArray = array (PageQueryResult::SCOPE_AUTHOR,
|
$ignoredBaseArray = array (PageQueryResult::SCOPE_AUTHOR,
|
||||||
PageQueryResult::SCOPE_TAG,
|
PageQueryResult::SCOPE_TAG,
|
||||||
PageQueryResult::SCOPE_SERIES,
|
PageQueryResult::SCOPE_SERIES,
|
||||||
PageQueryResult::SCOPE_PUBLISHER,
|
PageQueryResult::SCOPE_PUBLISHER,
|
||||||
"language");
|
"language");
|
||||||
foreach ($ignoredBaseArray as $key) {
|
|
||||||
if (in_array ($key, getCurrentOption ('ignored_categories'))) {
|
|
||||||
$ignored_categories [$key] = "checked='checked'";
|
|
||||||
} else {
|
|
||||||
$ignored_categories [$key] = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$content = "";
|
$content = "";
|
||||||
if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) {
|
if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) {
|
||||||
|
@ -862,7 +859,7 @@ class PageCustomize extends Page
|
||||||
$content, "text",
|
$content, "text",
|
||||||
array ()));
|
array ()));
|
||||||
if (!useServerSideRendering ()) {
|
if (!useServerSideRendering ()) {
|
||||||
$content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" ' . $use_fancybox . ' />';
|
$content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" ' . $this->isChecked ("use_fancyapps") . ' />';
|
||||||
array_push ($this->entryArray, new Entry (localize ("customize.fancybox"), "",
|
array_push ($this->entryArray, new Entry (localize ("customize.fancybox"), "",
|
||||||
$content, "text",
|
$content, "text",
|
||||||
array ()));
|
array ()));
|
||||||
|
@ -875,14 +872,14 @@ class PageCustomize extends Page
|
||||||
array_push ($this->entryArray, new Entry (localize ("customize.email"), "",
|
array_push ($this->entryArray, new Entry (localize ("customize.email"), "",
|
||||||
$content, "text",
|
$content, "text",
|
||||||
array ()));
|
array ()));
|
||||||
$content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="html_tag_filter" ' . $html_tag_filter . ' />';
|
$content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="html_tag_filter" ' . $this->isChecked ("html_tag_filter") . ' />';
|
||||||
array_push ($this->entryArray, new Entry (localize ("customize.filter"), "",
|
array_push ($this->entryArray, new Entry (localize ("customize.filter"), "",
|
||||||
$content, "text",
|
$content, "text",
|
||||||
array ()));
|
array ()));
|
||||||
$content = "";
|
$content = "";
|
||||||
foreach ($ignoredBaseArray as $key) {
|
foreach ($ignoredBaseArray as $key) {
|
||||||
$keyPlural = preg_replace ('/(ss)$/', 's', $key . "s");
|
$keyPlural = preg_replace ('/(ss)$/', 's', $key . "s");
|
||||||
$content .= '<input type="checkbox" name="ignored_categories[]" onchange="updateCookieFromCheckboxGroup (this);" id="ignored_categories_' . $key . '" ' . $ignored_categories [$key] . ' > ' . localize ("{$keyPlural}.title") . '</input> ';
|
$content .= '<input type="checkbox" name="ignored_categories[]" onchange="updateCookieFromCheckboxGroup (this);" id="ignored_categories_' . $key . '" ' . $this->isChecked ("ignored_categories", $key) . ' > ' . localize ("{$keyPlural}.title") . '</input> ';
|
||||||
}
|
}
|
||||||
|
|
||||||
array_push ($this->entryArray, new Entry (localize ("customize.ignored"), "",
|
array_push ($this->entryArray, new Entry (localize ("customize.ignored"), "",
|
||||||
|
|
Loading…
Reference in a new issue