public function sort_widgets($parent) { $widgets = get_widgets($parent); $count = 1; if (1 < count($widgets)) { foreach ($widgets as $wid) { if ($count != $wid['position']) { $this->db->where(array('wid_used_id' => $wid['wuid'])); $query = $this->db->update('tcp_wid_used', array('position' => $count)); } $count++; } } return true; }
/** * Reorders the widgets from a widget panel * * @param string $panelstring1 String of guids of ElggWidget objects separated by :: * @param string $panelstring2 String of guids of ElggWidget objects separated by :: * @param string $panelstring3 String of guids of ElggWidget objects separated by :: * @param string $context Profile or dashboard * @param int $owner Owner guid * * @return void * @deprecated 1.8 Don't use. */ function reorder_widgets_from_panel($panelstring1, $panelstring2, $panelstring3, $context, $owner) { elgg_deprecated_notice("reorder_widgets_from_panel() is deprecated", 1.8); $return = true; $mainwidgets = explode('::', $panelstring1); $sidewidgets = explode('::', $panelstring2); $rightwidgets = explode('::', $panelstring3); $handlers = array(); $guids = array(); if (is_array($mainwidgets) && sizeof($mainwidgets) > 0) { foreach ($mainwidgets as $widget) { $guid = (int) $widget; if ("{$guid}" == "{$widget}") { $guids[1][] = $widget; } else { $handlers[1][] = $widget; } } } if (is_array($sidewidgets) && sizeof($sidewidgets) > 0) { foreach ($sidewidgets as $widget) { $guid = (int) $widget; if ("{$guid}" == "{$widget}") { $guids[2][] = $widget; } else { $handlers[2][] = $widget; } } } 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, 3) as $column) { if ($dbwidgets = get_widgets($owner, $context, $column)) { foreach ($dbwidgets as $dbwidget) { if (in_array($dbwidget->getGUID(), $guids[1]) || in_array($dbwidget->getGUID(), $guids[2]) || in_array($dbwidget->getGUID(), $guids[3])) { if (in_array($dbwidget->getGUID(), $guids[1])) { $pos = array_search($dbwidget->getGUID(), $guids[1]); $col = 1; } 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; $dbwidget->order = $pos; } else { $dbguid = $dbwidget->getGUID(); if (!$dbwidget->delete()) { $return = false; } else { // Remove state cookie setcookie('widget' + $dbguid, null); } } } } // Add new ones if (sizeof($guids[$column]) > 0) { foreach ($guids[$column] as $key => $guid) { if ($guid == 0) { $pos = ($key + 1) * 10; $handler = $handlers[$column][$key]; if (!add_widget($owner, $handler, $context, $pos, $column)) { $return = false; } } } } } return $return; }
<div class="span3"> <?php get_widgets('right'); ?> </div>
<?php endforeach; ?> </div><!-- /.row --> <div id="dashboard-widgets-row-2" class="row"> <?php foreach (get_widgets() as $widget) : ?> <?php if ($widget->row == 2) { ?> <div class="col-lg-<?=$widget->width?>"> <div class="panel panel-info"> <div class="panel-heading"><h3><?=$widget->label?></h3></div> <div class="panel-body"> <?=$widget->get_html()?> </div> </div> </div> <?php } ?> <?php endforeach; ?> </div><!-- /.row --> <div id="dashboard-widgets-row-3" class="row"> <?php foreach (get_widgets() as $widget) : ?> <?php if ($widget->row == 3) { ?> <div class="col-lg-<?=$widget->width?>"> <div class="panel panel-info"> <div class="panel-heading"><h3><?=$widget->label?></h3></div> <div class="panel-body"> <?=$widget->get_html()?> </div> </div> </div> <?php } ?> <?php endforeach; ?> </div><!-- /.row -->
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, $xbmcjsonserviceoverride); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonRequest); $response = curl_exec($ch); curl_close($ch); } echo $response; } else { if (!empty($arrRequest)) { switch ($arrRequest["method"]) { case "SaveLayout": $arrResult = save_layout($arrRequest); break; case "GetWidgets": $arrResult = get_widgets($arrRequest); break; case "XBMCPassthough": $arrResult = xbmc_passthough($arrRequest); break; default: $arrResult = error_array(-32601, "Method not found."); } } else { $arrResult = error_array(-32700, "Parse error."); } echo json_encode($arrResult); } function save_layout($arrRequest) { if (!empty($arrRequest["params"]) && is_array($arrRequest["params"])) {
<?php /** * Elgg widget layout * * @package Elgg * @subpackage Core * @author Curverider Ltd * @link http://elgg.org/ */ $widgettypes = get_widget_types(); $owner = page_owner_entity(); $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) && empty($area3widgets)) { if (isset($vars['area3'])) { $vars['area1'] = $vars['area3']; } if (isset($vars['area4'])) { $vars['area2'] = $vars['area4']; } } if (is_array($widgettypes) && sizeof($widgettypes) > 0 && $owner && $owner->canEdit()) { ?> <div id="customise_editpanel"> <div id="customise_editpanel_rhs"> <h2><?php echo elgg_echo("widgets:gallery");
public function delete() { $this->check_authority(); if (isset($_POST['wuid']) and isset($_POST['parent'])) { $this->load->model('mwidget'); $wuid = $_POST['wuid']; $parent = $_POST['parent']; $wuid_info = $this->mwidget->get_wid_used($wuid); if (null != $wuid_info) { $wid_info = $this->mwidget->get_widget_list($wuid_info[0]->wid_id); if (null != $wid_info[0]->child_tbl) { $xtbl = $wid_info[0]->child_tbl; } else { $xtbl = null; } $delete = $this->mwidget->delete_widget($wuid, $xtbl); if (true == $delete) { $sort = $this->mwidget->sort_widgets($parent); $data['wid_list'] = $this->mwidget->get_widget_list(); $data['wid_area_wids'] = get_widgets($parent); $this->load->view($this->wid_dir . 'widgets_list', $data); } } } }
<?php $widgets = get_widgets($id); $theme = get_layout(); if (null != $widgets) { $wid_count = 0; foreach ($widgets as $widget) { $page = $widget['page']; require APP_PATH . "/views/widgets/{$page}.php"; if (file_exists(APP_PATH . "/views/layouts/{$theme}/{$view}.php")) { $view = "layouts/{$theme}/{$view}.php"; } $data['wid_count'] = $wid_count; $this->load->view($view, $data); $wid_count++; } }
<section id="bottom" class="wet-asphalt"> <div class="container"> <div class="row"> <?php get_widgets('bottom'); ?> </div> </div> </section>
public function widgets() { $this->check_authority(); $this->load->model('mwidget'); $this->load->model('msettings'); $gen_settings = $this->msettings->get_set_gen(); $wid_areas = get_layout_wid_areas($gen_settings[0]->theme); if (isset($_GET['area'])) { $area = $_GET['area']; if (in_array_r($area, $wid_areas, FALSE)) { $data['links'] = $this->get_dash_nav(); $data['wid_list'] = $this->mwidget->get_widget_list(); $data['wid_areas'] = $wid_areas; $data['wid_area_wids'] = get_widgets($area); $title = "Manage Widgets"; $page = 'dashboard/widgets/widgets'; $this->page_build($title, 'dashboard', $page, $data); } else { //Error 401 - Invalid/missing data $url = current_url() . '?area=' . $wid_areas[0]['id'] . '&msgcode=401'; redirect($url, 'refresh'); } } else { $url = current_url() . '?area=' . $wid_areas[0]['id']; redirect($url, 'refresh'); } }