protected function _prepareDocument()
 {
     $document = JFactory::getDocument();
     $uri = clone JUri::getInstance();
     $domain = $uri->toString(array('scheme', 'host', 'port'));
     $canonicalLink = $domain . JRoute::_(JUDirectoryHelperRoute::getListingRoute($this->item->id, $this->_layout), false);
     JUDirectoryFrontHelper::setCanonical($canonicalLink);
     $document->addCustomTag('<meta property="og:title" content="' . htmlspecialchars(strip_tags($this->item->title), ENT_COMPAT, 'UTF-8') . '" />');
     $document->addCustomTag('<meta property="og:type" content="website" />');
     $listingImage = JUDirectoryHelper::getListingImage($this->item->image);
     if ($listingImage) {
         $document->addCustomTag('<meta property="og:image" content="' . $listingImage . '" />');
     }
     $document->addCustomTag('<meta property="og:url" content="' . $canonicalLink . '" />');
     $document->addCustomTag('<meta property="og:description" content="' . htmlspecialchars(strip_tags($this->item->description), ENT_COMPAT, 'UTF-8') . '" />');
     $conf = JFactory::getConfig();
     if (JUDirectoryHelper::isJoomla3x()) {
         $siteName = $conf->get('sitename');
     } else {
         $siteName = $conf->getValue('config.sitename');
     }
     $document->addCustomTag('<meta property="og:site_name" content="' . htmlspecialchars(strip_tags($siteName), ENT_COMPAT, 'UTF-8') . '" />');
     JUDirectoryFrontHelperSeo::seo($this);
 }
Exemple #2
0
 public static function getLocations($listings)
 {
     $locations = array();
     $listingIds = array();
     if ($listings) {
         foreach ($listings as $listing) {
             $listingIds[] = $listing->id;
         }
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('location.*, listing.image AS listing_image, listing.title')->from('#__judirectory_locations AS location')->join('', '#__judirectory_listings AS listing ON listing.id = location.listing_id')->where('listing.id IN (' . implode(',', $listingIds) . ')');
         $db->setQuery($query);
         $locations = $db->loadObjectList();
         $locationIconUrl = JUri::root(true) . '/media/com_judirectory/images/location/';
         JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_judirectory/tables');
         $addressTable = JTable::getInstance('Address', 'JUDirectoryTable');
         foreach ($locations as $location) {
             if ($location->image) {
                 $location->image = $locationIconUrl . $location->listing_id . '/' . $location->image;
             } else {
                 $location->image = JUDirectoryHelper::getListingImage($location->listing_image);
             }
             $addresses = self::getAddresses($addressTable, $location->address_id);
             $addresses[] = $location->address;
             $location->address = implode(', ', array_reverse($addresses));
             $location->link = JRoute::_(JUDirectoryHelperRoute::getListingRoute($location->listing_id));
             $location->description = nl2br($location->description);
         }
     }
     return $locations;
 }
 public function getOutput($options = array())
 {
     if (!$this->isPublished()) {
         return "";
     }
     if (!$this->value) {
         return "";
     }
     $image_src = JUDirectoryHelper::getListingImage($this->value);
     if (!$this->listing_id || !$image_src) {
         return '';
     }
     $isDetailsView = $this->isDetailsView($options);
     $this->setVariable('image_src', $image_src);
     $this->setVariable('isDetailsView', $isDetailsView);
     return $this->fetch('output.php', __CLASS__);
 }
Exemple #4
0
 public function getRelatedListings()
 {
     $app = JFactory::getApplication();
     $listing_id = $app->input->getInt('id', 0);
     $relatedListingIds = $app->getUserState("com_judirectory.edit.listing.related_listings", array());
     $related_listings = array();
     if ($relatedListingIds) {
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('listing.id, listing.title, listing.image');
         $query->from('#__judirectory_listings AS listing');
         $query->where('listing.id IN (' . implode(',', $relatedListingIds) . ')');
         $db->setQuery($query);
         $related_listings = $db->loadObjectList();
     } elseif ($listing_id) {
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('listing.id, listing.title, listing.image');
         $query->from('#__judirectory_listings_relations AS listingrel');
         $query->join('INNER', '#__judirectory_listings AS listing ON listingrel.listing_id_related = listing.id');
         $query->where('listingrel.listing_id = ' . $listing_id);
         $query->order('listingrel.ordering ASC');
         $db->setQuery($query);
         $related_listings = $db->loadObjectList();
     }
     if ($related_listings) {
         foreach ($related_listings as $listing) {
             $listing->image_src = JUDirectoryHelper::getListingImage($listing->image);
         }
     }
     return $related_listings;
 }