Merge branch 'refs/heads/develop'

This commit is contained in:
snipe
2013-11-20 05:08:41 -05:00
11 changed files with 75 additions and 561 deletions
-110
View File
@@ -1,110 +0,0 @@
<?php
class BlogController extends BaseController {
/**
* Returns all the blog posts.
*
* @return View
*/
public function getIndex()
{
// Get all the blog posts
$posts = Post::with(array(
'author' => function($query)
{
$query->withTrashed();
},
))->orderBy('created_at', 'DESC')->paginate();
// Show the page
return View::make('frontend/blog/index', compact('posts'));
}
/**
* View a blog post.
*
* @param string $slug
* @return View
* @throws NotFoundHttpException
*/
public function getView($slug)
{
// Get this blog post data
$post = Post::with(array(
'author' => function($query)
{
$query->withTrashed();
},
'comments',
))->where('slug', $slug)->first();
// Check if the blog post exists
if (is_null($post))
{
// If we ended up in here, it means that a page or a blog post
// don't exist. So, this means that it is time for 404 error page.
return App::abort(404);
}
// Get this post comments
$comments = $post->comments()->with(array(
'author' => function($query)
{
$query->withTrashed();
},
))->orderBy('created_at', 'DESC')->get();
// Show the page
return View::make('frontend/blog/view-post', compact('post', 'comments'));
}
/**
* View a blog post.
*
* @param string $slug
* @return Redirect
*/
public function postView($slug)
{
// The user needs to be logged in, make that check please
if ( ! Sentry::check())
{
return Redirect::to("blog/$slug#comments")->with('error', 'You need to be logged in to post comments!');
}
// Get this blog post data
$post = Post::where('slug', $slug)->first();
// Declare the rules for the form validation
$rules = array(
'comment' => 'required|min:3',
);
// Create a new validator instance from our dynamic rules
$validator = Validator::make(Input::all(), $rules);
// If validation fails, we'll exit the operation now
if ($validator->fails())
{
// Redirect to this blog post page
return Redirect::to("blog/$slug#comments")->withInput()->withErrors($validator);
}
// Save the comment
$comment = new Comment;
$comment->user_id = Sentry::getUser()->id;
$comment->content = e(Input::get('comment'));
// Was the comment saved with success?
if($post->comments()->save($comment))
{
// Redirect to this blog post page
return Redirect::to("blog/$slug#comments")->with('success', 'Your comment was successfully added.');
}
// Redirect to this blog post page
return Redirect::to("blog/$slug#comments")->with('error', 'There was a problem adding your comment, please try again.');
}
}
-177
View File
@@ -1,177 +0,0 @@
<?php namespace Controllers\Admin;
use AdminController;
use Input;
use Lang;
use Post;
use Redirect;
use Sentry;
use Str;
use Validator;
use View;
class BlogsController extends AdminController {
/**
* Show a list of all the blog posts.
*
* @return View
*/
public function getIndex()
{
// Grab all the blog posts
$posts = Post::orderBy('created_at', 'DESC')->paginate(10);
// Show the page
return View::make('backend/blogs/index', compact('posts'));
}
/**
* Blog post create.
*
* @return View
*/
public function getCreate()
{
// Show the page
return View::make('backend/blogs/create');
}
/**
* Blog post create form processing.
*
* @return Redirect
*/
public function postCreate()
{
// Declare the rules for the form validation
$rules = array(
'title' => 'required|min:3',
'content' => 'required|min:3',
);
// Create a new validator instance from our validation rules
$validator = Validator::make(Input::all(), $rules);
// If validation fails, we'll exit the operation now.
if ($validator->fails())
{
// Ooops.. something went wrong
return Redirect::back()->withInput()->withErrors($validator);
}
// Create a new blog post
$post = new Post;
// Update the blog post data
$post->title = e(Input::get('title'));
$post->slug = e(Str::slug(Input::get('title')));
$post->content = e(Input::get('content'));
$post->meta_title = e(Input::get('meta-title'));
$post->meta_description = e(Input::get('meta-description'));
$post->meta_keywords = e(Input::get('meta-keywords'));
$post->user_id = Sentry::getId();
// Was the blog post created?
if($post->save())
{
// Redirect to the new blog post page
return Redirect::to("admin/blogs/$post->id/edit")->with('success', Lang::get('admin/blogs/message.create.success'));
}
// Redirect to the blog post create page
return Redirect::to('admin/blogs/create')->with('error', Lang::get('admin/blogs/message.create.error'));
}
/**
* Blog post update.
*
* @param int $postId
* @return View
*/
public function getEdit($postId = null)
{
// Check if the blog post exists
if (is_null($post = Post::find($postId)))
{
// Redirect to the blogs management page
return Redirect::to('admin/blogs')->with('error', Lang::get('admin/blogs/message.does_not_exist'));
}
// Show the page
return View::make('backend/blogs/edit', compact('post'));
}
/**
* Blog Post update form processing page.
*
* @param int $postId
* @return Redirect
*/
public function postEdit($postId = null)
{
// Check if the blog post exists
if (is_null($post = Post::find($postId)))
{
// Redirect to the blogs management page
return Redirect::to('admin/blogs')->with('error', Lang::get('admin/blogs/message.does_not_exist'));
}
// Declare the rules for the form validation
$rules = array(
'title' => 'required|min:3',
'content' => 'required|min:3',
);
// Create a new validator instance from our validation rules
$validator = Validator::make(Input::all(), $rules);
// If validation fails, we'll exit the operation now.
if ($validator->fails())
{
// Ooops.. something went wrong
return Redirect::back()->withInput()->withErrors($validator);
}
// Update the blog post data
$post->title = e(Input::get('title'));
$post->slug = e(Str::slug(Input::get('title')));
$post->content = e(Input::get('content'));
$post->meta_title = e(Input::get('meta-title'));
$post->meta_description = e(Input::get('meta-description'));
$post->meta_keywords = e(Input::get('meta-keywords'));
// Was the blog post updated?
if($post->save())
{
// Redirect to the new blog post page
return Redirect::to("admin/blogs/$postId/edit")->with('success', Lang::get('admin/blogs/message.update.success'));
}
// Redirect to the blogs post management page
return Redirect::to("admin/blogs/$postId/edit")->with('error', Lang::get('admin/blogs/message.update.error'));
}
/**
* Delete the given blog post.
*
* @param int $postId
* @return Redirect
*/
public function getDelete($postId)
{
// Check if the blog post exists
if (is_null($post = Post::find($postId)))
{
// Redirect to the blogs management page
return Redirect::to('admin/blogs')->with('error', Lang::get('admin/blogs/message.not_found'));
}
// Delete the blog post
$post->delete();
// Redirect to the blog posts management page
return Redirect::to('admin/blogs')->with('success', Lang::get('admin/blogs/message.delete.success'));
}
}
-22
View File
@@ -1,22 +0,0 @@
<?php
return array(
'does_not_exist' => 'Blog post does not exist.',
'create' => array(
'error' => 'Blog post was not created, please try again.',
'success' => 'Blog post created successfully.'
),
'update' => array(
'error' => 'Blog post was not updated, please try again',
'success' => 'Blog post updated successfully.'
),
'delete' => array(
'error' => 'There was an issue deleting the blog post. Please try again.',
'success' => 'The blog post was deleted successfully.'
)
);
-9
View File
@@ -1,9 +0,0 @@
<?php
return array(
'title' => 'Blog Title',
'comments' => '# of Comments',
'created_at' => 'Created at',
);
+24
View File
@@ -74,6 +74,30 @@ class Asset extends Elegant {
return $this->belongsTo('User','id');
}
/**
* Get total assets
*/
public static function assetcount()
{
return DB::table('assets')
->where('physical', '=', '1')
->whereNull('deleted_at','and')
->count();
}
/**
* Get total assets not checked out
*/
public static function availassetcount()
{
return DB::table('assets')
->where('physical', '=', '1')
->where('assigned_to', '=', '0')
->whereNull('deleted_at','and')
->count();
}
}
+25
View File
@@ -45,5 +45,30 @@ class License extends Elegant {
return $this->belongsTo('User','id');
}
/**
* Get total licenses
*/
public static function assetcount()
{
return DB::table('assets')
->where('physical', '=', '0')
->whereNull('deleted_at','and')
->count();
}
/**
* Get total licenses not checked out
*/
public static function availassetcount()
{
return DB::table('assets')
->where('physical', '=', '0')
->where('assigned_to', '=', '0')
->whereNull('deleted_at','and')
->count();
}
}
-73
View File
@@ -1,73 +0,0 @@
<?php
class Post extends Eloquent {
/**
* Deletes a blog post and all the associated comments.
*
* @return bool
*/
public function delete()
{
// Delete the comments
$this->comments()->delete();
// Delete the blog post
return parent::delete();
}
/**
* Returns a formatted post content entry, this ensures that
* line breaks are returned.
*
* @return string
*/
public function content()
{
return nl2br($this->content);
}
/**
* Return the post's author.
*
* @return User
*/
public function author()
{
return $this->belongsTo('User', 'user_id');
}
/**
* Return how many comments this post has.
*
* @return array
*/
public function comments()
{
return $this->hasMany('Comment');
}
/**
* Return the URL to the post.
*
* @return string
*/
public function url()
{
return URL::route('view-post', $this->slug);
}
/**
* Return the post thumbnail image url.
*
* @return string
*/
public function thumbnail()
{
# you should save the image url on the database
# and return that url here.
return 'http://lorempixel.com/130/90/business/';
}
}
-109
View File
@@ -1,109 +0,0 @@
@extends('backend/layouts/default')
{{-- Page title --}}
@section('title')
Blog Post Update ::
@parent
@stop
{{-- Page content --}}
@section('content')
<div class="page-header">
<h3>
Blog Post Update
<div class="pull-right">
<a href="{{ route('blogs') }}" class="btn btn-small btn-inverse"><i class="icon-circle-arrow-left icon-white"></i> Back</a>
</div>
</h3>
</div>
<!-- Tabs -->
<ul class="nav nav-tabs">
<li class="active"><a href="#tab-general" data-toggle="tab">General</a></li>
<li><a href="#tab-meta-data" data-toggle="tab">Meta Data</a></li>
</ul>
<form class="form-horizontal" method="post" action="" autocomplete="off">
<!-- CSRF Token -->
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
<!-- Tabs Content -->
<div class="tab-content">
<!-- General tab -->
<div class="tab-pane active" id="tab-general">
<!-- Post Title -->
<div class="control-group {{ $errors->has('title') ? 'error' : '' }}">
<label class="control-label" for="title">Post Title</label>
<div class="controls">
<input type="text" name="title" id="title" value="{{ Input::old('title', $post->title) }}" />
{{ $errors->first('title', '<span class="help-inline">:message</span>') }}
</div>
</div>
<!-- Post Slug -->
<div class="control-group">
<label class="control-label" for="slug">Slug</label>
<div class="controls">
<div class="input-prepend">
<span class="add-on">
{{ str_finish(URL::to('/'), '/') }}
</span>
<input class="span6" type="text" name="slug" id="slug" value="{{ Input::old('slug', $post->slug) }}">
</div>
</div>
</div>
<!-- Content -->
<div class="control-group {{ $errors->has('content') ? 'error' : '' }}">
<label class="control-label" for="content">Content</label>
<div class="controls">
<textarea class="span10" name="content" value="content" rows="10">{{ Input::old('content', $post->content) }}</textarea>
{{ $errors->first('content', '<span class="help-inline">:message</span>') }}
</div>
</div>
</div>
<!-- Meta Data tab -->
<div class="tab-pane" id="tab-meta-data">
<!-- Meta Title -->
<div class="control-group {{ $errors->has('meta-title') ? 'error' : '' }}">
<label class="control-label" for="meta-title">Meta Title</label>
<div class="controls">
<input class="span10" type="text" name="meta-title" id="meta-title" value="{{ Input::old('meta-title', $post->meta_title) }}" />
{{ $errors->first('meta-title', '<span class="help-inline">:message</span>') }}
</div>
</div>
<!-- Meta Description -->
<div class="control-group {{ $errors->has('meta-description') ? 'error' : '' }}">
<label class="control-label" for="meta-description">Meta Description</label>
<div class="controls">
<input class="span10" type="text" name="meta-description" id="meta-description" value="{{ Input::old('meta-description', $post->meta_description) }}" />
{{ $errors->first('meta-description', '<span class="help-inline">:message</span>') }}
</div>
</div>
<!-- Meta Keywords -->
<div class="control-group {{ $errors->has('meta-keywords') ? 'error' : '' }}">
<label class="control-label" for="meta-keywords">Meta Keywords</label>
<div class="controls">
<input class="span10" type="text" name="meta-keywords" id="meta-keywords" value="{{ Input::old('meta-keywords', $post->meta_keywords) }}" />
{{ $errors->first('meta-keywords', '<span class="help-inline">:message</span>') }}
</div>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="control-group">
<div class="controls">
<a class="btn btn-link" href="{{ route('blogs') }}">Cancel</a>
<button type="reset" class="btn">Reset</button>
<button type="submit" class="btn btn-success">Publish</button>
</div>
</div>
</form>
@stop
-48
View File
@@ -1,48 +0,0 @@
@extends('backend/layouts/default')
{{-- Page title --}}
@section('title')
Blog Management ::
@parent
@stop
{{-- Page content --}}
@section('content')
<div class="page-header">
<h3>
Blog Management
<div class="pull-right">
<a href="{{ route('create/blog') }}" class="btn btn-small btn-info"><i class="icon-plus-sign icon-white"></i> Create</a>
</div>
</h3>
</div>
{{ $posts->links() }}
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th class="span6">@lang('admin/blogs/table.title')</th>
<th class="span2">@lang('admin/blogs/table.comments')</th>
<th class="span2">@lang('admin/blogs/table.created_at')</th>
<th class="span2">@lang('table.actions')</th>
</tr>
</thead>
<tbody>
@foreach ($posts as $post)
<tr>
<td>{{ $post->title }}</td>
<td>{{ $post->comments()->count() }}</td>
<td>{{ $post->created_at->diffForHumans() }}</td>
<td>
<a href="{{ route('update/blog', $post->id) }}" class="btn btn-mini">@lang('button.edit')</a>
<a href="{{ route('delete/blog', $post->id) }}" class="btn btn-mini btn-danger">@lang('button.delete')</a>
</td>
</tr>
@endforeach
</tbody>
</table>
{{ $posts->links() }}
@stop
+22 -13
View File
@@ -116,7 +116,11 @@
<i class="icon-wrench icon-white"></i> Admin <span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li{{ (Request::is('admin/groups*') ? ' class="active"' : '') }}><a href="{{ URL::to('admin/groups') }}"><i class="icon-group"></i> Groups</a></li>
<li{{ (Request::is('admin/groups*') ? ' class="active"' : '') }}>
<a href="{{ URL::to('admin/groups') }}">
<i class="icon-group"></i> Groups
</a>
</li>
<li{{ (Request::is('admin/settings/manufacturers*') ? ' class="active"' : '') }}>
<a href="{{ URL::to('admin/settings/manufacturers') }}">
<i class="icon-briefcase"></i> Manufacturers
@@ -202,31 +206,36 @@
<div class="row-fluid stats-row">
<div class="span3 stat">
<div class="data">
<span class="number">2,457</span>
assets
<a href="{{ URL::to('admin') }}">
<span class="number">{{ number_format(Asset::assetcount()) }}</span>
<span style="color:black">total assets</span>
</a>
</div>
<span class="date">(placeholder)</span>
</div>
<div class="span3 stat">
<div class="data">
<span class="number">240</span>
licenses
<a href="{{ URL::to('admin') }}">
<span class="number">{{ number_format(Asset::availassetcount()) }}</span>
<span style="color:black">assets available</span>
</a>
</div>
<span class="date">(placeholder)</span>
</div>
<div class="span3 stat">
<div class="data">
<span class="number">36</span>
assets available
<a href="{{ URL::to('admin/licenses') }}">
<span class="number">{{ number_format(License::assetcount()) }}</span>
<span style="color:black">total licenses</span>
</a>
</div>
<span class="date">(placeholder)</span>
</div>
<div class="span3 stat last">
<div class="data">
<span class="number">89</span>
people
<a href="{{ URL::to('admin/licenses') }}">
<span class="number">{{ number_format(License::availassetcount()) }}</span>
<span style="color:black">licenses available</span>
</a>
</div>
<span class="date">(placeholder)</span>
</div>
</div>
</div>
+4
View File
@@ -40,6 +40,10 @@
right: 50px;
}
#main-stats a:hover {
text-decoration: none;
}
.section {
border-top: 1px solid #edeff1;
margin-top: 100px;