2013-10-01 13:26:39 +03:00
|
|
|
<?php
|
2014-10-08 08:20:29 +03:00
|
|
|
/*
|
2013-10-01 13:26:39 +03:00
|
|
|
* LiveStreet CMS
|
|
|
|
* Copyright © 2013 OOO "ЛС-СОФТ"
|
|
|
|
*
|
|
|
|
* ------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Official site: www.livestreetcms.com
|
|
|
|
* Contact e-mail: office@livestreetcms.com
|
|
|
|
*
|
|
|
|
* GNU General Public License, version 2:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
*
|
|
|
|
* ------------------------------------------------------
|
|
|
|
*
|
|
|
|
* @link http://www.livestreetcms.com
|
|
|
|
* @copyright 2013 OOO "ЛС-СОФТ"
|
|
|
|
* @author Maxim Mzhelskiy <rus.engine@gmail.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-10-08 08:20:29 +03:00
|
|
|
/**
|
|
|
|
* Объект управления типом float
|
|
|
|
*
|
|
|
|
* @package application.modules.property
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
2014-10-08 11:49:34 +03:00
|
|
|
class ModuleProperty_EntityValueTypeFloat extends ModuleProperty_EntityValueType
|
|
|
|
{
|
2013-10-01 13:26:39 +03:00
|
|
|
|
2014-10-08 11:49:34 +03:00
|
|
|
public function getValueForDisplay()
|
|
|
|
{
|
|
|
|
return $this->getValueObject()->getValueFloat();
|
|
|
|
}
|
2013-10-01 13:26:39 +03:00
|
|
|
|
2015-02-13 13:17:16 +02:00
|
|
|
public function isEmpty()
|
|
|
|
{
|
|
|
|
return is_null($this->getValueObject()->getValueFloat()) ? true : false;
|
|
|
|
}
|
|
|
|
|
2014-10-27 13:55:56 +02:00
|
|
|
public function getValueForForm()
|
|
|
|
{
|
|
|
|
$oValue = $this->getValueObject();
|
|
|
|
$oProperty = $oValue->getProperty();
|
|
|
|
return $oValue->_isNew() ? $oProperty->getParam('default') : $oValue->getValueFloat();
|
|
|
|
}
|
|
|
|
|
2014-10-08 11:49:34 +03:00
|
|
|
public function validate()
|
|
|
|
{
|
|
|
|
return $this->validateStandart('number', array('integerOnly' => false));
|
|
|
|
}
|
2013-10-01 13:26:39 +03:00
|
|
|
|
2014-10-08 11:49:34 +03:00
|
|
|
public function setValue($mValue)
|
|
|
|
{
|
|
|
|
$this->resetAllValue();
|
|
|
|
$oValue = $this->getValueObject();
|
|
|
|
$oValue->setValueFloat($mValue ? $mValue : null);
|
|
|
|
}
|
2013-10-01 13:26:39 +03:00
|
|
|
|
2014-10-08 11:49:34 +03:00
|
|
|
public function prepareValidateRulesRaw($aRulesRaw)
|
|
|
|
{
|
|
|
|
$aRules = array();
|
|
|
|
$aRules['allowEmpty'] = isset($aRulesRaw['allowEmpty']) ? false : true;
|
2013-10-01 13:26:39 +03:00
|
|
|
|
2014-10-08 11:49:34 +03:00
|
|
|
if (isset($aRulesRaw['max']) and is_numeric($aRulesRaw['max'])) {
|
|
|
|
$aRules['max'] = (int)$aRulesRaw['max'];
|
|
|
|
}
|
|
|
|
if (isset($aRulesRaw['min']) and is_numeric($aRulesRaw['min'])) {
|
|
|
|
$aRules['min'] = (int)$aRulesRaw['min'];
|
|
|
|
}
|
|
|
|
return $aRules;
|
|
|
|
}
|
2014-10-27 13:55:56 +02:00
|
|
|
|
|
|
|
public function prepareParamsRaw($aParamsRaw)
|
|
|
|
{
|
|
|
|
$aParams = array();
|
|
|
|
|
|
|
|
if (isset($aParamsRaw['default'])) {
|
|
|
|
$aParams['default'] = htmlspecialchars($aParamsRaw['default']);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $aParams;
|
|
|
|
}
|
2013-10-01 13:26:39 +03:00
|
|
|
}
|