/** * Returns levels info */ public function GetLevelsInfo($category_id, $target = 'category') { $lang = Application::Get('lang'); $output = array('first' => array('id' => '', 'name' => '', 'link' => ''), 'second' => array('id' => '', 'name' => '', 'link' => ''), 'third' => array('id' => '', 'name' => '', 'link' => '')); $sql = 'SELECT c.id, c.parent_id, cd.name FROM ' . TABLE_CATEGORIES . ' c LEFT OUTER JOIN ' . TABLE_CATEGORIES_DESCRIPTION . ' cd ON c.id = cd.category_id WHERE c.id = _CID_ AND cd.language_id = \'' . $lang . '\''; $sql_1 = str_replace('_CID_', (int) $category_id, $sql); $result = database_query($sql_1, DATA_AND_ROWS, FIRST_ROW_ONLY); if ($result[1] > 0) { $output['first']['id'] = $result[0]['id']; $output['first']['name'] = $result[0]['name']; $output['first']['link'] = prepare_link($target, 'cid', $result[0]['id'], '', $result[0]['name'], '', '', true); $sql_2 = str_replace('_CID_', $result[0]['parent_id'], $sql); $result_2 = database_query($sql_2, DATA_AND_ROWS, FIRST_ROW_ONLY); if ($result_2[1] > 0) { $output['second']['id'] = $result_2[0]['id']; $output['second']['name'] = $result_2[0]['name']; $output['second']['link'] = prepare_link($target, 'cid', $result_2[0]['id'], '', $result_2[0]['name'], '', '', true); $sql_3 = str_replace('_CID_', $result_2[0]['parent_id'], $sql); $result_3 = database_query($sql_3, DATA_AND_ROWS, FIRST_ROW_ONLY); if ($result_3[1] > 0) { $output['third']['id'] = $result_3[0]['id']; $output['third']['name'] = $result_3[0]['name']; $output['third']['link'] = prepare_link($target, 'cid', $result_3[0]['id'], '', $result_3[0]['name'], '', '', true); } } } return $output; }
<?php /** * @project ApPHP Business Directory * @copyright (c) 2011 ApPHP * @author ApPHP <*****@*****.**> * @license http://www.gnu.org/licenses/ */ // *** Make sure the file isn't accessed directly defined('APPHP_EXEC') or die('Restricted Access'); //-------------------------------------------------------------------------- $objCategory = Categories::Instance(); $objListings = Listings::Instance(); $category_info = $objCategory->GetLevelsInfo(Application::Get('category_id')); $button = ''; if (Modules::IsModuleInstalled('inquiries')) { $listings_locations = isset($_REQUEST['listings_locations']) ? (int) $_REQUEST['listings_locations'] : ''; $listings_sub_locations = isset($_REQUEST['listings_sub_locations']) ? (int) $_REQUEST['listings_sub_locations'] : ''; if (!empty($category_info['first']['id'])) { $button = '<input type="button" class="form_button" value="' . _SUBMIT_INQUIRY . '" onclick="appGoToPage(\'index.php?page=inquiry_form\',\'&inquiry_category=' . $category_info['first']['id'] . '&visitor_locations=' . $listings_locations . '&visitor_sub_locations=' . $listings_sub_locations . '\',\'post\')">'; } } draw_title_bar(prepare_breadcrumbs(array(_CATEGORIES => prepare_link('categories', '', '', 'all', _SEE_ALL, '', '', true), $category_info['third']['name'] => $category_info['third']['link'], $category_info['second']['name'] => $category_info['second']['link'], $category_info['first']['name'] => '')), $button); $objCategory->DrawSubCategories(Application::Get('category_id'), 'listings'); $objListings->DrawListings(Application::Get('category_id'));
/** * Draw featured all links * @param $draw */ public static function DrawRecentAll($draw = true) { global $objLogin; $show_expired_listings = ModulesSettings::Get('listings', 'show_expired_listings'); echo '<table border="0" cellspacing="5">'; echo '<tr><th></th><td colspan="3">' . draw_sub_title_bar(_RECENT_LISTINGS, false) . '</td></tr>'; $where_condition = ' 1=1 ' . (!$objLogin->IsLoggedIn() ? ' AND access_level="public"' : ''); $where_condition .= $show_expired_listings != 'yes' ? ' AND ((finish_publishing = \'0000-00-00 00:00:00\') OR (finish_publishing > \'' . date('Y-m-d H:i:s') . '\'))' : ''; $result = self::GetAllListings($where_condition, 'date_published DESC', 100); if ($result[1] > 0) { echo '<tr> <th width="20px"></td> <th>' . _NAME . '</th> <th width="200px" align="center">' . _CATEGORY . '</th> <th width="200px" align="center">' . _DATE_PUBLISHED . '</th> </tr>'; for ($i = 0; $i < $result[1] && $i < 100; $i++) { echo '<tr> <td align="right">' . ($i + 1) . '.</td> <td nowrap="nowrap">' . prepare_link('listing', 'lid', $result[0][$i]['id'], $result[0][$i]['business_name'], $result[0][$i]['business_name'], '') . '</td> <td align="center">' . $result[0][$i]['category_name'] . '</td> <td align="center">' . format_datetime($result[0][$i]['date_published']) . '</td> </tr>'; } echo '<tr><td colspan="4"> </td></tr>'; } else { echo '<tr><td colspan="4">' . _NO_LISTINGS_TO_DISPLAY . '</td></tr>'; } echo '</table>'; }
/** * Draws menus * @param $menu_position * @param $draw */ public static function DrawMenu($menu_position = 'left', $draw = true) { global $objSettings, $objLogin; $output = ''; if ($menu_position == 'left') { $objLogin->DrawLoginLinks(); } // Get all menus which have items (links to pages) $menus = self::GetMenus($menu_position); $menus_count = $menus[1]; $objNews = News::Instance(); $show_news_block = ModulesSettings::Get('news', 'show_news_block'); $show_subscribe_block = ModulesSettings::Get('news', 'show_newsletter_subscribe_block'); if (Modules::IsModuleInstalled('news') && ($show_news_block == 'right side' || $show_subscribe_block == 'right side')) { $menus_count++; } $show_inquiries_block = ModulesSettings::Get('inquiries', 'show_inquiries_block'); if (Modules::IsModuleInstalled('inquiries') && $show_inquiries_block == 'right side') { $menus_count++; } if (ModulesSettings::Get('listings', 'show_categories_side_block') == $menu_position . ' side') { $output .= Categories::DrawSideBlock(false); $menus_count++; } if (ModulesSettings::Get('listings', 'show_featured_block') == $menu_position . ' side') { $output .= Listings::DrawFeaturedBlock(false); $menus_count++; } if (ModulesSettings::Get('listings', 'show_recent_block') == $menu_position . ' side') { $output .= Listings::DrawRecentBlock(false); $menus_count++; } if (ModulesSettings::Get('listings', 'show_directory_statistics') == $menu_position . ' side') { $menus_count++; } if ($menus_count > 0) { $output .= '<div id="column-' . $menu_position . '-wrapper">'; } // Display all menu titles (names) according to their order for ($menu_ind = 0; $menu_ind < $menus[1]; $menu_ind++) { // Start draw new menu $output .= draw_block_top($menus[0][$menu_ind]['menu_name'], '', 'maximazed', false); $menu_links = self::GetMenuLinks($menus[0][$menu_ind]['id'], Application::Get('lang'), $menu_position); if ($menu_links[1] > 0) { $output .= '<ul>'; } for ($menu_link_ind = 0; $menu_link_ind < $menu_links[1]; $menu_link_ind++) { $class = Application::Get('page_id') == $menu_links[0][$menu_link_ind]['id'] ? ' active' : ''; if ($menu_links[0][$menu_link_ind]['content_type'] == 'link') { $output .= '<li>' . prepare_permanent_link($menu_links[0][$menu_link_ind]['link_url'], $menu_links[0][$menu_link_ind]['menu_link'], $menu_links[0][$menu_link_ind]['link_target'], 'main_menu_link' . $class) . '</li>'; } else { // draw current menu link $output .= '<li>' . prepare_link('pages', 'pid', $menu_links[0][$menu_link_ind]['id'], $menu_links[0][$menu_link_ind]['page_key'], $menu_links[0][$menu_link_ind]['menu_link'], 'main_menu_link' . $class) . '</li>'; } } if ($menu_links[1] > 0) { $output .= '</ul>'; } $output .= draw_block_bottom(false); } if ($menu_position == 'left') { if (!$objLogin->IsLoggedIn() || Application::Get('preview') == 'yes') { if (Modules::IsModuleInstalled('customers') && ModulesSettings::Get('customers', 'allow_login') == 'yes') { if (Application::Get('customer') != 'login') { $output .= Customers::DrawLoginFormBlock(false); } } } if (Modules::IsModuleInstalled('news')) { if ($show_news_block == 'left side') { $output .= $objNews->DrawNewsBlock(false); } if ($show_subscribe_block == 'left side') { $output .= $objNews->DrawSubscribeBlock(false); } } if (Modules::IsModuleInstalled('inquiries')) { if ($show_inquiries_block == 'left side') { $output .= Inquiries::DrawLastInquiriesBlock(false); } } } if ($menu_position == 'right') { if (Modules::IsModuleInstalled('inquiries')) { if ($show_inquiries_block == 'right side') { $output .= Inquiries::DrawLastInquiriesBlock(false); } } if (Modules::IsModuleInstalled('news')) { if ($show_news_block == 'right side') { $output .= $objNews->DrawNewsBlock(false); } if ($show_subscribe_block == 'right side') { $output .= $objNews->DrawSubscribeBlock(false); } } } if (ModulesSettings::Get('listings', 'show_directory_statistics') == $menu_position . ' side') { $output .= Listings::DrawDirectoryStatistics(false); } if ($menu_position == 'right') { if (Modules::IsModuleInstalled('adsense')) { $output .= '<div class="adsense-vertical">' . Adsense::GetVerticalBanerCode() . '</div>'; } } if ($menus_count > 0) { $output .= '</div>'; } $output .= '<br />'; if ($draw) { echo $output; } else { return $output; } }
/** * Draws news block * @param $draw */ public function DrawNewsBlock($draw = true) { $text_align_left = Application::Get('lang_dir') == 'ltr' ? 'text-align:left;' : 'text-align:right;padding-right:15px;'; $text_align_right = Application::Get('lang_dir') == 'ltr' ? 'text-align:right;padding-right:15px;' : 'text-align:left;'; $news_header_length = ModulesSettings::Get('news', 'news_header_length'); $news_count = ModulesSettings::Get('news', 'news_count'); $this->WHERE_CLAUSE = 'WHERE date_created < \'' . @date('Y-m-d H:i:s') . '\' AND language_id = \'' . Application::Get('lang') . '\''; $all_news = $this->GetAll($this->ORDER_CLAUSE); $output = draw_block_top(_NEWS_AND_EVENTS, '', 'maximized', false); $output .= '<ul class="news-block">'; for ($news_ind = 0; $news_ind < $all_news[1]; $news_ind++) { if ($news_ind + 1 > $news_count) { break; } // Show first X news $news_str = $all_news[0][$news_ind]['header_text']; // Display Y first chars $news_str = strlen($news_str) > $news_header_length ? substr($all_news[0][$news_ind]['header_text'], 0, $news_header_length) . '...' : $news_str; $output .= '<li>' . $news_str . '<br />'; $output .= prepare_link('news', 'nid', $all_news[0][$news_ind]['id'], $news_str, '<i>' . _READ_MORE . ' »</i>', 'category-news'); $output .= '</li>'; } if ($news_ind == 0) { $output .= '<li>' . _NO_NEWS . '</li>'; } $output .= '</ul>'; $output .= draw_block_bottom(false); if ($draw) { echo $output; } else { return $output; } }
$country_slug = $slug['slug']; $rsss = $db->array_select("SELECT * FROM rss WHERE country_id = '{$country_id}' AND active='1'"); foreach ($rsss as $rss) { $content = file_get_contents($rss['link']); $xmlfeed = new SimpleXmlElement($content); $author = $xmlfeed->channel->link; $first = strpos($author, '.'); $author = substr($author, $first + 1); $second = strpos($author, '/'); $author = substr($author, 0, $second); foreach ($xmlfeed->channel->item as $entry) { if (strpos($entry->pubDate, $today)) { $title = $db->escape_string($entry->title); $double = $db->num_rows("SELECT id FROM news WHERE title = '{$title}'"); if ($double == 0) { $link = $db->escape_string($entry->link); $pubDate = $entry->pubDate; $date = convert_date($pubDate); $description = prepare_description($entry->description); $site_link = prepare_link($title, $country_slug); $metakeywords = prepare_metakeywords($description); $metadescription = prepare_metadescription($description); $sql = $db->execute("INSERT INTO news (country_id, author, title, description, site_link, link, pubdate, metadescription, metakeywords) VALUES ('{$country_id}', '{$author}', '{$title}', '{$description}', '{$site_link}','{$link}', '{$date}', '{$metadescription}', '{$metakeywords}')"); } } } } } } //delete entries older than 2 days $sql = $db->execute("DELETE from news WHERE (pubdate NOT LIKE '%{$today2}%' AND pubdate NOT LIKE '%{$yesterday}%' AND pubdate NOT LIKE '%{$yesterday2}%')");