Spade
Mini Shell
PK�h�[o7��
�
html/utility.phpnu�[���<?php
/**
* This file is part of Joomla Estate Agency - Joomla! extension for real
estate agency
*
* @package Joomla.Site
* @subpackage com_jea
* @copyright Copyright (C) 2008 - 2020 PHILIP Sylvain. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Jea Utility helper
*
* @package Joomla.Site
* @subpackage com_jea
*
* @since 2.0
*/
abstract class JHtmlUtility
{
/**
* @var Joomla\Registry\Registry
*/
protected static $params = null;
/**
* Format price following the component configuration.
* If price is empty, return a default string value.
*
* @param float|int $price The price as number
* @param string $default Default value if price equals 0
*
* @return string
*/
public static function formatPrice($price = 0, $default = '')
{
$params = self::getParams();
if (! empty($price))
{
$currency_symbol = $params->get('currency_symbol',
'€');
$price = self::formaNumber($price);
// Is currency symbol before or after price ?
if ($params->get('symbol_position', 1))
{
$price = $price . ' ' . $currency_symbol;
}
else
{
$price = $currency_symbol . ' ' . $price;
}
return $price;
}
else
{
return $default;
}
}
/**
* Format surface following the component configuration.
* If surface is empty, return a default string value.
*
* @param float|int $surface The surface as number
* @param string $default Default value if surface equals 0
*
* @return string
*/
public static function formatSurface($surface = 0, $default =
'')
{
$params = self::getParams();
if (!empty($surface))
{
$surfaceMeasure = $params->get('surface_measure',
'm²');
$surface = self::formaNumber($surface);
return $surface . ' ' . $surfaceMeasure;
}
return $default;
}
/**
* Format number following the component configuration.
*
* @param float|int $number The number to format
*
* @return string
*/
public static function formaNumber($number = O)
{
$params = self::getParams();
$number = (float) $number;
$decimal_separator = $params->get('decimals_separator',
',');
$thousands_separator = $params->get('thousands_separator',
' ');
$decimals = (int) $params->get('decimals_number',
'0');
return number_format($number, $decimals, $decimal_separator,
$thousands_separator);
}
/**
* Get JEA params
*
* @return Joomla\Registry\Registry
*/
protected static function getParams()
{
if (self::$params == null)
{
self::$params = JComponentHelper::getParams('com_jea');
}
return self::$params;
}
}
PK�h�[6����html/amenities.phpnu�[���<?php
/**
* This file is part of Joomla Estate Agency - Joomla! extension for real
estate agency
*
* @package Joomla.Site
* @subpackage com_jea
* @copyright Copyright (C) 2008 - 2020 PHILIP Sylvain. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Jea Amenities HTML helper
*
* @package Joomla.Site
* @subpackage com_jea
*
* @since 2.0
*/
abstract class JHtmlAmenities
{
/**
* @var stdClass[]
*/
protected static $amenities = null;
/**
* Method to get an HTML list of amenities
*
* @param mixed $value string or array of amenities ids
* @param string $format The wanted format (ol, li, raw (default))
*
* @return string HTML for the list.
*/
static public function bindList($value = 0, $format = 'raw')
{
if (is_string($value) && !empty($value))
{
$ids = explode('-', $value);
}
elseif (empty($value))
{
$ids = array();
}
else
{
$ids = ArrayHelper::toInteger($value);
}
$html = '';
$amenities = self::getAmenities();
$items = array();
foreach ($amenities as $row)
{
if (in_array($row->id, $ids))
{
if ($format == 'ul')
{
$items[] = "<li>{$row->value}</li>\n";
}
else
{
$items[] = $row->value;
}
}
}
if ($format == 'ul')
{
$html = "<ul>\n" . implode("\n", $items) .
"</ul>\n";
}
else
{
$html = implode(', ', $items);
}
return $html;
}
/**
* Return HTML list of amenities as checkboxes
*
* @param array $values The checkboxes values
* @param string $name The attribute name for the checkboxes
* @param string $idSuffix An optional ID suffix for the checkboxes
*
* @return string Html list
*/
static public function checkboxes($values = array(), $name =
'amenities', $idSuffix = '')
{
$amenities = self::getAmenities();
$values = (array) $values;
$html = '';
if (!empty($amenities))
{
$html .= "<ul>\n";
foreach ($amenities as $row)
{
$checked = '';
$id = 'amenity' . $row->id . $idSuffix;
if (in_array($row->id, $values))
{
$checked = 'checked="checked"';
}
$html .= '<li><input name="' . $name .
'[]" id="' . $id . '"
type="checkbox" value="' . $row->id . '"
' . $checked . ' /> '
. '<label for="' . $id . '">' .
$row->value . '</label></li>' . "\n";
}
$html .= "</ul>";
}
return $html;
}
/**
* Get Jea amenities from database
*
* @return array An array of amenity row objects
*/
static public function getAmenities()
{
if (self::$amenities === null)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('a.id , a.value');
$query->from('#__jea_amenities AS a');
$query->where('a.language in (' .
$db->quote(JFactory::getLanguage()->getTag()) . ',' .
$db->quote('*') . ')');
$query->order('a.ordering');
$db->setQuery($query);
self::$amenities = $db->loadObjectList();
}
return self::$amenities;
}
}
PK�h�[o7��
�
html/utility.phpnu�[���PK�h�[6�����
html/amenities.phpnu�[���PK