1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-03 06:55:03 +03:00
ifhub.club/application/classes/modules/property/entity/ValueTypeCheckbox.entity.class.php

73 lines
1.8 KiB
PHP

<?php
/*
* 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>
*
*/
/**
* Объект управления типом checkbox
*
* @package application.modules.property
* @since 2.0
*/
class ModuleProperty_EntityValueTypeCheckbox extends ModuleProperty_EntityValueType
{
public function getValueForDisplay()
{
return (bool)$this->getValueObject()->getValueInt();
}
public function getValueForForm()
{
$oValue = $this->getValueObject();
$oProperty = $oValue->getProperty();
return $oValue->_isNew() ? $oProperty->getParam('default') : $oValue->getValueInt();
}
public function validate()
{
return $this->validateStandart('boolean');
}
public function setValue($mValue)
{
$this->resetAllValue();
$oValue = $this->getValueObject();
$oValue->setValueInt($mValue ? 1 : 0);
}
public function prepareParamsRaw($aParamsRaw)
{
$aParams = array();
$aParams['default'] = isset($aParamsRaw['default']) ? true : false;
if (isset($aParamsRaw['default_value'])) {
$aParams['default_value'] = htmlspecialchars($aParamsRaw['default_value']);
}
return $aParams;
}
public function getParamsDefault()
{
return array(
'default_value' => 1,
);
}
}