plugin wip
This commit is contained in:
@ -51,17 +51,24 @@ class Suggestions extends Controller {
|
||||
Issues::add( 'error', 'Suggestion not found.' );
|
||||
return $this->index();
|
||||
}
|
||||
if ( empty( self::$comments ) ) {
|
||||
self::$comments = new CommentsModel;
|
||||
}
|
||||
|
||||
if ( Input::exists( 'contentId' ) ) {
|
||||
$this->comments( 'post', Input::post( 'contentId' ) );
|
||||
}
|
||||
|
||||
Components::set( 'CONTENT_ID', $id );
|
||||
Components::set( 'COMMENT_TYPE', 'suggestions' );
|
||||
Components::set( 'NEWCOMMENT', Views::simpleView( 'comments.create' ) );
|
||||
Components::set( 'count', self::$comments->count( 'suggestion', $id ) );
|
||||
Components::set( 'COMMENTS', Views::simpleView( 'comments.list', self::$comments->display( 10, self::$suggestions->tableName, $id ) ) );
|
||||
$plugin = new Comments;
|
||||
if ( ! $plugin->checkEnabled() ) {
|
||||
Components::set( 'NEWCOMMENT', '' );
|
||||
Components::set( 'count', '' );
|
||||
Components::set( 'COMMENTS', '' );
|
||||
} else {
|
||||
$comments = new CommentsModel;
|
||||
Components::set( 'count', $comments->count( 'suggestion', $id ) );
|
||||
Components::set( 'COMMENTS', Views::simpleView( 'comments.list', $comments->display( 10, self::$suggestions->tableName, $id ) ) );
|
||||
Components::set( 'NEWCOMMENT', Views::simpleView( 'comments.create' ) );
|
||||
}
|
||||
Views::view( 'suggestions.view', $data );
|
||||
}
|
||||
|
||||
@ -98,36 +105,40 @@ class Suggestions extends Controller {
|
||||
}
|
||||
|
||||
public function comments( $sub = null, $data = null ) {
|
||||
if ( empty( self::$comments ) ) {
|
||||
self::$comments = new CommentsModel;
|
||||
}
|
||||
$commentsPlugin = new Comments;
|
||||
if ( empty( $sub ) || empty( $data ) ) {
|
||||
Session::flash( 'error', 'Whoops, try again.' );
|
||||
Redirect::to( 'suggestions' );
|
||||
Issues::add( 'error', 'There was an issue with your request. Please check the url and try again.' );
|
||||
return $this->index();
|
||||
}
|
||||
|
||||
$plugin = new Comments;
|
||||
if ( ! $plugin->checkEnabled() ) {
|
||||
Issues::add( 'error', 'Comments are disabled.' );
|
||||
return $this->index();
|
||||
}
|
||||
|
||||
switch ( $sub ) {
|
||||
case 'post':
|
||||
$content = self::$suggestions->findById( $data );
|
||||
if ( empty( $content ) ) {
|
||||
Session::flash( 'error', 'Unknown Content.' );
|
||||
Redirect::to( 'suggestions' );
|
||||
Issues::add( 'error', 'Unknown Content.' );
|
||||
return $this->index();
|
||||
}
|
||||
return $commentsPlugin->formPost( self::$suggestions->tableName, $content, 'suggestions/view/' );
|
||||
Redirect::to( 'suggestions' );
|
||||
return $plugin->formPost( self::$suggestions->tableName, $content, 'suggestions/view/' );
|
||||
case 'edit':
|
||||
$content = self::$comments->findById( $data );
|
||||
if ( empty( $content ) ) {
|
||||
Session::flash( 'error', 'Unknown Comment.' );
|
||||
Redirect::to( 'suggestions' );
|
||||
Issues::add( 'error', 'Unknown Comment.' );
|
||||
return $this->index();
|
||||
}
|
||||
return $commentsPlugin->formEdit( self::$suggestions->tableName, $content, 'suggestions/view/' );
|
||||
return $plugin->formEdit( self::$suggestions->tableName, $content, 'suggestions/view/' );
|
||||
case 'delete':
|
||||
$content = self::$comments->findById( $data );
|
||||
if ( empty( $content ) ) {
|
||||
Session::flash( 'error', 'Unknown Comment.' );
|
||||
Redirect::to( 'suggestions' );
|
||||
Issues::add( 'error', 'Unknown Comment.' );
|
||||
return $this->index();
|
||||
}
|
||||
return $commentsPlugin->formDelete( self::$suggestions->tableName, $content, 'suggestions/view/' );
|
||||
return $plugin->formDelete( self::$suggestions->tableName, $content, 'suggestions/view/' );
|
||||
}
|
||||
}
|
||||
}
|
@ -1,22 +1,38 @@
|
||||
<form action="" method="post" class="form-horizontal">
|
||||
<div class="form-group">
|
||||
<div class="col-lg-4 col-lg-offset-4">
|
||||
<label for="title" class="col-lg-3 control-label">Title</label>
|
||||
<input type="text" class="form-check-input" name="title" id="title" value="{title}">
|
||||
</div>
|
||||
<div class="mb-4 mt-4">
|
||||
<div class="offset-md-1 col-10 py-3 context-main-bg">
|
||||
<legend class="text-center">Edit Suggestion</legend>
|
||||
<hr>
|
||||
<form action="" method="post" class="container py-4">
|
||||
<fieldset>
|
||||
<div class="mb-3 row">
|
||||
<label for="title" class="col-lg-5 col-form-label text-end">Title</label>
|
||||
<div class="col-lg-3">
|
||||
<input type="text" class="form-control" name="title" id="title" value="{title}" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3 row">
|
||||
<label for="approved" class="col-lg-5 col-form-label text-end">Approved</label>
|
||||
<div class="col-lg-3">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="approved" value="true" name="approved">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3 row">
|
||||
<label for="suggestion" class="col-lg-5 col-form-label text-end">Suggestion:</label>
|
||||
<div class="col-lg-3">
|
||||
<textarea class="form-control" name="suggestion" maxlength="2000" rows="5" cols="50" id="suggestion">{suggestion}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hidden Token -->
|
||||
<input type="hidden" name="token" value="{TOKEN}">
|
||||
|
||||
<!-- Submit Button -->
|
||||
<div class="text-center">
|
||||
<button type="submit" name="submit" value="submit" class="btn btn-primary btn-lg">Save</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-lg-4 col-lg-offset-4">
|
||||
<label for="suggestion">Suggestion</label>
|
||||
<textarea class="form-control" name="suggestion" maxlength="2000" rows="10" cols="50" id="suggestion">{suggestion}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-lg-4 col-lg-offset-4">
|
||||
<input class="" type="checkbox" name="approved" id="approved" value="true" {CHECKED:approved=true}>
|
||||
<label for="approved">Approved (Publicly available)?</label>
|
||||
</div>
|
||||
</div>
|
||||
<button name="submit" value="submit" type="submit" class="btn btn-lg btn-primary center-block">Save</button>
|
||||
<input type="hidden" name="token" value="{TOKEN}">
|
||||
</form>
|
||||
</div>
|
@ -1,56 +1,59 @@
|
||||
<legend>Suggestions</legend>
|
||||
{PAGINATION}
|
||||
<form action="{ROOT_URL}admin/suggestions/delete" method="post">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 5%">ID</th>
|
||||
<th style="width: 30%">Suggestion</th>
|
||||
<th style="width: 10%">Suggested On</th>
|
||||
<th style="width: 10%">Suggested By</th>
|
||||
<th style="width: 10%">Approved</th>
|
||||
<th style="width: 10%">Approved On</th>
|
||||
<th style="width: 10%">Approved By</th>
|
||||
<th style="width: 5%"></th>
|
||||
<th style="width: 5%"></th>
|
||||
<th style="width: 5%">
|
||||
<INPUT type="checkbox" onchange="checkAll(this)" name="check.br" value="S_[]"/>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{LOOP}
|
||||
<tr>
|
||||
<td align="center">{ID}</td>
|
||||
<td>{suggestion}</td>
|
||||
<td align="center">{DTC}{suggestedOn}{/DTC}</td>
|
||||
<td align="center">{submittedBy}</td>
|
||||
<td>{approved}</td>
|
||||
<td align="center">{DTC}{approvedOn}{/DTC}</td>
|
||||
<td align="center">{approvedByName}</td>
|
||||
<td>
|
||||
<a href="{ROOT_URL}admin/suggestions/approve/{ID}" class="btn btn-sm btn-success" role="button"><i class="fa fa-fw fa-check"></i></a>
|
||||
<a href="{ROOT_URL}admin/suggestions/reject/{ID}" class="btn btn-sm btn-danger" role="button"><i class="fa fa-fw fa-close"></i></a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="{ROOT_URL}admin/suggestions/view/{ID}" class="btn btn-sm btn-primary" role="button"><i class="fa fa-fw fa-upload"></i></a>
|
||||
<a href="{ROOT_URL}admin/suggestions/delete/{ID}" class="btn btn-sm btn-danger" role="button"><i class="fa fa-fw fa-trash"></i></a>
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" value="{ID}" name="BR_[]">
|
||||
</td>
|
||||
</tr>
|
||||
{/LOOP}
|
||||
{ALT}
|
||||
<tr>
|
||||
<td align="center" colspan="6">
|
||||
No results to show.
|
||||
</td>
|
||||
</tr>
|
||||
{/ALT}
|
||||
</tbody>
|
||||
</table>
|
||||
<button name="submit" value="submit" type="submit" class="btn btn-sm btn-danger">Delete</button>
|
||||
</form>
|
||||
<br />
|
||||
<a href="{ROOT_URL}admin/suggestions/clear">clear all</a>
|
||||
<div class="context-main-bg context-main p-3">
|
||||
<legend class="text-center">Suggestions</legend>
|
||||
<hr>
|
||||
{ADMIN_BREADCRUMBS}
|
||||
<form action="{ROOT_URL}admin/suggestions/delete" method="post">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 5%">ID</th>
|
||||
<th style="width: 30%">Suggestion</th>
|
||||
<th style="width: 10%">Suggested On</th>
|
||||
<th style="width: 10%">Suggested By</th>
|
||||
<th style="width: 10%">Approved</th>
|
||||
<th style="width: 10%">Approved On</th>
|
||||
<th style="width: 10%">Approved By</th>
|
||||
<th style="width: 5%"></th>
|
||||
<th style="width: 5%"></th>
|
||||
<th style="width: 5%">
|
||||
<INPUT type="checkbox" onchange="checkAll(this)" name="check.br" value="S_[]"/>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{LOOP}
|
||||
<tr>
|
||||
<td align="center">{ID}</td>
|
||||
<td>{suggestion}</td>
|
||||
<td align="center">{DTC}{suggestedOn}{/DTC}</td>
|
||||
<td align="center">{submittedBy}</td>
|
||||
<td>{approved}</td>
|
||||
<td align="center">{DTC}{approvedOn}{/DTC}</td>
|
||||
<td align="center">{approvedByName}</td>
|
||||
<td>
|
||||
<a href="{ROOT_URL}admin/suggestions/approve/{ID}" class="btn btn-sm btn-success" role="button"><i class="fa fa-fw fa-check"></i></a>
|
||||
<a href="{ROOT_URL}admin/suggestions/reject/{ID}" class="btn btn-sm btn-danger" role="button"><i class="fa fa-fw fa-close"></i></a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="{ROOT_URL}admin/suggestions/view/{ID}" class="btn btn-sm btn-primary" role="button"><i class="fa fa-fw fa-upload"></i></a>
|
||||
<a href="{ROOT_URL}admin/suggestions/delete/{ID}" class="btn btn-sm btn-danger" role="button"><i class="fa fa-fw fa-trash"></i></a>
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" value="{ID}" name="BR_[]">
|
||||
</td>
|
||||
</tr>
|
||||
{/LOOP}
|
||||
{ALT}
|
||||
<tr>
|
||||
<td align="center" colspan="6">
|
||||
No results to show.
|
||||
</td>
|
||||
</tr>
|
||||
{/ALT}
|
||||
</tbody>
|
||||
</table>
|
||||
<button name="submit" value="submit" type="submit" class="btn btn-sm btn-danger"><i class="fa fa-fw fa-trash"></i></button>
|
||||
</form>
|
||||
<br />
|
||||
<a href="{ROOT_URL}admin/suggestions/clear">clear all</a>
|
||||
</div>
|
@ -1,17 +1,14 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-sm-12 blog-main">
|
||||
<div class="blog-post">
|
||||
<h2 class="blog-post-title">Suggestion</h2>
|
||||
<hr>
|
||||
<p class="blog-post-meta">{DTC date}{suggestedOn}{/DTC} by <a href="{ROOT_URL}home/profile/{author}">{submittedBy}</a></p>
|
||||
{suggestion}
|
||||
{ADMIN}
|
||||
<hr>
|
||||
<a href="{ROOT_URL}admin/suggestions/delete/{ID}" class="btn btn-md btn-danger" role="button">Delete</a>
|
||||
<a href="{ROOT_URL}admin/suggestions/edit/{ID}" class="btn btn-md btn-warning" role="button">Edit</a>
|
||||
<hr>
|
||||
{/ADMIN}
|
||||
</div><!-- /.suggestions-post -->
|
||||
{COMMENTS}
|
||||
</div><!-- /.suggestions-main -->
|
||||
</div><!-- /.row -->
|
||||
<div class="context-main-bg context-main p-3">
|
||||
<legend class="text-center">Suggestion: {title}</legend>
|
||||
<hr>
|
||||
{ADMIN_BREADCRUMBS}
|
||||
<p class="blog-post-meta">{DTC date}{suggestedOn}{/DTC} by <a href="{ROOT_URL}admin/users/view/{author}">{submittedBy}</a></p>
|
||||
{suggestion}
|
||||
{ADMIN}
|
||||
<hr>
|
||||
<a href="{ROOT_URL}admin/suggestions/edit/{ID}" class="btn btn-md btn-warning" role="button"><i class="fa fa-fw fa-pencil"></i></a>
|
||||
<a href="{ROOT_URL}admin/suggestions/delete/{ID}" class="btn btn-md btn-danger" role="button"><i class="fa fa-fw fa-trash"></i></a>
|
||||
<hr>
|
||||
{/ADMIN}
|
||||
{COMMENTS}
|
||||
</div>
|
@ -8,8 +8,8 @@
|
||||
{suggestion}
|
||||
{ADMIN}
|
||||
<hr>
|
||||
<a href="{ROOT_URL}admin/suggestions/delete/{ID}" class="btn btn-md btn-danger" role="button">Delete</a>
|
||||
<a href="{ROOT_URL}admin/suggestions/edit/{ID}" class="btn btn-md btn-warning" role="button">Edit</a>
|
||||
<a href="{ROOT_URL}admin/suggestions/edit/{ID}" class="btn btn-md btn-warning" role="button"><i class="fa fa-fw fa-pencil"></i></a>
|
||||
<a href="{ROOT_URL}admin/suggestions/delete/{ID}" class="btn btn-md btn-danger" role="button"><i class="fa fa-fw fa-trash"></i></a>
|
||||
<hr>
|
||||
{/ADMIN}
|
||||
</div><!-- /.suggestions-post -->
|
||||
|
Reference in New Issue
Block a user