Skip to content

Commit

Permalink
notify on preclusion of automatic redirect, refs #26
Browse files Browse the repository at this point in the history
  • Loading branch information
luniki committed Jun 18, 2013
1 parent c31cbc9 commit d3c6602
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions StudipMobile.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,17 @@ static function onEnable($id)

private function redirectToMobile()
{
# handle stop word
if (Request::submitted(self::REDIRECTION_STOP_WORD)) {
setcookie(self::REDIRECTION_STOP_WORD, 1);
$_COOKIE[self::REDIRECTION_STOP_WORD] = 1;
}
// make sure to break out if asked for
$this->handleStopWord();

if (!$this->shouldRedirect()) {
return;
}

// add mobile detection script from http://detectmobilebrowsers.com/
$url = PluginEngine::getLink($this, null, '', true);
$js = sprintf(self::DETECTION_REGEXP, $url);
PageLayout::addHeadElement('script', array(), $js);

}

private function shouldRedirect()
Expand All @@ -88,4 +85,14 @@ private function shouldRedirect()

return true;
}

private function handleStopWord()
{
# handle stop word
if (Request::submitted(self::REDIRECTION_STOP_WORD)) {
\NotificationCenter::postNotification('mobile.RedirectDidPreclude', $this);
setcookie(self::REDIRECTION_STOP_WORD, 1);
$_COOKIE[self::REDIRECTION_STOP_WORD] = 1;
}
}
}

0 comments on commit d3c6602

Please sign in to comment.