Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
widget.php
Go to the documentation of this file.
1 <?php
10 $widget = $vars['entity'];
11 if (!elgg_instanceof($widget, 'object', 'widget')) {
12  return true;
13 }
14 
15 $show_access = elgg_extract('show_access', $vars, true);
16 
17 // @todo catch for disabled plugins
19  'context' => 'all',
20  'container' => $widget->getContainerEntity(),
21 ]);
22 
23 $handler = $widget->handler;
24 
25 $title = $widget->getTitle();
26 
28 $can_edit = $widget->canEdit();
29 if ($can_edit) {
30  $edit_area = elgg_view('object/widget/elements/settings', array(
31  'widget' => $widget,
32  'show_access' => $show_access,
33  ));
34 }
35 $controls = elgg_view('object/widget/elements/controls', array(
36  'widget' => $widget,
37  'show_edit' => $edit_area != '',
38 ));
39 
40 $content = elgg_view('object/widget/elements/content', $vars);
41 
42 $widget_id = "elgg-widget-$widget->guid";
43 $widget_instance = preg_replace('/[^a-z0-9-]/i', '-', "elgg-widget-instance-$handler");
44 if ($can_edit) {
45  $widget_class = "elgg-state-draggable $widget_instance";
46 } else {
47  $widget_class = "elgg-state-fixed $widget_instance";
48 }
49 
51 if ($additional_class) {
52  $widget_class = "$widget_class $additional_class";
53 }
54 
55 $widget_header = <<<HEADER
56  <div class="elgg-widget-handle clearfix"><h3 class="elgg-widget-title">$title</h3>
57  $controls
58  </div>
59 HEADER;
60 
61 $widget_body = <<<BODY
63  <div class="elgg-widget-content" id="elgg-widget-content-$widget->guid">
64  $content
65  </div>
66 BODY;
67 
68 echo elgg_view_module('widget', '', $widget_body, array(
69  'class' => $widget_class,
70  'id' => $widget_id,
71  'header' => $widget_header,
72 ));
$additional_class
Definition: widget.php:50
if($can_edit) $controls
Definition: widget.php:35
$can_edit
Definition: widget.php:28
$vars['entity']
$content
Definition: widget.php:40
$widget
Widget object.
Definition: widget.php:10
$widget_body
Definition: widget.php:61
$edit_area
Definition: widget.php:27
if(!elgg_instanceof($widget, 'object', 'widget')) $show_access
Definition: widget.php:15
elgg_instanceof($entity, $type=null, $subtype=null, $class=null)
Checks if $entity is an and optionally for type and subtype.
Definition: entities.php:716
elgg module widget elgg head h3
$handler
Definition: widget.php:23
$title
Definition: widget.php:25
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype= '')
Return a parsed view.
Definition: views.php:342
$widget_types
Definition: widget.php:18
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1310
elgg_view_module($type, $title, $body, array $vars=array())
Wrapper function for the module display pattern.
Definition: views.php:1207
elgg_get_widget_types($context="", $exact=false)
Get the widget types for a context.
Definition: widgets.php:140
$widget_id
Definition: widget.php:42
if($additional_class) $widget_header
Definition: widget.php:55
$widget_instance
Definition: widget.php:43
if(elgg_can_edit_widget_layout($context)) if(isset($vars['content'])) $widget_class
Definition: widgets.php:72