wip
This commit is contained in:
100
app/plugins/wip/controllers/admin/wip.php
Normal file
100
app/plugins/wip/controllers/admin/wip.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/wip/controllers/admin/wip.php
|
||||
*
|
||||
* This is the projects admin controller.
|
||||
*
|
||||
* @package TP Wip
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Controllers\Admin;
|
||||
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Houdini\Classes\Navigation;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
use TheTempusProject\Classes\AdminController;
|
||||
use TheTempusProject\Classes\Forms;
|
||||
use TheTempusProject\Models\Projects;
|
||||
|
||||
class Wip extends AdminController {
|
||||
public static $projects;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
self::$projects = new Projects;
|
||||
self::$title = 'Admin - WIP';
|
||||
}
|
||||
|
||||
public function index( $data = null ) {
|
||||
Views::view( 'wip.admin.list', self::$projects->listPaginated() );
|
||||
}
|
||||
|
||||
public function create( $data = null ) {
|
||||
if ( !Input::exists( 'submit' ) ) {
|
||||
return Views::view( 'wip.admin.create' );
|
||||
}
|
||||
if ( !Forms::check( 'newProject' ) ) {
|
||||
Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] );
|
||||
return $this->index();
|
||||
}
|
||||
$result = self::$projects->create( Input::post( 'title' ), Input::post( 'description' ), Input::post( 'progress' ), Input::post( 'startDate' ) );
|
||||
if ( $result ) {
|
||||
Issues::add( 'success', 'Your projects has been created.' );
|
||||
return $this->index();
|
||||
} else {
|
||||
Issues::add( 'error', [ 'There was an unknown error submitting your data.' => Check::userErrors() ] );
|
||||
return $this->index();
|
||||
}
|
||||
}
|
||||
|
||||
public function edit( $data = null ) {
|
||||
if ( !Input::exists( 'submit' ) ) {
|
||||
return Views::view( 'wip.admin.edit', self::$projects->findById( $data ) );
|
||||
}
|
||||
if ( !Forms::check( 'editProject' ) ) {
|
||||
Issues::add( 'error', [ 'There was an error with your form.' => Check::userErrors() ] );
|
||||
return $this->index();
|
||||
}
|
||||
$fields = [
|
||||
'title' => Input::post( 'title' ),
|
||||
'description' => Input::post( 'description' ),
|
||||
'progress' => Input::post( 'progress' ),
|
||||
'startDate' => Input::post( 'startDate' ),
|
||||
];
|
||||
if ( self::$projects->update( $data, $fields ) ) {
|
||||
Issues::add( 'success', 'Projects Updated.' );
|
||||
return $this->index();
|
||||
}
|
||||
Issues::add( 'error', 'There was an error with your request.' );
|
||||
$this->index();
|
||||
}
|
||||
|
||||
public function view( $data = null ) {
|
||||
$projectData = self::$projects->findById( $data );
|
||||
if ( $projectData !== false ) {
|
||||
return Views::view( 'wip.admin.view', $projectData );
|
||||
}
|
||||
Issues::add( 'error', 'Projects not found.' );
|
||||
$this->index();
|
||||
}
|
||||
|
||||
public function delete( $data = null ) {
|
||||
if ( $data == null ) {
|
||||
if ( Input::exists( 'P_' ) ) {
|
||||
$data = Input::post( 'P_' );
|
||||
}
|
||||
}
|
||||
if ( !self::$projects->delete( (array) $data ) ) {
|
||||
Issues::add( 'error', 'There was an error with your request.' );
|
||||
} else {
|
||||
Issues::add( 'success', 'Projects has been deleted' );
|
||||
}
|
||||
$this->index();
|
||||
}
|
||||
}
|
36
app/plugins/wip/controllers/wip.php
Normal file
36
app/plugins/wip/controllers/wip.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/wip/controllers/wip.php
|
||||
*
|
||||
* This is the bug reports controller.
|
||||
*
|
||||
* @package TP Wip
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Controllers;
|
||||
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Classes\Controller;
|
||||
use TheTempusProject\Models\Projects;
|
||||
|
||||
class Wip extends Controller {
|
||||
protected static $projects;
|
||||
|
||||
public function index() {
|
||||
self::$projects = new Projects;
|
||||
self::$title = '{SITENAME} - Works in Progress';
|
||||
self::$pageDescription = 'Its not the longest wip in the world, but I\'m certainly proud of it.';
|
||||
|
||||
$projects = self::$projects->listPaginated();
|
||||
if ( false == $projects ) {
|
||||
Issues::add( 'error', 'Well, this is embarrassing, surely he wouldn\'t just have no wip..... right.... Dave? ... erm Joey?' );
|
||||
return;
|
||||
} else {
|
||||
Views::view( 'wip.wip', self::$projects->listPaginated() );
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user