Refactored code
This commit is contained in:
parent
aef76ab614
commit
44024d27aa
|
@ -2,7 +2,7 @@
|
||||||
// Core extension, https://github.com/annaesvensson/yellow-core
|
// Core extension, https://github.com/annaesvensson/yellow-core
|
||||||
|
|
||||||
class YellowCore {
|
class YellowCore {
|
||||||
const VERSION = "0.8.126";
|
const VERSION = "0.8.127";
|
||||||
const RELEASE = "0.8.23";
|
const RELEASE = "0.8.23";
|
||||||
public $content; // content files
|
public $content; // content files
|
||||||
public $media; // media files
|
public $media; // media files
|
||||||
|
@ -371,19 +371,17 @@ class YellowContent {
|
||||||
if ($absoluteLocation) $location = substru($location, strlenu($this->yellow->page->base));
|
if ($absoluteLocation) $location = substru($location, strlenu($this->yellow->page->base));
|
||||||
foreach ($this->scanLocation($this->getParentLocation($location)) as $page) {
|
foreach ($this->scanLocation($this->getParentLocation($location)) as $page) {
|
||||||
if ($page->location==$location) {
|
if ($page->location==$location) {
|
||||||
if (!$this->yellow->lookup->isRootLocation($page->location)) {
|
$found = true;
|
||||||
$found = true;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $found ? $page : null;
|
return $found ? $page : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return page collection with all pages
|
// Return page collection with all pages
|
||||||
public function index($showInvisible = false, $multiLanguage = false, $levelMax = 0) {
|
public function index($showInvisible = false, $multiLanguage = false) {
|
||||||
$rootLocation = $multiLanguage ? "" : $this->getRootLocation($this->yellow->page->location);
|
$rootLocation = $multiLanguage ? "" : $this->getRootLocation($this->yellow->page->location);
|
||||||
return $this->getChildrenRecursive($rootLocation, $showInvisible, $levelMax);
|
return $this->getChildrenRecursive($rootLocation, $showInvisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return page collection with top-level navigation
|
// Return page collection with top-level navigation
|
||||||
|
@ -431,7 +429,7 @@ class YellowContent {
|
||||||
foreach ($this->scanLocation("") as $page) {
|
foreach ($this->scanLocation("") as $page) {
|
||||||
if ($content = $this->find(substru($page->location, 4).$locationEnd)) {
|
if ($content = $this->find(substru($page->location, 4).$locationEnd)) {
|
||||||
if ($content->isAvailable() && ($content->isVisible() || $showInvisible)) {
|
if ($content->isAvailable() && ($content->isVisible() || $showInvisible)) {
|
||||||
if (!$this->yellow->lookup->isRootLocation($content->location)) $pages->append($content);
|
$pages->append($content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -448,7 +446,9 @@ class YellowContent {
|
||||||
$languages = array();
|
$languages = array();
|
||||||
if ($this->yellow->system->get("coreMultiLanguageMode")) {
|
if ($this->yellow->system->get("coreMultiLanguageMode")) {
|
||||||
foreach ($this->scanLocation("") as $page) {
|
foreach ($this->scanLocation("") as $page) {
|
||||||
if ($page->isAvailable() && ($page->isVisible() || $showInvisible)) array_push($languages, $page->get("language"));
|
if ($page->isAvailable() && ($page->isVisible() || $showInvisible)) {
|
||||||
|
array_push($languages, $page->get("language"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $languages;
|
return $languages;
|
||||||
|
@ -459,7 +459,7 @@ class YellowContent {
|
||||||
$pages = new YellowPageCollection($this->yellow);
|
$pages = new YellowPageCollection($this->yellow);
|
||||||
foreach ($this->scanLocation($location) as $page) {
|
foreach ($this->scanLocation($location) as $page) {
|
||||||
if ($page->isAvailable() && ($page->isVisible() || $showInvisible)) {
|
if ($page->isAvailable() && ($page->isVisible() || $showInvisible)) {
|
||||||
if (!$this->yellow->lookup->isRootLocation($page->location) && is_readable($page->fileName)) $pages->append($page);
|
$pages->append($page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $pages;
|
return $pages;
|
||||||
|
@ -471,7 +471,7 @@ class YellowContent {
|
||||||
$pages = new YellowPageCollection($this->yellow);
|
$pages = new YellowPageCollection($this->yellow);
|
||||||
foreach ($this->scanLocation($location) as $page) {
|
foreach ($this->scanLocation($location) as $page) {
|
||||||
if ($page->isAvailable() && ($page->isVisible() || $showInvisible)) {
|
if ($page->isAvailable() && ($page->isVisible() || $showInvisible)) {
|
||||||
if (!$this->yellow->lookup->isRootLocation($page->location) && is_readable($page->fileName)) $pages->append($page);
|
$pages->append($page);
|
||||||
}
|
}
|
||||||
if (!$this->yellow->lookup->isFileLocation($page->location) && $levelMax!=0) {
|
if (!$this->yellow->lookup->isFileLocation($page->location) && $levelMax!=0) {
|
||||||
$pages->merge($this->getChildrenRecursive($page->location, $showInvisible, $levelMax));
|
$pages->merge($this->getChildrenRecursive($page->location, $showInvisible, $levelMax));
|
||||||
|
@ -567,18 +567,16 @@ class YellowMedia {
|
||||||
if ($absoluteLocation) $location = substru($location, strlenu($this->yellow->system->get("coreServerBase")));
|
if ($absoluteLocation) $location = substru($location, strlenu($this->yellow->system->get("coreServerBase")));
|
||||||
foreach ($this->scanLocation($this->getParentLocation($location)) as $file) {
|
foreach ($this->scanLocation($this->getParentLocation($location)) as $file) {
|
||||||
if ($file->location==$location) {
|
if ($file->location==$location) {
|
||||||
if ($this->yellow->lookup->isFileLocation($file->location)) {
|
$found = true;
|
||||||
$found = true;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $found ? $file : null;
|
return $found ? $file : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return page collection with all media files
|
// Return page collection with all media files
|
||||||
public function index($showInvisible = false, $multiPass = false, $levelMax = 0) {
|
public function index($showInvisible = false, $multiPass = false) {
|
||||||
return $this->getChildrenRecursive("", $showInvisible, $levelMax);
|
return $this->getChildrenRecursive("", $showInvisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return page collection that's empty
|
// Return page collection that's empty
|
||||||
|
@ -591,7 +589,7 @@ class YellowMedia {
|
||||||
$files = new YellowPageCollection($this->yellow);
|
$files = new YellowPageCollection($this->yellow);
|
||||||
foreach ($this->scanLocation($location) as $file) {
|
foreach ($this->scanLocation($location) as $file) {
|
||||||
if ($file->isAvailable() && ($file->isVisible() || $showInvisible)) {
|
if ($file->isAvailable() && ($file->isVisible() || $showInvisible)) {
|
||||||
if ($this->yellow->lookup->isFileLocation($file->location)) $files->append($file);
|
$files->append($file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $files;
|
return $files;
|
||||||
|
@ -603,7 +601,7 @@ class YellowMedia {
|
||||||
$files = new YellowPageCollection($this->yellow);
|
$files = new YellowPageCollection($this->yellow);
|
||||||
foreach ($this->scanLocation($location) as $file) {
|
foreach ($this->scanLocation($location) as $file) {
|
||||||
if ($file->isAvailable() && ($file->isVisible() || $showInvisible)) {
|
if ($file->isAvailable() && ($file->isVisible() || $showInvisible)) {
|
||||||
if ($this->yellow->lookup->isFileLocation($file->location)) $files->append($file);
|
$files->append($file);
|
||||||
}
|
}
|
||||||
if (!$this->yellow->lookup->isFileLocation($file->location) && $levelMax!=0) {
|
if (!$this->yellow->lookup->isFileLocation($file->location) && $levelMax!=0) {
|
||||||
$files->merge($this->getChildrenRecursive($file->location, $showInvisible, $levelMax));
|
$files->merge($this->getChildrenRecursive($file->location, $showInvisible, $levelMax));
|
||||||
|
@ -2989,13 +2987,15 @@ class YellowPage {
|
||||||
if (!$this->isExisting("titleContent")) $this->set("titleContent", $this->get("title"));
|
if (!$this->isExisting("titleContent")) $this->set("titleContent", $this->get("title"));
|
||||||
if (!$this->isExisting("titleNavigation")) $this->set("titleNavigation", $this->get("title"));
|
if (!$this->isExisting("titleNavigation")) $this->set("titleNavigation", $this->get("title"));
|
||||||
if (!$this->isExisting("titleHeader")) $this->set("titleHeader", $titleHeader);
|
if (!$this->isExisting("titleHeader")) $this->set("titleHeader", $titleHeader);
|
||||||
if ($this->get("status")=="unlisted") $this->visible = false;
|
if ($this->yellow->lookup->isRootLocation($this->location) || !is_readable($this->fileName)) $this->available = false;
|
||||||
if ($this->get("status")=="shared") $this->available = false;
|
if ($this->get("status")=="shared") $this->available = false;
|
||||||
|
if ($this->get("status")=="unlisted") $this->visible = false;
|
||||||
} else {
|
} else {
|
||||||
$this->set("size", filesize($this->fileName));
|
$this->set("size", filesize($this->fileName));
|
||||||
$this->set("type", $this->yellow->toolbox->getFileType($this->fileName));
|
$this->set("type", $this->yellow->toolbox->getFileType($this->fileName));
|
||||||
$this->set("group", $this->yellow->toolbox->getFileGroup($this->fileName, $this->yellow->system->get("coreMediaDirectory")));
|
$this->set("group", $this->yellow->toolbox->getFileGroup($this->fileName, $this->yellow->system->get("coreMediaDirectory")));
|
||||||
$this->set("modified", date("Y-m-d H:i:s", $this->yellow->toolbox->getFileModified($this->fileName)));
|
$this->set("modified", date("Y-m-d H:i:s", $this->yellow->toolbox->getFileModified($this->fileName)));
|
||||||
|
if (!$this->yellow->lookup->isFileLocation($this->location)) $this->available = false;
|
||||||
}
|
}
|
||||||
foreach ($this->yellow->extension->data as $key=>$value) {
|
foreach ($this->yellow->extension->data as $key=>$value) {
|
||||||
if (method_exists($value["object"], "onParseMetaData")) $value["object"]->onParseMetaData($this);
|
if (method_exists($value["object"], "onParseMetaData")) $value["object"]->onParseMetaData($this);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Generate extension, https://github.com/annaesvensson/yellow-generate
|
// Generate extension, https://github.com/annaesvensson/yellow-generate
|
||||||
|
|
||||||
class YellowGenerate {
|
class YellowGenerate {
|
||||||
const VERSION = "0.8.53";
|
const VERSION = "0.8.54";
|
||||||
public $yellow; // access to API
|
public $yellow; // access to API
|
||||||
public $files; // number of files
|
public $files; // number of files
|
||||||
public $errors; // number of errors
|
public $errors; // number of errors
|
||||||
|
@ -130,7 +130,7 @@ class YellowGenerate {
|
||||||
|
|
||||||
// Generate static file
|
// Generate static file
|
||||||
public function generateStaticFile($path, $location, $analyse = false, $probe = false, $error = false) {
|
public function generateStaticFile($path, $location, $analyse = false, $probe = false, $error = false) {
|
||||||
$this->yellow->content = new YellowContent($this->yellow);
|
$this->yellow->content->pages = array();
|
||||||
$this->yellow->page = new YellowPage($this->yellow);
|
$this->yellow->page = new YellowPage($this->yellow);
|
||||||
$this->yellow->page->fileName = substru($location, 1);
|
$this->yellow->page->fileName = substru($location, 1);
|
||||||
if (!is_readable($this->yellow->page->fileName)) {
|
if (!is_readable($this->yellow->page->fileName)) {
|
||||||
|
|
|
@ -148,14 +148,14 @@ system/themes/copenhagen.css: copenhagen.css, create, update, careful
|
||||||
system/themes/copenhagen.png: copenhagen.png, create
|
system/themes/copenhagen.png: copenhagen.png, create
|
||||||
|
|
||||||
Extension: Core
|
Extension: Core
|
||||||
Version: 0.8.126
|
Version: 0.8.127
|
||||||
Description: Core functionality of your website.
|
Description: Core functionality of your website.
|
||||||
Developer: Anna Svensson
|
Developer: Anna Svensson
|
||||||
Tag: feature
|
Tag: feature
|
||||||
DownloadUrl: https://github.com/annaesvensson/yellow-core/archive/refs/heads/main.zip
|
DownloadUrl: https://github.com/annaesvensson/yellow-core/archive/refs/heads/main.zip
|
||||||
DocumentationUrl: https://github.com/annaesvensson/yellow-core
|
DocumentationUrl: https://github.com/annaesvensson/yellow-core
|
||||||
DocumentationLanguage: en, de, sv
|
DocumentationLanguage: en, de, sv
|
||||||
Published: 2024-03-15 13:36:26
|
Published: 2024-03-29 20:32:14
|
||||||
Status: available
|
Status: available
|
||||||
system/extensions/core.php: core.php, create, update
|
system/extensions/core.php: core.php, create, update
|
||||||
system/layouts/default.html: default.html, create, update, careful
|
system/layouts/default.html: default.html, create, update, careful
|
||||||
|
@ -304,14 +304,14 @@ system/extensions/gallery-default-skin.svg: gallery-default-skin.svg, create, up
|
||||||
system/extensions/gallery-preloader.gif: gallery-preloader.gif, create, update
|
system/extensions/gallery-preloader.gif: gallery-preloader.gif, create, update
|
||||||
|
|
||||||
Extension: Generate
|
Extension: Generate
|
||||||
Version: 0.8.53
|
Version: 0.8.54
|
||||||
Description: Generate a static website.
|
Description: Generate a static website.
|
||||||
Developer: Anna Svensson
|
Developer: Anna Svensson
|
||||||
Tag: feature
|
Tag: feature
|
||||||
DownloadUrl: https://github.com/annaesvensson/yellow-generate/archive/refs/heads/main.zip
|
DownloadUrl: https://github.com/annaesvensson/yellow-generate/archive/refs/heads/main.zip
|
||||||
DocumentationUrl: https://github.com/annaesvensson/yellow-generate
|
DocumentationUrl: https://github.com/annaesvensson/yellow-generate
|
||||||
DocumentationLanguage: en, de, sv
|
DocumentationLanguage: en, de, sv
|
||||||
Published: 2024-03-23 09:23:38
|
Published: 2024-03-29 20:45:42
|
||||||
Status: available
|
Status: available
|
||||||
system/extensions/generate.php: generate.php, create, update
|
system/extensions/generate.php: generate.php, create, update
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
# Datenstrom Yellow update settings for installed extensions
|
# Datenstrom Yellow update settings for installed extensions
|
||||||
|
|
||||||
Extension: Core
|
Extension: Core
|
||||||
Version: 0.8.126
|
Version: 0.8.127
|
||||||
Description: Core functionality of your website.
|
Description: Core functionality of your website.
|
||||||
Developer: Anna Svensson
|
Developer: Anna Svensson
|
||||||
Tag: feature
|
Tag: feature
|
||||||
DownloadUrl: https://github.com/annaesvensson/yellow-core/archive/refs/heads/main.zip
|
DownloadUrl: https://github.com/annaesvensson/yellow-core/archive/refs/heads/main.zip
|
||||||
DocumentationUrl: https://github.com/annaesvensson/yellow-core
|
DocumentationUrl: https://github.com/annaesvensson/yellow-core
|
||||||
DocumentationLanguage: en, de, sv
|
DocumentationLanguage: en, de, sv
|
||||||
Published: 2024-03-15 13:36:26
|
Published: 2024-03-29 20:32:14
|
||||||
Status: available
|
Status: available
|
||||||
system/extensions/core.php: core.php, create, update
|
system/extensions/core.php: core.php, create, update
|
||||||
system/layouts/default.html: default.html, create, update, careful
|
system/layouts/default.html: default.html, create, update, careful
|
||||||
|
@ -36,14 +36,14 @@ system/extensions/edit.woff: edit.woff, delete
|
||||||
content/shared/page-new-default.md: page-new-default.md, create, optional
|
content/shared/page-new-default.md: page-new-default.md, create, optional
|
||||||
|
|
||||||
Extension: Generate
|
Extension: Generate
|
||||||
Version: 0.8.53
|
Version: 0.8.54
|
||||||
Description: Generate a static website.
|
Description: Generate a static website.
|
||||||
Developer: Anna Svensson
|
Developer: Anna Svensson
|
||||||
Tag: feature
|
Tag: feature
|
||||||
DownloadUrl: https://github.com/annaesvensson/yellow-generate/archive/refs/heads/main.zip
|
DownloadUrl: https://github.com/annaesvensson/yellow-generate/archive/refs/heads/main.zip
|
||||||
DocumentationUrl: https://github.com/annaesvensson/yellow-generate
|
DocumentationUrl: https://github.com/annaesvensson/yellow-generate
|
||||||
DocumentationLanguage: en, de, sv
|
DocumentationLanguage: en, de, sv
|
||||||
Published: 2024-03-23 09:23:38
|
Published: 2024-03-29 20:45:42
|
||||||
Status: available
|
Status: available
|
||||||
system/extensions/generate.php: generate.php, create, update
|
system/extensions/generate.php: generate.php, create, update
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue