From e1d1044264bdb6836bd3f8f0f143507b33fd4916 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Mon, 25 Jun 2012 15:49:23 -0400
Subject: [PATCH] Introduced "offline mode" view helper.

---
 .../VuFind/Theme/Root/Helper/OfflineMode.php  | 56 +++++++++++++++++++
 .../blueprint/templates/search/home.phtml     |  2 +-
 .../jquerymobile/templates/search/home.phtml  |  2 +-
 themes/vufind/root/theme.ini                  |  1 +
 4 files changed, 59 insertions(+), 2 deletions(-)
 create mode 100644 module/VuFind/src/VuFind/Theme/Root/Helper/OfflineMode.php

diff --git a/module/VuFind/src/VuFind/Theme/Root/Helper/OfflineMode.php b/module/VuFind/src/VuFind/Theme/Root/Helper/OfflineMode.php
new file mode 100644
index 00000000000..d9dce6ade25
--- /dev/null
+++ b/module/VuFind/src/VuFind/Theme/Root/Helper/OfflineMode.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * "Offline mode" view helper
+ *
+ * PHP version 5
+ *
+ * Copyright (C) Villanova University 2010.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * @category VuFind2
+ * @package  View_Helpers
+ * @author   Demian Katz <demian.katz@villanova.edu>
+ * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
+ * @link     http://vufind.org/wiki/building_a_recommendations_module Wiki
+ */
+namespace VuFind\Theme\Root\Helper;
+use VuFind\Search\Options, Zend\View\Helper\AbstractHelper;
+
+/**
+ * "Offline mode" view helper
+ *
+ * @category VuFind2
+ * @package  View_Helpers
+ * @author   Demian Katz <demian.katz@villanova.edu>
+ * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
+ * @link     http://vufind.org/wiki/building_a_recommendations_module Wiki
+ */
+class OfflineMode extends AbstractHelper
+{
+    /**
+     * Wrapper function to the VF_Search_Options getInstance function
+     *
+     * @param string $type The search type of the object to retrieve
+     *
+     * @return SearchOptions
+     */
+    public function __invoke()
+    {
+        /* TODO:
+        return VF_Connection_Manager::connectToCatalog()->getOfflineMode();
+         */
+        return '';
+    }
+}
\ No newline at end of file
diff --git a/themes/vufind/blueprint/templates/search/home.phtml b/themes/vufind/blueprint/templates/search/home.phtml
index 1cdd484186e..8afe6dc6659 100644
--- a/themes/vufind/blueprint/templates/search/home.phtml
+++ b/themes/vufind/blueprint/templates/search/home.phtml
@@ -16,7 +16,7 @@
     $advSearch = $options->getAdvancedSearchAction();
 ?>
 <div class="searchHomeContent">
-  <? if (VF_Connection_Manager::connectToCatalog()->getOfflineMode() == "ils-offline"): ?>
+  <? if ($this->offlineMode() == "ils-offline"): ?>
     <div class="sysInfo">
       <h2><?=$this->transEsc('ils_offline_title')?></h2>
       <p><strong><?=$this->transEsc('ils_offline_status')?></strong></p>
diff --git a/themes/vufind/jquerymobile/templates/search/home.phtml b/themes/vufind/jquerymobile/templates/search/home.phtml
index 8586a01848e..46a26c505d0 100644
--- a/themes/vufind/jquerymobile/templates/search/home.phtml
+++ b/themes/vufind/jquerymobile/templates/search/home.phtml
@@ -5,7 +5,7 @@
 <div data-role="page" id="Search-home">
   <?=$this->mobileMenu()->header(array('searchLink' => false, 'results' => null))?>
   <div data-role="content">
-    <? if (VF_Connection_Manager::connectToCatalog()->getOfflineMode() == "ils-offline"): ?>
+    <? if ($this->offlineMode() == "ils-offline"): ?>
       <div class="sysInfo">
         <h2><?=$this->transEsc('ils_offline_title')?></h2>
         <p><strong><?=$this->transEsc('ils_offline_status')?></strong></p>
diff --git a/themes/vufind/root/theme.ini b/themes/vufind/root/theme.ini
index 308b7e07c08..ce161257c14 100644
--- a/themes/vufind/root/theme.ini
+++ b/themes/vufind/root/theme.ini
@@ -7,6 +7,7 @@ helpers_to_register[] = "HeadScript"
 helpers_to_register[] = "HeadThemeResources"
 helpers_to_register[] = "ImageLink"
 helpers_to_register[] = "MobileUrl"
+helpers_to_register[] = "OfflineMode"
 helpers_to_register[] = "SearchOptions"
 helpers_to_register[] = "TransEsc"
 helpers_to_register[] = "Translate"
-- 
GitLab