-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbootstrap.php
More file actions
133 lines (116 loc) · 6.7 KB
/
bootstrap.php
File metadata and controls
133 lines (116 loc) · 6.7 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
use Foolz\FoolFrame\Model\Autoloader;
use Foolz\FoolFrame\Model\Context;
use Foolz\FoolFrame\Model\DoctrineConnection;
use Foolz\Plugin\Event;
class HHVM_Articles
{
public function run()
{
Event::forge('Foolz\Plugin\Plugin::execute#foolz/foolframe-plugin-articles')
->setCall(function ($result) {
/* @var Context $context */
$context = $result->getParam('context');
/** @var Autoloader $autoloader */
$autoloader = $context->getService('autoloader');
$autoloader->addClassMap([
'Foolz\FoolFrame\Plugins\Articles\Model\Articles' => __DIR__ . '/classes/model/articles.php',
'Foolz\FoolFrame\Controller\Admin\Articles' => __DIR__ . '/classes/controller/admin.php',
'Foolz\FoolFuuka\Controller\Chan\Articles' => __DIR__ . '/classes/controller/chan.php'
]);
$context->getContainer()
->register('foolframe-plugin.articles', 'Foolz\FoolFrame\Plugins\Articles\Model\Articles')
->addArgument($context);
Event::forge('Foolz\FoolFrame\Model\Context::handleWeb#obj.afterAuth')
->setCall(function ($result) use ($context) {
// don't add the admin panels if the user is not an admin
if ($context->getService('auth')->hasAccess('maccess.admin')) {
$context->getRouteCollection()->add(
'foolframe.plugin.articles.admin', new \Symfony\Component\Routing\Route(
'/admin/articles/{_suffix}',
[
'_suffix' => 'manage',
'_controller' => '\Foolz\FoolFrame\Controller\Admin\Articles::*'
],
[
'_suffix' => '.*'
]
)
);
function() {die('lol');};
Event::forge('Foolz\FoolFrame\Controller\Admin::before#var.sidebar')
->setCall(function ($result) {
$sidebar = $result->getParam('sidebar');
$sidebar[]['articles'] = [
'name' => _i('Articles'),
'default' => 'manage',
'position' => [
'beforeafter' => 'before',
'element' => 'account'
],
'level' => 'admin',
'content' => [
'manage' => ['level' => 'admin', 'name' => _i('Articles'), 'icon' => 'icon-font'],
]];
$result->setParam('sidebar', $sidebar);
});
}
$context->getRouteCollection()->add(
'foolframe.plugin.articles.chan', new \Symfony\Component\Routing\Route(
'/_/articles/{_suffix}',
[
'_suffix' => '',
'_controller' => '\Foolz\FoolFuuka\Controller\Chan\Articles::articles'
],
[
'_suffix' => '.*'
]
)
);
Event::forge('foolframe.themes.generic_top_nav_buttons')
->setCall(function ($result) use ($context) {
$context->getService('foolframe-plugin.articles')->getNav('top', $result);
})
->setPriority(3);
Event::forge('foolframe.themes.generic_bottom_nav_buttons')
->setCall(function ($result) use ($context) {
$context->getService('foolframe-plugin.articles')->getNav('bottom', $result);
})
->setPriority(3);
Event::forge('foolframe.themes.generic.index_nav_elements')
->setCall(function ($result) use ($context) {
$context->getService('foolframe-plugin.articles')->getIndex($result);
})
->setPriority(3);
});
});
Event::forge('Foolz\FoolFrame\Model\Plugin::install#foolz/foolframe-plugin-articles')
->setCall(function ($result) {
/** @var Context $context */
$context = $result->getParam('context');
/** @var DoctrineConnection $dc */
$dc = $context->getService('doctrine');
/** @var $schema \Doctrine\DBAL\Schema\Schema */
/** @var $table \Doctrine\DBAL\Schema\Table */
$schema = $result->getParam('schema');
$table = $schema->createTable($dc->p('plugin_ff_articles'));
if ($dc->getConnection()->getDriver()->getName() == 'pdo_mysql') {
$table->addOption('charset', 'utf8mb4');
$table->addOption('collate', 'utf8mb4_unicode_ci');
}
$table->addColumn('id', 'integer', ['unsigned' => true, 'autoincrement' => true]);
$table->addColumn('slug', 'string', ['length' => 128]);
$table->addColumn('title', 'string', ['length' => 256]);
$table->addColumn('url', 'string', ['length' => 256]);
$table->addColumn('content', 'text', ['length' => 65532]);
$table->addColumn('hidden', 'smallint', ['unsigned' => true, 'default' => 0]);
$table->addColumn('top', 'smallint', ['unsigned' => true, 'default' => 0]);
$table->addColumn('bottom', 'smallint', ['unsigned' => true, 'default' => 0]);
$table->addColumn('timestamp', 'integer', ['unsigned' => true]);
$table->setPrimaryKey(['id']);
$table->addIndex(['slug'], $dc->p('plugin_ff_articles_slug_index'));
$table->addIndex(['title'], $dc->p('plugin_ff_articles_title_index'));
});
}
}
(new HHVM_Articles())->run();