From fa39c6aaf2f9f87cfd89feaebdc22cf313396ec7 Mon Sep 17 00:00:00 2001 From: ben Date: Fri, 1 Aug 2008 13:47:15 +0000 Subject: Widgets now work in three columns git-svn-id: https://code.elgg.org/elgg/trunk@1653 36083f99-b078-4883-b0ff-0f9b5a30f544 --- actions/widgets/reorder.php | 3 ++- engine/lib/widgets.php | 29 +++++++++++++++++++++++------ entities/index.php | 5 ++++- views/default/canvas/layouts/widgets.php | 18 +++++++++++++----- 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/actions/widgets/reorder.php b/actions/widgets/reorder.php index 68fecfd6b..ff0fa4b52 100644 --- a/actions/widgets/reorder.php +++ b/actions/widgets/reorder.php @@ -17,8 +17,9 @@ $maincontent = get_input('debugField1'); $sidebar = get_input('debugField2'); + $rightbar = get_input('debugField3'); - $result = reorder_widgets_from_panel($maincontent, $sidebar, $context, $owner); + $result = reorder_widgets_from_panel($maincontent, $sidebar, $rightbar, $context, $owner); if ($result) { system_message(elgg_echo('widgets:panel:save:success')); diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php index 171d4928e..6bfa4c428 100644 --- a/engine/lib/widgets.php +++ b/engine/lib/widgets.php @@ -53,7 +53,7 @@ * * @param ElggObject $widget The widget entity * @param int $order The order within the column - * @param int $column The column (1 or 2) + * @param int $column The column (1, 2 or 3) * @return true|false Depending on success */ function save_widget_location(ElggObject $widget, $order, $column) { @@ -66,7 +66,7 @@ return false; // Sanitise the column value - if ($column != 1 || $column != 2) + if ($column != 1 || $column != 2 || $column != 3) $column = 1; $widget->column = (int) $column; @@ -163,7 +163,7 @@ * @param string $handler The handler for this widget * @param string $context The page context for this widget * @param int $order The order to display this widget in - * @param int $column The column to display this widget in (1 or 2) + * @param int $column The column to display this widget in (1, 2 or 3) * @return true|false Depending on success */ function add_widget($user_guid, $handler, $context, $order = 0, $column = 1) { @@ -329,12 +329,13 @@ } - function reorder_widgets_from_panel($panelstring1, $panelstring2, $context, $owner) { + function reorder_widgets_from_panel($panelstring1, $panelstring2, $panelstring3, $context, $owner) { $return = true; $mainwidgets = explode('::',$panelstring1); $sidewidgets = explode('::',$panelstring2); + $rightwidgets = explode('::',$panelstring3); $handlers = array(); $guids = array(); @@ -365,9 +366,22 @@ } } + if (is_array($rightwidgets) && sizeof($rightwidgets) > 0) { + foreach($rightwidgets as $widget) { + + $guid = (int) $widget; + + if ("{$guid}" == "{$widget}") { + $guids[3][] = $widget; + } else { + $handlers[3][] = $widget; + } + + } + } // Reorder existing widgets or delete ones that have vanished - foreach (array(1,2) as $column) { + foreach (array(1,2,3) as $column) { if ($dbwidgets = get_widgets($owner,$context,$column)) { foreach($dbwidgets as $dbwidget) { @@ -375,9 +389,12 @@ if (in_array($dbwidget->getGUID(),$guids[1])) { $pos = array_search($dbwidget->getGUID(),$guids[1]); $col = 1; - } else { + } else if (in_array($dbwidget->getGUID(),$guids[2])) { $pos = array_search($dbwidget->getGUID(),$guids[2]); $col = 2; + } else { + $pos = array_search($dbwidget->getGUID(),$guids[3]); + $col = 3; } $pos = ($pos + 1) * 10; $dbwidget->column = $col; diff --git a/entities/index.php b/entities/index.php index 3e573b338..b9890c1f8 100644 --- a/entities/index.php +++ b/entities/index.php @@ -35,8 +35,11 @@ // Set the body to be the full view of the entity, and the title to be its title $area2 = elgg_view_entity($entity,true); - if ($shell) + if ($shell) { $body = elgg_view_layout('two_column_left_sidebar', '', $area1 . $area2); + } else { + $body = $area2; + } // Otherwise? } else { diff --git a/views/default/canvas/layouts/widgets.php b/views/default/canvas/layouts/widgets.php index 57c46f3a4..0815242c8 100644 --- a/views/default/canvas/layouts/widgets.php +++ b/views/default/canvas/layouts/widgets.php @@ -17,8 +17,9 @@ $area1widgets = get_widgets(page_owner(),get_context(),1); $area2widgets = get_widgets(page_owner(),get_context(),2); + $area3widgets = get_widgets(page_owner(),get_context(),3); - if (empty($area1widgets) && empty($area2widgets)) { + if (empty($area1widgets) && empty($area2widgets) && empty($area3widgets)) { if (isset($vars['area3'])) $vars['area1'] = $vars['area3']; if (isset($vars['area4'])) $vars['area2'] = $vars['area4']; @@ -104,8 +105,8 @@ Choose the features you want to add to your page by dragging them from the Wi
> 0) { - foreach($area2widgets as $widget) { + if (is_array($area3widgets) && sizeof($area3widgets) > 0) { + foreach($area3widgets as $widget) { if (!empty($sidebarwidgetstring)) { $sidebarwidgetstring .= "::"; } @@ -259,7 +260,7 @@ Choose the features you want to add to your page by dragging them from the Wi - + Wi ?>
- + 0) + foreach($area3widgets as $widget) { + echo elgg_view_entity($widget); + } + + ?>
-- cgit v1.2.3