diff options
Diffstat (limited to 'ratatoeskr')
-rw-r--r-- | ratatoeskr/libs/INFO | 24 | ||||
-rw-r--r-- | ratatoeskr/main.php | 1 | ||||
-rw-r--r-- | ratatoeskr/setup/setup.php | 1 | ||||
-rw-r--r-- | ratatoeskr/sys/GlobalSte.php | 135 | ||||
-rw-r--r-- | ratatoeskr/sys/init_ste.php | 45 |
5 files changed, 153 insertions, 53 deletions
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(); |