-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathextension.php
50 lines (41 loc) · 1.37 KB
/
extension.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
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
class HelloWorldExtension extends Minz_Extension {
public function init() {
Minz_View::appendStyle($this->getFileUrl('style.css', 'css'));
Minz_View::appendScript($this->getFileUrl('script.js', 'js'));
$this->registerTranslates();
$this->registerController('hello');
$this->registerController('index');
$this->registerViews();
// $this->registerHook('entry_before_insert',
// array('HelloWorldExtension', 'setHelloWorldContentHook'));
$this->registerHook('entry_before_display',
array('HelloWorldExtension', 'setHelloWorldTitleHook'));
$this->registerHook('feed_before_insert',
array('HelloWorldExtension', 'noMoreFeedsHook'));
}
public function handleConfigureAction() {
$this->registerTranslates();
}
public static function setHelloWorldContentHook($entry) {
$entry->_content('Hello world!');
return $entry;
}
private static $hello_world_title_odd = false;
public static function setHelloWorldTitleHook($entry) {
if (self::$hello_world_title_odd) {
$entry->_title('Hello world!');
}
self::$hello_world_title_odd = !self::$hello_world_title_odd;
return $entry;
}
public static function noMoreFeedsHook($feed) {
$feedDAO = FreshRSS_Factory::createFeedDao();
$feeds = $feedDAO->listFeeds();
if (count($feeds) >= 10) {
return null;
} else {
return $feed;
}
}
}