     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99:

    <?php

    namespace WPGMZA\MarkerListing;

    class BasicTable extends \WPGMZA\MarkerListing
    {
        public function __construct($map_id)
        {
            \WPGMZA\MarkerListing::__construct($map_id);
        }

        public function getAjaxResponse($request)
        {
            global $wpgmza;

            $response = $this->getRecords($request);

            $document = new \WPGMZA\DOMDocument();
            $document->loadPHPFile($this->getItemHTMLPath() . 'basic-table-item.html.php');

            $template = $document->querySelector("body>*");
            $template->remove();

            if(!$this->map->isDirectionsEnabled())
            {
                foreach($template->querySelectorAll(".wpgmza_gd") as $el)
                    $el->remove();
            }

            $imageDimensions = $this->getImageDimensions();

            foreach($response->data as $marker)
            {
                $item = $template->cloneNode(true);

                if($wpgmza->settings->useLegacyHTML)
                {
                    if(isset($request['map_id']))
                        $item->setAttribute('mapid',    $request['map_id']);

                    // Attributes
                    $item->setAttribute('id', "wpgmza_marker_{$marker->id}");
                    $item->setAttribute('mid', $marker->id);

                    // Image
                    $img = $item->querySelector('.wpgmza_map_image');
                    if(!empty($marker->pic))
                        $img->setAttribute('src', $marker->pic);
                    $img->setInlineStyle('width', "{$imageDimensions->width}px");
                    $img->setInlineStyle('height', "{$imageDimensions->height}px");

                    // Title
                    $title = $item->querySelector('.wpgmza_marker_title a');
                    $title->setAttribute('title', $marker->title);
                    $title->appendText($marker->title);

                    // Address
                    $address = $item->querySelector(".wpgmza-address");
                    $address->appendText($marker->address);

                    // Description
                    $item->querySelector(".wpgmza-desc>p")->import($marker->description);

                    // Icon
                    $item->querySelector('.wpgmza_marker_icon')->setAttribute('src', $marker->icon);

                    // Directions
                    $directions = $item->querySelector('.wpgmza_gd');
                    if($directions)
                    {
                        $directions->setAttribute('wpgm_addr_field', $marker->address);
                        $directions->setAttribute('gps', "{$marker->lat},{$marker->lng}");
                    }

                    // Link
                    $a = $item->querySelector('.wpgmza-link > a, .wpgmza_marker_link > a');
                    $text = __('More Details', 'wp-google-maps');

                    if(!empty($wpgmza->settings->wpgmza_settings_infowindow_link_text))
                        $text = $wpgmza->settings->wpgmza_settings_infowindow_link_text;

                    if($a && !empty($marker->link))
                    {
                        $a->setAttribute('href', $marker->link);
                        $a->appendText($text);
                    }
                }

                $this->appendListingItem($document, $item, $marker);
            }

            $response->html = $document->saveInnerBody();

            unset($response->data);

            return $response;
        }
    }