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
5 changes: 3 additions & 2 deletions Entities/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,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','meta','avatar_url'
);
}
//-------------------------------------------------
Expand Down Expand Up @@ -327,7 +327,8 @@ public static function getList($request)
$list->where(function ($q) use ($item){
$q->where('name', 'LIKE', '%'.$item.'%')
->orWhere('id', 'LIKE', $item.'%')
->orWhere('slug', 'LIKE', '%'.$item.'%');
->orWhere('slug', 'LIKE', '%'.$item.'%')
->orWhere('permalink', 'LIKE', '%'.$item.'%');
});
}
}
Expand Down
120 changes: 63 additions & 57 deletions Helpers/cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,71 +180,77 @@ function setReturnValue($field,$return_html=true)
$field->content = vh_translate_dynamic_strings($field['content']);
}

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

case 'seo-meta-tags':
$value = '<title>'.$field->content->seo_title->content.'</title>'."\n";
$value .= '<meta name="description" content="'.$field->content->seo_description->content.'"/>'."\n";
$value .= '<meta name="keywords" content="'.$field->content->seo_keywords->content.'"/>'."\n";
break;

case 'twitter-card':
$value = '<meta name="twitter:card" content="summary" />'."\n";
$value .= '<meta name="twitter:site" content="'.$field->content->twitter_site->content.'"/>'."\n";
$value .= '<meta name="twitter:title" content="'.$field->content->twitter_title->content.'"/>'."\n";
$value .= '<meta name="twitter:description" content="'.$field->content->twitter_description->content.'"/>'."\n";
$value .= '<meta name="twitter:image" content="'.$field->content->twitter_image->content.'"/>'."\n";
break;

case 'facebook-card':
$value = '<meta name="og:title" content="'.$field->content->og_title->content.'"/>'."\n";
$value .= '<meta name="og:description" content="'.$field->content->og_description->content.'"/>'."\n";
$value .= '<meta name="og:image" content="'.$field->content->og_image->content.'"/>'."\n";
break;

case 'address':
$value = '<address>'."\n";

$value .= $field->content->address_line_1->content.', '.$field->content->address_line_2->content."</br>";
$value .= $field->content->city->content.', '.$field->content->state->content."</br>";
$value .= $field->content->landmark->content."</br>";
$value .= $field->content->country->content.', '.$field->content->zip_code->content;

$value .= '</address>';
break;

case 'json':
$value = json_encode($field->content);
break;

case 'image-group':

$value = '<div class="image-group field-id-'.$field->id.'"
$value = null;

if($field->content){
switch($field['type']['slug']){

case 'seo-meta-tags':
$value = '<title>'.$field->content->seo_title->content.'</title>'."\n";
$value .= '<meta name="description" content="'.$field->content->seo_description->content.'"/>'."\n";
$value .= '<meta name="keywords" content="'.$field->content->seo_keywords->content.'"/>'."\n";
break;

case 'twitter-card':
$value = '<meta name="twitter:card" content="summary" />'."\n";
$value .= '<meta name="twitter:site" content="'.$field->content->twitter_site->content.'"/>'."\n";
$value .= '<meta name="twitter:title" content="'.$field->content->twitter_title->content.'"/>'."\n";
$value .= '<meta name="twitter:description" content="'.$field->content->twitter_description->content.'"/>'."\n";
$value .= '<meta name="twitter:image" content="'.$field->content->twitter_image->content.'"/>'."\n";
break;

case 'facebook-card':
$value = '<meta name="og:title" content="'.$field->content->og_title->content.'"/>'."\n";
$value .= '<meta name="og:description" content="'.$field->content->og_description->content.'"/>'."\n";
$value .= '<meta name="og:image" content="'.$field->content->og_image->content.'"/>'."\n";
break;

case 'address':
$value = '<address>'."\n";

$value .= $field->content->address_line_1->content.', '.$field->content->address_line_2->content."</br>";
$value .= $field->content->city->content.', '.$field->content->state->content."</br>";
$value .= $field->content->landmark->content."</br>";
$value .= $field->content->country->content.', '.$field->content->zip_code->content;

$value .= '</address>';
break;

case 'json':
$value = json_encode($field->content);
break;

case 'image-group':

$value = '<div class="image-group field-id-'.$field->id.'"
id="field-'.$field->id.'" >'."\n";

foreach ($field->content as $item){
$value .= '<div class="image-container">'."\n";
$value .= '<img class="image" src='.$item.'/>'."\n";
$value .= '</div>'."\n";
}
foreach ($field->content as $item){
$value .= '<div class="image-container">'."\n";
$value .= '<img class="image" src='.$item.'/>'."\n";
$value .= '</div>'."\n";
}

$value .= '</div>'."\n";
break;
$value .= '</div>'."\n";
break;

case 'list':
$value = '<ul>'."\n";
case 'list':
$value = '<ul>'."\n";

foreach ($field->content as $item){
$value .= '<li>'.$item.'</li>'."\n";
}
$value .= '</ul>';
break;
foreach ($field->content as $item){
$value .= '<li>'.$item.'</li>'."\n";
}
$value .= '</ul>';
break;

default:
$value = $field->content;
break;
default:
$value = $field->content;
break;
}
}



