diff --git a/constant.php b/constant.php index e9f2681..4ea100c 100644 --- a/constant.php +++ b/constant.php @@ -2,6 +2,6 @@ const APP_NAME = "ph-Bookshelf"; -const VERSION = "0.3.0.9"; +const VERSION = "0.3.0.10"; const CHANNEL = "suk-ws"; const BRANCH = "master"; diff --git a/src/Data/PageMeta.php b/src/Data/PageMeta.php index add6c7e..70fdf4c 100644 --- a/src/Data/PageMeta.php +++ b/src/Data/PageMeta.php @@ -1,5 +1,6 @@ getConfiguration($key); + if ($valueAttr != null) $value = $valueAttr; + return $value; + } + + public static function getConfigurationLevelPage (string $key): ?string { + $value = self::getConfigurationLevelBook($key); + $valueAttr = self::$page->getConfiguration($key); + if ($valueAttr != null) $value = $valueAttr; + return $value; + } + + public static function compatibilityOldTitlePolicy (): bool { + if (self::getConfigurationLevelPage("compatibility.article.title.oldversion") == "true") + return true; + return false; + } + + public static function highlightJsTheme (): string { + $theme = trim(self::getConfigurationLevelPage("customization.article.codeblock.highlightjs.theme")); + if (empty($theme)) return "atom-one-dark"; + return $theme; + } + } diff --git a/src/Data/SiteMeta.php b/src/Data/SiteMeta.php index a3fb68d..5f81b8e 100644 --- a/src/Data/SiteMeta.php +++ b/src/Data/SiteMeta.php @@ -1,5 +1,6 @@ getConfiguration($key); + } + } diff --git a/src/Element/BookContent/BookContented.php b/src/Element/BookContent/BookContented.php index 6a3383b..412cbab 100644 --- a/src/Element/BookContent/BookContented.php +++ b/src/Element/BookContent/BookContented.php @@ -1,6 +1,7 @@ id = $id; $this->name = $name; @@ -32,6 +35,7 @@ class BookContented { else $id = $attrId->nodeValue; $node = new BookContented($id, $name); $node->childs = Chapter::parse($xmlData, null); + Bookshelf::parseConfigurationAttr($xmlData->attributes, $node->configurations, array("name", "id")); } else throw new Exception("No child or attribute found on BookWithContent"); return $node; @@ -71,4 +75,8 @@ class BookContented { return $this->childs->getPage($id); } + public function getConfiguration (string $key): ?string { + return @$this->configurations[$key]; + } + } diff --git a/src/Element/BookContent/Page.php b/src/Element/BookContent/Page.php index ee08a42..592cc1c 100644 --- a/src/Element/BookContent/Page.php +++ b/src/Element/BookContent/Page.php @@ -1,6 +1,7 @@ id = $id; $this->name = $name; @@ -33,6 +36,7 @@ class Page { if ($attrId == null) throw new Exception("Page xml data named \"$name\" missing attribute \"id\""); else $id = $attrId->nodeValue; $node = new Page($id, $name, $parent); + Bookshelf::parseConfigurationAttr($xmlData->attributes, $node->configurations, array("name", "id")); } else throw new Exception("Book xml data missing attributes"); for ($child = $xmlData->firstChild;$child != null ; $child = $child->nextSibling) { @@ -57,6 +61,10 @@ class Page { return $this->parent; } + public function getConfiguration (string $key): ?string { + return @$this->configurations[$key]; + } + public function getSummaryHtml (): string { // $str = // "