Skip to content

Commit

Permalink
Merge pull request #12 from x-team/issue-11
Browse files Browse the repository at this point in the history
Issue-11 Views This close #11
  • Loading branch information
jonathanbardo committed Feb 11, 2014
2 parents 1017846 + 56b71e8 commit 486329b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
35 changes: 23 additions & 12 deletions stream-reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ private function __construct() {
define( 'WP_STREAM_REPORTS_DIR', plugin_dir_path( __FILE__ ) );
define( 'WP_STREAM_REPORTS_URL', plugin_dir_url( __FILE__ ) );
define( 'WP_STREAM_REPORTS_INC_DIR', WP_STREAM_REPORTS_DIR . 'includes/' );
define( 'WP_STREAM_REPORTS_VIEW_DIR', WP_STREAM_REPORTS_DIR . 'views/' );
define( 'WP_STREAM_REPORTS_CLASS_DIR', WP_STREAM_REPORTS_DIR . 'classes/' );

add_action( 'plugins_loaded', array( $this, 'load' ) );
Expand Down Expand Up @@ -134,18 +135,28 @@ public function register_menu() {
* @return void
*/
public function page() {
$view = filter_input( INPUT_GET, 'view', FILTER_DEFAULT, array( 'options' => array( 'default' => 'list' ) ) );
$id = filter_input( INPUT_GET, 'id' );

return 'This is the page';
/*switch ( $view ) {
case 'rule':
$this->page_form( $id );
break;
default:
$this->page_list();
break;
}*/
$view = (object) array(
'slug' => 'all',
'path' => null,
);
if ( isset( $_GET['view'] ) && ! empty( $_GET['view'] ) ){
$view->slug = $_GET['view'];
}

// First we check if the file exists in our plugin folder, otherwhise give the user an error
if ( ! file_exists( WP_STREAM_REPORTS_VIEW_DIR . sanitize_file_name( $view->slug ) . '.php' ) ){
$view->slug = 'error';
}

// Define the path for the view we
$view->path = WP_STREAM_REPORTS_VIEW_DIR . sanitize_file_name( $view->slug ) . '.php';

// Execute some actions before including the view, to allow others to hook in here
// Use these to do stuff related to the view you are working with
do_action( 'stream-reports-view', $view );
do_action( "stream-reports-view-{$view->slug}", $view );

include_once $view->path;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions views/all.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="wrap">
<h2><?php _e( "Stream Reports", 'stream-reports' ); ?></h2>


</div>
6 changes: 6 additions & 0 deletions views/error.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class='wrap about-wrap'>
<h1><?php _e( "Oops, that's an Error!", 'stream-reports' ); ?></h1>
<div class='about-text'>
<?php echo wpautop(__( "Yeah... Something went very wrong somewhere along your last actions.", 'stream-reports' )); ?>
</div>
</div>

0 comments on commit 486329b

Please sign in to comment.