return $value;
}
//-----------------------------------------------------------------------------------
Expand Down
68 changes: 55 additions & 13 deletions Libraries/CmsSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use VaahCms\Modules\Cms\Entities\Content;
use VaahCms\Modules\Cms\Entities\ContentType;
use WebReinvent\VaahCms\Entities\ThemeTemplate;
use WebReinvent\VaahCms\Entities\User;

class CmsSeeder{

Expand Down Expand Up @@ -94,14 +95,17 @@ public static function storeSeeds($theme_slug,
$record = DB::table($table)
->where('vh_theme_id', $theme->id)
->where($primary_key, $item[$primary_key])
->where('type', $item['type'])
->first();


if(!$record)
{
DB::table($table)->insert($item);
} else{
DB::table($table)->where($primary_key, $item[$primary_key])
DB::table($table)->where('vh_theme_id', $theme->id)
->where($primary_key, $item[$primary_key])
->where('type', $item['type'])
->update($item);
}
}
Expand Down Expand Up @@ -287,15 +291,37 @@ public static function createSampleField($theme_slug, $file_path, $content_type_
$item['slug'] = Str::slug($item['name']);
}

$page = Content::where('slug', $item['slug'])

$content = Content::where('slug', $item['slug'])
->where('vh_cms_content_type_id', $content_type['id'])
->where('vh_theme_id', $theme->id)
->where('vh_theme_template_id', $template['id'])
->first();

if(!$page)
{
$page = new Content();
$is_permalink_exist = Content::where('permalink', $item['permalink']);

if(!$content){
$content = new Content();
}else{
$is_permalink_exist->where('id','!=', $content->id);
}

$is_permalink_exist = $is_permalink_exist->first();

if($is_permalink_exist){
$item['permalink'] = Str::random(10).'-'.$item['permalink'];
}

$author_id = null;

if(isset($item['author']) && $item['author']){

$user = User::where('email',$item['author'])->first();

if($user){
$author_id = $user->id;
}

}

$fillable = [
Expand All @@ -305,28 +331,40 @@ public static function createSampleField($theme_slug, $file_path, $content_type_
'name' => $item['name'],
'slug' => $item['slug'],
'permalink' => $item['permalink'],
'author' => $author_id,
'status' => 'published',
'is_published_at' => \Carbon::now(),
];


$page->fill($fillable);
$page->save();
$content->fill($fillable);
$content->save();

$json_content = array();
$json_template = array();

if(isset($item['content'])){
$json_content = $item['content'];
}

if(isset($item['template'])){
$json_template = $item['template'];
}

$content_groups = self::fillFields($content_type['groups']);
$template_groups = self::fillFields($template['groups']);

Content::storeFormGroups($page, $content_groups);
Content::storeFormGroups($page, $template_groups);
$content_groups = self::fillFields($content_type['groups'],$json_content);
$template_groups = self::fillFields($template['groups'],$json_template);

Content::storeFormGroups($content, $content_groups);
Content::storeFormGroups($content, $template_groups);

}

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

//-------------------------------------------------------
public static function fillFields($groups)
public static function fillFields($groups, $json_data = [])
{

$faker = \Faker\Factory::create();
Expand All @@ -347,8 +385,12 @@ public static function fillFields($groups)
foreach ($group['fields'] as $key => $field)
{

if(isset($json_data[$group['slug']]) && $json_data[$group['slug']]
&& isset($json_data[$group['slug']][$field['slug']])){

$field['content'] = $json_data[$group['slug']][$field['slug']];

if(
} elseif(
isset($field['meta'])
&& is_object($field['meta'])
&& isset($field['meta']->default)
Expand Down
2 changes: 1 addition & 1 deletion Resources/assets/build/app.js

Large diffs are not rendered by default.

22 changes: 14 additions & 8 deletions Vue/pages/contents/partials/ListLargeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,32 @@
{{ props.row.name }}
</b-table-column>

<b-table-column v-slot="props" width="150px" field="status" label="Status">
<b-table-column v-slot="props" width="170" field="permalink" label="Permalink">
<b-tooltip :label="props.row.permalink" type="is-dark">
{{$vaah.limitString(props.row.permalink, 22)}}
</b-tooltip>
</b-table-column>

<b-table-column v-slot="props" width="150" field="status" label="Status">


<div v-if="props.row.deleted_at">

<b-dropdown aria-role="list" disabled size="is-small" v-model="props.row.status"
<b-dropdown aria-role="list" disabled size="is-small" v-model="props.row.status"
@input="changeStatus(props.row.id,props.row.status)">

<p v-if="props.row.status === 'published'"
class="tag is-success"
slot="trigger"
role="button" slot-scope="{ active }">
class="tag is-success"
slot="trigger"
role="button" slot-scope="{ active }">
<span>{{ props.row.status }}</span>

</p>

<p v-else
class="tag is-dark"
slot="trigger"
role="button" slot-scope="{ active }">
class="tag is-dark"
slot="trigger"
role="button" slot-scope="{ active }">
<span>{{ props.row.status }}</span>

</p>
Expand Down
2 changes: 1 addition & 1 deletion Vue/vaahvue