Skip to content

Commit

Permalink
General bugfixes and consistency improvements.
Browse files Browse the repository at this point in the history
Also did some work on the Monitor extension.
  • Loading branch information
sybrew committed Nov 5, 2016
1 parent 6e73501 commit 8de474c
Show file tree
Hide file tree
Showing 25 changed files with 814 additions and 191 deletions.
2 changes: 1 addition & 1 deletion extensions/premium/analytics/trunk/analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function analytics_init() {
if ( isset( $loaded ) )
return $loaded;

tsf_extension_manager()->register_premium_extension_autoload_path( TSFEM_E_ANALYTICS_PATH_CLASS, 'Analytics' );
tsf_extension_manager()->_register_premium_extension_autoload_path( TSFEM_E_ANALYTICS_PATH_CLASS, 'Analytics' );

if ( is_admin() ) {
new Analytics_Admin();
Expand Down
115 changes: 94 additions & 21 deletions extensions/premium/monitor/trunk/inc/classes/monitor-admin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public function init_monitor_page() {
?>
<div class="wrap tsfem tsfem-flex tsfem-flex-nowrap tsfem-flex-nogrowshrink">
<?php
$this->output_monitor_overview_wrapper();
$this->output_monitor_overview_wrapper();
?>
</div>
<?php
Expand Down Expand Up @@ -330,38 +330,25 @@ public function output_theme_color_meta() {
$this->get_view( 'layout/pages/meta' );
}

/**
* Wraps pane data into HTML objects. Iterates over data.
*
* @since 1.0.0
* @uses TSF_Extension_Manager_Extension\Monitor_Data->interpret_data_input()
* @generator
*/
protected function output_pane_data( $data, $type = '' ) {
echo '<div class="tsfem-pane-inner-wrap">';
foreach ( $data as $key => $val ) {
yield $this->interpret_data_input( $key, $val, $type );
}
echo '</div>';
}

/**
* Creates issues overview for the issues pane.
*
* @since 1.0.0
*/
protected function get_issues_overview() {

$output = '';
$issues = $this->get_data( 'issues', array() );

if ( empty( $issues ) ) {
return esc_html__( 'No data has been found as of yet.', 'the-seo-framework-extension-manager' );
$output .= esc_html__( 'No data has been found as of yet.', 'the-seo-framework-extension-manager' );
} else {
/* foreach ( $this->output_pane_data( $issues, 'issues' ) as $output ) :
//* Already escaped.
echo $output;
endforeach;*/
foreach ( $this->render_pane_slab_data( $issues, 'issues' ) as $slab )
$output .= $slab;

}

return sprintf( '<div class="tsfem-pane-inner-wrap">%s</div>', $output );
}

/**
Expand Down Expand Up @@ -396,6 +383,92 @@ protected function get_statistics_overview() {
}
}

/**
* Iterates over pane slab data.
*
* @since 1.0.0
* @uses TSF_Extension_Manager_Extension\Monitor_Admin->setup_slab_title_prefix()
* @uses TSF_Extension_Manager_Extension\Monitor_Admin->make_slab_nav_entry()
* @uses TSF_Extension_Manager_Extension\Monitor_Admin->make_slab_info_entry()
* @generator
*
* @param array $data The fetched data.
* @param string $type The pane-date type.
* @yields Interpreted data from array in two slabs (js) or beneath eachother (no-js).
*/
protected function render_pane_slab_data( $data = array(), $type = '' ) {

foreach ( $data as $key => $value ) :
//* @TODO var_dump()
//$this->setup_slab_title_prefix( $key, $value, $type );

yield $this->make_slab_nav_entry( $key, $type, -1 );
yield $this->make_slab_info_entry( $key, $value, $type );
endforeach;

}

/**
* Makes slab entry title from input $key and $type for when no JS is present.
*
* @since 1.0.0
*
* @param string $key The array key.
* @param string $type The pane-data type.
* @return string The HTML formed data.
*/
protected function make_slab_nav_entry( $key, $type ) {

$title = $this->get_slab_entry_title( $key, $type );
$prefix = $this->get_slab_nav_entry_state_sign( $key, $type );

return sprintf( '<h2 id="tsfem-e-monitor-%s-nav-entry" class="tsfem-e-monitor-nav-entry">%s%s</h2>', esc_attr( $key ), $prefix, esc_html( $title ) );
}

/**
* Interprets data input and finds an appropriate content function for it.
*
* @since 1.0.0
*
* @param string $key The array key.
* @param mixed $value The array value attached to $key.
* @param string $type The pane-data type.
* @return string The HTML formed data.
*/
protected function make_slab_info_entry( $key, $value, $type ) {

$output = Monitor_Output::parse_content( $key, $value, $type );

return sprintf( '<div id="tsfem-e-monitor-%s-nav-output" class="tsfem-e-monitor-nav-output">%s</div>', esc_attr( $key ), $output );
}

protected function get_slab_nav_entry_state_sign( $key, $type ) {
// TODO: set "good/okay/warning/bad/unknown" signs.
return '_X_';
}

/**
* Returns slab entry title based on $key and $type.
*
* @since 1.0.0
* @staticvar array $cache Maintains the titles cache.
*
* @param string $key The array key.
* @param string $type The pane-data type.
* @return string The escaped $type $key title.
*/
protected function get_slab_entry_title( $key, $type ) {

static $cache = array();

if ( isset( $cache[ $type ][ $key ] ) )
return $cache[ $type ][ $key ];

$title = Monitor_Output::parse_title( $key, $type );

return $cache[ $type ][ $key ] = esc_html( $title );
}

/**
* Fetches files based on input to reduce memory overhead.
* Passes on input vars.
Expand Down
Loading

0 comments on commit 8de474c

Please sign in to comment.