diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..9ab59b180fb670006ac910a2bc4524a1376dcea0 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,15 @@ + +# Ignore developer files when exporting +.gitattributes export-ignore +.gitignore export-ignore +.gitlab-ci.yml export-ignore +.phive export-ignore +captainhook.json export-ignore +phpcs.xml.dist export-ignore +phpstan-baseline.neon export-ignore +phpstan.dist.neon export-ignore +phpunit.dist.xml export-ignore +tests export-ignore + +# Explicitly set file type and line endings for PHP files, improves git diff output +*.php text eol=lf diff=php \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..b9f7c5c4723a7ff60166164bae8afaeec189067a --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ + +tools/ + +phpstan.neon + +.phpunit.result.cache + +phpunit.xml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..958e6dbe58befe8c34f0133df3c67aea44810b20 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,19 @@ +include: + - component: dev.quiqqer.com/quiqqer/stabilization/ci-cd-components/quiqqer-package-bundle/quiqqer-package-bundle@2 + inputs: + quiqqer-major-version: 1 + +# Remove the entire phpunit-php8.1 block, to allow PHPUnit to run on PHP 8.1 in your pipeline +phpunit-php8.1: + rules: + - when: never + +# Remove the entire phpunit-php8.2 block, to allow PHPUnit to run on PHP 8.2 in your pipeline +phpunit-php8.2: + rules: + - when: never + +# Remove the entire phpunit-php8.3 block, to allow PHPUnit to run on PHP 8.3 in your pipeline +phpunit-php8.3: + rules: + - when: never \ No newline at end of file diff --git a/.phive/phars.xml b/.phive/phars.xml new file mode 100644 index 0000000000000000000000000000000000000000..5bfa092bfad10dad9d23240281a5a2041acb815b --- /dev/null +++ b/.phive/phars.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<phive xmlns="https://phar.io/phive"> + <phar name="phpstan" version="1.11.8" installed="1.11.8" location="./tools/phpstan" copy="false"/> + <phar name="phpunit" version="^10.5.20" installed="10.5.20" location="./tools/phpunit" copy="false"/> + <phar name="phpcs" version="^3.10.1" installed="3.10.1" location="./tools/phpcs" copy="false"/> + <phar name="phpcbf" version="^3.10.1" installed="3.10.1" location="./tools/phpcbf" copy="false"/> + <phar name="captainhook" version="^5.23.3" installed="5.23.3" location="./tools/captainhook" copy="false"/> +</phive> diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000000000000000000000000000000000..4a69a59b440e5beec561eca1e341509bd5a18688 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,3 @@ +# Contributing + +This package follows the [QUIQQER contribution guidelines](https://dev.quiqqer.com/quiqqer/stabilization/documentation/-/wikis/home). \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..57cd60a5af2567fefadef1c99f241dbbb207183d --- /dev/null +++ b/LICENSE @@ -0,0 +1 @@ +GPL-3.0+ \ No newline at end of file diff --git a/captainhook.json b/captainhook.json new file mode 100644 index 0000000000000000000000000000000000000000..3702e1a358868bedd5ff4c7eae40bb1abb589267 --- /dev/null +++ b/captainhook.json @@ -0,0 +1,13 @@ +{ + "pre-commit": { + "enabled": true, + "actions": [ + { + "action": "\\CaptainHook\\App\\Hook\\PHP\\Action\\Linting" + }, + { + "action": "composer test" + } + ] + } +} \ No newline at end of file diff --git a/composer.json b/composer.json index d79bfa466d0ab49d88aa14c67cb7a82697eafd37..e78e1188ad5958f6cd2b81551da92a79b19c9d98 100644 --- a/composer.json +++ b/composer.json @@ -1,34 +1,76 @@ { - "name": "quiqqer\/interview", - "type": "quiqqer-plugin", - "description": "Extension for blog and news plugin. This plugin adds some new attributes and provides new bricks.", - "license": "GPL-3.0+", - "authors": [ - { - "name": "Michael Danielczok", - "email": "michael@pcsg.de", - "homepage": "http:\/\/www.pcsg.de", - "role": "Developer" + "name": "quiqqer/interview", + "type": "quiqqer-plugin", + "description": "Extension for blog and news plugin. This plugin adds some new attributes and provides new bricks.", + "license": "GPL-3.0+", + "authors": [ + { + "name": "Michael Danielczok", + "email": "michael@pcsg.de", + "homepage": "http://www.pcsg.de", + "role": "Developer" + }, + { + "name": "Dominik Chrzanowski", + "email": "dominik.chrzanowski@gmail.com", + "role": "Developer" + } + ], + "support": { + "email": "support@pcsg.de" }, - { - "name": "Dominik Chrzanowski", - "email": "dominik.chrzanowski@gmail.com", - "role": "Developer" - } - ], - "support": { - "email": "support@pcsg.de" - }, - "require": { - "quiqqer\/quiqqer": ">=1.6|dev-master|dev-dev" - }, - "suggest": { - "quiqqer\/blog": "Create your own online diary. With the provided page types, managing and creating your own blog is no longer a problem.", - "quiqqer\/news": "News functionality for the QUIQQER system." - }, - "autoload": { - "psr-4": { - "QUI\\Interview\\": "src\/QUI\/Interview" + "require": { + "quiqqer/quiqqer": ">=1.6|dev-master|dev-dev" + }, + "suggest": { + "quiqqer/blog": "Create your own online diary. With the provided page types, managing and creating your own blog is no longer a problem.", + "quiqqer/news": "News functionality for the QUIQQER system." + }, + "autoload": { + "psr-4": { + "QUI\\Interview\\": "src/QUI/Interview" + } + }, + "scripts": { + "test": [ + "@dev:lint", + "@dev:phpunit" + ], + "dev:phpunit": "./tools/phpunit", + "dev:lint": [ + "@dev:lint:phpstan", + "@dev:lint:style" + ], + "dev:lint:phpstan": "./tools/phpstan", + "dev:lint:style": "./tools/phpcs", + "dev:lint:style:fix": "./tools/phpcbf", + "dev:init": [ + "@dev:init:check-requirements", + "@dev:init:tools", + "@dev:init:git-hooks" + ], + "dev:init:check-requirements": [ + "which composer > /dev/null || (echo 'Error: composer has to be globally installed'; exit 1)", + "which phive > /dev/null || (echo 'Error: PHIVE has to be globally installed'; exit 1)" + ], + "dev:init:tools": "phive install --temporary", + "dev:init:git-hooks": "./tools/captainhook install --only-enabled --force" + }, + "scripts-aliases": { + "test": [ + "dev:test" + ] + }, + "scripts-descriptions": { + "test": "Runs linting, static analysis, and unit tests.", + "dev:phpunit": "Run PHPUnit test suites", + "dev:lint": "Run PHPStan and code style check", + "dev:lint:phpstan": "Run PHPStan", + "dev:lint:style": "Run code style check (PHP_CodeSniffer)", + "dev:lint:style:fix": "Try to fix code style errors automatically", + "dev:init": "Initialize the developer tooling (tools and git hooks)", + "dev:init:check-requirements": "Check if the necessary requirements are met", + "dev:init:tools": "Install all developer tools (requires PHIVE)", + "dev:init:git-hooks": "Install all git hooks (may require tools to be installed)" } - } -} +} \ No newline at end of file diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000000000000000000000000000000000000..d48084fbdc86a2dbfb78dd89ab2e0b0ff2322ba7 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,23 @@ +<?xml version="1.0"?> +<ruleset> + <!-- Use PSR-12 ruleset --> + <rule ref="PSR12"/> + + <!-- Only scan *.php files --> + <arg name="extensions" value="php"/> + + <!-- Ignore warnings --> + <arg name="warning-severity" value="0"/> + + <!-- Process 64 (or number of CPU cores) files in parallel --> + <arg name="parallel" value="64"/> + + <!-- Output relative file paths, by setting the current folder as the basepath --> + <arg name="basepath" value="."/> + + <!-- Show colored output --> + <arg name="colors"/> + + <!-- Scan everything in the current folder --> + <file>.</file> +</ruleset> diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000000000000000000000000000000000000..364905f71489c1bf2c77d2bfe157d6c90f0ee4f2 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,2 @@ +parameters: + ignoreErrors: diff --git a/phpstan.dist.neon b/phpstan.dist.neon new file mode 100644 index 0000000000000000000000000000000000000000..58a61ffc72c1f40e0a78719bbd0039957efa3ccb --- /dev/null +++ b/phpstan.dist.neon @@ -0,0 +1,10 @@ +includes: + - phpstan-baseline.neon + +parameters: + level: 5 + paths: + - src + bootstrapFiles: + - tests/phpstan-bootstrap.php + tipsOfTheDay: false diff --git a/phpunit.dist.xml b/phpunit.dist.xml new file mode 100644 index 0000000000000000000000000000000000000000..f6c7becf0c12757beb871a9333e2d81e02aa7cae --- /dev/null +++ b/phpunit.dist.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<phpunit bootstrap="tests/phpunit-bootstrap.php"> + <testsuites> + <testsuite name="Tests"> + <directory>tests/</directory> + </testsuite> + </testsuites> +</phpunit> diff --git a/src/QUI/Interview/Controls/IntervieweeData.LargeImageLeft.html b/src/QUI/Interview/Controls/IntervieweeData.LargeImageLeft.html index 56bb75037ac4eeb4973357d5aca8ee1db95df33c..040676bba28543fc5ce494ae1bc4b0ff87ffcff8 100644 --- a/src/QUI/Interview/Controls/IntervieweeData.LargeImageLeft.html +++ b/src/QUI/Interview/Controls/IntervieweeData.LargeImageLeft.html @@ -11,6 +11,6 @@ </div> {if $description} - <div class="quiqqer-interview-control-interviewee-content-short">{$description}</div> + <div class="quiqqer-interview-control-interviewee-content-short default-content">{$description}</div> {/if} </div> \ No newline at end of file diff --git a/src/QUI/Interview/Controls/IntervieweeData.LargeImageTop.html b/src/QUI/Interview/Controls/IntervieweeData.LargeImageTop.html index acd960c138f958480ea4eb97d80cd9e7a8592d89..c68760984766d7c135d390d364533d05b5506825 100644 --- a/src/QUI/Interview/Controls/IntervieweeData.LargeImageTop.html +++ b/src/QUI/Interview/Controls/IntervieweeData.LargeImageTop.html @@ -9,6 +9,6 @@ </header> {if $description} - <div class="quiqqer-interview-control-interviewee-short">{$description}</div> + <div class="quiqqer-interview-control-interviewee-short default-content">{$description}</div> {/if} </div> \ No newline at end of file diff --git a/src/QUI/Interview/Controls/IntervieweeData.SmallImageLeft.html b/src/QUI/Interview/Controls/IntervieweeData.SmallImageLeft.html index 6a23210a23b9cff83ee79c7e102da81dc9a60efb..2d079136faafdaa982e0c80434e569b1e962edc0 100644 --- a/src/QUI/Interview/Controls/IntervieweeData.SmallImageLeft.html +++ b/src/QUI/Interview/Controls/IntervieweeData.SmallImageLeft.html @@ -12,7 +12,7 @@ <div class="quiqqer-interview-control-interviewee-content"> {if $description} - <div class="quiqqer-interview-control-interviewee-content-short">{$description}</div> + <div class="quiqqer-interview-control-interviewee-content-short default-content">{$description}</div> {/if} </div> </div> \ No newline at end of file diff --git a/src/QUI/Interview/Controls/IntervieweeData.html b/src/QUI/Interview/Controls/IntervieweeData.html index 45e0bfccc5d437333d11175e833eb796acb690ff..96b122e2a1994eaa3b2a1610ee588f7befc0ac32 100644 --- a/src/QUI/Interview/Controls/IntervieweeData.html +++ b/src/QUI/Interview/Controls/IntervieweeData.html @@ -5,7 +5,7 @@ {/if} {if $this->getAttribute('content') != ""} - <div class="control-body"> + <div class="control-body default-content"> {$this->getAttribute('content')} </div> {/if} diff --git a/src/QUI/Interview/Controls/IntervieweeData.php b/src/QUI/Interview/Controls/IntervieweeData.php index 2516905345167041ad6c9c1cb2b7dc541e02b0bc..d73c549b408825f6d3446eb85689e675aed73424 100644 --- a/src/QUI/Interview/Controls/IntervieweeData.php +++ b/src/QUI/Interview/Controls/IntervieweeData.php @@ -31,11 +31,11 @@ public function __construct($attributes = []) 'template' => 'largeImageTop' // template ]); - $this->addCSSFile(dirname(__FILE__).'/IntervieweeData.css'); + $this->addCSSFile(dirname(__FILE__) . '/IntervieweeData.css'); parent::__construct($attributes); - $this->setAttribute('cacheable', 0); + $this->setAttribute('cacheable', "0"); } /** @@ -43,13 +43,15 @@ public function __construct($attributes = []) * * @see \QUI\Control::create() */ - public function getBody() + public function getBody(): string { $Engine = QUI::getTemplateManager()->getEngine(); $Site = $this->getSite(); - if ($Site->getAttribute("type") !== 'quiqqer/blog:blog/entry' && - $Site->getAttribute("type") !== 'quiqqer/news:news/entry') { + if ( + $Site->getAttribute("type") !== 'quiqqer/blog:blog/entry' && + $Site->getAttribute("type") !== 'quiqqer/news:news/entry' + ) { return ''; } @@ -82,9 +84,9 @@ public function getBody() 'description' => $intervieweeData['description'] ]); - $Engine->assign('controlTemplate', $Engine->fetch(dirname(__FILE__).$html)); + $Engine->assign('controlTemplate', $Engine->fetch(dirname(__FILE__) . $html)); - return $Engine->fetch(dirname(__FILE__).'/IntervieweeData.html'); + return $Engine->fetch(dirname(__FILE__) . '/IntervieweeData.html'); } /** diff --git a/tests/phpstan-bootstrap.php b/tests/phpstan-bootstrap.php new file mode 100644 index 0000000000000000000000000000000000000000..b61ff4b8300a965e0f46025ba64745a22b118e74 --- /dev/null +++ b/tests/phpstan-bootstrap.php @@ -0,0 +1,13 @@ +<?php + +if (!defined('QUIQQER_SYSTEM')) { + define('QUIQQER_SYSTEM', true); +} + +if (!defined('QUIQQER_AJAX')) { + define('QUIQQER_AJAX', true); +} + +putenv("QUIQQER_OTHER_AUTOLOADERS=KEEP"); + +require_once __DIR__ . '/../../../../bootstrap.php'; diff --git a/tests/phpunit-bootstrap.php b/tests/phpunit-bootstrap.php new file mode 100644 index 0000000000000000000000000000000000000000..eca92fd67bed8ae4ec424ed82d300119d792f042 --- /dev/null +++ b/tests/phpunit-bootstrap.php @@ -0,0 +1,11 @@ +<?php + +if (!defined('QUIQQER_SYSTEM')) { + define('QUIQQER_SYSTEM', true); +} + +if (!defined('QUIQQER_AJAX')) { + define('QUIQQER_AJAX', true); +} + +require_once __DIR__ . '/../../../../bootstrap.php';