<?php if ($config['show_intro']) { ?> <div class="uiwelcome"><?php echo stripslashes_deep(get_awpcp_option('uiwelcome')); ?> </div> <?php } ?> <?php if ($config['show_menu']) { ?> <?php echo awpcp_menu_items(); ?> <?php } ?> <?php echo join('', $before_content); ?> <?php echo $pagination_block; ?> <div class="awpcp-listings awpcp-clearboth"><?php echo join('', $items); ?>
/** * @deprecated 3.4 */ function awpcp_display_ads($where, $byl, $hidepager, $grouporderby, $adorcat, $before_content = '') { _deprecated_function(__FUNCTION__, '3.4', 'awpcp_display_listings'); global $wpdb; global $awpcp_plugin_path; global $hasregionsmodule; $output = ''; $awpcp_browsecats_pageid = awpcp_get_page_id_by_ref('browse-categories-page-name'); $browseadspageid = awpcp_get_page_id_by_ref('browse-ads-page-name'); $searchadspageid = awpcp_get_page_id_by_ref('search-ads-page-name'); // filters to provide alternative method of storing custom layouts (e.g. can be outside of this plugin's directory) if (has_action('awpcp_browse_ads_template_action') || has_filter('awpcp_browse_ads_template_filter')) { do_action('awpcp_browse_ads_template_action'); $output = apply_filters('awpcp_browse_ads_template_filter'); return; } else { if (file_exists("{$awpcp_plugin_path}/awpcp_display_ads_my_layout.php") && get_awpcp_option('activatemylayoutdisplayads')) { include "{$awpcp_plugin_path}/awpcp_display_ads_my_layout.php"; } else { $output .= "<div id=\"classiwrapper\">"; $uiwelcome = stripslashes_deep(get_awpcp_option('uiwelcome')); $output .= apply_filters('awpcp-content-before-listings-page', ''); $output .= "<div class=\"uiwelcome\">{$uiwelcome}</div>"; $output .= awpcp_menu_items(); if ($hasregionsmodule == 1) { // Do not show Region Control form when showing Search Ads page // search result. Changing the current location will redirect the user // to the form instead of a filterd version of the form and that's confusing if (is_page(awpcp_get_page_id_by_ref('search-ads-page-name')) && isset($_POST['a']) && $_POST['a'] == 'dosearch') { // do nothing } else { $output .= awpcp_region_control_selector(); } } $output .= $before_content; $tbl_ads = $wpdb->prefix . "awpcp_ads"; $from = "{$tbl_ads}"; $ads_exist = ads_exist(); if (!$ads_exist) { $showcategories = "<p style=\"padding:10px\">"; $showcategories .= __("There are currently no ads in the system", "AWPCP"); $showcategories .= "</p>"; $pager1 = ''; $pager2 = ''; } else { $awpcp_image_display_list = array(); if ($adorcat == 'cat') { $tpname = get_permalink($awpcp_browsecats_pageid); } elseif ($adorcat == 'search') { $tpname = get_permalink($searchadspageid); } elseif (preg_match('/^custom:/', $adorcat)) { $tpname = str_replace('custom:', '', $adorcat); } else { $tpname = get_permalink($browseadspageid); } $results = get_awpcp_option('adresultsperpage', 10); $results = absint(awpcp_request_param('results', $results)); $offset = absint(awpcp_request_param('offset', 0)); if ($results === 0) { $results = 10; } $args = array('order' => AWPCP_Ad::get_order_conditions($grouporderby), 'offset' => $offset, 'limit' => $results); $ads = AWPCP_Ad::get_enabled_ads($args, array($where)); // get_where_conditions() is called from get_enabled_ads(), we need the // WHERE conditions here to pass them to create_pager() $where = AWPCP_Ad::get_where_conditions(array($where)); if (!isset($hidepager) || empty($hidepager)) { //Unset the page and action here...these do the wrong thing on display ad unset($_GET['page_id']); unset($_POST['page_id']); //unset($params['page_id']); $pager1 = create_pager($from, join(' AND ', $where), $offset, $results, $tpname); $pager2 = create_pager($from, join(' AND ', $where), $offset, $results, $tpname); } else { $pager1 = ''; $pager2 = ''; } $items = awpcp_render_listings_items($ads, 'listings'); $opentable = ""; $closetable = ""; if (empty($ads)) { $showcategories = "<p style=\"padding:20px;\">"; $showcategories .= __("There were no ads found", "AWPCP"); $showcategories .= "</p>"; $pager1 = ''; $pager2 = ''; } else { $showcategories = smart_table($items, intval($results / $results), $opentable, $closetable); } } $show_category_id = absint(awpcp_request_param('category_id')); if (!isset($url_browsecatselect) || empty($url_browsecatselect)) { $url_browsecatselect = get_permalink($awpcp_browsecats_pageid); } if ($ads_exist) { $category_id = (int) awpcp_request_param('category_id', -1); $category_id = $category_id === -1 ? (int) get_query_var('cid') : $category_id; $output .= "<div class=\"changecategoryselect\"><form method=\"post\" action=\"{$url_browsecatselect}\">"; $output .= '<div class="awpcp-category-dropdown-container">'; $dropdown = new AWPCP_CategoriesDropdown(); $output .= $dropdown->render(array('context' => 'search', 'name' => 'category_id', 'selected' => $category_id)); $output .= '</div>'; $output .= "<input type=\"hidden\" name=\"a\" value=\"browsecat\" /> <input class=\"button\" type=\"submit\" value=\""; $output .= __("Change Category", "AWPCP"); $output .= "\" /></form></div>"; $output .= "<div class=\"pager\">{$pager1}</div><div class=\"fixfloat\"></div>"; $output .= "<div id='awpcpcatname' class=\"fixfloat\">"; if ($category_id > 0) { $output .= "<h3>" . __("Category: ", "AWPCP") . get_adcatname($category_id) . "</h3>"; } $output .= "</div>"; } $output .= apply_filters('awpcp-display-ads-before-list', ''); $output .= "{$showcategories}"; if ($ads_exist) { $output .= " <div class=\"pager\">{$pager2}</div>"; } $output .= apply_filters('awpcp-content-after-listings-page', ''); $output .= "</div>"; } } return $output; }
/** * Handles AWPCPSHOWAD shortcode. * * @param $adid An Ad ID. * @param $omitmenu * @param $preview true if the function is used to show an ad just after * it was posted to the website. * @param $send_email if true and $preview=true, a success email will be send * to the admin and poster user. * * @return Show Ad page content. */ function showad($adid = null, $omitmenu = false, $preview = false, $send_email = true, $show_messages = true) { global $wpdb; awpcp_maybe_add_thickbox(); wp_enqueue_script('awpcp-page-show-ad'); $awpcp = awpcp(); $awpcp->js->set('page-show-ad-flag-ad-nonce', wp_create_nonce('flag_ad')); $awpcp->js->localize('page-show-ad', array('flag-confirmation-message' => __('Are you sure you want to flag this ad?', 'AWPCP'), 'flag-success-message' => __('This Ad has been flagged.', 'AWPCP'), 'flag-error-message' => __('An error occurred while trying to flag the Ad.', 'AWPCP'))); $preview = $preview === true || 'preview' == awpcp_array_data('adstatus', '', $_GET); $is_moderator = awpcp_current_user_is_moderator(); $messages = array(); $permastruc = get_option('permalink_structure'); if (!isset($adid) || empty($adid)) { if (isset($_REQUEST['adid']) && !empty($_REQUEST['adid'])) { $adid = $_REQUEST['adid']; } elseif (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) { $adid = $_REQUEST['id']; } else { if (isset($permastruc) && !empty($permastruc)) { $adid = get_query_var('id'); } else { $adid = 0; } } } $adid = absint($adid); if (!empty($adid)) { // filters to provide alternative method of storing custom // layouts (e.g. can be outside of this plugin's directory) $prefix = 'awpcp_single_ad_template'; if (has_action("{$prefix}_action") || has_filter("{$prefix}_filter")) { do_action("{$prefix}_action"); return apply_filters("{$prefix}_filter"); } else { $results = AWPCP_Ad::query(array('where' => $wpdb->prepare('ad_id = %d', $adid))); if (count($results) === 1) { $ad = array_shift($results); } else { $ad = null; } if (is_null($ad)) { $message = __('Sorry, that listing is not available. Please try browsing or searching existing listings.', 'AWPCP'); return '<div id="classiwrapper">' . awpcp_print_error($message) . '</div><!--close classiwrapper-->'; } if ($ad->user_id > 0 && $ad->user_id == wp_get_current_user()->ID) { $is_ad_owner = true; } else { $is_ad_owner = false; } $content_before_page = apply_filters('awpcp-content-before-listing-page', ''); $content_after_page = apply_filters('awpcp-content-after-listing-page', ''); $output = '<div id="classiwrapper">%s%s<!--awpcp-single-ad-layout-->%s</div><!--close classiwrapper-->'; $output = sprintf($output, $content_before_page, $omitmenu ? '' : awpcp_menu_items(), $content_after_page); if (!$is_moderator && !$is_ad_owner && !$preview && $ad->disabled == 1) { $message = __('The Ad you are trying to view is pending approval. Once the Administrator approves it, it will be active and visible.', 'AWPCP'); return str_replace('<!--awpcp-single-ad-layout-->', awpcp_print_error($message), $output); } if (awpcp_request_param('verified') && $ad->verified) { $messages[] = awpcp_print_message(__('Your email address was successfully verified.', 'AWPCP')); } if ($show_messages && $is_moderator && $ad->disabled == 1) { $message = __('This Ad is currently disabled until the Administrator approves it. Only you (the Administrator) and the author can see it.', 'AWPCP'); $messages[] = awpcp_print_error($message); } else { if ($show_messages && ($is_ad_owner || $preview) && !$ad->verified) { $message = __('This Ad is currently disabled until you verify the email address used for the contact information. Only you (the author) can see it.', 'AWPCP'); $messages[] = awpcp_print_error($message); } else { if ($show_messages && ($is_ad_owner || $preview) && $ad->disabled == 1) { $message = __('This Ad is currently disabled until the Administrator approves it. Only you (the author) can see it.', 'AWPCP'); $messages[] = awpcp_print_error($message); } } } $layout = awpcp_get_listing_single_view_layout($ad); $layout = awpcp_do_placeholders($ad, $layout, 'single'); $output = str_replace('<!--awpcp-single-ad-layout-->', join('', $messages) . $layout, $output); $output = apply_filters('awpcp-show-ad', $output, $adid); if (!awpcp_request()->is_bot()) { $ad->visit(); } $ad->save(); } } else { $query = array('limit' => absint(awpcp_request_param('results', get_awpcp_option('adresultsperpage', 10))), 'offset' => absint(awpcp_request_param('offset', 0)), 'orderby' => get_awpcp_option('groupbrowseadsby')); $output = awpcp_display_listings_in_page($query, 'show-listing'); } return $output; }
function awpcp_display_the_classifieds_page_body($awpcppagename) { global $hasregionsmodule; $output = ''; if (!isset($awpcppagename) || empty($awpcppagename)) { $awpcppage = get_currentpagename(); $awpcppagename = sanitize_title($awpcppage, $post_ID = ''); } $output .= "<div id=\"classiwrapper\">"; $uiwelcome = strip_slashes_recursive(get_awpcp_option('uiwelcome')); $output .= "<div class=\"uiwelcome\">{$uiwelcome}</div>"; // Place the menu items $output .= awpcp_menu_items(); if ($hasregionsmodule == 1) { $output .= awpcp_region_control_selector(); } $output .= "<div class=\"classifiedcats\">"; //Display the categories $params = array('show_in_columns' => get_awpcp_option('view-categories-columns'), 'show_empty_categories' => !get_awpcp_option('hide-empty-categories'), 'show_children_categories' => true, 'show_listings_count' => get_awpcp_option('showadcount'), 'show_sidebar' => true); $output .= awpcp_categories_list_renderer()->render($params); $output .= "</div>"; $output .= "</div>"; return $output; }
function deletead($adid, $adkey, $editemail, $force = false, &$errors = array()) { $output = ''; $awpcppage = get_currentpagename(); $awpcppagename = sanitize_title($awpcppage, $post_ID = ''); $isadmin = checkifisadmin() || $force; if (get_awpcp_option('onlyadmincanplaceads') && $isadmin != 1) { $message = __("You do not have permission to perform the function you are trying to perform. Access to this page has been denied", "AWPCP"); $errors[] = $message; } else { global $wpdb, $nameofsite; $tbl_ads = $wpdb->prefix . "awpcp_ads"; $tbl_ad_photos = $wpdb->prefix . "awpcp_adphotos"; $savedemail = get_adposteremail($adid); if ($isadmin == 1 || strcasecmp($editemail, $savedemail) == 0) { $ad = AWPCP_Ad::find_by_id($adid); if ($ad && $ad->delete()) { if ($isadmin == 1 && is_admin()) { $message = __("The Ad has been deleted", "AWPCP"); return $message; } else { $message = __("Your Ad details and any photos you have uploaded have been deleted from the system", "AWPCP"); $errors[] = $message; } } else { if ($ad === null) { $errors[] = __("The specified Ad doesn't exists.", 'AWPCP'); } else { $errors[] = __("There was an error trying to delete the Ad. The Ad was not deleted.", 'AWPCP'); } } } else { $message = __("Problem encountered. Cannot complete request", "AWPCP"); $errors[] = $message; } } $output .= "<div id=\"classiwrapper\">"; $output .= awpcp_menu_items(); $output .= "<p>"; $output .= $message; $output .= "</p>"; $output .= "</div>"; return $output; }