Example #1
0
 function CityMenu($data)
 {
     global $hgconf;
     $menulist = '<ul id="menu">' . "\n";
     $db =& JFactory::getDBO();
     $query = 'SELECT s.id AS value, s.name AS text, s.image, cc.continent AS continent, cc.name AS countryname,' . ' CASE WHEN CHAR_LENGTH( s.alias ) THEN CONCAT_WS( \':\', s.id, s.alias ) ELSE s.id END AS slug' . ' FROM #__hg_states AS s' . ' LEFT JOIN #__hg_countries AS cc ON cc.id = s.country' . ' WHERE s.published = 1' . ' AND s.country = ' . $data->country;
     $db->setQuery($query);
     $states = $db->loadObjectList();
     $where = ' WHERE c.published = 1';
     if ($data->parent_id <= 0) {
         $where .= ' AND c.id = ' . $data->id;
     } else {
         $where .= ' AND c.id = ' . $data->parent_id;
     }
     $where .= ' AND c.states = ' . $data->states;
     $query = 'SELECT c.id, c.name, s.name AS statesname,' . ' CASE WHEN CHAR_LENGTH( c.alias ) THEN CONCAT_WS( \':\', c.id, c.alias ) ELSE c.id END AS cityslug,' . ' CASE WHEN CHAR_LENGTH( s.alias ) THEN CONCAT_WS( \':\', s.id, s.alias ) ELSE s.id END AS statesslug' . ' FROM #__hg_cities AS c' . ' LEFT JOIN #__hg_states AS s ON s.id = c.states' . $where;
     $db->setQuery($query);
     $maincity = $db->loadObject();
     if (count($states) > 0) {
         $query = 'SELECT c.id AS value, c.name AS text, c.image, s.name AS statesname,' . ' CASE WHEN CHAR_LENGTH( c.alias ) THEN CONCAT_WS( \':\', c.id, c.alias ) ELSE c.id END AS slug' . ' FROM #__hg_cities AS c' . ' LEFT JOIN #__hg_states AS s ON s.id = c.states' . ' WHERE c.published = 1' . ' AND c.states = ' . $data->states . ' AND c.parent_id = 0';
         $db->setQuery($query);
         $statecities = $db->loadObjectList();
     } else {
         /*			$where = ' WHERE c.published = 1';
         			if ($data->parent_id <= 0)
         				$where .= ' AND c.id = '.$data->id;
         			else
         				$where .= ' AND c.id = '.$data->parent_id;
         			
         			$query = 'SELECT c.id, c.name,'
         					. ' CASE WHEN CHAR_LENGTH( c.alias ) THEN CONCAT_WS( \':\', c.id, c.alias ) ELSE c.id END AS cityslug'
         					. ' FROM #__hg_cities AS c'
         					. $where
         					;
         				
         			$db->setQuery( $query );
         			$maincity = $db->loadObject(); */
     }
     $where = ' WHERE c.published = 1';
     if ($data->parent_id <= 0) {
         $where .= ' AND c.parent_id = ' . $data->id;
     } else {
         $where .= ' AND c.parent_id = ' . $data->parent_id;
     }
     $query = 'SELECT c.id AS value, c.name AS text, c.image,' . ' CASE WHEN CHAR_LENGTH( c.alias ) THEN CONCAT_WS( \':\', c.id, c.alias ) ELSE c.id END AS slug' . ' FROM #__hg_cities AS c' . $where . ' ORDER BY c.name ASC';
     $db->setQuery($query);
     $locals = $db->loadObjectList();
     $query = 'SELECT c.id AS value, c.name AS text, c.image, cc.continent AS continent, cc.name AS countryname,' . ' CASE WHEN CHAR_LENGTH( c.alias ) THEN CONCAT_WS( \':\', c.id, c.alias ) ELSE c.id END AS slug,' . ' CASE WHEN CHAR_LENGTH( cc.alias ) THEN CONCAT_WS( \':\', cc.id, cc.alias ) ELSE cc.id END AS countryslug' . ' FROM #__hg_cities AS c' . ' LEFT JOIN #__hg_countries AS cc ON cc.id = c.country' . ' WHERE c.published = 1' . ' AND c.country = ' . $data->country . ' AND c.parent_id = 0' . ' ORDER BY c.name ASC';
     $db->setQuery($query);
     $cities = $db->loadObjectList();
     if ($hgconf->city_front != 1) {
         $query = 'SELECT c.id AS value, c.name AS text, c.code_1, cc.name AS continentname,' . ' CASE WHEN CHAR_LENGTH( c.alias ) THEN CONCAT_WS( \':\', c.id, c.alias ) ELSE c.id END AS slug,' . ' CASE WHEN CHAR_LENGTH( cc.alias ) THEN CONCAT_WS( \':\', cc.id, cc.alias ) ELSE cc.id END AS continentslug' . ' FROM #__hg_countries AS c' . ' LEFT JOIN #__hg_continents AS cc ON cc.id = c.continent' . ' WHERE c.published = 1' . ' AND c.continent = ' . $cities[0]->continent . ' ORDER BY c.name ASC';
         $db->setQuery($query);
         $countries = $db->loadObjectList();
         if ($hgconf->frontpage == 2) {
             $query = 'SELECT id AS value, name AS text, image,' . ' CASE WHEN CHAR_LENGTH( alias ) THEN CONCAT_WS( \':\', id, alias ) ELSE id END AS slug' . ' FROM #__hg_continents' . ' WHERE published = 1';
             $db->setQuery($query);
             $continents = $db->loadObjectList();
             $nocontinent = count($continents);
         }
         if (isset($continents) && $hgconf->frontpage == 2) {
             $clink = JRoute::_('index.php?option=com_hotelguide&amp;view=hotelguide');
             $menulist .= '<li><a href="' . $clink . '">' . JText::_('HG_CONTINENTS') . '</a>' . "\n";
             $menulist .= '<div class="dropdown_4columns">' . "\n";
             $i = 0;
             foreach ($continents as $continent) {
                 $continentlink = JRoute::_(hotelguideHelperRoute::getContinentRoute($continent->slug));
                 if ($continent->image) {
                     $imagelink = JURI::base() . 'images/hotelguide/country/scrop/' . $continent->image;
                 } else {
                     $imagelink = JURI::base() . '/components/com_hotelguide/assets/images/no_list.gif';
                 }
                 $menulist .= '<div class="col_1">';
                 if (strlen(strip_tags($continent->text)) > 20) {
                     $continent->text = substr($continent->text, 0, 30);
                     $continent->text = trim($continent->text) . "...\n\n";
                     $menulist .= '<p style="line-height:16px"><a href="' . $continentlink . '"><img src="' . $imagelink . '" width="20px" class="img_left imgshadow" align="left" alt="' . $continent->text . '" />';
                 } else {
                     $menulist .= '<p style="line-height:32px"><a href="' . $continentlink . '"><img src="' . $imagelink . '" width="20px" class="img_left imgshadow" align="left" alt="' . $continent->text . '" />';
                 }
                 $menulist .= $continent->text . '</a></p></div>';
                 $i++;
                 if ($i == 4) {
                     $menulist .= '<div style="clear:both;"></div>' . "\n";
                     $i = 0;
                 }
             }
             $menulist .= '</div></li>' . "\n";
         }
         if ($hgconf->frontpage == 2 || $hgconf->frontpage == 3) {
             $wlink = JRoute::_(hotelguideHelperRoute::getContinentRoute($countries[0]->continentslug));
             $menulist .= '<li><a href="' . $wlink . '">' . $countries[0]->continentname . '</a>' . "\n";
             $menulist .= '<div class="dropdown_4columns">' . "\n";
             $i = 0;
             foreach ($countries as $country) {
                 $countrylink = JRoute::_(hotelguideHelperRoute::getCountryRoute($country->slug));
                 $imagelink = JURI::base() . 'images/hotelguide/country/flags/' . $country->code_1 . '.png';
                 $menulist .= '<div class="col_1">';
                 if (strlen(strip_tags($country->text)) > 20) {
                     $country->text = substr($country->text, 0, 30);
                     $country->text = trim($country->text) . "...\n\n";
                     $menulist .= '<p style="line-height:14px"><a href="' . $countrylink . '"><img src="' . $imagelink . '" width="22px" class="img_left imgshadow" align="left" alt="' . $country->text . '" />';
                 } else {
                     $menulist .= '<p style="line-height:28px"><a href="' . $countrylink . '"><img src="' . $imagelink . '" width="22px" class="img_left imgshadow" align="left" alt="' . $country->text . '" />';
                 }
                 $menulist .= $country->text . '</a></p></div>';
                 $i++;
                 if ($i == 4) {
                     $menulist .= '<div style="clear:both;"></div>' . "\n";
                     $i = 0;
                 }
             }
             $menulist .= '</div></li>' . "\n";
         }
         if (count($states) > 0 && ($hgconf->frontpage == 2 || $hgconf->frontpage == 3 || $hgconf->frontpage == 4)) {
             $tlink = JRoute::_(hotelguideHelperRoute::getCountryRoute($cities[0]->countryslug));
             $menulist .= '<li><a href="' . $tlink . '">' . $states[0]->countryname . '</a>' . "\n";
             $menulist .= '<div class="dropdown_4columns">' . "\n";
             $i = 0;
             foreach ($states as $state) {
                 $stateslink = JRoute::_(hotelguideHelperRoute::getStatesRoute($state->slug));
                 if ($state->image) {
                     $imagelink = JURI::base() . 'images/hotelguide/states/crop/' . $state->image;
                 } else {
                     $imagelink = JURI::base() . '/components/com_hotelguide/assets/images/no_list.gif';
                 }
                 $menulist .= '<div class="col_1">';
                 if (strlen(strip_tags($state->text)) > 20) {
                     $state->text = substr($state->text, 0, 30);
                     $state->text = trim($state->text) . "...\n\n";
                     $menulist .= '<p style="line-height:16px"><a href="' . $stateslink . '"><img src="' . $imagelink . '" width="20px" class="img_left imgshadow" align="left" alt="' . $state->text . '" />';
                 } else {
                     $menulist .= '<p style="line-height:32px"><a href="' . $stateslink . '"><img src="' . $imagelink . '" width="20px" class="img_left imgshadow" align="left" alt="' . $state->text . '" />';
                 }
                 $menulist .= $state->text . '</a></p></div>';
                 $i++;
                 if ($i == 4) {
                     $menulist .= '<div style="clear:both;"></div>' . "\n";
                     $i = 0;
                 }
             }
             $menulist .= '</div></li>' . "\n";
         }
         if (isset($statecities) && ($hgconf->frontpage == 2 || $hgconf->frontpage == 3 || $hgconf->frontpage == 4 || $hgconf->frontpage == 5)) {
             $slink = JRoute::_(hotelguideHelperRoute::getStatesRoute($maincity->statesslug));
             $menulist .= '<li><a href="' . $slink . '">' . $maincity->statesname . '</a>' . "\n";
             $menulist .= '<div class="dropdown_4columns">' . "\n";
             $i = 0;
             foreach ($statecities as $city) {
                 $citylink = JRoute::_(hotelguideHelperRoute::getCityRoute($city->slug));
                 if ($city->image) {
                     $imagelink = JURI::base() . 'images/hotelguide/city/scrop/' . $city->image;
                 } else {
                     $imagelink = JURI::base() . '/components/com_hotelguide/assets/images/no_list.gif';
                 }
                 $menulist .= '<div class="col_1">';
                 if (strlen(strip_tags($city->text)) > 20) {
                     $city->text = substr($city->text, 0, 35);
                     $city->text = trim($city->text) . "...\n\n";
                     $menulist .= '<p style="line-height:16px"><a href="' . $citylink . '"><img src="' . $imagelink . '" width="20px" class="img_left imgshadow" align="left" alt="' . $city->text . '" />';
                 } else {
                     $menulist .= '<p style="line-height:32px"><a href="' . $citylink . '"><img src="' . $imagelink . '" width="20px" class="img_left imgshadow" align="left" alt="' . $city->text . '" />';
                 }
                 $menulist .= $city->text . '</a></p></div>';
                 $i++;
                 if ($i == 4) {
                     $menulist .= '<div style="clear:both;"></div>' . "\n";
                     $i = 0;
                 }
             }
             $menulist .= '</div></li>' . "\n";
         }
         if (count($states) == 0 && ($hgconf->frontpage == 2 || $hgconf->frontpage == 3 || $hgconf->frontpage == 4)) {
             $tlink = JRoute::_(hotelguideHelperRoute::getCountryRoute($cities[0]->countryslug));
             $menulist .= '<li><a href="' . $tlink . '">' . $cities[0]->countryname . '</a>' . "\n";
             $menulist .= '<div class="dropdown_4columns">' . "\n";
             $i = 0;
             foreach ($cities as $citylist) {
                 $citylink = JRoute::_(hotelguideHelperRoute::getCityRoute($citylist->slug));
                 if ($citylist->image) {
                     $imagelink = JURI::base() . 'images/hotelguide/city/scrop/' . $citylist->image;
                 } else {
                     $imagelink = JURI::base() . '/components/com_hotelguide/assets/images/no_list.gif';
                 }
                 $menulist .= '<div class="col_1">';
                 if (strlen(strip_tags($citylist->text)) > 20) {
                     $citylist->text = substr($citylist->text, 0, 35);
                     $citylist->text = trim($citylist->text) . "...\n\n";
                     $menulist .= '<p style="line-height:16px"><a href="' . $citylink . '"><img src="' . $imagelink . '" width="20px" class="img_left imgshadow" align="left" alt="' . $citylist->text . '" />';
                 } else {
                     $menulist .= '<p style="line-height:32px"><a href="' . $citylink . '"><img src="' . $imagelink . '" width="20px" class="img_left imgshadow" align="left" alt="' . $citylist->text . '" />';
                 }
                 $menulist .= $citylist->text . '</a></p></div>';
                 $i++;
                 if ($i == 4) {
                     $menulist .= '<div style="clear:both;"></div>' . "\n";
                     $i = 0;
                 }
             }
             $menulist .= '</div></li>' . "\n";
         }
     }
     if (count($locals) > 0) {
         $maincitylink = JRoute::_(hotelguideHelperRoute::getCityRoute($maincity->cityslug));
         $menulist .= '<li><a href="' . $maincitylink . '">' . $maincity->name . '</a>' . "\n";
         $menulist .= '<div class="dropdown_4columns">' . "\n";
         $i = 0;
         foreach ($locals as $local) {
             $citylink = JRoute::_(hotelguideHelperRoute::getCityRoute($local->slug));
             if ($local->image) {
                 $imagelink = JURI::base() . 'images/hotelguide/city/scrop/' . $local->image;
             } else {
                 $imagelink = JURI::base() . '/components/com_hotelguide/assets/images/no_list.gif';
             }
             $menulist .= '<div class="col_1">';
             if (strlen(strip_tags($local->text)) > 25) {
                 $local->text = substr($local->text, 0, 36);
                 $local->text = trim($local->text) . "...\n\n";
                 $menulist .= '<p style="line-height:16px"><a href="' . $citylink . '"><img src="' . $imagelink . '" width="20px" class="img_left imgshadow" align="left" alt="' . $local->text . '" />';
             } else {
                 $menulist .= '<p style="line-height:32px"><a href="' . $citylink . '"><img src="' . $imagelink . '" width="20px" class="img_left imgshadow" align="left" alt="' . $local->text . '" />';
             }
             $menulist .= $local->text . '</a></p></div>';
             $i++;
             if ($i == 4) {
                 $menulist .= '<div style="clear:both;"></div>' . "\n";
                 $i = 0;
             }
         }
         $menulist .= '</div></li>' . "\n";
     }
     $menulist .= '</ul>' . "\n";
     return $menulist;
 }
} else {
    echo '<p style="margin:0">';
    echo '<strong>' . JText::_('HG_OOPS_NO_INFORMATION') . '</strong>';
    echo '</p>';
}
echo '<div style="clear:both;"></div>' . "\n";
if (count($this->cityname) > 0) {
    echo '<h3 class="title" style="margin-top:20px">';
    echo JText::sprintf('HG_ALL_CITIES_IN', $this->country->name);
    echo '</h3>';
    if ($this->country->no <= 0) {
        echo '<div id="list_wrapper"><ul class="multiple_columns">' . "\n";
    }
    foreach ($this->cityname as $city) {
        if (isset($city->city)) {
            $link = JRoute::_(hotelguideHelperRoute::getStatesRoute($city->statesslug));
            echo '<div id="list_wrapper"><strong><a href="' . $link . '">' . $city->name . '</a></strong><ul class="multiple_columns">' . "\n";
            if (count($city->city) > 0) {
                foreach ($city->city as $town) {
                    echo '<li>' . "\n";
                    $link = JRoute::_(hotelguideHelperRoute::getCityRoute($town->cityslug));
                    echo '<a href="' . $link . '">' . $town->name . '</a>' . "\n";
                    echo '</li>' . "\n";
                }
            }
            echo '</ul></div><div style="clear:both;"></div>' . "\n";
        } else {
            echo '<li>' . "\n";
            $link = JRoute::_(hotelguideHelperRoute::getCityRoute($city->cityslug));
            echo '<a href="' . $link . '">' . $city->name . '</a>' . "\n";
            echo '</li>' . "\n";