widgets.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Widgets CSS
  4. */
  5. $url = current_page_url();
  6. elgg_register_plugin_hook_handler('view', 'widgets/friends/content', 'css_widget_content');
  7. elgg_register_plugin_hook_handler('view', 'widgets/friends/edit', 'css_widget_content');
  8. elgg_register_plugin_hook_handler('permissions_check', 'all', 'css_permissions_override');
  9. function css_widget_content() {
  10. return $ipsum = elgg_view('developers/ipsum');
  11. }
  12. function css_permissions_override() {
  13. return true;
  14. }
  15. ?>
  16. <div class="elgg-body mal">
  17. <?php echo elgg_view('theme_sandbox/header', $vars); ?>
  18. <?php
  19. $w = array();
  20. for ($i=1; $i<=6; $i++) {
  21. $obj = new ElggWidget();
  22. $obj->handler = 'friends';
  23. $obj->title = "Widget $i";
  24. $w[] = $obj;
  25. }
  26. $column1 = array($w[0], $w[1]);
  27. $column2 = array($w[2], $w[3]);
  28. $column3 = array($w[4], $w[5]);
  29. $widgets = array(1 => $column1, 2 => $column2, 3 => $column3);
  30. $num_columns = 3;
  31. echo '<div class="elgg-layout-widgets">';
  32. $widget_class = "elgg-col-1of{$num_columns}";
  33. for ($column_index = 1; $column_index <= $num_columns; $column_index++) {
  34. $column_widgets = $widgets[$column_index];
  35. echo "<div class=\"$widget_class elgg-widgets\" id=\"elgg-widget-col-$column_index\">";
  36. if (is_array($column_widgets) && sizeof($column_widgets) > 0) {
  37. foreach ($column_widgets as $widget) {
  38. echo elgg_view_entity($widget);
  39. }
  40. }
  41. echo '</div>';
  42. }
  43. echo '</div>';
  44. ?>
  45. </div>
  46. <script type="text/javascript">
  47. // widgets do not have guids so we override the edit toggle and delete button
  48. $(function() {
  49. $('.elgg-widget-edit-button').unbind('click');
  50. $('.elgg-widget-edit-button').click(function() {
  51. $(this).closest('.elgg-module-widget').find('.elgg-widget-edit').slideToggle('medium');
  52. return false;
  53. });
  54. $('.elgg-widget-delete-button').click(function() {
  55. $(this).closest('.elgg-module-widget').remove();
  56. return false;
  57. });
  58. });
  59. </script>