a few updates for the admin panel

This commit is contained in:
dignajar 2020-11-30 22:00:54 +01:00
parent 226750af09
commit e84df311c2
18 changed files with 1328 additions and 592 deletions

View file

@ -1,7 +1,7 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
// ============================================================================
// Check role
// Authorization
// ============================================================================
checkRole(array('admin', 'editor', 'author'));
@ -10,7 +10,7 @@ checkRole(array('admin', 'editor', 'author'));
// Functions
// ============================================================================
// Returns the content belongs to the current user if the user has the role Editor
// Returns the content belongs to the current logged user
function filterContentOwner($list) {
global $login;
global $pages;
@ -24,15 +24,7 @@ function filterContentOwner($list) {
}
// ============================================================================
// Main before POST
// ============================================================================
// ============================================================================
// POST Method
// ============================================================================
// ============================================================================
// Main after POST
// Main
// ============================================================================
$published = $pages->getList($url->pageNumber(), ITEMS_PER_PAGE_ADMIN);
@ -42,7 +34,7 @@ $static = $pages->getStaticDB(true);
$sticky = $pages->getStickyDB(true);
$autosave = $pages->getAutosaveDB(true);
// If the user is an Author filter the content he/she can edit
// If the user has the role "Author" filter the content so he/she can edit
if (checkRole(array('author'), false)) {
$published = filterContentOwner($published);
$drafts = filterContentOwner($drafts);
@ -51,10 +43,10 @@ if (checkRole(array('author'), false)) {
$sticky = filterContentOwner($sticky);
}
// Check if out of range the pageNumber
// Check if the page number is out of range
if (empty($published) && $url->pageNumber()>1) {
Redirect::page('content');
}
// Title of the page
$layout['title'] .= ' - '.$L->g('Manage content');
// View HTML <title>
$layout['title'] = $L->g('Manage content') . ' - ' . $layout['title'];

View file

@ -1,7 +1,7 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
// ============================================================================
// Check role
// Authorization
// ============================================================================
checkRole(array('admin', 'editor', 'author'));
@ -11,20 +11,7 @@ checkRole(array('admin', 'editor', 'author'));
// ============================================================================
// ============================================================================
// Main before POST
// ============================================================================
// ============================================================================
// POST Method
// ============================================================================
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$pageKey = createPage($_POST);
Redirect::page('edit-content/'.$pageKey);
}
// ============================================================================
// Main after POST
// Main
// ============================================================================
// UUID of the page is need it for autosave and media manager
@ -48,5 +35,5 @@ if (IMAGE_RESTRICT) {
define('PAGE_THUMBNAILS_URL', DOMAIN_UPLOADS_THUMBNAILS);
}
// Title of the page
$layout['title'] = $L->g('New content').' - '.$layout['title'];
// View HTML <title>
$layout['title'] = $L->g('New content') . ' - ' . $layout['title'];

View file

@ -1,7 +1,7 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
// ============================================================================
// Check role
// Authorization
// ============================================================================
checkRole(array('admin'));
@ -11,21 +11,8 @@ checkRole(array('admin'));
// ============================================================================
// ============================================================================
// Main after POST
// Main
// ============================================================================
// ============================================================================
// POST Method
// ============================================================================
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
editSettings($_POST);
Redirect::page('settings');
}
// ============================================================================
// Main after POST
// ============================================================================
// Title of the page
$layout['title'] .= ' - '.$L->g('Advanced Settings');
// View HTML <title>
$layout['title'] = $L->g('Settings') . ' - ' . $layout['title'];

View file

@ -1,111 +1,143 @@
/* Tables */
.table {
background-color: #F4F4F4;
}
.table-striped tbody tr:nth-of-type(odd) {
background-color: rgba(0, 0, 0, 0.02);
}
.table thead th {
font-size: 0.8em;
text-transform: uppercase!important;
}
.table td {
border-top: none;
}
/* Common elements */
a {
color: #1A66A6;
color: #1A66A6;
}
a:hover {
color: #1A66A6;
text-decoration: none;
color: #1A66A6;
text-decoration: none;
}
.bg-success {
background-color: #8BC34A!important;
background-color: #8BC34A!important;
}
.text-primary {
color: #06A8C5!important;
color: #06A8C5!important;
}
.text-danger {
color: #D40000!important;
}
a.text-danger:focus,
a.text-danger:hover {
color: #790000!important;
color: #D40000!important;
}
a.text-danger:focus,
a.text-danger:hover {
color: #790000!important;
}
/* Buttons */
.btn {
border-radius: 2px;
border-radius: 2px;
}
.btn-sm {
padding: .25rem .75rem;
padding: .25rem .75rem;
}
.btn-save {
color: #5b8e09;
color: #5b8e09;
}
.btn-save:hover {
color: #466d07;
color: #466d07;
}
.btn-cancel:hover {
color: #000;
color: #000;
}
.btn-primary {
background-color: #0378D3;
border-color: #0378D3;
background-color: #0378D3;
border-color: #0378D3;
}
.btn-primary:hover {
background-color: #0270c4;
border-color: #0270c4;
background-color: #0270c4;
border-color: #0270c4;
}
.btn-primary-disabled {
background-color: #71b6ff !important;
border-color: #71b6ff !important;
background-color: #71b6ff !important;
border-color: #71b6ff !important;
}
.btn-secondary {
background-color: #6c757d;
border-color: #6c757d;
background-color: #6c757d;
border-color: #6c757d;
}
.btn-secondary:hover {
background-color: #5a6268;
border-color: #5a6268;
background-color: #5a6268;
border-color: #5a6268;
}
.btn-light {
color: #212529;
background-color: #f3f3f3;
border-color: #ced4d9;
color: #212529;
background-color: #f3f3f3;
border-color: #ced4d9;
}
.btn-light.focus,
.btn-light:focus {
box-shadow: none !important;
box-shadow: none !important;
}
.btn.focus,
.btn:focus {
box-shadow: none !important;
box-shadow: none !important;
}
/* Form */
.form-control:focus {
box-shadow: none;
box-shadow: none;
}
/* Tables */
.table-striped tbody tr:nth-of-type(odd) {
background-color: rgba(0, 0, 0, 0.02);
}
.table thead th {
font-size: 0.8em;
text-transform: uppercase!important;
}
/* Right sidebar Options */
#sidebarOptions .card {
background: none;
border: none;
background: none;
border: none;
}
#sidebarOptions a {
color: #212529;
color: #212529;
}
.nav-link {
border-color: #f9f9f9;
}
.nav-link.active {
background-color: #f9f9f9 !important;
border-color: #dee2e6 #dee2e6 #f9f9f9 !important;
}
.tab-content>.active {
background-color: #f9f9f9 !important;
}

View file

