-
Notifications
You must be signed in to change notification settings - Fork 2
/
helloworld.php
37 lines (33 loc) · 1.64 KB
/
helloworld.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
// Helloworld extension, https://github.com/schulle4u/yellow-helloworld
class YellowHelloworld {
const VERSION = "0.9.1";
public $yellow; // access to API
// Handle initialisation
public function onLoad($yellow) {
$this->yellow = $yellow;
$this->yellow->system->setDefault("helloworldMessage", "Hello World");
$this->yellow->system->setDefault("helloworldSpeed", "100");
}
// Handle page content element
public function onParseContentElement($page, $name, $text, $attributes, $type) {
$output = null;
if ($name=="helloworld" && ($type=="block" || $type=="inline")) {
$message = $this->yellow->system->get("helloworldMessage");
$speed = $this->yellow->system->get("helloworldSpeed");
if (substru($text, 0, 2)=="- ") $message = trim(substru($text, 2));
$output = "<div class=\"helloworld\" aria-label=\"".htmlspecialchars($message)."\" data-message=\"".htmlspecialchars($message)."\" data-speed=\"".htmlspecialchars($speed)."\"> </div>";
}
return $output;
}
// Handle page extra data
public function onParsePageExtra($page, $name) {
$output = null;
if ($name=="header") {
$assetLocation = $this->yellow->system->get("coreServerBase").$this->yellow->system->get("coreAssetLocation");
$output = "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"{$assetLocation}helloworld.css\" />\n";
$output .= "<script type=\"text/javascript\" defer=\"defer\" src=\"{$assetLocation}helloworld.js\"></script>\n";
}
return $output;
}
}