FEATURE #2472: fix few minor bugs in template management

This commit is contained in:
Michal Kváček
2017-07-31 18:26:26 +02:00
parent 638f6ef134
commit a7e91ef499
5 changed files with 39 additions and 37 deletions
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Admin\Templates;
use App\Cms\Repositories\Templates\Template as TemplateRepository;
use App\Http\Controllers\Admin\Controller;
use App\Http\Requests\CopyTemplateRequest;
use App\Models\Templates\Template;
@@ -10,7 +11,6 @@ class CopyTemplate extends Controller
{
/**
* Method for copying given template.
*
* This method is supposed to be called by POST method.
*
* @param CopyTemplateRequest $request
@@ -32,15 +32,22 @@ class CopyTemplate extends Controller
$namespace .= '::';
}
$repository = app(TemplateRepository::class);
$repository->setModel($template);
// get template absolute paths
$realTemplatePath = $template->getPathToTemplate();
$customTemplatePath = $template->getPathToTemplate(Template::CUSTOM_EDIT_DIRECTORY);
$realTemplatePath = $repository->getPathToTemplate();
$customTemplatePath = $repository->getPathToTemplate(TemplateRepository::CUSTOM_EDIT_DIRECTORY);
$path = dirname($customTemplatePath);
// create file copy
$data = file_get_contents($realTemplatePath);
$written = file_put_contents($path . DIRECTORY_SEPARATOR . $newName . Template::TEMPLATE_SUFFIX, $data);
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
$written = file_put_contents($path . DIRECTORY_SEPARATOR . $newName . TemplateRepository::TEMPLATE_SUFFIX, $data);
// were data written?
if ($written === false) {
return $this->copyFailed($request, $template);
@@ -67,7 +74,6 @@ class CopyTemplate extends Controller
* @param Template $template
*
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
*
*/
private function copyFailed(CopyTemplateRequest $request, Template $template)
{
@@ -23,14 +23,4 @@ class ArticleEventServiceProvider extends ServiceProvider
DeletedComment::class => [LogDeletedComment::class],
CreatedComment::class => [LogNewComment::class],
];
public function boot(DispatcherContract $events)
{
parent::boot($events);
}
protected function setModulePath()
{
$this->path = __DIR__;
}
}
+1 -1
View File
@@ -38,7 +38,7 @@ return [
"noTemplates" => "Nelze vytvořit stránku. Pro tento modul neexistuje žádná šablona, která by šla použít pro vykreslení obsahu.",
"nothingToEdit" => "Nebyly provedeny žádné změny, proto nedošlo k editaci.",
"overview" => "Seznam všech obsahových stránek",
"pageDeleted" => "Stránka :name (:url) úspěšně smazána.",
"pageDeleted" => "Stránka :name úspěšně smazána.",
"parentPage" => "Nadřazená stránka",
"publicationOptions" => "Nastavení publikace",
"save" => "Uložit",
+4
View File
@@ -1,5 +1,6 @@
<?php
return [
"copy" => 'Kopírovat šablonu',
"cannotCopy" => "Adresář nemá potřebná práva k zápisu. Kopírování není dostupné.",
"cannotWriteContent" => "Nelze uložit obsah šablony, adresář pro uložení souboru nemá dostatečná oprávnění pro zápis. Meta informace k šabloně však byly uloženy.",
"copyFailed" => "Nelze zkopírovat šablonu do :name. Zkontrolujte prosím právo pro zápis do adresáře s šablonami.",
@@ -20,4 +21,7 @@ return [
"overview" => "Šablony",
"parentDirectory" => "Rodičovský adresář",
"subdirectories" => "Podadresáře",
'widgets' => 'Widgety',
'errors' => 'Chybové stránky',
'contact' => 'Kontaktní formulář'
];
@@ -17,9 +17,11 @@
<h5>@lang('admin/templates.subdirectories')</h5>
<ul>
@forelse($subdirectories as $subdirectory)
<a href="{{route('templates.overview', ['path' => $subdirectory->id])}}">{{trans($subdirectory->name)}}</a>
<li><a href="{{route('templates.overview', ['path' => $subdirectory->id])}}">{{trans($subdirectory->name)}}</a></li>
@empty
<em>@lang('admin/templates.noSubdirectories')</em>
<li><em>@lang('admin/templates.noSubdirectories')</em></li>
@endforelse
</ul>
</div>