Skip to content

Commit

Permalink
Apply coding style around FunctionCallSignature #4 (#21930)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl authored Feb 15, 2024
1 parent 0b68d1a commit 127f508
Show file tree
Hide file tree
Showing 30 changed files with 409 additions and 155 deletions.
5 changes: 4 additions & 1 deletion plugins/Annotations/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ public function getAnnotationCountForDates($idSite, $date, $period, $lastN = fal
&& $result[$idSite][$strDate]['count'] == 1
) {
$annotationsForSite = $annotations->search(
$date, Date::factory($nextDate->getTimestamp() - 1), $idSite);
$date,
Date::factory($nextDate->getTimestamp() - 1),
$idSite
);
$annotation = reset($annotationsForSite[$idSite]);

$result[$idSite][$strDate]['note'] = $annotation['note'];
Expand Down
8 changes: 6 additions & 2 deletions plugins/Annotations/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public function getAnnotationManager($fetch = false, $date = false, $period = fa
$view = new View('@Annotations/getAnnotationManager');

$allAnnotations = Request::processRequest(
'Annotations.getAll', array('date' => $date, 'period' => $period, 'lastN' => $lastN));
'Annotations.getAll',
array('date' => $date, 'period' => $period, 'lastN' => $lastN)
);
$view->annotations = empty($allAnnotations[$this->idSite]) ? array() : $allAnnotations[$this->idSite];

$view->period = $period;
Expand Down Expand Up @@ -210,7 +212,9 @@ public function getEvolutionIcons()
{
// get annotation the count
$annotationCounts = Request::processRequest(
"Annotations.getAnnotationCountForDates", array('getAnnotationText' => 1));
"Annotations.getAnnotationCountForDates",
array('getAnnotationText' => 1)
);

// create & render the view
$view = new View('@Annotations/getEvolutionIcons');
Expand Down
7 changes: 6 additions & 1 deletion plugins/Annotations/tests/System/AnnotationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,12 @@ public function testGetInvalidNoteIdFail()
public function testSaveSuccess()
{
API::getInstance()->save(
self::$fixture->idSite1, 0, $date = '2011-04-01', $note = 'new note text', $starred = 1);
self::$fixture->idSite1,
0,
$date = '2011-04-01',
$note = 'new note text',
$starred = 1
);

