-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathpi.widgets.php
More file actions
96 lines (73 loc) · 2 KB
/
pi.widgets.php
File metadata and controls
96 lines (73 loc) · 2 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
<?php defined('BASEPATH') or exit('No direct script access allowed');
/**
* Widgets Add-on
*
* @package ExpressionEngine 2
* @subpackage Third Party
* @category Modules
* @author Phil Sturgeon
* @link http://devot-ee.com/add-ons/widgets
*/
include_once PATH_THIRD.'widgets/libraries/Widget'.EXT;
class Widgets extends Widget
{
public $return_data = '';
private $_rendered_areas = array();
private $_default_wrapper = '
<div class="widget {slug}">
<h3>{instance_title}</h3>
<div class="widget-body">
{body}
</div>
</div>';
// --------------------------------------------------------------------
/**
* __construct()
*
* Called by {exp:widgets} the construct is the center of all logic for this plugin
*
* @access private
* @param int
* @return bool
*/
public function Widgets()
{
parent::__construct();
$this->load->library('widget');
}
public function widget()
{
$slug = $this->TMPL->fetch_param('name');
return $this->widget->render($slug, $options);
}
public function area()
{
$area = $this->TMPL->fetch_param('name');
$wrapper_html = $this->TMPL->tagdata ? $this->TMPL->tagdata : $this->_default_wrapper;
if (isset($this->_rendered_areas[$area]))
{
return $this->_rendered_areas[$area];
}
$widgets = $this->widgets_m->get_by_area($area);
$output = '';
foreach ($widgets as &$widget)
{
$widget->options = $this->widget->_unserialize_options($widget->options);
$widget->body = $this->widget->render($widget->slug, $widget->options);
$widget = (array) $widget;
}
$return = $this->TMPL->parse_variables(
'{widgets}'.$wrapper_html.'{/widgets}',
array(array('widgets' => $widgets))
);
return $this->_rendered_areas[$area] = $return;
}
public function instance()
{
$id = $this->TMPL->fetch_param('id');
$widget = $this->widget->get_instance($id, TRUE);
return $widget ? $this->widget->render($widget->slug, $widget->options) : '';
}
}
// END Widgets Class
/* Location: ./application/libraries/Widgets.php */