CMS  Version 3.9
online_help_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("settings");
40 
42 {
44  {
45  }
46 
47  function export()
48  {
49  return SerializationManager::serialize(HelpBook, "ORDER BY help_book_id");
50  return SerializationManager::serialize(HelpPage, "ORDER BY help_page_id");
51  }
52 
53  function import($doc, $tx)
54  {
57  }
58 }
59 
61 {
62  var $book;
63 
65  {
66  $this->book = $book;
67  }
68 
69  static function setDefaults()
70  {
71  Settings::setDefaultValue("online_help", "default_book", "", String, "Specify the default help book to which the help link will connect");
72  Settings::setDefaultValue("online_help", "use_page_identifiers", "", Boolean, "Use page identifiers as the default help identifier");
73  Settings::setDefaultValue("online_help", "help_text", "Help", String, "The text to display on the help link");
74  Settings::setDefaultValue("online_help", "help_css", "/components/online_help/css/online_help.css", String, "CSS Files defining the help popup look and feel (comma separated)");
75  }
76 
77  static function onInitialize()
78  {
79  global $help_book;
80  global $help_page;
81  }
82 
83  static function substituteHelpLink($output)
84  {
85  global $help_book;
86  global $help_page;
87  global $page;
88 
89  $useIdentifier = Settings::getValue("online_help", "use_page_identifiers");
90  if (!$help_book) $help_book = Settings::getValue("online_help", "default_book");
91  if (!$help_page && $useIdentifier) $help_page = $page->identifier;
92 
93  if ($help_book && $help_page)
94  {
95  $helpText = Settings::getValue("online_help", "help_text");
96  $helpLink = "<a class='help_link' href='#' onclick='OnlineHelp.help(\"{$help_book}\", \"{$help_page}\"); return false;'>$helpText</a>";
97 
98  $output = str_replace("{help}", $helpLink, $output);
99  }
100 
101  return $output;
102  }
103 
104  static function getAdminTabs($key)
105  {
106  $tabs = array( "Details" => "/admin/help_book_form",
107  "Help Pages" => "/admin/help_pages"
108  );
109 
110  $qs = ($key) ? "help_book_id=$key" : "";
111  return new TabBar("tabs", $tabs, $qs);
112  }
113 
114  static function upgradeComponent($version)
115  {
117  $mgr->upgrade($version);
118  }
119 
121  {
122  SerializationManager::registerHandler("online_help", "Online Help", new OnlineHelpSerializationHandler());
123  }
124 
125  function startFrame($class)
126  {
127  global $script;
129 
130  // Ensure that video player is configured.
131 
132  $flowPlayerScript = Settings::getValue("video", "flowplayer_script");
133 
134  if ($flowPlayerScript)
135  {
136  $script .= "<script type='text/javascript' src='$flowPlayerScript'></script>\n";
137  }
138 
139  $flowPlayer = Settings::getValue("video", "flowplayer_player");
140 
141  $script .= "<script type='text/javascript'>\nvar flowplayerPath = '$flowPlayer';\n</script>\n";
142 
143 
145 
146  $css = explode(",", Settings::getValue("online_help", "help_css"));
147  $additional = explode(",", $this->book->additional_css_files);
148 
149  foreach($css as $c)
150  {
151  $styles .= "<link href='$c' rel='stylesheet'/>\n";
152  }
153 
154  foreach($additional as $c)
155  {
156  $styles .= "<link href='$c' rel='stylesheet'/>\n";
157  }
158 
159 ?>
160 <!DOCTYPE html>
161 <html>
162  <head>
163  <?echo $styles?>
164  <?echo $script?>
165  </head>
166  <body class='<?echo $class?>'>
167 <?
168  $script = "";
169  }
170 
171  function endFrame()
172  {
173 ?>
174  </body>
175 </html>
176 <?
177  }
178 }
179 ?>
$tabs
$page
Definition: help.inc:39
static getStyles()
Returns the HTML link tags for CSS files specified by the registered components in their manifest fil...
Definition: core.inc:603
static getScripts()
Returns the HTML scripts tags for Javascript files specified by the registered components in their ma...
Definition: core.inc:554
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
static upgradeComponent($version)
static registerSerializationHandler()
static substituteHelpLink($output)
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 getValue($component, $name)
Retrieve the value of the specified Setting.
Definition: settings.inc:104
static setDefaultValue($component, $name, $value, $field_type="String", $annotation="", $category="", $options="", $weight=0)
Sets the default value of the given component setting.
Definition: settings.inc:174
if(!checkRole("admin")) $c
$output
Definition: generate.inc:9
$styles