Skip to content

Commit

Permalink
Merge branch 'develop' into 195-make-the-slugs-of-singles-editable-by…
Browse files Browse the repository at this point in the history
…-content-manager
  • Loading branch information
janhenckens committed Mar 21, 2024
2 parents 60c7ab3 + 2f65cc6 commit 3cd7108
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 23 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: ci
on:
workflow_dispatch:
push:
branches: [ develop ]
pull_request:
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
ci:
name: ci
uses: statikbe/.github/.github/workflows/ci.yml@main
with:
craft_version: '4'
jobs: '["ecs"]'
php_version: '8.2'
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
18 changes: 9 additions & 9 deletions modules/statik/src/Statik.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
use modules\statik\variables\StatikVariable;
use modules\statik\web\twig\HyperExtension;
use modules\statik\web\twig\HyphenateExtension;
use modules\statik\web\twig\IconExtension;
use modules\statik\web\twig\PaginateExtension;
use modules\statik\web\twig\ValidateInputExtension;
use modules\statik\web\twig\StatikExtension;
use modules\statik\web\twig\IconExtension;
use modules\statik\web\twig\ValidateInputExtension;
use verbb\formie\events\RegisterFieldsEvent;
use verbb\formie\fields\formfields;
use yii\base\Event;
Expand Down Expand Up @@ -71,7 +71,7 @@ public function __construct($id, $parent = null, array $config = [])
}

