aboutsummaryrefslogtreecommitdiff
path: root/views/default
diff options
context:
space:
mode:
Diffstat (limited to 'views/default')
-rw-r--r--views/default/css.php22
-rw-r--r--views/default/layouts/widgets.php22
-rw-r--r--views/default/widgets/add.php20
-rw-r--r--views/default/widgets/add_button.php13
4 files changed, 71 insertions, 6 deletions
diff --git a/views/default/css.php b/views/default/css.php
index 8409ceb8b..edb0ebe07 100644
--- a/views/default/css.php
+++ b/views/default/css.php
@@ -881,6 +881,28 @@ li.navigation_more ul li {
.widget_first_col {
margin-right: 0;
}
+#widget_add_button {
+ padding: 0px;
+ background-color: transparent;
+ text-align: right;
+}
+.widgets_add {
+ width: 100%;
+ padding: 10px;
+ margin-bottom: 15px;
+ background: #dedede;
+}
+.widgets_add li {
+ float: left;
+ margin: 2px 10px;
+ list-style: none;
+}
+.widgets_add li a {
+ display: block;
+ width: 200px;
+ padding: 4px;
+ background-color: #cccccc;
+}
.widget {
background-color: #dedede;
padding: 2px;
diff --git a/views/default/layouts/widgets.php b/views/default/layouts/widgets.php
index 21d942080..5d6e42a43 100644
--- a/views/default/layouts/widgets.php
+++ b/views/default/layouts/widgets.php
@@ -4,21 +4,25 @@
*
* @uses $vars['box'] Optional display box at the top of layout
* @uses $vars['num_columns'] Number of widget columns for this layout
+ * @uses $vars['show_add_widgets'] Display the add widgets button
*/
+$box = elgg_get_array_value('box', $vars, '');
+$num_columns = elgg_get_array_value('num_columns', $vars, 3);
+$show_add_widgets = elgg_get_array_value('show_add_widgets', $vars, true);
+
$owner = elgg_get_page_owner();
$context = elgg_get_context();
elgg_push_context('widgets');
-if (isset($vars['box'])) {
- echo $vars['box'];
-}
+elgg_get_widgets($owner->guid, $context);
-$num_columns = 3;
-if (isset($vars['num_columns'])) {
- $num_columns = $vars['num_columns'];
+if (elgg_can_edit_widgets()) {
+ echo elgg_view('widgets/add', array('widgets' => $widgets));
}
+echo $vars['box'];
+
$widget_class = "widget_col_$num_columns";
for ($column_index = 1; $column_index <= $num_columns; $column_index++) {
$widgets = get_widgets($owner->guid, $context, $column_index);
@@ -33,6 +37,12 @@ for ($column_index = 1; $column_index <= $num_columns; $column_index++) {
$first = ($column_index == 1) ? 'widget_first_col' : '';
echo "<div class=\"widget_column $widget_class $first\">";
+ // button for adding new widgets
+ if ($column_index == 1) {
+ if ($show_add_widgets && elgg_can_edit_widgets()) {
+ echo elgg_view('widgets/add_button');
+ }
+ }
if (is_array($widgets) && sizeof($widgets) > 0) {
foreach ($widgets as $widget) {
echo elgg_view_entity($widget);
diff --git a/views/default/widgets/add.php b/views/default/widgets/add.php
new file mode 100644
index 000000000..2cc06dab7
--- /dev/null
+++ b/views/default/widgets/add.php
@@ -0,0 +1,20 @@
+<?php
+
+$widgets = $vars['widgets'];
+$widget_types = get_widget_types();
+
+?>
+<div class="widgets_add hidden">
+ <p>
+ <?php echo elgg_echo('widgets:add:description'); ?>
+ </p>
+ <ul>
+ <?php
+ foreach ($widget_types as $widget_type) {
+ $link = elgg_view('output/url', array('text' => $widget_type->name, 'href' => '#'));
+ echo "<li>$link</li>";
+ }
+ ?>
+ </ul>
+ <div class="clearfloat"></div>
+</div>
diff --git a/views/default/widgets/add_button.php b/views/default/widgets/add_button.php
new file mode 100644
index 000000000..8ec36b086
--- /dev/null
+++ b/views/default/widgets/add_button.php
@@ -0,0 +1,13 @@
+<?php
+
+?>
+<div class="widget" id="widget_add_button">
+<?php
+$options = array(
+ 'href' => '#',
+ 'text' => elgg_echo('widgets:add'),
+ 'class' => 'action_button',
+);
+echo elgg_view('output/url', $options);
+?>
+</div>