CMS  Version 3.9
menu_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("component");
40 
42 {
44  {
45  }
46 
47  function export()
48  {
49  $xml = "\n<MenuMap>";
50  $xml .= SerializationManager::serialize(Menu, "ORDER BY menu_id");
51  $xml .= SerializationManager::serialize(MenuItem, "ORDER BY menu_item_id");
52  $xml .= "</MenuMap>";
53 
54  return $xml;
55  }
56 
57  function import($doc, $tx)
58  {
61  }
62 }
63 
65 {
66  static $displayFlags = array();
67 
68  function MenuManager()
69  {
70 
71  }
72 
73  static function deleteRole($del_role)
74  {
75  trace("MenuManager: del_role $del_role", 3);
76  $constraint = "WHERE role like '%$del_role%'";
77 
78  $mItems = Query::create(MenuItem, $constraint)->execute();
79  RoleManager::deleteRoleFromString($mItems, $del_role);
80 
81  return $del_role;
82  }
83 
84  static function setDisplayFlag($name, $value = true)
85  {
87  }
88 
89  static function testFlags($flags)
90  {
91  if (!$flags) return true;
92  $flags = explode(",", $flags);
93 
94  foreach($flags as $flag)
95  {
96  if (startsWith($flag, "!"))
97  {
98  $flag = substr($flag, 1);
99  if (MenuManager::$displayFlags[$flag] == true) return false;
100  }
101  else if (!MenuManager::$displayFlags[$flag]) return false;
102  }
103 
104  return true;
105  }
106  static function upgradeComponent($version)
107  {
108  $mgr = new MenuUpgradeManager();
109  $mgr->upgrade($version);
110  }
111 
113  {
114  SerializationManager::registerHandler("menu", "Menus and Menu Items", new MenuSerializationHandler());
115  return true;
116  }
117 }?>
$constraint
$name
Definition: upload.inc:54
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
Definition: menus.inc:41
static $displayFlags
static deleteRole($del_role)
static setDisplayFlag($name, $value=true)
static registerSerializationHandler()
static testFlags($flags)
static upgradeComponent($version)
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.