diff --git a/core.php b/core.php index b2a248e..23a7297 100644 --- a/core.php +++ b/core.php @@ -149,6 +149,8 @@ require_once( $t_core_path.'html_api.php' ); require_once( $t_core_path.'gpc_api.php' ); require_once( $t_core_path.'print_api.php' ); + require_once( $t_core_path.'collapse_api.php' ); + collapse_cache_token(); # custom functions (in main directory) # @@@ Move all such files to core/ diff --git a/core/collapse_api.php b/core/collapse_api.php index c32ec8a..49d7ec4 100644 --- a/core/collapse_api.php +++ b/core/collapse_api.php @@ -22,6 +22,7 @@ # -------------------------------------------------------- $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR; + require_once( $t_core_dir . 'tokens_api.php' ); ### Collapse API ### @@ -36,39 +37,52 @@ # : # collapse_end( 'xyz' ); # marks the end of the whole section # - # In javascript/common.js, add the g_div_xyz constants. - # $g_current_collapse_section = null; $g_open_collapse_section = false; - # --------------- - # Use at the top of the section that should be visible when the section is expanded. - # sections can not be nested - function collapse_open( $p_name ) { + $g_collapse_cache_token = null; + + /** + * Marks the beginning of a collapse block's open phase. + * This will be visible if the block is expanded, or if + * javascript is disabled. + * @param string Collapse block name + * @param string Collapse block section + */ + function collapse_open( $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 ); + $t_display = collapse_display( $t_block ); + # make sure no other collapse section is started if ( $g_current_collapse_section !== null ) { trigger_error( ERROR_GENERIC, ERROR ); } $g_open_collapse_section = true; - $g_current_collapse_section = $p_name; + $g_current_collapse_section = $t_block; - $t_div_id = $p_name . '_open'; - echo "
"; + $t_div_id = $t_block . '_open'; + echo '