Skip to content
This repository has been archived by the owner on Mar 21, 2018. It is now read-only.

Commit

Permalink
More coding style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Dec 15, 2013
1 parent 7c1d11d commit f3fc2e8
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 43 deletions.
12 changes: 6 additions & 6 deletions src/Kmd/Logviewer/Logviewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use ReflectionClass;

class Logviewer
{
{
public $path;
public $sapi;
public $date;
Expand Down Expand Up @@ -58,7 +58,7 @@ public function log()

$log_levels = $this->getLevels();

$log_file = glob($this->path . '/log-' . $this->sapi . '*-' . $this->date . '.txt');
$log_file = glob($this->path.'/log-'.$this->sapi.'*-'.$this->date.'.txt');

if (!empty($log_file)) {
$this->empty = false;
Expand All @@ -76,8 +76,8 @@ public function log()
foreach ($headings as $h) {
for ($i=0, $j = count($h); $i < $j; $i++) {
foreach ($log_levels as $ll) {
if ($this->level == $ll OR $this->level == 'all') {
if (strpos(strtolower($h[$i]), strtolower('.' . $ll))) {
if ($this->level == $ll || $this->level == 'all') {
if (strpos(strtolower($h[$i]), strtolower('.'.$ll))) {
$log[] = array('level' => $ll, 'header' => $h[$i], 'stack' => $log_data[$i]);
}
}
Expand All @@ -89,7 +89,7 @@ public function log()
unset($headings);
unset($log_data);

if(strtolower(Config::get('logviewer::log_order')) == "desc"){
if (strtolower(Config::get('logviewer::log_order')) == 'desc'){
$log = array_reverse($log);
}

Expand All @@ -104,7 +104,7 @@ public function log()
*/
public function delete()
{
$log_file = glob($this->path . '/log-' . $this->sapi . '*-' . $this->date . '.txt');
$log_file = glob($this->path.'/log-'.$this->sapi.'*-'.$this->date.'.txt');

if (!empty($log_file)) {
return File::delete($log_file[0]);
Expand Down
9 changes: 4 additions & 5 deletions src/Kmd/Logviewer/LogviewerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public function boot()
{
$this->package('kmd/logviewer');

include __DIR__ . '/../../routes.php';
include __DIR__ . '/../../filters.php';
include __DIR__ . '/../../macros.php';
include __DIR__.'/../../routes.php';
include __DIR__.'/../../filters.php';
include __DIR__.'/../../macros.php';
}

/**
Expand All @@ -35,8 +35,7 @@ public function boot()
*/
public function register()
{
$this->app['logviewer'] = $this->app->share(function ($app)
{
$this->app['logviewer'] = $this->app->share(function ($app) {
return new Logviewer;
});
}
Expand Down
30 changes: 10 additions & 20 deletions src/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,23 @@
Route::filter('logviewer.logs', function ()
{
$logs = array();
if( ! Lang::has('logviewer::logviewer.sapi')){
if (!Lang::has('logviewer::logviewer.sapi')) {
App::setLocale('en');
}
foreach (Lang::get('logviewer::logviewer.sapi') as $sapi => $human)
{
foreach (Lang::get('logviewer::logviewer.sapi') as $sapi => $human) {
$logs[$sapi]['sapi'] = $human;
$dirs = Config::get('logviewer::log_dirs');

$files = array();

foreach ($dirs as $app => $dir)
{
$files[$app] = glob($dir . '/log-' . $sapi . '*', GLOB_BRACE);
if (is_array($files[$app]))
{
foreach ($dirs as $app => $dir) {
$files[$app] = glob($dir.'/log-'.$sapi.'*', GLOB_BRACE);
if (is_array($files[$app])) {
$files[$app] = array_reverse($files[$app]);
foreach ($files[$app] as &$file)
{
foreach ($files[$app] as &$file) {
$file = preg_replace('/.*(\d{4}-\d{2}-\d{2}).*/', '$1', basename($file));
}
}
else
{
} else {
$files[$app] = array();
}
}
Expand All @@ -36,14 +30,10 @@
View::share('logs', $logs);
});

Route::filter('logviewer.messages', function ()
{
if (Session::has('success') OR Session::has('error') OR Session::has('info'))
{
Route::filter('logviewer.messages', function () {
if (Session::has('success') OR Session::has('error') OR Session::has('info')) {
View::share('has_messages', true);
}
else
{
} else {
View::share('has_messages', false);
}
});
6 changes: 3 additions & 3 deletions src/macros.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
$href = HTML::link($url, $text, $a_attr);
$response = '';

if( Request::is($url) || Request::is($url . '/*')) {
if (Request::is($url) || Request::is($url.'/*')) {
if (isset($li_attrs['class'])) {
$li_attrs['class'] .= ' ' . $active_class;
$li_attrs['class'] .= ' '.$active_class;
} else {
$li_attrs['class'] = $active_class;
}
}

return '<li ' . HTML::attributes($li_attrs) . '>' . $href . '</li>';
return '<li '.HTML::attributes($li_attrs).'>'.$href.'</li>';
});
8 changes: 4 additions & 4 deletions src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
Session::reflash();
}

return Redirect::to(Config::get('logviewer::base_url') . '/' . $path . '/' . $sapi . '/' . $today . '/all');
return Redirect::to(Config::get('logviewer::base_url').'/'.$path.'/'.$sapi.'/'.$today.'/all');
});

$filters = Config::get('logviewer::filters.delete');
Expand All @@ -70,10 +70,10 @@

if ($logviewer->delete()) {
$today = Carbon::today()->format('Y-m-d');
return Redirect::to(Config::get('logviewer::base_url') . '/' . $path . '/' . $sapi . '/' . $today .'/all')
return Redirect::to(Config::get('logviewer::base_url').'/'.$path.'/'.$sapi.'/'.$today.'/all')
->with('success', Lang::get('logviewer::logviewer.delete.success'));
} else {
return Redirect::to(Config::get('logviewer::base_url') . '/' . $path . '/' . $sapi . '/' . $date . '/all')
return Redirect::to(Config::get('logviewer::base_url').'/'.$path.'/'.$sapi.'/'.$date.'/all')
->with('error', Lang::get('logviewer::logviewer.delete.error'));
}
});
Expand Down Expand Up @@ -134,7 +134,7 @@
->with('log', (count($log) > $page->getPerPage() ? array_slice($log, $page->getFrom()-1, $page->getPerPage()) : $log))
->with('empty', $logviewer->isEmpty())
->with('date', $date)
->with('sapi', Lang::get('logviewer::logviewer.sapi.' . $sapi))
->with('sapi', Lang::get('logviewer::logviewer.sapi.'.$sapi))
->with('sapi_plain', $sapi)
->with('url', Config::get('logviewer::base_url'))
->with('levels', $levels)
Expand Down
10 changes: 5 additions & 5 deletions src/views/viewer.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
<div class="container-fluid">
{{ HTML::link($url, Lang::get('logviewer::logviewer.title'), array('class' => 'brand')) }}
<ul class="nav">
{{ HTML::nav_item($url . '/' . $path . '/' . $sapi_plain . '/' . $date . '/all', ucfirst(Lang::get('logviewer::logviewer.levels.all'))) }}
{{ HTML::nav_item($url.'/'.$path.'/'.$sapi_plain.'/'.$date.'/all', ucfirst(Lang::get('logviewer::logviewer.levels.all'))) }}
@foreach ($levels as $level)
{{ HTML::nav_item($url . '/' . $path . '/' . $sapi_plain . '/' . $date . '/' . $level, ucfirst(Lang::get('logviewer::logviewer.levels.' . $level))) }}
{{ HTML::nav_item($url.'/'.$path.'/'.$sapi_plain.'/'.$date.'/'.$level, ucfirst(Lang::get('logviewer::logviewer.levels.'.$level))) }}
@endforeach
</ul>
@if ( ! $empty)
Expand All @@ -62,10 +62,10 @@
<?php $count = count($files['logs']) ?>
@foreach ($files['logs'] as $app => $file)
@if ( ! empty($file))
<li class="nav-header">{{ ($count > 1 ? $app . ' - ' . $files['sapi'] : $files['sapi']) }}</li>
<li class="nav-header">{{ ($count > 1 ? $app.' - '.$files['sapi'] : $files['sapi']) }}</li>
<ul class="nav nav-list">
@foreach ($file as $f)
{{ HTML::decode(HTML::nav_item($url . '/' . $app . '/' . $type . '/' . $f, $f)) }}
{{ HTML::decode(HTML::nav_item($url.'/'.$app.'/'.$type.'/'.$f, $f)) }}
@endforeach
</ul>
@endif
Expand Down Expand Up @@ -149,7 +149,7 @@
<p>{{ Lang::get('logviewer::logviewer.delete.modal.body') }}</p>
</div>
<div class="modal-footer">
{{ HTML::link($url . '/' . $path . '/' . $sapi_plain . '/' . $date . '/delete', Lang::get('logviewer::logviewer.delete.modal.btn.yes'), array('class' => 'btn btn-success')) }}
{{ HTML::link($url.'/'.$path.'/'.$sapi_plain.'/'.$date.'/delete', Lang::get('logviewer::logviewer.delete.modal.btn.yes'), array('class' => 'btn btn-success')) }}
<button class="btn btn-danger" data-dismiss="modal">{{ Lang::get('logviewer::logviewer.delete.modal.btn.no') }}</button>
</div>
</div>
Expand Down

0 comments on commit f3fc2e8

Please sign in to comment.