HTML_QuickForm_LiveText
[ class tree: HTML_QuickForm_LiveText ] [ index: HTML_QuickForm_LiveText ] [ all elements ]

Source for file auto_server.php

Documentation is available at auto_server.php

  1. <?php
  2. // include the server class
  3. include 'HTML/AJAX/Server.php';
  4.  
  5. // extend HTML_AJAX_Server creating our own custom one with init{ClassName} methods for each class it supports calls on
  6. class LiveText extends HTML_AJAX_Server {
  7. // this flag must be set to on init methods
  8. var $initMethods = true;
  9.  
  10. // simple search
  11. var $LiveText = array(
  12. 1 => 'Orange',
  13. 2 => 'Apple',
  14. 3 => 'Pear',
  15. 4 => 'Banana',
  16. 5 => 'Blueberry',
  17. );
  18.  
  19. // search with complex result
  20. var $LiveText2 = array(
  21. 'Alice' => array('id' => 0, 'name' => 'Alice', 'department' => 'Managment'),
  22. 'Fabio' => array('id' => 1, 'name' => 'Fabio', 'department' => 'Development'),
  23. 'John' => array('id' => 2, 'name' => 'John', 'department' => 'Systems'),
  24. 'Joe' => array('id' => 31, 'name' => 'Joe', 'department' => 'Development'),
  25. 'Bob' => array('id' => 4, 'name' => 'Bob', 'department' => 'Systems'),
  26. 'Jonathan' => array('id' => 20, 'name' => 'Jonathan', 'department' => 'Systems'),
  27. 'Joaquin' => array('id' => 21, 'name' => 'Joaquin', 'department' => 'Development'),
  28. 'Jody' => array('id' => 10, 'name' => 'Jody', 'department' => 'Managment'),
  29. );
  30.  
  31. /**
  32. * Perform a search
  33. *
  34. * @return array
  35. */
  36. function search($input) {
  37. $ret = array();
  38. foreach($this->LiveText as $key => $value) {
  39. if (stristr($value,$input)) {
  40. $ret[$key] = $value;
  41. }
  42. }
  43. return $ret;
  44. }
  45.  
  46. function search2($input) {
  47. $ret = array();
  48. foreach($this->LiveText2 as $key => $value) {
  49. if (stristr($key,$input)) {
  50. $ret[$key] = $value;
  51. }
  52. }
  53. return $ret;
  54. }
  55.  
  56. // init method for the LiveText class, includes needed files an registers it for ajax
  57. function initLiveText() {
  58. $this->registerClass(new LiveText());
  59. }
  60. }
  61.  
  62. // create an instance of our test server
  63. $server = new LiveText();
  64. $server->handleRequest();
  65. ?>

Documentation generated on Thu, 12 Apr 2007 08:37:35 +0200 by phpDocumentor 1.3.0RC3