CMS  Version 3.9
MobileSettingsManager Class Reference

Provides a central management class for event handlers and common functionality for the mobile component. More...

Public Member Functions

 MobileSettingsManager ()
 

Static Public Member Functions

static setDefaults ()
 
static onInitialize ()
 
static overrideTemplate ($template, &$continue)
 
static useMobile ()
 
static isTablet ()
 

Detailed Description

Provides a central management class for event handlers and common functionality for the mobile component.

Definition at line 14 of file mobile_content_manager.inc.

Member Function Documentation

◆ isTablet()

static MobileSettingsManager::isTablet ( )
static

Definition at line 141 of file mobile_content_manager.inc.

142  {
143  $detect = new MobileDetect();
144  return $detect->isTablet();
145  }
Mobile Detect.

◆ MobileSettingsManager()

MobileSettingsManager::MobileSettingsManager ( )

Definition at line 16 of file mobile_content_manager.inc.

17  {
18 
19  }

◆ onInitialize()

static MobileSettingsManager::onInitialize ( )
static

Definition at line 29 of file mobile_content_manager.inc.

30  {
31  global $isResource;
32  global $isAction;
33  global $auto_form_defaults;
34 
35  $identifier = checkIdentifier($_GET["identifier"]);
36 
37  $mode = Settings::getValue("mobile_settings", "mobile_content_mode");
38  $useNative = Settings::getValue("mobile_settings", "use_native_form_controls");
39 
40  $useMobile = MobileSettingsManager::useMobile();
41  $isTablet = MobileSettingsManager::isTablet();
42 
43  MenuManager::setDisplayFlag("mobile", $useMobile);
44  MenuManager::setDisplayFlag("tablet", $isTablet);
45 
46  if ($useMobile && !$isTablet)
47  {
48  $auto_form_defaults["default_layout"] = "mobile";
49  }
50 
51  if ($useMobile && $useNative)
52  {
53  $detect = new MobileDetect();
54  if ($detect->isiPhone() || $detect->isiPad())
55  {
56  Fakoli::usingFeature("auto_form");
57  AutoForm::registerFieldRendererClass(DateTime, NativeDateTimeFieldRenderer);
58  AutoForm::registerFieldRendererClass(Date, NativeDateFieldRenderer);
59  }
60  }
61 
62  if ($isResource || $isAction || $mode == "Deliver Full Content") return;
63 
64  if ($mode != "Dedicated Mobile Section" || !$useMobile) return;
65 
66  trace ("Using Dedicated Mobile Section", 4);
67 
68  $section = checkIdentifier($_GET["section"]);
69 
70  $mobileSection = Settings::getValue("mobile_settings", "mobile_content_section");
71 
72  if ($mobileSection == "") return;
73 
74  trace("Mobile: $mobileSection vs $section", 4);
75 
76  if ($mobileSection != $section)
77  {
78  if ($useMobile)
79  {
80  $mobileSectionObject = Section::findSection($mobileSection);
81  if ($mobileSectionObject->getContent($identifier))
82  {
83  $pattern = ($section == "") ? "#^/#" : "#/^{$section}/#";
84  $uri = preg_replace($pattern, "/{$mobileSection}/", $_SERVER["REQUEST_URI"]);
85  }
86  else
87  {
88 
89  $uri = ($mobileSection == "/") ? "/" : "/{$mobileSection}/";
90  }
91 
92  trace("Redirecting to mobile section at $uri", 3);
93  redirect($uri);
94  }
95  }
96  else
97  {
99  {
100  $auto_form_defaults["default_layout"] = "mobile";
101  }
102  }
103  }
$section
Definition: event_form.inc:44
static usingFeature()
Uses the specified framework feature(s).
Definition: core.inc:388
static setDisplayFlag($name, $value=true)
static findSection($section_name)
Definition: section.inc:145
static getValue($component, $name)
Retrieve the value of the specified Setting.
Definition: settings.inc:104
$isResource
Definition: core.inc:1585
if($config["default_content_type"]) $isAction
Definition: core.inc:1584
$mode
$identifier
Definition: rss.inc:37
$uri
Definition: tearoff.inc:4

◆ overrideTemplate()

static MobileSettingsManager::overrideTemplate (   $template,
$continue 
)
static

Definition at line 105 of file mobile_content_manager.inc.

106  {
107  global $site;
108 
109  if (!MobileSettingsManager::useMobile()) return $template;
110 
111  $mode = Settings::getValue("mobile_settings", "mobile_content_mode");
112  $mode = ($mode == "Use Mobile Template");
113  $continue = !$mode;
114  $out = $mode ? $site->mobile_template : $template;
115 
116  trace("OverrideTemplate: $template -> $out", 4);
117  return $out;
118  }
$out
Definition: page.inc:66

◆ setDefaults()

static MobileSettingsManager::setDefaults ( )
static

Definition at line 21 of file mobile_content_manager.inc.

22  {
23  Settings::setDefaultValue("mobile_settings", "mobile_content_mode", "Deliver Full Content", String, "Sets the content delivery mode for mobile content", "", "Deliver Full Content\nUse Mobile Template\nDedicated Mobile Section");
24  Settings::setDefaultValue("mobile_settings", "mobile_content_section", "", String, "The identifier of the section providing dedicated mobile content");
25  Settings::setDefaultValue("mobile_settings", "send_mobile_content_to_tablets", false, Boolean);
26  Settings::setDefaultValue("mobile_settings", "use_native_form_controls", false, Boolean, "Use native HTML 5 controls for date and time fields (when available on mobile device)");
27  }
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

◆ useMobile()

static MobileSettingsManager::useMobile ( )
static

Definition at line 120 of file mobile_content_manager.inc.

121  {
122  if (isset($_SESSION["useMobile"])) return $_SESSION["useMobile"];
123 
124  $mobileTablets = Settings::getValue("mobile_settings", "send_mobile_content_to_tablets");
125 
126  $detect = new MobileDetect();
127 
128  $mobile = false;
129 
130  if ($detect->isTablet())
131  {
132  $mobile = $mobileTablets;
133  }
134  else $mobile = $detect->isMobile();
135 
136  trace("useMobile: ".($mobile?'true':'false'), 4);
137 
138  return $mobile;
139  }
$mobile
Definition: override.inc:4
$_SESSION["useMobile"]
Definition: override.inc:7

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