CMS  Version 3.9
page_manager.inc
Go to the documentation of this file.
1 <?php
7 /**************************************************************
8 
9  Copyright (c) 2010 Sonjara, Inc
10 
11  Permission is hereby granted, free of charge, to any person
12  obtaining a copy of this software and associated documentation
13  files (the "Software"), to deal in the Software without
14  restriction, including without limitation the rights to use,
15  copy, modify, merge, publish, distribute, sublicense, and/or sell
16  copies of the Software, and to permit persons to whom the
17  Software is furnished to do so, subject to the following
18  conditions:
19 
20  The above copyright notice and this permission notice shall be
21  included in all copies or substantial portions of the Software.
22 
23  Except as contained in this notice, the name(s) of the above
24  copyright holders shall not be used in advertising or otherwise
25  to promote the sale, use or other dealings in this Software
26  without prior written authorization.
27 
28  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
30  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
32  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
34  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35  OTHER DEALINGS IN THE SOFTWARE.
36 
37 *****************************************************************/
38 
39 Fakoli::using("page", "versioned_content");
40 
42 {
44  {
45  }
46 
47  function export()
48  {
49  $xml .= "\n<PageMap>";
50  $xml .= SerializationManager::serialize(Page, "ORDER BY page_id");
52  $xml .= "\n</PageMap>";
53  return $xml;
54  }
55 
56  function import($doc, $tx)
57  {
60  }
61 }
62 
64 {
65 
66  static function pageTabs($key)
67  {
68  $tabs = array( "Content" => "page_form",
69  "Modules" => "page_modules"
70  );
71 
72  $qs = ($key) ? "page_id=$key" : "";
73  return new TabBar("tabs", $tabs, $qs);
74  }
75 
76  static function displayPage($identifier, &$continue)
77  {
78  global $page_role;
79 
80  try
81  {
82  $page = Query::create(Page, "WHERE identifier=:i")
83  ->bind(":i", $identifier)
84  ->executeSingle();
85 
87 
88  if (!$page->published && !checkRole("admin")) throw new FakoliException("Unrecognized page '$identifier'");
89 
90  // JDG 11/2011 - why did the code think the template would not have tpl at the end??
91  // avoid adding 2nd "tpl"
92  $page_template = (preg_match("/tpl$/", $page->template)) ? $page->template : "{$page->template}.tpl";
93  $pageView = new PageView($page, $page_template);
94 
95  $page_role = $page->role;
96 
97  if (!checkRole($page->role))
98  {
100  redirect("/login");
101  }
102 
103  echo $pageView->drawView();
104 
105  $continue = false;
106  }
107  catch(DataNotFoundException $e)
108  {
109 
110  }
111 
112  return $identifier;
113  }
114 
115  static function enumeratePages($items)
116  {
117  $pages = Query::create(Page, "ORDER BY page_title")->execute();
118 
119  $items["Pages"] = $pages;
120  return $items;
121  }
122 
123  static function deleteRole($del_role)
124  {
125  $constraint = "WHERE role like '%$del_role%'";
126  $pages = Query::create(Page, $constraint)->execute();
127 
129 
130  return $del_role;
131  }
132 
133  static function registerSearchables($searchables)
134  {
135  trace("PageManager registerSearchables", 3);
136  $searchables["page"] = array(Page);
137  return $searchables;
138  }
139 
140  static function registerSolrAdapter()
141  {
142  SolrManager::registerSolrAdapter(Page, new PageSolrAdapter());
143  }
144 
146  {
147  $classes[] = Page;
148  return $classes;
149  }
150 
151  static function registerVersionedContent()
152  {
154  }
155 
156  static function upgradeComponent($version)
157  {
158  $mgr = new PageUpgradeManager();
159  $mgr->upgrade($version);
160  }
161 
163  {
165  return true;
166  }
167 }?>
$constraint
$tabs
$page
Definition: help.inc:39
FakoliException is the base exception class for all Fakoli errors.
Definition: core.inc:53
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
static storeRedirectPage()
Store the page from which a user has been redirected when prompted to login or create an account.
Definition: login.inc:493
Definition: page.inc:43
static deleteRole($del_role)
static registerSolrAdapter()
static displayPage($identifier, &$continue)
static upgradeComponent($version)
static enumeratePages($items)
static registerVersionedContent()
static pageTabs($key)
static registerTaxonomyClasses($classes)
static registerSerializationHandler()
static registerSearchables($searchables)
PageView generates the page content, substituting page fields, menus and associated modules into an H...
Definition: page_view.inc:48
static deleteRoleFromString(&$items, $del_role, $field="")
static serialize($class, $constraint="")
Serializes the specified DataItems to XML.
registerHandler($component, $title, $handler)
Registers a serialization handler for a component.
static unserialize($class, $doc, $tx, $save=true)
Instantiates DataItems from the supplied XML document and stores them in the database.
static selectDisplayVersion($target, $param="version")
$pages
Definition: export.inc:38
$identifier
Definition: rss.inc:37