source: extensions/rv_autocomplete/main.inc.php @ 31176

Last change on this file since 31176 was 31029, checked in by rvelices, 10 years ago

fix bug on variants with quotes

File size: 2.3 KB
RevLine 
[22201]1<?php /*
2Plugin Name: RV autocomplete
[31029]3Version: 2.7.b
[22201]4Description: Autocompletes the quick search with albums, tags or custom suggestions
[22214]5Plugin URI: http://piwigo.org/ext/extension_view.php?eid=694
[22201]6Author: rvelices
7Author URI: http://www.modusoptimus.com/
8*/
9defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
10
11define('RVAC_ID', $plugin['id']);
12
13global $prefixeTable;
14define('RVAC_SUGGESTIONS', $prefixeTable.'suggestions');
15
16function rvac_get_data_file() {
[22214]17        global $user,$conf;
18        $f = PWG_COMBINED_DIR.'acds-';
19        $f .= $conf['rvac_version'];
20        $keys = array( $user['language'], $user['nb_total_images'], $user['level'], strlen($user['forbidden_categories']) );
21        $f .= '-'.base_convert(crc32( implode('-', $keys ) ), 10, 36);
22        $f .= '.js';
23        return $f;
[22201]24}
25
26add_event_handler('get_admin_plugin_menu_links', function ($menu) {
27        $menu[] = array(
28                        'NAME' => 'Autocomplete',
29                        'URL' => 'admin.php?page=plugin-'.RVAC_ID
30        );
31        return $menu;
32}
33);
34
35add_event_handler('ws_add_methods', function($srv_arr) {
36  include_once( 'admin/functions.inc.php' );
37  rvac_ws_add_methods($srv_arr);
38});
39
40
41add_event_handler('blockmanager_apply', function($mb_arr)       {
42  if ($mb_arr[0]->get_id() != 'menubar' )
43    return;
[22214]44
[22201]45  global $template;
46
[22246]47        $plug_root = get_root_url().'plugins/'.RVAC_ID.'/';
48  $core_src = $plug_root.'res/suggest-core.js';
[22201]49
50  $data_src = rvac_get_data_file();
51  if (file_exists(PHPWG_ROOT_PATH.$data_src))
52    $data_src = get_root_url().$data_src;
53  else
[22246]54    $data_src = $plug_root.'suggestions.php';
[22201]55
[22246]56  $fs = 'var RVAC={root:"'.$plug_root.'"};
[22201]57$("#qsearchInput").one("focus", function() {
58var s;
59';
60  foreach (array($data_src,$core_src) as $src)
61    $fs .='s=document.createElement("script");s.type="text/javascript";s.async=true;s.src="'.$src.'";document.body.appendChild(s);
62';
63
[27771]64  $css_src = get_root_url().'plugins/'.RVAC_ID.'/res/dark-hive/custom.css';
[22201]65  $fs .= 's="'.$css_src.'";
66if (document.createStyleSheet) document.createStyleSheet(s); else $("head").append($("<link rel=\'stylesheet\' href=\'"+s+"\' type=\'text/css\'>"));';
67  $fs .= '
68});';
69  $template->block_footer_script( array(), $fs);
70  $template->func_combine_script( array('id'=>'jquery','load'=>'footer'));
71}
72);
[28153]73
74add_event_handler('qsearch_expression_parsed', 'rvac_on_qsearch_expression_parsed', EVENT_HANDLER_PRIORITY_NEUTRAL, dirname(__FILE__).'/functions.inc.php');
[22201]75?>
Note: See TracBrowser for help on using the repository browser.