Exemple #1
0
 public function searchjsonAction()
 {
     $keyword = strtolower($this->getRequest()->getParam('term'));
     $numOfItem = (int) Zend_Registry::get('Setting')->autocomplete_limit;
     if ($numOfItem > 0) {
         list($Pager, $aRespon['cities']) = City::getAll(array('LOWER(city_id) || LOWER(tags) LIKE ?' => "%{$keyword}%"), 1, $numOfItem);
         $numOfItem = $numOfItem - $Pager->getNumResults();
     }
     if ($numOfItem > 0) {
         //Search countries three
         $aRespon['countries'] = Countries::getAll(array('LOWER(countries_id) LIKE ? OR  LOWER(tags) LIKE ?' => array("%{$keyword}%", "%{$keyword}%")), $numOfItem);
         $numOfItem = $numOfItem - count($aRespon['countries']);
     }
     header('Content-Type: text/html; charset=iso-8859-1');
     $search = ucwords($keyword);
     $keywords = array($keyword, $search, ucfirst(str_replace(' ', '', $keyword)), ucfirst(str_replace(' ', '', My_Plugin_Libs::unUnicode($keyword))));
     $response = array();
     $address = '';
     //rebuil to autocomplete struc
     foreach ($aRespon as $location => $data) {
         foreach ($data as $Obj) {
             $link = '';
             if ($location == 'cities') {
                 $label = $Obj->name . ', ' . $Obj->Countries->name;
                 $link = $Obj->getLink();
                 $country = $Obj->Countries->name;
             } elseif ($location == 'countries') {
                 $label = $Obj->name;
                 $link = $Obj->getLink();
                 $country = $Obj->name;
             } else {
                 $label = $Obj->name;
                 $link = $Obj->getLink();
                 $country = $Obj->Countries->name;
                 $address = $Obj->address;
             }
             $response[] = array('location' => $location, 'link' => $link, 'id' => $Obj->id, 'label' => str_replace($keywords, '<b>' . $search . '</b>', $label), 'value' => $label, 'country' => $country, 'address' => str_replace($keywords, '<b>' . $search . '</b>', $address));
         }
     }
     echo json_encode($response);
 }
            <div class="input-group groups div-names">
                <span class="input-group-addon span-names">Еще раз пароль</span>
                <input type="password" id="pass_again" class="form-control"
                       placeholder="Введите еще раз пароль">
            </div>
            <div class="input-group groups div-names">
                <span class="input-group-addon span-names">Телефон</span>
                <input type="tel" id="phone" class="form-control" aria-describedby="basic-addon1"
                       placeholder="Введите номер телефона">
            </div>
            <div class="input-group groups div-names">
                <span class="input-group-addon span-names">Страна</span>
                <select id="country" class="form-control">
                    <option value='select'>Выберите страну</option>
                    <?php 
foreach ($countries->getAll() as $k => $v) {
    foreach ($v as $key => $value) {
        echo '<option value="' . $k . '">' . $value . '</option>';
    }
}
?>
                </select>
            </div>
            <div class="input-group groups div-names">
                <span class="input-group-addon span-names">Город</span>
                <select id="city" class="form-control">
                    <option value='select'>Выберите город</option>
                    <?php 
foreach ($cities->getCities() as $k => $v) {
    foreach ($v as $key => $value) {
        echo '<option value="' . $k . '">' . $value . '</option>';