commit bb6ce84f4de88ff9188052a885d8a2c5bb3e8c9f
parent c43493b72c4ee8c83f68cc522001420885902e14
Author: markseu <mark2011@mayberg.se>
Date: Thu, 25 Jun 2020 17:18:22 +0200
Updated API, changed command interface
Diffstat:
4 files changed, 24 insertions(+), 28 deletions(-)
diff --git a/system/extensions/bundle.php b/system/extensions/bundle.php
@@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowBundle {
- const VERSION = "0.8.11";
+ const VERSION = "0.8.12";
const TYPE = "feature";
public $yellow; //access to API
@@ -23,21 +23,19 @@ class YellowBundle {
}
// Handle command
- public function onCommand($args) {
- list($command) = $args;
+ public function onCommand($command, $text) {
switch ($command) {
- case "clean": $statusCode = $this->processCommandClean($args); break;
+ case "clean": $statusCode = $this->processCommandClean($command, $text); break;
default: $statusCode = 0;
}
return $statusCode;
}
// Process command to clean bundles
- public function processCommandClean($args) {
+ public function processCommandClean($command, $text) {
$statusCode = 0;
- list($command, $path) = $args;
- if ($path=="all") {
- $path = $this->yellow->system->get("coreResourceDir");
+ if ($command=="clean" && $text=="all") {
+ $path = $this->yellow->system->get("coreResourceDirectory");
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/bundle-.*/", false, false) as $entry) {
if (!$this->yellow->toolbox->deleteFile($entry)) $statusCode = 500;
}
@@ -100,7 +98,7 @@ class YellowBundle {
if (!empty($fileNames)) {
$autoVersioning = intval($modified/(60*60*24));
$id = substru(md5($autoVersioning.$base.implode($fileNames)), 0, 10);
- $fileNameBundle = $this->yellow->system->get("coreResourceDir")."bundle-$id.min.$type";
+ $fileNameBundle = $this->yellow->system->get("coreResourceDirectory")."bundle-$id.min.$type";
$locationBundle = $base.$this->yellow->system->get("coreResourceLocation")."bundle-$id.min.$type";
$rawDataAttribute = $attribute=="defer" ? "defer=\"defer\" " : "";
if ($type=="css") {
@@ -133,8 +131,8 @@ class YellowBundle {
// Process bundle, convert URLs
public function processBundleConvert($scheme, $address, $base, $fileData, $fileName, $type) {
if ($type=="css") {
- $extensionDirLength = strlenu($this->yellow->system->get("coreExtensionDir"));
- if (substru($fileName, 0, $extensionDirLength) == $this->yellow->system->get("coreExtensionDir")) {
+ $extensionDirectoryLength = strlenu($this->yellow->system->get("coreExtensionDirectory"));
+ if (substru($fileName, 0, $extensionDirectoryLength) == $this->yellow->system->get("coreExtensionDirectory")) {
$base .= $this->yellow->system->get("coreExtensionLocation");
} else {
$base .= $this->yellow->system->get("coreResourceLocation");
diff --git a/system/extensions/image.php b/system/extensions/image.php
@@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowImage {
- const VERSION = "0.8.7";
+ const VERSION = "0.8.8";
const TYPE = "feature";
public $yellow; //access to API
@@ -16,7 +16,7 @@ class YellowImage {
$this->yellow->system->setDefault("imageUploadHeightMax", "1280");
$this->yellow->system->setDefault("imageUploadJpgQuality", "80");
$this->yellow->system->setDefault("imageThumbnailLocation", "/media/thumbnails/");
- $this->yellow->system->setDefault("imageThumbnailDir", "media/thumbnails/");
+ $this->yellow->system->setDefault("imageThumbnailDirectory", "media/thumbnails/");
$this->yellow->system->setDefault("imageThumbnailJpgQuality", "80");
}
@@ -24,12 +24,12 @@ class YellowImage {
public function onParseContentShortcut($page, $name, $text, $type) {
$output = null;
if ($name=="image" && $type=="inline") {
- list($name, $alt, $style, $width, $height) = $this->yellow->toolbox->getTextArgs($text);
+ list($name, $alt, $style, $width, $height) = $this->yellow->toolbox->getTextArguments($text);
if (!preg_match("/^\w+:/", $name)) {
if (empty($alt)) $alt = $this->yellow->system->get("imageAlt");
if (empty($width)) $width = "100%";
if (empty($height)) $height = $width;
- list($src, $width, $height) = $this->getImageInformation($this->yellow->system->get("coreImageDir").$name, $width, $height);
+ list($src, $width, $height) = $this->getImageInformation($this->yellow->system->get("coreImageDirectory").$name, $width, $height);
} else {
if (empty($alt)) $alt = $this->yellow->system->get("imageAlt");
$src = $this->yellow->lookup->normaliseUrl("", "", "", $name);
@@ -64,21 +64,19 @@ class YellowImage {
}
// Handle command
- public function onCommand($args) {
- list($command) = $args;
+ public function onCommand($command, $text) {
switch ($command) {
- case "clean": $statusCode = $this->processCommandClean($args); break;
+ case "clean": $statusCode = $this->processCommandClean($command, $text); break;
default: $statusCode = 0;
}
return $statusCode;
}
// Process command to clean thumbnails
- public function processCommandClean($args) {
+ public function processCommandClean($command, $text) {
$statusCode = 0;
- list($command, $path) = $args;
- if ($path=="all") {
- $path = $this->yellow->system->get("imageThumbnailDir");
+ if ($command=="clean" && $text=="all") {
+ $path = $this->yellow->system->get("imageThumbnailDirectory");
foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/.*/", false, false) as $entry) {
if (!$this->yellow->toolbox->deleteFile($entry)) $statusCode = 500;
}
@@ -89,7 +87,7 @@ class YellowImage {
// Return image info, create thumbnail on demand
public function getImageInformation($fileName, $widthOutput, $heightOutput) {
- $fileNameShort = substru($fileName, strlenu($this->yellow->system->get("coreImageDir")));
+ $fileNameShort = substru($fileName, strlenu($this->yellow->system->get("coreImageDirectory")));
list($widthInput, $heightInput, $type) = $this->yellow->toolbox->detectImageInformation($fileName);
$widthOutput = $this->convertValueAndUnit($widthOutput, $widthInput);
$heightOutput = $this->convertValueAndUnit($heightOutput, $heightInput);
@@ -101,7 +99,7 @@ class YellowImage {
$fileNameThumb = ltrim(str_replace(array("/", "\\", "."), "-", dirname($fileNameShort)."/".pathinfo($fileName, PATHINFO_FILENAME)), "-");
$fileNameThumb .= "-".$widthOutput."x".$heightOutput;
$fileNameThumb .= ".".pathinfo($fileName, PATHINFO_EXTENSION);
- $fileNameOutput = $this->yellow->system->get("imageThumbnailDir").$fileNameThumb;
+ $fileNameOutput = $this->yellow->system->get("imageThumbnailDirectory").$fileNameThumb;
if ($this->isFileNotUpdated($fileName, $fileNameOutput)) {
$image = $this->loadImage($fileName, $type);
$image = $this->resizeImage($image, $widthInput, $heightInput, $widthOutput, $heightOutput);
diff --git a/system/extensions/meta.php b/system/extensions/meta.php
@@ -4,7 +4,7 @@
// This file may be used and distributed under the terms of the public license.
class YellowMeta {
- const VERSION = "0.8.11";
+ const VERSION = "0.8.12";
const TYPE = "feature";
public $yellow; //access to API
@@ -20,7 +20,7 @@ class YellowMeta {
if ($name=="header" && !$page->isError()) {
list($imageUrl, $imageAlt) = $this->getImageInformation($page);
$locale = $this->yellow->text->getText("languageLocale", $page->get("language"));
- $output .= "<meta property=\"og:url\" content=\"".htmlspecialchars($page->getUrl().$this->yellow->toolbox->getLocationArgs())."\" />\n";
+ $output .= "<meta property=\"og:url\" content=\"".htmlspecialchars($page->getUrl().$this->yellow->toolbox->getLocationArguments())."\" />\n";
$output .= "<meta property=\"og:locale\" content=\"".htmlspecialchars($locale)."\" />\n";
$output .= "<meta property=\"og:type\" content=\"website\" />\n";
$output .= "<meta property=\"og:title\" content=\"".$page->getHtml("title")."\" />\n";
@@ -47,7 +47,7 @@ class YellowMeta {
$name = $page->get("image");
$alt = $page->isExisting("imageAlt") ? $page->get("imageAlt") : $page->get("title");
} elseif (preg_match("/\[image(\s.*?)\]/", $page->getContent(true), $matches)) {
- list($name, $alt) = $this->yellow->toolbox->getTextArgs(trim($matches[1]));
+ list($name, $alt) = $this->yellow->toolbox->getTextArguments(trim($matches[1]));
if (empty($alt)) $alt = $page->get("title");
} else {
$name = $this->yellow->system->get("metaDefaultImage");
diff --git a/system/settings/system.ini b/system/settings/system.ini
@@ -68,6 +68,6 @@ ImageUploadWidthMax: 1280
ImageUploadHeightMax: 1280
ImageUploadJpgQuality: 80
ImageThumbnailLocation: /media/thumbnails/
-ImageThumbnailDir: media/thumbnails/
+ImageThumbnailDirectory: media/thumbnails/
ImageThumbnailJpgQuality: 80
MetaDefaultImage: icon