mirror of
https://github.com/processwire/processwire.git
synced 2025-08-11 17:24:46 +02:00
Minor adjustments
This commit is contained in:
@@ -111,7 +111,7 @@ function __($text, $textdomain = null, $context = '') {
|
||||
$textArray = false;
|
||||
$encode = $options['entityEncode'];
|
||||
$user = wire('user');
|
||||
$language = $user ? $user->language : null; /** @var Language $language */
|
||||
$language = $user ? $user->get('language') : null; /** @var Language $language */
|
||||
|
||||
if(!is_string($text)) {
|
||||
// getting/setting options or translating with multiple phrases accepted
|
||||
|
@@ -669,7 +669,7 @@ class WireArray extends Wire implements \IteratorAggregate, \ArrayAccess, \Count
|
||||
if(ctype_digit("$key")) return null;
|
||||
$item = null;
|
||||
foreach($this->data as $wire) {
|
||||
if(is_object($wire)) {
|
||||
if(is_object($wire) && $wire instanceof Wire) {
|
||||
if($wire->$key === $value) {
|
||||
$item = $wire;
|
||||
break;
|
||||
|
@@ -266,6 +266,19 @@ class WireLog extends Wire {
|
||||
return $this->wire('config')->paths->logs . $name . '.' . $this->logExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does given log name exist?
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
* @since 3.0.176
|
||||
*
|
||||
*/
|
||||
public function exists($name) {
|
||||
$filename = $this->getFilename($name);
|
||||
return is_file($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the given number of entries from the end of log file
|
||||
*
|
||||
@@ -447,8 +460,10 @@ class WireLog extends Wire {
|
||||
*
|
||||
*/
|
||||
public function delete($name) {
|
||||
if(!$this->exists($name)) return false;
|
||||
$log = $this->getFileLog($name);
|
||||
return $log->delete();
|
||||
if($log) return $log->delete();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -463,6 +478,7 @@ class WireLog extends Wire {
|
||||
*
|
||||
*/
|
||||
public function prune($name, $days) {
|
||||
if(!$this->exists($name)) return false;
|
||||
$log = $this->getFileLog($name);
|
||||
if($days < 1) throw new WireException("Prune days must be 1 or more");
|
||||
$oldestDate = strtotime("-$days DAYS");
|
||||
|
Reference in New Issue
Block a user