oikai_listsource() – List the source of the function

You appear to be a bot. Output may be restricted

Description

List the source of the function

List source may involve parsing some or all of the source to create the dynamic listing. When we only want a bit of the source then we will parse only a subset but when we're parsing it for real we do the lot. Whether or not we update the parsed source after parsing depends on how we were doing it.

$parsed_source context( “paged” ) processing update parsed source
latest false Parse the full source Yes
latest other Use the parsed source No
not latest false Parse the full source Yes
not latest true Parse part of the source No

Once we've got the source then we can do the "navi" bit.

Usage

oikai_listsource( $refFunc, $post_id, $plugin_slug, $component_type, $echo );

Parameters

$refFunc
( object ) required
$post_id
( ID ) required
$plugin_slug
( mixed ) required
$component_type
( string ) required
$echo
( bool ) optional default: 1 – true if we actually do want the source listed

Returns

void

Source

File name: oik-shortcodes/shortcodes/oik-api-importer.php
Lines:

1 to 67 of 67
function oikai_listsource( $refFunc, $post_id=null, $plugin_slug, $component_type, $echo=true ) {
  bw_trace2( $refFunc->methodname, $plugin_slug, false );
  oikai_protect_save_post();
  $fileName = $refFunc->getFileName();
  $paged = bw_context( "paged" );
  $saved_post = null;
  $parsed_source_id = null;
  oik_require( "classes/class-oiksc-parsed-source.php", "oik-shortcodes" );
  $oiksc_parsed_source = oiksc_parsed_source::instance();
  $parsed_source = $oiksc_parsed_source->get_latest_parsed_source_by_sourceref( $fileName, $component_type, $post_id, $plugin_slug );
  
  if ( $post_id && $paged !== false ) {
    
    // $parsed_source = bw_get_parsed_source_by_sourceref( $post_id );
    $saved_post = bw_global_post( $parsed_source );
    if ( $parsed_source ) {
      $parsed_source_id = $parsed_source->ID;
    }
  } else {
    $parsed_source = null;
  }
  
  if ( !$parsed_source ) {

    $fileName = oiksc_real_file( $fileName, $component_type, $plugin_slug ); 
    $sources = oikai_load_from_file( $fileName, $refFunc );
    $parsing_necessary = $oiksc_parsed_source->is_parsing_necessary( $sources );
    if ( $paged === false && $parsing_necessary ) {
      oikai_set_time_limit();
      bw_push();
      oikai_syntax_source( $sources, 1 );
      $parsed_source = bw_ret();
      bw_pop();
      
      oik_require( "classes/class-oiksc-parsed-source.php", "oik-shortcodes" );
      oik_require( "classes/oik-listapis2.php", "oik-shortcodes" );
      //$plugin_slug = get_post_meta( $plugin_id, "_oikp_slug", true );
      //$component_type = oiksc_query_component_type( $plugin_slug );
      global $plugin;
      $plugin = $plugin_slug;
      // e( "flarg: $fileName" );
      $parsed_source_id = $oiksc_parsed_source->update_parsed_source( $post_id, $parsed_source, $fileName );   //   $files[$file]
    } else { 
      // We only handle a subset!
      // $parsed_source = null;
      //
    }
  } else { 
    $parsed_source = $parsed_source->post_content;
  }
  
  if ( $echo ) { 
    if ( $parsed_source ) {

      //oikai_navi_parsed_source( $parsed_source );
      oik_require( "shortcodes/oik-parsed-source.php", "oik-shortcodes" );
      $atts = array( "paged" => $paged, "id" => $parsed_source_id ); 
      $result = oikai_parsed_source( $atts, $parsed_source );
      c( "after oikai_parsed_source" );
      e( $result ); 
      c( "agter result" );
    } else {
      oikai_navi_source( $sources );
    }
  }  
  bw_global_post( $saved_post );
}