Beispiel #1
0
function sb_featured_func($atts)
{
    global $sb_config;
    $a = '<!-- The Gallery as inline carousel, can be positioned anywhere on the page -->
		<div id="sb_blueimp-gallery-carousel" class="sb_blueimp-gallery sb_blueimp-gallery-carousel">
			<div class="sb_slides"></div>
			<h3 class="sb_slide_title" class="display: none; color: black !important;"></h3>
			<p class="sb_featured_description" style="cursor: pointer;"></p>
			<a class="sb_prev">&lsaquo;</a>
			<a class="sb_next">&rsaquo;</a>
			<ol class="sb_indicator"></ol>
		</div>
		';
    $path = $sb_config['server_address'] . '/wp_feed/featured';
    $xml = sb_load_xml($path);
    $a .= "<div id='sb_links'>";
    $n = 1;
    foreach ($xml->boat as $b) {
        $desc = $b->builder . ' ' . $b->model . ", ";
        if ($b->suffix == true) {
            $desc .= number_format(intval($b->price), 0) . '&nbsp;' . $b->symbol;
        } else {
            $desc .= $b->symbol . number_format(intval($b->price), 0);
        }
        if (isset($b->tax_message)) {
            $desc .= ' ' . $b->tax_message;
        } else {
            if ($b->vat_paid == true) {
                $desc .= ' ' . $b->tax_label . ' ' . __('paid', 'smartbroker');
            } else {
                $desc .= ' ' . $b->tax_label . ' ' . __('not paid', 'smartbroker');
            }
        }
        $a .= "<a href='" . $sb_config['server_address'] . "/images/boats/" . $b->boat_id . "/large/" . $b->photo_id . ".jpg' data-description='{$desc}'\r\n\t\tdata-link='/?page_id={$sb_config['listing_page']}&boat_id=" . $b->boat_id . "'></a>";
        $n++;
    }
    $a .= "</div>";
    echo $a;
}
Beispiel #2
0
function sb_listing_func()
{
    global $sb_config, $user_email, $user_identity, $current_user, $wp_query;
    include_once 'utility_functions.php';
    $boat_id = '';
    //var_dump($wp_query->query_vars);
    if (array_key_exists('boat_id', $_GET)) {
        $boat_id = $_GET['boat_id'];
    } else {
        $boat_id = get_query_var('boat_id');
        //used if there's a rewrite in operation
    }
    if (array_key_exists('server', $_GET) and $_GET['server'] != '') {
        $sb_config['server_address'] = urldecode($_GET['server']);
    } elseif (get_query_var('server_address', 'none') != 'none') {
        $sb_config['server_address'] = get_query_var('server_address');
        //used if there's a rewrite in operation
    }
    $sb_config['video_link'] = '<div class="sb_clean_thumb" style="display: none;">
		<a href="http://www.youtube.com/watch?v=%1$s?rel=0&wmode=opaque&modestbranding=1&showinfo=0&theme=light" rel="sb_prettyPhoto[all]" title="Video: %2$s" style="text-decoration: none;">
			<div class="sb_clean_vt_holder">
				<span>&#9654;</span>
			</div>
		</a>
	</div>';
    //configure tracking, if required
    $tracking_code = '';
    if (is_user_logged_in() and array_key_exists('sb_tracking', $sb_config)) {
        $tracking_code = "&track=true&a1=" . urlencode($user_email) . "&a2=" . urlencode($current_user->display_name);
    }
    $site_id = explode(".", $sb_config['server_address']);
    $site_id = $site_id[0];
    $site_id = explode("/", $site_id);
    $site_id = end($site_id);
    $xml_file = $sb_config['server_address'] . "/system/wp_plugin/boat.php?boat_id={$boat_id}";
    $xml = sb_load_xml($xml_file);
    if ($xml !== FALSE) {
        //check if we're using a server other than the default, and substitute in the proper config node if required
        $sb_temp_config = get_option('sb_plugin_options');
        if ($sb_config['server_address'] != $sb_temp_config['server_address']) {
            $xml_file = $sb_temp_config['server_address'] . "/system/wp_plugin/boat.php?boat_id=0";
            $xml2 = sb_load_xml($xml_file);
            $domToChange = dom_import_simplexml($xml->config);
            $domReplace = dom_import_simplexml($xml2->config);
            $nodeImport = $domToChange->ownerDocument->importNode($domReplace, TRUE);
            $domToChange->parentNode->replaceChild($nodeImport, $domToChange);
        }
        //--------------------------------------------
        // Format price
        //--------------------------------------------
        //load exchange rates into sb_config
        foreach ($xml->currencies->currency as $c) {
            $sb_config['currencies'][strval($c->currency)] = array('rate' => floatval($c->rate), 'symbol' => strval($c->symbol), 'name' => strval($c->name), 'suffix' => strval($c->suffix));
        }
        $currency = $xml->boat->currency;
        $curr_symbol = $xml->boat->symbol;
        $value = floatval($xml->boat->asking_price);
        //Tax label
        $vat_paid = $xml->boat->vat_included;
        if ($vat_paid == '1') {
            $vat_message = $xml->config->tax_label . " " . $xml->config->tax_paid_label;
        } else {
            $vat_message = $xml->config->tax_label . " " . $xml->config->tax_not_paid_label;
        }
        if ($sb_config['hide_tax_label'] == 'on') {
            $vat_message = '';
        }
        if ($xml->boat->suffix == 1) {
            $price = number_format($value, 0) . '&nbsp;' . $curr_symbol . ' ' . $vat_message;
        } else {
            $price = $curr_symbol . number_format($value, 0) . ' ' . $vat_message;
        }
        //add currency conversion if not in primary currency
        $currency_conversion = currency_conversion($value, $currency);
        //--------------------------------------------
        // Format provisional message
        //--------------------------------------------
        $prov = $xml->boat->approved;
        $prov_message = '';
        if ($prov != 'true') {
            $prov_message = '<p><em>' . $xml->config->provisional_listing_disclaimer . '</em></p>';
        }
        //--------------------------------------------
        // Compile specification categories
        //--------------------------------------------
        $cats = '';
        $i = '';
        $j = '';
        $k = '';
        foreach ($xml->boat->specifications->categories->category as $category) {
            $e = "<hr/><h3>" . $category->name . "</h3><hr/><p>";
            foreach ($category->item as $item) {
                $e .= $item->name;
                $note = $item->note;
                //note already includes units in XML feed
                if ($note != '') {
                    $e .= ": " . $note;
                }
                $e .= "<br/>";
            }
            $e = substr($e, 0, -5) . "</p>";
            if (strlen($i) > strlen($j) and strlen($j) >= strlen($k)) {
                $k .= $e;
            } elseif (strlen($i) > strlen($k) and strlen($k) >= strlen($j)) {
                $j .= $e;
            } else {
                $i .= $e;
            }
        }
        $cats = "<div class='smartbroker_section smartbroker_group'>\r\n\t\t\t\t\t<div class='smartbroker_col smartbroker_span_1_of_3'>{$i}</div>\r\n\t\t\t\t\t<div class='smartbroker_col smartbroker_span_1_of_3'>{$j}</div>\r\n\t\t\t\t\t<div class='smartbroker_col smartbroker_span_1_of_3'>{$k}</div>\r\n\t\t\t\t</div>";
        //--------------------------------------------
        // Compile media
        //--------------------------------------------
        $m = "<div id='sb_clean_thumb_window'>";
        foreach ($xml->boat->media->media as $media) {
            if ($media['type'] == 'photo') {
                $m .= build_photo($media->link, $media->path, $media->description, $boat_id, $xml);
            } elseif ($media['type'] == 'video') {
                $m .= sprintf($sb_config['video_link'], $media->video_id, $media->description);
            }
        }
        $m .= "</div>";
        //count photos and videos
        $photos = $xml->xpath('//*[@type="photo"]');
        $num_photos = count($photos);
        $videos = $xml->xpath('//*[@type="video"]');
        $num_videos = count($videos);
        if ($num_photos > 8 or $num_videos > 0) {
            $m .= "<a id='sb_view_all_link' href='#' style='text-align: right; display: block;'>+ ";
            if ($num_photos - 9 == 1) {
                $mes .= " 1 more photo";
            }
            if ($num_photos - 9 > 1) {
                $mes .= $num_photos - 9 . " more photos";
            }
            if ($num_videos == 1) {
                if ($mes != '') {
                    $mes .= ' and';
                }
                $mes .= " 1 video";
            }
            if ($num_videos > 1) {
                if ($mes != '') {
                    $mes .= ' and';
                }
                $mes .= " {$num_videos} videos";
            }
            $m .= $mes . "</a>";
        }
        //--------------------------------------------
        // Sort the find out more div
        //--------------------------------------------
        include_once 'find_out_more.php';
        $brokers_notes = nl2br($xml->boat->brokers_notes);
        if ($brokers_notes == '') {
            $brokers_notes = "<em>" . __("(There are no broker's notes available for this boat)", 'smartbroker') . "</em>";
        }
        //--------------------------------------------
        // Status label (if required)
        //--------------------------------------------
        $label = '';
        if ($xml->boat->add_label == 1) {
            $label = $xml->boat->status_text . '<br/>';
        }
        //--------------------------------------------
        // Catch widgets into variables
        //--------------------------------------------
        ob_start();
        dynamic_sidebar('sb_listing_under_photos');
        $wd1 = ob_get_contents();
        ob_end_clean();
        //--------------------------------------------
        // Build image & key facts blocks
        //--------------------------------------------
        $image_link = $sb_config['server_address'] . "/images/boats/{$boat_id}/large/" . $xml->boat->primary_photo . ".jpg";
        $image = "<div id='sb_primary_image'>\r\n\t\t\t\t<a href='{$image_link}' rel='sb_prettyPhoto[all]' title=''>\r\n\t\t\t\t<img src='{$image_link}' title='' alt='" . $xml->boats->model . "'/>\r\n\t\t\t\t</a>\t \r\n\t\t\t</div>\r\n\t\t\t<div class='sb_no_print'>{$m}</div>{$wd1}";
        //key facts
        $kf = "<div class='sb_wide_only'><h1 style='clear: left;'><span id='sb_boat_builder_and_model'>" . $xml->boat->builder . " " . $xml->boat->model . "</span>" . $admin_link . "</h1></div>\r\n\t\t<h2 style='clear: left;'><span class='sb_price_message'>{$label}" . $price . "\r\n\t\t<br /><small>" . $currency_conversion . "</small></span></h2>\r\n\t\t<p><span class='sb_year_message'>" . __('Built', 'smartbroker') . ': ' . $xml->boat->year . "</span><span class='sb_lying_message'><br/>" . __('Currently lying', 'smartbroker') . ': ' . $xml->boat->region . ", " . $xml->boat->country_name . "</span></p>";
        if ($xml->boat->approved == 'false') {
            $kf .= $prov_message;
        }
        //--------------------------------------------
        // Data required by javascript
        //--------------------------------------------
        $a = "<div style='display: none;' id='server_address_address'>" . $sb_config['server_address'] . "</div>";
        $a .= "<div style='display: none;' id='sb_listing_page'>" . $sb_config['listing_page'] . "</div>";
        //--------------------------------------------
        // Compile main layout
        //--------------------------------------------
        $a .= "\r\n\t\t<div class='sb_wrapper sb_theme_clean'>\r\n\t\t<div class='sb_narrow_only'><h1 style='clear: left;'><span id='sb_boat_builder_and_model'>" . $xml->boat->builder . " " . $xml->boat->model . "</span></h1></div>\r\n\t\t<div>\r\n\t\t\t<div id='sb_clean_images'>\r\n\t\t\t\t{$image}\r\n\t\t\t</div>\r\n\t\t\t{$kf}\r\n\t\t\t<div class='sb_no_print'>\r\n\t\t\t\t<button onclick=\"location.href='#sb_find_out_more';\" style='position: relative !important;' \\>\r\n\t\t\t\t\t" . __('Contact us about this boat', 'smartbroker') . "\r\n\t\t\t\t</button>\r\n\t\t\t\t<br/><br/>\r\n\t\t\t</div>\r\n\t\t\t<hr style='clear: left;'/>\r\n\t\t\t<p><br/>{$brokers_notes}</p>\r\n\t\t</div>\r\n\t\t{$cats}\r\n\t\t<hr/><div class='sb_no_print'><a name='sb_find_out_more'></a><h3>" . __('Find out more', 'smartbroker') . "</h3>{$find_out_more}</div>\r\n\t\t<hr /><p><small>" . $xml->config->disclaimer . "</small></p>\r\n\t\t</div> <!--end sb_wrapper -->";
        return $a;
    }
}
Beispiel #3
0
function load_results_xml($data)
{
    global $sb_config;
    foreach ($data as $k => $v) {
        //if (array_key_exists($k, $_GET) AND (intval($_GET[$k]) == 0)) {
        $_GET[$k] = $v;
        //	}
    }
    $search_string = http_build_query($_GET);
    if (!array_key_exists('auth', $sb_config)) {
        $sb_config['auth'] = '';
    }
    $xml_file = $sb_config['server_address'] . "/system/wp_plugin/search.php?auth={$sb_config['auth']}&" . $search_string;
    $xml = sb_load_xml($xml_file);
    return $xml;
}