1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-15 19:24:28 +02:00

Various minor primarily phpdoc updates

This commit is contained in:
Ryan Cramer
2019-05-22 14:03:03 -04:00
parent 2b7f80d575
commit 73f0c915de
5 changed files with 72 additions and 20 deletions

View File

@@ -39,6 +39,7 @@
* @property Pagefiles $pagefiles The Pagefiles WireArray that contains this file. #pw-group-other
* @property Page $page The Page object that this file is part of. #pw-group-other
* @property Field $field The Field object that this file is part of. #pw-group-other
* @property array $filedata
*
* @method void install($filename)
* @method string httpUrl()
@@ -388,7 +389,7 @@ class Pagefile extends WireData {
* - To SET in all languages as a JSON string: Specify boolean true, plus the JSON string $value as the 2nd argument (internal use only).
* - To SET in all languages as an array: Specify the array here, indexed by language ID or name, and omit 2nd argument.
* @param null|string $value Specify only when you are setting (single language) rather than getting a value.
* @return string
* @return string|array
*
*/
public function description($language = null, $value = null) {
@@ -564,7 +565,7 @@ class Pagefile extends WireData {
*
* #pw-group-traversal
*
* @return Pagefile|null
* @return Pagefile|Wire|null
*
*/
public function getNext() {
@@ -576,7 +577,7 @@ class Pagefile extends WireData {
*
* #pw-group-traversal
*
* @return Pagefile|null
* @return Pagefile|Wire|null
*
*/
public function getPrev() {

View File

@@ -56,6 +56,12 @@ class PagefilesManager extends Wire {
*/
const extendedDirName = '0/';
/**
* Name of file that maintains the last modification time independent of directory (LATER/FUTURE)
*
const metaFileName = '.pw';
*/
/**
* Reference to the Page object this PagefilesManager is managing
*
@@ -483,6 +489,7 @@ class PagefilesManager extends Wire {
if(!$dir) return false;
$has = false;
while(!$has && ($f = readdir($dir)) !== false) $has = $f !== '..' && $f !== '.';
// while(!$has && ($f = readdir($dir)) !== false) $has = $f !== '..' && $f !== '.' && !$f !== self::metaFileName;
return $has;
}
@@ -624,5 +631,48 @@ class PagefilesManager extends Wire {
// if(is_null($wtd)) $wtd = $this->wire(new WireTempDir($this->className() . $this->page->id));
// return $wtd->get();
}
/**
* Have this pages files had modifications since last isModified(true) call? (FUTURE USE)
*
* Please note the following:
*
* - This only takes into account files in the actual directory and not subdirectories unless
* the $recursive option is true.
*
* - This method always returns true the first time it has been called on a given path.
*
* @param bool $reset Reset to current time if modified? Ensures future calls return false until modified again. (default=false)
* @param bool $recursive Descend into directories (max 1 level)? (default=false)
* @param string $path Path to check if not default, primarily for internal recursive use. (default='')
* @return bool True if files in directory have been modified since last reset, or false if not
*
public function isModified($reset = false, $recursive = false, $path = '') {
$files = $this->wire('files');
$path = empty($path) ? $this->path() : $files->unixDirName($path);
$file = $path . self::metaFileName;
if(!file_exists($file)) {
touch($file);
$files->chmod($file);
$isModified = true;
} else {
$fileTime = filemtime($file);
$pathTime = filemtime($path);
$isModified = $pathTime > $fileTime;
if($isModified && $reset) touch($file);
}
if($recursive && !$isModified) {
$dirs = array();
foreach(new \DirectoryIterator($path) as $item) {
if($item->isDot() || !$item->isDir()) continue;
$dirs[] = $item->getPathname();
}
foreach($dirs as $dir) {
$isModified = $this->isModified($reset, false, $dir);
if($isModified) break;
}
}
return $isModified;
}
*/
}