detail pages for customers and projects (#1371)

This commit is contained in:
Kevin Papst
2020-01-16 16:25:28 +01:00
committed by GitHub
parent 28c5357f11
commit 6a44dbfe83
131 changed files with 3055 additions and 1742 deletions

View File

@@ -15,9 +15,9 @@ use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
/**
* A twig extension to handle markdown parser.
* A twig extension to handle markdown content.
*/
class MarkdownExtension extends AbstractExtension
final class MarkdownExtension extends AbstractExtension
{
/**
* @var Markdown
@@ -26,10 +26,9 @@ class MarkdownExtension extends AbstractExtension
/**
* @var TimesheetConfiguration
*/
protected $configuration;
private $configuration;
/**
* MarkdownExtension constructor.
* @param Markdown $parser
*/
public function __construct(Markdown $parser, TimesheetConfiguration $configuration)
@@ -46,10 +45,36 @@ class MarkdownExtension extends AbstractExtension
return [
new TwigFilter('md2html', [$this, 'markdownToHtml'], ['is_safe' => ['html']]),
new TwigFilter('desc2html', [$this, 'timesheetContent'], ['is_safe' => ['html']]),
new TwigFilter('comment2html', [$this, 'timesheetContent'], ['is_safe' => ['html']]),
new TwigFilter('comment2html', [$this, 'commentContent'], ['is_safe' => ['html']]),
];
}
/**
* Transforms the entities comment (customer, project, activity ...) into HTML.
*
* @param string $content
* @param bool $fullLength
* @return string
*/
public function commentContent(?string $content, bool $fullLength = false): string
{
if (empty($content)) {
return '';
}
if (!$fullLength && strlen($content) > 101) {
$content = trim(substr($content, 0, 100)) . ' …';
}
if ($this->configuration->isMarkdownEnabled()) {
$content = $this->markdown->toHtml($content, false);
} elseif ($fullLength) {
$content = '<p>' . nl2br($content) . '</p>';
}
return $content;
}
/**
* Transforms the timesheet description content into HTML.
*