Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
answer.php
1
<?php
8
namespace
Bitrix\Vote
;
9
use \Bitrix\Main\Entity;
10
use \Bitrix\Main\Localization\Loc;
11
use
Bitrix\Main\ORM\Fields\BooleanField
;
12
use
Bitrix\Main\ORM\Fields\EnumField
;
13
use
Bitrix\Main\ORM\Fields\IntegerField
;
14
use
Bitrix\Main\ORM\Fields\DatetimeField
;
15
use
Bitrix\Main\ORM\Fields\Relations\Reference
;
16
use
Bitrix\Main\ORM\Fields\StringField
;
17
use
Bitrix\Main\ORM\Fields\TextField
;
18
use
Bitrix\Main\ORM\Query\Join
;
19
20
Loc::loadMessages
(__FILE__);
21
51
class
AnswerTable
extends
Entity\DataManager
52
{
58
public
static
function
getTableName
()
59
{
60
return
'b_vote_answer'
;
61
}
62
68
public
static
function
getMap
()
69
{
70
return
[
71
(
new
IntegerField
(
'ID'
))
72
->configurePrimary(
true
)
73
->configureAutocomplete(
true
),
74
(
new
BooleanField
(
'ACTIVE'
))
75
->configureValues(
'N'
,
'Y'
)
76
->configureDefaultValue(
'Y'
),
77
(
new
DatetimeField
(
'TIMESTAMP_X'
)),
78
(
new
IntegerField
(
'QUESTION_ID'
)),
79
(
new
IntegerField
(
'C_SORT'
)),
80
(
new
IntegerField
(
'IMAGE_ID'
)),
81
(
new
Reference
(
'IMAGE'
,
82
\
Bitrix
\Main\FileTable::class,
83
Join::on(
'this.IMAGE_ID'
,
'ref.ID'
)
84
)),
85
(
new
TextField
(
'MESSAGE'
)),
86
(
new
EnumField
(
'MESSAGE_TYPE'
, [
'values'
=> [
'text'
,
'html'
]]))
87
->configureDefaultValue(
'text'
),
88
(
new
IntegerField
(
'COUNTER'
)),
89
(
new
IntegerField
(
'FIELD_TYPE'
)),
90
(
new
IntegerField
(
'FIELD_WIDTH'
)),
91
(
new
IntegerField
(
'FIELD_HEIGHT'
)),
92
(
new
StringField
(
'FIELD_PARAM'
))
93
->configureSize(255),
94
(
new
StringField
(
'COLOR'
))
95
->configureSize(6)
96
];
97
}
103
public
static
function
setCounter
(array $id, $increment =
true
)
104
{
105
$id = implode(
", "
, array_map(
'intval'
, $id));
106
if
(empty($id))
107
return
;
108
$connection = \Bitrix\Main\Application::getInstance()->getConnection();
109
110
$sql = intval($increment);
111
if
($increment ===
true
)
112
$sql =
"COUNTER+1"
;
113
else
if
($increment ===
false
)
114
$sql =
"COUNTER-1"
;
115
$connection->queryExecute(
"UPDATE "
.self::getTableName().
" SET COUNTER="
.$sql.
" WHERE ID IN ("
.$id.
")"
);
116
}
117
}
118
119
class
Answer
120
{
121
public
static
$storage
= array();
122
}
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\ORM\Fields\BooleanField
Definition
booleanfield.php:20
Bitrix\Main\ORM\Fields\DatetimeField
Definition
datetimefield.php:22
Bitrix\Main\ORM\Fields\EnumField
Definition
enumfield.php:20
Bitrix\Main\ORM\Fields\IntegerField
Definition
integerfield.php:20
Bitrix\Main\ORM\Fields\Relations\Reference
Definition
reference.php:26
Bitrix\Main\ORM\Fields\StringField
Definition
stringfield.php:20
Bitrix\Main\ORM\Fields\TextField
Definition
textfield.php:20
Bitrix\Main\ORM\Query\Join
Definition
join.php:19
Bitrix\Vote\Answer
Definition
answer.php:120
Bitrix\Vote\Answer\$storage
static $storage
Definition
answer.php:121
Bitrix\Vote\AnswerTable
Definition
answer.php:52
Bitrix\Vote\AnswerTable\getMap
static getMap()
Definition
answer.php:68
Bitrix\Vote\AnswerTable\setCounter
static setCounter(array $id, $increment=true)
Definition
answer.php:103
Bitrix\Vote\AnswerTable\getTableName
static getTableName()
Definition
answer.php:58
Bitrix\Vote
Definition
answer.php:8
Bitrix
modules
vote
lib
answer.php
Создано системой
1.10.0