-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathModule.php
executable file
·109 lines (98 loc) · 3 KB
/
Module.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
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
<?php
namespace SocialogAdmin;
/**
* Socialog Admin Module
*/
class Module
{
/**
* Bootstrap event
*
* @param type $e
*/
public function onBootstrap($e)
{
$app = $e->getApplication();
$sm = $app->getServiceManager();
$sharedEvents = $app->getEventManager()->getSharedManager();
$sharedEvents->attach('Zend\Mvc\Controller\AbstractController', 'dispatch', function($e) {
$controller = $e->getTarget();
if ($controller instanceof Controller\AbstractController) {
$controller->layout('socialog-admin/layout');
$sm = $controller->getServiceLocator();
$auth = $sm->get('socialog_auth');
if (!$auth->hasIdentity() && !$controller instanceof Controller\UserController) {
return $controller->redirect()->toRoute('socialog-admin/user');
}
}
}, 9999);
// Inhaken in menue
$sharedEvents->attach('render', array('post.edit', 'page.edit'), function($e) use ($sm) {
$view = $e->getTarget();
$cfg = $sm->get('Config');
if ($cfg['socialog-admin']['text-mode'] == 'wysiwyg') {
$basePath = $view->basePath() . '/../module/SocialogAdmin/public';
$view->headLink()
->appendStylesheet($basePath . '/vendor/wysihtml5/bootstrap-wysihtml5.css');
$view->headScript()
->appendFile($basePath . '/vendor/wysihtml5/wysihtml5-0.3.0.min.js')
->appendFile($basePath . '/vendor/wysihtml5/bootstrap-wysihtml5.js')
->appendScript(<<<SCRIPT
<script type="text/javascript">
$(function(){
$('textarea[name=content]').wysihtml5();
});
</script>
SCRIPT
);
}
}, 100);
}
/**
* Module Configuration
*
* @return array
*/
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
/**
* Autoloader Configuration
*
* @return array
*/
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
/**
* Service Configuration
*/
public function getServiceConfig()
{
return include __DIR__ . '/config/service.config.php';
}
/**
* Controller Helper Configuration
*/
public function getControllerPluginConfig()
{
return array(
'factories' => array(
'socialogauth' => function($sm) {
$sm = $sm->getServiceLocator();
$helper = new Controller\Plugin\Auth;
$helper->setAuthService($sm->get('socialog_auth'));
return $helper;
}
)
);
}
}