CMS
Version 3.9
section_content_properties_field_renderer.inc
Go to the documentation of this file.
1
<?php
7
Fakoli::using
(
"site"
,
"section"
);
8
9
class
SectionContentPropertiesFieldRenderer
extends
FieldRenderer
10
{
11
private
$identifierField =
null
;
12
13
function
__construct
(
$form
,
$field
=
"section_mapping"
, $label =
"Section Mapping"
, $identifierField =
"identifier"
)
14
{
15
$this->FieldRenderer(
$form
);
16
17
$this->identifierField = $identifierField;
18
19
// JDG 7/31/2011 - allow override
20
if
(
$form
->data->hasField(
$field
))
21
{
22
$form
->override(
$field
, $label, $this);
23
}
24
else
25
{
26
$form
->add($this,
$field
);
27
$form
->overrides[
$field
][
'label'
] = $label;
28
}
29
30
Fakoli::includeScript
(
"/components/section/js/section_content_properties_manager.js"
);
31
}
32
33
function
renderScript
(
$field
)
34
{
35
$obj
= $this->parent->data;
36
$id
= $this->parent->id.
"_"
.
$field
;
37
?>
38
<script>
39
var sectionContentPropertyManager;
40
41
window.addEvent(
'domready'
,
function
()
42
{
43
sectionContentPropertyManager =
new
SectionContentPropertiesManager(
'<?php echo $id?>'
);
44
});
45
</script>
46
<?
47
}
48
49
function
renderField
(
$field
)
50
{
51
$obj
= $this->parent->data;
52
53
$this->_startField(
$field
);
54
55
$sites
=
Site::getSites
();
56
$sections
= GroupedQuery::create(
Section
,
"WHERE section_type='Content' ORDER BY section"
,
"site_id"
)
57
->execute();
58
59
$id
= $this->parent->id.
"_"
.
$field
;
60
61
$identifier
=
$obj
->get($this->identifierField);
62
if
(
$identifier
)
63
{
64
$sectionContent
= IndexedQuery::create(
SectionContent
,
"WHERE identifier=:i"
,
"section_id"
)
65
->bind(
":i"
,
$identifier
)
66
->execute();
67
}
68
else
69
{
70
$sectionContent
= array();
71
}
72
73
$sectionContent
= toJSONIndexed(
$sectionContent
);
74
?>
75
<input type=
'hidden'
name=
'<?echo $id?>'
id
=
'<?echo $id?>'
value=
'<? echo htmlSafe($sectionContent)?>'
/>
76
<table
id
=
'<?echo $id?>_table'
class
=
'list'
>
77
<tbody>
78
<?
79
foreach
(
$sites
as
$site
)
80
{
81
$sectionsForSite =
$sections
[
$site
->site_id];
82
if
(!$sectionsForSite)
continue
;
83
?>
84
<tr>
85
<th
class
=
'subheading'
colspan
=
'3'
><?echo
$site
->site_name?></th>
86
</tr>
87
<?
88
foreach
($sectionsForSite as $s)
89
{
90
?>
91
<tr data-section_id=
'<?echo $s->section_id?>'
>
92
<td><label><input type=
'checkbox'
><? echo $s->section?></label></td>
93
<td><a
class
=
'button'
href=
'#'
><i
class
=
'fa-fw fas fa-ellipsis-h'
></i></a></td>
94
</tr>
95
<?
96
}
97
}
98
?>
99
</tbody>
100
</table>
101
<?
102
$this->_endField(
$field
);
103
}
104
105
function
postProcess
(
$field
=
""
)
106
{
107
108
$id
= $this->parent->id.
"_"
.
$field
;
109
$json =
$_POST
[
$id
];
110
111
trace(
"JSON: $json"
, 3);
112
$items
= fromJSON(
'SectionContent'
, $json);
113
114
$tx
=
new
DataTransaction();
115
try
116
{
117
foreach
(
$items
as $item)
118
{
119
if
($item->section_id && $item->identifier)
120
{
121
$item->joinTransaction(
$tx
);
122
$item->save();
123
}
124
}
125
126
$tx
->commit();
127
}
128
catch
(Exception $e)
129
{
130
$tx
->rollback();
131
throw
$e;
132
}
133
}
134
}
135
?>
$form
$form
Definition:
article_form.inc:52
$_POST
$_POST["owner_id"]
Definition:
blog_form.inc:54
$items
$items
Definition:
data_import_select.inc:47
$obj
$obj
Definition:
data_import_select.inc:29
$site
$site
Definition:
menu_item_form.inc:58
$id
$id
Definition:
blog_archives.inc:22
Fakoli\using
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition:
core.inc:116
Fakoli\includeScript
static includeScript($src)
Utility function to pull in a specific Javascript file for the current page.
Definition:
core.inc:714
SectionContent
Definition:
section.inc:251
SectionContentPropertiesFieldRenderer
Definition:
section_content_properties_field_renderer.inc:10
SectionContentPropertiesFieldRenderer\__construct
__construct($form, $field="section_mapping", $label="Section Mapping", $identifierField="identifier")
Definition:
section_content_properties_field_renderer.inc:13
SectionContentPropertiesFieldRenderer\renderScript
renderScript($field)
Definition:
section_content_properties_field_renderer.inc:33
SectionContentPropertiesFieldRenderer\renderField
renderField($field)
Definition:
section_content_properties_field_renderer.inc:49
Section
Section DataItem, defining the data model for sections within a site.
Definition:
section.inc:45
Site\getSites
static getSites()
Definition:
site.inc:141
$field
$field
Definition:
context_help_form.inc:44
$sites
$sites
Definition:
event_edit.inc:83
colspan
$topicList colspan
Definition:
group_form.inc:54
postProcess
postProcess($field="")
Definition:
section_content_properties_field_renderer.inc:105
$sections
$sections
Definition:
permissions_checker.inc:54
$sectionContent
$sectionContent
Definition:
permissions_checker.inc:50
$tx
$tx
Definition:
reorder_articles.inc:38
$identifier
$identifier
Definition:
rss.inc:37
code
cms.sonjara.com
cms
components
section
section_content_properties_field_renderer.inc
Generated on Tue Mar 23 2021 15:36:14 for CMS by
1.9.1