From 14ec883cb6bf1aeed000632068106eb8893fa4d1 Mon Sep 17 00:00:00 2001 From: Andrew Powers Date: Wed, 21 Mar 2012 15:49:50 -0700 Subject: [PATCH] Remove buffering :'( --- includes/class.template.php | 100 ++++++++++++++++++++--------------- index.php | 3 +- sections/content/section.php | 1 - 3 files changed, 57 insertions(+), 47 deletions(-) diff --git a/includes/class.template.php b/includes/class.template.php index 91fb58fd..e41d05a7 100644 --- a/includes/class.template.php +++ b/includes/class.template.php @@ -394,60 +394,58 @@ function print_section_html( $hook ){ foreach( $this->$hook as $key => $sid ){ /** - * Check for buffered version, use if that exists; then unset. + * This goes through and buffers sections so we can add classes to sections that 'tell the future' + * proved to be extremely hard to implement, and harder to work w/ all wp plugins (get_sidebars conflict) + * Leaving here for now, enabled by action. + * Original idea was for themers to use classes based on adjacent sections to style, instead, recommend using section hooks + options + * */ - if(isset($plbuffer[$sid])){ - $render = $plbuffer[$sid]; - unset($plbuffer[$sid]); - }else - $render = $this->buffer_template($sid); - - - - // RENDER // - if($render){ - - //$this->render_template($render, $sid, $markup_type); + if( has_action('buffer_sections') ){ + + /** + * Check for buffered version, use if that exists; then unset. + */ + if(isset($plbuffer[$sid])){ + $render = $plbuffer[$sid]; + unset($plbuffer[$sid]); + }else + $render = $this->buffer_template($sid); + + // RENDER // + if($render){ + + //$this->render_template($render, $sid, $markup_type); + + // PREVIOUS // + $last_sid = $this->get_last_rendered($hook); + + // NEXT // + $next_sid = $this->buffer_next_section($hook, $key, $sid); + + // DRAW APPROPRIATE SECTION // + $this->render_template($render, $sid, $markup_type, $this->conc($sid, $next_sid), $this->conc($sid, $last_sid, 'previous')); + + // SET AS LAST RENDERED // + $this->last_rendered = array('sid' => $sid, 'hook' => $hook); + + } - // PREVIOUS // - $last_sid = $this->get_last_rendered($hook); - // NEXT // - $next_sid = $this->buffer_next_section($hook, $key, $sid); + } else { - // DRAW APPROPRIATE SECTION // - $this->render_template($render, $sid, $markup_type, $this->conc($sid, $next_sid), $this->conc($sid, $last_sid, 'previous')); + $render = $this->buffer_template( $sid ); + + if($render) + $this->render_template($render, $sid, $markup_type); - // SET AS LAST RENDERED // - $this->last_rendered = array('sid' => $sid, 'hook' => $hook); - } - + } } } - function get_last_rendered($hook){ - - $order = array('header', 'templates', 'morefoot', 'footer'); - - $k = array_search($hook, $order); - - - if($k && isset($this->last_rendered)){ - return $this->last_rendered['sid']; - } elseif(isset($this->last_rendered) && ($hook == $this->last_rendered['hook'])){ - return $this->last_rendered['sid']; - } else { - return 'top'; - } - - } - - - /** * Renders the HTML template and adds surrounding 'standardized' markup and hooks */ @@ -518,6 +516,22 @@ function buffer_template( $sid ){ } + function get_last_rendered($hook){ + + $order = array('header', 'templates', 'morefoot', 'footer'); + + $k = array_search($hook, $order); + + + if($k && isset($this->last_rendered)){ + return $this->last_rendered['sid']; + } elseif(isset($this->last_rendered) && ($hook == $this->last_rendered['hook'])){ + return $this->last_rendered['sid']; + } else { + return 'top'; + } + + } /** * Concatenation used in classes */ @@ -601,8 +615,6 @@ function next_section($hook, $key){ } - - return $data; } diff --git a/index.php b/index.php index 27e4516e..ed9d2f27 100644 --- a/index.php +++ b/index.php @@ -46,6 +46,5 @@ * @todo Update inline documentation * @todo Define dates of releases; add to changelog? */ -?> -