Ansel_Ajax_Imple_LocationAutoCompleter::_getAutoCompleter PHP Method

_getAutoCompleter() protected method

protected _getAutoCompleter ( )
    protected function _getAutoCompleter()
    {
        global $injector, $session;
        $opts = array('onSelect' => 'function (v) {' . $this->_params['map'] . '.ll = Ansel.ajax.locationAutoCompleter.geocache[v]; return v;}', 'tokens' => array());
        /* Use ajax? */
        if (!$session->exists('ansel', 'ajax_locationac')) {
            try {
                $results = $injector->getInstance('Ansel_Storage')->searchLocations();
                $session->set('ansel', 'ajax_locationac', count($results) > 50);
            } catch (Ansel_Exception $e) {
                Horde::log($e, 'ERR');
            }
        }
        if ($session->get('ansel', 'ajax_locationac')) {
            return new Horde_Core_Ajax_Imple_AutoCompleter_Ajax($opts);
        }
        if (empty($results)) {
            $results = $injector->getInstance('Ansel_Storage')->searchLocations();
        }
        return new Horde_Core_Ajax_Imple_AutoCompleter_Local($results, $opts);
    }
Ansel_Ajax_Imple_LocationAutoCompleter