$expectedAnnotation = array(
'date' => '2011-04-01',
Expand Down
12 changes: 10 additions & 2 deletions plugins/CoreAdminHome/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,16 @@ public function getOptOutJSEmbedCode(
string $language
): string {

return $this->optOutManager->getOptOutJSEmbedCode($matomoUrl, $language, $backgroundColor, $fontColor, $fontSize,
$fontFamily, $applyStyling, $showIntro);
return $this->optOutManager->getOptOutJSEmbedCode(
$matomoUrl,
$language,
$backgroundColor,
$fontColor,
$fontSize,
$fontFamily,
$applyStyling,
$showIntro
);
}

/**
Expand Down
18 changes: 12 additions & 6 deletions plugins/CoreAdminHome/Commands/DeleteLogsData.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,18 @@ protected function configure()
$this->setName('core:delete-logs-data');
$this->setDescription('Delete data from the user log tables: ' . implode(', ', self::$logTables) . '.');
$this->addRequiredValueOption('dates', null, 'Delete log data with a date within this date range. Eg, 2012-01-01,2013-01-01');
$this->addOptionalValueOption('idsite', null,
'Delete log data belonging to the site with this ID. Comma separated list of website id. Eg, 1, 2, 3, etc. By default log data from all sites is purged.');
$this->addOptionalValueOption(
'idsite',
null,
'Delete log data belonging to the site with this ID. Comma separated list of website id. Eg, 1, 2, 3, etc. By default log data from all sites is purged.'
);
$this->addRequiredValueOption('limit', null, "The number of rows to delete at a time. The larger the number, "
. "the more time is spent deleting logs, and the less progress will be printed to the screen.", 1000);
$this->addNoValueOption('optimize-tables', null,
"If supplied, the command will optimize log tables after deleting logs. Note: this can take a very long time.");
$this->addNoValueOption(
'optimize-tables',
null,
"If supplied, the command will optimize log tables after deleting logs. Note: this can take a very long time."
);
}

protected function doExecute(): int
Expand All @@ -72,8 +78,8 @@ protected function doExecute(): int
$step = $this->getRowIterationStep();

$output->writeln(sprintf(
"<info>Preparing to delete all visits belonging to %s between $from and $to.</info>",
$idSite ? "website $idSite" : "ALL websites"
"<info>Preparing to delete all visits belonging to %s between $from and $to.</info>",
$idSite ? "website $idSite" : "ALL websites"
));

$confirm = $this->askForDeleteConfirmation();
Expand Down
58 changes: 44 additions & 14 deletions plugins/CoreAdminHome/Commands/InvalidateReportData.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,54 @@ protected function configure()
{
$this->setName('core:invalidate-report-data');
$this->setDescription('Invalidate archived report data by date range, site and period.');
$this->addRequiredValueOption('dates', null,
'List of dates or date ranges to invalidate report data for, eg, 2015-01-03 or 2015-01-05,2015-02-12.', null, true);
$this->addRequiredValueOption('sites', null,
$this->addRequiredValueOption(
'dates',
null,
'List of dates or date ranges to invalidate report data for, eg, 2015-01-03 or 2015-01-05,2015-02-12.',
null,
true
);
$this->addRequiredValueOption(
'sites',
null,
'List of site IDs to invalidate report data for, eg, "1,2,3,4" or "all" for all sites.',
self::ALL_OPTION_VALUE);
$this->addRequiredValueOption('periods', null,
self::ALL_OPTION_VALUE
);
$this->addRequiredValueOption(
'periods',
null,
'List of period types to invalidate report data for. Can be one or more of the following values: day, '
. 'week, month, year or "all" for all of them.',
self::ALL_OPTION_VALUE);
$this->addRequiredValueOption('segment', null,
self::ALL_OPTION_VALUE
);
$this->addRequiredValueOption(
'segment',
null,
'List of segments to invalidate report data for. This can be the segment string itself, the segment name from the UI or the ID of the segment.'
. ' If specifying the segment definition, make sure it is encoded properly (it should be the same as the segment parameter in the URL.', null, true);
$this->addNoValueOption('cascade', null,
. ' If specifying the segment definition, make sure it is encoded properly (it should be the same as the segment parameter in the URL.',
null,
true
);
$this->addNoValueOption(
'cascade',
null,
'If supplied, invalidation will cascade, invalidating child period types even if they aren\'t specified in'
. ' --periods. For example, if --periods=week, --cascade will cause the days within those weeks to be '
. 'invalidated as well. If --periods=month, then weeks and days will be invalidated. Note: if a period '
. 'falls partly outside of a date range, then --cascade will also invalidate data for child periods '
. 'outside the date range. For example, if --dates=2015-09-14,2015-09-15 & --periods=week, --cascade will'
. ' also invalidate all days within 2015-09-13,2015-09-19, even those outside the date range.');
. ' also invalidate all days within 2015-09-13,2015-09-19, even those outside the date range.'
);
$this->addNoValueOption('dry-run', null, 'For tests. Runs the command w/o actually '
. 'invalidating anything.');
$this->addRequiredValueOption('plugin', null, 'To invalidate data for a specific plugin only.');
$this->addNoValueOption('ignore-log-deletion-limit', null,
$this->addNoValueOption(
'ignore-log-deletion-limit',
null,
'Ignore the log purging limit when invalidating archives. If a date is older than the log purging threshold (which means '
. 'there should be no log data for it), we normally skip invalidating it in order to prevent losing any report data. In some cases, '
. 'however it is useful, if, for example, your site was imported from Google, and there is never any log data.');
. 'however it is useful, if, for example, your site was imported from Google, and there is never any log data.'
);
$this->setHelp('Invalidate archived report data by date range, site and period. Invalidated archive data will '
. 'be re-archived during the next core:archive run. If your log data has changed for some reason, this '
. 'command can be used to make sure reports are generated using the new, changed log data.');
Expand Down Expand Up @@ -109,8 +131,16 @@ protected function doExecute(): int
}
$logger->info($message);
} else {
$invalidationResult = $invalidator->markArchivesAsInvalidated($sites, $dates, $periodType, $segment, $cascade,
false, $plugin, $ignoreLogDeletionLimit);
$invalidationResult = $invalidator->markArchivesAsInvalidated(
$sites,
$dates,
$periodType,
$segment,
$cascade,
false,
$plugin,
$ignoreLogDeletionLimit
);

if ($output->getVerbosity() > $output::VERBOSITY_NORMAL) {
foreach ($invalidationResult->makeOutputLogs() as $outputLog) {
Expand Down
8 changes: 6 additions & 2 deletions plugins/CoreAdminHome/Commands/OptimizeArchiveTables.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ protected function configure()
{
$this->setName('database:optimize-archive-tables');
$this->setDescription("Runs an OPTIMIZE TABLE query on the specified archive tables.");
$this->addRequiredArgument("dates",
$this->addRequiredArgument(
"dates",
"The months of the archive tables to optimize. Use '" . self::ALL_TABLES_STRING . "' for all dates or '" .
self::CURRENT_MONTH_STRING . "' to optimize the current month only.", null, true);
self::CURRENT_MONTH_STRING . "' to optimize the current month only.",
null,
true
);
$this->addNoValueOption('dry-run', null, 'For testing purposes.');
$this->setHelp("This command can be used to ease or automate maintenance. Instead of manually running "
. "OPTIMIZE TABLE queries, the command can be used.\n\nYou should run the command if you find your "
Expand Down
32 changes: 23 additions & 9 deletions plugins/CoreAdminHome/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,27 @@ public function configureAdminMenu(MenuAdmin $menu)
$menu->addDevelopmentItem('', [], 40);

if (Piwik::hasUserSuperUserAccess()) {
$menu->addSystemItem('General_GeneralSettings',
$menu->addSystemItem(
'General_GeneralSettings',
$this->urlForAction('generalSettings'),
$order = 5);
$order = 5
);
}

if (!Piwik::isUserIsAnonymous()) {
$menu->addMeasurableItem('CoreAdminHome_TrackingCode',
$menu->addMeasurableItem(
'CoreAdminHome_TrackingCode',
$this->urlForAction('trackingCodeGenerator'),
$order = 12);
$order = 12
);
}

if (Piwik::isUserHasSomeAdminAccess()) {
$menu->addDiagnosticItem('CoreAdminHome_TrackingFailures',
$menu->addDiagnosticItem(
'CoreAdminHome_TrackingFailures',
$this->urlForAction('trackingFailures'),
$order = 2);
$order = 2
);
}
}

Expand All @@ -64,11 +70,19 @@ public function configureTopMenu(MenuTop $menu)
$icon = ($newChangesStatus === ChangesModel::NEW_CHANGES_EXIST ? 'icon-notifications_on' : 'icon-reporting-actions');

$menu->registerMenuIcon('CoreAdminHome_WhatIsNew', $icon);
$menu->addItem('CoreAdminHome_WhatIsNew', null, 'javascript:', 990,
$menu->addItem(
'CoreAdminHome_WhatIsNew',
null,
'javascript:',
990,
Piwik::translate('CoreAdminHome_WhatIsNewTooltip'),
$icon, "Piwik_Popover.createPopupAndLoadUrl('module=CoreAdminHome&action=whatIsNew', '" .
$icon,
"Piwik_Popover.createPopupAndLoadUrl('module=CoreAdminHome&action=whatIsNew', '" .
addslashes(Piwik::translate('CoreAdminHome_WhatIsNewTooltip')) . "','what-is-new-popup')",
null, null, $userChanges->getNewChangesCount());
null,
null,
$userChanges->getNewChangesCount()
);
}
}
}
Expand Down
30 changes: 22 additions & 8 deletions plugins/CoreAdminHome/OptOutManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,15 @@ public function getOptOutSelfContainedEmbedCode(
window.MatomoConsent = { };
</script>
HTML;
return str_replace('window.MatomoConsent = { };', $this->getOptOutCommonJS(),
str_replace('style=""', ($applyStyling ? 'style="' . $styleSheet . '"' : ''),
str_replace("var settings = {};", $settingsString, $code)));
return str_replace(
'window.MatomoConsent = { };',
$this->getOptOutCommonJS(),
str_replace(
'style=""',
($applyStyling ? 'style="' . $styleSheet . '"' : ''),
str_replace("var settings = {};", $settingsString, $code)
)
);
}

/**
Expand Down Expand Up @@ -297,8 +303,10 @@ public function getOptOutJS(): string

// If the language parameter is 'auto' then use the browser language
if ($language === 'auto') {
$language = Common::extractLanguageAndRegionCodeFromBrowserLanguage(Common::getBrowserLanguage(),
APILanguagesManager::getInstance()->getAvailableLanguages());
$language = Common::extractLanguageAndRegionCodeFromBrowserLanguage(
Common::getBrowserLanguage(),
APILanguagesManager::getInstance()->getAvailableLanguages()
);
}

$settings = [
Expand Down Expand Up @@ -385,9 +393,15 @@ function showOptOutDirect() {
window.MatomoConsent = { };
JS;

return str_replace('window.MatomoConsent = { };', $this->getOptOutCommonJS(),
str_replace('stylecss', $styleSheet,
str_replace("var settings = {};", $settingsString, $code)));
return str_replace(
'window.MatomoConsent = { };',
$this->getOptOutCommonJS(),
str_replace(
'stylecss',
$styleSheet,
str_replace("var settings = {};", $settingsString, $code)
)
);
}

/**
Expand Down
Loading

0 comments on commit 127f508

Please sign in to comment.