2015-06-29 16:11:01 +02:00
|
|
|
<?php namespace Todaymade\Daux;
|
|
|
|
|
2020-04-22 22:24:52 +02:00
|
|
|
use Todaymade\Daux\Format\Confluence\Config as ConfluenceConfig;
|
2016-09-30 22:24:33 +02:00
|
|
|
use Todaymade\Daux\Format\HTML\Config as HTMLConfig;
|
2019-12-05 21:25:58 +01:00
|
|
|
use Todaymade\Daux\Format\HTML\Theme as Theme;
|
2020-04-22 22:24:52 +02:00
|
|
|
use Todaymade\Daux\Tree\Content;
|
|
|
|
use Todaymade\Daux\Tree\Entry;
|
2015-06-29 16:11:01 +02:00
|
|
|
|
2016-09-30 22:24:33 +02:00
|
|
|
class Config extends BaseConfig
|
2015-07-17 23:38:06 +02:00
|
|
|
{
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getTitle()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('title');
|
2017-05-16 23:17:06 +02:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function hasAuthor(): bool
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->hasValue('author');
|
2016-07-04 20:33:44 +02:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getAuthor()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('author');
|
2016-07-04 20:33:44 +02:00
|
|
|
}
|
2016-07-27 23:27:51 +02:00
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function hasTagline(): bool
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->hasValue('tagline');
|
2016-07-27 23:27:51 +02:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getTagline()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('tagline');
|
2016-07-27 23:27:51 +02:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getCurrentPage()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('current_page');
|
2016-07-27 23:27:51 +02:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function setCurrentPage(Content $entry)
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
$this->setValue('current_page', $entry);
|
2016-09-21 23:30:01 +02:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getDocumentationDirectory()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('docs_directory');
|
2016-09-06 23:11:32 +02:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getThemesDirectory()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('themes_directory');
|
2016-09-06 23:11:32 +02:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getThemesPath()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('themes_path');
|
2016-07-28 22:47:47 +02:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getFormat()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('format');
|
2016-07-28 22:47:47 +02:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function hasTimezone(): bool
|
|
|
|
{
|
2016-09-06 23:11:32 +02:00
|
|
|
return isset($this['timezone']);
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getTimezone()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('timezone');
|
2016-09-06 23:11:32 +02:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getTree()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('tree');
|
2016-07-27 23:27:51 +02:00
|
|
|
}
|
2016-08-02 23:39:57 +02:00
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function setTree($tree)
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
$this->setValue('tree', $tree);
|
2016-08-16 23:25:06 +02:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function isMultilanguage(): bool
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->hasValue('languages') && !empty($this->getValue('languages'));
|
2016-08-16 23:25:06 +02:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getLanguages(): array
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('languages');
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getLanguage(): string
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('language');
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getMode()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('mode');
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function isLive()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('mode') == Daux::LIVE_MODE;
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function isStatic()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('mode') == Daux::STATIC_MODE;
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function shouldInheritIndex()
|
|
|
|
{
|
2016-08-04 22:10:36 +02:00
|
|
|
// As the global configuration is always present, we
|
|
|
|
// need to test for the existence of the legacy value
|
|
|
|
// first. Then use the current value.
|
2019-12-07 11:22:40 +01:00
|
|
|
if ($this->hasValue('live') && array_key_exists('inherit_index', $this['live'])) {
|
2016-08-02 23:39:57 +02:00
|
|
|
return $this['live']['inherit_index'];
|
|
|
|
}
|
|
|
|
|
2016-08-04 22:10:36 +02:00
|
|
|
return $this['html']['inherit_index'];
|
2016-08-02 23:39:57 +02:00
|
|
|
}
|
2016-09-15 17:20:24 +02:00
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getIndexKey()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('mode') == Daux::STATIC_MODE ? 'index.html' : 'index';
|
2016-09-15 17:20:24 +02:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getProcessor()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('processor');
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getConfluenceConfiguration(): ConfluenceConfig
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return new ConfluenceConfig($this->hasValue('confluence') ? $this->getValue('confluence') : []);
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getHTML(): HTMLConfig
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return new HTMLConfig($this->hasValue('html') ? $this->getValue('html') : []);
|
|
|
|
}
|
2016-09-15 17:20:24 +02:00
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getTheme(): ?Theme
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->hasValue('theme') ? new Theme($this->getValue('theme')) : null;
|
2016-09-15 17:20:24 +02:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getValidContentExtensions()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('valid_content_extensions');
|
2016-09-15 17:20:24 +02:00
|
|
|
}
|
2016-09-30 22:24:33 +02:00
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function setValidContentExtensions(array $value)
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
$this->setValue('valid_content_extensions', $value);
|
2016-09-30 22:24:33 +02:00
|
|
|
}
|
2018-06-06 23:20:29 +02:00
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function canCache()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
if ($this->hasValue('cache')) {
|
|
|
|
return $this->getValue('cache');
|
2018-06-06 23:20:29 +02:00
|
|
|
}
|
|
|
|
|
2018-06-06 23:37:26 +02:00
|
|
|
return false;
|
2018-06-06 23:20:29 +02:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getCacheKey()
|
|
|
|
{
|
2018-06-06 23:20:29 +02:00
|
|
|
$cloned = [];
|
|
|
|
foreach ($this as $key => $value) {
|
|
|
|
$cloned[$key] = ($value instanceof Entry) ? $value->dump() : $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sha1(json_encode($cloned));
|
|
|
|
}
|
2019-12-05 21:25:58 +01:00
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function hasTranslationKey($language, $key): bool
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return array_key_exists($language, $this['strings']) && array_key_exists($key, $this['strings'][$language]);
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getTranslationKey($language, $key)
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this['strings'][$language][$key];
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function hasImage(): bool
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->hasValue('image');
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getImage()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('image');
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function setImage($value)
|
|
|
|
{
|
2019-12-07 11:22:40 +01:00
|
|
|
$this->setValue('image', $value);
|
2019-12-05 21:25:58 +01:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getLocalBase()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('local_base');
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getTemplates()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('templates');
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getBaseUrl()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('base_url');
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getBasePage()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
if ($this->isLive()) {
|
|
|
|
$value = '//' . $this->getBaseUrl();
|
|
|
|
if (!$this['live']['clean_urls']) {
|
|
|
|
$value .= 'index.php/';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $value;
|
|
|
|
}
|
2020-04-22 22:24:52 +02:00
|
|
|
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getBaseUrl();
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function hasEntryPage(): bool
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->hasValue('entry_page') && !empty($this->getValue('entry_page'));
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getEntryPage()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('entry_page');
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function setEntryPage($value)
|
|
|
|
{
|
2019-12-07 11:22:40 +01:00
|
|
|
$this->setValue('entry_page', $value);
|
2019-12-05 21:25:58 +01:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function hasRequest(): bool
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->hasValue('request') && !empty($this->getValue('request'));
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getRequest()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('request');
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function setRequest($value)
|
|
|
|
{
|
2019-12-07 11:22:40 +01:00
|
|
|
$this->setValue('request', $value);
|
2019-12-05 21:25:58 +01:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getIndex()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('index');
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function setIndex($value)
|
|
|
|
{
|
2019-12-07 11:22:40 +01:00
|
|
|
$this->setValue('index', $value);
|
2019-12-05 21:25:58 +01:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function hasProcessorInstance()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->hasValue('processor_instance');
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getProcessorInstance()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('processor_instance');
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function setProcessorInstance($value)
|
|
|
|
{
|
2019-12-07 11:22:40 +01:00
|
|
|
$this->setValue('processor_instance', $value);
|
2019-12-05 21:25:58 +01:00
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getIgnore()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('ignore');
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function hasHost()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->hasValue('host');
|
|
|
|
}
|
|
|
|
|
2020-04-22 21:55:53 +02:00
|
|
|
public function getHost()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
return $this->getValue('host');
|
|
|
|
}
|
2015-06-29 16:11:01 +02:00
|
|
|
}
|