-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.php
More file actions
57 lines (51 loc) · 1.27 KB
/
base.php
File metadata and controls
57 lines (51 loc) · 1.27 KB
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
51
52
53
54
55
56
57
<?php
/**
* @package Blocks
* @author Alan Hardman <alan@phpizza.com>
* @version 0.1.1
*/
namespace Plugin\Blocks;
class Base extends \Plugin
{
/**
* Initialize the plugin, adding hooks dynamically
*/
public function _load()
{
$block = new Block();
$blocks = $block->find();
\Base::instance()->set("site.plugins.blocks.blocks", $blocks);
foreach ($blocks as $block) {
$this->_hook($block->hook, function ($data) use ($block) {
echo $block->content;
return $data;
});
}
}
/**
* Handle admin page for plugin
*/
public function _admin()
{
echo \Helper\View::instance()->render("blocks/blocks-plugin-admin.html");
}
/**
* Install plugin (add database table)
*/
public function _install()
{
$db = \Base::instance()->get("db.instance");
$install_db = file_get_contents(__DIR__ . "/db.sql");
$db->exec(explode(";", $install_db));
}
/**
* Check if plugin is installed
* @return bool
*/
public function _installed()
{
$db = \Base::instance()->get("db.instance");
$db->exec("SHOW TABLES LIKE 'block'");
return (bool) $db->count();
}
}