Skip to content
Snippets Groups Projects
Commit a5758034 authored by Demian Katz's avatar Demian Katz
Browse files

Updated MobileUrl helper for ZF2.

parent 2e096600
No related merge requests found
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/building_a_recommendations_module Wiki * @link http://vufind.org/wiki/building_a_recommendations_module Wiki
*/ */
namespace VuFindThemes\Root\Helpers;
use VuFind\Mobile,
Zend\View\Helper\AbstractHelper;
/** /**
* Mobile URL view helper * Mobile URL view helper
...@@ -35,7 +38,7 @@ ...@@ -35,7 +38,7 @@
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/building_a_recommendations_module Wiki * @link http://vufind.org/wiki/building_a_recommendations_module Wiki
*/ */
class VuFind_Theme_Root_Helper_MobileUrl extends Zend_View_Helper_Abstract class MobileUrl extends AbstractHelper
{ {
/** /**
* Return the mobile version of the current URL if the user is on a mobile device * Return the mobile version of the current URL if the user is on a mobile device
...@@ -43,22 +46,17 @@ class VuFind_Theme_Root_Helper_MobileUrl extends Zend_View_Helper_Abstract ...@@ -43,22 +46,17 @@ class VuFind_Theme_Root_Helper_MobileUrl extends Zend_View_Helper_Abstract
* *
* @return string * @return string
*/ */
public function mobileUrl() public function __invoke()
{ {
// Do nothing special if we're not on a mobile device or no mobile theme is // Do nothing special if we're not on a mobile device or no mobile theme is
// enabled: // enabled:
if (!VF_Mobile::enabled() || !VF_Mobile::detect()) { if (!Mobile::enabled() || !Mobile::detect()) {
return false; return false;
} }
// TODO: find a better way to obtain GET parameters without using superglobal $urlHelper = $this->getView()->plugin('serverurl');
// (Zend Framework doesn't seem to offer a simple solution). $currentUrl = rtrim($urlHelper(true), '?');
$newParams = array('ui' => 'mobile'); $currentUrl .= strstr($currentUrl, '?') ? '&' : '?';
foreach ($_GET as $key => $value) { return $currentUrl .= 'ui=mobile';
if ($key != 'ui') {
$newParams[$key] = $value;
}
}
return $this->view->url() . '?' . http_build_query($newParams);
} }
} }
\ No newline at end of file
extends = false extends = false
helper_namespace = "VuFindThemes\Root\Helpers" helper_namespace = "VuFindThemes\Root\Helpers"
helpers_to_register[] = "MobileUrl"
helpers_to_register[] = "TransEsc" helpers_to_register[] = "TransEsc"
helpers_to_register[] = "Translate" helpers_to_register[] = "Translate"
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment