Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions Entities/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,28 @@ public function getNameAttribute($value)
return null;
}
//-------------------------------------------------
public function setContentAttribute($value)
{
if($value)
{
$this->attributes['content'] = vh_translate_dynamic_strings($value,['has_replace_string' => true]);
} else{
$this->attributes['content'] = null;
}

}
//-------------------------------------------------
public function getContentAttribute($value)
{
if($value)
{
return vh_translate_dynamic_strings($value);
}

return null;

}
//-------------------------------------------------
public function setMetaAttribute($value)
{
if($value)
Expand Down Expand Up @@ -223,8 +245,6 @@ public static function getList($request)

$data['list'] = $list->paginate(config('vaahcms.per_page'));



$response['status'] = 'success';
$response['data'] = $data;

Expand Down Expand Up @@ -323,6 +343,7 @@ public static function postStore($request,$id)
return $validation;
}


// check if name exist
$name_exist = static::where('id','!=',$request['id'])
->where('name',$request['name'])
Expand Down Expand Up @@ -534,7 +555,7 @@ public static function getBlock($block_slug)
return false;
}

return $block->content;
return vh_translate_dynamic_strings($block->content);
}

//---------------------------------------------------------------------------
Expand All @@ -560,7 +581,7 @@ public static function getBlocksByLocation($location)
$data = "";

foreach ($blocks as $block){
$data .= $block->content;
$data .= vh_translate_dynamic_strings($block->content);
}


Expand Down
28 changes: 22 additions & 6 deletions Entities/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function authorUser()
'author', 'id'
)->select(
'id', 'uuid', 'first_name', 'last_name', 'email',
'username', 'display_name', 'title', 'bio', 'website',
'username', 'display_name', 'title', 'bio', 'website'
);
}
//-------------------------------------------------
Expand Down Expand Up @@ -438,11 +438,18 @@ public static function getFormGroups(Content $content, $type, array $fields=null
$field_content->where('vh_cms_form_field_id', $field->id);
$field_content = $field_content->first();


if($field_content)
{
$groups[$i]['fields'][$y]['vh_cms_form_field_id'] = $field_content->id;
$groups[$i]['fields'][$y]['content'] = $field_content->content;

if(is_array($field_content->content) || is_object($field_content->content)){
$groups[$i]['fields'][$y]['content'] = json_decode(
vh_translate_dynamic_strings(json_encode($field_content->content))
);
}else{
$groups[$i]['fields'][$y]['content'] = vh_translate_dynamic_strings($field_content->content);
}

$groups[$i]['fields'][$y]['content_meta'] = $field_content->meta;
}

Expand Down Expand Up @@ -533,9 +540,18 @@ public static function storeFormGroups(Content $content, $groups)
$stored_field->vh_cms_form_field_id = $field['id'];
}

if(is_array($field['content']) || is_object($field['content']))
{
$field['content'] = json_encode($field['content']);
if(is_array($field['content']) || is_object($field['content'])){
$field['content'] = json_decode(
vh_translate_dynamic_strings(
json_encode($field['content']),
['has_replace_string' => true]
)
);
}else{
$field['content'] = vh_translate_dynamic_strings(
$field['content'],
['has_replace_string' => true]
);
}

if($field['type']['slug'] == 'user' && $field['content']){
Expand Down
38 changes: 38 additions & 0 deletions Helpers/cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,37 @@
//-----------------------------------------------------------------------------------
use VaahCms\Modules\Cms\Entities\Content;


//-----------------------------------------------------------------------------------
function cms_dynamic_variables()
{
$list = [
[
'name' => '#!PUBLIC:MODULE_URL!#',
'value' => url('/vaahcms/modules'),
'detail'=>'Will be replaced with public module url.'
],
[
'name' => '#!PUBLIC:THEME_URL!#',
'value' => url('/vaahcms/themes'),
'detail'=>'Will be replaced with public theme url.'
],
[
'name' => '#!PUBLIC:STORAGE_URL!#',
'value' => url('/storage'),
'detail'=>'Will be replaced with public storage url.'
],
[
'name' => '#!PUBLIC:BASE_URL!#',
'value' => url('/'),
'detail'=>'Will be replaced with public url.',
]
];

return $list;

}

function get_content_types(array $args = null)
{

Expand Down Expand Up @@ -141,6 +172,13 @@ function setReturnValue($field,$return_html=true)
return $field->content;
}

if(is_array($field->content) || is_object($field->content)){
$field->content = json_decode(
vh_translate_dynamic_strings(json_encode($field['content']))
);
}else{
$field->content = vh_translate_dynamic_strings($field['content']);
}

switch($field['type']['slug']){

Expand Down
2 changes: 2 additions & 0 deletions Http/Controllers/Backend/BlocksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public function __construct()
public function getAssets(Request $request)
{

$data['replace_strings'] = vh_action('getPublicUrls', null, 'array');

$data['field_types'] = FieldType::select('id', 'name', 'slug', 'meta')
->get();

Expand Down
2 changes: 2 additions & 0 deletions Libraries/CmsSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ public static function createSampleField($theme_slug, $file_path, $content_type_
}

}
//-------------------------------------------------------

//-------------------------------------------------------
public static function fillFields($groups)
{
Expand Down
1 change: 1 addition & 0 deletions Providers/CmsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function boot(Router $router)
$this->registerConfig();
$this->registerViews();
$this->registerAssets();

//$this->registerFactories();
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
$this->registerSeeders();
Expand Down
29 changes: 27 additions & 2 deletions Vue/pages/blocks/Edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,42 @@

<p class="control">
<b-button type="is-light"
@click="is_textarea_disable = false"
@click="setDynamicContent(false)"
:disabled="!is_textarea_disable">
Editor
</b-button>
</p>
<p class="control">
<b-button type="is-light"
@click="is_textarea_disable = true"
@click="setDynamicContent(true)"
:disabled="is_textarea_disable">
Code Editor
</b-button>
</p>
<p class="control">
<b-dropdown position="is-bottom-left" :triggers="['hover']" aria-role="list">
<template #trigger>
<button class="button is-light"
slot="trigger">
<b-icon icon="caret-down"></b-icon>
</button>
</template>



<span v-for="string in assets.replace_strings.success">
<b-dropdown-item >
<vh-copy class="text-copyable"
@copied="copyCode(string.name)"
>
<b-icon icon="copy"></b-icon> {{string.name.replace(/[^a-zA-Z ]/g, " ")}}
</vh-copy>
</b-dropdown-item>
</span>


</b-dropdown>
</p>
</div>
</div>

Expand All @@ -46,6 +70,7 @@
:options="cm_options"
/>


<ContentFieldAll v-else
field_slug="editor"
:labelPosition="labelPosition"
Expand Down
60 changes: 34 additions & 26 deletions Vue/pages/blocks/EditJs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ContentFieldAll from '../../vaahvue/reusable/content-fields/All'
import draggable from 'vuedraggable';
import { codemirror } from 'vue-codemirror'


// language
import 'codemirror/mode/xml/xml.js'
// theme css
Expand All @@ -12,6 +13,7 @@ import 'codemirror/theme/monokai.css'
import'codemirror/addon/selection/active-line.js'
// autoCloseTags
import'codemirror/addon/edit/closetag.js'
import copy from "copy-to-clipboard";

let namespace = 'blocks';

Expand Down Expand Up @@ -76,32 +78,6 @@ export default {
}
},

'item.plural': {
deep: true,
handler(new_val, old_val) {

if(new_val)
{
this.item.plural_slug = this.$vaah.strToSlug(new_val);
this.updateNewItem();
}

}
},

'item.singular': {
deep: true,
handler(new_val, old_val) {

if(new_val)
{
this.item.singular_slug = this.$vaah.strToSlug(new_val);
this.updateNewItem();
}

}
},

},
mounted() {
//----------------------------------------------------
Expand Down Expand Up @@ -271,5 +247,37 @@ export default {
this.update('active_item', null);
this.$router.push({name:'blocks.list'});
},
//---------------------------------------------------------------------
setDynamicContent: function (value) {
let self = this;

if(value){
$.each(self.assets.replace_strings.success, function( index, string ) {
let regex = new RegExp(string.value, "g");
self.item.content = self.item.content.replace(regex, string.name);
});

}else{
$.each(self.assets.replace_strings.success, function( index, string ) {
let regex = new RegExp(string.name, "g");
self.item.content = self.item.content.replace(regex, string.value);
});

}

self.is_textarea_disable = value;


},
//---------------------------------------------------------------------
copyCode: function (item,has_location = false)
{
copy(item);

this.$buefy.toast.open({
message: 'Copied!',
type: 'is-success'
});
},
}
}
5 changes: 4 additions & 1 deletion Vue/pages/blocks/ViewJs.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,17 @@ export default {
this.$Progress.finish();
this.is_content_loading = false;

if(data && data)
if(data && data && this.page && this.page.assets )
{
if(data.is_active == 1){
data.is_active = 'Yes';
}else{
data.is_active = 'No';
}

this.update('active_item', data);


} else
{
//if item does not exist or delete then redirect to list
Expand Down