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