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

Moved DisplayDateFormat functionality from separate view helper into DateTime...

Moved DisplayDateFormat functionality from separate view helper into DateTime view helper to consolidate code.
parent 61e788ab
No related merge requests found
...@@ -66,4 +66,23 @@ class DateTime extends AbstractHelper ...@@ -66,4 +66,23 @@ class DateTime extends AbstractHelper
return false; 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
<?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
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<? if (in_array("requiredByDate", $this->extraHoldFields)): ?> <? if (in_array("requiredByDate", $this->extraHoldFields)): ?>
<div> <div>
<strong><?=$this->transEsc("hold_required_by")?>: </strong> <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> </div>
<? endif; ?> <? endif; ?>
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<? if (in_array("requiredByDate", $this->extraHoldFields)): ?> <? if (in_array("requiredByDate", $this->extraHoldFields)): ?>
<div> <div>
<strong><?=$this->transEsc("hold_required_by")?>: </strong> <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> </div>
<? endif; ?> <? endif; ?>
......
...@@ -11,7 +11,6 @@ helpers_to_register[] = "Citation" ...@@ -11,7 +11,6 @@ helpers_to_register[] = "Citation"
helpers_to_register[] = "Context" helpers_to_register[] = "Context"
helpers_to_register[] = "CurrentPath" helpers_to_register[] = "CurrentPath"
helpers_to_register[] = "DateTime" helpers_to_register[] = "DateTime"
helpers_to_register[] = "DisplayDateFormat"
helpers_to_register[] = "DisplayLanguageOption" helpers_to_register[] = "DisplayLanguageOption"
helpers_to_register[] = "Excerpt" helpers_to_register[] = "Excerpt"
helpers_to_register[] = "Flashmessages" helpers_to_register[] = "Flashmessages"
......
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