Browse Source

Merge 682f6e9698 into d9b82195fe

pull/21/merge
Alexander V. Sergeyev 10 years ago
parent
commit
c0724c1051
3 changed files with 88 additions and 0 deletions
  1. +35
    -0
      cms/includes/ajaxprocess.inc.php
  2. +1
    -0
      cms/templates/admin/main.tpl
  3. +52
    -0
      static/js/admin_backend.js

+ 35
- 0
cms/includes/ajaxprocess.inc.php View File

@ -40,6 +40,41 @@ if(isset($_SESSION[$settings['session_prefix'].'user_id']))
if(isset($cache) && $cache->autoClear) $cache->clear();
}
break;
case 'get':
if(isset($_REQUEST['page']))
{
$table = Database::$db_settings['pages_table'];
$list = 'page';
}
elseif(isset($_REQUEST['category']))
{
$table = Database::$db_settings['pages_table'];
$list = 'category';
}
elseif(isset($_REQUEST['sections']))
{
$table = Database::$db_settings['menu_table'];
$list = 'section';
}
$term = addCslashes($_REQUEST['term'],'\%_');
if(isset($list) && isset($table))
{
$dbr = Database::$content->query('SELECT distinct '.$list.' FROM '.$table.' WHERE '.$list.' LIKE "%' .$term.'%"');
$i=0;
while($row=$dbr->fetch()){
if (!$row[$list]=="") $res[] = array("id"=>$i, "label"=>$row[$list], "value"=>$row[$list]);
$i++;
}
$res_list = json_encode($res);
echo $res_list;
if(isset($cache) && $cache->autoClear) $cache->clear();
}
break;
}
}
}


+ 1
- 0
cms/templates/admin/main.tpl View File

@ -8,6 +8,7 @@
<link href="<?php echo BOOTSTRAP_CSS; ?>" rel="stylesheet">
<link href="<?php echo STATIC_URL; ?>css/style_admin.css" rel="stylesheet">
<link href="<?php echo JQUERY_UI_CSS; ?>" rel="stylesheet">
<link rel="shortcut icon" href="<?php echo STATIC_URL; ?>img/favicon.png">
</head>


+ 52
- 0
static/js/admin_backend.js View File

@ -55,5 +55,57 @@ $('.modal').on('show.bs.modal', function (e) {
$insertField = $(e.relatedTarget).data('insert');
});
//Ajax autocompleate
function split( val ) {
return val.split( /,\s*/ );
}
function extractLast( term ) {
return split( term ).pop();
}
jQuery( 'input[name="page"],input[name="category"],input[name="link"]' ).autocomplete({
source: function( request, response ) {
var $list = this.element.attr("name");
if($list=='link') $list="page";
jQuery.getJSON( "./index.php?mode=ajaxprocess&action=get&"+$list+"=1", {
term: request.term
}, response );
}
});
jQuery( 'input[name="sections"]' ).autocomplete({
source: function( request, response ) {
var $list = this.element.attr("name");
jQuery.getJSON( "./index.php?mode=ajaxprocess&action=get&"+$list+"=1", {
term: extractLast( request.term )
}, response );
},
search: function() {
// custom minLength
var term = extractLast( this.value );
if ( term.length < 2 ) {
return false;
}
//console.log(term);
},
focus: function() {
// prevent value inserted on focus
return false;
},
select: function( event, ui ) {
var terms = split( this.value );
// remove the current input
terms.pop();
// add the selected item
terms.push( ui.item.value );
// add placeholder to get the comma-and-space at the end
terms.push( "" );
this.value = terms.join( ", " );
return false;
},
create: function(){
}
});
});

Loading…
Cancel
Save