Elgg  Version 1.11
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 // don't show content for default widgets
38 if (elgg_in_context('default_widgets')) {
39  $content = '';
40 } else {
41  if (elgg_view_exists("widgets/$handler/content")) {
42  $content = elgg_view("widgets/$handler/content", $vars);
43  } else {
44  elgg_deprecated_notice("widgets use content as the display view", 1.8);
45  $content = elgg_view("widgets/$handler/view", $vars);
46  }
47 }
48 
49 $widget_id = "elgg-widget-$widget->guid";
50 $widget_instance = preg_replace('/[^a-z0-9-]/i', '-', "elgg-widget-instance-$handler");
51 if ($can_edit) {
52  $widget_class = "elgg-state-draggable $widget_instance";
53 } else {
54  $widget_class = "elgg-state-fixed $widget_instance";
55 }
56 
58 if ($additional_class) {
59  $widget_class = "$widget_class $additional_class";
60 }
61 
62 $widget_header = <<<HEADER
63  <div class="elgg-widget-handle clearfix"><h3 class="elgg-widget-title">$title</h3>
64  $controls
65  </div>
66 HEADER;
67 
68 $widget_body = <<<BODY
70  <div class="elgg-widget-content" id="elgg-widget-content-$widget->guid">
71  $content
72  </div>
73 BODY;
74 
75 echo elgg_view_module('widget', '', $widget_body, array(
76  'class' => $widget_class,
77  'id' => $widget_id,
78  'header' => $widget_header,
79 ));
$additional_class
Definition: widget.php:57
elgg_view_module($type, $title, $body, array $vars=array())
Wrapper function for the module display pattern.
Definition: views.php:1217
if($can_edit) $controls
Definition: widget.php:32
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
Definition: views.php:318
$can_edit
Definition: widget.php:25
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1246
fieldset div
Definition: admin.php:470
$widget
Widget object.
Definition: widget.php:10
$widget_body
Definition: widget.php:68
$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:922
$handler
Definition: widget.php:20
$title
Definition: widget.php:22
elgg_in_context($context)
Check if this context exists anywhere in the stack.
Definition: pageowner.php:250
elgg echo
Translates a string.
Definition: languages.js:43
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:1006
$widget_types
Definition: widget.php:18
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
Definition: views.php:354
elgg_get_widget_types($context="", $exact=false)
Get the widget types for a context.
Definition: widgets.php:119
$content
Set robots.txt action.
Definition: set_robots.php:6
if($additional_class) $widget_header
Definition: widget.php:62
$widget_instance
Definition: widget.php:50
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