mirror of
https://github.com/processwire/processwire.git
synced 2025-08-16 03:34:33 +02:00
Various minor primarily phpdoc updates
This commit is contained in:
@@ -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() {
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
@@ -625,4 +632,47 @@ class PagefilesManager extends Wire {
|
||||
// return $wtd->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Have this page’s 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;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@@ -117,6 +117,7 @@ class FieldtypeFile extends FieldtypeMulti {
|
||||
$inputfieldClass = $field->get('inputfieldClass');
|
||||
if($inputfieldClass) $inputfield = $this->modules->get($inputfieldClass);
|
||||
if(!$inputfield) $inputfield = $this->modules->get($this->defaultInputfieldClass);
|
||||
/** @var Inputfield $inputfield */
|
||||
$inputfield->class = $this->className();
|
||||
|
||||
$this->setupHooks($page, $field, $inputfield);
|
||||
@@ -228,7 +229,7 @@ class FieldtypeFile extends FieldtypeMulti {
|
||||
* @param Page $page
|
||||
* @param Field $field
|
||||
* @param string|int|array|object $value
|
||||
* @return string|int
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
public function ___sleepValue(Page $page, Field $field, $value) {
|
||||
|
@@ -240,7 +240,7 @@ class FieldtypePage extends FieldtypeMulti implements Module, ConfigurableModule
|
||||
* @param Page $page
|
||||
* @param Field $field
|
||||
* @param string|int|array|object $value
|
||||
* @return string|int
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
public function ___sleepValue(Page $page, Field $field, $value) {
|
||||
@@ -717,7 +717,6 @@ class FieldtypePage extends FieldtypeMulti implements Module, ConfigurableModule
|
||||
* @param string $operator The comparison operator
|
||||
* @param mixed $value The value to find
|
||||
* @return DatabaseQuery $query
|
||||
* @throws WireException if given invalid or unrecognized arguments
|
||||
*
|
||||
*/
|
||||
protected function getLoadQueryWhere(Field $field, DatabaseQuerySelect $query, $col, $operator, $value) {
|
||||
@@ -733,7 +732,7 @@ class FieldtypePage extends FieldtypeMulti implements Module, ConfigurableModule
|
||||
* @param string $subfield
|
||||
* @param string $operator
|
||||
* @param string $value
|
||||
* @return DatabaseQuerySelect
|
||||
* @return DatabaseQuery
|
||||
* @throws WireException
|
||||
*
|
||||
*/
|
||||
@@ -1502,7 +1501,6 @@ class FieldtypePage extends FieldtypeMulti implements Module, ConfigurableModule
|
||||
* @param Field|array $field Field object or array with all possible template IDs
|
||||
* @param bool $getString Specify true to return a 1|2|3 style string rather than an array
|
||||
* @return array|string
|
||||
* @throws WireException
|
||||
*
|
||||
*/
|
||||
static public function getTemplateIDs($field, $getString = false) {
|
||||
|
@@ -40,9 +40,9 @@ class FieldtypeURL extends FieldtypeText {
|
||||
*/
|
||||
public function sanitizeValue(Page $page, Field $field, $value) {
|
||||
return $this->sanitizer->url($value, array(
|
||||
'allowRelative' => $field->noRelative ? false : true,
|
||||
'allowIDN' => $field->allowIDN ? true : false,
|
||||
'stripQuotes' => $field->allowQuotes ? false : true
|
||||
'allowRelative' => $field->get('noRelative') ? false : true,
|
||||
'allowIDN' => $field->get('allowIDN') ? true : false,
|
||||
'stripQuotes' => $field->get('allowQuotes') ? false : true
|
||||
));
|
||||
}
|
||||
|
||||
@@ -50,13 +50,13 @@ class FieldtypeURL extends FieldtypeText {
|
||||
public function getInputfield(Page $page, Field $field) {
|
||||
/** @var InputfieldURL $inputfield */
|
||||
$inputfield = $this->modules->get('InputfieldURL');
|
||||
$inputfield->set('noRelative', $field->noRelative);
|
||||
$inputfield->set('addRoot', $field->addRoot);
|
||||
$inputfield->set('noRelative', $field->get('noRelative'));
|
||||
$inputfield->set('addRoot', $field->get('addRoot'));
|
||||
return $inputfield;
|
||||
}
|
||||
|
||||
public function ___formatValue(Page $page, Field $field, $value) {
|
||||
if($field->addRoot && !$field->noRelative && substr($value, 0, 1) == '/') {
|
||||
if($field->get('addRoot') && !$field->get('noRelative') && substr($value, 0, 1) == '/') {
|
||||
$root = rtrim($this->config->urls->root, '/');
|
||||
$value = $root . $value;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ class FieldtypeURL extends FieldtypeText {
|
||||
$f->label = $this->_('Allow relative/local URLs without "http://" at the beginning?');
|
||||
$f->addOption(0, $labelYes);
|
||||
$f->addOption(1, $labelNo);
|
||||
$f->attr('value', $field->noRelative ? 1 : 0);
|
||||
$f->attr('value', $field->get('noRelative') ? 1 : 0);
|
||||
$f->description = $this->_('Local/relative URLs are those without scheme and domain.');
|
||||
$f->columnWidth = 33;
|
||||
$f->optionColumns = 1;
|
||||
@@ -95,7 +95,7 @@ class FieldtypeURL extends FieldtypeText {
|
||||
$f->label = $this->_('Allow internationalized domain names (IDNs)?');
|
||||
$f->addOption(1, $labelYes);
|
||||
$f->addOption(0, $labelNo);
|
||||
$f->attr('value', $field->allowIDN ? 1 : 0);
|
||||
$f->attr('value', $field->get('allowIDN') ? 1 : 0);
|
||||
$f->description = $this->_('When enabled, non-ASCII domain names are allowed.');
|
||||
$f->columnWidth = 33;
|
||||
$f->optionColumns = 1;
|
||||
@@ -106,7 +106,7 @@ class FieldtypeURL extends FieldtypeText {
|
||||
$f->label = $this->_('Allow single/double quote characters in URLs?');
|
||||
$f->addOption(1, $labelYes);
|
||||
$f->addOption(0, $labelNo);
|
||||
$f->attr('value', $field->allowQuotes ? 1 : 0);
|
||||
$f->attr('value', $field->get('allowQuotes') ? 1 : 0);
|
||||
$f->description = $this->_('When enabled, you should be absolutely certain such URLs are entity encoded when used in markup.');
|
||||
$f->columnWidth = 34;
|
||||
$f->optionColumns = 1;
|
||||
@@ -117,10 +117,10 @@ class FieldtypeURL extends FieldtypeText {
|
||||
$f->label = $this->_("Prepend site's root path to local/relative URLs?");
|
||||
$f->addOption(1, $labelYes);
|
||||
$f->addOption(0, $labelNo);
|
||||
$f->attr('value', $field->addRoot ? 1 : 0);
|
||||
$f->attr('value', $field->get('addRoot') ? 1 : 0);
|
||||
$f->description = $this->_("This option will automatically prepend the site's root path to any URLs that start with a slash, like /some/path/. This is useful if your site is running from a subdirectory because you won't have to include that subdirectory in the URLs you enter into this field. Should you later move your site to the root of a domain (or another subdirectory) you won't have to worry about broken URLs. With this option enabled, always enter URLs as if the site were running from the root of a domain, regardless of whether it's running from a subdirectory or not. Naturally this is applicable only if you selected 'Yes' to allowing local/relative URLs in the field above. Developers may also want to note that this option applies only when a page's outputFormatting is on."); // addRoot description
|
||||
$f->notes = $this->_("Ensures that URLs aren't broken when moving a site from a subdirectory to root (the most common example)."); // addRoot notes
|
||||
$f->collapsed = $field->addRoot ? Inputfield::collapsedNo : Inputfield::collapsedYes;
|
||||
$f->collapsed = $field->get('addRoot') ? Inputfield::collapsedNo : Inputfield::collapsedYes;
|
||||
$f->optionColumns = 1;
|
||||
$f->showIf = "noRelative=0";
|
||||
$inputfields->add($f);
|
||||
@@ -128,5 +128,7 @@ class FieldtypeURL extends FieldtypeText {
|
||||
return $inputfields;
|
||||
}
|
||||
|
||||
// @todo add markupValue()
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user