CMS  Version 3.9
page_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("page", "menu", "module");
35 Fakoli::usingFeature("auto_form");
36 
37 $menu_item = "Pages";
38 
39 $page_id = checkNumeric($_GET["page_id"]);
40 
41 if (!$page_id) redirect("/index");
42 
44 
46 $tabs->page = "page_modules";
47 
48 $title = "Position Modules for {$cmspage->page_title}";
49 
50 $modulePositions = reindexList($cmspage->PageModuleXrefs(), "module_id");
51 $modules = query(Module, "ORDER BY title");
52 $positions = $cmspage->getPositions();
53 
54 if ($method == "POST")
55 {
56  $xref = new PageModuleXref();
57  $xref->delete("WHERE page_id=$page_id");
58 
59  foreach($_POST["module"] as $module_id => $position)
60  {
61  if ($position)
62  {
63  $xref = new PageModuleXref();
64  $xref->page_id = $page_id;
65  $xref->module_id = $module_id;
66  $xref->position = $position;
67  $xref->sort_order = $_POST["sort_order"][$module_id];
68  $xref->save();
69  }
70  }
71 
72  redirect("/admin/page_modules?page_id=$page_id");
73 }
74 
75 
76 
77 $tabs->writeHTML();
78 ?>
79 <div class="tab_border">
80 <form method="POST" action="?page_id=<?echo $page_id?>">
81 <table class="list">
82  <tr>
83  <th>Module</th>
84  <th>Position</th>
85  <th>Sort Order</th>
86  </tr>
87 <?
88 foreach($modules as $module)
89 {
90 
91  $position = $modulePositions[$module->module_id];
92 
93 ?>
94 <tr>
95  <td><strong><a href="<?echo $module->getAdminForm()?>?module_id=<?echo $module->module_id?>" ><?echo $module->title?></a></strong></td>
96  <td><select name="module[<?echo $module->module_id?>]">
97  <?
98 
99  /*if($module->title == "Login") {
100  echo '<option selected="Login">Login</option>';
101  $position->sort_order=1;
102  }*/
103 
104 if ($module->title == "Search") {
105 
106  echo "<option selected='Right'>Right</option>";
107  $position->sort_order=1;
108 }
109 else {
110  echo "<option selected=''></option>";
111 }
112 
113  foreach($positions as $p)
114  {
115  option($p, ucwords($p), $position->position);
116  }
117  ?>
118  </select></td>
119  <td>
120  <input type="text" name="sort_order[<?echo $module->module_id?>]" maxlength="4" style="width: 50px" value="<?echo $position->sort_order?>"/></td>
121 </tr>
122 <?
123 }
124 ?>
125 </table>
126 <br/>
127 <input type="submit" class="button" name="submit" value="Update Module Positions"/><NOBR>&nbsp;&nbsp;&nbsp;<input type="button" class="button" value="Preview Page" name="preview" onclick="window.open('/page?page_id=<?echo $page_id?>', 'popupwindow1', 'width=900, height=600, resizable=no, scrollbars=yes'); return false;"/>
128 <?
129 
130 ?>
131 </form>
132 </div>
133 <?
134 
135 
136 ?>
& nbsp
Definition: index.inc:49
$_POST["owner_id"]
Definition: blog_form.inc:54
$helpTree style
Definition: tree.inc:46
$form action
Definition: edit.inc:67
static usingFeature()
Uses the specified framework feature(s).
Definition: core.inc:388
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
Defines the Module class.
Definition: module.inc:57
Definition: page.inc:43
static pageTabs($key)
$module_id
$method
Pull out a simple reference to the request method.
Definition: core.inc:1573
$page_id
$modules
$modulePositions
$positions
$tabs
$menu_item
$cmspage
$title