-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautomore.php
More file actions
29 lines (24 loc) · 957 Bytes
/
Copy pathautomore.php
File metadata and controls
29 lines (24 loc) · 957 Bytes
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
<?php
// Automore extension, https://github.com/pftnhr/yellow-automore
class YellowAutomore {
const VERSION = "0.9.1";
public $yellow; //access to API
// Handle initialisation
public function onLoad($yellow) {
$this->yellow = $yellow;
$this->yellow->system->setDefault("automoreLength", "250");
}
// Handle page content in HTML format
public function onParseContentHtml($page, $text) {
$output = null;
if ($this->yellow->page->get("layout") === "blog-start") {
$length = $this->yellow->system->get("automoreLength");
if (strlenu($text) >= $length) {
$text = substru(strip_tags($text), 0, $length) . "...\n";
$text .= "<p><small><a href=\"".$page->getLocation(true)."\">".$this->yellow->language->getTextHtml("blogMore")."</small></a></p>";
}
$output = $text;
}
return $output;
}
}