@ -1,86 +1,98 @@
html {
font-size: 0.9rem;
background: #EFEFEF;
font-size: 0.9rem;
background: #EFEFEF;
}
body {
background: #EFEFEF;
color: #1b1b1b;
background: #EFEFEF;
color: #1b1b1b;
}
nav.paginator {
background: #EFEFEF;
}
/*
ICONS
*/
.fa {
padding-right: 2px;
line-height: inherit;
padding-right: 2px;
line-height: inherit;
}
/*
SIDEBAR
*/
div.sidebar .nav-item a {
padding-left:0;
padding-right:0;
color: #555;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 0;
padding-right: 0;
color: #555;
padding-top: 5px;
padding-bottom: 5px;
}
div.sidebar .nav-item a:hover {
color: #0078D4;
color: #0078D4;
}
div.sidebar .nav-item h4 {
font-size: 1.2em;
text-transform: uppercase;
font-weight: 400;
margin-top: 10px;
font-size: 1.2em;
text-transform: uppercase;
font-weight: 400;
margin-top: 10px;
}
/*
AUTOCOMPLETE SEARCH
*/
.search-suggestion {
padding: 5px;
padding: 5px;
}
.search-suggestion-options {
font-size: 0.9em;
padding-top: 2px;
font-size: 0.9em;
padding-top: 2px;
}
/*
BOOTSTRAP Hacks
*/
@media (min-width: 1300px) {
.container {
max-width: 1350px;
}
.container {
max-width: 1350px;
}
}
/* for small devices */
@media (max-width: 575.98px) {
#jsmediaManagerButton,
#jscategoryButton,
#jsdescriptionButton {
width: 100%;
text-align: left;
}
#jsmediaManagerButton,
#jscategoryButton,
#jsdescriptionButton {
width: 100%;
text-align: left;
}
}
code {
padding: 3px 5px 2px;
margin: 0 1px;
background: #eaeaea;
background: rgba(0,0,0,.07);
color: #444;
padding: 3px 5px 2px;
margin: 0 1px;
background: #eaeaea;
background: rgba(0, 0, 0, .07);
color: #444;
}
.list-group-sortable {
cursor: pointer;
cursor: pointer;
}
@ -89,235 +101,238 @@ code {
*/
#dashboard ul.list-group.list-group-striped li {
border: none;
word-break: break-word;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
border: none;
word-break: break-word;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
#dashboard ul.list-group.list-group-striped li:nth-of-type(even) {
background: #f1f1f1;
background: #f1f1f1;
}
#dashboard div.quick-links-icons {
font-size: 3em;
width: 100%;
font-size: 3em;
width: 100%;
}
#dashboard a.quick-links {
color: #777;
color: #777;
}
#dashboard a.quick-links:hover {
text-decoration: none;
color: #4586d4;
text-decoration: none;
color: #4586d4;
}
#hello-message {
padding: 10px 0;
color: #777;
margin-bottom: 20px;
padding: 10px 0;
color: #777;
margin-bottom: 20px;
}
#hello-message span.oi {
top: 3px;
top: 3px;
}
.ct-series-a .ct-line {
/* Set the colour of this series line */
stroke: #4a90e2;
/* Control the thikness of your lines */
stroke-width: 2px;
/* Create a dashed line with a pattern */
/* Set the colour of this series line */
stroke: #4a90e2;
/* Control the thikness of your lines */
stroke-width: 2px;
/* Create a dashed line with a pattern */
}
.ct-series-a .ct-point {
/* Colour of your points */
stroke: #4a90e2;
/* Size of your points */
stroke-width: 8px;
/* Colour of your points */
stroke: #4a90e2;
/* Size of your points */
stroke-width: 8px;
}
/*
ALERT
*/
#alert {
display: none;
position: fixed;
text-align: center;
border-radius: 0px;
border: 0;
z-index: 1000;
bottom: 0;
right: 0;
margin: 0;
display: none;
position: fixed;
text-align: center;
border-radius: 0px;
border: 0;
z-index: 1000;
bottom: 0;
right: 0;
margin: 0;
}
.alert-success {
background-color: #4586d4;
border-left: 6px solid #abd1ff !important;
color: #ffffff;
background-color: #4586d4;
border-left: 6px solid #abd1ff !important;
color: #ffffff;
}
.alert-danger {
background-color: #d44545;
border-left: 6px solid #ff9c9c !important;
color: #ffffff;
background-color: #d44545;
border-left: 6px solid #ff9c9c !important;
color: #ffffff;
}
/*
PLUGINS
*/
.plugin-form label {
display: block;
margin-top: 1rem !important;
display: block;
margin-top: 1rem !important;
}
.plugin-form input[type="text"],
.plugin-form textarea,
.plugin-form select {
display: block;
width: 100%;
padding: .375rem .75rem;
font-size: 1rem;
line-height: 1.5;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: .25rem;
transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
display: block;
width: 100%;
padding: .375rem .75rem;
font-size: 1rem;
line-height: 1.5;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: .25rem;
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
.plugin-form textarea {
min-height: 120px;
min-height: 120px;
}
.plugin-form span.tip {
display: block;
font-size: 80%;
font-weight: 400;
margin-top: .25rem;
color: #6c757d !important;
display: block;
font-size: 80%;
font-weight: 400;
margin-top: .25rem;
color: #6c757d !important;
}
/*
Manage > Content
*/
td.child {
padding-left: 30px;
padding-left: 30px;
}
/*
Manage > New Content
*/
#jseditor {
background: #fff;
padding: 10px 5% !important;
font-size: 16px;
line-height: 1.5em;
border: 1px solid #ced4da;
background: #fff;
padding: 10px 5% !important;
font-size: 16px;
line-height: 1.5em;
border: 1px solid #ced4da;
}
#jseditorSidebar {
display: none;
height: calc(100% - 45px);
width: 50%;
max-width: 350px;
position: absolute;
z-index: 50;
top: 45px;
right: 15px;
background-color: #fff;
overflow-x: hidden;
transition: 0.5s;
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
border-top: 1px solid #ccc;
display: none;
height: calc(100% - 45px);
width: 50%;
max-width: 350px;
position: absolute;
z-index: 50;
top: 45px;
right: 15px;
background-color: #fff;
overflow-x: hidden;
transition: 0.5s;
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
border-top: 1px solid #ccc;
}
@media (max-width: 575.98px) {
#jseditorSidebar {
width: 100%;
max-width: 100%;
right: 0;
}
#editorToolbarRight button {
font-size: 0px !important;
}
#editorToolbarRight button span {
font-size: 16px !important;
}
.contentTools .btn {
font-size: 0px !important;
margin-right: 5px;
}
.contentTools .btn span {
font-size: 16px !important;
}
#jseditorSidebar {
width: 100%;
max-width: 100%;
right: 0;
}
#editorToolbarRight button {
font-size: 0px !important;
}
#editorToolbarRight button span {
font-size: 16px !important;
}
.contentTools .btn {
font-size: 0px !important;
margin-right: 5px;
}
.contentTools .btn span {
font-size: 16px !important;
}
}
#jseditorSidebar nav {
background: #f3f3f3;
background: #f3f3f3;
}
#jseditorSidebar nav a {
color: #000;
color: #000;
}
#jseditorSidebar .nav-tabs .nav-link {
border: none;
border: none;
}
#jseditorSidebar .nav-link.active {
background: none;
border: none;
border-bottom: 3px solid #ccc;
background: none;
border: none;
border-bottom: 3px solid #ccc;
}
#jsshadow {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba(72,72,72,0.7);
z-index: 10;
display: none;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba(72, 72, 72, 0.7);
z-index: 10;
display: none;
}
img.profilePicture {
width: 30px;
height: 30px;
border-radius: 30px;
border: 1px solid #ccc;
width: 30px;
height: 30px;
border-radius: 30px;
border: 1px solid #ccc;
}
/* Switch button */
.switch-button {
font-size: 0.9em;
text-transform: uppercase;
cursor: pointer;
font-size: 0.9em;
text-transform: uppercase;
cursor: pointer;
}
.switch-icon-published {
color: #1cb11c;
color: #1cb11c;
}
.switch-icon-draft {
color: #b11c1c;
color: #b11c1c;
}
.switch-icon-unlisted,
.switch-icon-static,
.switch-icon-sticky {
color: #1c81b1;
color: #1c81b1;
}

View file

@ -20,9 +20,10 @@
), DOMAIN_ADMIN_THEME_CSS);
echo Theme::css(array(
'jquery.datetimepicker.min.css',
'jquery-ui.min.css',
'select2.min.css',
'select2-bootstrap4.min.css',
'token-autocomplete.css'
'tagsinput-revisited.min.css'
), DOMAIN_CORE_CSS);
?>
@ -33,8 +34,9 @@
echo Theme::jsSortable();
echo Theme::js(array(
'jquery.datetimepicker.full.min.js',
'jquery-ui.min.js',
'select2.full.min.js',
'token-autocomplete.js',
'tagsinput-revisited.min.js',
'functions.js',
'api.js'
), DOMAIN_CORE_JS, null);

View file

