Hashing posts and pages
This commit is contained in:
parent
696d49c9bc
commit
6772b41799
9
kernel/admin/themes/default/css/jquery.auto-complete.css
Executable file
9
kernel/admin/themes/default/css/jquery.auto-complete.css
Executable file
@ -0,0 +1,9 @@
|
||||
.autocomplete-suggestions {
|
||||
text-align: left; cursor: default; border: 1px solid #ccc; border-top: 0; background: #fff; box-shadow: -1px 1px 3px rgba(0,0,0,.1);
|
||||
|
||||
/* core styles should not be changed */
|
||||
position: absolute; display: none; z-index: 9999; max-height: 254px; overflow: hidden; overflow-y: auto; box-sizing: border-box;
|
||||
}
|
||||
.autocomplete-suggestion { position: relative; padding: 0 .6em; line-height: 23px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.02em; color: #333; }
|
||||
.autocomplete-suggestion b { font-weight: normal; color: #1f8dd6; }
|
||||
.autocomplete-suggestion.selected { background: #f0f0f0; }
|
@ -20,12 +20,14 @@
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="./css/default.css?version=<?php echo BLUDIT_VERSION ?>">
|
||||
<link rel="stylesheet" type="text/css" href="./css/jquery.datetimepicker.css?version=<?php echo BLUDIT_VERSION ?>">
|
||||
<link rel="stylesheet" type="text/css" href="./css/jquery.auto-complete.css?version=<?php echo BLUDIT_VERSION ?>">
|
||||
|
||||
<!-- Javascript -->
|
||||
<script charset="utf-8" src="./js/jquery.min.js?version=<?php echo BLUDIT_VERSION ?>"></script>
|
||||
<script charset="utf-8" src="./js/uikit/uikit.min.js?version=<?php echo BLUDIT_VERSION ?>"></script>
|
||||
<script charset="utf-8" src="./js/uikit/upload.min.js?version=<?php echo BLUDIT_VERSION ?>"></script>
|
||||
<script charset="utf-8" src="./js/jquery.datetimepicker.js?version=<?php echo BLUDIT_VERSION ?>"></script>
|
||||
<script charset="utf-8" src="./js/jquery.auto-complete.min.js?version=<?php echo BLUDIT_VERSION ?>"></script>
|
||||
|
||||
<!-- Plugins -->
|
||||
<?php Theme::plugins('adminHead') ?>
|
||||
|
@ -52,6 +52,28 @@ class HTML {
|
||||
echo $html;
|
||||
}
|
||||
|
||||
public static function formInputAutocomplete($args)
|
||||
{
|
||||
self::formInputText($args);
|
||||
|
||||
$script = '<script>
|
||||
$("input[name=\"'.$args['name'].'\"]").autoComplete({
|
||||
minChars: 1,
|
||||
source: function(term, suggest){
|
||||
term = term.toLowerCase();
|
||||
var choices = ['.$args['words'].'];
|
||||
var matches = [];
|
||||
for (i=0; i<choices.length; i++)
|
||||
if (~choices[i].toLowerCase().indexOf(term)) matches.push(choices[i]);
|
||||
suggest(matches);
|
||||
}
|
||||
});
|
||||
</script>';
|
||||
|
||||
echo $script;
|
||||
|
||||
}
|
||||
|
||||
public static function formInputPassword($args)
|
||||
{
|
||||
$args['type'] = 'password';
|
||||
|
3
kernel/admin/themes/default/js/jquery.auto-complete.min.js
vendored
Executable file
3
kernel/admin/themes/default/js/jquery.auto-complete.min.js
vendored
Executable file
@ -0,0 +1,3 @@
|
||||
// jQuery autoComplete v1.0.7
|
||||
// https://github.com/Pixabay/jQuery-autoComplete
|
||||
!function(e){e.fn.autoComplete=function(t){var o=e.extend({},e.fn.autoComplete.defaults,t);return"string"==typeof t?(this.each(function(){var o=e(this);"destroy"==t&&(e(window).off("resize.autocomplete",o.updateSC),o.off("blur.autocomplete focus.autocomplete keydown.autocomplete keyup.autocomplete"),o.data("autocomplete")?o.attr("autocomplete",o.data("autocomplete")):o.removeAttr("autocomplete"),e(o.data("sc")).remove(),o.removeData("sc").removeData("autocomplete"))}),this):this.each(function(){function t(e){var t=s.val();if(s.cache[t]=e,e.length&&t.length>=o.minChars){for(var a="",c=0;c<e.length;c++)a+=o.renderItem(e[c],t);s.sc.html(a),s.updateSC(0)}else s.sc.hide()}var s=e(this);s.sc=e('<div class="autocomplete-suggestions '+o.menuClass+'"></div>'),s.data("sc",s.sc).data("autocomplete",s.attr("autocomplete")),s.attr("autocomplete","off"),s.cache={},s.last_val="",s.updateSC=function(t,o){if(s.sc.css({top:s.offset().top+s.outerHeight(),left:s.offset().left,width:s.outerWidth()}),!t&&(s.sc.show(),s.sc.maxHeight||(s.sc.maxHeight=parseInt(s.sc.css("max-height"))),s.sc.suggestionHeight||(s.sc.suggestionHeight=e(".autocomplete-suggestion",s.sc).first().outerHeight()),s.sc.suggestionHeight))if(o){var a=s.sc.scrollTop(),c=o.offset().top-s.sc.offset().top;c+s.sc.suggestionHeight-s.sc.maxHeight>0?s.sc.scrollTop(c+s.sc.suggestionHeight+a-s.sc.maxHeight):0>c&&s.sc.scrollTop(c+a)}else s.sc.scrollTop(0)},e(window).on("resize.autocomplete",s.updateSC),s.sc.appendTo("body"),s.sc.on("mouseleave",".autocomplete-suggestion",function(){e(".autocomplete-suggestion.selected").removeClass("selected")}),s.sc.on("mouseenter",".autocomplete-suggestion",function(){e(".autocomplete-suggestion.selected").removeClass("selected"),e(this).addClass("selected")}),s.sc.on("mousedown",".autocomplete-suggestion",function(t){var a=e(this),c=a.data("val");return(c||a.hasClass("autocomplete-suggestion"))&&(s.val(c),o.onSelect(t,c,a),s.sc.hide()),!1}),s.on("blur.autocomplete",function(){try{over_sb=e(".autocomplete-suggestions:hover").length}catch(t){over_sb=0}over_sb?s.is(":focus")||setTimeout(function(){s.focus()},20):(s.last_val=s.val(),s.sc.hide(),setTimeout(function(){s.sc.hide()},350))}),o.minChars||s.on("focus.autocomplete",function(){s.last_val="\n",s.trigger("keyup.autocomplete")}),s.on("keydown.autocomplete",function(t){if((40==t.which||38==t.which)&&s.sc.html()){var a,c=e(".autocomplete-suggestion.selected",s.sc);return c.length?(a=40==t.which?c.next(".autocomplete-suggestion"):c.prev(".autocomplete-suggestion"),a.length?(c.removeClass("selected"),s.val(a.addClass("selected").data("val"))):(c.removeClass("selected"),s.val(s.last_val),a=0)):(a=40==t.which?e(".autocomplete-suggestion",s.sc).first():e(".autocomplete-suggestion",s.sc).last(),s.val(a.addClass("selected").data("val"))),s.updateSC(0,a),!1}if(27==t.which)s.val(s.last_val).sc.hide();else if(13==t.which||9==t.which){var c=e(".autocomplete-suggestion.selected",s.sc);c.length&&s.sc.is(":visible")&&(o.onSelect(t,c.data("val"),c),setTimeout(function(){s.sc.hide()},20))}}),s.on("keyup.autocomplete",function(a){if(!~e.inArray(a.which,[13,27,35,36,37,38,39,40])){var c=s.val();if(c.length>=o.minChars){if(c!=s.last_val){if(s.last_val=c,clearTimeout(s.timer),o.cache){if(c in s.cache)return void t(s.cache[c]);for(var l=1;l<c.length-o.minChars;l++){var i=c.slice(0,c.length-l);if(i in s.cache&&!s.cache[i].length)return void t([])}}s.timer=setTimeout(function(){o.source(c,t)},o.delay)}}else s.last_val=c,s.sc.hide()}})})},e.fn.autoComplete.defaults={source:0,minChars:3,delay:150,cache:1,menuClass:"",renderItem:function(e,t){t=t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");var o=new RegExp("("+t.split(" ").join("|")+")","gi");return'<div class="autocomplete-suggestion" data-val="'+e+'">'+e.replace(o,"<b>$1</b>")+"</div>"},onSelect:function(e,t,o){}}}(jQuery);
|
@ -77,12 +77,13 @@ echo '<div class="sidebar uk-width-large-2-10">';
|
||||
));
|
||||
|
||||
// Tags input
|
||||
HTML::formInputText(array(
|
||||
HTML::formInputAutocomplete(array(
|
||||
'name'=>'tags',
|
||||
'value'=>$_Page->tags(),
|
||||
'class'=>'uk-width-1-1 uk-form-large',
|
||||
'tip'=>$L->g('Write the tags separated by commas'),
|
||||
'label'=>$L->g('Tags')
|
||||
'label'=>$L->g('Tags'),
|
||||
'words'=>'"'.implode('", "', $dbTags->getAll()).'"'
|
||||
));
|
||||
|
||||
echo '</li>';
|
||||
|
@ -71,12 +71,13 @@ echo '<div class="sidebar uk-width-large-2-10">';
|
||||
));
|
||||
|
||||
// Tags input
|
||||
HTML::formInputText(array(
|
||||
HTML::formInputAutocomplete(array(
|
||||
'name'=>'tags',
|
||||
'value'=>$_Post->tags(),
|
||||
'class'=>'uk-width-1-1 uk-form-large',
|
||||
'tip'=>$L->g('Write the tags separated by commas'),
|
||||
'label'=>$L->g('Tags')
|
||||
'label'=>$L->g('Tags'),
|
||||
'words'=>'"'.implode('", "', $dbTags->getAll()).'"'
|
||||
));
|
||||
|
||||
echo '</li>';
|
||||
|
@ -64,12 +64,13 @@ echo '<div class="sidebar uk-width-large-2-10">';
|
||||
));
|
||||
|
||||
// Tags input
|
||||
HTML::formInputText(array(
|
||||
HTML::formInputAutocomplete(array(
|
||||
'name'=>'tags',
|
||||
'value'=>'',
|
||||
'class'=>'uk-width-1-1 uk-form-large',
|
||||
'tip'=>$L->g('Write the tags separated by commas'),
|
||||
'label'=>$L->g('Tags')
|
||||
'label'=>$L->g('Tags'),
|
||||
'words'=>'"'.implode('", "', $dbTags->getAll()).'"'
|
||||
));
|
||||
|
||||
echo '</li>';
|
||||
|
@ -64,12 +64,13 @@ echo '<div class="sidebar uk-width-large-2-10">';
|
||||
));
|
||||
|
||||
// Tags input
|
||||
HTML::formInputText(array(
|
||||
HTML::formInputAutocomplete(array(
|
||||
'name'=>'tags',
|
||||
'value'=>'',
|
||||
'class'=>'uk-width-1-1 uk-form-large',
|
||||
'tip'=>$L->g('Write the tags separated by commas'),
|
||||
'label'=>$L->g('Tags')
|
||||
'label'=>$L->g('Tags'),
|
||||
'words'=>'"'.implode('", "', $dbTags->getAll()).'"'
|
||||
));
|
||||
|
||||
echo '</li>';
|
||||
|
@ -14,6 +14,7 @@ class dbPages extends dbJSON
|
||||
'date'=> array('inFile'=>false, 'value'=>''),
|
||||
'position'=> array('inFile'=>false, 'value'=>0),
|
||||
'coverImage'=> array('inFile'=>false, 'value'=>''),
|
||||
'hash'=> array('inFile'=>false, 'value'=>'')
|
||||
);
|
||||
|
||||
function __construct()
|
||||
@ -75,6 +76,10 @@ class dbPages extends dbJSON
|
||||
}
|
||||
}
|
||||
|
||||
// Create Hash
|
||||
$serialize = serialize($dataForDb+$dataForFile);
|
||||
$dataForDb['hash'] = sha1($serialize);
|
||||
|
||||
// Make the directory. Recursive.
|
||||
if( Filesystem::mkdir(PATH_PAGES.$key, true) === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the directory '.PATH_PAGES.$key);
|
||||
@ -157,6 +162,10 @@ class dbPages extends dbJSON
|
||||
}
|
||||
}
|
||||
|
||||
// Create Hash
|
||||
$serialize = serialize($dataForDb+$dataForFile);
|
||||
$dataForDb['hash'] = sha1($serialize);
|
||||
|
||||
// Move the directory from old key to new key.
|
||||
if($newKey!==$args['key'])
|
||||
{
|
||||
|
@ -12,6 +12,7 @@ class dbPosts extends dbJSON
|
||||
'allowComments'=> array('inFile'=>false, 'value'=>false),
|
||||
'date'=> array('inFile'=>false, 'value'=>''),
|
||||
'coverImage'=> array('inFile'=>false, 'value'=>''),
|
||||
'hash'=> array('inFile'=>false, 'value'=>'')
|
||||
);
|
||||
|
||||
private $numberPosts = array(
|
||||
@ -158,6 +159,10 @@ class dbPosts extends dbJSON
|
||||
}
|
||||
}
|
||||
|
||||
// Create Hash
|
||||
$serialize = serialize($dataForDb+$dataForFile);
|
||||
$dataForDb['hash'] = sha1($serialize);
|
||||
|
||||
// Make the directory.
|
||||
if( Filesystem::mkdir(PATH_POSTS.$key) === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the directory '.PATH_POSTS.$key);
|
||||
|
Loading…
Reference in New Issue
Block a user