-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwidget.php
63 lines (56 loc) · 1.85 KB
/
widget.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
<?php
/*
* ===================================================================
* -------------Widget library for codeigniter framework--------------
* ===================================================================
* install this file as core file,for example:
* application/core/widget.php
* -------------------------------------------------------------------
* @Developer: Abdullah AbuNada
* @Design pattern: HMVC
* @Date: 24-03-2014
* @version: 1.0
* @copyright: Copyright © 2014 Free Software Foundation GNU
* -------------------------------------------------------------------
*/
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Widget {
function Widget() {
$this->_assign_libraries();
}
//
function run($module, $name) {
$args = func_get_args();
$path = APPPATH . 'modules/' . $module . '/widgets/' . $name . EXT;
if(file_exists($path)){
require_once $path;
}
else {return FALSE;}
$name = ucfirst($name);
$widget = new $name();
// 2 for visible parameter to check permission
return call_user_func_array(array($widget, 'run'), array_slice($args, 2));
}
//render
function render($module, $view, $data = array()) {
extract($data);
$path = APPPATH . 'modules/' . $module . '/widgets/views/' . $view . EXT;
if(file_exists($path)){
include_once $path;
} else {
return FALSE;
}
}
//
function load($object) {
$this->$object = & load_class(ucfirst($object));
}
//
function _assign_libraries() {
$ci = & get_instance();
foreach (get_object_vars($ci) as $key => $object) {
$this->$key = & $ci->$key;
}
}
}