From d935e9b6995124d76e6fda17fd47ab46dc4d3a3c Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 18 Nov 2016 12:23:27 -0500 Subject: [PATCH] Some minor doc tweaks, update $modules->getModuleInfo() method to support returning info for all modules, bump version to 3.0.41 --- wire/core/Fieldtype.php | 8 +++----- wire/core/Modules.php | 18 ++++++++++++++--- wire/core/ProcessWire.php | 2 +- .../AdminThemeDefault.module | 2 +- wire/modules/Fieldtype/FieldtypeCache.module | 20 +++++++++++++++++++ 5 files changed, 40 insertions(+), 10 deletions(-) diff --git a/wire/core/Fieldtype.php b/wire/core/Fieldtype.php index bd5a4d79..98f48d3c 100644 --- a/wire/core/Fieldtype.php +++ b/wire/core/Fieldtype.php @@ -396,13 +396,11 @@ abstract class Fieldtype extends WireData implements Module { * need to have some text formatting applied to them, like Markdown, SmartyPants, Textile, etc. As a result, * Fieldtype modules don't need to implement this unless it's applicable. * - * Fieldtype modules that implement this do not need to call this parent method, as it doesn't do anything. - * * #pw-group-formatting * - * @param Page $page - * @param Field $field - * @param string|int|object $value + * @param Page $page Page that the value lives on + * @param Field $field Field that represents the value + * @param string|int|object $value The value to format * @return mixed * */ diff --git a/wire/core/Modules.php b/wire/core/Modules.php index 18d9dd07..41da080f 100644 --- a/wire/core/Modules.php +++ b/wire/core/Modules.php @@ -2456,7 +2456,8 @@ class Modules extends WireArray { * $moduleInfo = $modules->getModuleInfoVerbose('MarkupAdminDataTable'); * ~~~~~ * - * @param string|Module|int $class May be class name, module instance, or module ID + * @param string|Module|int $class May be class name, module instance, or module ID. + * Specify "*" or "all" to retrieve module info for all modules. * @param array $options Optional options to modify behavior of what gets returned * - `verbose` (bool): Makes the info also include additional properties (they will be usually blank without this option specified). * - `noCache` (bool): prevents use of cache to retrieve the module info. @@ -2544,11 +2545,22 @@ class Modules extends WireArray { if(!count($info)) $info = $this->getModuleInfoInternal($module); } - } else if($module == 'PHP' || $module == 'ProcessWire') { + } else if($module == 'PHP' || $module == 'ProcessWire') { // module is a system - $info = $this->getModuleInfoSystem($module); + $info = $this->getModuleInfoSystem($module); return array_merge($infoTemplate, $info); + } else if($module === '*' || $module === 'all') { + if(empty($this->moduleInfoCache)) $this->loadModuleInfoCache(); + $modulesInfo = $this->moduleInfoCache; + if($options['verbose']) { + if(empty($this->moduleInfoCacheVerbose)) $this->loadModuleInfoCacheVerbose(); + foreach($this->moduleInfoCacheVerbose as $moduleID => $moduleInfoVerbose) { + $modulesInfo[$moduleID] = array_merge($modulesInfo[$moduleID], $moduleInfoVerbose); + } + } + return $modulesInfo; + } else { // module is a class name or ID diff --git a/wire/core/ProcessWire.php b/wire/core/ProcessWire.php index fb27721e..affb8b4d 100644 --- a/wire/core/ProcessWire.php +++ b/wire/core/ProcessWire.php @@ -28,7 +28,7 @@ class ProcessWire extends Wire { const versionMajor = 3; const versionMinor = 0; - const versionRevision = 40; + const versionRevision = 41; const versionSuffix = ''; const indexVersion = 300; // required version for index.php file (represented by PROCESSWIRE define) diff --git a/wire/modules/AdminTheme/AdminThemeDefault/AdminThemeDefault.module b/wire/modules/AdminTheme/AdminThemeDefault/AdminThemeDefault.module index b23905a3..6a076216 100644 --- a/wire/modules/AdminTheme/AdminThemeDefault/AdminThemeDefault.module +++ b/wire/modules/AdminTheme/AdminThemeDefault/AdminThemeDefault.module @@ -3,7 +3,7 @@ /** * Class AdminThemeDefault * - * @property string $colors + * @property string $colors Color set being used: "classic", "warm", "modern" or "futura" * */ diff --git a/wire/modules/Fieldtype/FieldtypeCache.module b/wire/modules/Fieldtype/FieldtypeCache.module index 2ec6dd3b..01e77eac 100644 --- a/wire/modules/Fieldtype/FieldtypeCache.module +++ b/wire/modules/Fieldtype/FieldtypeCache.module @@ -15,6 +15,12 @@ class FieldtypeCache extends Fieldtype { + /** + * Get module information + * + * @return array + * + */ public static function getModuleInfo() { return array( 'title' => 'Cache', @@ -99,6 +105,13 @@ class FieldtypeCache extends Fieldtype { return parent::___savePageField($page, $field); } + /** + * Get number of pages in the cache + * + * @param Field $field FieldtypeCache field to check + * @return int Number of cached pages + * + */ public function getNumPagesCached(Field $field) { $database = $this->wire('database'); $table = $database->escapeTable($field->getTable()); @@ -113,6 +126,13 @@ class FieldtypeCache extends Fieldtype { return $num; } + /** + * Regenerate the cache for the given Field + * + * @param Field $field Field of type FieldtypeCache + * @return int Number of pages that were cached + * + */ protected function regenerateCache(Field $field) { $numPages = 0;