Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
widgets.php
Go to the documentation of this file.
1 <?php
13 $num_columns = elgg_extract('num_columns', $vars, 3);
14 $show_add_widgets = elgg_extract('show_add_widgets', $vars, true);
15 $exact_match = elgg_extract('exact_match', $vars, false);
16 $show_access = elgg_extract('show_access', $vars, true);
17 $owner_guid = elgg_extract('owner_guid', $vars);
18 
20 if ($owner_guid) {
22 } else {
24 }
25 
26 if (!$owner) {
27  elgg_log('Can not resolve owner entity for widget layout', 'ERROR');
28  return;
29 }
30 
31 // Underlying views and functions assume that the page owner is the owner of the widgets
32 if ($owner->guid != $page_owner->guid) {
34 }
35 
37 
39  'context' => $context,
40  'exact' => $exact_match,
41  'container' => $owner,
42 ]);
43 
44 elgg_push_context('widgets');
45 
47 
49  'class' => 'elgg-layout-widgets',
50  'data-page-owner-guid' => $owner->guid,
51 ));
52 
53 echo "<div $layout_attrs>";
54 
56  if ($show_add_widgets) {
57  echo elgg_view('page/layouts/widgets/add_button');
58  }
59  $params = array(
60  'widgets' => $widgets,
61  'context' => $context,
62  'exact_match' => $exact_match,
63  'show_access' => $show_access,
64  );
65  echo elgg_view('page/layouts/widgets/add_panel', $params);
66 }
67 
68 if (isset($vars['content'])) {
69  echo $vars['content'];
70 }
71 
72 $widget_class = "elgg-col-1of{$num_columns}";
73 for ($column_index = 1; $column_index <= $num_columns; $column_index++) {
74  if (isset($widgets[$column_index])) {
75  $column_widgets = $widgets[$column_index];
76  } else {
77  $column_widgets = array();
78  }
79 
80  echo "<div class=\"$widget_class elgg-widgets\" id=\"elgg-widget-col-$column_index\">";
81  if (sizeof($column_widgets) > 0) {
82  foreach ($column_widgets as $widget) {
83  if (array_key_exists($widget->handler, $widget_types)) {
84  echo elgg_view_entity($widget, array('show_access' => $show_access));
85  }
86  }
87  }
88  echo '</div>';
89 }
90 
92 
93 echo elgg_view('graphics/ajax_loader', array('id' => 'elgg-widget-loader'));
94 
95 echo '</div>';
96 
97 
98 // Restore original page owner
99 if ($owner->guid != $page_owner->guid) {
101 }
$exact_match
Definition: widgets.php:15
$widget_types
Definition: widgets.php:38
$num_columns
Elgg widgets layout.
Definition: widgets.php:13
$widget
Definition: delete.php:9
$vars['entity']
elgg_set_page_owner_guid($guid)
Set the guid of the entity that owns this page.
Definition: pageowner.php:72
$params
Definition: login.php:72
elgg_get_widgets($owner_guid, $context)
Get widgets for a particular context.
Definition: widgets.php:24
$owner
Definition: crop.php:8
elgg_view_entity(\ElggEntity $entity, array $vars=array(), $bypass=false, $debug=false)
Returns a string of a rendered entity.
Definition: views.php:832
elgg_can_edit_widget_layout($context, $user_guid=0)
Can the user edit the widget layout.
Definition: widgets.php:54
elgg_pop_context()
Removes and returns the top context string from the stack.
Definition: pageowner.php:225
$page_owner
Definition: widgets.php:19
elgg_get_context()
Get the current context.
Definition: pageowner.php:204
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype= '')
Return a parsed view.
Definition: views.php:342
if(!$owner) if($owner->guid!=$page_owner->guid) $context
Definition: widgets.php:36
elgg_get_page_owner_entity()
Gets the owner entity for the current page.
Definition: pageowner.php:56
elgg_format_attributes(array $attrs=array())
Converts an associative array into a string of well-formed HTML/XML attributes Returns a concatenated...
Definition: output.php:139
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
$widgets
Definition: widgets.php:46
elgg_log($message, $level= 'NOTICE')
Display or log a message.
Definition: elgglib.php:1000
elgg_push_context($context)
Push a context onto the top of the stack.
Definition: pageowner.php:215
$owner_guid
Definition: widgets.php:17
elgg_get_widget_types($context="", $exact=false)
Get the widget types for a context.
Definition: widgets.php:140
$layout_attrs
Definition: widgets.php:48
$show_access
Definition: widgets.php:16
$show_add_widgets
Definition: widgets.php:14
if(elgg_can_edit_widget_layout($context)) if(isset($vars['content'])) $widget_class
Definition: widgets.php:72
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:204