From dcf240ab6de9dfd5a71a8e9589b7c974a5616d4b Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Wed, 29 Aug 2012 14:50:51 -0400
Subject: [PATCH] Moved DisplayDateFormat functionality from separate view
 helper into DateTime view helper to consolidate code.

---
 .../src/VuFind/Theme/Root/Helper/DateTime.php | 19 ++++++
 .../Theme/Root/Helper/DisplayDateFormat.php   | 62 -------------------
 themes/blueprint/templates/record/hold.phtml  |  2 +-
 .../jquerymobile/templates/record/hold.phtml  |  2 +-
 themes/root/theme.ini                         |  1 -
 5 files changed, 21 insertions(+), 65 deletions(-)
 delete mode 100644 module/VuFind/src/VuFind/Theme/Root/Helper/DisplayDateFormat.php

diff --git a/module/VuFind/src/VuFind/Theme/Root/Helper/DateTime.php b/module/VuFind/src/VuFind/Theme/Root/Helper/DateTime.php
index 9212c55c9f7..4ccaf2dd2fc 100644
--- a/module/VuFind/src/VuFind/Theme/Root/Helper/DateTime.php
+++ b/module/VuFind/src/VuFind/Theme/Root/Helper/DateTime.php
@@ -66,4 +66,23 @@ class DateTime extends AbstractHelper
             return false;
         }
     }
+
+    /**
+     * Builds an alphabetical help string based on the default display date format.
+     *
+     * @return string
+     */
+    public function getDisplayDateFormat()
+    {
+        $dueDateHelpString
+            = $this->converter->convertToDisplayDate("m-d-y", "11-22-3333");
+        $search = array("1", "2", "3");
+        $replace = array(
+            $this->view->translate("date_month_placeholder"),
+            $this->view->translate("date_day_placeholder"),
+            $this->view->translate("date_year_placeholder")
+        );
+
+        return str_replace($search, $replace, $dueDateHelpString);
+    }
 }
\ No newline at end of file
diff --git a/module/VuFind/src/VuFind/Theme/Root/Helper/DisplayDateFormat.php b/module/VuFind/src/VuFind/Theme/Root/Helper/DisplayDateFormat.php
deleted file mode 100644
index 817f43cdb90..00000000000
--- a/module/VuFind/src/VuFind/Theme/Root/Helper/DisplayDateFormat.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-/**
- * Date format display view helper -- build a language-appropriate format key for
- * entering dates.
- *
- * 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\Date\Converter as DateConverter, Zend\View\Helper\AbstractHelper;
-
-/**
- * Date format display 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 DisplayDateFormat extends AbstractHelper
-{
-    /**
-     * Builds an alphabetical help string based on the default display date format.
-     *
-     * @return string
-     */
-    public function __invoke()
-    {
-        $dateFormat = new DateConverter();
-        $dueDateHelpString
-            = $dateFormat->convertToDisplayDate("m-d-y", "11-22-3333");
-        $search = array("1", "2", "3");
-        $replace = array(
-            $this->view->translate("date_month_placeholder"),
-            $this->view->translate("date_day_placeholder"),
-            $this->view->translate("date_year_placeholder")
-        );
-
-        return str_replace($search, $replace, $dueDateHelpString);
-    }
-}
\ No newline at end of file
diff --git a/themes/blueprint/templates/record/hold.phtml b/themes/blueprint/templates/record/hold.phtml
index d6d45a19c25..70ecaf3ec7d 100644
--- a/themes/blueprint/templates/record/hold.phtml
+++ b/themes/blueprint/templates/record/hold.phtml
@@ -22,7 +22,7 @@
     <? if (in_array("requiredByDate", $this->extraHoldFields)): ?>
       <div>
       <strong><?=$this->transEsc("hold_required_by")?>: </strong>
-      <div id="requiredByHolder"><input id="requiredByDate" type="text" name="gatheredDetails[requiredBy]" value="<?=(isset($this->gatheredDetails['requiredBy']) && !empty($this->gatheredDetails['requiredBy'])) ? $this->escapeHtml($this->gatheredDetails['requiredBy']) : $this->escapeHtml($this->defaultRequiredDate)?>" size="8" /> <strong>(<?=$this->displayDateFormat()?>)</strong></div>
+      <div id="requiredByHolder"><input id="requiredByDate" type="text" name="gatheredDetails[requiredBy]" value="<?=(isset($this->gatheredDetails['requiredBy']) && !empty($this->gatheredDetails['requiredBy'])) ? $this->escapeHtml($this->gatheredDetails['requiredBy']) : $this->escapeHtml($this->defaultRequiredDate)?>" size="8" /> <strong>(<?=$this->dateTime()->getDisplayDateFormat()?>)</strong></div>
       </div>
     <? endif; ?>
 
diff --git a/themes/jquerymobile/templates/record/hold.phtml b/themes/jquerymobile/templates/record/hold.phtml
index 31cd4c7f157..9f8cdee8896 100644
--- a/themes/jquerymobile/templates/record/hold.phtml
+++ b/themes/jquerymobile/templates/record/hold.phtml
@@ -21,7 +21,7 @@
         <? if (in_array("requiredByDate", $this->extraHoldFields)): ?>
           <div>
           <strong><?=$this->transEsc("hold_required_by")?>: </strong>
-          <div id="requiredByHolder"><input id="requiredByDate" type="text" name="gatheredDetails[requiredBy]" value="<?=(isset($this->gatheredDetails['requiredBy']) && !empty($this->gatheredDetails['requiredBy'])) ? $this->escapeHtml($this->gatheredDetails['requiredBy']) : $this->escapeHtml($this->defaultRequiredDate)?>" size="8" /> <strong>(<?=$this->displayDateFormat()?>)</strong></div>
+          <div id="requiredByHolder"><input id="requiredByDate" type="text" name="gatheredDetails[requiredBy]" value="<?=(isset($this->gatheredDetails['requiredBy']) && !empty($this->gatheredDetails['requiredBy'])) ? $this->escapeHtml($this->gatheredDetails['requiredBy']) : $this->escapeHtml($this->defaultRequiredDate)?>" size="8" /> <strong>(<?=$this->dateTime()->getDisplayDateFormat()?>)</strong></div>
           </div>
         <? endif; ?>
 
diff --git a/themes/root/theme.ini b/themes/root/theme.ini
index 4eecd264563..97d6acb6184 100644
--- a/themes/root/theme.ini
+++ b/themes/root/theme.ini
@@ -11,7 +11,6 @@ helpers_to_register[] = "Citation"
 helpers_to_register[] = "Context"
 helpers_to_register[] = "CurrentPath"
 helpers_to_register[] = "DateTime"
-helpers_to_register[] = "DisplayDateFormat"
 helpers_to_register[] = "DisplayLanguageOption"
 helpers_to_register[] = "Excerpt"
 helpers_to_register[] = "Flashmessages"
-- 
GitLab