2 # MantisBT - A PHP based bugtracking system
4 # MantisBT is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 2 of the License, or
7 # (at your option) any later version.
9 # MantisBT is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
22 * @subpackage ProjaxAPI
23 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
24 * @copyright Copyright (C) 2002 - 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net
25 * @link http://www.mantisbt.org
27 * @uses ../library/projax/projax.php
28 * @uses config_api.php
31 require_lib( 'projax' . DIRECTORY_SEPARATOR
. 'projax.php' );
32 require_api( 'config_api.php' );
34 # enables the projax library for this page.
35 $g_enable_projax = true;
37 $g_projax = new Projax();
39 # Outputs an auto-complete field to the HTML form. The supported attribute keys in the attributes array are:
40 # class, size, maxlength, value, and tabindex.
41 function projax_autocomplete( $p_entrypoint, $p_field_name, $p_attributes_array = null ) {
43 static $s_projax_style_done = false;
45 if ( ON
== config_get( 'use_javascript' ) ) {
46 echo $g_projax->text_field_with_auto_complete( $p_field_name, $p_attributes_array, $s_projax_style_done ?
array( 'url' => 'xmlhttprequest.php?entrypoint=' . $p_entrypoint, 'skip_style' => '1' ) : array( 'url' => 'xmlhttprequest.php?entrypoint=' . $p_entrypoint ) );
47 $s_projax_style_done = true;
49 $t_tabindex = isset( $p_attributes_array['tabindex'] ) ?
( ' tabindex="' . $p_attributes_array['tabindex'] . '"' ) : '';
50 $t_maxlength = isset( $p_attributes_array['maxlength'] ) ?
( ' maxlength="' . $p_attributes_array['maxlength'] . '"' ) : '';
51 echo '<input id="'.$p_field_name.'" name="'.$p_field_name.'"'. $t_tabindex . $t_maxlength . ' size="'.(isset($p_attributes_array['size'])?
$p_attributes_array['size']:30).'" type="text" value="'.(isset($p_attributes_array['value'])?
$p_attributes_array['value']:'').'" '.(isset($p_attributes_array['class'])?
'class = "'.$p_attributes_array['class'].'" ':'').'/>';
55 # Filters the provided array of strings and only returns the ones that start with $p_prefix.
56 # The comparison is not case sensitive.
57 # Returns the array of the filtered strings, or an empty array. If the input array has non-unique
58 # entries, then the output one may contain duplicates.
59 function projax_array_filter_by_prefix( $p_array, $p_prefix ) {
62 foreach( $p_array as $t_entry ) {
63 if( utf8_strtolower( utf8_substr( $t_entry, 0, utf8_strlen( $p_prefix ) ) ) == utf8_strtolower( $p_prefix ) ) {
64 $t_matches[] = $t_entry;
71 # Serializes the provided array of strings into the format expected by the auto-complete library.
72 function projax_array_serialize_for_autocomplete( $p_array ) {
75 foreach( $p_array as $t_entry ) {
76 $t_matches .= "<li>$t_entry</li>";
79 $t_matches .= '</ul>';