CMS  Version 3.9
ContextHelpManager Class Reference

Public Member Functions

 ContextHelpManager ()
 
 getHelp ($form, $field)
 
 getCriteria ($form, $field)
 
 getTitle ($form, $field)
 
 getContextHelpRecords ($obj)
 
 formatLinks ($form, $field)
 

Static Public Member Functions

static getInstance ()
 
static setDefaults ()
 
static upgradeComponent ($version)
 
static onInitialize ()
 
static registerSerializationHandler ()
 

Public Attributes

 $classes
 
 $nonmatches
 

Static Public Attributes

static $_instance
 

Detailed Description

Definition at line 56 of file context_help.inc.

Member Function Documentation

◆ ContextHelpManager()

ContextHelpManager::ContextHelpManager ( )

Definition at line 80 of file context_help.inc.

81  {
82  $this->classes = array();
83  $this->nonmatches = array();
84  $this->contextHelpLabel = Settings::getValue("context_help", "context_help_label");
85  $this->criteriaHelpLabel = Settings::getValue("context_help", "criterial_help_label");
86  $this->showTitle = Settings::getValue("context_help", "show_title");
87  }
static getValue($component, $name)
Retrieve the value of the specified Setting.
Definition: settings.inc:104

◆ formatLinks()

ContextHelpManager::formatLinks (   $form,
  $field 
)

Definition at line 160 of file context_help.inc.

161  {
162  $help = $this->getHelp($form, $field);
163  $criteria = $this->getCriteria($form, $field);
164  $title = $this->getTitle($form, $field);
165 
166  $links = "";
167  $text = "";
168 
169  if ($help)
170  {
171  $links .= "<a class=\"context_link\" href=\"javascript:toggleContextHelp('help-{$field}');\" onmouseover=\"showContextHelp('help-{$field}');\" onmouseout=\"hideContextHelp('help-{$field}');\">{$this->contextHelpLabel}</a>&nbsp;";
172  $text .= "<div id=\"help-$field\" class=\"contexthelp\">\n";
173  if ($this->showTitle)
174  {
175  $text .= "<p id=\"heading-$field\">$title Help</p>\n";
176  }
177  $text .= $help;
178  $text .= "</div>\n";
179  }
180 
181  if ($criteria)
182  {
183  $links .= "<a class=\"context_link\" href=\"javascript:toggleContextHelp('criteria-{$field}');\" onmouseover=\"showContextHelp('criteria-{$field}');\" onmouseout=\"hideContextHelp('criteria-{$field}');\">{$this->criteriaHelpLabel}</a>";
184  $text .= "<div id=\"criteria-$field\" class=\"contexthelp\">\n";
185  if ($this->showTitle)
186  {
187  $text .= "<h2 id=\"heading-$field\">$title Criteria</h2>\n";
188  }
189  $text .= $criteria;
190  $text .= "</div>\n";
191  }
192 
193  return "{$links}\n{$text}";
194  }
$form
getTitle($form, $field)
getCriteria($form, $field)
getHelp($form, $field)

◆ getContextHelpRecords()

ContextHelpManager::getContextHelpRecords (   $obj)

Definition at line 137 of file context_help.inc.

138  {
139  $cl = $obj->contextHelpProxy ? $obj->contextHelpProxy : get_class($obj);
140 
141  if ($this->nonmatches[$cl]) return null;
142 
143  if ($this->classes[$cl])
144  {
145  return $this->classes[$cl];
146  }
147 
148  $records = indexedQuery(ContextHelp, "WHERE class_name='$cl'", "field");
149  if ($records)
150  {
151  $this->classes[$cl] = $records;
152  }
153  else
154  {
155  $this->nonmatches[$cl] = true;
156  }
157  return $records;
158  }

◆ getCriteria()

ContextHelpManager::getCriteria (   $form,
  $field 
)

Definition at line 103 of file context_help.inc.

104  {
105  $obj = $form->data;
106  $records = $this->getContextHelpRecords($obj);
107  if (!$records) return null;
108 
109  if (array_key_exists($field, $records))
110  {
111  return $records[$field]->criteria;
112  }
113 
114  return null;
115  }

◆ getHelp()

ContextHelpManager::getHelp (   $form,
  $field 
)

Definition at line 89 of file context_help.inc.

90  {
91  $obj = $form->data;
92  $records = $this->getContextHelpRecords($obj);
93  if (!$records) return null;
94 
95  if (array_key_exists($field, $records))
96  {
97  return $records[$field]->help;
98  }
99 
100  return null;
101  }

◆ getInstance()

static ContextHelpManager::getInstance ( )
static

Definition at line 63 of file context_help.inc.

◆ getTitle()

ContextHelpManager::getTitle (   $form,
  $field 
)

Definition at line 117 of file context_help.inc.

118  {
119  $title = null;
120  $obj = $form->data;
121  $records = $this->getContextHelpRecords($obj);
122  if (!$records) return null;
123 
124  if (array_key_exists($field, $records))
125  {
126  $title = $records[$field]->title;
127  }
128 
129  if (!$title)
130  {
131  $title = $form->prettifyFieldName($field);
132  }
133 
134  return $title;
135  }

◆ onInitialize()

static ContextHelpManager::onInitialize ( )
static

Definition at line 202 of file context_help.inc.

203  {
204  global $auto_form_defaults;
205 
206  $auto_form_defaults["onFormatLabel"] = "addContextHelp";
207  }

◆ registerSerializationHandler()

static ContextHelpManager::registerSerializationHandler ( )
static

Definition at line 209 of file context_help.inc.

210  {
211  SerializationManager::registerHandler("context_help", "Context Help", new ContextHelpSerializationHandler());
212  return true;
213  }
registerHandler($component, $title, $handler)
Registers a serialization handler for a component.

◆ setDefaults()

static ContextHelpManager::setDefaults ( )
static

Definition at line 73 of file context_help.inc.

74  {
75  Settings::setDefaultValue("context_help", "context_help_label", "(?)", String, "Text to display for context help links (HTML is ok)");
76  Settings::setDefaultValue("context_help", "criteria_help_label", "(criteria)", String, "Text to display for criteria help links (HTML is ok)");
77  Settings::setDefaultValue("context_help", "show_title", true, Boolean, "Show the title heading in context help popups");
78  }
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

◆ upgradeComponent()

static ContextHelpManager::upgradeComponent (   $version)
static

Definition at line 196 of file context_help.inc.

197  {
199  $mgr->upgrade($version);
200  }

Member Data Documentation

◆ $_instance

ContextHelpManager::$_instance
static

Definition at line 58 of file context_help.inc.

◆ $classes

ContextHelpManager::$classes

Definition at line 60 of file context_help.inc.

◆ $nonmatches

ContextHelpManager::$nonmatches

Definition at line 61 of file context_help.inc.


The documentation for this class was generated from the following file: