-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinjector.php
65 lines (56 loc) · 1.8 KB
/
injector.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* @package fi_openkeidas_articles
* @author The Midgard Project, http://www.midgard-project.org
* @copyright The Midgard Project, http://www.midgard-project.org
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
*/
/**
* @package fi_openkeidas_articles
*/
class fi_openkeidas_articles_injector
{
public function inject_process(midgardmvc_core_request $request)
{
static $connected = false;
if (!$connected)
{
// Subscribe to content changed signals from Midgard
midgard_object_class::connect_default('fi_openkeidas_articles_article', 'action-create', array('fi_openkeidas_articles_injector', 'check_node'), array($request));
$connected = true;
}
$component = $request->get_node()->get_component();
/* Patch out article authorization 200712 */
/*
if ($component == 'fi_openkeidas_articles')
{
midgardmvc_core::get_instance()->authorization->require_user();
}
*/
}
public function inject_template(midgardmvc_core_request $request)
{
// We inject the template to provide Open Keidas styling
$request->add_component_to_chain(midgardmvc_core::get_instance()->component->get('fi_openkeidas_articles'), true);
}
public static function check_node(fi_openkeidas_articles_article $article, $params)
{
if ($article->node)
{
return;
}
$request = midgardmvc_core::get_instance()->context->get_request();
$node = $request->get_node();
if (!$node)
{
return;
}
$node_object = $node->get_object();
if (!$node_object instanceof midgardmvc_core_node)
{
return;
}
$article->node = $node_object->id;
}
}
?>