Elgg  Version 1.12
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 
20 $handler = $widget->handler;
21 
22 $title = $widget->getTitle();
23 
25 $can_edit = $widget->canEdit();
26 if ($can_edit) {
27  $edit_area = elgg_view('object/widget/elements/settings', array(
28  'widget' => $widget,
29  'show_access' => $show_access,
30  ));
31 }
32 $controls = elgg_view('object/widget/elements/controls', array(
33  'widget' => $widget,
34  'show_edit' => $edit_area != '',
35 ));
36 
37 $content = elgg_view('object/widget/elements/content', $vars);
38 
39 $widget_id = "elgg-widget-$widget->guid";
40 $widget_instance = preg_replace('/[^a-z0-9-]/i', '-', "elgg-widget-instance-$handler");
41 if ($can_edit) {
42  $widget_class = "elgg-state-draggable $widget_instance";
43 } else {
44  $widget_class = "elgg-state-fixed $widget_instance";
45 }
46 
48 if ($additional_class) {
49  $widget_class = "$widget_class $additional_class";
50 }
51 
52 $widget_header = <<<HEADER
53  <div class="elgg-widget-handle clearfix"><h3 class="elgg-widget-title">$title</h3>
54  $controls
55  </div>
56 HEADER;
57 
58 $widget_body = <<<BODY
60  <div class="elgg-widget-content" id="elgg-widget-content-$widget->guid">
61  $content
62  </div>
63 BODY;
64 
65 echo elgg_view_module('widget', '', $widget_body, array(
66  'class' => $widget_class,
67  'id' => $widget_id,
68  'header' => $widget_header,
69 ));
$additional_class
Definition: widget.php:47
elgg_view_module($type, $title, $body, array $vars=array())
Wrapper function for the module display pattern.
Definition: views.php:1203
if($can_edit) $controls
Definition: widget.php:32
$can_edit
Definition: widget.php:25
fieldset div
Definition: admin.php:474
$content
Definition: widget.php:37
$widget
Widget object.
Definition: widget.php:10
$widget_body
Definition: widget.php:58
$edit_area
Definition: widget.php:24
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:926
$handler
Definition: widget.php:20
$title
Definition: widget.php:22
elgg echo
Translates a string.
Definition: languages.js:48
$widget_types
Definition: widget.php:18
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
Definition: views.php:340
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:1271
elgg_get_widget_types($context="", $exact=false)
Get the widget types for a context.
Definition: widgets.php:119
$widget_id
Definition: widget.php:39
if($additional_class) $widget_header
Definition: widget.php:52
$widget_instance
Definition: widget.php:40
if(elgg_can_edit_widget_layout($context)) if(isset($vars['content'])) $widget_class
Definition: widgets.php:45
h3
Definition: admin.php:85
if(file_exists($welcome)) $vars
Definition: upgrade.php:93