// Base template directory
Event::on(View::class, View::EVENT_REGISTER_CP_TEMPLATE_ROOTS, function (RegisterTemplateRootsEvent $e) {
Event::on(View::class, View::EVENT_REGISTER_CP_TEMPLATE_ROOTS, function(RegisterTemplateRootsEvent $e) {
if (is_dir($baseDir = $this->getBasePath() . DIRECTORY_SEPARATOR . 'templates')) {
$e->roots[$this->id] = $baseDir;
}
Expand All @@ -97,7 +97,7 @@ public function init(): void
}

// Register our variables
Event::on(CraftVariable::class, CraftVariable::EVENT_INIT, function (Event $event) {
Event::on(CraftVariable::class, CraftVariable::EVENT_INIT, function(Event $event) {
/** @var CraftVariable $variable */
$variable = $event->sender;
$variable->set('statik', StatikVariable::class);
Expand All @@ -111,22 +111,22 @@ public function init(): void
Craft::$app->view->registerTwigExtension(new StatikExtension());
Craft::$app->view->registerTwigExtension(new PaginateExtension());

Event::on(Assets::class, Assets::EVENT_SET_FILENAME, function (SetAssetFilenameEvent $event) {
Event::on(Assets::class, Assets::EVENT_SET_FILENAME, function(SetAssetFilenameEvent $event) {
$event->extension = mb_strtolower($event->extension);
});

if (Craft::$app->getRequest()->getIsCpRequest()) {
Event::on(View::class, View::EVENT_BEFORE_RENDER_TEMPLATE, function (TemplateEvent $event) {
Event::on(View::class, View::EVENT_BEFORE_RENDER_TEMPLATE, function(TemplateEvent $event) {
Craft::$app->getView()->registerAssetBundle(StatikAsset::class);
});
}

// Register our fields
Event::on(Fields::class, Fields::EVENT_REGISTER_FIELD_TYPES, function (RegisterComponentTypesEvent $event) {
Event::on(Fields::class, Fields::EVENT_REGISTER_FIELD_TYPES, function(RegisterComponentTypesEvent $event) {
$event->types[] = AnchorLink::class;
});

Event::on(\verbb\formie\services\Fields::class, \verbb\formie\services\Fields::EVENT_REGISTER_FIELDS, function (RegisterFieldsEvent $event) {
Event::on(\verbb\formie\services\Fields::class, \verbb\formie\services\Fields::EVENT_REGISTER_FIELDS, function(RegisterFieldsEvent $event) {
$excludedFields = [
formfields\Address::class,
formfields\Group::class,
Expand All @@ -146,7 +146,7 @@ public function init(): void
$event->fields = array_values($event->fields);
});

Event::on(Cp::class, Cp::EVENT_REGISTER_CP_NAV_ITEMS, function (RegisterCpNavItemsEvent $event) {
Event::on(Cp::class, Cp::EVENT_REGISTER_CP_NAV_ITEMS, function(RegisterCpNavItemsEvent $event) {
if (Craft::$app->getConfig()->getGeneral()->allowAdminChanges) {
$event->navItems[] = [
'url' => 'settings/fields',
Expand Down
2 changes: 1 addition & 1 deletion modules/statik/src/console/controllers/SetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private function setProjectCode(): void
// Replace self::PROJECT_CODE_PLACEHOLDER in htaccess-staging and htaccess-production
$this->replaceInFile(Craft::$app->path->getConfigPath() . '/htaccess-staging', $newProjectCode);
$this->replaceInFile(Craft::$app->path->getConfigPath() . '/htaccess-production', $newProjectCode);
foreach(self::DEPLOY_FILES as $deployFile) {
foreach (self::DEPLOY_FILES as $deployFile) {
$this->replaceInFile($deployFile, $newProjectCode);
}
}
Expand Down
3 changes: 1 addition & 2 deletions modules/statik/src/web/twig/HyperExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace modules\statik\web\twig;

use Craft;
use craft\web\View;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
use craft\web\View;
use verbb\hyper\models\LinkCollection;

class HyperExtension extends AbstractExtension
Expand Down Expand Up @@ -44,5 +44,4 @@ public function renderHyperLinks(LinkCollection $cta, array $options = []): stri

return $html;
}

}
3 changes: 1 addition & 2 deletions modules/statik/src/web/twig/HyphenateExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Craft;
use craft\elements\Asset;
use craft\helpers\ElementHelper;
use Twig\Extension\AbstractExtension;
use Twig\Markup;
use Twig\TwigFilter;
Expand All @@ -25,7 +24,7 @@ public function hyphenate(string|Asset $source, array $attributes = []): Markup

$output = Craft::$app->getCache()->getOrSet(
"hypen-" . base64_encode($source),
function () use ($source, $minimumWordLength) {
function() use ($source, $minimumWordLength) {
$source = preg_replace('/&(?!amp)/', '&', $source);
$language = strtolower(explode('-', Craft::$app->language)[0]);
$language = $language === 'en' ? 'en-us' : $language;
Expand Down
5 changes: 2 additions & 3 deletions modules/statik/src/web/twig/PaginateExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace modules\statik\web\twig;

use Craft;
use craft\web\twig\variables\Paginate;
use craft\web\View;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
use craft\web\View;
use craft\web\twig\variables\Paginate;

class PaginateExtension extends AbstractExtension
{
Expand Down Expand Up @@ -36,5 +36,4 @@ public function paginate(Paginate $pageInfo, array $options = []): string
'options' => $options,
], View::TEMPLATE_MODE_SITE);
}

}
4 changes: 2 additions & 2 deletions modules/statik/src/web/twig/StatikExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace modules\statik\web\twig;

use craft\elements\Entry;
use craft\helpers\ElementHelper;
use Jaybizzle\CrawlerDetect\CrawlerDetect;
use Twig\Extension\AbstractExtension;
use Twig\Extension\GlobalsInterface;
use Twig\TwigFilter;
use Twig\TwigFunction;
use craft\elements\Entry;
use craft\helpers\ElementHelper;

class StatikExtension extends AbstractExtension implements GlobalsInterface
{
Expand Down
7 changes: 3 additions & 4 deletions modules/statik/src/web/twig/ValidateInputExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public function validateIdInput(null|array|string $input): bool
return false;
}

if(!is_array($input)) {
if (!is_array($input)) {
return is_numeric($input);
}

foreach($input as $value) {
foreach ($input as $value) {
if (!$this->validateIdInput($value)) {
return false;
}
Expand All @@ -50,13 +50,12 @@ public function validateQueryInput(null|array|string $input): bool
return preg_match(self::COMMON_QUERY_CHARACTERS_REGEX, $input);
}

foreach($input as $value) {
foreach ($input as $value) {
if (!$this->validateQueryInput($value)) {
return false;
}
}

return true;
}

}

0 comments on commit 3cd7108

Please sign in to comment.