function display($bodyLayout = 'mainbody', $sidebarLayout = 'sidebar', $sidebarChrome = 'standard', $contentTopLayout = 'standard', $contentTopChrome = 'standard', $contentBottomLayout = 'standard', $contentBottomChrome = 'standard', $grid = null) { global $gantry; global $wp_registered_sidebars, $wp_registered_widgets, $_wp_sidebars_widgets; if ($grid == null) { $grid = GRID_SYSTEM; } // get sidebar count $sidebars_widgets = wp_get_sidebars_widgets(); $sidebarCount = self::countSidebars($sidebars_widgets['sidebar']); $columnCount = $sidebarCount + 1; $position_renders = array(); //here we would see if the mainbody schema was set to soemthing else $defaultSchema = $gantry->mainbodySchemas[$grid][$columnCount]; $mbp = $gantry->get('mainbodyPosition'); $position = @unserialize($mbp); if (!isset($position[$grid]) || !isset($position[$grid]) || !array_key_exists($columnCount, $position[$grid])) { $schema = $defaultSchema; } else { $schema = $position[$grid][$columnCount]; } $end = end(array_keys($schema)); $start = reset(array_keys($schema)); $rtl_enabled = get_bloginfo('text_direction') == 'rtl' && $gantry->get('rtl-enabled') ? true : false; // If RTL then flip the array if ($rtl_enabled) { //$schema = $gantry->_flipBodyPosition($schema); $schema = array_reverse($schema, true); } $classKey = $gantry->_getKey($schema); $pushPull = $gantry->pushPullSchemas[$classKey]; $output = ''; $sidebars = ''; $contentTop = null; $contentBottom = null; $index = 1; // remove the mainbody and use the schema array for grid sizes $sidebarSchema = $schema; unset($sidebarSchema['mb']); // Add extra data to sidebar $sidebar =& $wp_registered_sidebars['sidebar']; $sidebar['layout'] = $sidebarLayout; $sidebar['chrome'] = $sidebarChrome; // clean to max sidebars $filtered_widgets = GantryWidgetsRenderer::filterWidgetCount($sidebars_widgets); $widgets = $filtered_widgets['sidebar']; if (null == $widgets) { $widgets = array(); } // Map widgets to sidebars without the dividers $widget_map = array(); $pos = 1; $pos_info_set = false; foreach ($widgets as $widget) { if (!$pos_info_set) { $widget_map[$pos]['gridCount'] = current($sidebarSchema); $widget_map[$pos]['pushPull'] = $pushPull[$index++]; $pos_info_set = true; } if (preg_match("/^gantrydivider/", $widget)) { $pos++; $pos_info_set = false; next($sidebarSchema); } else { $widget_map[$pos]['widgets'][$widget] = array('name' => $widget); } } $sidebar['widget_map'] = $widget_map; $sidebar['start'] = $start; $sidebar['end'] = $end; $schemaShorts = array_keys($sidebarSchema); if ($rtl_enabled) { $schemaShorts = array_reverse($schemaShorts); } $sbcount = 0; foreach ($widget_map as $pos => $widgets) { $extraClass = ''; $newsb = self::array_copy($sidebar); unset($newsb['widget_map']); $newsb['widget_map'][$pos] = $widgets; if ($schemaShorts[$sbcount] == $sidebar['start']) { $extraClass = " rt-alpha"; } if ($schemaShorts[$sbcount] == $sidebar['end']) { $extraClass = " rt-omega"; } if ($schemaShorts[$sbcount] == $sidebar['start'] && $schemaShorts[$sbcount] == $sidebar['end']) { $extraClass = " rt-alpha rt-omega"; } $newsb['widget_map'][$pos]['extraClass'] = $extraClass; $newsb['widget_map'][$pos]['pushPull'] = $extraClass; $wp_registered_sidebars['sidebar-' . $schemaShorts[$sbcount]] = $newsb; foreach ($widgets['widgets'] as $name => $widget) { $_wp_sidebars_widgets['sidebar-' . $schemaShorts[$sbcount]][] = $name; } $sbcount++; } $sidebars = array(); if ($rtl_enabled) { add_filter('sidebars_widgets', array('GantryOrderedMainBodyRenderer', 'invertPositionOrder')); } add_filter('dynamic_sidebar_params', array('GantryOrderedMainBodyRenderer', 'filterWidget')); foreach ($schemaShorts as $sshort) { ob_start(); dynamic_sidebar('sidebar-' . $sshort); $sidebars[$sshort] .= ob_get_clean(); } remove_filter('dynamic_sidebar_params', array('GantryOrderedMainBodyRenderer', 'filterWidget')); if ($rtl_enabled) { remove_filter('sidebars_widgets', array('GantryOrderedMainBodyRenderer', 'invertPositionOrder')); } if ($gantry->countModules('content-top')) { $contentTop = $gantry->displayModules('content-top', $contentTopLayout, $contentTopChrome, $schema['mb']); } if ($gantry->countModules('content-bottom')) { $contentBottom = $gantry->displayModules('content-bottom', $contentBottomLayout, $contentBottomChrome, $schema['mb']); } $extraClass = ''; if ('mb' == $start) { $extraClass = " rt-alpha"; } if ('mb' == $end) { $extraClass = " rt-omega"; } if ('mb' == $start && 'mb' == $end) { $extraClass = " rt-alpha rt-omega"; } $output = $gantry->renderLayout('orderedbody_' . $bodyLayout, array('schema' => $schema, 'pushPull' => '', 'classKey' => $classKey, 'sidebars' => $sidebars, 'contentTop' => $contentTop, 'contentBottom' => $contentBottom, 'extraClass' => $extraClass)); return $output; }
function display($positionStub, $layout = 'standard', $chrome = 'standard', $gridsize = GRID_SYSTEM, $pattern = null) { global $gantry; global $wp_registered_sidebars, $wp_registered_widgets; $position_info = $gantry->getPositionInfo($positionStub); $max_positions = $position_info->max_positions; $output = ''; $index = 0; $poscount = 1; $uniqpositions = $gantry->getUniquePositions(); $showAllParam = $gantry->get($positionStub . '-showall'); $showMaxParam = $gantry->get($positionStub . '-showmax'); if (!in_array($positionStub, $uniqpositions)) { return ""; } $sidebars_widgets = wp_get_sidebars_widgets(); // Add extra data to sidebar $sidebar =& $wp_registered_sidebars[$positionStub]; $sidebar['layout'] = $layout; $sidebar['chrome'] = $chrome; $sidebar['gridsize'] = $gridsize; $sidebar['pattern'] = $pattern; $sidebar['showall'] = $showAllParam; $sidebar['showmax'] = $showMaxParam; $filtered_widgets = GantryWidgetsRenderer::filterWidgetCount($sidebars_widgets); $widgets = $filtered_widgets[$positionStub]; // Map widgets to positions without the dividers $widget_map = array(); $pos = 1; if (null != $widgets) { foreach ($widgets as $widget) { if (preg_match("/^gantrydivider/", $widget)) { $pos++; } else { $widget_map[$pos]['widgets'][$widget] = array('name' => $widget); } } } $count = count($widget_map); if ($showAllParam == 1) { $count = $showMaxParam; } $end = end(array_keys($widget_map)); $start = reset(array_keys($widget_map)); $prefixCount = 0; for ($position = 1; $position <= $max_positions; $position++) { $widgets_in_position = false; if (array_key_exists($position, $widget_map)) { $widgets_in_position = true; } $extraClass = ''; if ($position == $start) { $extraClass = " rt-alpha"; } if ($position == $end) { $extraClass = " rt-omega"; } if ($position == $start && $position == $end) { $extraClass = " rt-alpha rt-omega"; } if ($showAllParam == 1 && !$widgets_in_position) { $prefixCount += $gantry->_getPositionSchema($positionStub, $gridsize, $count, $index); $index++; } else { if ($widgets_in_position) { // Apply chrome and render module $paramSchema = $gantry->_getPositionSchema($positionStub, $gridsize, $count, $index); $widget_map[$position]['extraClass'] = $extraClass; $widget_map[$position]['prefixCount'] = $prefixCount; $widget_map[$position]['paramsSchema'] = $paramSchema; $prefixCount = 0; // reset prefix count $index++; } } } $sidebar['widget_map'] = $widget_map; if (get_bloginfo('text_direction') == 'rtl' && $gantry->get('rtl-enabled')) { add_filter('sidebars_widgets', array('GantryWidgetsRenderer', 'invertPositionOrder')); } add_filter('dynamic_sidebar_params', array('GantryWidgetsRenderer', 'filterWidget')); ob_start(); do_action('get_sidebar', $positionStub); dynamic_sidebar($positionStub); $output = ob_get_clean(); remove_filter('dynamic_sidebar_params', array('GantryWidgetsRenderer', 'filterWidget')); if (get_bloginfo('text_direction') == 'rtl' && $gantry->get('rtl-enabled')) { remove_filter('sidebars_widgets', array('GantryWidgetsRenderer', 'invertPositionOrder')); } return $output; }
function display($bodyLayout = 'mainbody', $sidebarLayout = 'sidebar', $sidebarChrome = 'standard', $contentTopLayout = 'standard', $contentTopChrome = 'standard', $contentBottomLayout = 'standard', $contentBottomChrome = 'standard', $grid = null) { global $gantry; global $wp_registered_sidebars, $wp_registered_widgets; if ($grid == null) { $grid = GRID_SYSTEM; } // get sidebar count $sidebars_widgets = wp_get_sidebars_widgets(); $sidebarCount = GantryMainBodyRenderer::countSidebars($sidebars_widgets['sidebar']); $columnCount = $sidebarCount + 1; //here we would see if the mainbody schema was set to soemthing else $defaultSchema = $gantry->mainbodySchemas[$grid][$columnCount]; $mbp = $gantry->get('mainbodyPosition'); $position = @unserialize($mbp); if (!isset($position[$grid]) || !isset($position[$grid]) || !array_key_exists($columnCount, $position[$grid])) { $schema = $defaultSchema; } else { $schema = $position[$grid][$columnCount]; } // If RTL then flip the array if (get_bloginfo('text_direction') == 'rtl' && $gantry->get('rtl-enabled')) { $schema = $gantry->_flipBodyPosition($schema); } $classKey = $gantry->_getKey($schema); $pushPull = $gantry->pushPullSchemas[$classKey]; $output = ''; $sidebars = ''; $contentTop = null; $contentBottom = null; $index = 1; // remove the mainbody and use the schema array for grid sizes $sidebarSchema = $schema; unset($sidebarSchema['mb']); // Add extra data to sidebar $sidebar =& $wp_registered_sidebars['sidebar']; $sidebar['layout'] = $sidebarLayout; $sidebar['chrome'] = $sidebarChrome; // clean to max sidebars $filtered_widgets = GantryWidgetsRenderer::filterWidgetCount($sidebars_widgets); $widgets = $filtered_widgets['sidebar']; if (null == $widgets) { $widgets = array(); } // Map widgets to sidebars without the dividers $widget_map = array(); $pos = 1; $pos_info_set = false; if (get_bloginfo('text_direction') == 'rtl' && $gantry->get('rtl-enabled')) { $main_body_pp = array_shift($pushPull); $pushPull = array_reverse($pushPull); array_unshift($pushPull, $main_body_pp); } foreach ($widgets as $widget) { if (!$pos_info_set) { $widget_map[$pos]['gridCount'] = current($sidebarSchema); $widget_map[$pos]['pushPull'] = $pushPull[$index++]; $pos_info_set = true; } if (preg_match("/^gantrydivider/", $widget)) { $pos++; $pos_info_set = false; next($sidebarSchema); } else { $widget_map[$pos]['widgets'][$widget] = array('name' => $widget); } } $sidebar['widget_map'] = $widget_map; $sidebars = ""; if (get_bloginfo('text_direction') == 'rtl' && $gantry->get('rtl-enabled')) { add_filter('sidebars_widgets', array('GantryMainBodyRenderer', 'invertPositionOrder')); } add_filter('dynamic_sidebar_params', array('GantryMainBodyRenderer', 'filterWidget')); ob_start(); dynamic_sidebar('sidebar'); $sidebars .= ob_get_clean(); remove_filter('dynamic_sidebar_params', array('GantryMainBodyRenderer', 'filterWidget')); if (get_bloginfo('text_direction') == 'rtl' && $gantry->get('rtl-enabled')) { remove_filter('sidebars_widgets', array('GantryMainBodyRenderer', 'invertPositionOrder')); } if ($gantry->countModules('content-top')) { $contentTop = $gantry->displayModules('content-top', $contentTopLayout, $contentTopChrome, $schema['mb']); } if ($gantry->countModules('content-bottom')) { $contentBottom = $gantry->displayModules('content-bottom', $contentBottomLayout, $contentBottomChrome, $schema['mb']); } $output = $gantry->renderLayout('body_' . $bodyLayout, array('schema' => $schema, 'pushPull' => $pushPull, 'classKey' => $classKey, 'sidebars' => $sidebars, 'contentTop' => $contentTop, 'contentBottom' => $contentBottom)); return $output; }
function displayModules($positionStub, $layout = 'standard', $chrome = 'standard', $gridsize = GRID_SYSTEM, $pattern = null) { if (defined('GANTRY_FINALIZED')) { return; } gantry_import('core.renderers.gantrywidgetsrenderer'); return GantryWidgetsRenderer::display($positionStub, $layout, $chrome, $gridsize, $pattern); }