diff --git a/wire/modules/Process/ProcessModule/ProcessModule.module b/wire/modules/Process/ProcessModule/ProcessModule.module index 07fb8981..b25e652b 100644 --- a/wire/modules/Process/ProcessModule/ProcessModule.module +++ b/wire/modules/Process/ProcessModule/ProcessModule.module @@ -90,7 +90,7 @@ class ProcessModule extends Process { 'FieldtypeOptions', 'InputfieldIcon', 'ProcessLogger', - ); + ); protected $labels = array(); @@ -273,85 +273,102 @@ class ProcessModule extends Process { * */ public function ___execute() { + + $modules = $this->wire()->modules; + $session = $this->wire()->session; + $sanitizer = $this->wire()->sanitizer; + $input = $this->wire()->input; - foreach($this->modules as $module) { + foreach($modules as $module) { $this->modulesArray[$module->className()] = 1; } - foreach($this->modules->getInstallable() as $module) { + foreach($modules->getInstallable() as $module) { $this->modulesArray[basename(basename($module, '.php'), '.module')] = 0; } ksort($this->modulesArray); - if($this->input->post('install')) { - $this->session->CSRF->validate(); - $name = $this->wire('sanitizer')->name($this->input->post('install')); + if($input->post('install')) { + $session->CSRF->validate(); + $name = $sanitizer->name($input->post('install')); if($name && isset($this->modulesArray[$name]) && !$this->modulesArray[$name]) { - $module = $this->modules->install($name, array('force' => true)); + $module = $modules->install($name, array('force' => true)); if($module) { $this->modulesArray[$name] = 1; - $this->session->message($this->_("Module Install") . " - $name"); // Message that precedes the name of the module installed - $this->session->redirect("edit?name=$name"); + $session->message($this->_("Module Install") . " - $name"); // Message that precedes the name of the module installed + $session->redirect("edit?name=$name"); } else { - $this->session->error($this->_('Error installing module') . " - $name"); - $this->session->redirect("./"); + $session->error($this->_('Error installing module') . " - $name"); + $session->redirect("./"); } } } - if($this->input->post('delete')) { - $this->session->CSRF->validate(); - $name = $this->input->post('delete'); + if($input->post('delete')) { + $session->CSRF->validate(); + $name = $input->post('delete'); if($name && isset($this->modulesArray[$name])) { - $info = $this->modules->getModuleInfoVerbose($name); + $info = $modules->getModuleInfoVerbose($name); try { - $this->modules->delete($name); + $modules->delete($name); $this->message($this->_('Deleted module files') . ' - ' . $info['title']); } catch(WireException $e) { $this->error($e->getMessage()); } - $this->session->redirect("./"); + $session->redirect("./"); } } - if($this->input->post('download') && $this->input->post('download_name')) { - $this->session->CSRF->validate(); - return $this->downloadConfirm($this->input->post('download_name')); - } else if($this->input->get('download_name')) { - return $this->downloadConfirm($this->input->get('download_name')); + if($input->post('remove')) { + $session->CSRF->validate(); + $removeName = $input->post('remove'); + foreach($modules->findMissingModules() as $missingInfo) { + if($removeName !== $missingInfo['name']) continue; + $modules->removeModuleEntry($missingInfo['name']); + $this->message($this->_('Removed module from database') . ' - ' . $missingInfo['name']); + break; + } + $session->redirect('./'); } - if($this->input->post('upload')) { - $this->session->CSRF->validate(); + if($input->post('download') && $input->post('download_name')) { + $session->CSRF->validate(); + return $this->downloadConfirm($input->post('download_name')); + } else if($input->get('download_name')) { + return $this->downloadConfirm($input->get('download_name')); + } + + if($input->post('upload')) { + $session->CSRF->validate(); $this->executeUpload('upload_module'); } - if($this->input->post('download_zip') && $this->input->post('download_zip_url')) { - $this->session->CSRF->validate(); - $this->executeDownloadURL($this->input->post('download_zip_url')); + if($input->post('download_zip') && $input->post('download_zip_url')) { + $session->CSRF->validate(); + $this->executeDownloadURL($input->post('download_zip_url')); } - if($this->input->post('clear_file_compiler')) { - $this->session->CSRF->validate(); + if($input->post('clear_file_compiler')) { + $session->CSRF->validate(); /** @var FileCompiler $compiler */ $compiler = $this->wire(new FileCompiler($this->wire('config')->paths->siteModules)); $compiler->clearCache(true); - $this->session->message($this->_('Cleared file compiler cache')); - $this->session->redirect('./'); + $session->message($this->_('Cleared file compiler cache')); + $session->redirect('./'); } - if($this->input->get('update')) { - $name = $this->sanitizer->name($this->input->get('update')); + if($input->get('update')) { + $name = $sanitizer->name($input->get('update')); if(isset($this->modulesArray[$name])) return $this->downloadConfirm($name, true); } - if($this->input->get('reset') == 1) { - $this->modules->resetCache(); - $this->message(sprintf($this->_('Modules cache refreshed (%d modules)'), count($this->modules))); - $edit = $this->input->get->fieldName('edit'); - $duplicates = $this->modules->duplicates()->getDuplicates(); + if($input->get('reset') == 1) { + $modules->resetCache(); + $this->message(sprintf($this->_('Modules cache refreshed (%d modules)'), count($modules))); + $edit = $input->get->fieldName('edit'); + $duplicates = $modules->duplicates()->getDuplicates(); foreach($duplicates as $className => $files) { - $dup = $this->modules->duplicates()->getDuplicates($className); + $dup = $modules->duplicates()->getDuplicates($className); if(!count($dup['files'])) continue; $msg = sprintf($this->_('Module "%s" has multiple files (bold file is the one in use).'), $className) . ' ' . "" . $this->_('Click here to change which file is used') . "
";
@@ -362,9 +379,9 @@ class ProcessModule extends Process {
 				$this->message("$msg
", Notice::allowMarkup); } if($edit) { - $this->session->redirect("./edit?name=$edit&reset=2"); + $session->redirect("./edit?name=$edit&reset=2"); } else { - $this->session->redirect("./?reset=2"); + $session->redirect("./?reset=2"); } } @@ -378,6 +395,10 @@ class ProcessModule extends Process { */ protected function renderList() { + $modules = $this->wire()->modules; + $input = $this->wire()->input; + $session = $this->wire()->session; + // module arrays: array(moduleName => 0 (uninstalled) or 1 (installed)) $modulesArray = $this->modulesArray; $installedArray = array(); @@ -388,24 +409,24 @@ class ProcessModule extends Process { $coreModulesArray = array(); $newModulesArray = array(); - if($this->wire('input')->post('new_seconds')) { - $this->wire('session')->set('ProcessModuleNewSeconds', (int) $this->wire('input')->post('new_seconds')); + if($input->post('new_seconds')) { + $session->set('ProcessModuleNewSeconds', (int) $input->post('new_seconds')); } - $newSeconds = (int) $this->wire('session')->get('ProcessModuleNewSeconds'); + $newSeconds = (int) $session->get('ProcessModuleNewSeconds'); if(!$newSeconds) $newSeconds = 86400; foreach($modulesArray as $name => $installed) { if($installed) { $installedArray[$name] = $installed; - $errors = $this->modules->getDependencyErrors($name); + $errors = $modules->getDependencyErrors($name); if($errors) foreach($errors as $error) $this->error($error); } else { $uninstalledNames[] = $name; $uninstalledArray[$name] = $installed; } - $info = $this->modules->getModuleInfoVerbose($name); + $info = $modules->getModuleInfoVerbose($name); $isNew = !$info['core'] || ($info['core'] && in_array($name, $this->newCoreModules)); if($isNew) $isNew = $info['created'] > 0 && $info['created'] > (time()-$newSeconds); @@ -418,7 +439,7 @@ class ProcessModule extends Process { } if($info['configurable'] && $info['installed']) { - $flags = $this->modules->getFlags($name); + $flags = $modules->getFlags($name); if(!($flags & Modules::flagsNoUserConfig)) { $configurableArray[$name] = $installed; } @@ -426,40 +447,47 @@ class ProcessModule extends Process { } /** @var InputfieldForm $form */ - $form = $this->modules->get('InputfieldForm'); + $form = $modules->get('InputfieldForm'); $form->attr('action', './'); $form->attr('method', 'post'); $form->attr('enctype', 'multipart/form-data'); $form->attr('id', 'modules_form'); $form->addClass('ModulesList'); - $this->modules->get('JqueryWireTabs'); + $modules->get('JqueryWireTabs'); // site - + + /** @var InputfieldWrapper $tab */ $tab = $this->wire(new InputfieldWrapper()); $tab->attr('id', 'tab_site_modules'); $tab->attr('title', $this->labels['site']); $tab->attr('class', 'WireTab'); /** @var InputfieldSubmit $button */ - $button = $this->modules->get('InputfieldSubmit'); + $button = $modules->get('InputfieldSubmit'); $button->attr('name', 'clear_file_compiler'); $button->attr('value', $this->_('Clear compiled files')); $button->addClass('ui-priority-secondary'); $button->icon = 'trash-o'; /** @var InputfieldMarkup $markup */ - $markup = $this->modules->get('InputfieldMarkup'); + $markup = $modules->get('InputfieldMarkup'); $markup->label = $this->_('/site/modules/ - Modules specific to your site'); $markup->icon = 'folder-open-o'; - $markup->value .= $this->renderListTable($siteModulesArray, true); - $markup->value .= "

" . sprintf($this->_('Browse the modules directory at %s'), "modules.processwire.com") . "

"; - $markup->value .= "

" . $this->_("To remove a module, click the module to edit, check the Uninstall box, then save. Once uninstalled, the module's file(s) may be removed from /site/modules/. If it still appears in the list above, you may need to click the Refresh button for ProcessWire to see the change."); // Instructions on how to remove a module - $markup->value .= "

" . $this->_('The button below clears compiled site modules and template files, forcing them to be re-compiled the next time they are accessed. Note that this may cause a temporary delay for one or more requests while files are re-compiled.') . "

"; - $markup->value .= "

" . $button->render() . "

"; + $markup->value .= + $this->renderListTable($siteModulesArray, array('allowDelete' => true)) . + "

" . + sprintf($this->_('Browse the modules directory at %s'), "processwire.com/modules") . + "

" . + "

" . + $this->_("To remove a module, click the module to edit, check the Uninstall box, then save. Once uninstalled, the module's file(s) may be removed from /site/modules/. If it still appears in the list above, you may need to click the Refresh button for ProcessWire to see the change.") . // Instructions on how to remove a module + "

" . + "

" . + $this->_('The button below clears compiled site modules and template files, forcing them to be re-compiled the next time they are accessed. Note that this may cause a temporary delay for one or more requests while files are re-compiled.') . + "

" . + "

" . $button->render() . "

"; $tab->add($markup); - $form->add($tab); // core @@ -471,7 +499,7 @@ class ProcessModule extends Process { $tab->attr('class', 'WireTab'); /** @var InputfieldMarkup $markup */ - $markup = $this->modules->get('InputfieldMarkup'); + $markup = $modules->get('InputfieldMarkup'); $markup->value = $this->renderListTable($coreModulesArray); $markup->label = $this->_('/wire/modules/ - Modules included with the ProcessWire core'); $markup->icon = 'folder-open-o'; @@ -479,14 +507,18 @@ class ProcessModule extends Process { $form->add($tab); // configurable - + $tab = $this->wire(new InputfieldWrapper()); $tab->attr('id', 'tab_configurable_modules'); $tab->attr('title', $this->labels['configure']); $tab->attr('class', 'WireTab'); - $markup = $this->modules->get('InputfieldMarkup'); - $markup->value = $this->renderListTable($configurableArray, true, true, false, false, true); + /** @var InputfieldMarkup $markup */ + $markup = $modules->get('InputfieldMarkup'); + $markup->value = $this->renderListTable($configurableArray, array( + 'allowDelete' => true, + 'allowType' => true + )); $markup->label = $this->_('Modules that have configuration options'); $markup->icon = 'folder-open-o'; $tab->add($markup); @@ -500,13 +532,45 @@ class ProcessModule extends Process { $tab->attr('title', $tabLabel); $tab->attr('class', 'WireTab'); - $markup = $this->modules->get('InputfieldMarkup'); - $markup->value = $this->renderListTable($uninstalledArray, true, true, false, false, true); + $markup = $modules->get('InputfieldMarkup'); + $markup->value = $this->renderListTable($uninstalledArray, array( + 'allowDelete' => true, + 'allowType' => true + )); $markup->label = $this->_('Modules on the file system that are not currently installed'); $markup->icon = 'folder-open-o'; $tab->add($markup); $form->add($tab); + // missing + + $missing = $modules->findMissingModules(); + if(count($missing)) { + $missingArray = array(); + $missingFiles = array(); + $rootPath = $this->wire()->config->paths->root; + foreach($missing as $name => $item) { + $missingArray[$name] = $modules->isInstalled($name); + $missingFiles[$name] = $this->_('Missing file:') . ' ' . str_replace($rootPath, '/', $item['file']); + } + $tab = $this->wire(new InputfieldWrapper()); + $tab->attr('id', 'tab_missing_modules'); + $tabLabel = $this->_('Missing'); + $tab->attr('title', $tabLabel); + $tab->attr('class', 'WireTab'); + + $markup = $modules->get('InputfieldMarkup'); + $markup->value = $this->renderListTable($missingArray, array( + 'allowRemove' => true, + 'allowInstall' => false, + 'allowType' => true, + 'summaries' => $missingFiles, + )); + $markup->label = $this->_('Modules in database that are not found on the file system'); + $markup->icon = 'warning'; + $tab->add($markup); + $form->add($tab); + } // new @@ -516,7 +580,7 @@ class ProcessModule extends Process { $tab->attr('title', $this->_('New')); $tab->attr('class', 'WireTab'); - $newModules = $this->wire('session')->get($this, 'newModules'); + $newModules = $session->get($this, 'newModules'); if($newModules) foreach($newModules as $name => $created) { if(!is_numeric($name) && !isset($newModulesArray[$name])) { // add to newModulesArray and identify as uninstalled @@ -525,7 +589,7 @@ class ProcessModule extends Process { } /** @var InputfieldSelect $select */ - $select = $this->wire('modules')->get('InputfieldSelect'); + $select = $modules->get('InputfieldSelect'); $select->attr('name', 'new_seconds'); $select->addClass('modules_filter'); $select->addOption(3600, $this->_('Within the last hour')); @@ -536,7 +600,7 @@ class ProcessModule extends Process { $select->attr('value', $newSeconds); /** @var InputfieldSubmit $btn */ - $btn = $this->modules->get('InputfieldSubmit'); + $btn = $modules->get('InputfieldSubmit'); $btn->attr('hidden', 'hidden'); $btn->attr('name', 'submit_check'); $btn->textFormat = Inputfield::textFormatNone; @@ -547,14 +611,19 @@ class ProcessModule extends Process { $btn = ""; /** @var InputfieldMarkup $markup */ - $markup = $this->modules->get('InputfieldMarkup'); + $markup = $modules->get('InputfieldMarkup'); $markup->icon = 'lightbulb-o'; - $markup->value = $select->render() . ' ' . $btn . $this->renderListTable($newModulesArray, false, false, true, true); + $markup->value = $select->render() . ' ' . $btn . + $this->renderListTable($newModulesArray, array( + 'allowSections' => false, + 'allowDates' => true, + 'allowClasses' => true + )); $markup->label = $this->_('Recently Found and Installed Modules'); $tab->add($markup); /** @var InputfieldFieldset $fieldset */ - $fieldset = $this->modules->get('InputfieldFieldset'); + $fieldset = $modules->get('InputfieldFieldset'); $fieldset->label = $this->labels['download_dir']; $fieldset->icon = 'cloud-download'; $tab->add($fieldset); @@ -562,7 +631,7 @@ class ProcessModule extends Process { if($this->installer()->canInstallFromDirectory(false)) { /** @var InputfieldName $f */ - $f = $this->modules->get('InputfieldName'); + $f = $modules->get('InputfieldName'); $f->attr('id+name', 'download_name'); $f->label = $this->_('Module Class Name'); $f->description = @@ -571,13 +640,13 @@ class ProcessModule extends Process { $this->_('Type or paste in the class name for the module you want to install, then click the ā€œ%sā€ button to proceed.'), $this->labels['get_module_info'] ); - $f->notes = sprintf($this->_('The modules directory is located at %s'), '[modules.processwire.com](https://modules.processwire.com)'); + $f->notes = sprintf($this->_('The modules directory is located at %s'), '[processwire.com/modules](https://processwire.com/modules/)'); $f->attr('placeholder', $this->_('ModuleClassName')); // placeholder $f->required = false; $fieldset->add($f); /** @var InputfieldSubmit $f */ - $f = $this->modules->get('InputfieldSubmit'); + $f = $modules->get('InputfieldSubmit'); $f->attr('id+name', 'download'); $f->value = $this->labels['get_module_info']; $f->icon = $fieldset->icon; @@ -588,7 +657,7 @@ class ProcessModule extends Process { } /** @var InputfieldFieldset $fieldset */ - $fieldset = $this->modules->get('InputfieldFieldset'); + $fieldset = $modules->get('InputfieldFieldset'); $fieldset->label = $this->labels['download_zip']; $fieldset->icon = 'download'; $fieldset->collapsed = Inputfield::collapsedYes; @@ -597,7 +666,7 @@ class ProcessModule extends Process { if($this->installer()->canInstallFromDownloadUrl(false)) { /** @var InputfieldURL $f */ - $f = $this->modules->get('InputfieldURL'); + $f = $modules->get('InputfieldURL'); $f->attr('id+name', 'download_zip_url'); $f->label = $this->_('Module ZIP file URL'); $f->description = $this->_('Download a ZIP file containing a module. If you download a module that is already installed, the installed version will be overwritten with the newly downloaded version.'); @@ -607,7 +676,7 @@ class ProcessModule extends Process { $fieldset->add($f); /** @var InputfieldSubmit $f */ - $f = $this->modules->get('InputfieldSubmit'); + $f = $modules->get('InputfieldSubmit'); $f->attr('id+name', 'download_zip'); $f->value = $this->labels['download']; $f->icon = $fieldset->icon; @@ -617,7 +686,7 @@ class ProcessModule extends Process { } /** @var InputfieldFieldset $fieldset */ - $fieldset = $this->modules->get('InputfieldFieldset'); + $fieldset = $modules->get('InputfieldFieldset'); $fieldset->label = $this->labels['upload_zip']; $fieldset->icon = 'upload'; $fieldset->collapsed = Inputfield::collapsedYes; @@ -625,7 +694,7 @@ class ProcessModule extends Process { if($this->installer()->canInstallFromFileUpload(false)) { /** @var InputfieldFile $f */ - $f = $this->modules->get('InputfieldFile'); + $f = $modules->get('InputfieldFile'); $f->extensions = 'zip'; $f->maxFiles = 1; $f->descriptionRows = 0; @@ -637,7 +706,8 @@ class ProcessModule extends Process { $f->required = false; $f->noCustomButton = true; $fieldset->add($f); - $f = $this->modules->get('InputfieldSubmit'); + /** @var InputfieldSubmit $f */ + $f = $modules->get('InputfieldSubmit'); $f->attr('id+name', 'upload'); $f->value = $this->labels['upload']; $f->icon = $fieldset->icon; @@ -647,7 +717,7 @@ class ProcessModule extends Process { } /** @var InputfieldFieldset $fieldset */ - $fieldset = $this->modules->get('InputfieldFieldset'); + $fieldset = $modules->get('InputfieldFieldset'); $fieldset->attr('id', 'fieldset_check_new'); $fieldset->label = $this->labels['add_manually']; $fieldset->icon = 'plug'; @@ -655,7 +725,7 @@ class ProcessModule extends Process { $tab->add($fieldset); /** @var InputfieldMarkup $markup */ - $markup = $this->modules->get('InputfieldMarkup'); + $markup = $modules->get('InputfieldMarkup'); $fieldset->add($markup); $moduleNameLabel = $this->_('ModuleName'); // Example module class/directory name $moduleNameDir = $this->wire()->config->urls->siteModules . $moduleNameLabel . '/'; @@ -681,7 +751,7 @@ class ProcessModule extends Process { */ /** @var InputfieldButton $submit */ - $submit = $this->modules->get('InputfieldButton'); + $submit = $modules->get('InputfieldButton'); $submit->attr('href', './?reset=1'); $submit->attr('id', 'reset_modules'); $submit->showInHeader(); @@ -694,7 +764,7 @@ class ProcessModule extends Process { $form->add($tab); // if($this->input->get->reset == 2 && !$this->numFound) $this->message($this->_("No new modules found")); - $this->session->set('ModulesUninstalled', $uninstalledNames); + $session->set('ModulesUninstalled', $uninstalledNames); return $form->render(); } @@ -703,22 +773,43 @@ class ProcessModule extends Process { * Render a modules listing table, as it appears in the 'site' and 'core' tabs * * @param array $modulesArray - * @param bool $allowDelete Whether or not delete is allowed (default=false) - * @param bool $allowSections Whether to show module sections/categories (default=true) - * @param bool $allowDates Whether to show created dates (default=false) - * @param bool $allowClasses Whether to show module class names(default=false) - * @param bool $allowType Whether to show if module is site or core + * @param array $options + * `allowDelete` (bool): Whether or not delete is allowed (default=false) + * `allowSections` (bool): Whether to show module sections/categories (default=true) + * `allowDates` (bool): Whether to show created dates (default=false) + * `allowClasses` (bool) Whether to show module class names (default=false) + * `allowType` (bool): Whether to show if module is site or core (default=false) + * `allowInstall` (bool): Whether or not install is allowed (default=true) + * `allowRemove` (bool): Allow remove from database? (default=false) for missing entries + * `summaries` (array): Replacement summary info indexed by module name (default=[]) * @return string * */ - protected function renderListTable($modulesArray, $allowDelete = false, $allowSections = true, $allowDates = false, $allowClasses = false, $allowType = false) { + protected function renderListTable($modulesArray, array $options = array()) { + + $defaults = array( + 'allowDelete' => false, + 'allowSections' => true, + 'allowDates' => false, + 'allowClasses' => false, + 'allowType' => false, + 'allowInstall' => true, + 'allowRemove' => false, + 'summaries' => array(), + ); + + $options = array_merge($defaults, $options); + $session = $this->wire()->session; + $modules = $this->wire()->modules; + $input = $this->wire()->input; + $sanitizer = $this->wire()->sanitizer; if(!count($modulesArray)) return "
" . $this->_('No modules found.') . "
"; static $numCalls = 0; $numCalls++; - $uninstalledPrev = is_array($this->session->get('ModulesUninstalled')) ? $this->session->get('ModulesUninstalled') : array(); + $uninstalledPrev = is_array($session->get('ModulesUninstalled')) ? $session->get('ModulesUninstalled') : array(); $section = 'none'; $tableHeader = array( $this->_x('Module', 'list'), // Modules list table header for 'Module' column @@ -730,7 +821,7 @@ class ProcessModule extends Process { $total = 0; $out = ''; $this->numFound = 0; - $newModules = $this->wire('session')->get($this, 'newModules'); + $newModules = $session->get($this, 'newModules'); if(!is_array($newModules)) $newModules = array(); $sections = array(); @@ -740,47 +831,45 @@ class ProcessModule extends Process { if(strpos($name, $section) !== 0 || preg_match('/' . $section . '[^A-Z0-9]/', $name)) { if(!preg_match('/^([A-Za-z][a-z]+)/', $name, $matches)) $this->error(sprintf($this->_('Invalid module name: %s'), $name)); - if($allowSections || is_null($table)) { + if($options['allowSections'] || is_null($table)) { $section = $matches[1]; $sections[] = $section; if($table) $out .= $table->render() . ""; - $table = $this->modules->get("MarkupAdminDataTable"); + $table = $modules->get("MarkupAdminDataTable"); $table->setEncodeEntities(false); $table->headerRow($tableHeader); - if($allowSections) $out .= "\n

$section

"; + if($options['allowSections']) $out .= "\n

$section

"; } } - $info = $this->modules->getModuleInfoVerbose($name); - - // $interfaces = @class_implements($name, false); - // $configurable = is_array($interfaces) && in_array('ConfigurableModule', $interfaces); + $info = $modules->getModuleInfoVerbose($name); $configurable = $info['configurable']; - $title = !empty($info['title']) ? $this->wire('sanitizer')->entities1($info['title']) : substr($name, strlen($section)); - if($allowClasses) $title .= "
$name"; + $title = !empty($info['title']) ? $sanitizer->entities1($info['title']) : substr($name, strlen($section)); + if($options['allowClasses']) $title .= "
$name"; if($info['icon']) $title = " $title"; $class = $configurable ? 'ConfigurableModule' : ''; if(!empty($info['permanent'])) $class .= ($class ? ' ' : '') . 'PermanentModule'; if($class) $title = "$title"; $version = $this->formatVersion(isset($info['version']) ? $info['version'] : 0); - if($allowType) $version .= "
" . ($info['core'] ? $this->labels['core'] : $this->labels['site']) . ""; - $summary = empty($info['summary']) ? '' : $this->wire('sanitizer')->entities1($info['summary']); + if($options['allowType']) $version .= "
" . ($info['core'] ? $this->labels['core'] : $this->labels['site']) . ""; + if(!empty($options['summaries'][$name])) $info['summary'] = $options['summaries'][$name]; + $summary = empty($info['summary']) ? '' : $sanitizer->entities1($info['summary']); if(strpos($summary, '<') !== false) $summary = preg_replace('/([^\s]{35})[^\s]{20,}/', '$1...', $summary); // prevent excessively long text without whitespace - $summary .= empty($info['href']) ? '' : (" " . $this->_('more') . ""); + $summary .= empty($info['href']) ? '' : (" " . $this->_('more') . ""); if($summary) $summary = "

$summary

"; $buttons = ''; $confirmDeleteJS = "return confirm('" . sprintf($this->_('Delete %s?'), $name) . "')"; $confirmInstallJS = "return confirm('" . sprintf($this->_('Module requirements are not fulfilled so installing may cause problems. Are you sure you want to install?'), $name) . "')"; $editUrl = "edit?name={$name}"; - if(!$installed) { + if(!$installed && $options['allowInstall']) { if(count($info['requires'])) { - $requires = $this->modules->getRequiresForInstall($name); + $requires = $modules->getRequiresForInstall($name); if(count($requires)) { foreach($requires as $key => $value) { $nameOnly = preg_replace('/^([_a-zA-Z0-9]+)[=<>]+.*$/', '$1', $value); - $requiresInfo = $this->modules->getModuleInfo($nameOnly); + $requiresInfo = $modules->getModuleInfo($nameOnly); if(!empty($requiresInfo['error'])) $requires[$key] = "$value"; } $summary .= "" . $this->labels['requires'] . " - " . implode(', ', $requires) . ""; @@ -794,14 +883,14 @@ class ProcessModule extends Process { $class = 'not_installed'; if(count($uninstalledPrev) && !in_array($name, $uninstalledPrev)) { $class .= " new_module"; - if(!$this->input->get('uninstalled')) $this->message($this->_("Found new module") . " - $name"); // Message that precedes module name when new module is found + if(!$input->get('uninstalled')) $this->message($this->_("Found new module") . " - $name"); // Message that precedes module name when new module is found $newModules[$name] = time(); $this->numFound++; } $title = "$title"; - $isConfirm = count($modulesArray) == 1 && $this->wire('input')->get('name'); + $isConfirm = count($modulesArray) == 1 && $input->get('name'); $buttonState = 'ui-state-default'; $buttonPriority = $isConfirm ? "ui-priority-primary" : "ui-priority-secondary"; $buttonType = 'submit'; @@ -830,7 +919,7 @@ class ProcessModule extends Process { "" . ""; - if($allowDelete && $this->wire('modules')->isDeleteable($name)) $buttons .= + if($options['allowDelete'] && $modules->isDeleteable($name)) $buttons .= ""; - + ""; + $editUrl = '#'; } else if($configurable) { - $flags = $this->modules->getFlags($name); + $flags = $modules->getFlags($name); if(!($flags & Modules::flagsNoUserConfig)) { $buttons .= ""; // Text for 'Settings' button } } + + if($options['allowRemove']) $buttons .= + ""; if($buttons) $buttons = "$buttons"; - if($allowDates) { + if($options['allowDates']) { $summary .= ""; $summary .= $installed ? $this->labels['installed_date'] : $this->_('Found'); $created = isset($newModules[$name]) ? $newModules[$name] : $info['created']; @@ -875,11 +974,11 @@ class ProcessModule extends Process { } $out .= $table->render(); - if($allowSections) { + if($options['allowSections']) { $out .= "
"; $select = "