Commit 85cf9a75 authored by nirgendswo's avatar nirgendswo

bugfix locale

bugfix pagination
parent bfa9df26
APP_DEBUG=true
APP_THEME=simple
APP_LOCALE=en
......@@ -86,7 +86,7 @@ class ViewHelper
}
$string = array_slice($string, 0, 1);
$result = Lang::choice('date.ago', ['date' => implode(', ', $string)]);
$result = Lang::trans('date.ago', ['date' => implode(', ', $string)]);
return $result;
}
......
......@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use Illuminate\Support\Facades\Validator;
use Laravel\Lumen\Routing\Controller;
use Illuminate\Support\Facades\Lang;
use App\Facades\PageRepositoryFacade as PageRepository;
......@@ -29,7 +30,7 @@ class PageController extends Controller
'slug' => '404'
]);
}
return app()->make('view')->make($this->getView($page), [
'page' => $page
]);
......
......@@ -13,6 +13,6 @@ class AppServiceProvider extends ServiceProvider
*/
public function register()
{
//
$this->loadTranslationsFrom(base_path().'/bresources/lang', 'date');
}
}
......@@ -44,12 +44,16 @@ class PageRepository
'limit' => 10
];
/** items */
protected $items = 0;
/**
*
* @param array $config
*/
public function __construct()
{
$this->pageService = app(\App\PageService::class);
$this->repositoryPath = base_path().'/'.config('app.repositoryPath');
}
......@@ -70,6 +74,14 @@ class PageRepository
// and render markdown
if ($file) {
$page = PageParser::toObject($slug, $file);
// if title not set, set page to null,
// pages without title are handle like snippets,
// but the are not call with slugs
// @TODO Take that to the documentation
if (!isset($page->data['title'])) {
$page = NULL;
}
}
return $page;
......@@ -107,12 +119,30 @@ class PageRepository
public function paginate(Array $parameters, Array $options)
{
$options = array_merge($this->options, $options);
$options['offset'] = ($options['page'] - 1) * $options['limit'];
unset($options['page']);
$options['offset'] = ($this->pageService->getPage() - 1) * $options['limit'];
return $this->find($parameters, $options);
}
/**
*
*
*/
public function getCount()
{
return $this->count;
}
/**
*
* @param [type] $items [description]
* @param [type] $limit [description]
*/
protected function setCount($items, $limit)
{
$this->count = ceil($items / $limit);
}
/**
* parse slug from $filePathname
*
......@@ -181,6 +211,7 @@ class PageRepository
}
$pages = $this->limit($pages, $options['limit'], $options['offset']);
$this->setCount($items, $options['limit']);
return $pages;
}
......
......@@ -26,6 +26,9 @@ $app = new Laravel\Lumen\Application(
$app->withFacades();
$app->configure('app');
// set locale
app('translator')->setLocale(env('APP_LOCALE'));
/*
|--------------------------------------------------------------------------
| Register Container Bindings
......
@if ($pageRepository->getCount() > 1)
<div class="pagination">
@for ($i = 1; $i <= $pageRepository->getCount(); $i++)
<a class="pagination__item" href="p/{{ $i }}">
{{ $i }}
</a>
@endfor
</div>
@endif
......@@ -34,4 +34,7 @@
</div>
</article>
@endforeach
<div class="pagination">
@include('pagination')
</div>
@endsection
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment