Skip to content

Commit

Permalink
Merge pull request #1 from AsgardCms/3.0
Browse files Browse the repository at this point in the history
updated 3.5.3
  • Loading branch information
kamekun authored May 3, 2018
2 parents e7394a3 + c59bf4c commit 5bc09f2
Show file tree
Hide file tree
Showing 49 changed files with 450 additions and 15 deletions.
8 changes: 4 additions & 4 deletions Modules/Core/Assets/js/mixins/ActiveEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ export default {
methods: {
getCurrentEditor() {
const configuredEditor = window.AsgardCMS.editor;
if (configuredEditor === undefined || configuredEditor === 'ckeditor') {
return 'ckeditor';
}
if (configuredEditor === 'simplemde') {
return 'markdown-editor';
}
if (configuredEditor === 'ckeditor') {
return 'ckeditor';
}
return 'ckeditor';
return configuredEditor;
},
},
};
2 changes: 1 addition & 1 deletion Modules/Core/Foundation/AsgardCms.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ class AsgardCms
* The AsgardCms version.
* @var string
*/
const VERSION = '3.5.2';
const VERSION = '3.5.3';
}
4 changes: 4 additions & 0 deletions Modules/Core/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
url: https://github.com/AsgardCms/Platform
versions:
"3.5.3":
changed:
- Updating Polish translations
- Updating Spanish translations
"3.5.2":
changed:
- Correctly returning the Query object from <code>allWithBuilder</code> method in base repository
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddDescriptionColumnToMenuitemsTranslationTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('menu__menuitem_translations', function (Blueprint $table) {
$table->string('description')->after('uri')->nullable()->default(null);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('menu__menuitem_translations', function (Blueprint $table) {
$table->dropColumn('description');
});
}
}
1 change: 1 addition & 0 deletions Modules/Menu/Entities/Menuitem.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Menuitem extends Model
'link_type',
'locale',
'class',
'description',
];
protected $table = 'menu__menuitems';

Expand Down
2 changes: 1 addition & 1 deletion Modules/Menu/Entities/MenuitemTranslation.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

class MenuitemTranslation extends Model
{
public $fillable = ['title', 'uri', 'url', 'status', 'locale'];
public $fillable = ['title', 'uri', 'url', 'status', 'locale', 'description'];
protected $table = 'menu__menuitem_translations';
}
5 changes: 4 additions & 1 deletion Modules/Menu/Providers/MenuServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Modules\Menu\Providers;

use Illuminate\Support\ServiceProvider;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
use Modules\Core\Events\BuildingSidebar;
use Modules\Core\Events\LoadingBackendTranslations;
use Modules\Core\Traits\CanGetSidebarClassForModule;
Expand Down Expand Up @@ -122,7 +123,9 @@ public function addItemToMenu(Menuitem $item, Builder $menu)
]
);
} else {
$target = $item->link_type != 'external' ? $item->locale . '/' . $item->uri : $item->url;
$localisedUri = ltrim(parse_url(LaravelLocalization::localizeURL($item->uri), PHP_URL_PATH), '/');
$target = $item->link_type != 'external' ? $localisedUri : $item->url;

$menu->url(
$target,
$item->title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
{!! Form::text("{$lang}[url]", old("{$lang}[url]"), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.url')]) !!}
{!! $errors->first("{$lang}[url]", '<span class="help-block">:message</span>') !!}
</div>
<div class="form-group{{ $errors->has("{$lang}[description]") ? ' has-error' : '' }}">
{!! Form::label("{$lang}[description]", trans('menu::menu.form.description')) !!}
{!! Form::text("{$lang}[description]", old("{$lang}[description]"), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.description')]) !!}
{!! $errors->first("{$lang}[description]", '<span class="help-block">:message</span>') !!}
</div>

<div class="checkbox">
<label for="{{$lang}}[status]">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
{!! Form::text("{$lang}[url]", old("{$lang}[url]", $old), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.url')]) !!}
{!! $errors->first("{$lang}[url]", '<span class="help-block">:message</span>') !!}
</div>
<div class="form-group{{ $errors->has("{$lang}[description]") ? ' has-error' : '' }}">
{!! Form::label("{$lang}[description]", trans('menu::menu.form.description')) !!}
<?php $old = $menuItem->hasTranslation($lang) ? $menuItem->translate($lang)->description : '' ?>
{!! Form::text("{$lang}[description]", old("{$lang}[description]", $old), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.description')]) !!}
{!! $errors->first("{$lang}[description]", '<span class="help-block">:message</span>') !!}
</div>
<div class="checkbox">
<?php $old = $menuItem->hasTranslation($lang) ? $menuItem->translate($lang)->status : false ?>
<label for="{{$lang}}[status]">
Expand Down
5 changes: 5 additions & 0 deletions Modules/Menu/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
url: https://github.com/AsgardCms/Platform
versions:
"3.5.3":
changed:
- Description field added for extra convenience
- Use LaravelLocalization When Generating Menu Item URIs
- Updating typicms/nestablecollection package
"3.4.0":
changed:
- Using new <code>remember</code> method in the <code>CacheMenuDecorator</code> class
Expand Down
2 changes: 1 addition & 1 deletion Modules/Page/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
url: https://github.com/AsgardCms/Platform
versions:
"@unreleased":
"3.5.2":
changed:
- Adding support for UTF-8 slug for non ASCII characters (Chinese etc.)
"3.4.0":
Expand Down
9 changes: 8 additions & 1 deletion Modules/Setting/Entities/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@

use Dimsav\Translatable\Translatable;
use Illuminate\Database\Eloquent\Model;
use Modules\Media\Support\Traits\MediaRelation;

class Setting extends Model
{
use Translatable;
use Translatable, MediaRelation;

public $translatedAttributes = ['value', 'description'];
protected $fillable = ['name', 'value', 'description', 'isTranslatable', 'plainValue'];
protected $table = 'setting__settings';

public function isMedia(): bool
{
$value = json_decode($this->plainValue, true);
return is_array($value) && isset($value['medias_single']);
}
}
27 changes: 25 additions & 2 deletions Modules/Setting/Events/SettingWasCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,40 @@

namespace Modules\Setting\Events;

use Modules\Media\Contracts\StoringMedia;
use Modules\Setting\Entities\Setting;

class SettingWasCreated
class SettingWasCreated implements StoringMedia
{
/**
* @var Setting
*/
public $setting;

public function __construct(Setting $setting)
/**
* @var array
*/
public $data;

public function __construct(Setting $setting, $data)
{
$this->setting = $setting;
$this->data = $data;
}

/**
* @inheritDoc
*/
public function getEntity()
{
return $this->setting;
}

/**
* @inheritDoc
*/
public function getSubmissionData()
{
return $this->data;
}
}
28 changes: 26 additions & 2 deletions Modules/Setting/Events/SettingWasUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,41 @@

namespace Modules\Setting\Events;

use Modules\Media\Contracts\StoringMedia;

use Modules\Setting\Entities\Setting;

class SettingWasUpdated
class SettingWasUpdated implements StoringMedia
{
/**
* @var Setting
*/
public $setting;

public function __construct(Setting $setting)
/**
* @var array
*/
public $data;

public function __construct(Setting $setting, $data)
{
$this->setting = $setting;
$this->data = $data;
}

/**
* @inheritDoc
*/
public function getEntity()
{
return $this->setting;
}

/**
* @inheritDoc
*/
public function getSubmissionData()
{
return $this->data;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ public function createOrUpdate($settings)
$this->removeTokenKey($settings);

foreach ($settings as $settingName => $settingValues) {
// Check if media exists
if($settingName == 'medias_single') {
// Get first key of values (Original settingName)
foreach ($settingValues as $key => $value) {
$normalisedValue = [ $settingName => [$key => $value] ];
$settingName = $key;
break;
}
$settingValues = $normalisedValue;
}
if ($setting = $this->findByName($settingName)) {
$this->updateSetting($setting, $settingValues);
continue;
Expand Down Expand Up @@ -99,7 +109,7 @@ private function createForName($settingName, $settingValues)

$setting->save();

event(new SettingWasCreated($setting));
event(new SettingWasCreated($setting, $settingValues));

return $setting;
}
Expand All @@ -121,7 +131,7 @@ private function updateSetting($setting, $settingValues)
}
$setting->save();

event(new SettingWasUpdated($setting));
event(new SettingWasUpdated($setting, $settingValues));

return $setting;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@php
$setting = isset($dbSettings[$settingName]) ? $dbSettings[$settingName] : null;
@endphp

@mediaSingle($settingName, $setting, null, trans($moduleInfo['description']))
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@php
$setting = isset($dbSettings[$settingName]) ? $dbSettings[$settingName] : null;
@endphp

@mediaSingle($settingName, $setting, null, trans($moduleInfo['description']))
4 changes: 4 additions & 0 deletions Modules/Setting/Support/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public function get($name, $locale = null, $default = null)
return is_null($default) ? $defaultFromConfig : $default;
}

if($setting->isMedia() && $media = $setting->files()->first()) {
return $media->path;
}

if ($setting->isTranslatable) {
if ($setting->hasTranslation($locale)) {
return trim($setting->translate($locale)->value) === '' ? $defaultFromConfig : $setting->translate($locale)->value;
Expand Down
4 changes: 4 additions & 0 deletions Modules/Setting/Tests/BaseSettingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,9 @@ private function resetDatabase()
$this->artisan('migrate', [
'--database' => 'sqlite',
]);
$this->artisan('migrate', [
'--database' => 'sqlite',
'--path' => 'Modules/Media/Database/Migrations',
]);
}
}
6 changes: 6 additions & 0 deletions Modules/Setting/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
url: https://github.com/AsgardCms/Platform
versions:
"@unreleased":
added:
- New <code>@hasSetting()</code> and <code>@endHasSetting</code> directives
"3.5.3":
added:
- New setting type media-single
"3.4.0":
changed:
- Fix settings with falsey values not getting returned
Expand Down
11 changes: 11 additions & 0 deletions Modules/Tag/Tests/Integration/TaggableTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ public function it_gets_pages_with_non_latin_tags()
$this->assertCount(1, Page::whereTag(['한글-태그'])->get());
}

/** @test */
public function it_creates_page_without_tags()
{
$this->createPage(['original tag']);

$page = $this->page->find(1);
$page->setTags(null);

$this->assertEmpty(Page::first()->tags->count());
}

private function createPage(array $tags = [])
{
return $this->page->create([
Expand Down
4 changes: 4 additions & 0 deletions Modules/Tag/Traits/TaggableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ public static function allTags()
*/
public function setTags($tags, $type = 'slug')
{
if (empty($tags)) {
$tags = [];
}

// Get the current entity tags
$entityTags = $this->tags->pluck($type)->all();

Expand Down
3 changes: 3 additions & 0 deletions Modules/Tag/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
url: https://github.com/AsgardCms/Platform
versions:
"3.5.3":
changed:
- Set tags only if passed any
"3.4.0":
changed:
- Using new <code>remember</code> method in the <code>CacheTagDecorator</code>
Expand Down
1 change: 1 addition & 0 deletions Modules/Translation/Resources/lang/menu/de/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'uri' => 'URI',
'url' => 'URL',
'primary' => 'Hauptmenü (für das Frontend-Routing)',
'description' => 'Menü Beschreibung (Kann für zusätzliche Informationen verwendet werden)',
],
'navigation' => [
'back to index' => 'Zurück zur Übersicht',
Expand Down
1 change: 1 addition & 0 deletions Modules/Translation/Resources/lang/menu/en/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'uri' => 'URI',
'url' => 'URL',
'primary' => 'Primary menu (used for front-end routing)',
'description' => 'Menu Description (Can be used to provide extra information)',
],
'navigation' => [
'back to index' => 'Go back to the menu index',
Expand Down
1 change: 1 addition & 0 deletions Modules/Translation/Resources/lang/menu/es/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'uri' => 'URI',
'url' => 'URL',
'primary' => 'Menú principal (usado para rutas del sitio)',
'description' => 'Descripción del menú (Se puede usar para proporcionar información adicional)',
],
'navigation' => [
'back to index' => 'Regresar',
Expand Down
Loading

0 comments on commit 5bc09f2

Please sign in to comment.