[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: Поиск от и до
Mopsusha
У J-BusinessDirectory нет поля поиска по цене, подскажите пожалуйста как сделать поиск от некой цены, до такой-то цены через поле input
<?php
/**
*
@package JBusinessDirectory
*
*
@author CMSJunkie http://www.cmsjunkie.com
* @copyright Copyright © 2007 - 2017 CMS Junkie. All rights reserved.
*
@license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
*/


defined('_JEXEC') or die('Restricted access');

class AttributeService{

public static function renderAttributes($attributes, $enablePackages, $packageFeatures) {
$appSettings = JBusinessUtil::getInstance()->getApplicationSettings();
$renderedContent="";
if(count($attributes)>0) {
foreach ($attributes as $attribute) {
$class = "";

if ($attribute->is_mandatory == 1)
$class = "validate[required]";

$hideClass= "";
$app = JFactory::getApplication();
if (!$app->isAdmin() && $attribute->show_in_filter){
$hideClass = "hidden";
}

if (isset($packageFeatures) && in_array($attribute->code, $packageFeatures) || !$enablePackages)
{
$attributeOptions = explode(",", $attribute->options);
if ($appSettings->enable_multilingual && isset($attribute->options))
{
foreach ($attributeOptions as $key => $option)
{
$attributeOptions[$key] = JBusinessDirectoryTranslations::getTranslatedItemName($option);
}
}

switch ($attribute->attributeTypeCode)
{
case "header":
$renderedContent .= '<div class="detail_box">';
$renderedContent .= '<h3 title="' . $attribute->name . '">' . $attribute->name . '</h3>';
$renderedContent .= '<div class="clear"></div>';
$renderedContent .= '</div>';
break;
case "input":
$inputValue = $attribute->attributeValue;

if ($attribute->is_mandatory == 1)
$class = "validate[required] text-input";

$renderedContent .= '<div class="detail_box $hideClass">';
if ($attribute->is_mandatory)
$renderedContent .= '<div class="form-detail req"></div>';
$renderedContent .= '<label id="details-lbl" for="attribute_' . $attribute->id . '" class="hasTip" title="' . $attribute->name . '">' . $attribute->name . '</label>';
$renderedContent .= '<input type="text" size="50" name="attribute_' . $attribute->id . '" id="attribute_' . $attribute->id . '" value="' . $inputValue . '" class="input_txt ' . $class . '"/>';
$renderedContent .= '<div class="clear"></div>';
$renderedContent .= '</div>';

break;
case "link":
$inputValue = $attribute->attributeValue;

if ($attribute->is_mandatory == 1)
$class = "validate[required] text-input";

$renderedContent .= '<div class="detail_box $hideClass">';
if ($attribute->is_mandatory)
$renderedContent .= '<div class="form-detail req"></div>';
$renderedContent .= '<label id="details-lbl" for="attribute_' . $attribute->id . '" class="hasTip" title="' . $attribute->name . '">' . $attribute->name . '</label>';
$renderedContent .= '<input type="text" size="50" name="attribute_' . $attribute->id . '" id="attribute_' . $attribute->id . '" value="' . $inputValue . '" class="input_txt ' . $class . '"/>';
$renderedContent .= '<div class="clear"></div>';
$renderedContent .= '</div>';

break;
case "textarea":
$inputValue = $attribute->attributeValue;

if ($attribute->is_mandatory == 1)
$class = "validate[required] text-input";

$renderedContent .= '<div class="detail_box $hideClass">';
if ($attribute->is_mandatory)
$renderedContent .= '<div class="form-detail req"></div>';
$renderedContent .= '<label id="details-lbl" for="attribute_' . $attribute->id . '" class="hasTip" title="' . $attribute->name . '">' . $attribute->name . '</label>';
$renderedContent .= '<textarea cols="10" name="attribute_' . $attribute->id . '" id="attribute_' . $attribute->id . '" class="input_txt ' . $class . '">' . $inputValue . '</textarea>';
$renderedContent .= '<div class="clear"></div>';
$renderedContent .= '</div>';

break;
case "select_box":
$attributeOptionsIDS = explode(",", $attribute->optionsIDS);

if ($attribute->is_mandatory == 1)
$class = "validate[required] select";

$renderedContent .= '<div class="detail_box $hideClass">';
if ($attribute->is_mandatory)
$renderedContent .= '<div class="form-detail req"></div>';
$renderedContent .= '<label id="details-lbl" for="attribute_' . $attribute->id . '" class="hasTip" title="' . $attribute->name . '">' . $attribute->name . '</label>';
$renderedContent .= '<select name="attribute_' . $attribute->id . '" id="attribute_' . $attribute->id . '" class="input_sel ' . $class . '">';
$renderedContent .= '<option value="" selected="selected">' . JText::_("LNG_SELECT") . '</option>';
foreach ($attributeOptions as $key => $option)
{
if (isset($attribute->attributeValue) && $attributeOptionsIDS[$key] == $attribute->attributeValue)
$renderedContent .= '<option value="' . $attributeOptionsIDS[$key] . '" selected="selected">' . $option . '</option>';
else
$renderedContent .= '<option value="' . $attributeOptionsIDS[$key] . '">' . $option . '</option>';
}
$renderedContent .= '</select>';
$renderedContent .= '<div class="clear"></div>';
$renderedContent .= '</div>';
break;
case "checkbox":
$attributeOptionsIDS = explode(",", $attribute->optionsIDS);
$attributeValues = explode(",", $attribute->attributeValue);
if ($attribute->is_mandatory == 1)
$class = "validate[minCheckbox[1]] checkbox";

$renderedContent .= '<div class="detail_box $hideClass">';
if ($attribute->is_mandatory)
$renderedContent .= '<div class="form-detail req"></div>';
$renderedContent .= '<label id="details-lbl" for="attribute_' . $attribute->id . '" class="hasTip" title="' . $attribute->name . '">' . $attribute->name . '</label>';
foreach ($attributeOptions as $key => $option)
{
$renderedContent .= "<div class='custom-attr-checkbox'>";
$option = "<span class='option'>" . $option . "</span>";
if (in_array($attributeOptionsIDS[$key], $attributeValues))
$renderedContent .= '<input type="checkbox" name="attribute_' . $attribute->id . '[]" id="attribute_' . $attribute->id . '" value="' . $attributeOptionsIDS[$key] . '" class="' . $class . '" checked="true"/>' . $option;
else
$renderedContent .= '<input type="checkbox" name="attribute_' . $attribute->id . '[]" id="attribute_' . $attribute->id . '" value="' . $attributeOptionsIDS[$key] . '" class="' . $class . '"/>' . $option;
$renderedContent .= "</div>";
}
$renderedContent .= '<div class="clear"></div>';
$renderedContent .= '</div>';
break;
case "radio":
$attributeOptionsIDS = explode(",", $attribute->optionsIDS);
if ($attribute->is_mandatory == 1)
$class = "validate[required] radio";

$renderedContent .= '<div class="detail_box $hideClass">';
if ($attribute->is_mandatory)
$renderedContent .= '<div class="form-detail req"></div>';
$renderedContent .= '<label id="details-lbl" for="attribute_' . $attribute->id . '" class="hasTip" title="' . $attribute->name . '">' . $attribute->name . '</label>';
foreach ($attributeOptions as $key => $option)
{

$option = "<span class='option'>" . $option . "</span>";
if ($attributeOptionsIDS[$key] == $attribute->attributeValue)
$renderedContent .= ' <input type="radio" name="attribute_' . $attribute->id . '" id="attribute_' . $attribute->id . '" value="' . $attributeOptionsIDS[$key] . '" class="' . $class . '" checked="true"/>  ' . $option;
else
$renderedContent .= ' <input type="radio" name="attribute_' . $attribute->id . '" id="attribute_' . $attribute->id . '" value="' . $attributeOptionsIDS[$key] . '" class="' . $class . '"/>  ' . $option;
}
$renderedContent .= '<div class="clear"></div>';
$renderedContent .= '</div>';
break;
default:
echo "";
}
}
}
}

return $renderedContent;
}

public static function renderAttributesSearch($attributes, $enablePackages, $packageFeatures) {
//dump($attributes);
$appSettings = JBusinessUtil::getInstance()->getApplicationSettings();

$renderedContent="";
if(!empty($attributes)){
if($appSettings->enable_multilingual){
JBusinessDirectoryTranslations::updateAttributesTranslation($attributes);
}

foreach($attributes as $attribute) {
$class = "";
if(!isset($attribute->attributeValue)){
$attribute->attributeValue ="";
}

if($attribute->is_mandatory==1 )
$class = "validate[required]";

if(isset($packageFeatures) && in_array($attribute->code,$packageFeatures) || !$enablePackages){
$attributeOptions = explode(",", $attribute->options);
if ($appSettings->enable_multilingual && isset($attribute->options)) {
foreach ($attributeOptions as $key => $option) {
$attributeOptions[$key] = JBusinessDirectoryTranslations::getTranslatedItemName($option);
}
}

switch ($attribute->attributeTypeCode){
case "header":
break;
case "input":
$inputValue= $attribute->attributeValue;
$inputValueot="ot";
$inputValuedo=$attribute->attributeValue;
$renderedContent.= '<div class="form-field">';
$renderedContent.= '<input type="text" placeholder="'.$attribute->name.' от" size="50" name="attribute_'.$attribute->id.'" id="attribute_'.$attribute->id.'" value="'.$inputValueot.'" class="input_txt '.$class.'"/>';
$renderedContent.= '<input type="text" placeholder="'.$attribute->name.' до" size="50" name="attribute_'.$attribute->id.'" id="attribute_'.$attribute->id.'" value="'.$inputValuedo.'" class="input_txt '.$class.'"/>';
if($inputValueot > $inputValue and $inputValue < $inputValuedo){
$renderedContent.= 'hellow word';
}
$renderedContent.= '</div>';
break;
case "textarea":
$inputValue= $attribute->attributeValue;
$renderedContent.= '<div class="form-field">';
$renderedContent.= '<label id="details-lbl" for="attribute_'.$attribute->id.'" class="hasTip" title="'.$attribute->name.'">'.$attribute->name.'</label>';
$renderedContent.= '<textarea cols="10" name="attribute_'.$attribute->id.'" id="attribute_'.$attribute->id.'" class="input_txt '.$class.'">'.$inputValue.'</textarea>';
$renderedContent.= '</div>';
break;
case "select_box":
$attributeOptionsIDS = explode(",",$attribute->optionsIDS);
$renderedContent.= '<div class="form-field">';
$renderedContent.= '<select name="attribute_'.$attribute->id.'" id="attribute_'.$attribute->id.'" class="input_sel '.$class.'">';
$renderedContent.= '<option value="" selected="selected">'.JText::_("LNG_SELECT").' '.$attribute->name.'</option>';
foreach ($attributeOptions as $key=>$option){
if($attributeOptionsIDS[$key] == $attribute->attributeValue)
$renderedContent.='<option value="'.$attributeOptionsIDS[$key].'" selected="selected">'.$option.'</option>';
else
$renderedContent.='<option value="'.$attributeOptionsIDS[$key].'">'.$option.'</option>';
}
$renderedContent.= '</select>';
$renderedContent.= '</div>';
break;
case "checkbox":
$attributeOptionsIDS = explode(",",$attribute->optionsIDS);
$attributeValues = explode(",",$attribute->attributeValue);
if($attribute->is_mandatory==1 )
$class = "validate[minCheckbox[1]] checkbox";

$renderedContent.= '<div class="multiselect"><div class="selectBox" onclick="showCheckboxes()">';
$renderedContent.= '<select><option><label id="details-lbl" for="attribute_'.$attribute->id.'" class="hasTip" title="'.$attribute->name.'">'.$attribute->name.' </label></option></select><div class="overSelect"></div></div><div id="checkboxes">';
foreach ($attributeOptions as $key=>$option){
$renderedContent.="<div class='custom-div'>";
$option = "<span class='dir-check-lbl'>".$option."</span>";
if( in_array($attributeOptionsIDS[$key] , $attributeValues))
$renderedContent.= '<input type="checkbox" name="attribute_'.$attribute->id.'[]" id="attribute_'.$attribute->id.'" value="'.$attributeOptionsIDS[$key].'" class="'.$class.'" checked="true"/>'.$option;
else
$renderedContent.= '<input type="checkbox" name="attribute_'.$attribute->id.'[]" id="attribute_'.$attribute->id.'" value="'.$attributeOptionsIDS[$key].'" class="'.$class.'"/>'.$option;
$renderedContent.="</div>";
}
$renderedContent.= '</div>
</div>'
;
break;
case "radio":
$attributeOptionsIDS = explode(",",$attribute->optionsIDS);
if($attribute->is_mandatory==1 )
$class = "validate[required] radio";

$renderedContent.= '<div class="form-field">';
$renderedContent.= '<label id="details-lbl" for="attribute_'.$attribute->id.'" class="hasTip" title="'.$attribute->name.'">'.$attribute->name.'</label>';
foreach ($attributeOptions as $key=>$option){

$option = "<span class='dir-check-lbl'>".$option."</span>";
if($attributeOptionsIDS[$key] == $attribute->attributeValue)
$renderedContent.= ' <input type="radio" name="attribute_'.$attribute->id.'" id="attribute_'.$attribute->id.'" value="'.$attributeOptionsIDS[$key].'" class="'.$class.'" checked="true"/>  '.$option;
else
$renderedContent.= ' <input type="radio" name="attribute_'.$attribute->id.'" id="attribute_'.$attribute->id.'" value="'.$attributeOptionsIDS[$key].'" class="'.$class.'"/>  '.$option;
}
$renderedContent.= '</div>';
break;
default:
echo "";
}
}
}
}

return $renderedContent;
}

public static function renderAttributesFront($attributes, $enablePackages, $packageFeatures) {
$appSettings = JBusinessUtil::getInstance()->getApplicationSettings();

$renderedContent="";
if(!empty($attributes)){
//update the translations
if($appSettings->enable_multilingual){
JBusinessDirectoryTranslations::updateAttributesTranslation($attributes);
}

foreach($attributes as $attribute) {
if($attribute->show_in_front != 1){



continue;
}

if(isset($packageFeatures) && in_array($attribute->code,$packageFeatures) || !$enablePackages){
$attributeOptions = explode(",", $attribute->options);
if ($appSettings->enable_multilingual && isset($attribute->options)) {
foreach ($attributeOptions as $key => $option) {
$attributeOptions[$key] = JBusinessDirectoryTranslations::getTranslatedItemName($option);
}
}

switch ($attribute->attributeTypeCode){
case "header":
$renderedContent.="<h3 class='attribute-header'>".$attribute->name."</h3>";
break;
case "input":
$inputValue= $attribute->attributeValue;
if(!empty($inputValue)){
$renderedContent.='<ul class="business-properties">';
$renderedContent.= '<li><div>'.$attribute->name.': </div></li>';
$renderedContent.= '<li>'.$inputValue.'</li>';
$renderedContent.= '</ul>';
}
break;
case "link":
$inputValue= $attribute->attributeValue;

if(!empty($inputValue)){
if (!preg_match("~^(?:f|ht)tps?://~i", $inputValue)) {
$inputValue = "http://" . $inputValue;
}

$renderedContent.='<ul class="business-properties">';
$renderedContent.= '<li><div>'.$attribute->name.': </div></li>';
$renderedContent.= '<li> <a target="_blank" href="'.$inputValue.'">'.$inputValue.'</a></li>';
$renderedContent.= '</ul>';
}
break;
case "textarea":
$inputValue= $attribute->attributeValue;
if(!empty($inputValue)){
$renderedContent.='<ul class="business-properties">';
$renderedContent.= '<li><div>'.$attribute->name.': </div></li>';
$renderedContent.= '<li>'.$inputValue.'</li>';
$renderedContent.= '</ul>';
}
break;
case "select_box":
$attributeOptionsIDS = explode(",",$attribute->optionsIDS);
$inputValue="";
foreach ($attributeOptions as $key=>$option){
if($attributeOptionsIDS[$key] == $attribute->attributeValue){
$inputValue = $option;
break;
}
}

if(!empty($inputValue)){
$renderedContent.='<ul class="business-properties">';
$renderedContent.= '<li><div>'.$attribute->name.': </div></li>';
$renderedContent.= '<li>'.$inputValue.'</li>';
$renderedContent.='</ul>';
}
break;
case "checkbox":
$attributeOptionsIDS = explode(",",$attribute->optionsIDS);
$attributeValues = explode(",",$attribute->attributeValue);
if($attributeValues[0]=="")
break;

$renderedContent.='<ul class="business-properties">';
$renderedContent.= '<li><div>'.$attribute->name.': </div></li>';
foreach ($attributeOptions as $key=>$option){
if( in_array($attributeOptionsIDS[$key] , $attributeValues)){
$renderedContent.= '<li>'.$option.', </li>';
}
}


$renderedContent = substr($renderedContent, 0, -12);
$renderedContent.= '</li>';
$renderedContent.='</ul>';
break;
case "radio":
$attributeOptionsIDS = explode(",",$attribute->optionsIDS);
$inputValue="";
foreach ($attributeOptions as $key=>$option){
if($attributeOptionsIDS[$key] == $attribute->attributeValue){
$inputValue = $option;
break;
}
}

if(!empty($inputValue)){
$renderedContent.='<ul class="business-properties">';
$renderedContent.= '<li><div>'.$attribute->name.': </div></li>';
$renderedContent.= '<li>'.$inputValue.'</li>';
$renderedContent.='</ul>';
}

break;
default:
echo "";
}
}
}
}

return $renderedContent;
}

/**
* Parse attributes and get the values for selected attribute
*
@param Object $attributes
*
@param string $name
*/

static function getAttributeAsString($attributes, $name){
foreach($attributes as $attribute) {
if($attribute->name == name){
return self::getAttributeValues($attribute);
}
}

return "";
}

/**
* Render a attribute
*
*
@param unknown_type $attribute
*/

static function getAttributeValues($attribute){
$appSettings = JBusinessUtil::getInstance()->getApplicationSettings();
$attributeOptions = explode(",", $attribute->options);
if ($appSettings->enable_multilingual && isset($attribute->options)) {
foreach ($attributeOptions as $key => $option) {
$attributeOptions[$key] = JBusinessDirectoryTranslations::getTranslatedItemName($option);
}
}

switch ($attribute->attributeTypeCode){
case "header":
return "";
case "input":
$inputValue= $attribute->attributeValue;
if(!empty($inputValue)){
return $inputValue;
}else{
return "";
}
break;
case "link":
$inputValue= $attribute->attributeValue;
if(!empty($inputValue)){
return $inputValue;
}else{
return "";
}
break;
case "textarea":
$inputValue= $attribute->attributeValue;
if(!empty($inputValue)){
return $inputValue;
}else{
return "";
}
break;
case "select_box":
$attributeOptionsIDS = explode(",",$attribute->optionsIDS);
$inputValue="";
foreach ($attributeOptions as $key=>$option){
if($attributeOptionsIDS[$key] == $attribute->attributeValue){
$inputValue = $option;
break;
}
}

if(!empty($inputValue)){
return $inputValue;
}else{
return "";
}
break;
case "checkbox":
$attributeOptionsIDS = explode(",",$attribute->optionsIDS);
$attributeValues = explode(",",$attribute->attributeValue);
if($attributeValues[0]=="")
break;
$renderedContent="";
foreach ($attributeOptions as $key=>$option){
if( in_array($attributeOptionsIDS[$key] , $attributeValues)){
$renderedContent.= $option.',';
}
}

$inputValue= rtrim($renderedContent,',');
if(!empty($inputValue)){
return $inputValue;
}else{
return "";
}
break;
case "radio":
$attributeOptionsIDS = explode(",",$attribute->optionsIDS);
$inputValue="";
foreach ($attributeOptions as $key=>$option){
if($attributeOptionsIDS[$key] == $attribute->attributeValue){
$inputValue = $option;
break;
}
}

if(!empty($inputValue)){
return $inputValue;
}else{
return "";
}
break;
default:
echo "";
}

}
}


?>


_____________
Мы говорим и говорим друг с другом,// Но мы одиноки. Живые, одинокие. //Чьи мы? // Как перекати-поле, без корней...
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.