Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
collapse_api: code cleanup
- Remove useless output buffering in collapse_api
  The obsolescence of $g_use_javascript setting (see commit
  75be0f4) makes the various ob_* calls
  unnecessary since the generated output is displayed in every case.
- phpDoc changes (revise references to javascript disabled)
- remove useless function call
- use a variable for collapse status class to improve readability
  • Loading branch information
dregad committed Oct 27, 2015
1 parent 7515016 commit 5a16d0e
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions core/collapse_api.php
Expand Up @@ -53,8 +53,7 @@

/**
* Marks the beginning of a collapse block's open phase.
* This will be visible if the block is expanded, or if
* javascript is disabled.
* This will be visible if the block is expanded or javascript is disabled.
* @param string $p_name Collapse block name.
* @param string $p_section Collapse block section.
* @param string $p_css_class CSS class to apply to the div (defaults to none).
Expand Down Expand Up @@ -86,8 +85,8 @@ function collapse_open( $p_name, $p_section = '', $p_css_class = '' ) {

/**
* Marks the end of a collapse block's open phase and the beginning
* of the block's closed phase. This will only be visible if the
* block have been collapsed and javascript is enabled.
* of the closed phase.
* This will be visible if the block is collapsed and javascript is enabled.
* @param string $p_name Collapse block name.
* @param string $p_section Collapse block section.
* @return void
Expand All @@ -107,10 +106,10 @@ function collapse_closed( $p_name, $p_section = '' ) {

$g_open_collapse_section = false;

ob_start();

$t_div_id = $t_block . '_closed';
echo "\n<div id=\"", $t_div_id, '" class="collapse-section-closed ', ( $t_display ? 'collapse-open' : 'collapse-closed' ), '">';
$t_collapse_status_class = $t_display ? 'collapse-open' : 'collapse-closed';
echo "\n" . '<div id="', $t_div_id,
'" class="collapse-section-closed ' . $t_collapse_status_class . '">';
}

/**
Expand Down Expand Up @@ -139,7 +138,6 @@ function collapse_icon( $p_name, $p_section = '' ) {

/**
* Marks the end of a collapse block's closed phase.
* Closed phase output is discarded if javascript is disabled.
* @param string $p_name Collapse block name.
* @param string $p_section Collapse block section.
* @return void
Expand All @@ -148,20 +146,15 @@ function collapse_end( $p_name, $p_section = '' ) {
global $g_current_collapse_section, $g_open_collapse_section;

$t_block = ( is_blank( $p_section ) ? $p_name : $p_section . '_' . $p_name );
collapse_display( $t_block );

# Make sure a section is opened, and it is the same section.
if( $t_block !== $g_current_collapse_section ) {
ob_end_clean();
trigger_error( ERROR_GENERIC, ERROR );
}

echo '</div>';

$g_open_collapse_section = false;

ob_end_flush();

$g_current_collapse_section = null;
}

Expand Down

0 comments on commit 5a16d0e

Please sign in to comment.