X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Flinkchecker%2Flinkchecker.drush.inc;fp=web%2Fmodules%2Fcontrib%2Flinkchecker%2Flinkchecker.drush.inc;h=5941e7224d5dd31d0acd3d8165a9912dea8876d9;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/linkchecker/linkchecker.drush.inc b/web/modules/contrib/linkchecker/linkchecker.drush.inc new file mode 100644 index 000000000..5941e7224 --- /dev/null +++ b/web/modules/contrib/linkchecker/linkchecker.drush.inc @@ -0,0 +1,100 @@ + 'Reanalyzes content for links. Recommended after module has been upgraded.', + ]; + $commands['linkchecker-clear'] = [ + 'description' => 'Clears all link data and analyze content for links. WARNING: Custom link check settings are deleted.', + ]; + $commands['linkchecker-check'] = [ + 'description' => 'Check link status.', + // 'options' => array( + // 'links' => 'Number of links to check in one round. Default: 1000', + // ), + ]; + + return $commands; +} + +/** + * Callback for command linkchecker-analyze. + */ +function drush_linkchecker_analyze() { + // @fixme + global $base_url; + if ($base_url == 'http://default') { + drush_die('You MUST configure the site $base_url or provide --uri parameter.'); + } + + // @fixme + module_load_include('admin.inc', 'linkchecker'); + + // Fake $form_state to leverage _submit function. + $form_state = [ + 'values' => ['op' => t('Analyze content for links')], + 'buttons' => [], + ]; + + $node_types = linkchecker_scan_node_types(); + if (!empty($node_types) || \Drupal::config('linkchecker.settings')->get('scan_blocks')) { + linkchecker_analyze_links_submit(NULL, $form_state); + drush_backend_batch_process(); + } + else { + drush_log('No content configured for link analysis.', 'status'); + } +} + +/** + * Callback for command linkchecker-analyze. + */ +function drush_linkchecker_clear() { + // @fixme + global $base_url; + if ($base_url == 'http://default') { + drush_die('You MUST configure the site $base_url or provide --uri parameter.'); + } + + // @fixme + module_load_include('admin.inc', 'linkchecker'); + + // Fake $form_state to leverage _submit function. + $form_state = [ + 'values' => ['op' => t('Clear link data and analyze content for links')], + 'buttons' => [], + ]; + + $node_types = linkchecker_scan_node_types(); + if (!empty($node_types) || \Drupal::config('linkchecker.settings')->get('scan_blocks')) { + linkchecker_clear_analyze_links_submit(NULL, $form_state); + drush_backend_batch_process(); + } + else { + drush_log('No content configured for link analysis.', 'status'); + } +} + +/** + * Callback for command linkchecker-check. + */ +function drush_linkchecker_check() { + drush_log('Starting link checking...', 'info'); + $run = _linkchecker_check_links(); + if (!$run) { + drush_log('Attempted to re-run link checks while they are already running.', 'warning'); + } + else { + drush_log('Finished checking links.', 'completed'); + } +}