CMS
Version 3.9
content_modules.inc
Go to the documentation of this file.
1
<?php
2
/**************************************************************
3
4
Copyright (c) 2010 Sonjara, Inc
5
6
Permission is hereby granted, free of charge, to any person
7
obtaining a copy of this software and associated documentation
8
files (the "Software"), to deal in the Software without
9
restriction, including without limitation the rights to use,
10
copy, modify, merge, publish, distribute, sublicense, and/or sell
11
copies of the Software, and to permit persons to whom the
12
Software is furnished to do so, subject to the following
13
conditions:
14
15
The above copyright notice and this permission notice shall be
16
included in all copies or substantial portions of the Software.
17
18
Except as contained in this notice, the name(s) of the above
19
copyright holders shall not be used in advertising or otherwise
20
to promote the sale, use or other dealings in this Software
21
without prior written authorization.
22
23
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
25
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
27
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
28
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
30
OTHER DEALINGS IN THE SOFTWARE.
31
32
*****************************************************************/
33
34
Fakoli::using
(
"section"
,
"menu"
,
"module"
);
35
Fakoli::usingFile
(
"framework/auto_form.inc"
);
36
37
$ids
= checkNumeric($_GET[
"section_content_id"
]);
38
39
$qs
=
"section_content_id[]="
.implode(
"§ion_content_id[]="
, $_GET[
"section_content_id"
]);
40
41
if
(!
$ids
) redirect(
"/index"
);
42
43
// Default dialog to properties for first selected item
44
$content
=
new
SectionContent
(
$ids
[0]);
45
$section
=
$content
->Section();
46
47
$title
=
"Position Modules for {$section->section_title}"
;
48
49
$modulePositions
= reindexList(
$content
->SectionContentModuleXrefs(),
"module_id"
);
50
$modules
= query(
Module
,
"ORDER BY title"
);
51
$positions
=
$content
->getPositions();
52
53
if
(
$method
==
"POST"
)
54
{
55
$section
->clearModuleCache();
56
57
foreach
(
$ids
as $section_content_id)
58
{
59
$xref =
new
SectionContentModuleXref
();
60
$xref->delete(
"WHERE section_content_id=$section_content_id"
);
61
62
foreach
(
$_POST
[
"module"
] as
$module_id
=> $position)
63
{
64
if
($position)
65
{
66
$xref =
new
SectionContentModuleXref
();
67
$xref->section_content_id = $section_content_id;
68
$xref->module_id =
$module_id
;
69
$xref->position = $position;
70
$xref->sort_order =
$_POST
[
"sort_order"
][
$module_id
];
71
$xref->save();
72
}
73
}
74
}
75
76
Fakoli::end
(
"OK"
);
77
}
78
79
$script
.= <<<ENDSCRIPT
80
<script type=
'text/javascript'
>
81
82
window.addEvent(
'domready'
,
function
()
83
{
84
document.id(
'SectionContentModules_form'
).iFrameFormRequest(
85
{
86
'onComplete'
:
function
(response) { sectionContentManager.modulesChanged(response); },
87
'onFailure'
:
function
() {document.id(
'SectonContentModules_form_error'
).set(
'text'
,
'Failed to communicate with server'
); }
88
});
89
});
90
91
</script>
92
ENDSCRIPT;
93
?>
94
<div
style
=
"clear:left;border:solid 1px #000; padding: 4px;"
>
95
<p
class
=
'error'
style
=
'display: none'
id
=
'SectionContentModules_form__error'
></p>
96
<form
id
=
"SectionContentModules_form"
method=
"POST"
action
=
"/action/section/content_modules?<?echo $qs?>"
>
97
<table
class
=
"list"
>
98
<tr>
99
<th>
Module
</th>
100
<th>Position</th>
101
<th>Sort Order</th>
102
</tr>
103
<?
104
foreach
(
$modules
as
$module
)
105
{
106
107
$position =
$modulePositions
[
$module
->module_id];
108
109
?>
110
<tr>
111
<td><strong><a href=
"<?echo $module->getAdminForm()?>?module_id=<?echo $module->module_id?>"
><?echo
$module
->title?></a></strong></td>
112
<td><select name=
"module[<?echo $module->module_id?>]"
>
113
<?
114
echo
"<option value=''></option>"
;
115
116
foreach
(
$positions
as $p)
117
{
118
option($p, ucwords($p), $position->position);
119
}
120
?>
121
</select></td>
122
<td>
123
<input type=
"text"
name=
"sort_order[<?echo $module->module_id?>]"
maxlength=
"4"
style
=
"width: 50px"
value=
"<?echo $position->sort_order?>"
/></td>
124
</tr>
125
<?
126
}
127
?>
128
</table>
129
<br/>
130
<input type=
"submit"
class
=
"button"
name=
"submit"
value=
"Update Module Positions"
/>
131
<?
132
133
?>
134
</form>
135
</div>
$_POST
$_POST["owner_id"]
Definition:
blog_form.inc:54
style
$helpTree style
Definition:
tree.inc:46
action
$form action
Definition:
edit.inc:67
Fakoli\using
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition:
core.inc:116
Fakoli\end
static end($message="")
Use this method to terminate execution of a script instead of using the php keywords exit() or die().
Definition:
core.inc:1149
Fakoli\usingFile
static usingFile()
Uses the specified framework file(s) from the framework directory.
Definition:
core.inc:369
Module
Defines the Module class.
Definition:
module.inc:57
SectionContent
Definition:
section.inc:251
SectionContentModuleXref
Definition:
section.inc:439
$module_id
$module_id
Definition:
code_module_form.inc:41
$module
$module
Definition:
code_module_form.inc:43
$modules
$modules
Definition:
content_modules.inc:50
$qs
$qs
Definition:
content_modules.inc:39
$modulePositions
$modulePositions
Definition:
content_modules.inc:49
$content
$content
Definition:
content_modules.inc:44
$positions
$positions
Definition:
content_modules.inc:51
$section
$section
Definition:
content_modules.inc:45
$title
$title
Definition:
content_modules.inc:47
$ids
$ids
Definition:
content_modules.inc:37
$script
if($method=="POST") $script
Definition:
content_modules.inc:79
$method
$method
Pull out a simple reference to the request method.
Definition:
core.inc:1573
code
cms.sonjara.com
cms
components
section
handlers
content_modules.inc
Generated on Tue Mar 23 2021 15:36:14 for CMS by
1.9.1