@ -15,7 +15,7 @@ function table($type) {
if ($type=='published') {
$list = $published;
if (empty($list)) {
echo '<p class="mt-4 text-muted">';
echo '<p class="text-muted p-4">';
echo $L->g('There are no pages at this moment.');
echo '</p>';
return false;
@ -23,7 +23,7 @@ function table($type) {
} elseif ($type=='draft') {
$list = $drafts;
if (empty($list)) {
echo '<p class="mt-4 text-muted">';
echo '<p class="text-muted p-4">';
echo $L->g('There are no draft pages at this moment.');
echo '</p>';
return false;
@ -31,7 +31,7 @@ function table($type) {
} elseif ($type=='scheduled') {
$list = $scheduled;
if (empty($list)) {
echo '<p class="mt-4 text-muted">';
echo '<p class="text-muted p-4">';
echo $L->g('There are no scheduled pages at this moment.');
echo '</p>';
return false;
@ -39,7 +39,7 @@ function table($type) {
} elseif ($type=='static') {
$list = $static;
if (empty($list)) {
echo '<p class="mt-4 text-muted">';
echo '<p class="text-muted p-4">';
echo $L->g('There are no static pages at this moment.');
echo '</p>';
return false;
@ -47,7 +47,7 @@ function table($type) {
} elseif ($type=='sticky') {
$list = $sticky;
if (empty($list)) {
echo '<p class="mt-4 text-muted">';
echo '<p class="text-muted p-4">';
echo $L->g('There are no sticky pages at this moment.');
echo '</p>';
return false;
@ -56,22 +56,7 @@ function table($type) {
$list = $autosave;
}
echo '
<table class="table mt-3">
<thead>
<tr>
<th class="border-0" scope="col">'.$L->g('Title').'</th>
';
if ($type=='published' || $type=='static' || $type=='sticky') {
echo '<th class="border-0 d-none d-lg-table-cell" scope="col">'.$L->g('URL').'</th>';
}
echo ' <th class="border-0 text-center d-sm-table-cell" scope="col">'.$L->g('Actions').'</th>
</tr>
</thead>
<tbody>
';
echo '<table class="table table-striped m-0"><tbody><tr></tr>';
if ( (ORDER_BY=='position') || $type=='static' ) {
foreach ($list as $pageKey) {
@ -156,10 +141,7 @@ function table($type) {
</div>
</td>';
if ($type=='published' || $type=='static' || $type=='sticky') {
$friendlyURL = Text::isEmpty($url->filters('page')) ? '/'.$page->key() : '/'.$url->filters('page').'/'.$page->key();
echo '<td class="pt-3 d-none d-lg-table-cell"><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
}
echo '<td class="pt-3 d-none d-lg-table-cell">'.$L->get('Category').': '.($page->category()?$page->category():$L->get('uncategorized')).'</td>';
echo '<td class="contentTools pt-3 text-center d-sm-table-cell">'.PHP_EOL;
if ($type=='published' || $type=='static' || $type=='sticky') {
@ -187,7 +169,7 @@ function table($type) {
?>
<!-- TABS -->
<ul class="nav nav-tabs" role="tablist">
<ul class="nav nav-tabs pl-3" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="pages-tab" data-toggle="tab" href="#pages" role="tab"><?php $L->p('Pages') ?></a>
</li>
@ -217,7 +199,7 @@ function table($type) {
<?php if (Paginator::numberOfPages() > 1): ?>
<!-- Paginator -->
<nav class="paginator">
<nav class="paginator pt-3">
<ul class="pagination flex-wrap justify-content-center">
<!-- First button -->

View file

@ -17,9 +17,9 @@ if (typeof editorGetContent != 'function') {
return $('#editor').val();
};
}
if (typeof editorInsertMedia != 'function') {
window.editorInsertMedia = function(filename){
$('#editor').val($('#editor').val()+'<img src="'+filename+'" alt="">');
if (typeof editorInsertContent != 'function') {
window.editorInsertContent = function(html){
$('#editor').val($('#editor').val()+html);
};
}
@ -57,7 +57,7 @@ function save(args) {
}
// Open the modal and store the current value
// The current value is store to recover it if the user click in the button "Cancel"
// The current value is store to recover it if the user click on the button "Cancel"
function openModal(fieldName) {
var value = $('#'+fieldName).val();
localStorage.setItem(fieldName, value);
@ -76,7 +76,7 @@ function closeModal(fieldName) {
// Provides Shortcuts
// The editor plugin need to call this function for the event "keydown"
function keypress(event) {
console.log(event);
logs(event);
// Shortcuts
// ------------------------------------------------------------------------
@ -84,7 +84,9 @@ function keypress(event) {
if ((event.ctrlKey || event.metaKey) && event.which == 83) {
var args = {
title: $('#title').val(),
content: editorGetContent()
content: editorGetContent(),
category: $('#category option:selected').val(),
tags: $('#tags').val()
}
save(args);
$('#btnSave').addClass('btn-primary-disabled').html('<?php $L->p('Saved') ?>');
@ -109,7 +111,9 @@ $(document).ready(function() {
$('#btnSave').on('click', function() {
var args = {
title: $('#title').val(),
content: editorGetContent()
content: editorGetContent(),
category: $('#category option:selected').val(),
tags: $('#tags').val()
}
save(args);
$(this).addClass('btn-primary-disabled').html('<?php $L->p('Saved') ?>');
@ -168,7 +172,7 @@ $(document).ready(function() {
});
$('#btnCancelFriendlyURL').on('click', function() {
closeModal('FriendlyURL');
closeModal('friendlyURL');
});
$('#btnGenURLFromTitle').on('click', function() {
@ -207,6 +211,19 @@ $(document).ready(function() {
closeModal('status');
});
// Modal SEO events
// ------------------------------------------------------------------------
$('#btnSaveSeo').on('click', function() {
var args = {
parent: $('#parent').val()
};
save(args);
});
$('#btnCancelSeo').on('click', function() {
closeModal('parent');
});
// Modal parent events
// ------------------------------------------------------------------------
$('#btnSaveParent').on('click', function() {
@ -319,8 +336,8 @@ $(document).ready(function() {
</div>
</div>
<div class="modal-footer modal-footer pl-2 pr-2 pt-1 pb-1">
<button id="btnCancelfriendlyURL" type="button" class="btn btn-cancel font-weight-bold mr-auto"><i class="fa fa-times"></i> Cancel</button>
<button id="btnSavefriendlyURL" type="button" class="btn btn-save font-weight-bold"><i class="fa fa-check"></i> Save</button>
<button id="btnCancelFriendlyURL" type="button" class="btn btn-cancel font-weight-bold mr-auto"><i class="fa fa-times"></i> Cancel</button>
<button id="btnSaveFriendlyURL" type="button" class="btn btn-save font-weight-bold"><i class="fa fa-check"></i> Save</button>
</div>
</div>
</div>
@ -449,8 +466,8 @@ $(document).ready(function() {
</div>
</div>
<div class="modal-footer modal-footer pl-2 pr-2 pt-1 pb-1">
<button type="button" class="btn btn-cancel font-weight-bold mr-auto" data-dismiss="modal"><i class="fa fa-times"></i> Cancel</button>
<button type="button" class="btn btn-save font-weight-bold"><i class="fa fa-check"></i> Save</button>
<button id="btnCancelSeo" type="button" class="btn btn-cancel font-weight-bold mr-auto" data-dismiss="modal"><i class="fa fa-times"></i> Cancel</button>
<button id="btnSaveSeo" type="button" class="btn btn-save font-weight-bold"><i class="fa fa-check"></i> Save</button>
</div>
</div>
</div>
@ -520,23 +537,23 @@ $(document).ready(function() {
<!-- Tags -->
<h6 class="mt-4 mb-2 pb-2 text-uppercase">Tags</h6>
<div id="tags"></div>
<input id="tags" name="tags" type="text" value="">
<script>
$(document).ready(function() {
let tokenAutocomplete = new TokenAutocomplete({
name: 'tags',
selector: '#tags',
noMatchesText: 'No matching results...',
minCharactersForSuggestion: 2,
initialSuggestions: [
<?php
foreach ($tags->db as $key=>$fields) {
echo '{value: "'.$key.'", text: "'.$fields['name'].'"},';
}
?>
]
$('#tags').tagsInput({
placeholder:'Add a tag',
delimiter:',',
removeWithBackspace:true,
'autocomplete': {
source: [
<?php
foreach ($tags->db as $key=>$fields) {
echo '"'.$fields['name'].'",';
}
?>
]
}
});
tokenAutocomplete.debug(true);
});
</script>
<!-- End Tags -->

View file

@ -0,0 +1,568 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); ?>
<div class="align-middle">
<div class="float-right mt-1">
<button type="submit" class="btn btn-primary btn-sm" name="save"><?php $L->p('Save') ?></button>
<a class="btn btn-secondary btn-sm" href="<?php echo HTML_PATH_ADMIN_ROOT.'dashboard' ?>" role="button"><?php $L->p('Cancel') ?></a>
</div>
<?php echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog')); ?>
</div>
<!-- Tabs -->
<nav>
<div class="nav nav-tabs pl-3" id="nav-tab" role="tablist">
<a class="nav-item nav-link active" id="nav-general-tab" data-toggle="tab" href="#general" role="tab" aria-controls="nav-general" aria-selected="false"><?php $L->p('General') ?></a>
<a class="nav-item nav-link" id="nav-advanced-tab" data-toggle="tab" href="#advanced" role="tab" aria-controls="nav-advanced" aria-selected="false"><?php $L->p('Advanced') ?></a>
<a class="nav-item nav-link" id="nav-seo-tab" data-toggle="tab" href="#seo" role="tab" aria-controls="nav-seo" aria-selected="false"><?php $L->p('SEO') ?></a>
<a class="nav-item nav-link" id="nav-social-tab" data-toggle="tab" href="#social" role="tab" aria-controls="nav-social" aria-selected="false"><?php $L->p('Social Networks') ?></a>
<a class="nav-item nav-link" id="nav-images-tab" data-toggle="tab" href="#images" role="tab" aria-controls="nav-images" aria-selected="false"><?php $L->p('Images') ?></a>
<a class="nav-item nav-link" id="nav-language-tab" data-toggle="tab" href="#language" role="tab" aria-controls="nav-language" aria-selected="false"><?php $L->p('Language') ?></a>
<a class="nav-item nav-link" id="nav-custom-fields-tab" data-toggle="tab" href="#custom-fields" role="tab" aria-controls="nav-custom-fields" aria-selected="false"><?php $L->p('Custom fields') ?></a>
<a class="nav-item nav-link" id="nav-logo-tab" data-toggle="tab" href="#logo" role="tab" aria-controls="nav-logo" aria-selected="false"><?php $L->p('Logo') ?></a>
</div>
</nav>
<!-- End Tabs -->
<div class="tab-content" id="myTabContent">
<!-- General tab -->
<div class="tab-pane fade show active pt-1 pb-1 pl-3 pr-3" id="general" role="tabpanel" aria-labelledby="general-tab">
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Site')));
echo Bootstrap::formInputText(array(
'name'=>'title',
'label'=>$L->g('Site title'),
'value'=>$site->title(),
'tip'=>$L->g('use-this-field-to-name-your-site')
));
echo Bootstrap::formInputText(array(
'name'=>'slogan',
'label'=>$L->g('Site slogan'),
'value'=>$site->slogan(),
'tip'=>$L->g('use-this-field-to-add-a-catchy-phrase')
));
echo Bootstrap::formInputText(array(
'name'=>'description',
'label'=>$L->g('Site description'),
'value'=>$site->description(),
'tip'=>$L->g('you-can-add-a-site-description-to-provide')
));
echo Bootstrap::formInputText(array(
'name'=>'footer',
'label'=>$L->g('Footer text'),
'value'=>$site->footer(),
'tip'=>$L->g('you-can-add-a-small-text-on-the-bottom')
));
echo Bootstrap::formTitle(array('title'=>$L->g('Content')));
echo Bootstrap::formSelect(array(
'name'=>'itemsPerPage',
'label'=>$L->g('Items per page'),
'options'=>array('1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8', '-1'=>$L->g('All content')),
'selected'=>$site->itemsPerPage(),
'tip'=>$L->g('Number of items to show per page')
));
echo Bootstrap::formSelect(array(
'name'=>'orderBy',
'label'=>$L->g('Order content by'),
'options'=>array('date'=>$L->g('Date'),'position'=>$L->g('Position')),
'selected'=>$site->orderBy(),
'tip'=>$L->g('order-the-content-by-date-to-build-a-blog')
));
?>
</div>
<!-- End General tab -->
<!-- Advanced tab -->
<div class="tab-pane fade pt-1 pb-1 pl-3 pr-3" id="advanced" role="tabpanel" aria-labelledby="advanced-tab">
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Page content')));
echo Bootstrap::formSelect(array(
'name'=>'markdownParser',
'label'=>$L->g('Markdown parser'),
'options'=>array('true'=>$L->g('Enabled'), 'false'=>$L->g('Disabled')),
'selected'=>($site->markdownParser()?'true':'false'),
'tip'=>$L->g('Enable the markdown parser for the content of the page.')
));
echo Bootstrap::formTitle(array('title'=>$L->g('Predefined pages')));
// Homepage
try {
$options = array();
$homeKey = $site->homepage();
if (!empty($homeKey)) {
$home = new Page($homeKey);
$options = array($homeKey=>$home->title());
}
} catch (Exception $e) {
// continue
}
echo Bootstrap::formSelect(array(
'name'=>'homepage',
'label'=>$L->g('Homepage'),
'options'=>$options,
'selected'=>false,
'class'=>'',
'tip'=>$L->g('Returning page for the main page')
));
?>
<script>
$(document).ready(function() {
var homepage = $("#jshomepage").select2({
placeholder: "<?php $L->p('Start typing to see a list of suggestions.') ?>",
allowClear: true,
theme: "bootstrap4",
minimumInputLength: 2,
ajax: {
url: HTML_PATH_ADMIN_ROOT+"ajax/get-published",
data: function (params) {
var query = { query: params.term }
return query;
},
processResults: function (data) {
return data;
}
},
escapeMarkup: function(markup) {
return markup;
}
});
});
</script>
<?php
// Page not found 404
try {
$options = array();
$pageNotFoundKey = $site->pageNotFound();
if (!empty($pageNotFoundKey)) {
$pageNotFound = new Page($pageNotFoundKey);
$options = array($pageNotFoundKey=>$pageNotFound->title());
}
} catch (Exception $e) {
// continue
}
echo Bootstrap::formSelect(array(
'name'=>'pageNotFound',
'label'=>$L->g('Page not found'),
'options'=>$options,
'selected'=>false,
'class'=>'',
'tip'=>$L->g('Returning page when the page doesnt exist')
));
?>
<script>
$(document).ready(function() {
var homepage = $("#jspageNotFound").select2({
placeholder: "<?php $L->p('Start typing to see a list of suggestions.') ?>",
allowClear: true,
theme: "bootstrap4",
minimumInputLength: 2,
ajax: {
url: HTML_PATH_ADMIN_ROOT+"ajax/get-published",
data: function (params) {
var query = { query: params.term }
return query;
},
processResults: function (data) {
return data;
}
},
escapeMarkup: function(markup) {
return markup;
}
});
});
</script>
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Email account settings')));
echo Bootstrap::formInputText(array(
'name'=>'emailFrom',
'label'=>$L->g('Sender email'),
'value'=>$site->emailFrom(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('Emails will be sent from this address')
));
echo Bootstrap::formTitle(array('title'=>$L->g('Autosave')));
echo Bootstrap::formInputText(array(
'name'=>'autosaveInterval',
'label'=>$L->g('Interval'),
'value'=>$site->autosaveInterval(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('Number in minutes for every execution of autosave')
));
echo Bootstrap::formTitle(array('title'=>$L->g('Site URL')));
echo Bootstrap::formInputText(array(
'name'=>'url',
'label'=>'URL',
'value'=>$site->url(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('full-url-of-your-site'),
'placeholder'=>'https://'
));
echo Bootstrap::formTitle(array('title'=>$L->g('URL Filters')));
echo Bootstrap::formInputText(array(
'name'=>'uriPage',
'label'=>$L->g('Pages'),
'value'=>$site->uriFilters('page'),
'class'=>'',
'placeholder'=>'',
'tip'=>DOMAIN_PAGES
));
echo Bootstrap::formInputText(array(
'name'=>'uriTag',
'label'=>$L->g('Tags'),
'value'=>$site->uriFilters('tag'),
'class'=>'',
'placeholder'=>'',
'tip'=>DOMAIN_TAGS
));
echo Bootstrap::formInputText(array(
'name'=>'uriCategory',
'label'=>$L->g('Category'),
'value'=>$site->uriFilters('category'),
'class'=>'',
'placeholder'=>'',
'tip'=>DOMAIN_CATEGORIES
));
echo Bootstrap::formInputText(array(
'name'=>'uriBlog',
'label'=>$L->g('Blog'),
'value'=>$site->uriFilters('blog'),
'class'=>'',
'placeholder'=>'',
'tip'=>DOMAIN.$site->uriFilters('blog'),
'disabled'=>Text::isEmpty($site->uriFilters('blog'))
));
?>
</div>
<!-- SEO tab -->
<div class="tab-pane fade" id="seo" role="tabpanel" aria-labelledby="seo-tab">
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Extreme friendly URL')));
echo Bootstrap::formSelect(array(
'name'=>'extremeFriendly',
'label'=>$L->g('Allow Unicode'),
'options'=>array('true'=>$L->g('Enabled'), 'false'=>$L->g('Disabled')),
'selected'=>($site->extremeFriendly()?'true':'false'),
'class'=>'',
'tip'=>$L->g('Allow unicode characters in the URL and some part of the system.')
));
echo Bootstrap::formTitle(array('title'=>$L->g('Title formats')));
echo Bootstrap::formInputText(array(
'name'=>'titleFormatHomepage',
'label'=>$L->g('Homepage'),
'value'=>$site->titleFormatHomepage(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('Variables allowed').' <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>',
'placeholder'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'titleFormatPages',
'label'=>$L->g('Pages'),
'value'=>$site->titleFormatPages(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('Variables allowed').' <code>{{page-title}}</code> <code>{{page-description}}</code> <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>',
'placeholder'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'titleFormatCategory',
'label'=>$L->g('Category'),
'value'=>$site->titleFormatCategory(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('Variables allowed').' <code>{{category-name}}</code> <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>',
'placeholder'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'titleFormatTag',
'label'=>$L->g('Tag'),
'value'=>$site->titleFormatTag(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('Variables allowed').' <code>{{tag-name}}</code> <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>',
'placeholder'=>''
));
?>
</div>
<!-- Social Network tab -->
<div class="tab-pane fade" id="social" role="tabpanel" aria-labelledby="social-tab">
<?php
echo Bootstrap::formInputText(array(
'name'=>'twitter',
'label'=>'Twitter',
'value'=>$site->twitter(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'facebook',
'label'=>'Facebook',
'value'=>$site->facebook(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'codepen',
'label'=>'CodePen',
'value'=>$site->codepen(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'instagram',
'label'=>'Instagram',
'value'=>$site->instagram(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'gitlab',
'label'=>'GitLab',
'value'=>$site->gitlab(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'github',
'label'=>'GitHub',
'value'=>$site->github(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'linkedin',
'label'=>'LinkedIn',
'value'=>$site->linkedin(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'xing',
'label'=>'Xing',
'value'=>$site->xing(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'mastodon',
'label'=>'Mastodon',
'value'=>$site->mastodon(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'dribbble',
'label'=>'Dribbble',
'value'=>$site->dribbble(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
echo Bootstrap::formInputText(array(
'name'=>'vk',
'label'=>'VK',
'value'=>$site->vk(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
?>
</div>
<!-- Images tab -->
<div class="tab-pane fade" id="images" role="tabpanel" aria-labelledby="images-tab">
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Thumbnails')));
echo Bootstrap::formInputText(array(
'name'=>'thumbnailWidth',
'label'=>$L->g('Width'),
'value'=>$site->thumbnailWidth(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('Thumbnail width in pixels')
));
echo Bootstrap::formInputText(array(
'name'=>'thumbnailHeight',
'label'=>$L->g('Height'),
'value'=>$site->thumbnailHeight(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('Thumbnail height in pixels')
));
echo Bootstrap::formInputText(array(
'name'=>'thumbnailQuality',
'label'=>$L->g('Quality'),
'value'=>$site->thumbnailQuality(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('Thumbnail quality in percentage')
));
?>
</div>
<!-- Timezone and language tab -->
<div class="tab-pane fade" id="language" role="tabpanel" aria-labelledby="language-tab">
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Language and timezone')));
echo Bootstrap::formSelect(array(
'name'=>'language',
'label'=>$L->g('Language'),
'options'=>$L->getLanguageList(),
'selected'=>$site->language(),
'class'=>'',
'tip'=>$L->g('select-your-sites-language')
));
echo Bootstrap::formSelect(array(
'name'=>'timezone',
'label'=>$L->g('Timezone'),
'options'=>Date::timezoneList(),
'selected'=>$site->timezone(),
'class'=>'',
'tip'=>$L->g('select-a-timezone-for-a-correct')
));
echo Bootstrap::formInputText(array(
'name'=>'locale',
'label'=>$L->g('Locale'),
'value'=>$site->locale(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('with-the-locales-you-can-set-the-regional-user-interface')
));
echo Bootstrap::formTitle(array('title'=>$L->g('Date and time formats')));
echo Bootstrap::formInputText(array(
'name'=>'dateFormat',
'label'=>$L->g('Date format'),
'value'=>$site->dateFormat(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('Current format').': '.Date::current($site->dateFormat())
));
?>
</div>
<!-- Custom fields -->
<div class="tab-pane fade" id="custom-fields" role="tabpanel" aria-labelledby="custom-fields-tab">
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Custom fields')));
echo Bootstrap::formTextarea(array(
'name'=>'customFields',
'label'=>'JSON Format',
'value'=>json_encode($site->customFields(), JSON_PRETTY_PRINT),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('define-custom-fields-for-the-content'),
'rows'=>15
));
?>
</div>
<!-- Site logo tab -->
<div class="tab-pane fade" id="logo" role="tabpanel" aria-labelledby="logo-tab">
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Site logo')));
?>
<div class="container">
<div class="row">
<div class="col-lg-4 col-sm-12 p-0 pr-2">
<div class="custom-file">
<input id="jssiteLogoInputFile" class="custom-file-input" type="file" name="inputFile">
<label for="jssiteLogoInputFile" class="custom-file-label"><?php $L->p('Upload image'); ?></label>
</div>
<button id="jsbuttonRemoveLogo" type="button" class="btn btn-primary w-100 mt-4 mb-4"><i class="fa fa-trash"></i><?php $L->p('Remove logo') ?></button>
</div>
<div class="col-lg-8 col-sm-12 p-0 text-center">
<img id="jssiteLogoPreview" class="img-fluid img-thumbnail" alt="Site logo preview" src="<?php echo ($site->logo()?DOMAIN_UPLOADS.$site->logo(false).'?version='.time():HTML_PATH_CORE_IMG.'default.svg') ?>" />
</div>
</div>
</div>
<script>
$("#jsbuttonRemoveLogo").on("click", function() {
bluditAjax.removeLogo();
$("#jssiteLogoPreview").attr("src", "<?php echo HTML_PATH_CORE_IMG.'default.svg' ?>");
});
$("#jssiteLogoInputFile").on("change", function() {
var formData = new FormData();
formData.append('tokenCSRF', tokenCSRF);
formData.append('inputFile', $(this)[0].files[0]);
$.ajax({
url: HTML_PATH_ADMIN_ROOT+"ajax/logo-upload",
type: "POST",
data: formData,
cache: false,
contentType: false,
processData: false
}).done(function(data) {
if (data.status==0) {
$("#jssiteLogoPreview").attr('src',data.absoluteURL+"?time="+Math.random());
} else {
showAlert(data.message);
}
});
});
</script>
</div>

View file

@ -1,18 +1,96 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); ?>
<?php echo Bootstrap::formOpen(array('id'=>'jsform', 'class'=>'tab-content')); ?>
<script>
// ============================================================================
// Variables for the view
// ============================================================================
// ============================================================================
// Functions for the view
// ============================================================================
// This function catch all key press
// Provide shortcuts for the view
function keypress(event) {
logs(event);
// Shortcuts
// ------------------------------------------------------------------------
// Ctrl+S or Command+S
if ((event.ctrlKey || event.metaKey) && event.which == 83) {
save();
$('#btnSave').addClass('btn-primary-disabled').html('<?php $L->p('Saved') ?>');
event.preventDefault();
return false;
}
$('#btnSave').removeClass('btn-primary-disabled').html('<?php $L->p('Save') ?>');
return true;
}
function save() {
var args = {}
// Get values from all inputs['text']
$('input[type=text]').each(function(){
var key = $(this).attr('name');
var value = $(this).val();
args[key] = value;
});
// Get values from all selects
$('select').each(function() {
var key = $(this).attr('name');
var value = $(this).val();
args[key] = value;
});
logs('Saving settings');
api.saveSettings(args).then(function() {
logs('Settings saved');
});
return true;
}
// ============================================================================
// Events for the view
// ============================================================================
$(document).ready(function() {
// Main interface events
// ------------------------------------------------------------------------
$(this).keydown(function(event){
keypress(event);
});
$('#btnSave').on('click', function() {
save();
$(this).addClass('btn-primary-disabled').html('<?php $L->p('Saved') ?>');
});
});
// ============================================================================
// Initlization for the view
// ============================================================================
$(document).ready(function() {
// nothing here yet
// how do you hang your toilet paper ? over or under ?
});
</script>
<div class="align-middle">
<div class="float-right mt-1">
<button type="submit" class="btn btn-primary btn-sm" name="save"><?php $L->p('Save') ?></button>
<button type="button" class="btn btn-primary btn-sm btn-primary-disabled" id="btnSave"><?php $L->p('Saved') ?></button>
<a class="btn btn-secondary btn-sm" href="<?php echo HTML_PATH_ADMIN_ROOT.'dashboard' ?>" role="button"><?php $L->p('Cancel') ?></a>
</div>
<?php echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog')); ?>
</div>
<!-- TABS -->
<nav class="mb-3">
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<!-- Tabs -->
<nav>
<div class="nav nav-tabs pl-3" id="nav-tab" role="tablist">
<a class="nav-item nav-link active" id="nav-general-tab" data-toggle="tab" href="#general" role="tab" aria-controls="nav-general" aria-selected="false"><?php $L->p('General') ?></a>
<a class="nav-item nav-link" id="nav-advanced-tab" data-toggle="tab" href="#advanced" role="tab" aria-controls="nav-advanced" aria-selected="false"><?php $L->p('Advanced') ?></a>
<a class="nav-item nav-link" id="nav-seo-tab" data-toggle="tab" href="#seo" role="tab" aria-controls="nav-seo" aria-selected="false"><?php $L->p('SEO') ?></a>
@ -23,18 +101,12 @@
<a class="nav-item nav-link" id="nav-logo-tab" data-toggle="tab" href="#logo" role="tab" aria-controls="nav-logo" aria-selected="false"><?php $L->p('Logo') ?></a>
</div>
</nav>
<!-- End Tabs -->
<?php
// Token CSRF
echo Bootstrap::formInputHidden(array(
'name'=>'tokenCSRF',
'value'=>$security->getTokenCSRF()
));
?>
<div class="tab-content" id="myTabContent">
<!-- General tab -->
<div class="tab-pane fade show active" id="general" role="tabpanel" aria-labelledby="general-tab">
<div class="tab-pane show active pt-1 pb-1 pl-3 pr-3" id="general" role="tabpanel" aria-labelledby="general-tab">
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Site')));
@ -42,8 +114,6 @@
'name'=>'title',
'label'=>$L->g('Site title'),
'value'=>$site->title(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('use-this-field-to-name-your-site')
));
@ -51,8 +121,6 @@
'name'=>'slogan',
'label'=>$L->g('Site slogan'),
'value'=>$site->slogan(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('use-this-field-to-add-a-catchy-phrase')
));
@ -60,8 +128,6 @@
'name'=>'description',
'label'=>$L->g('Site description'),
'value'=>$site->description(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('you-can-add-a-site-description-to-provide')
));
@ -69,16 +135,9 @@
'name'=>'footer',
'label'=>$L->g('Footer text'),
'value'=>$site->footer(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('you-can-add-a-small-text-on-the-bottom')
));
?>
</div>
<!-- Advanced tab -->
<div class="tab-pane fade" id="advanced" role="tabpanel" aria-labelledby="advanced-tab">
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Content')));
echo Bootstrap::formSelect(array(
@ -86,7 +145,6 @@
'label'=>$L->g('Items per page'),
'options'=>array('1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8', '-1'=>$L->g('All content')),
'selected'=>$site->itemsPerPage(),
'class'=>'',
'tip'=>$L->g('Number of items to show per page')
));
@ -95,23 +153,27 @@
'label'=>$L->g('Order content by'),
'options'=>array('date'=>$L->g('Date'),'position'=>$L->g('Position')),
'selected'=>$site->orderBy(),
'class'=>'',
'tip'=>$L->g('order-the-content-by-date-to-build-a-blog')
));
?>
</div>
<!-- End General tab -->
<!-- Advanced tab -->
<div class="tab-pane pt-1 pb-1 pl-3 pr-3" id="advanced" role="tabpanel" aria-labelledby="advanced-tab">
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Page content')));
echo Bootstrap::formSelect(array(
'name'=>'markdownParser',
'label'=>$L->g('Markdown parser'),
'options'=>array('true'=>$L->g('Enabled'), 'false'=>$L->g('Disabled')),
'selected'=>($site->markdownParser()?'true':'false'),
'tip'=>$L->g('Enable the markdown parser for the content of the page.')
));
echo Bootstrap::formTitle(array('title'=>$L->g('Predefined pages')));
// Homepage
try {
$options = array();
$homeKey = $site->homepage();
if (!empty($homeKey)) {
$home = new Page($homeKey);
$options = array($homeKey=>$home->title());
}
} catch (Exception $e) {
// continue
}
echo Bootstrap::formSelect(array(
'name'=>'homepage',
'label'=>$L->g('Homepage'),
@ -120,43 +182,7 @@
'class'=>'',
'tip'=>$L->g('Returning page for the main page')
));
?>
<script>
$(document).ready(function() {
var homepage = $("#jshomepage").select2({
placeholder: "<?php $L->p('Start typing to see a list of suggestions.') ?>",
allowClear: true,
theme: "bootstrap4",
minimumInputLength: 2,
ajax: {
url: HTML_PATH_ADMIN_ROOT+"ajax/get-published",
data: function (params) {
var query = { query: params.term }
return query;
},
processResults: function (data) {
return data;
}
},
escapeMarkup: function(markup) {
return markup;
}
});
});
</script>
<?php
// Page not found 404
try {
$options = array();
$pageNotFoundKey = $site->pageNotFound();
if (!empty($pageNotFoundKey)) {
$pageNotFound = new Page($pageNotFoundKey);
$options = array($pageNotFoundKey=>$pageNotFound->title());
}
} catch (Exception $e) {
// continue
}
echo Bootstrap::formSelect(array(
'name'=>'pageNotFound',
'label'=>$L->g('Page not found'),
@ -165,33 +191,7 @@
'class'=>'',
'tip'=>$L->g('Returning page when the page doesnt exist')
));
?>
<script>
$(document).ready(function() {
var homepage = $("#jspageNotFound").select2({
placeholder: "<?php $L->p('Start typing to see a list of suggestions.') ?>",
allowClear: true,
theme: "bootstrap4",
minimumInputLength: 2,
ajax: {
url: HTML_PATH_ADMIN_ROOT+"ajax/get-published",
data: function (params) {
var query = { query: params.term }
return query;
},
processResults: function (data) {
return data;
}
},
escapeMarkup: function(markup) {
return markup;
}
});
});
</script>
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Email account settings')));
echo Bootstrap::formInputText(array(
@ -226,17 +226,6 @@
'placeholder'=>'https://'
));
echo Bootstrap::formTitle(array('title'=>$L->g('Page content')));
echo Bootstrap::formSelect(array(
'name'=>'markdownParser',
'label'=>$L->g('Markdown parser'),
'options'=>array('true'=>$L->g('Enabled'), 'false'=>$L->g('Disabled')),
'selected'=>($site->markdownParser()?'true':'false'),
'class'=>'',
'tip'=>$L->g('Enable the markdown parser for the content of the page.')
));
echo Bootstrap::formTitle(array('title'=>$L->g('URL Filters')));
echo Bootstrap::formInputText(array(
@ -279,7 +268,7 @@
</div>
<!-- SEO tab -->
<div class="tab-pane fade" id="seo" role="tabpanel" aria-labelledby="seo-tab">
<div class="tab-pane pt-1 pb-1 pl-3 pr-3" id="seo" role="tabpanel" aria-labelledby="seo-tab">
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Extreme friendly URL')));
@ -337,8 +326,10 @@
</div>
<!-- Social Network tab -->
<div class="tab-pane fade" id="social" role="tabpanel" aria-labelledby="social-tab">
<div class="tab-pane pt-1 pb-1 pl-3 pr-3" id="social" role="tabpanel" aria-labelledby="social-tab">
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Social Networks')));
echo Bootstrap::formInputText(array(
'name'=>'twitter',
'label'=>'Twitter',
@ -441,7 +432,7 @@
</div>
<!-- Images tab -->
<div class="tab-pane fade" id="images" role="tabpanel" aria-labelledby="images-tab">
<div class="tab-pane pt-1 pb-1 pl-3 pr-3" id="images" role="tabpanel" aria-labelledby="images-tab">
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Thumbnails')));
@ -475,7 +466,7 @@
</div>
<!-- Timezone and language tab -->
<div class="tab-pane fade" id="language" role="tabpanel" aria-labelledby="language-tab">
<div class="tab-pane pt-1 pb-1 pl-3 pr-3" id="language" role="tabpanel" aria-labelledby="language-tab">
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Language and timezone')));
@ -520,7 +511,7 @@
</div>
<!-- Custom fields -->
<div class="tab-pane fade" id="custom-fields" role="tabpanel" aria-labelledby="custom-fields-tab">
<div class="tab-pane pt-1 pb-1 pl-3 pr-3" id="custom-fields" role="tabpanel" aria-labelledby="custom-fields-tab">
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Custom fields')));
@ -537,7 +528,7 @@
</div>
<!-- Site logo tab -->
<div class="tab-pane fade" id="logo" role="tabpanel" aria-labelledby="logo-tab">
<div class="tab-pane pt-1 pb-1 pl-3 pr-3" id="logo" role="tabpanel" aria-labelledby="logo-tab">
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Site logo')));
?>
@ -584,18 +575,3 @@
</script>
</div>
<?php echo Bootstrap::formClose(); ?>
<script>
// Open current tab after refresh page
$(function() {
$('a[data-toggle="tab"]').on('click', function(e) {
window.localStorage.setItem('activeTab', $(e.target).attr('href'));
});
var activeTab = window.localStorage.getItem('activeTab');
if (activeTab) {
$('#nav-tab a[href="' + activeTab + '"]').tab('show');
//window.localStorage.removeItem("activeTab");
}
});
</script>

View file

@ -112,6 +112,7 @@ include(PATH_HELPERS.'image.class.php');
include(PATH_HELPERS.'tcp.class.php');
include(PATH_HELPERS.'dom.class.php');
include(PATH_HELPERS.'cookie.class.php');
include(PATH_HELPERS.'bootstrap.class.php');
if (file_exists(PATH_KERNEL.'bludit.pro.php')) {
include(PATH_KERNEL.'bludit.pro.php');

6
bl-kernel/css/jquery-ui.min.css vendored Normal file
View file

@ -0,0 +1,6 @@
/*! jQuery UI - v1.12.1 - 2020-11-01
* http://jqueryui.com
* Includes: core.css, autocomplete.css, menu.css
* Copyright jQuery Foundation and other contributors; Licensed MIT */
.ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important;pointer-events:none}.ui-icon{display:inline-block;vertical-align:middle;margin-top:-.25em;position:relative;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-icon-block{left:50%;margin-left:-8px;display:block}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-autocomplete{position:absolute;top:0;left:0;cursor:default}.ui-menu{list-style:none;padding:0;margin:0;display:block;outline:0}.ui-menu .ui-menu{position:absolute}.ui-menu .ui-menu-item{margin:0;cursor:pointer;list-style-image:url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")}.ui-menu .ui-menu-item-wrapper{position:relative;padding:3px 1em 3px .4em}.ui-menu .ui-menu-divider{margin:5px 0;height:0;font-size:0;line-height:0;border-width:1px 0 0 0}.ui-menu .ui-state-focus,.ui-menu .ui-state-active{margin:-1px}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item-wrapper{padding-left:2em}.ui-menu .ui-icon{position:absolute;top:0;bottom:0;left:.2em;margin:auto 0}.ui-menu .ui-menu-icon{left:auto;right:0}

View file

@ -0,0 +1,123 @@
.tagsinput,
.tagsinput * {
box-sizing: border-box
}
.tagsinput {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
background: #fff;
font-family: sans-serif;
font-size: 14px;
line-height: 20px;
color: #6c757d;
padding: 5px 5px 0;
border: 1px solid #e6e6e6;
border-radius: 2px
}
.tagsinput.focus {
border-color: #ccc
}
.tagsinput .tag {
position: relative;
background: #6c757d;
display: block;
max-width: 100%;
word-wrap: break-word;
color: #fff;
padding: 5px 30px 5px 5px;
border-radius: 2px;
margin: 0 5px 5px 0
}
.tagsinput .tag .tag-remove {
position: absolute;
background: 0 0;
display: block;
width: 30px;
height: 30px;
top: 0;
right: 0;
cursor: pointer;
text-decoration: none;
text-align: center;
color: #ccc;
line-height: 30px;
padding: 0;
border: 0
}
.tagsinput .tag .tag-remove:after,
.tagsinput .tag .tag-remove:before {
background: #ccc;
position: absolute;
display: block;
width: 10px;
height: 2px;
top: 14px;
left: 10px;
content: ''
}
.tagsinput .tag .tag-remove:before {
-webkit-transform: rotateZ(45deg);
transform: rotateZ(45deg)
}
.tagsinput .tag .tag-remove:after {
-webkit-transform: rotateZ(-45deg);
transform: rotateZ(-45deg)
}
.tagsinput div {
-webkit-box-flex: 1;
-webkit-flex-grow: 1;
-ms-flex-positive: 1;
flex-grow: 1
}
.tagsinput div input {
background: 0 0;
display: block;
width: 100%;
font-size: 14px;
line-height: 20px;
padding: 5px;
border: 0;
margin: 0 5px 5px 0
}
.tagsinput div input.error {
color: #ccc
}
.tagsinput div input::-ms-clear {
display: none
}
.tagsinput div input::-webkit-input-placeholder {
color: #ccc;
opacity: 1
}
.tagsinput div input:-moz-placeholder {
color: #ccc;
opacity: 1
}
.tagsinput div input::-moz-placeholder {
color: #ccc;
opacity: 1
}
.tagsinput div input:-ms-input-placeholder {
color: #ccc;
opacity: 1
}

View file

@ -647,8 +647,6 @@ function editSettings($args) {
'notes'=>''
));
// Create alert
Alert::set($L->g('The changes have been saved'));
return true;
}

View file

@ -2,6 +2,74 @@
class Bootstrap {
public static function formInputText($args)
{
$name = $args['name'];
$id = isset($args['id'])?$args['id']:$name;
$disabled = empty($args['disabled'])?'':'disabled';
$readonly = empty($args['readonly'])?'':'readonly';
$placeholder = isset($args['placeholder'])?$args['placeholder']:'';
$value = isset($args['value'])?$args['value']:'';
$type = isset($args['type'])?$args['type']:'text';
$tip = '';
if (isset($args['tip'])) {
$tip = '<small class="form-text text-muted">'.$args['tip'].'</small>';
}
$label = '';
if (isset($args['label'])) {
$label = '<label for="'.$id.'" class="col-sm-2 col-form-label">'.$args['label'].'</label>';
}
$class = 'form-control';
if (isset($args['class'])) {
$class = $class.' '.$args['class'];
}
return <<<EOF
<div class="form-group row">
$label
<div class="col-sm-10">
<input class="$class" id="$id" name="$name" value="$value" placeholder="$placeholder" type="$type" $disabled $readonly>
$tip
</div>
</div>
EOF;
}
public static function formSelect($args)
{
$name = $args['name'];
$id = isset($args['id'])?$args['id']:$name;
$value = isset($args['value'])?$args['value']:'';
$class = 'custom-select';
if (isset($args['class'])) {
$class = $class.' '.$args['class'];
}
$html = '<div class="form-group row">';
if (isset($args['label'])) {
$html .= '<label for="'.$id.'" class="col-sm-2 col-form-label">'.$args['label'].'</label>';
}
$html .= '<div class="col-sm-10">';
$html .= '<select id="'.$id.'" name="'.$name.'" class="'.$class.'">';
foreach ($args['options'] as $key=>$value) {
$html .= '<option '.(($key==$args['selected'])?'selected':'').' value="'.$key.'">'.$value.'</option>';
}
$html .= '</select>';
if (isset($args['tip'])) {
$html .= '<small class="form-text text-muted">'.$args['tip'].'</small>';
}
$html .= '</div>';
$html .= '</div>';
return $html;
}
// -- OLD --------
public static function modal($args) {
$buttonSecondary = $args['buttonSecondary'];
@ -221,49 +289,7 @@ EOF;
return $html;
}
public static function formInputText($args)
{
$name = $args['name'];
$disabled = empty($args['disabled'])?'':'disabled';
$readonly = empty($args['readonly'])?'':'readonly';
$placeholder = isset($args['placeholder'])?$args['placeholder']:'';
$value = isset($args['value'])?$args['value']:'';
$id = 'js'.$name;
if (isset($args['id'])) {
$id = $args['id'];
}
$tip = '';
if (isset($args['tip'])) {
$tip = '<small class="form-text text-muted">'.$args['tip'].'</small>';
}
$label = '';
if (isset($args['label'])) {
$label = '<label for="'.$id.'" class="col-sm-2 col-form-label">'.$args['label'].'</label>';
}
$class = 'form-control';
if (isset($args['class'])) {
$class = $class.' '.$args['class'];
}
$type = 'text';
if (isset($args['type'])) {
$type = $args['type'];
}
return <<<EOF
<div class="form-group row">
$label
<div class="col-sm-10">
<input class="$class" id="$id" name="$name" value="$value" placeholder="$placeholder" type="$type" $disabled $readonly>
$tip
</div>
</div>
EOF;
}
public static function formCheckbox($args)
{
@ -313,38 +339,7 @@ return <<<EOF
EOF;
}
public static function formSelect($args)
{
$id = 'js'.$args['name'];
if (isset($args['id'])) {
$id = $args['id'];
}
$class = 'custom-select';
if (isset($args['class'])) {
$class = $class.' '.$args['class'];
}
$html = '<div class="form-group row">';
if (isset($args['label'])) {
$html .= '<label for="'.$id.'" class="col-sm-2 col-form-label">'.$args['label'].'</label>';
}
$html .= '<div class="col-sm-10">';
$html .= '<select id="'.$id.'" name="'.$args['name'].'" class="'.$class.'">';
foreach ($args['options'] as $key=>$value) {
$html .= '<option '.(($key==$args['selected'])?'selected':'').' value="'.$key.'">'.$value.'</option>';
}
$html .= '</select>';
if (isset($args['tip'])) {
$html .= '<small class="form-text text-muted">'.$args['tip'].'</small>';
}
$html .= '</div>';
$html .= '</div>';
return $html;
}
public static function formSelectBlock($args)
{

View file

@ -1,89 +1,113 @@
class API {
constructor(apiURL, apiToken, apiAuth) {
this.apiURL = "http://localhost:9000/api/";
this.body = {
token: '45643a4071fad6a12261bb0763550feb',
authentication: '18a8410f0043d004c2e87f404170e112'
}
}
constructor(apiURL, apiToken, apiAuth) {
this.apiURL = "http://localhost:9000/api/";
this.body = {
token: '45643a4071fad6a12261bb0763550feb',
authentication: '18a8410f0043d004c2e87f404170e112'
}
}
async createPage(args) {
var url = this.apiURL+"pages";
var body = Object.assign({}, this.body, args);
try {
var response = await fetch(url, {
credentials: "same-origin",
method: "POST",
body: JSON.stringify(body),
headers: new Headers({
"Content-Type": "application/json"
})
});
var json = await response.json();
return json.data.key;
}
catch (err) {
console.log(err);
return true;
}
}
async createPage(args) {
var url = this.apiURL + "pages";
var body = Object.assign({}, this.body, args);
try {
var response = await fetch(url, {
credentials: "same-origin",
method: "POST",
body: JSON.stringify(body),
headers: new Headers({
"Content-Type": "application/json"
})
});
var json = await response.json();
return json.data.key;
} catch (err) {
console.log(err);
return true;
}
}
/*
Save page fields
/*
Save page fields
$args['pageKey'] string Page key for the page to edit
$args array Arguments can be any of the fields from a page
$args['pageKey'] string Page key for the page to edit
$args array Arguments can be any of the fields from a page
returns string New page key
*/
async savePage(args) {
var url = this.apiURL+"pages/"+args['pageKey'];
var body = Object.assign({}, this.body, args);
try {
var response = await fetch(url, {
credentials: "same-origin",
method: "PUT",
body: JSON.stringify(body),
headers: new Headers({
"Content-Type": "application/json"
})
});
var json = await response.json();
return json.data.key;
}
catch (err) {
console.log(err);
return true;
}
}
returns string New page key
*/
async savePage(args) {
var url = this.apiURL + "pages/" + args['pageKey'];
var body = Object.assign({}, this.body, args);
try {
var response = await fetch(url, {
credentials: "same-origin",
method: "PUT",
body: JSON.stringify(body),
headers: new Headers({
"Content-Type": "application/json"
})
});
var json = await response.json();
return json.data.key;
} catch (err) {
console.log(err);
return true;
}
}
/*
Generates unique slug text for the a page
/*
Generates unique slug text for the a page
$args['pageKey'] string Page key for the page to generate the slug url
$args['text'] string Text that you want to generate the slug url
$args['parentKey'] string Parent page key if the page has one, if not empty string
$args['pageKey'] string Page key for the page to generate the slug url
$args['text'] string Text that you want to generate the slug url
$args['parentKey'] string Parent page key if the page has one, if not empty string
returns string Slug text
*/
async friendlyURL(args) {
var url = this.apiURL+"helper/friendly-url/";
var parameters = "?token="+this.body.token+"&authentication="+this.body.authentication;
parameters = parameters+"&pageKey="+args['pageKey'];
parameters = parameters+"&text="+args['text'];
parameters = parameters+"&parentKey="+args['parentKey'];
try {
const response = await fetch(url+parameters, {
method: "GET"
});
var json = await response.json();
return json.data;
}
catch (err) {
console.log(err);
return true;
}
}
returns string Slug text
*/
async friendlyURL(args) {
var url = this.apiURL + "helper/friendly-url/";
var parameters = "?token=" + this.body.token + "&authentication=" + this.body.authentication;
parameters = parameters + "&pageKey=" + args['pageKey'];
parameters = parameters + "&text=" + args['text'];
parameters = parameters + "&parentKey=" + args['parentKey'];
try {
const response = await fetch(url + parameters, {
method: "GET"
});
var json = await response.json();
return json.data;
} catch (err) {
console.log(err);
return true;
}
}
}
/*
Save settings
$args array Arguments can be any of the fields from settings
returns array
*/
async saveSettings(args) {
var url = this.apiURL + "settings";
var body = Object.assign({}, this.body, args);
try {
var response = await fetch(url, {
credentials: "same-origin",
method: "PUT",
body: JSON.stringify(body),
headers: new Headers({
"Content-Type": "application/json"
})
});
var json = await response.json();
return json.data;
} catch (err) {
console.log(err);
return true;
}
}
}

1
bl-kernel/js/jquery-ui.min.js vendored Normal file

File diff suppressed because one or more lines are too long

30
bl-kernel/js/tagsinput-revisited.min.js vendored Normal file
View file

@ -0,0 +1,30 @@
/* jQuery Tags Input Revisited Plugin
https://www.jqueryscript.net/form/Tags-Input-Autocomplete.html
* Copyright (c) Krzysztof Rusnarczyk
* Licensed under the MIT license */
! function(a) { var b = [],
c = [],
d = [];
a.fn.addTag = function(g, h) { return h = jQuery.extend({ focus: !1, callback: !0 }, h), this.each(function() { var i = a(this).attr("id"),
j = a(this).val().split(e(b[i])); "" === j[0] && (j = []), g = jQuery.trim(g); var k = c[i]; if (k.whitelist && k.whitelist.indexOf(g) === -1) return !1; if (c[i].unique && a(this).tagExist(g) || !f(g, c[i], j, b[i])) return a("#" + i + "_tag").addClass("error"), !1; if (a("<span>", { class: "tag" }).append(a("<span>", { class: "tag-text" }).text(g), a("<button>", { class: "tag-remove" }).click(function() { return a("#" + i).removeTag(encodeURI(g)) })).insertBefore("#" + i + "_addTag"), j.push(g), a("#" + i + "_tag").val(""), h.focus ? a("#" + i + "_tag").focus() : a("#" + i + "_tag").blur(), a.fn.tagsInput.updateTagsField(this, j), h.callback && d[i] && d[i].onAddTag) { var l = d[i].onAddTag;
l.call(this, this, g) } if (d[i] && d[i].onChange) { var l = (j.length, d[i].onChange);
l.call(this, this, g) } }), !1 }, a.fn.removeTag = function(c) { return c = decodeURI(c), this.each(function() { var f = a(this).attr("id"),
g = a(this).val().split(e(b[f]));
a("#" + f + "_tagsinput .tag").remove(); var h = ""; for (i = 0; i < g.length; ++i) g[i] != c && (h = h + e(b[f]) + g[i]); if (a.fn.tagsInput.importTags(this, h), d[f] && d[f].onRemoveTag) { var j = d[f].onRemoveTag;
j.call(this, this, c) } }), !1 }, a.fn.tagExist = function(c) { var d = a(this).attr("id"),
f = a(this).val().split(e(b[d])); return jQuery.inArray(c, f) >= 0 }, a.fn.importTags = function(b) { var c = a(this).attr("id");
a("#" + c + "_tagsinput .tag").remove(), a.fn.tagsInput.importTags(this, b) }, a.fn.tagsInput = function(f) { var i = jQuery.extend({ interactive: !0, placeholder: "Add a tag", minChars: 0, maxChars: null, limit: null, validationPattern: null, width: "auto", height: "auto", autocomplete: null, hide: !0, delimiter: ",", unique: !0, removeWithBackspace: !0, whitelist: null }, f),
j = 0; return this.each(function() { if ("undefined" == typeof a(this).data("tagsinput-init")) { a(this).data("tagsinput-init", !0), i.hide && a(this).hide(); var f = a(this).attr("id");
f && !e(b[a(this).attr("id")]) || (f = a(this).attr("id", "tags" + (new Date).getTime() + ++j).attr("id")); var k = jQuery.extend({ pid: f, real_input: "#" + f, holder: "#" + f + "_tagsinput", input_wrapper: "#" + f + "_addTag", fake_input: "#" + f + "_tag" }, i);
b[f] = k.delimiter, c[f] = { minChars: i.minChars, maxChars: i.maxChars, limit: i.limit, validationPattern: i.validationPattern, unique: i.unique, whitelist: i.whitelist }, (i.onAddTag || i.onRemoveTag || i.onChange) && (d[f] = [], d[f].onAddTag = i.onAddTag, d[f].onRemoveTag = i.onRemoveTag, d[f].onChange = i.onChange); var l = a("<div>", { id: f + "_tagsinput", class: "tagsinput" }).append(a("<div>", { id: f + "_addTag" }).append(i.interactive ? a("<input>", { id: f + "_tag", class: "tag-input", value: "", placeholder: i.placeholder }) : null));
a(l).insertAfter(this), a(k.holder).css("width", i.width), a(k.holder).css("min-height", i.height), a(k.holder).css("height", i.height), "" !== a(k.real_input).val() && a.fn.tagsInput.importTags(a(k.real_input), a(k.real_input).val()), i.interactive && (a(k.fake_input).val(""), a(k.fake_input).data("pasted", !1), a(k.fake_input).on("focus", k, function(b) { a(k.holder).addClass("focus"), "" === a(this).val() && a(this).removeClass("error") }), a(k.fake_input).on("blur", k, function(b) { a(k.holder).removeClass("focus") }), null !== i.autocomplete && void 0 !== jQuery.ui.autocomplete ? (a(k.fake_input).autocomplete(i.autocomplete), a(k.fake_input).on("autocompleteselect", k, function(b, c) { return a(b.data.real_input).addTag(c.item.value, { focus: !0, unique: i.unique }), !1 }), a(k.fake_input).on("keypress", k, function(b) { g(b) && a(this).autocomplete("close") })) : a(k.fake_input).on("blur", k, function(b) { return a(b.data.real_input).addTag(a(b.data.fake_input).val(), { focus: !0, unique: i.unique }), !1 }), a(k.fake_input).on("keypress", k, function(b) { if (g(b)) return b.preventDefault(), a(b.data.real_input).addTag(a(b.data.fake_input).val(), { focus: !0, unique: i.unique }), !1 }), a(k.fake_input).on("paste", function() { a(this).data("pasted", !0) }), a(k.fake_input).on("input", k, function(b) { if (a(this).data("pasted")) { a(this).data("pasted", !1); var c = a(b.data.fake_input).val();
c = c.replace(/\n/g, ""), c = c.replace(/\s/g, ""); var d = h(b.data.delimiter, c); if (d.length > 1) { for (var e = 0; e < d.length; ++e) a(b.data.real_input).addTag(d[e], { focus: !0, unique: i.unique }); return !1 } } }), k.removeWithBackspace && a(k.fake_input).on("keydown", function(b) { if (8 == b.keyCode && "" === a(this).val()) { b.preventDefault(); var c = a(this).closest(".tagsinput").find(".tag:last > span").text(),
d = a(this).attr("id").replace(/_tag$/, "");
a("#" + d).removeTag(encodeURI(c)), a(this).trigger("focus") } }), a(k.fake_input).keydown(function(b) { jQuery.inArray(b.keyCode, [13, 37, 38, 39, 40, 27, 16, 17, 18, 225]) === -1 && a(this).removeClass("error") })) } }), this }, a.fn.tagsInput.updateTagsField = function(c, d) { var f = a(c).attr("id");
a(c).val(d.join(e(b[f]))) }, a.fn.tagsInput.importTags = function(c, e) { a(c).val(""); var f = a(c).attr("id"),
g = h(b[f], e); for (i = 0; i < g.length; ++i) a(c).addTag(g[i], { focus: !1, callback: !1 }); if (d[f] && d[f].onChange) { var j = d[f].onChange;
j.call(c, c, g) } }; var e = function(a) { return "undefined" == typeof a ? a : "string" == typeof a ? a : a[0] },
f = function(b, c, d, e) { var f = !0; return "" === b && (f = !1), b.length < c.minChars && (f = !1), null !== c.maxChars && b.length > c.maxChars && (f = !1), null !== c.limit && d.length >= c.limit && (f = !1), null === c.validationPattern || c.validationPattern.test(b) || (f = !1), "string" == typeof e ? b.indexOf(e) > -1 && (f = !1) : a.each(e, function(a, c) { return b.indexOf(c) > -1 && (f = !1), !1 }), f },
g = function(b) { var c = !1; return 13 === b.which || ("string" == typeof b.data.delimiter ? b.which === b.data.delimiter.charCodeAt(0) && (c = !0) : a.each(b.data.delimiter, function(a, d) { b.which === d.charCodeAt(0) && (c = !0) }), c) },
h = function(b, c) { if ("" === c) return []; if ("string" == typeof b) return c.split(b); var d = "∞",
e = c; return a.each(b, function(a, b) { e = e.split(b).join(d) }), e.split(d) } }(jQuery);