- <?php
- // include the server class
- include 'HTML/AJAX/Server.php';
-
- // extend HTML_AJAX_Server creating our own custom one with init{ClassName} methods for each class it supports calls on
- class LiveText2 extends HTML_AJAX_Server {
- // this flag must be set to on init methods
-
- var $initMethods = true;
-
- // simple search
-
- var $LiveText = array(
- 1 => 'Orange',
- 2 => 'Apple',
- 3 => 'Pear',
- 4 => 'Banana',
- 5 => 'Blueberry',
- 6 => 'Ananas'
- );
-
- /**
- * Perform a search
- *
- * @return array
- */
- function search($input) {
- $ret = array();
- foreach($this->LiveText as $key => $value) {
- if (stristr($value,$input)) {
- $ret[$key] = $value;
- }
- }
- return $ret;
- }
-
- // init method for the LiveText class, includes needed files an registers it for ajax
-
- function initLiveText2() {
- $this->registerClass(new LiveText2());
- }
- }
-
- // create an instance of our test server
- $server = new LiveText2();
- $server->handleRequest();
- ?>