Stud.IP  2.0 Revision 48548
 All Data Structures Namespaces Files Functions Variables Pages
QuickSearch Class Reference
Collaboration diagram for QuickSearch:
Collaboration graph

Public Member Functions

 QuickSearch ($name, $search=NULL)
 withButton ($design=array())
 withoutButton ()
 defaultValue ($valueID, $valueName)
 setInputClass ($class)
 setInputStyle ($style)
 noSelectbox ($set=true)
 disableAutocomplete ($disable=true)
 fireJSFunctionOnSelect ($function_name)
 setAttributes ($attr_array)
 render ()
 getId ()

Static Public Member Functions

static get ($name, $search=NULL)

Static Public Attributes

static $count_QS = 0

Detailed Description

This class provides a small and intuitive GUI-element for an instant search of courses, persons, institutes or other items. Mainly the structure to include a QuickSearch-field is the following: //code-begin $sf = new QuickSearch("username"); $sf->withButton(); $sf->specialSQL("SELECT username, CONCAT(Vorname, \" ", Nachname) " . "FROM auth_user_md5 " . "WHERE CONCAT(Vorname, " ", Nachname) LIKE :input " . "AND perms = 'dozent'", _("Dozenten suchen")); print $sf->render(); //code-end This code should be included into an html <form>-tag. It will provide a nice looking input-field with a button (this is the $sf->withButton() command for), a javascript instant-search for your items (in this case 'Dozenten') and also a non-javascript oldschool version of a searchfield with a select-box in step 2 of the search (first write what you search, click on the button and then select in the select-box what you wanted to have). You can handle the searchfield in your form-tag as if you have written an '<input type="text" name="username">'.

For most cases you may only want to search for persons, courses or institutes. Thus a shortcut is implemented in this class. You may write //code-begin $sf = new QuickSearch("username", "username"); $sf->withButton(); print $sf->render(); //code-end to receive a searchfield that is automatically searching for users and inserts the selected users's username in the searchfield. The first parameter of the constructor 'new Quicksearch' is the name of the variable in your form and is completely free to name. The (optional) second parameter describes what you are searching for: username, user_id, Seminar_id or Institut_id.

Also you can do method-chaining with this class, so you can press everything you need infront of your semicolon. Watch this example: //code-begin print QuickSearch::get("username", "username")->withButton->render(); //code-end

Lastly you can replace the second argument of the constructor (or get-method) by an object whose class extends the SearchType-class. This might be useful to create your own searches and handle them with oop-style or even use a totally different search-engine like lucene-index! All you need to do so is implement your searchclass and follow this example: //code-begin class TeacherSearch extends SearchType { ... } $searcher = new TeacherSearch(); print QuickSearch::get("username", $searcher)->withButton->render(); //code-end Watch the SearchType class in lib/classes/searchtypes/SearchType.class.php for details. Enjoy!

Member Function Documentation

defaultValue (   $valueID,
  $valueName 
)

Here you can set a default-value for the searchfield

Parameters
string$valueIDthe default-ID that should be stored
string$valueNamethe default value, that should be displayed
  • remember that these may not be the same, they may be something like "ae2b1fca515949e5d54fb22b8ed95575", "test_dozent"
Returns
QuickSearch
disableAutocomplete (   $disable = true)

disables the ajax autocomplete for this searchfield If you want to disable all QuickSearches, you better use the config variable global -> AJAX_AUTOCOMPLETE_DISABLED

Parameters
disableboolean: true (default) to disable, false to enable autocomplete via ajax.
Returns
QuickSearch
fireJSFunctionOnSelect (   $function_name)

set a JavaScript-function to be fired after the user has selected a value in the QuickSearch field. Arguments are: function fireme(id_of_item, text_of_item) example setting: QS->fireJSFunctionOnSelect('fireme');

Parameters
string$function_namethe name of the javascript function
Returns
QuickSearch
static get (   $name,
  $search = NULL 
)
static

returns an instance of QuickSearch so you can use it as singleton

Parameters
string$namethe name of the destinated variable in your html-form. Handle it as if it was an '<input type="text" name="yourname">' input.
string$searchif set to user_id, username, Seminar_id, Arbeitsgruppe_id or Institute_id the searchfield will automatically search for persons, courses, workgroups, institutes and you don't need to call the specialSearch-method.
Returns
object of type QuickSearch

Here is the call graph for this function:

Here is the caller graph for this function:

getId ( )

returns the id string used for the input field

Returns
string

Here is the caller graph for this function:

noSelectbox (   $set = true)

disables the select-box, which is displayed for non-JS users who will choose with this box, which item they want to have.

Parameters
bool$setfalse if we DO want a select-box, false otherwise
Returns
QuickSearch
QuickSearch (   $name,
  $search = NULL 
)

constructor which prepares a searchfield for persons, courses, institutes or special items you may want to search for. This is a GUI-class, see QuickSearch.class.php for further documentation.

Parameters
string$namethe name of the destinated variable in your html-form. Handle it as if it was an '<input type="text" name="yourname">' input.
string$searchif set to user_id, username, Seminar_id, Arbeitsgruppe_id or Institute_id the searchfield will automatically search for persons, courses, workgroups, institutes and you don't need to call the specialSearch-method.
Returns
void

Here is the call graph for this function:

Here is the caller graph for this function:

render ( )

last step: display everything and be happy! comment: the Ajax-Result (for the javascript-instant-search) will be also displayed here, but that does not need to concern you.

Returns
string

Here is the call graph for this function:

setAttributes (   $attr_array)

assigns special attributes to the html-element of the searchfield

Parameters
array$ttr_arraylike array("title" => "hello world")
Returns
QuickSearch
setInputClass (   $class)

defines a css class for the searchfield

Parameters
string$classany css class name for the "input type=text" tag
Returns
QuickSearch
setInputStyle (   $style)

defines css-proporties for searchfield that will be included as 'style="$style"'

Parameters
string$styleone or more css-proporties separated with ";"
Returns
QuickSearch
withButton (   $design = array())

if set to true, the searchfield will be a nice-looking grey searchfield with a magnifier-symbol as a submit-button. Set this to false to create your own submit-button and style of the form.

Parameters
mixed$designassociative array of params.
Returns
QuickSearch

Here is the caller graph for this function:

withoutButton ( )

this will disable a submit button for the searchfield

Returns
QuickSearch

Here is the call graph for this function:

Field Documentation

$count_QS = 0
static

The documentation for this class was generated from the following file: