source: extensions/rv_autocomplete/suggestions.php @ 24491

Last change on this file since 24491 was 22304, checked in by rvelices, 12 years ago
File size: 1.0 KB
Line 
1<?php
2
3define('PHPWG_ROOT_PATH','../../');
4include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
5
6if (!defined('RVAC_ID')) {
7        set_status_header(501);
8        exit;
9}
10
11include_once( 'functions.inc.php' );
12
13$page['root_path'] = get_absolute_root_url(false);
14
15$data = rvac_get_index();
16
17if (isset($_GET['txt'])) {
18        foreach($data['src'] as $item)
19                echo implode("\t", $item)."\n";
20        exit;
21}
22
23
24$ds = str_replace(
25        array('\\/', '"q":', '"label":', '"value":', '"w":'),
26        array('/', 'q:', 'label:', 'value:', 'w:'),
27        json_encode($data['src']));
28$js = '$.extend(RVAC, {
29        dataSource:'.$ds.',
30        dataSourceAltLangIndex: '.$data['altLangIndex'].',
31        roots: '.json_encode($data['roots']).',
32        minForAltLang: 2,
33        stopLookingAfter: 80,
34        suggestions: 4,
35        maxSuggestions: 8,
36        minWeightForContextTrigger: 25
37});
38$.each(RVAC.dataSource, function(i,item) {
39        item.q = item.q || item.label.toLowerCase()
40});
41RVAC.start && RVAC.start();';
42
43header("Content-Type: application/javascript; charset=".get_pwg_charset());
44echo $js;
45
46file_put_contents(PHPWG_ROOT_PATH.rvac_get_data_file(), $js);
47?>
Note: See TracBrowser for help on using the repository browser.