From 0133519da23bf33cd9c2d4bf84f0dc564b30cfbb Mon Sep 17 00:00:00 2001 From: Milan Felix Sulc Date: Thu, 11 Feb 2016 13:01:03 +0100 Subject: [PATCH] Addon\Detail: dont link php & php extension to packagist [closes #42] --- app/config/app/latte.neon | 1 + app/core/latte/Filters.php | 21 +++++++++++++++++++ .../AddonDetail/templates/sidebar.latte | 7 ++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/config/app/latte.neon b/app/config/app/latte.neon index d275c5bf..3c59165a 100644 --- a/app/config/app/latte.neon +++ b/app/config/app/latte.neon @@ -7,3 +7,4 @@ services: - addFilter('timeAgo', ['App\Core\Latte\Filters', 'timeAgo']) - addFilter('datetime', ['App\Core\Latte\Filters', 'datetime']) - addFilter('shields', ['App\Core\Latte\Filters', 'shields']) + - addFilter('isPhpDependency', ['App\Core\Latte\Filters', 'isPhpDependency']) diff --git a/app/core/latte/Filters.php b/app/core/latte/Filters.php index a6dbc4f3..e5e16cf0 100644 --- a/app/core/latte/Filters.php +++ b/app/core/latte/Filters.php @@ -3,6 +3,7 @@ namespace App\Core\Latte; use Nette\Utils\DateTime; +use Nette\Utils\Strings; final class Filters { @@ -96,4 +97,24 @@ public static function shields($name) return $name; } + /** + * @param string $name + * @return bool + */ + public static function isPhpDependency($name) + { + $blacklist = [ + 'php', + 'ext-\w' + ]; + + foreach ($blacklist as $regex) { + if (Strings::match($name, "#$regex#")) { + return TRUE; + } + } + + return FALSE; + } + } diff --git a/app/modules/front/controls/AddonDetail/templates/sidebar.latte b/app/modules/front/controls/AddonDetail/templates/sidebar.latte index f52e1571..e7034fe0 100644 --- a/app/modules/front/controls/AddonDetail/templates/sidebar.latte +++ b/app/modules/front/controls/AddonDetail/templates/sidebar.latte @@ -73,7 +73,12 @@
Requirements
{/if}