| Current Path : /home/h/e/l/helpink/www/components/com_jbusinessdirectory/helpers/ |
| Current File : /home/h/e/l/helpink/www/components/com_jbusinessdirectory/helpers/listing_styles.php |
<?php
/**
* @package J-BusinessDirectory
*
* @author CMSJunkie http://www.cmsjunkie.com/
* @copyright Copyright (C) 2007 - 2022 CMSJunkie. All rights reserved.
* @license https://www.gnu.org/licenses/agpl-3.0.en.html
*/
defined('_JEXEC') or die('Restricted access');
/**
* Class to handle common listing style functionality
*/
class JBDListingStyles {
/**
* Get rating display HTML
* @param object $company Company object
* @param object $appSettings Application settings
* @return string HTML for rating display
*/
public static function getRatingDisplay($company, $appSettings) {
if (!($appSettings->enable_packages && $appSettings->enable_reviews && isset($company->package->features) && in_array(REVIEWS, $company->package->features) || !$appSettings->enable_packages && $appSettings->enable_reviews)) {
return '';
}
$html = '<div class="company-info-rating"' . (!$appSettings->enable_ratings ? ' style="display:none"' : '') . '>';
if (!empty($company->reviews) > 0) {
$html .= '<span style="display:none" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">';
$html .= '<span>';
$html .= '<span itemprop="itemReviewed" itemscope itemtype="http://schema.org/LocalBusiness">';
$html .= '<span itemprop="name">' . $company->name . '</span>';
$html .= '<span itemprop="image">' . BD_PICTURES_PATH . $company->logoLocation . '</span>';
$html .= '<span itemprop="address">' . JBusinessUtil::getAddressText($company) . '</span>';
$html .= '<span itemprop="telephone">' . $company->phone . '</span>';
$html .= '</span>';
$html .= '<span itemprop="ratingValue">' . $company->review_score . '</span>';
$html .= '<span itemprop="worstRating">0</span>';
$html .= '<span itemprop="bestRating">5</span>';
$html .= '</span>';
$html .= '<span itemprop="ratingCount">' . count($company->totalReviews) . '</span>';
$html .= '</span>';
}
$html .= '<div class="rating">';
$html .= '<span class="user-rating-avg" id="rating-average" title="' . $company->review_score . '" alt="' . $company->id . '" style="display: block;"></span>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
/**
* Get review actions HTML
* @param object $company Company object
* @param object $appSettings Application settings
* @param object $user Current user
* @return string HTML for review actions
*/
public static function getReviewActions($company, $appSettings, $user, $showAddReview = true) {
if (!($appSettings->enable_packages && $appSettings->enable_reviews && isset($company->package->features) && in_array(REVIEWS, $company->package->features) || !$appSettings->enable_packages && $appSettings->enable_reviews)) {
return '';
}
$html = '<div class="review-count">';
if (!empty($company->totalReviews)) {
$html .= '<a href="javascript:void(0)" onclick="jQuery(\'#dir-tab-3\').click()">' . count($company->totalReviews) . ' ' . JText::_('LNG_REVIEWS') . '</a>';
if($showAddReview) {
$html .= ' | ';
$html .= '<a href="javascript:void(0)" onclick="jbdReviews.addNewReviewOnTabs(' . ($appSettings->enable_reviews_users && $user->id == 0 ? "1" : "0") . ')">' . JText::_('LNG_WRITE_REVIEW') . '</a>';
}
} else {
if($showAddReview) {
$html .= '<a href="javascript:void(0)" onclick="jbdReviews.addNewReviewOnTabs(' . ($appSettings->enable_reviews_users && $user->id == 0 ? "1" : "0") . ')">' . JText::_('LNG_BE_THE_FIRST_TO_REVIEW') . '</a>';
}
}
$html .= '</div>';
return $html;
}
/**
* Get schema rating HTML
* @param object $company Company object
* @return string HTML for schema rating
*/
public static function getSchemaRating($company) {
$address = JBusinessUtil::getAddressText($company);
$html = '<span style="display:none" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">';
$html .= '<span>';
$html .= '<span itemprop="itemReviewed" itemscope itemtype="http://schema.org/LocalBusiness">';
$html .= '<span itemprop="name">' . $company->name . '</span>';
$html .= '<span itemprop="image">' . BD_PICTURES_PATH . $company->logoLocation . '</span>';
$html .= '<span itemprop="address">' . $address . '</span>';
$html .= '<span itemprop="telephone">' . $company->phone . '</span>';
$html .= '</span>';
$html .= '<span itemprop="ratingValue">' . $company->review_score . '</span>';
$html .= '<span itemprop="worstRating">0</span>';
$html .= '<span itemprop="bestRating">5</span>';
$html .= '</span>';
$html .= '<span itemprop="ratingCount">' . count($company->totalReviews) . '</span>';
$html .= '</span>';
return $html;
}
/**
* Get company contact info HTML
* @param object $company Company object
* @param object $appSettings Application settings
* @param boolean $showData Whether to show data
* @return string HTML for company contact info
*/
public static function getCompanyContactInfo($company, $appSettings, $showData = true) {
$html = '<ul class="item-details">';
$address = JBusinessUtil::getAddressText($company);
// Address
if ($showData && !empty($address)) {
$html .= '<li>';
$html .= '<div class="icon-wrapper"><i class="icon map-marker"></i></div>';
$html .= '<span itemprop="address">' . $address . '</span>';
$html .= '</li>';
}
// Phone numbers
if ($showData && (isset($company->package->features) && in_array(PHONE, $company->package->features) || !$appSettings->enable_packages)) {
$html .= self::getPhoneNumbers($company);
}
// Email
if (!empty($company->email) && $showData && $appSettings->show_email) {
$html .= self::getEmailInfo($company);
}
// Website
if ($showData && (isset($company->package->features) && in_array(WEBSITE_ADDRESS, $company->package->features) || !$appSettings->enable_packages) && !empty($company->website)) {
$html .= self::getWebsiteInfo($company, $appSettings);
}
// Content responsible
if (!empty($appSettings->content_responsible)) {
$html .= self::getContentResponsibleInfo($appSettings);
}
// Report abuse
if ($appSettings->enable_reporting) {
$html .= self::getReportAbuseInfo();
}
$html .= '</ul>';
return $html;
}
/**
* Get phone numbers HTML
* @param object $company Company object
* @return string HTML for phone numbers
*/
public static function getPhoneNumbers($company) {
$html = '';
if (!empty($company->phone)) {
$html .= '<li>';
$html .= '<div class="icon-wrapper"><i class="icon phone-o"></i></div>';
$html .= '<a href="tel:' . $company->phone . '"><span class="phone" itemprop="telephone">' . $company->phone . '</span></a>';
$html .= '</li>';
}
if (!empty($company->mobile)) {
$html .= '<li>';
$html .= '<div class="icon-wrapper"><i class="icon mobile"></i></div>';
$html .= '<a href="tel:' . $company->mobile . '"><span class="phone" itemprop="telephone">' . $company->mobile . '</span></a>';
$html .= '</li>';
}
if (!empty($company->fax)) {
$html .= '<li>';
$html .= '<div class="icon-wrapper"><i class="la la-fax la-fw"></i></div>';
$html .= '<span class="faxNumber">' . $company->fax . '</span>';
$html .= '</li>';
}
return $html;
}
/**
* Get email info HTML
* @param object $company Company object
* @return string HTML for email info
*/
public static function getEmailInfo($company) {
return '<li>
<div class="icon-wrapper"><i class="icon envelope"></i></div>
<a href="mailto:' . $company->email . '"><span itemprop="email">' . $company->email . '</span></a>
</li>';
}
/**
* Get website info HTML
* @param object $company Company object
* @param object $appSettings Application settings
* @return string HTML for website info
*/
public static function getWebsiteInfo($company, $appSettings) {
$html = '';
if ($appSettings->enable_link_following) {
$followLink = (isset($company->package->features) && in_array(LINK_FOLLOW, $company->package->features) && $appSettings->enable_packages)
? 'rel="follow noopener"'
: 'rel="nofollow noopener"';
} else {
$followLink = 'rel="noopener"';
}
$html .= '<li>';
$html .= '<div class="icon-wrapper"><i class="icon link-square"></i></div>';
$html .= '<a target="_blank" ' . $followLink . ' itemprop="url" title="' . $company->name . ' Website" onclick="jbdUtils.registerStatAction(' . $company->id . ',' . STATISTIC_ITEM_BUSINESS . ',' . STATISTIC_TYPE_WEBSITE_CLICK . ')" href="' . $company->website . '">' . $company->website . '</a>';
$html .= '</li>';
return $html;
}
/**
* Get content responsible info HTML
* @param object $appSettings Application settings
* @return string HTML for content responsible info
*/
public static function getContentResponsibleInfo($appSettings) {
return '<li>
<div class="icon-wrapper"><i class="icon info-circle"></i></div>
<a href="javascript:void(0)" id="content-responsible-link">' . JText::_('LNG_CONTENT_RESPONSIBLE_PERSON') . '</a>
<div id="content_responsible_text" style="display: none;">
' . JHTML::_("content.prepare", $appSettings->content_responsible) . '
</div>
</li>';
}
/**
* Get report abuse info HTML
* @return string HTML for report abuse info
*/
public static function getReportAbuseInfo() {
return '<li>
<div class="icon-wrapper"><i class="la la-flag"></i></div>
<a href="javascript:jbdListings.showReportAbuse()">' . JText::_('LNG_REPORT_LISTING') . '</a>
</li>';
}
/**
* Get company actions HTML
* @param object $company Company object
* @param object $appSettings Application settings
* @param object $user Current user
* @param boolean $showData Whether to show data
* @return string HTML for company actions
*/
public static function getCompanyActions($company, $appSettings, $user, $showData = true) {
$html = '<div class="contact-actions">';
// Quote request button
if ($showData && (isset($company->package->features) && in_array(CONTACT_FORM, $company->package->features) || !$appSettings->enable_packages)
&& !empty($company->email) && $appSettings->enable_request_quote) {
$html .= '<a class="btn btn-primary" href="javascript:jbdListings.showQuoteCompany(\'' . $company->id . '\',\'' . ($showData ? "1" : "0") . '\')">';
$html .= '<i class="la la-edit"></i> ' . JText::_("LNG_REQUEST_QUOTE") . '</a>';
}
// Contact form button
if ((isset($company->package->features) && in_array(CONTACT_FORM, $company->package->features) || !$appSettings->enable_packages)
&& !empty($company->email) && $appSettings->show_contact_form) {
$html .= '<button type="button" class="btn btn-primary" onclick="jbdListings.contactCompany(' . ($showData ? "1" : "0") . ')">';
$html .= '<i class="la la-envelope"></i> ' . (!empty($company->userId) ? JText::_("LNG_CONTACT_COMPANY") : JText::_("LNG_REQUEST_MORE_INFO")) . '</button>';
}
// Join listing button
if (isset($company->showListLinkButton) && $company->showListLinkButton && $appSettings->enable_linked_listings) {
$html .= '<button class="btn btn-outline w-100" onclick="jbdListings.joinListing(' . count($company->joinedCompanies) . ','
. $company->id . ',' . ($user->id == 0 ? 0 : 1) . ',' . (count($company->userCompanies) < 2 ? 'false' : 'true') . ')">';
$html .= '<i class="la la-user"></i>' . JText::_('LNG_JOIN_LEAVE') . '</button>';
}
$html .= '</div>';
return $html;
}
/**
* Get company badges HTML
* @param object $company Company object
* @param object $appSettings Application settings
* @return string HTML for company badges
*/
public static function getCompanyBadges($company, $appSettings) {
$html = '';
// Claimed badge
if ($company->userId != 0 && $appSettings->show_claimed) {
$html .= '<span class="claimed"><i class="la la-check"></i> ' . JText::_("LNG_CLAIMED") . '</span>';
}
// Recommended badge
if ($company->recommended && $appSettings->show_recommended) {
$html .= '<span class="recommended"><i class="la la-star"></i> ' . JText::_("LNG_RECOMMENDED") . '</span>';
}
return $html;
}
/**
* Get company header actions HTML (social share, print, QR code, vCard, bookmarks)
* @param object $company Company object
* @param object $appSettings Application settings
* @param object $user Current user
* @return string HTML for company header actions
*/
public static function getCompanyHeaderActions($company, $appSettings, $user) {
$html = '';
// Social share
ob_start();
$view = 'companies';
$company = $company;
$appSettings = $appSettings;
require_once JPATH_COMPONENT_SITE . "/include/social_share.php";
$html .= ob_get_clean();
// Print button
$html .= '<a rel="nofollow" href="javascript:jbdUtils.printItem(\'' . JRoute::_("index.php?option=com_jbusinessdirectory&view=companies&tmpl=component&layout=print&companyId=" . $company->id) . '\')"><i class="icon print-circle"></i></a>';
// Contact cards (QR code and vCard)
if ($appSettings->show_contact_cards) {
$html .= '<a rel="nofollow" title="' . JText::_("LNG_QR_CODE") . '" target="_blank" href="' . JRoute::_("index.php?option=com_jbusinessdirectory&task=companies.generateQrCode&itemId=" . $company->id) . '"><i class="icon qr-code-circle"></i></a>';
$html .= '<a rel="nofollow" title="' . JText::_("LNG_VCARD") . '" href="' . JRoute::_("index.php?option=com_jbusinessdirectory&task=companies.generateVCard&itemId=" . $company->id) . '"><i class="icon vcard-circle"></i></a>';
}
// Bookmarks
if ($appSettings->enable_bookmarks) {
if (!empty($company->bookmark)) {
$html .= '<a id="bookmark-' . $company->id . '" href="javascript:jbdUtils.showUpdateBookmarkDialog(' . ($user->id == 0 ? "1" : "0") . ',' . $company->id . ',' . BOOKMARK_TYPE_BUSINESS . ')" title="' . JText::_("LNG_UPDATE_BOOKMARK") . '" class="bookmark"><i class="icon heart-circle"></i></a>';
} else {
$html .= '<a id="bookmark-' . $company->id . '" href="javascript:jbdUtils.showAddBookmark(' . ($user->id == 0 ? "1" : "0") . ',' . $company->id . ',' . BOOKMARK_TYPE_BUSINESS . ')" title="' . JText::_("LNG_ADD_BOOKMARK") . '" class="bookmark"><i class="icon heart-o-circle"></i></a>';
}
}
return $html;
}
/**
* Check if a package feature is enabled
* @param string $feature The feature to check
* @param object $package The package object
* @param object $appSettings Application settings
* @return boolean Whether the feature is enabled
*/
public static function hasPackageFeature($feature, $package, $appSettings) {
return (isset($package->features) && in_array($feature, $package->features) || !$appSettings->enable_packages);
}
/**
* Render a section header
* @param string $title The section title
* @return string HTML for the section header
*/
public static function renderSectionHeader($title) {
return '<h2>' . JText::_($title) . '</h2>';
}
/**
* Render a section container
* @param string $id The section ID
* @param string $content The content file to include
* @return string HTML for the section container
*/
public static function renderSectionContainer($id, $content) {
$html = '<div id="' . $id . '" class="company-cell">';
$html .= self::renderSectionHeader($id);
ob_start();
require_once $content;
$html .= ob_get_clean();
$html .= '<div class="clear"></div>';
$html .= '</div>';
return $html;
}
/**
* Render menu items
* @param array $menuItems Array of menu items
* @return string HTML for the menu items
*/
public static function renderMenuItems($menuItems) {
$html = '<nav>';
foreach ($menuItems as $key => $item) {
if (!isset($item['condition']) || $item['condition']) {
$html .= '<a id="' . $key . '" href="javascript:jbdListings.showDetails(\'' . $item['id'] . '\');" class="' . (isset($item['active']) ? 'active' : '') . '">' . JText::_($item['text']) . '</a>';
}
}
$html .= '</nav>';
return $html;
}
/**
* Render sections
* @param array $sections Array of sections
* @return string HTML for all sections
*/
public static function renderSections($sections) {
$html = '';
foreach ($sections as $id => $section) {
if (!isset($section['condition']) || $section['condition']) {
$html .= self::renderSectionContainer($id, $section['content']);
}
}
return $html;
}
/**
* Get opening status HTML with schema.org markup
* @param object $company Company object
* @param object $appSettings Application settings
* @return string HTML for opening status
*/
public static function getOpeningStatus($company, $appSettings) {
if (!$appSettings->show_open_status || ($appSettings->enable_packages && (!isset($company->package->features) || !in_array(OPENING_HOURS, $company->package->features)))) {
return '';
}
$html = '';
if ($company->opening_status == COMPANY_OPEN_BY_TIMETABLE && $company->enableWorkingStatus) {
if ($company->workingStatus) {
$html .= '<div class="ribbon-open" itemprop="openingHoursSpecification" itemscope itemtype="http://schema.org/OpeningHoursSpecification">';
if (!empty($company->business_hours[0])) {
$html .= '<meta itemprop="opens" content="' . date('H:i', strtotime($company->business_hours[0]->open_time)) . '">';
$html .= '<meta itemprop="closes" content="' . date('H:i', strtotime($company->business_hours[0]->close_time)) . '">';
}
$html .= '<span>' . JText::_("LNG_OPEN") . '</span>';
$html .= '</div>';
} else {
$html .= '<div class="ribbon-close"><span>' . JText::_("LNG_CLOSED") . '</span></div>';
}
} else {
$statusInfo = JBusinessUtil::getOpeningStatus($company->opening_status);
if ($company->opening_status == COMPANY_ALWAYS_OPEN) {
$html .= '<div class="ribbon-open" itemprop="openingHoursSpecification" itemscope itemtype="http://schema.org/OpeningHoursSpecification">';
$html .= '<meta itemprop="opens" content="00:00">';
$html .= '<meta itemprop="closes" content="23:59">';
$html .= '<span>' . JText::_("LNG_OPEN") . '</span>';
$html .= '</div>';
} else if (in_array($company->opening_status, array(COMPANY_TEMP_CLOSED, COMPANY_SEASON_CLOSED, COMPANY_PERMANENTLY_CLOSED))) {
$html .= '<div class="ribbon-close"><span>' . JText::_("LNG_CLOSED") . '</span></div>';
}
}
return $html;
}
/**
* Get company details HTML
* @param object $company Company object
* @param object $appSettings Application settings
* @return string HTML for company details
*/
public static function getCompanyDetails($company, $appSettings) {
$html = '';
// Company Type
if(!empty($company->typeName)) {
$html .= '<div class="listing-detail-section">';
$html .= '<div class="listing-item-title">'.JText::_('LNG_TYPE').'</div>';
$html .= '<div class="listing-item-content">'.$company->typeName.'</div>';
$html .= '</div>';
}
// Establishment Year
if(!empty($company->establishment_year)) {
$html .= '<div class="listing-detail-section">';
$html .= '<div class="listing-item-title">'.JText::_('LNG_ESTABLISHMENT_YEAR').'</div>';
$html .= '<div class="listing-item-content">'.$company->establishment_year.'</div>';
$html .= '</div>';
}
// Number of Employees
if(!empty($company->employees)) {
$html .= '<div class="listing-detail-section">';
$html .= '<div class="listing-item-title">'.JText::_('LNG_EMPLOYEES').'</div>';
$html .= '<div class="listing-item-content">'.$company->employees.'</div>';
$html .= '</div>';
}
// Minimum Project Size
if(!empty($company->min_project_size)) {
$html .= '<div class="listing-detail-section">';
$html .= '<div class="listing-item-title">'.JText::_('LNG_MIN_PROJECT_SIZE').'</div>';
$html .= '<div class="listing-item-content"><i class="icon tag"></i> '.$company->min_project_size.'</div>';
$html .= '</div>';
}
// Hourly Rate
if(!empty($company->hourly_rate)) {
$html .= '<div class="listing-detail-section">';
$html .= '<div class="listing-item-title">'.JText::_('LNG_HOURLY_RATE').'</div>';
$html .= '<div class="listing-item-content"><i class="icon clock"></i> '.$company->hourly_rate.' '.$appSettings->currency_symbol.' / h</div>';
$html .= '</div>';
}
return $html;
}
}