Elgg /
Elgg
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Widgets CSS |
||
| 4 | */ |
||
| 5 | |||
| 6 | $url = current_page_url(); |
||
| 7 | |||
| 8 | elgg_register_plugin_hook_handler('view', 'widgets/friends/content', 'css_widget_content'); |
||
| 9 | elgg_register_plugin_hook_handler('view', 'widgets/friends/edit', 'css_widget_content'); |
||
| 10 | elgg_register_plugin_hook_handler('permissions_check', 'all', 'css_permissions_override', 600); |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Create dummy content |
||
| 14 | * |
||
| 15 | * @return string |
||
| 16 | */ |
||
| 17 | function css_widget_content() { |
||
| 18 | return elgg_view('developers/ipsum'); |
||
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Give permissions |
||
| 23 | * |
||
| 24 | * @return true |
||
| 25 | */ |
||
| 26 | function css_permissions_override() { |
||
| 27 | return true; |
||
| 28 | } |
||
| 29 | |||
| 30 | ?> |
||
| 31 | <div class="elgg-body mal"> |
||
| 32 | <?php echo elgg_view('theme_sandbox/header', $vars); ?> |
||
| 33 | <?php |
||
| 34 | $w = []; |
||
| 35 | for ($i=1; $i<=6; $i++) { |
||
| 36 | $obj = new ElggWidget(); |
||
| 37 | $obj->handler = 'friends'; |
||
| 38 | $obj->title = "Widget $i"; |
||
| 39 | $w[] = $obj; |
||
| 40 | } |
||
| 41 | $column1 = [$w[0], $w[1]]; |
||
| 42 | $column2 = [$w[2], $w[3]]; |
||
| 43 | $column3 = [$w[4], $w[5]]; |
||
| 44 | $widgets = [1 => $column1, 2 => $column2, 3 => $column3]; |
||
| 45 | $num_columns = 3; |
||
| 46 | |||
| 47 | echo '<div class="elgg-layout-widgets">'; |
||
| 48 | echo '<div class="elgg-widgets-grid">'; |
||
| 49 | $widget_class = "elgg-col-1of{$num_columns}"; |
||
| 50 | for ($column_index = 1; $column_index <= $num_columns; $column_index++) { |
||
| 51 | $column_widgets = $widgets[$column_index]; |
||
| 52 | |||
| 53 | echo "<div class=\"$widget_class elgg-widgets\" id=\"elgg-widget-col-$column_index\">"; |
||
| 54 | if (is_array($column_widgets) && sizeof($column_widgets) > 0) { |
||
|
0 ignored issues
–
show
|
|||
| 55 | foreach ($column_widgets as $widget) { |
||
| 56 | echo elgg_view_entity($widget); |
||
| 57 | } |
||
| 58 | } |
||
| 59 | echo '</div>'; |
||
| 60 | } |
||
| 61 | echo '</div>'; |
||
| 62 | echo '</div>'; |
||
| 63 | |||
| 64 | ?> |
||
| 65 | </div> |
||
| 66 | <script> |
||
| 67 | require(['elgg', 'jquery'], function (elgg, $) { |
||
| 68 | // widgets do not have guids so we override the edit toggle and delete button |
||
| 69 | $(function() { |
||
| 70 | $('.elgg-widget-edit-button').unbind('click'); |
||
| 71 | $('.elgg-widget-edit-button').on('click', function() { |
||
| 72 | $(this).closest('.elgg-module-widget').find('.elgg-widget-edit').slideToggle('medium'); |
||
| 73 | return false; |
||
| 74 | }); |
||
| 75 | $('.elgg-widget-delete-button').on('click', function() { |
||
| 76 | $(this).closest('.elgg-module-widget').remove(); |
||
| 77 | return false; |
||
| 78 | }); |
||
| 79 | }); |
||
| 80 | }); |
||
| 81 | </script> |
||
| 82 |
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.