aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaria Carolin Chabowski <laria@laria.me>2020-09-22 21:30:49 +0200
committerLaria Carolin Chabowski <laria@laria.me>2020-09-22 21:41:13 +0200
commita0f6f2e849d0884259693e7c1df1bc9de6585eb2 (patch)
tree99a8fad184309f39494de8c97eb2a3a7465f72de
parent7f3cb06630bcb1c81c68e0153d923584f233e38d (diff)
downloadratatoeskr-cms-a0f6f2e849d0884259693e7c1df1bc9de6585eb2.tar.gz
ratatoeskr-cms-a0f6f2e849d0884259693e7c1df1bc9de6585eb2.tar.bz2
ratatoeskr-cms-a0f6f2e849d0884259693e7c1df1bc9de6585eb2.zip
Require STE using composer and add autoloading
-rw-r--r--.gitignore1
-rw-r--r--README.md2
-rwxr-xr-xbuild.sh13
-rw-r--r--composer.json24
-rw-r--r--composer.lock67
-rw-r--r--css.php1
-rw-r--r--ratatoeskr/libs/INFO24
-rw-r--r--ratatoeskr/main.php1
-rw-r--r--ratatoeskr/setup/setup.php1
-rw-r--r--ratatoeskr/sys/GlobalSte.php135
-rw-r--r--ratatoeskr/sys/init_ste.php45
-rw-r--r--setup.php2
12 files changed, 252 insertions, 64 deletions
diff --git a/.gitignore b/.gitignore
index 855df26..383163b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@ ratatoeskr/libs/kses.php
ratatoeskr/libs/jquery.min.js
ratatoeskr/config.php
.php_cs.cache
+ratatoeskr/vendor/
diff --git a/README.md b/README.md
index 1e0821a..120bedf 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
Ratatöskr
=========
-Ratatöskr is a flexible Content Management System / Blogging Software for PHP 5.3.
+Ratatöskr is a flexible Content Management System / Blogging Software for PHP >= 7.3.
Why you should use Ratatöskr
----------------------------
diff --git a/build.sh b/build.sh
index a30f095..8a6bbcd 100755
--- a/build.sh
+++ b/build.sh
@@ -11,19 +11,12 @@ setup_directories() {
mkdir_if_missing ratatoeskr/plugin_extradata/public
mkdir_if_missing ratatoeskr/templates/src/plugintemplates
mkdir_if_missing ratatoeskr/templates/transc
- mkdir_if_missing ratatoeskr/libs/ste
}
install_dependencies() {
- cd ratatoeskr/libs
+ composer install
- cd ste
- wget https://github.com/silvasur/ste/archive/master.zip
- unzip master.zip
- cp ste-master/ste.php .
- cp -r ste-master/src .
- rm -rf ste-master master.zip
- cd ..
+ cd ratatoeskr/libs
wget http://michelf.com/docs/projets/php-markdown-1.0.1o.zip
unzip php-markdown-*.zip
@@ -38,6 +31,8 @@ install_dependencies() {
rm kses.zip
wget http://code.jquery.com/jquery.min.js
+
+ cd ../..
}
setup_dev_environment() {
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..03bdcb1
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,24 @@
+{
+ "name": "r7r/ratatoeskr-cms",
+ "description": "Ratatöskr is a flexible Content Management System / Blogging Software for PHP",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Laria Carolin Chabowski",
+ "email": "laria@laria.me"
+ }
+ ],
+ "autoload": {
+ "psr-4": {
+ "r7r\\cms\\": "ratatoeskr/"
+ }
+ },
+ "type": "project",
+ "require": {
+ "php": ">=7.3",
+ "r7r/ste": "~2.0"
+ },
+ "config": {
+ "vendor-dir": "ratatoeskr/vendor"
+ }
+} \ No newline at end of file
diff --git a/composer.lock b/composer.lock
new file mode 100644
index 0000000..f266f55
--- /dev/null
+++ b/composer.lock
@@ -0,0 +1,67 @@
+{
+ "_readme": [
+ "This file locks the dependencies of your project to a known state",
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
+ "This file is @generated automatically"
+ ],
+ "content-hash": "8bcbdb4bc21d0897a78eb6567bffea81",
+ "packages": [
+ {
+ "name": "r7r/ste",
+ "version": "2.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/silvasur/ste.git",
+ "reference": "ceb262e08027531717f1a16faafc343e8d9656e3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/silvasur/ste/zipball/ceb262e08027531717f1a16faafc343e8d9656e3",
+ "reference": "ceb262e08027531717f1a16faafc343e8d9656e3",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.3.0"
+ },
+ "require-dev": {
+ "phpdocumentor/phpdocumentor": "^2.9",
+ "phpunit/phpunit": "^9"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "r7r\\ste\\": "src/ste"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Laria Carolin Chabowski",
+ "email": "laria@laria.me",
+ "homepage": "http://hi-im.laria.me",
+ "role": "Developer"
+ }
+ ],
+ "description": "A compiling template engine with an XML-ish syntax",
+ "homepage": "http://github.com/silvasur/ste",
+ "keywords": [
+ "templating"
+ ],
+ "time": "2020-09-21T18:46:15+00:00"
+ }
+ ],
+ "packages-dev": [],
+ "aliases": [],
+ "minimum-stability": "stable",
+ "stability-flags": [],
+ "prefer-stable": false,
+ "prefer-lowest": false,
+ "platform": {
+ "php": ">=7.3"
+ },
+ "platform-dev": [],
+ "plugin-api-version": "1.1.0"
+}
diff --git a/css.php b/css.php
index a1ae6bc..28fad06 100644
--- a/css.php
+++ b/css.php
@@ -9,6 +9,7 @@
* See "ratatoeskr/licenses/ratatoeskr" for more information.
*/
+require_once(dirname(__FILE__) . "/ratatoeskr/vendor/autoload.php");
require_once(dirname(__FILE__) . "/ratatoeskr/sys/models.php");
if (!isset($_GET["name"])) {
diff --git a/ratatoeskr/libs/INFO b/ratatoeskr/libs/INFO
index 1ce4244..80a47e3 100644
--- a/ratatoeskr/libs/INFO
+++ b/ratatoeskr/libs/INFO
@@ -1,25 +1,19 @@
This directory will hold some libraries Ratatöskr needs.
-1. STE Template Engine (STE)
-
- Place the STE files into the subdirectory "ste" (create it, if it doesn't exist). At least "ste.php" and the "src" directory of STE are needed!
-
- STE can be found here: <https://github.com/silvasur/ste>
-
-2. PHP Markdown
-
+1. PHP Markdown
+
Place "markdown.php" from the archive directly into this directory.
-
+
PHP Markdown can be found here: <http://michelf.com/projects/php-markdown/>
-3. kses
-
+2. kses
+
Place "kses.php" from the archive directly into this directory.
-
+
kses can be found at <http://sourceforge.net/projects/kses/>
-4. jQuery
-
+3. jQuery
+
Place jquery.min.js into this folder.
-
+
jQuery can be found at <http://jquery.com> \ No newline at end of file
diff --git a/ratatoeskr/main.php b/ratatoeskr/main.php
index 9bbe504..6353050 100644
--- a/ratatoeskr/main.php
+++ b/ratatoeskr/main.php
@@ -16,6 +16,7 @@ if (!defined("CONFIG_FILLED_OUT") || !CONFIG_FILLED_OUT) {
die("Config file not filled out!");
}
+require_once(dirname(__FILE__) . "/vendor/autoload.php");
require_once(dirname(__FILE__) . "/sys/db.php");
require_once(dirname(__FILE__) . "/sys/models.php");
require_once(dirname(__FILE__) . "/sys/init_ste.php");
diff --git a/ratatoeskr/setup/setup.php b/ratatoeskr/setup/setup.php
index 749315a..f1c6dee 100644
--- a/ratatoeskr/setup/setup.php
+++ b/ratatoeskr/setup/setup.php
@@ -2,6 +2,7 @@
define("SETUP", true);
+require_once(dirname(__FILE__) . "/../vendor/autoload.php");
require_once(dirname(__FILE__) . "/../sys/init_ste.php");
require_once(dirname(__FILE__) . "/../sys/translation.php");
require_once(dirname(__FILE__) . "/../sys/db.php");
diff --git a/ratatoeskr/sys/GlobalSte.php b/ratatoeskr/sys/GlobalSte.php
new file mode 100644
index 0000000..3a5c8e6
--- /dev/null
+++ b/ratatoeskr/sys/GlobalSte.php
@@ -0,0 +1,135 @@
+<?php
+
+namespace r7r\cms\sys;
+
+use r7r\ste\STECore;
+use r7r\ste\FilesystemStorageAccess;
+
+/**
+ * Manages the global STE instance
+ */
+class GlobalSte
+{
+ /** @var STECore */
+ private $ste;
+
+ /** @var self|null */
+ private static $instance = null;
+
+ private function __construct()
+ {
+ $tpl_basedir = dirname(__FILE__) . "/../templates";
+
+ $this->ste = new STECore(new FilesystemStorageAccess("$tpl_basedir/src", "$tpl_basedir/transc"));
+ if (defined("__DEBUG__") && __DEBUG__) {
+ $this->ste->mute_runtime_errors = false;
+ }
+
+ $this->ste->register_tag("l10n_replace", [self::class, "tag_l10n_replace"]);
+ $this->ste->register_tag("capitalize", [self::class, "tag_capitalize"]);
+ $this->ste->register_tag("loremipsum", [self::class, "tag_loremipsum"]);
+ }
+
+ public static function tag_l10n_replace($ste, $params, $sub)
+ {
+ $content = $sub($ste);
+ foreach ($params as $name => $replace) {
+ $content = str_replace("[[$name]]", $replace, $content);
+ }
+ return $content;
+ }
+
+ public static function tag_capitalize($ste, $params, $sub)
+ {
+ return ucwords($sub($ste));
+ }
+
+ public static function tag_loremipsum($ste, $params, $sub)
+ {
+ $repeats = empty($params["repeat"]) ? 1 : $params["repeat"] + 0;
+ return implode(
+ "\n\n",
+ array_repeat(
+ "<p>Lorem ipsum dolor sit amet, consectetur adipisici elit, "
+ . "sed eiusmod tempor incidunt ut labore et dolore magna "
+ . "aliqua. Ut enim ad minim veniam, quis nostrud exercitation "
+ . "ullamco laboris nisi ut aliquid ex ea commodi consequat. "
+ . "Quis aute iure reprehenderit in voluptate velit esse cillum "
+ . "dolore eu fugiat nulla pariatur. Excepteur sint obcaecat "
+ . "cupiditat non proident, sunt in culpa qui officia deserunt "
+ . "mollit anim id est laborum.</p>\n\n<p>Duis autem vel eum "
+ . "iriure dolor in hendrerit in vulputate velit esse molestie "
+ . "consequat, vel illum dolore eu feugiat nulla facilisis at "
+ . "vero eros et accumsan et iusto odio dignissim qui blandit "
+ . "praesent luptatum zzril delenit augue duis dolore te "
+ . "feugait nulla facilisi. Lorem ipsum dolor sit amet, "
+ . "consectetuer adipiscing elit, sed diam nonummy nibh euismod "
+ . "tincidunt ut laoreet dolore magna aliquam erat volutpat."
+ . "</p>\n\n<p>Ut wisi enim ad minim veniam, quis nostrud "
+ . "exerci tation ullamcorper suscipit lobortis nisl ut aliquip "
+ . "ex ea commodo consequat. Duis autem vel eum iriure dolor in "
+ . "hendrerit in vulputate velit esse molestie consequat, vel "
+ . "illum dolore eu feugiat nulla facilisis at vero eros et "
+ . "accumsan et iusto odio dignissim qui blandit praesent "
+ . "luptatum zzril delenit augue duis dolore te feugait nulla "
+ . "facilisi.</p>\n\n<p>Nam liber tempor cum soluta nobis "
+ . "eleifend option congue nihil imperdiet doming id quod mazim "
+ . "placerat facer possim assum. Lorem ipsum dolor sit amet, "
+ . "consectetuer adipiscing elit, sed diam nonummy nibh euismod "
+ . "tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut "
+ . "wisi enim ad minim veniam, quis nostrud exerci tation "
+ . "ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo "
+ . "consequat.</p>\n\n<p>Duis autem vel eum iriure dolor in "
+ . "hendrerit in vulputate velit esse molestie consequat, vel "
+ . "illum dolore eu feugiat nulla facilisis.</p>\n\n<p>At vero "
+ . "eos et accusam et justo duo dolores et ea rebum. Stet clita "
+ . "kasd gubergren, no sea takimata sanctus est Lorem ipsum "
+ . "dolor sit amet. Lorem ipsum dolor sit amet, consetetur "
+ . "sadipscing elitr, sed diam nonumy eirmod tempor invidunt "
+ . "ut labore et dolore magna aliquyam erat, sed diam voluptua. "
+ . "At vero eos et accusam et justo duo dolores et ea rebum. "
+ . "Stet clita kasd gubergren, no sea takimata sanctus est "
+ . "Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, "
+ . "consetetur sadipscing elitr, At accusam aliquyam diam diam "
+ . "dolore dolores duo eirmod eos erat, et nonumy sed tempor et "
+ . "et invidunt justo labore Stet clita ea et gubergren, kasd "
+ . "magna no rebum. sanctus sea sed takimata ut vero voluptua. "
+ . "est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, "
+ . "consetetur sadipscing elitr, sed diam nonumy eirmod tempor "
+ . "invidunt ut labore et dolore magna aliquyam erat.</p>\n\n"
+ . "<p>Consetetur sadipscing elitr, sed diam nonumy eirmod "
+ . "tempor invidunt ut labore et dolore magna aliquyam erat, "
+ . "sed diam voluptua. At vero eos et accusam et justo duo "
+ . "dolores et ea rebum. Stet clita kasd gubergren, no sea "
+ . "takimata sanctus est Lorem ipsum dolor sit amet. Lorem "
+ . "ipsum dolor sit amet, consetetur sadipscing elitr, sed "
+ . "diam nonumy eirmod tempor invidunt ut labore et dolore "
+ . "magna aliquyam erat, sed diam voluptua. At vero eos et "
+ . "accusam et justo duo dolores et ea rebum. Stet clita kasd "
+ . "gubergren, no sea takimata sanctus est Lorem ipsum dolor "
+ . "sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing "
+ . "elitr, sed diam nonumy eirmod tempor invidunt ut labore et "
+ . "dolore magna aliquyam erat, sed diam voluptua. At vero eos "
+ . "et accusam et justo duo dolores et ea rebum. Stet clita "
+ . "kasd gubergren, no sea takimata sanctus est Lorem ipsum "
+ . "dolor sit amet.</p>",
+ $repeats
+ )
+ );
+ }
+
+ private static function getInstance(): self
+ {
+ self::$instance = self::$instance ?? new self();
+ return self::$instance;
+ }
+
+ /**
+ * Get (and initialize, if necessary) the global STE instance.
+ * @return STECore
+ */
+ public static function getGlobalSte(): STECore
+ {
+ return self::getInstance()->ste;
+ }
+}
diff --git a/ratatoeskr/sys/init_ste.php b/ratatoeskr/sys/init_ste.php
index b422046..07e8976 100644
--- a/ratatoeskr/sys/init_ste.php
+++ b/ratatoeskr/sys/init_ste.php
@@ -11,42 +11,11 @@
* See "ratatoeskr/licenses/ratatoeskr" for more information.
*/
-require_once(dirname(__FILE__) . "/../libs/ste/ste.php");
+use r7r\cms\sys\GlobalSte;
+use r7r\ste\STECore;
-$tpl_basedir = dirname(__FILE__) . "/../templates";
-
-if (!isset($ste)) {
- /*
- * Variable: $ste
- *
- * The global STECore instance.
- */
- $ste = new \ste\STECore(new \ste\FilesystemStorageAccess("$tpl_basedir/src", "$tpl_basedir/transc"));
- if (defined("__DEBUG__") && __DEBUG__) {
- $ste->mute_runtime_errors = false;
- }
-}
-
-$ste->register_tag(
- "l10n_replace",
- function ($ste, $params, $sub) {
- $content = $sub($ste);
- foreach ($params as $name => $replace) {
- $content = str_replace("[[$name]]", $replace, $content);
- }
- return $content;
- }
-);
-$ste->register_tag(
- "capitalize",
- function ($ste, $params, $sub) {
- return ucwords($sub($ste));
- }
-);
-$ste->register_tag(
- "loremipsum",
- function ($ste, $params, $sub) {
- $repeats = empty($params["repeat"]) ? 1 : $params["repeat"] + 0;
- return implode("\n\n", array_repeat("<p>Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>\n\n<p>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>\n\n<p>Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>\n\n<p>Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>\n\n<p>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis.</p>\n\n<p>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.</p>\n\n<p>Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>", $repeats));
- }
-);
+/**
+ * @var STECore The global STECore instance.
+ * @deprecated Use {@see GlobalSte} directly now.
+ */
+$ste = GlobalSte::getGlobalSte();
diff --git a/setup.php b/setup.php
index 4d99233..cbb58f4 100644
--- a/setup.php
+++ b/setup.php
@@ -60,8 +60,8 @@ $files = [
"/ratatoeskr/translations/en.php",
"/ratatoeskr/backend.php",
"/ratatoeskr/libs/markdown.php",
- "/ratatoeskr/libs/ste/ste.php",
"/ratatoeskr/libs/kses.php",
+ "/ratatoeskr/vendor/autoload.php",
"/ratatoeskr/.htaccess",
"/ratatoeskr/setup/create_tables.php",
"/ratatoeskr/setup/setup.php",