forked from elan-ev/studip-opencast-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopencast_controller.php
70 lines (61 loc) · 1.87 KB
/
opencast_controller.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
<?php
/**
* OpencastController - pimp the controller to work neatly in plugins
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @author Till Glöggler <tgloeggl@uos.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
*/
class OpencastController extends StudipController
{
function before_filter(&$action, &$args)
{
parent::before_filter($action, $args);
$this->plugin = $this->dispatcher->current_plugin;
$this->flash = Trails_Flash::instance();
}
/**
* a wrapper to allow retrieving the plugin-url in the controllers
*
* @return string
*/
function getPluginURL()
{
return $GLOBALS['epplugin_path'];
}
/**
* overwrite the default url_for to enable to it work in plugins
*
* @param type $to
* @return type
*/
function url_for($to = '')
{
$args = func_get_args();
// find params
$params = array();
if (is_array(end($args))) {
$params = array_pop($args);
}
// urlencode all but the first argument
$args = array_map('urlencode', $args);
$args[0] = $to;
return PluginEngine::getURL($this->dispatcher->current_plugin, $params, join('/', $args));
}
/**
* Throw an array at this function and it will call render_text to output
* the json-version of that array while setting an appropriate http-header
*
* @param array $data
*/
function render_json($data)
{
$this->response->add_header('Content-Type', 'application/json');
$this->render_text(json_encode(studip_utf8encode($data)));
}
}