From 5636a81d1537924b1d4b2114bdb472c8c2f495ee Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 13 May 2022 10:34:30 -0400 Subject: [PATCH] Various pre-merge documentation and housekeeping updates --- README.md | 6 +- wire/core/AdminThemeFramework.php | 2 +- wire/core/Config.php | 30 +++- wire/core/InputfieldWrapper.php | 2 +- wire/core/MarkupQA.php | 31 +++- wire/core/Modules.php | 8 +- wire/core/Page.php | 29 ++-- wire/core/Pages.php | 35 +++-- wire/core/PagesPathFinder.php | 50 +++++-- wire/core/PagesRaw.php | 4 - wire/core/PagesRequest.php | 10 +- wire/core/Paths.php | 11 +- wire/core/Permissions.php | 2 +- wire/core/Sanitizer.php | 29 +++- wire/core/Session.php | 46 +++++- wire/core/User.php | 42 ++++-- wire/core/WireDatabasePDO.php | 132 ++++++++++++++---- wire/core/WireFileTools.php | 33 ++++- wire/core/WireInput.php | 10 +- wire/core/WireTextTools.php | 5 +- .../FieldtypeComments.module | 53 +++++++ 21 files changed, 457 insertions(+), 113 deletions(-) diff --git a/README.md b/README.md index 867585e4..6abd7c36 100644 --- a/README.md +++ b/README.md @@ -129,9 +129,9 @@ replacing your `/wire/` directory with the one from the newer version. ### Pro module version upgrade notes (if applicable) - [FormBuilder](https://processwire.com/store/form-builder/) - version 0.4.0 or newer required, 0.5.0 or newer recommended. + version 0.4.0 or newer required, 0.5.2 or newer recommended. - [ListerPro](https://processwire.com/store/lister-pro/) - version 1.0.9 or newer required, 1.1.3 or newer recommended. + version 1.0.9 or newer required, 1.1.4 or newer recommended. - [ProFields](https://processwire.com/store/pro-fields/) the latest versions of all ProFields (10 modules) are recommended. - [LoginRegisterPro](https://processwire.com/store/login-register-pro/) @@ -181,5 +181,5 @@ resolved any issues. ------ -Copyright 2021 by Ryan Cramer / Ryan Cramer Design, LLC +Copyright 2022 by Ryan Cramer / Ryan Cramer Design, LLC diff --git a/wire/core/AdminThemeFramework.php b/wire/core/AdminThemeFramework.php index 4d5ec788..901c8417 100644 --- a/wire/core/AdminThemeFramework.php +++ b/wire/core/AdminThemeFramework.php @@ -19,7 +19,7 @@ * @property bool|int $useAsLogin * @method array getUserNavArray() * @method array getPrimaryNavArray() - * @method string renderFile($basename, array $vars = array()) + * @method string renderFile($basename, array $vars = []) * */ abstract class AdminThemeFramework extends AdminTheme { diff --git a/wire/core/Config.php b/wire/core/Config.php index 5e42d4b7..8cfabde3 100644 --- a/wire/core/Config.php +++ b/wire/core/Config.php @@ -8,10 +8,11 @@ * This file is licensed under the MIT license * https://processwire.com/about/license/mit/ * - * ProcessWire 3.x, Copyright 2021 by Ryan Cramer + * ProcessWire 3.x, Copyright 2022 by Ryan Cramer * https://processwire.com * * #pw-summary Holds ProcessWire configuration settings as defined in /wire/config.php and /site/config.php. + * #pw-summary-js Javascript configuration * #pw-body = * For more detailed descriptions of these $config properties, including default values, see the * [/wire/config.php](https://github.com/processwire/processwire/blob/master/wire/config.php) file. @@ -32,7 +33,7 @@ * @property FilenameArray $scripts Array used by ProcessWire admin to keep track of what javascript files its template should load. It will be blank otherwise. Feel free to use it for the same purpose in your own sites. #pw-group-runtime * * @property Paths $urls Items from $config->urls reflect the http path one would use to load a given location in the web browser. URLs retrieved from $config->urls always end with a trailing slash. This is the same as the $urls API variable. #pw-group-runtime #pw-group-URLs - * @property Paths $paths All of what can be accessed from $config->urls can also be accessed from $config->paths, with one important difference: the returned value is the full disk path on the server. There are also a few items in $config->paths that aren't in $config->urls. All entries in $config->paths always end with a trailing slash. #pw-group-runtime + * @property Paths $paths All of what can be accessed from $config->urls can also be accessed from $config->paths, with one important difference: the returned value is the full disk path on the server. There are also a few items in $config->paths that aren't in $config->urls. All entries in $config->paths always end with a trailing slash. #pw-group-paths #pw-group-runtime * * @property string $templateExtension Default is 'php' #pw-group-template-files * @@ -204,6 +205,8 @@ class Config extends WireData { /** * Get config property * + * #pw-internal + * * @param string $key * @return string|array|int|bool|object|callable|null * @@ -236,6 +239,8 @@ class Config extends WireData { * $url = $config->urls->admin; * ~~~~~ * + * #pw-group-URLs + * * @param string|Wire $for Predefined ProcessWire URLs property or module name * @return string|null * @@ -247,7 +252,7 @@ class Config extends WireData { /** * Get URL for requested resource or module or get all URLs if no argument * - * #pw-internal + * #pw-group-URLs * * @param string|Wire $for Predefined ProcessWire URLs property or module name * @return null|string|Paths @@ -284,6 +289,9 @@ class Config extends WireData { * } * ~~~~~ * + * #pw-group-URLs + * #pw-group-paths + * * @param string $for Named location from `$config->paths` or `$config->urls`, one of: `cache`, `logs`, `files`, `tmp`, `templates`, or your own. * @param string $dir Directory or URL to the location. Should be either a path or URL relative to current installation root (recommended), * or an absolute disk path that resolves somewhere in current installation root. If specifying an absolute path outside of the installation @@ -346,6 +354,8 @@ class Config extends WireData { * - The `$for` argument can be: `cache`, `logs`, `files`, `tmp`, `templates`, or one of your own. Other named locations may * also work, but since they can potentially be used before PW’s “ready” state, they may not be reliable. * + * #pw-group-paths + * * @param string $for Named location from `$config->paths`, one of: `cache`, `logs`, `files`, `tmp`, `templates`, or your own. * @param string $path Path relative to PW installation root (no leading slash), or absolute path if not. * @return self @@ -389,6 +399,8 @@ class Config extends WireData { * $config->setUrl('files', 'https://files.domain.com/'); * } * ~~~~~ + * + * #pw-group-URLs * * @param string $for Named location from `$config->urls`, one of: `cache`, `logs`, `files`, `tmp`, `templates`, or your own. * @param string $url URL relative to PW installation root (no leading slash) or absolute URL if not (optionally including scheme and domain). @@ -414,6 +426,8 @@ class Config extends WireData { * $path = $config->paths->root; * ~~~~~ * + * #pw-group-paths + * * @param string $for Predefined ProcessWire paths property or module class name * @return null|string * @@ -425,7 +439,7 @@ class Config extends WireData { /** * Get disk path for requested resource or module or get all paths if no argument * - * #pw-internal + * #pw-group-paths * * @param string $for Predefined ProcessWire paths property or module name * @return null|string|Paths @@ -487,6 +501,8 @@ class Config extends WireData { * console.log(mySettings.foo); * console.log(mySettings.bar); * ~~~~~ + * + * #pw-group-js * * @param string|array $key Property or array of properties * @param mixed $value @@ -576,6 +592,8 @@ class Config extends WireData { * console.log(mySettings.foo); * console.log(mySettings.bar); * ~~~~~ + * + * #pw-group-js * * @param string $key Name of property to get or set or omit to return all data * @param mixed|null $value Specify value to set or omit (null) to get @@ -781,7 +799,8 @@ class Config extends WireData { * } * ~~~~~ * - * #pw-group-tools + * #pw-group-URLs + * #pw-group-tools * #pw-group-runtime * * @param string|array $match Optionally return URL only if some part matches given string(s) (default='') @@ -837,6 +856,7 @@ class Config extends WireData { * } * ~~~~~ * + * #pw-group-URLs * #pw-group-tools * #pw-group-runtime * diff --git a/wire/core/InputfieldWrapper.php b/wire/core/InputfieldWrapper.php index 498ab02f..a89a7fa7 100644 --- a/wire/core/InputfieldWrapper.php +++ b/wire/core/InputfieldWrapper.php @@ -24,7 +24,7 @@ * @property InputfieldsArray|null $children Inputfield instances that are direct children of this InputfieldWrapper. #pw-group-properties * * @method string renderInputfield(Inputfield $inputfield, $renderValueMode = false) #pw-group-output - * @method Inputfield new($typeName, $name = '', $label = '', array $settings = array()) #pw-group-manipulation + * @method Inputfield new($typeName, $name = '', $label = '', array $settings = []) #pw-group-manipulation * * @property InputfieldAsmSelect $InputfieldAsmSelect * @property InputfieldButton $InputfieldButton diff --git a/wire/core/MarkupQA.php b/wire/core/MarkupQA.php index a296a1a7..9736adfe 100644 --- a/wire/core/MarkupQA.php +++ b/wire/core/MarkupQA.php @@ -766,7 +766,7 @@ class MarkupQA extends Wire { $options = array_merge($defaults, $options); $replaceAlt = ''; // exact text to replace for blank alt attribute, i.e. alt="" $src = ''; - $user = $this->wire('user'); + $user = $this->wire()->user; $attrStrings = explode(' ', $img); // array of strings like "key=value" if($this->verbose()) { @@ -832,6 +832,35 @@ class MarkupQA extends Wire { return; } } + + /* + * @todo potential replacement for 'removeNoAccess' block above + * Regarding: https://github.com/processwire/processwire-issues/issues/1548 + * + // if(($pagefile->page->id != $this->page->id && !$user->hasPermission('page-view', $pagefile->page)) + if($options['removeNoAccess']) { + // if the file resolves to another page that the user doesn't have access to view, + // OR user doesn't have permission to view the field that $pagefile is in, remove image + $page = $pagefile->page; + $field = $pagefile->field; + $removeImage = false; + if(wireInstanceOf($page, 'RepeaterPage')) { + $page = $page->getForPageRoot(); + $field = $page->getForFieldRoot(); + } + if($page->id != $this->page->id && !$page->viewable(false)) { + $this->error("Image on page ($page->id) that user does not have view access to: $src"); + $removeImage = true; + } else if($field && !$page->viewable($field)) { + $this->error("Image on page:field ($page->id:$field) that user does not have view access to: $src"); + $removeImage = true; + } + if($removeImage) { + if($this->page->of()) $value = str_replace($img, '', $value); + return; + } + } + */ if($options['replaceBlankAlt'] && $replaceAlt) { // image has a blank alt tag, meaning, we will auto-populate it with current file description, diff --git a/wire/core/Modules.php b/wire/core/Modules.php index 5ff9b9b7..5d5c955e 100644 --- a/wire/core/Modules.php +++ b/wire/core/Modules.php @@ -321,7 +321,13 @@ class Modules extends WireArray { parent::__construct(); $this->addPath($path); } - + + /** + * Wired to API + * + * #pw-internal + * + */ public function wired() { $this->coreModulesDir = '/' . $this->wire('config')->urls->data('modules'); parent::wired(); diff --git a/wire/core/Page.php b/wire/core/Page.php index b334b73c..068c5342 100644 --- a/wire/core/Page.php +++ b/wire/core/Page.php @@ -8,7 +8,7 @@ * 1. Providing get/set access to the Page's properties * 2. Accessing the related hierarchy of pages (i.e. parents, children, sibling pages) * - * ProcessWire 3.x, Copyright 2021 by Ryan Cramer + * ProcessWire 3.x, Copyright 2022 by Ryan Cramer * https://processwire.com * * #pw-summary Class used by all Page objects in ProcessWire. @@ -27,22 +27,22 @@ * @link http://processwire.com/api/ref/page/ Offical $page Documentation * @link http://processwire.com/api/selectors/ Official Selectors Documentation * - * @property int $id The numbered ID of the current page #pw-group-system + * @property int $id The numbered ID of the current page #pw-group-system #pw-group-common * @property string $name The name assigned to the page, as it appears in the URL #pw-group-system #pw-group-common - * @property string $namePrevious Previous name, if changed. Blank if not. #pw-group-previous + * @property string|null $namePrevious Previous name, if changed. Null or blank string if not. #pw-group-previous * @property string $title The page’s title (headline) text * @property string $path The page’s URL path from the homepage (i.e. /about/staff/ryan/) * @property string $url The page’s URL path from the server's document root * @property array $urls All URLs the page is accessible from, whether current, former and multi-language. #pw-group-urls * @property string $httpUrl Same as $page->url, except includes scheme (http or https) and hostname. * @property Page|string|int $parent The parent Page object or a NullPage if there is no parent. For assignment, you may also use the parent path (string) or id (integer). #pw-group-traversal - * @property Page|null $parentPrevious Previous parent, if parent was changed. #pw-group-previous + * @property Page|null $parentPrevious Previous parent, if parent was changed. Null if not. #pw-group-previous * @property int $parent_id The numbered ID of the parent page or 0 if homepage or not assigned. #pw-group-system * @property int $templates_id The numbered ID of the template usedby this page. #pw-group-system * @property PageArray $parents All the parent pages down to the root (homepage). Returns a PageArray. #pw-group-common #pw-group-traversal * @property Page $rootParent The parent page closest to the homepage (typically used for identifying a section) #pw-group-traversal * @property Template|string $template The Template object this page is using. The template name (string) may also be used for assignment. - * @property Template|null $templatePrevious Previous template, if template was changed. #pw-group-previous + * @property Template|null $templatePrevious Previous template, if template was changed. Null if not. #pw-group-previous * @property Fieldgroup $fields All the Fields assigned to this page (via its template). Returns a Fieldgroup. #pw-advanced * @property int $numChildren The number of children (subpages) this page has, with no exclusions (fast). #pw-group-traversal * @property int $hasChildren The number of visible children this page has. Excludes unpublished, no-access, hidden, etc. #pw-group-traversal @@ -54,20 +54,19 @@ * @property PageArray $siblings All the sibling pages of this page. Returns a PageArray. See also $page->siblings($selector). #pw-group-traversal * @property Page $next This page's next sibling page, or NullPage if it is the last sibling. See also $page->next($pageArray). #pw-group-traversal * @property Page $prev This page's previous sibling page, or NullPage if it is the first sibling. See also $page->prev($pageArray). #pw-group-traversal - * @property int $created Unix timestamp of when the page was created. #pw-group-common #pw-group-date-time #pw-group-system + * @property int $created Unix timestamp of when the page was created. #pw-group-date-time #pw-group-system * @property string $createdStr Date/time when the page was created (formatted date/time string). #pw-group-date-time - * @property int $modified Unix timestamp of when the page was last modified. #pw-group-common #pw-group-date-time #pw-group-system + * @property int $modified Unix timestamp of when the page was last modified. #pw-group-date-time #pw-group-system * @property string $modifiedStr Date/time when the page was last modified (formatted date/time string). #pw-group-date-time - * @property int $published Unix timestamp of when the page was published. #pw-group-common #pw-group-date-time #pw-group-system + * @property int $published Unix timestamp of when the page was published. #pw-group-date-time #pw-group-system * @property string $publishedStr Date/time when the page was published (formatted date/time string). #pw-group-date-time - * @property int $created_users_id ID of created user. #pw-group-system - * @property User|NullPage $createdUser The user that created this page. Returns a User or a NullPage. - * @property int $modified_users_id ID of last modified user. #pw-group-system - * @property User|NullPage $modifiedUser The user that last modified this page. Returns a User or a NullPage. + * @property int $created_users_id ID of created user. #pw-group-system #pw-group-users + * @property User|NullPage $createdUser The user that created this page. Returns a User or a NullPage. #pw-group-users + * @property int $modified_users_id ID of last modified user. #pw-group-system #pw-group-users + * @property User|NullPage $modifiedUser The user that last modified this page. Returns a User or a NullPage. #pw-group-users * @property PagefilesManager $filesManager The object instance that manages files for this page. #pw-group-files * @property string $filesPath Get the disk path to store files for this page, creating it if it does not exist. #pw-group-files * @property string $filesUrl Get the URL to store files for this page, creating it if it does not exist. #pw-group-files - * @property bool $hasFilePath Does this page have a disk path for storing files? #pw-group-files * @property bool $hasFiles Does this page have one or more files in its files path? #pw-group-files * @property bool $outputFormatting Whether output formatting is enabled or not. #pw-advanced * @property int $sort Sort order of this page relative to siblings (applicable when manual sorting is used). #pw-group-system @@ -75,7 +74,7 @@ * @property string $sortfield Field that a page is sorted by relative to its siblings (default="sort", which means drag/drop manual) #pw-group-system * @property null|array _statusCorruptedFields Field names that caused the page to have Page::statusCorrupted status. #pw-internal * @property int $status Page status flags. #pw-group-system #pw-group-status - * @property int|null $statusPrevious Previous status, if status was changed. #pw-group-status #pw-group-previous + * @property int|null $statusPrevious Previous status, if status was changed. Null if not. #pw-group-status #pw-group-previous * @property string statusStr Returns space-separated string of status names active on this page. #pw-group-status * @property Fieldgroup $fieldgroup Fieldgroup used by page template. Shorter alias for $page->template->fieldgroup (same as $page->fields) #pw-advanced * @property string $editUrl URL that this page can be edited at. #pw-group-urls @@ -3525,7 +3524,7 @@ class Page extends WireData implements \Countable, WireMatchable { * $value = $page->edit('field_name'); * ~~~~~ * - * #pw-group-common + * #pw-group-output-rendering * #pw-hooker * * @param string|bool|null $key Name of field, omit to get editor active status, or boolean true to enable editor. diff --git a/wire/core/Pages.php b/wire/core/Pages.php index 4f7ae235..e147c999 100644 --- a/wire/core/Pages.php +++ b/wire/core/Pages.php @@ -15,6 +15,7 @@ * @link http://processwire.com/api/selectors/ Official Selectors Documentation * * #pw-summary Enables loading and manipulation of Page objects, to and from the database. + * #pw-order-groups retrieval,creation,manipulation,advanced,cache,helpers,hooker * * PROPERTIES * ========== @@ -1224,7 +1225,7 @@ class Pages extends Wire { * echo "Path for page 1234 is: $path"; * ~~~~~ * - * #pw-advanced + * #pw-group-advanced * * @param int|Page $id ID of the page you want the path to * @param null|array|Language|int|string $options Specify $options array or Language object, id or name. Allowed options include: @@ -1365,6 +1366,8 @@ class Pages extends Wire { * ] * ~~~~~ * + * #pw-group-retrieval + * * @param string $path Page path optionally including URL segments, language prefix, pagination number * @param array $options * - `useLanguages` (bool): Allow use of multi-language page names? (default=true) @@ -1570,7 +1573,7 @@ class Pages extends Wire { * * You may also pass in the string "id=123", where 123 is the page_id * - * #pw-internal + * #pw-group-cache * * @param int|string|null $id * @return Page|array|null @@ -1596,10 +1599,10 @@ class Pages extends Wire { /** * Remove the given page(s) from the cache, or uncache all by omitting $page argument * - * When no $page argument is given, this method behaves the same as $pages->uncacheAll(). + * When no $page argument is given, this method behaves the same as `$pages->uncacheAll()`. * When any $page argument is given, this does not remove pages from selectorCache. * - * #pw-internal + * #pw-group-cache * * @param Page|PageArray|int|null $page Page to uncache, PageArray of pages to uncache, ID of page to uncache (3.0.153+), or omit to uncache all. * @param array $options Additional options to modify behavior: @@ -1648,7 +1651,7 @@ class Pages extends Wire { * echo "Total value of all products: $" . number_format($total); * ~~~~~ * - * #pw-advanced + * #pw-group-cache * * @param Page $page Optional Page that initiated the uncacheAll * @param array $options Options to modify default behavior: @@ -2030,7 +2033,7 @@ class Pages extends Wire { * * @return PagesNames * - * #pw-advanced + * #pw-group-helpers * */ public function names() { @@ -2071,11 +2074,13 @@ class Pages extends Wire { } /** + * Get the PagesRaw instance + * + * #pw-group-helpers + * * @return PagesRaw * @since 3.0.172 * - * #pw-internal - * */ public function raw() { if(!$this->raw) $this->raw = $this->wire(new PagesRaw($this)); @@ -2083,11 +2088,13 @@ class Pages extends Wire { } /** + * Get the PagesRequest instance + * + * #pw-group-helpers + * * @return PagesRequest * @since 3.0.186 * - * #pw-internal - * */ public function request() { if(!$this->request) $this->request = $this->wire(new PagesRequest($this)); @@ -2095,11 +2102,13 @@ class Pages extends Wire { } /** + * Get the PagesPathFinder instance + * + * #pw-group-helpers + * * @return PagesPathFinder * @since 3.0.186 * - * #pw-internal - * */ public function pathFinder() { if(!$this->pathFinder) $this->pathFinder = $this->wire(new PagesPathFinder($this)); @@ -2227,6 +2236,8 @@ class Pages extends Wire { /** * Hook called when a Page is about to be trashed * + * #pw-hooker + * * @param Page $page * @since 3.0.163 * diff --git a/wire/core/PagesPathFinder.php b/wire/core/PagesPathFinder.php index 7acd65d9..eab33dc5 100644 --- a/wire/core/PagesPathFinder.php +++ b/wire/core/PagesPathFinder.php @@ -3,14 +3,19 @@ /** * ProcessWire Pages Path Finder * - * Enables finding pages by path, optionally including URL segments, - * pagination/page numbers and language prefixes. Build for use by - * the PagesRequest class and ProcessPageView module. + * #pw-summary Enables finding pages by path, optionally with URL segments, pagination numbers, language prefixes, etc. + * #pw-body = + * This is built for use by the PagesRequest class and ProcessPageView module, but can also be useful from the public API. + * The most useful method is the `get()` method which returns a verbose array of information about the given path. + * Methods in this class should be acessed from `$pages->pathFinder()`, i.e. + * ~~~~~ + * $result = $pages->pathFinder()->get('/en/foo/bar/page3'); + * ~~~~~ + * Note that PagesPathFinder does not perform any access control checks, so if using this class then validate access + * afterwards when appropriate. + * #pw-body * - * Note that this does not perform any access control checks, so - * if using this class then validate access afterwards when appropriate. - * - * ProcessWire 3.x, Copyright 2021 by Ryan Cramer + * ProcessWire 3.x, Copyright 2022 by Ryan Cramer * https://processwire.com * * @todo: @@ -148,10 +153,15 @@ class PagesPathFinder extends Wire { * * If the `response` property in the return value is 301 or 302, then the * `redirect` property will be populated with a recommend redirect path. + * + * Please access this method from `$pages->pathFinder()->get('…');` * - * If given a `$path` argument of `/en/foo/bar/page3` on a site that has default - * language homepage segment of `en`, a page living at `/foo/` that accepts - * URL segment `bar` and has pagination enabled, it will return the following: + * Below is an example when given a `$path` argument of `/en/foo/bar/page3` + * on a site that has default language homepage segment of `en`, a page living + * at `/foo/` that accepts URL segment `bar` and has pagination enabled; + * ~~~~~ + * $array = $pages->pathFinder()->get('/en/foo/bar/page3'); + * ~~~~~ * ~~~~~ * [ * 'request' => '/en/foo/bar/page3', @@ -213,6 +223,7 @@ class PagesPathFinder extends Wire { * - `verbose` (bool): Return verbose array of information? (default=true) * If false, some optional information will be omitted in return value. * @return array + * @see PagesPathFinder::getPage() * */ public function get($path, array $options = array()) { @@ -242,12 +253,17 @@ class PagesPathFinder extends Wire { /** * Given a path, get a Page object or NullPage if not found * - * Sets a `_pagePathFinder` property to the returned Page, which is an associative - * array containing the same result array returned by the get() method. + * This method is like the `get()` method except that it returns a `Page` + * object rather than an array. It sets a `_pagePathFinder` property to the + * returned Page, which is an associative array containing the same result + * array returned by the `get()` method. + * + * Please access this method from `$pages->pathFinder()->getPage('…');` * * @param string $path * @param array $options * @return NullPage|Page + * @see PagesPathFinder::get() * */ public function getPage($path, array $options = array()) { @@ -1479,6 +1495,8 @@ class PagesPathFinder extends Wire { /** * Get default options * + * #pw-internal + * * @return array * */ @@ -1541,6 +1559,10 @@ class PagesPathFinder extends Wire { } /** + * Get PagesPathFinderTests instance + * + * #pw-internal + * * @return PagesPathFinderTests * */ @@ -1698,6 +1720,8 @@ class PagesPathFinder extends Wire { /** * Get homepage name segments used for each language, indexed by language id + * + * #pw-internal * * @return array * @@ -1757,6 +1781,8 @@ class PagesPathFinder extends Wire { /** * Is given segment a language segment? Returns language ID if yes, false if no * + * #pw-internal + * * @param string $segment * @return false|int * diff --git a/wire/core/PagesRaw.php b/wire/core/PagesRaw.php index fcc8ccea..9d2ef1c9 100644 --- a/wire/core/PagesRaw.php +++ b/wire/core/PagesRaw.php @@ -84,8 +84,6 @@ class PagesRaw extends Wire { * This can only be used for native 'pages' table columns, * i.e. id, name, templates_id, status, parent_id, etc. * - * #pw-internal - * * @param int|array $pageId Page ID or array of page IDs * @param string|array $col Column name you want to get * @return int|string|array|null Returns column value or array of column values if $pageId was an array. @@ -150,8 +148,6 @@ class PagesRaw extends Wire { * This can only be used for native 'pages' table columns, * i.e. id, name, templates_id, status, parent_id, etc. * - * #pw-internal - * * @param int|array $pageId Page ID or array of page IDs * @param array|string $cols Names of columns to get or omit to get all columns * @param array $options diff --git a/wire/core/PagesRequest.php b/wire/core/PagesRequest.php index 57e5b2d1..35f33d48 100644 --- a/wire/core/PagesRequest.php +++ b/wire/core/PagesRequest.php @@ -3,9 +3,15 @@ /** * ProcessWire Pages Request * - * Identifies page from current request URL and loads it + * #pw-summary Methods for identifying and loading page from current request URL. + * #pw-body = + * Methods in this class should be accessed from `$pages->request()`, i.e. + * ~~~~~ + * $page = $pages->request()->getPage(); + * ~~~~~ + * #pw-body * - * ProcessWire 3.x, Copyright 2021 by Ryan Cramer + * ProcessWire 3.x, Copyright 2022 by Ryan Cramer * https://processwire.com * * @method Page|NullPage getPage() diff --git a/wire/core/Paths.php b/wire/core/Paths.php index 4fe5fd89..5e505015 100644 --- a/wire/core/Paths.php +++ b/wire/core/Paths.php @@ -8,7 +8,7 @@ * #pw-summary-paths-only These properties are only useful when accessed from `$config->paths` as they are not HTTP accessible as URLs. * #pw-summary-urls-only These properties apply only to the `$urls` or `$config->urls`. Do not use them with `$config->paths`. * #pw-summary-pagination These properties apply only to the `$urls` or `$config->urls` and only when pagination is active for the current request. - * #pw-var $var + * #pw-var $urls * * #pw-body = * The Paths class is used by `$config->paths` and `$config->urls` (or just `$urls`). The `$config->paths` refers to server disk paths @@ -47,13 +47,14 @@ * In the examples on this page, you can replace the `$urls` variable with `$config->paths` if you need to get the server path * instead of a URL. As indicated earlier, `$urls` can aso be accessed at the more verbose `$config->urls` if you prefer. * - * > Please note in the property/method descriptions below that the placeholder `$var` refers to either `$config->paths` or - * `$config->urls` (or the shorter alias `$urls`). So `$var->files` (for example) refers to either `$config->paths->files` - * or `$config->urls->files` (or the shorter alias `$urls->files`). + * > Please note in the property/method descriptions below that use the placeholder `$urls` refers to either `$config->paths` or + * `$config->urls` (or the shorter alias `$urls`). So `$urls->files` (for example) in the definitions below can refer to either + * `$config->paths->files` or `$config->urls->files` (or the shorter alias `$urls->files`). We use `$urls` here because it’s + * just the shortest option for example purposes. * * #pw-body * - * ProcessWire 3.x, Copyright 2020 by Ryan Cramer + * ProcessWire 3.x, Copyright 2022 by Ryan Cramer * https://processwire.com * * This file is licensed under the MIT license diff --git a/wire/core/Permissions.php b/wire/core/Permissions.php index 7837ce1d..ba21216a 100644 --- a/wire/core/Permissions.php +++ b/wire/core/Permissions.php @@ -9,7 +9,7 @@ * @method Permission|NullPage get($selector) Return permission by given name, numeric ID or a selector string. * @method array getOptionalPermissions($omitInstalled = true) #pw-internal * @method array saveReady(Page $page) Hook called just before a Permission is saved #pw-hooker - * @method void saved(Page $page, array $changes = array(), $values = array()) #pw-hooker + * @method void saved(Page $page, array $changes = array(), $values = []) #pw-hooker * @method void added(Page $page) Hook called just after a Permission is added #pw-hooker * @method void deleteReady(Page $page) Hook called before a Permission is deleted #pw-hooker * @method void deleted(Page $page) Hook called after a permission is deleted #pw-hooker diff --git a/wire/core/Sanitizer.php b/wire/core/Sanitizer.php index 6a22ca78..ba222040 100644 --- a/wire/core/Sanitizer.php +++ b/wire/core/Sanitizer.php @@ -90,7 +90,7 @@ * * #pw-body * - * ProcessWire 3.x, Copyright 2019 by Ryan Cramer + * ProcessWire 3.x, Copyright 2022 by Ryan Cramer * https://processwire.com * * @link https://processwire.com/api/variables/sanitizer/ Offical $sanitizer API variable Documentation @@ -544,6 +544,8 @@ class Sanitizer extends Wire { /** * Sanitize to an ASCII-only HTML attribute name * + * #pw-group-strings + * * @param string $value * @param int $maxLength * @return string @@ -633,6 +635,8 @@ class Sanitizer extends Wire { * echo $sanitizer->fieldSubfield('foo bar baz'); // outputs: foo_bar_baz * ~~~~~~ * + * #pw-group-strings + * * @param string $value Value to sanitize * @param int $limit Max allowed quantity of subfields, or use -1 for any quantity (default=1). * @return string @@ -1258,6 +1262,7 @@ class Sanitizer extends Wire { * Sanitize string to contain only ASCII digits (0-9) * * #pw-group-strings + * #pw-group-numbers * * @param string $value Value to sanitize * @param int $maxLength Maximum length of returned value (default=1024) @@ -1735,7 +1740,8 @@ class Sanitizer extends Wire { * Convert a string containing markup or entities to be plain text * * This is one implementation but there is also a better one that you may prefer with the - * `WireTextTools::markupToText()` method: + * `WireTextTools::markupToText()` method. Try both to determine which suits your needs + * best: * * ~~~~~ * $markup = 'a bunch of HTML here'; @@ -1753,7 +1759,7 @@ class Sanitizer extends Wire { * - `entities` (bool): Entity encode returned value? (default=false). * - `trim` (string): Character(s) to trim from beginning and end of value (default=" -,:;|\n\t"). * @return string Converted string of text - * @see WireTextTools::markupToText() for different though likely better (for most cases) implementation. + * @see WireTextTools::markupToText(), Sanitizer::markupToLine() * */ public function markupToText($value, array $options = array()) { @@ -2274,6 +2280,8 @@ class Sanitizer extends Wire { * *Note: If double quotes are used in your selector value, this method will convert them to matching * parenthesis, i.e. `+"phrase"` gets converted to `+(phrase)`.* * + * #pw-group-strings + * * @param string|array $value * @param array $options See options for Sanitizer::selectorValue() method * @return bool|mixed|string @@ -3373,6 +3381,8 @@ class Sanitizer extends Wire { * 'more' => '…' * ]); * ~~~~~~~ + * + * #pw-group-strings * * @param string $str String to truncate * @param int|array $maxLength Maximum length of returned string, or specify $options array here. @@ -3404,7 +3414,9 @@ class Sanitizer extends Wire { * Truncate string to given maximum length without breaking words and with no added visible extras * * This is a shortcut to the truncate() sanitizer, sanitizing to nearest word with the `more` option - * disabled and the `collapseLinesWith` set to 1 space (rather than ellipsis). + * disabled and the `collapseLinesWith` set to 1 space (rather than ellipsis). + * + * #pw-group-strings * * @param string $str String to truncate * @param int|array $maxLength Maximum allowed length in characters, or substitute $options argument here @@ -4343,6 +4355,8 @@ class Sanitizer extends Wire { * delimited/csv strings to arrays. Meaning, a delimited string would simply become an array * with the first item being that delimited string. * + * #pw-group-arrays + * * @param mixed $value * @param array $options * - `maxItems` (int): Maximum items allowed in each array (default=0, which means no limit) @@ -5113,6 +5127,8 @@ class Sanitizer extends Wire { /** * Get all sanitizer method names and optionally types they return * + * #pw-group-other + * * @param bool $getReturnTypes Get array where method names are keys and values are return types? * @return array * @since 3.0.165 @@ -5125,6 +5141,9 @@ class Sanitizer extends Wire { /** * Get instance of WireTextTools * + * #pw-group-strings + * #pw-group-other + * * @return WireTextTools * @since 3.0.101 * @@ -5411,6 +5430,8 @@ class Sanitizer extends Wire { * $value = $sanitizer->sanitize($value, 'text128,entities'); * ~~~~~ * + * #pw-group-other + * * @param mixed $value * @param string $method Method name "method", or combined method name(s) "method1,method2,method3" * @return string|int|array|float|null diff --git a/wire/core/Session.php b/wire/core/Session.php index b5fb697b..de10091d 100644 --- a/wire/core/Session.php +++ b/wire/core/Session.php @@ -6,13 +6,14 @@ * Start a session with login/logout capability * * #pw-summary Maintains sessions in ProcessWire, authentication, persistent variables, notices and redirects. + * #pw-order-groups redirects,get,set,remove,info,notices,authentication,advanced,hooker * * This should be used instead of the $_SESSION superglobal, though the $_SESSION superglobal can still be * used, but it's in a different namespace than this. A value set in $_SESSION won't appear in $session * and likewise a value set in $session won't appear in $_SESSION. It's also good to use this class * over the $_SESSION superglobal just in case we ever need to replace PHP's session handling in the future. * - * ProcessWire 3.x, Copyright 2019 by Ryan Cramer + * ProcessWire 3.x, Copyright 2022 by Ryan Cramer * https://processwire.com * * @see https://processwire.com/api/ref/session/ Session documentation @@ -220,6 +221,8 @@ class Session extends Wire implements \IteratorAggregate { /** * Are session cookie(s) present? * + * #pw-group-info + * * @param bool $checkLogin Specify true to check instead for challenge cookie (which indicates login may be active). * @return bool Returns true if session cookie present, false if not. * @@ -241,6 +244,8 @@ class Session extends Wire implements \IteratorAggregate { * This only indicates the user was likely logged in at some point, and may not indicate an active login. * This method is more self describing version of `$session->hasCookie(true);` * + * #pw-group-info + * * @return bool * @since 3.0.175 * @@ -500,6 +505,8 @@ class Session extends Wire implements \IteratorAggregate { * $firstName = $session->firstName; * ~~~~~ * + * #pw-group-get + * * @param string|object $key Name of session variable to retrieve (or object if using namespaces) * @param string $_key Name of session variable to get if first argument is namespace, omit otherwise. * @return mixed Returns value of seession variable, or NULL if not found. @@ -534,6 +541,8 @@ class Session extends Wire implements \IteratorAggregate { * This is the same as get() except that it lets you specify a fallback return value in the method call. * For a namespace version use `Session::getValFor()` instead. * + * #pw-group-get + * * @param string $key Name of session variable to retrieve. * @param mixed $val Fallback value to return if session does not have it. * @return mixed Returns value of seession variable, or NULL if not found. @@ -548,6 +557,8 @@ class Session extends Wire implements \IteratorAggregate { /** * Get all session variables in an associative array + * + * #pw-group-get * * @param object|string $ns Optional namespace * @return array @@ -565,6 +576,8 @@ class Session extends Wire implements \IteratorAggregate { /** * Get all session variables for given namespace and return associative array * + * #pw-group-get + * * @param string|Wire $ns * @return array * @since 3.0.141 Method added for consistency, but any version can do this with $session->getFor($ns, ''); @@ -597,6 +610,8 @@ class Session extends Wire implements \IteratorAggregate { * $firstName = $session->firstName; * ~~~~~ * + * #pw-group-set + * * @param string|object $key Name of session variable to set (or object for namespace) * @param string|mixed $value Value to set (or name of variable, if first argument is namespace) * @param mixed $_value Value to set if first argument is namespace. Omit otherwise. @@ -622,6 +637,8 @@ class Session extends Wire implements \IteratorAggregate { * // Retrieve namespaced session value * $firstName = $session->getFor($this, 'firstName'); * ~~~~~ + * + * #pw-group-get * * @param string|object $ns Namespace string or object * @param string $key Specify variable name to retrieve, or blank string to return all variables in the namespace. @@ -641,6 +658,8 @@ class Session extends Wire implements \IteratorAggregate { * * This is the same as get() except that it lets you specify a fallback return value in the method call. * For a namespace version use `Session::getValFor()` instead. + * + * #pw-group-get * * @param string|object $ns Namespace string or object * @param string $key Specify variable name to retrieve @@ -664,6 +683,8 @@ class Session extends Wire implements \IteratorAggregate { * // Set a session value for a namespace * $session->setFor($this, 'firstName', 'Bob'); * ~~~~~ + * + * #pw-group-set * * @param string|object $ns Namespace string or object. * @param string $key Name of session variable you want to set. @@ -693,6 +714,8 @@ class Session extends Wire implements \IteratorAggregate { * // Unset all session vars in a namespace * $session->remove($this, true); * ~~~~~ + * + * #pw-group-remove * * @param string|object $key Name of session variable you want to remove (or namespace string/object) * @param string|bool|null $_key Omit this argument unless first argument is a namespace. Otherwise specify one of: @@ -725,6 +748,8 @@ class Session extends Wire implements \IteratorAggregate { /** * Unset a session variable within a namespace * + * #pw-group-remove + * * @param string|object $ns Namespace * @param string $key Provide name of variable to remove, or boolean true to remove all in namespace. * @return $this @@ -737,6 +762,8 @@ class Session extends Wire implements \IteratorAggregate { /** * Remove all session variables in given namespace * + * #pw-group-remove + * * @param string|object $ns * @return $this * @@ -749,6 +776,8 @@ class Session extends Wire implements \IteratorAggregate { /** * Given a namespace object or string, return the namespace string * + * #pw-group-retrieval + * * @param object|string $ns * @return string * @throws WireException if given invalid namespace type @@ -798,6 +827,8 @@ class Session extends Wire implements \IteratorAggregate { * } * ~~~~~ * + * #pw-internal + * * @return \ArrayObject * */ @@ -814,6 +845,8 @@ class Session extends Wire implements \IteratorAggregate { * $ip = $session->getIP(); * echo $ip; // outputs 111.222.333.444 * ~~~~~ + * + * #pw-group-info * * @param bool $int Return as a long integer? (default=false) * - IPv6 addresses cannot be represented as an integer, so please note that using this int option makes it return a CRC32 @@ -904,6 +937,7 @@ class Session extends Wire implements \IteratorAggregate { return $ip; } + /** * Login a user with the given name and password * @@ -1291,6 +1325,8 @@ class Session extends Wire implements \IteratorAggregate { * $session->redirect('/'); * ~~~~~ * + * #pw-group-redirects + * * @param string $url URL to redirect to * @param bool|int $status One of the following (or omit for 301): * - `true` (bool): Permanent redirect (same as 301). @@ -1363,7 +1399,9 @@ class Session extends Wire implements \IteratorAggregate { * Perform a temporary redirect * * This is an alias of `$session->redirect($url, false);` that sends only the - * location header, which translates to a 302 redirect. + * location header, which translates to a 302 redirect. + * + * #pw-group-redirects * * @param string $url * @param int $status One of the following HTTP status codes, or omit for 302 (added 3.0.192): @@ -1589,6 +1627,8 @@ class Session extends Wire implements \IteratorAggregate { * ); * ~~~~~ * + * #pw-group-advanced + * * @return array Array of arrays containing history entries. * */ @@ -1629,6 +1669,8 @@ class Session extends Wire implements \IteratorAggregate { * } * ~~~~ * + * #pw-group-advanced + * * @return SessionCSRF * @see SessionCSRF::renderInput(), SessionCSRF::validate(), SessionCSRF::hasValidToken() * diff --git a/wire/core/User.php b/wire/core/User.php index 9177dc61..f35b64e0 100644 --- a/wire/core/User.php +++ b/wire/core/User.php @@ -5,7 +5,7 @@ * * A type of Page used for storing an individual User * - * ProcessWire 3.x, Copyright 2016 by Ryan Cramer + * ProcessWire 3.x, Copyright 2022 by Ryan Cramer * https://processwire.com * * #pw-summary The $user API variable is a type of page representing the current user, and the User class is Page type used for all users. @@ -14,9 +14,9 @@ * * @property string $email Get or set email address for this user. * @property string|Password $pass Set the user’s password. - * @property PageArray $roles Get the roles this user has. - * @property Language $language User language, applicable only if LanguageSupport installed. - * @property string $admin_theme Admin theme class name + * @property PageArray $roles Get the roles this user has. #pw-group-common #pw-group-access + * @property Language $language User language, applicable only if LanguageSupport installed. #pw-group-languages + * @property string $admin_theme Admin theme class name (when applicable). * * @method bool hasPagePermission($name, Page $page = null) #pw-internal * @method bool hasTemplatePermission($name, $template) #pw-internal @@ -53,7 +53,7 @@ class User extends Page { /** * Wired to API * - * @throws WireException + * #pw-internal * */ public function wired() { @@ -66,6 +66,8 @@ class User extends Page { /** * Does this user have the given Role? * + * #pw-group-access + * * ~~~~~ * if($user->hasRole('editor')) { * // user has the editor role @@ -119,6 +121,8 @@ class User extends Page { * $user->addRole('editor'); * $user->save(); * ~~~~~ + * + * #pw-group-access * * @param string|int|Role $role May be Role name, object, or ID. * @return bool Returns false if role not recognized, true otherwise @@ -143,6 +147,8 @@ class User extends Page { * $user->removeRole('editor'); * $user->save(); * ~~~~~ + * + * #pw-group-access * * @param string|int|Role $role May be Role name, object or ID. * @return bool false if role not recognized, true otherwise @@ -172,6 +178,8 @@ class User extends Page { * } * ~~~~~ * + * #pw-group-access + * * @param string|Permission $name Permission name, object or id. * @param Page|Template|bool|string $context Page or Template... * - or specify boolean true to return if user has permission OR if it was added at any template @@ -215,7 +223,7 @@ class User extends Page { * You use the PagePermissions module by calling the editable(), addable(), etc., functions on a page object. * The PagePermissions does use this function for some of it's checking. * - * #pw-hooker + * #pw-group-access * * @param string|Permission * @param Page $page Optional page to check against @@ -303,7 +311,7 @@ class User extends Page { /** * Does this user have the given permission on the given template? * - * #pw-hooker + * #pw-group-access * * @param string|Permission $name Permission name * @param Template|int|string $template Template object, name or ID @@ -380,6 +388,8 @@ class User extends Page { * // Get all permissions the user has for $page * $permissions = $user->getPermissions($page); * ~~~~~ + * + * #pw-group-access * * @param Page $page Optional page to check against * @return PageArray of Permission objects @@ -409,7 +419,9 @@ class User extends Page { /** * Does this user have the superuser role? * - * Same as calling `$user->roles->has('name=superuser');` but potentially faster. + * Same as calling `$user->roles->has('name=superuser');` but potentially faster. + * + * #pw-group-access * * @return bool * @@ -440,7 +452,9 @@ class User extends Page { } /** - * Is this the non-logged in guest user? + * Is this the non-logged in guest user? + * + * #pw-group-access * * @return bool * @@ -453,7 +467,9 @@ class User extends Page { * Is the current $user logged in and the same as this user? * * When this method returns true, it means the current $user (API variable) is - * this user and that they are logged in. + * this user and that they are logged in. + * + * #pw-group-access * * @return bool * @@ -471,6 +487,8 @@ class User extends Page { * - Sets the language without tracking it as a change to the user. * - If language support is not installed this method silently does nothing. * + * #pw-group-languages + * * @param Language|string|int $language Language object, name, or ID * @return self * @throws WireException if language support is installed and given an invalid/unknown language @@ -571,6 +589,8 @@ class User extends Page { * be initialized (hooks not added, etc.). To retrieve an initialized instance, you can get it * from `$user->tfa_type` rather than calling this method. * + * #pw-group-access + * * @param bool $getInstance Get Tfa module instance when available? (default=false) * @return bool|string|Tfa * @since 3.0.162 @@ -583,6 +603,8 @@ class User extends Page { /** * Hook called when field has changed * + * #pw-internal + * * @param string $what * @param mixed $old * @param mixed $new diff --git a/wire/core/WireDatabasePDO.php b/wire/core/WireDatabasePDO.php index 4fdc883a..b4c556e6 100644 --- a/wire/core/WireDatabasePDO.php +++ b/wire/core/WireDatabasePDO.php @@ -5,7 +5,7 @@ * * Serves as a wrapper to PHP’s PDO class * - * ProcessWire 3.x, Copyright 2021 by Ryan Cramer + * ProcessWire 3.x, Copyright 2022 by Ryan Cramer * https://processwire.com * */ @@ -14,9 +14,38 @@ * Database class provides a layer on top of mysqli * * #pw-summary All database operations in ProcessWire are performed via this PDO-style database class. + * #pw-order-groups queries,transactions,schema,info,sanitization,connection + * #pw-var-database + * #pw-body = + * ProcessWire creates the database connection automatically at boot and this is available from the `$database` API variable. + * If you want to create a new connection on your own, choose either option A or B below: + * ~~~~~ + * // The following are required to construct a WireDatabasePDO + * $dsn = 'mysql:dbname=mydb;host=myhost;port=3306'; + * $username = 'username'; + * $password = 'password'; + * $driver_options = []; // optional + * + * // Construct option A + * $db = new WireDatabasePDO($dsn, $username, $password, $driver_options); + * + * // Construct option B + * $db = new WireDatabasePDO([ + * 'dsn' => $dsn, + * 'user' => $username, + * 'pass' => $password, + * 'options' => $driver_options, // optional + * 'reader' => [ // optional + * 'dsn' => '…', + * … + * ], + * … + * ]); + * ~~~~~ + * #pw-body * * @method void unknownColumnError($column) #pw-internal - * @property bool $debugMode + * @property bool $debugMode #pw-internal * */ class WireDatabasePDO extends Wire implements WireDatabase { @@ -205,15 +234,28 @@ class WireDatabasePDO extends Wire implements WireDatabase { protected $stopwordCache = null; /** - * Create a new PDO instance from ProcessWire $config API variable + * Create a new connection instance from given ProcessWire $config API variable and return it * * If you need to make other PDO connections, just instantiate a new WireDatabasePDO (or native PDO) * rather than calling this getInstance method. + * + * The following properties are pulled from given `$config` (see `Config` class for details): + * + * - `$config->dbUser` + * - `$config->dbPass` + * - `$config->dbName` + * - `$config->dbHost` + * - `$config->dbPort` + * - `$config->dbSocket` + * - `$config->dbCharset` + * - `$config->dbOptions` + * - `$config->dbReader` + * - `$config->dbInitCommand` + * - `$config->debug` * * #pw-internal * * @param Config $config - * * @return WireDatabasePDO * @throws WireException * @@ -438,7 +480,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { * * If connection is lost, this will restore it automatically. * - * #pw-group-PDO + * #pw-group-connection * * @param string|\PDOStatement|null SQL, statement, or statement type (reader or primary) (3.0.175+) * @@ -605,7 +647,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Fetch the SQLSTATE associated with the last operation on the statement handle * - * #pw-group-PDO + * #pw-group-connection * * @return string * @link http://php.net/manual/en/pdostatement.errorcode.php @@ -618,7 +660,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Fetch extended error information associated with the last operation on the database handle * - * #pw-group-PDO + * #pw-group-connection * * @return array * @link http://php.net/manual/en/pdo.errorinfo.php @@ -631,7 +673,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Retrieve a database connection attribute * - * #pw-group-PDO + * #pw-group-connection * * @param int $attribute * @return mixed @@ -645,7 +687,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Sets an attribute on the database handle * - * #pw-group-PDO + * #pw-group-connection * * @param int $attribute * @param mixed $value @@ -660,7 +702,8 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Returns the ID of the last inserted row or sequence value * - * #pw-group-PDO + * #pw-group-queries + * #pw-group-info * * @param string|null $name * @return string @@ -674,7 +717,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Executes an SQL statement, returning a result set as a PDOStatement object * - * #pw-group-PDO + * #pw-group-queries * * @param string $statement * @param string $note @@ -691,7 +734,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Initiates a transaction * - * #pw-group-PDO + * #pw-group-transactions * * @return bool * @link http://php.net/manual/en/pdo.begintransaction.php @@ -705,7 +748,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Checks if inside a transaction * - * #pw-group-PDO + * #pw-group-transactions * * @return bool * @link http://php.net/manual/en/pdo.intransaction.php @@ -718,7 +761,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Are transactions available with current DB engine (or table)? * - * #pw-group-PDO + * #pw-group-transactions * * @param string $table Optionally specify a table to specifically check to that table * @return bool @@ -746,7 +789,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { * * Returns combined result of supportsTransaction() === true and inTransaction() === false. * - * #pw-group-PDO + * #pw-group-transactions * * @param string $table Optional table that transaction will be for * @return bool @@ -760,7 +803,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Commits a transaction * - * #pw-group-PDO + * #pw-group-transactions * * @return bool * @link http://php.net/manual/en/pdo.commit.php @@ -774,7 +817,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Rolls back a transaction * - * #pw-group-PDO + * #pw-group-transactions * * @return bool * @link http://php.net/manual/en/pdo.rollback.php @@ -805,7 +848,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Prepare an SQL statement for accepting bound parameters * - * #pw-group-PDO + * #pw-group-queries * * @param string $statement * @param array|string|bool $driver_options Optionally specify one of the following: @@ -844,7 +887,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { * * If given a PDOStatement, this method behaves the same as the execute() method. * - * #pw-group-PDO + * #pw-group-queries * * @param string|\PDOStatement $statement * @param string $note @@ -879,7 +922,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { * $database->execute($query); * ~~~~~ * - * #pw-group-custom + * #pw-group-queries * * @param \PDOStatement $query * @param bool $throw Whether or not to throw exception on query error (default=true) @@ -973,7 +1016,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { * * Note that this method caches its result unless you specify boolean false for the $allowCache argument. * - * #pw-group-custom + * #pw-group-schema * * @param bool $allowCache Specify false if you don't want result to be cached or pulled from cache (default=true) * @return array Returns array of table names @@ -998,6 +1041,8 @@ class WireDatabasePDO extends Wire implements WireDatabase { * is, and any extra information, such as whether it is auto_increment. The verbose option * also makes the return value indexed by column name (associative array). * + * #pw-group-schema + * * @param string $table Table name or or `table.column` to get for specific column (when combined with verbose=true) * @param bool|int|string $verbose Include array of verbose information for each? (default=false) * - Omit or false (bool) to just get column names. @@ -1055,6 +1100,8 @@ class WireDatabasePDO extends Wire implements WireDatabase { * * By default it returns an array of index names. Specify true for the verbose option to get * index `name`, `type` and `columns` (array) for each index. + * + * #pw-group-schema * * @param string $table Name of table to get indexes for or `table.index` (usually combined with verbose option). * @param bool|int|string $verbose Include array of verbose information for each? (default=false) @@ -1108,6 +1155,8 @@ class WireDatabasePDO extends Wire implements WireDatabase { * information about the primary key. If you specify integer `2` then it returns an array of * raw MySQL SHOW INDEX information. * + * #pw-group-schema + * * @param string $table * @param bool|int $verbose Get array of info rather than column(s) string? (default=false) * @return string|array @@ -1129,7 +1178,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Does the given table exist in this database? * - * #pw-group-custom + * #pw-group-schema * * @param string $table * @return bool @@ -1165,7 +1214,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { * } * ~~~~~ * - * #pw-group-custom + * #pw-group-schema * * @param string $table Specify table name (or table and column name in format "table.column"). * @param string $column Specify column name (or omit or blank string if already specified in $table argument). @@ -1216,6 +1265,8 @@ class WireDatabasePDO extends Wire implements WireDatabase { * } * ~~~~ * + * #pw-group-schema + * * @param string $table * @param string $indexName * @param bool $getInfo Return arrays of index information rather than boolean true? (default=false) @@ -1253,6 +1304,8 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Rename table columns without changing type * + * #pw-group-schema + * * @param string $table * @param array $columns Associative array with one or more of `[ 'old_name' => 'new_name' ]` * @return int Number of columns renamed @@ -1294,6 +1347,8 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Rename a table column without changing type * + * #pw-group-schema + * * @param string $table * @param string $oldName * @param string $newName @@ -1310,7 +1365,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Is the given string a database comparison operator? * - * #pw-group-custom + * #pw-group-info * * ~~~~~ * if($database->isOperator('>=')) { @@ -1359,6 +1414,8 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Is given word a fulltext stopword for database engine? * + * #pw-group-info + * * @param string $word * @param string $engine DB engine ('myisam' or 'innodb') or omit for current engine * @return bool @@ -1375,6 +1432,8 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Get all fulltext stopwords for database engine * + * #pw-group-info + * * @param string $engine Specify DB engine of "myisam" or "innodb" or omit for current DB engine * @param bool $flip Return flipped array where stopwords are array keys rather than values? for isset() use (default=false) * @return array @@ -1449,6 +1508,8 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Sanitize comparison operator * + * #pw-group-sanitization + * * @param string $operator * @param bool|int|null $operatorType Specify a WireDatabasePDO::operatorType* constant (default=operatorTypeComparison) * @param string $default Default/fallback operator to return if given one is not valid (default='=') @@ -1491,7 +1552,6 @@ class WireDatabasePDO extends Wire implements WireDatabase { * Quote and escape a string value * * #pw-group-sanitization - * #pw-group-PDO * * @param string $str * @return string @@ -1547,7 +1607,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Close the PDO connection * - * #pw-group-custom + * #pw-group-connection * */ public function closeConnection() { @@ -1567,7 +1627,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { * echo $value; // outputs "4" * ~~~~~ * - * #pw-group-custom + * #pw-group-info * * @param string $name Name of MySQL variable you want to retrieve * @param bool $cache Allow use of cached values? (default=true) @@ -1600,6 +1660,8 @@ class WireDatabasePDO extends Wire implements WireDatabase { * - 5.7.23 * - 10.1.34-MariaDB * + * #pw-group-info + * * @return string * @param bool $getNumberOnly Get only version number, exclude any vendor specific suffixes? (default=false) 3.0.185+ * @since 3.0.166 @@ -1614,6 +1676,8 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Get server type, one of MySQL, MariDB, Percona, etc. * + * #pw-group-info + * * @return string * @since 3.0.185 * @@ -1638,6 +1702,8 @@ class WireDatabasePDO extends Wire implements WireDatabase { * * Returns one of 'ICU' (MySQL 8.0.4+) or 'HenrySpencer' (earlier versions and MariaDB) * + * #pw-group-info + * * @return string * @since 3.0.166 * @todo this will need to be updated when/if MariaDB adds version that uses ICU engine @@ -1654,7 +1720,9 @@ class WireDatabasePDO extends Wire implements WireDatabase { } /** - * Get current database engine (lowercase) + * Get current database engine (lowercase) + * + * #pw-group-schema * * @return string * @since 3.0.160 @@ -1667,6 +1735,8 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Get current database charset (lowercase) * + * #pw-group-schema + * * @return string * @since 3.0.160 * @@ -1707,7 +1777,7 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Get max length allowed for a fully indexed varchar column in ProcessWire * - * #pw-internal + * #pw-group-schema * * @return int * @@ -1728,6 +1798,8 @@ class WireDatabasePDO extends Wire implements WireDatabase { * Returns true if reader is configured and allowed * Returns false if reader is not configured or not allowed * + * #pw-internal + * * @param bool $allow * @return bool * @since 3.0.175 @@ -1818,6 +1890,8 @@ class WireDatabasePDO extends Wire implements WireDatabase { /** * Get current date/time ISO-8601 string or UNIX timestamp according to database * + * #pw-group-info + * * @param bool $getTimestamp Get unix timestamp rather than ISO-8601 string? (default=false) * @return string|int * @since 3.0.183 diff --git a/wire/core/WireFileTools.php b/wire/core/WireFileTools.php index 12de13c8..4a5514a8 100644 --- a/wire/core/WireFileTools.php +++ b/wire/core/WireFileTools.php @@ -4,6 +4,7 @@ * ProcessWire File Tools ($files API variable) * * #pw-summary Helpers for working with files and directories. + * #pw-var-files * * ProcessWire 3.x, Copyright 2022 by Ryan Cramer * https://processwire.com @@ -48,6 +49,8 @@ class WireFileTools extends Wire { * } * ~~~~~ * + * #pw-group-manipulation + * * @param string $path Directory you want to create * @param bool|string $recursive If set to true, all directories will be created as needed to reach the end. * @param string|null|bool $chmod Optional mode to set directory to (default: $config->chmodDir), format must be a string i.e. "0755" @@ -95,6 +98,8 @@ class WireFileTools extends Wire { * $files->rmdir($pathname, true, [ 'limitPath' => $config->paths->assets ]); * ~~~~~ * + * #pw-group-manipulation + * * @param string $path Path/directory you want to remove * @param bool $recursive If set to true, all files and directories in $path will be recursively removed as well (default=false). * @param array|bool|string $options Optional settings to adjust behavior or (bool|string) for limitPath option: @@ -157,6 +162,8 @@ class WireFileTools extends Wire { * $files->chmod($config->paths->cache . 'foo-bar/', true); * ~~~~~ * + * #pw-group-manipulation + * * @param string $path Path or file that you want to adjust mode for (may be a path/directory or a filename). * @param bool|string $recursive If set to true, all files and directories in $path will be recursively set as well (default=false). * @param string|null|bool $chmod If you want to set the mode to something other than ProcessWire's chmodFile/chmodDir settings, @@ -228,6 +235,8 @@ class WireFileTools extends Wire { * $files->copy($copyFrom, $copyTo); * ~~~~~ * + * #pw-group-manipulation + * * @param string $src Path to copy files from, or filename to copy. * @param string $dst Path (or filename) to copy file(s) to. Directory is created if it doesn't already exist. * @param bool|array $options Array of options: @@ -322,6 +331,8 @@ class WireFileTools extends Wire { * - This method will be limited to unlink files only in /site/assets/ if you * specify `true` for the `$limitPath` option (recommended). * + * #pw-group-manipulation + * * @param string $filename * @param string|bool $limitPath Limit only to files within some starting path? (default=false) * - Boolean true to limit unlink operations to somewhere within /site/assets/ (only known always writable path). @@ -356,7 +367,9 @@ class WireFileTools extends Wire { /** * Rename a file or directory and update permissions * - * Note that this method will fail if pathname given by $newName argument already exists. + * Note that this method will fail if pathname given by $newName argument already exists. + * + * #pw-group-manipulation * * @param string $oldName Old pathname, must be full disk path. * @param string $newName New pathname, must be full disk path OR can be basename to assume same path as $oldName. @@ -455,6 +468,8 @@ class WireFileTools extends Wire { * The operation is considered successful so long as the source files were able to be copied to the destination. * If source files cannot be deleted afterwards, the warning is logged, plus a warning notice is also shown when in debug mode. * + * #pw-group-manipulation + * * @param string $oldName Old pathname, must be full disk path. * @param string $newName New pathname, must be full disk path OR can be basename to assume same path as $oldName. * @param array $options See options for rename() method @@ -502,6 +517,8 @@ class WireFileTools extends Wire { * $exists = $files->exists('/path/file.ext', 'readable writable file'); * ~~~~~ * + * #pw-group-retrieval + * * @param string $filename * @param array|string $options Can be specified as array or string: * - `type` (string): Verify it is of type: 'file', 'link', 'dir' (default='') @@ -714,6 +731,8 @@ class WireFileTools extends Wire { /** * Find all files in the given $path recursively, and return a flat array of all found filenames * + * #pw-group-retrieval + * * @param string $path Path to start from (required). * @param array $options Options to affect what is returned (optional): * - `recursive` (int|bool): How many levels of subdirectories this method should descend into beyond the 1 given. @@ -1022,6 +1041,8 @@ class WireFileTools extends Wire { * * This function throws a `WireException` if the file can’t be sent for some reason. Set the `throw` option to * false if you want it to instead return integer 0 when errors occur. + * + * #pw-group-http * * @param string|bool $filename Full path and filename to send or boolean false if provided in `$options[data]`. * @param array $options Optional options to modify default behavior: @@ -1068,6 +1089,8 @@ class WireFileTools extends Wire { * This is the same as PHP’s `file_put_contents()` except that it’s preferable to use this in * ProcessWire because it adjusts the file permissions configured with `$config->chmodFile`. * + * #pw-group-manipulation + * * @param string $filename Filename to write to * @param string|mixed $contents Contents to write to file * @param int $flags Flags to modify behavior: @@ -1096,6 +1119,8 @@ class WireFileTools extends Wire { * it may be preferable to use this in ProcessWire for future cases where the file system may be * abstracted from the installation. * + * #pw-group-retrieval + * * @param string $filename Full path and filename to read * @param int $offset The offset where the reading starts on the original stream. Negative offsets count from the end of the stream. * @param int $maxlen Maximum length of data read. The default is to read until end of file is reached. @@ -1147,6 +1172,8 @@ class WireFileTools extends Wire { * } * ~~~~~ * + * #pw-group-CSV + * * @param string $filename CSV filename to read from * @param array $options * - `header` (bool|array): Indicate whether CSV has header and how it should be used (default=true): @@ -1288,6 +1315,8 @@ class WireFileTools extends Wire { * echo "Color: $row[Color] "; * } * ~~~~~ + * + * #pw-group-CSV * * @param string $filename CSV filename to read from * @param array $options @@ -1761,7 +1790,7 @@ class WireFileTools extends Wire { /** * Compile and include_once() the given file * - * #pw-group-internal + * #pw-internal * * @param string $file File to compile and include * @param array $options Optional associative array of the following: diff --git a/wire/core/WireInput.php b/wire/core/WireInput.php index fdfd7af8..e047df04 100644 --- a/wire/core/WireInput.php +++ b/wire/core/WireInput.php @@ -131,6 +131,8 @@ class WireInput extends Wire { * * Must be called before accessing any get/post/cookie input * + * #pw-internal + * * @param bool $lazy * */ @@ -1056,7 +1058,9 @@ class WireInput extends Wire { /** * Same as httpUrl() method but always uses https scheme, rather than current request scheme * - * See httpUrl() method for argument and usage details. + * See httpUrl() method for argument and usage details. + * + * #pw-group-URLs * * @param array|bool $options Specify `withQueryString` (bool) option, or in 3.0.167+ you can also use an options array: * - `withQueryString` (bool): Include the query string as well? (if present, default=false) @@ -1110,7 +1114,9 @@ class WireInput extends Wire { * Generate canonical URL for current page and request * * Canonical URL includes full scheme, hostname, path and optionally: - * URL segments, page numbers and query string. + * URL segments, page numbers and query string. + * + * #pw-group-URLs * * @param array $options * - `scheme` (string|bool): Scheme "https", "http", or omit to auto-detect (default=''). diff --git a/wire/core/WireTextTools.php b/wire/core/WireTextTools.php index 1961505a..0e91c524 100644 --- a/wire/core/WireTextTools.php +++ b/wire/core/WireTextTools.php @@ -43,7 +43,9 @@ class WireTextTools extends Wire { * In 3.0.197+ inner content of script, style and object tags is now removed, rather than just the tags. * To revert this behavior or to remove content of additional tags, see the `clearTags` option. * - * #pw-internal + * Note that this method differs from the `Sanitizer::markupToText()` method in that this method is newer, + * more powerful and has more options. But the two methods differ in how they perform markup-to-text + * conversion so you may want to review and try both to determine which one better suits your needs. * * @param string $str String to convert to text * @param array $options @@ -59,6 +61,7 @@ class WireTextTools extends Wire { * - `collapseSpaces` (bool): Collapse extra/redundant extra spaces to single space? (default=true) Since 3.0.132 * - `replacements` (array): Associative array of strings to manually replace. (default=[' ' => ' ']) * @return string + * @see Sanitizer::markupToText() * */ public function markupToText($str, array $options = array()) { diff --git a/wire/modules/Fieldtype/FieldtypeComments/FieldtypeComments.module b/wire/modules/Fieldtype/FieldtypeComments/FieldtypeComments.module index ff693959..ad281287 100644 --- a/wire/modules/Fieldtype/FieldtypeComments/FieldtypeComments.module +++ b/wire/modules/Fieldtype/FieldtypeComments/FieldtypeComments.module @@ -2208,6 +2208,59 @@ class FieldtypeComments extends FieldtypeMulti { parent::___renamedField($field, $prevName); } + + /** + * Delete the given Field from the given Page. + * + * Must delete entries from field's database table that belong to the Page. + * + * #pw-internal + * + * @param Page $page + * @param Field $field Field object + * @return bool True on success, false on DB delete failure. + * @throws WireException + * + */ + public function ___deletePageField(Page $page, Field $field) { + // @todo + return parent::___deletePageField($page, $field); + } + + /** + * Empty out the DB table data for page field, but leave everything else in tact. + * + * In most cases this may be nearly identical to `Fieldtype::deletePageField()`, but would be different + * for things like page references where we wouldn't want relational data deleted. + * + * #pw-group-deleting + * + * @param Page $page + * @param Field $field Field object + * @return bool True on success, false on DB delete failure. + * @throws WireException + * + */ + public function ___emptyPageField(Page $page, Field $field) { + // @todo + return parent::___emptyPageField($page, $field); + } + + /** + * Move this field’s data from one page to another. + * + * #pw-internal + * + * @param Page $src Source Page + * @param Page $dst Destination Page + * @param Field $field + * @return bool + * + */ + public function ___replacePageField(Page $src, Page $dst, Field $field) { + // @todo + return parent::___replacePageField($src, $dst, $field); + } /** * Export Comment to array