Skip to content
2 changes: 1 addition & 1 deletion core/lexicon/en/tv_widget.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
$_lang['combo_typeahead_delay_desc'] = 'Milliseconds before a matched option is shown. (Default: 250)';
$_lang['date'] = 'Date';
$_lang['date_format'] = 'Date Format';
$_lang['date_format_desc'] = 'Enter a format using <a href="https://www.php.net/strftime" target="_blank">php’s strftime syntax</a>.
$_lang['date_format_desc'] = 'Enter a format using <a href="https://www.php.net/manual/en/datetime.format.php" target="_blank">php’s datetime syntax</a>.
<div class="example-list">Common examples include:
<ul>
<li><span class="example-input">[[+example_1a]]</span> ([[+example_1b]]) (default format)</li>
Expand Down
15 changes: 7 additions & 8 deletions core/src/Revolution/File/modFile.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* This file is part of the MODX Revolution package.
*
Expand All @@ -10,7 +11,6 @@

namespace MODX\Revolution\File;


/**
* File implementation of modFileSystemResource
*
Expand Down Expand Up @@ -151,7 +151,6 @@ public function save($content = null, $mode = 'w+')
*/
public function unpack($to = '', $options = [])
{

$results = false;

if ($this->fileHandler->modx->getService('archive', 'compression.xPDOZip', XPDO_CORE_PATH, $this->path)) {
Expand Down Expand Up @@ -184,25 +183,25 @@ public function getSize()
/**
* Gets the last accessed time of the file
*
* @param string $timeFormat The format, in strftime format, of the time
* @param string $timeFormat The format, in datetime format, of the time
*
* @return string The formatted time
*/
public function getLastAccessed($timeFormat = '%b %d, %Y %I:%M:%S %p')
public function getLastAccessed($timeFormat = 'M d, Y h:i:s A')
{
return strftime($timeFormat, fileatime($this->path));
return $this->fileHandler->formatter->format(fileatime($this->path), $timeFormat);
}

/**
* Gets the last modified time of the file
*
* @param string $timeFormat The format, in strftime format, of the time
* @param string $timeFormat The format, in datetime format, of the time
*
* @return string The formatted time
*/
public function getLastModified($timeFormat = '%b %d, %Y %I:%M:%S %p')
public function getLastModified($timeFormat = 'M d, Y h:i:s A')
{
return strftime($timeFormat, filemtime($this->path));
return $this->fileHandler->formatter->format(filemtime($this->path), $timeFormat);
}

/**
Expand Down
33 changes: 23 additions & 10 deletions core/src/Revolution/File/modFileHandler.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* This file is part of the MODX Revolution package.
*
Expand All @@ -10,7 +11,7 @@

namespace MODX\Revolution\File;


use MODX\Revolution\Formatter\modManagerDateFormatter;
use MODX\Revolution\modContext;
use MODX\Revolution\modX;

Expand All @@ -19,7 +20,8 @@
*
* @package MODX\Revolution\File
*/
class modFileHandler {
class modFileHandler
{
/**
* An array of configuration properties for the class
* @var array $config
Expand All @@ -31,19 +33,23 @@ class modFileHandler {
*/
public $context = null;

protected modManagerDateFormatter $formatter;

/**
* The constructor for the modFileHandler class
*
* @param modX &$modx A reference to the modX object.
* @param array $config An array of options.
*/
function __construct(modX &$modx, array $config = []) {
public function __construct(modX &$modx, array $config = [])
{
$this->modx =& $modx;
$this->config = array_merge($this->config, $this->modx->_userConfig, $config);
if (!isset($this->config['context'])) {
$this->config['context'] = $this->modx->context->get('key');
}
$this->context = $this->modx->getContext($this->config['context']);
$this->formatter = $this->modx->services->get(modManagerDateFormatter::class);
}

/**
Expand All @@ -57,7 +63,8 @@ function __construct(modX &$modx, array $config = []) {
* of the object as the specified class.
* @return mixed The appropriate modFile/modDirectory object
*/
public function make($path, array $options = [], $overrideClass = '') {
public function make($path, array $options = [], $overrideClass = '')
{
$path = $this->sanitizePath($path);

if (!empty($overrideClass)) {
Expand All @@ -79,7 +86,8 @@ public function make($path, array $options = [], $overrideClass = '') {
*
* @return string The base path
*/
public function getBasePath() {
public function getBasePath()
{
$basePath = '';

/* expand placeholders */
Expand All @@ -100,7 +108,8 @@ public function getBasePath() {
*
* @return string The base URL
*/
public function getBaseUrl() {
public function getBaseUrl()
{
$baseUrl = '';

/* expand placeholders */
Expand All @@ -122,7 +131,8 @@ public function getBaseUrl() {
* @param string $path The path to clean
* @return string The sanitized path
*/
public function sanitizePath($path) {
public function sanitizePath($path)
{
return preg_replace(["/\.*[\/|\\\]/i", "/[\/|\\\]+/i"], ['/', '/'], $path);
}

Expand All @@ -132,7 +142,8 @@ public function sanitizePath($path) {
* @param string $path
* @return string The postfixed path
*/
public function postfixSlash($path) {
public function postfixSlash($path)
{
$len = strlen($path);
if (substr($path, $len - 1, $len) != '/') {
$path .= '/';
Expand All @@ -146,7 +157,8 @@ public function postfixSlash($path) {
* @param string $fileName The path for a file
* @return string The directory path of the given file
*/
public function getDirectoryFromFile($fileName) {
public function getDirectoryFromFile($fileName)
{
$dir = dirname($fileName);
return $this->postfixSlash($dir);
}
Expand All @@ -157,7 +169,8 @@ public function getDirectoryFromFile($fileName) {
* @param string $file
* @return boolean True if a binary file.
*/
public function isBinary($file) {
public function isBinary($file)
{
if (!file_exists($file) || !is_file($file)) {
return false;
}
Expand Down
Loading