PSR 2 compliance
This commit is contained in:
parent
472e254a5f
commit
e7321ef146
|
@ -5,7 +5,7 @@ const Post = function(w) {
|
|||
Post.prototype.commentsEvents = function() {
|
||||
var document = this.window.document;
|
||||
|
||||
var parentCommentIdField = document.getElementById('comment_parentCommentId');
|
||||
var parentCommentIdField = document.getElementById('user_comment_parentCommentId');
|
||||
|
||||
if (!parentCommentIdField) {
|
||||
return;
|
||||
|
|
|
@ -2,16 +2,15 @@
|
|||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Core\Manager\EntityManager;
|
||||
use App\Entity\Blog\Category;
|
||||
use App\Entity\Blog\Comment;
|
||||
use App\Entity\Blog\Post;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use App\Core\Manager\EntityManager;
|
||||
use App\Entity\Blog\Category;
|
||||
use App\Entity\Blog\Comment;
|
||||
use App\Entity\Blog\Post;
|
||||
|
||||
class MigrateDataCommand extends Command
|
||||
{
|
||||
|
|
|
@ -2,15 +2,11 @@
|
|||
|
||||
namespace App\Controller\Blog;
|
||||
|
||||
use App\Core\Annotation\UrlGenerator;
|
||||
use App\Core\Controller\Site\PageController;
|
||||
use App\Core\Site\SiteRequest;
|
||||
use App\Entity\Blog\Category;
|
||||
use App\Entity\Blog\Post;
|
||||
use App\Repository\Blog\CategoryRepositoryQuery;
|
||||
use App\UrlGenerator\PostGenerator;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use App\Core\Site\SiteStore;
|
||||
use App\Repository\Blog\CategoryRepositoryQuery;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class CategoryController extends PageController
|
||||
{
|
||||
|
|
|
@ -7,14 +7,13 @@ use App\Core\Form\FileUploadHandler;
|
|||
use App\Core\Manager\EntityManager;
|
||||
use App\Entity\Blog\Post as Entity;
|
||||
use App\Factory\Blog\PostFactory as EntityFactory;
|
||||
use App\Form\Blog\Filter\PostFilterType;
|
||||
use App\Form\Blog\PostType as EntityType;
|
||||
use App\Repository\Blog\PostRepositoryQuery as RepositoryQuery;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
|
||||
use App\Form\Blog\Filter\PostFilterType;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
/**
|
||||
* @Route("/admin/blog/post")
|
||||
|
@ -33,7 +32,8 @@ class PostAdminController extends AdminController
|
|||
$pager = $query
|
||||
->orderBy('.id', 'DESC')
|
||||
->useFilters($this->filters)
|
||||
->paginate($page);
|
||||
->paginate($page)
|
||||
;
|
||||
|
||||
return $this->render('blog/post_admin/index.html.twig', [
|
||||
'pager' => $pager,
|
||||
|
@ -143,12 +143,17 @@ class PostAdminController extends AdminController
|
|||
return $this->redirectToRoute('admin_blog_post_index');
|
||||
}
|
||||
|
||||
public function getSection(): string
|
||||
{
|
||||
return 'blog_post';
|
||||
}
|
||||
|
||||
protected function updateFilters(Request $request, Session $session)
|
||||
{
|
||||
if ($request->query->has('post_filter')) {
|
||||
$filters = $request->query->get('post_filter');
|
||||
|
||||
if ($filters === '0') {
|
||||
if ('0' === $filters) {
|
||||
$filters = [];
|
||||
}
|
||||
} elseif ($session->has('post_filter')) {
|
||||
|
@ -168,9 +173,4 @@ class PostAdminController extends AdminController
|
|||
$session->set('post_filter', $this->filters);
|
||||
}
|
||||
}
|
||||
|
||||
public function getSection(): string
|
||||
{
|
||||
return 'blog_post';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,8 @@
|
|||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use App\Core\Controller\Site\PageController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class BotController extends PageController
|
||||
{
|
||||
|
|
|
@ -2,13 +2,11 @@
|
|||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use App\Core\Controller\Site\PageController;
|
||||
use App\Form\ContactType;
|
||||
use App\Core\Notification\MailNotifier;
|
||||
use App\Form\ContactType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class ContactController extends PageController
|
||||
{
|
||||
|
@ -30,7 +28,8 @@ class ContactController extends PageController
|
|||
->setReplyTo($data['email'])
|
||||
->notify('mail/contact.html.twig', [
|
||||
'message' => $data,
|
||||
], 'text/plain');
|
||||
], 'text/plain')
|
||||
;
|
||||
|
||||
$this->addFlash(
|
||||
'success',
|
||||
|
|
|
@ -2,15 +2,13 @@
|
|||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use App\Api\TTRssClient;
|
||||
use App\Core\Controller\Site\PageController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class LinkController extends PageController
|
||||
{
|
||||
public function links(TTRssClient $client, int $page = 1): Response
|
||||
public function links(TTRssClient $client, int $page = 1): Response
|
||||
{
|
||||
return $this->defaultRender($this->siteRequest->getPage()->getTemplate(), [
|
||||
'pager' => $client->getPager($page),
|
||||
|
|
|
@ -9,8 +9,6 @@ class Configuration implements ConfigurationInterface
|
|||
{
|
||||
public function getConfigTreeBuilder(): TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('app');
|
||||
|
||||
return $treeBuilder;
|
||||
return new TreeBuilder('app');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,7 @@
|
|||
|
||||
namespace App\Entity\Page;
|
||||
|
||||
use App\Core\Entity\Site\Page\Block;
|
||||
use App\Core\Entity\Site\Page\FileBlock;
|
||||
use App\Core\Entity\Site\Page\Page;
|
||||
use App\Core\Form\Site\Page\ImageBlockType;
|
||||
use App\Core\Form\Site\Page\TextareaBlockType;
|
||||
use App\Core\Form\Site\Page\TextBlockType;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
|
|
|
@ -2,14 +2,7 @@
|
|||
|
||||
namespace App\Entity\Page;
|
||||
|
||||
use App\Core\Entity\Site\Page\Block;
|
||||
use App\Core\Entity\Site\Page\FileBlock;
|
||||
use App\Core\Entity\Site\Page\Page;
|
||||
use App\Core\Form\Site\Page\ImageBlockType;
|
||||
use App\Core\Form\Site\Page\TextareaBlockType;
|
||||
use App\Core\Form\Site\Page\TextBlockType;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
|
|
|
@ -4,10 +4,7 @@ namespace App\Entity\Page;
|
|||
|
||||
use App\Core\Entity\Site\Page\Block;
|
||||
use App\Core\Entity\Site\Page\FileBlock;
|
||||
use App\Core\Entity\Site\Page\Page;
|
||||
use App\Core\Form\Site\Page\ImageBlockType;
|
||||
use App\Core\Form\Site\Page\TextareaBlockType;
|
||||
use App\Core\Form\Site\Page\TextBlockType;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
|
|
|
@ -3,10 +3,7 @@
|
|||
namespace App\Entity\Page;
|
||||
|
||||
use App\Core\Entity\Site\Page\Block;
|
||||
use App\Core\Entity\Site\Page\FileBlock;
|
||||
use App\Core\Entity\Site\Page\Page;
|
||||
use App\Core\Form\Site\Page\ImageBlockType;
|
||||
use App\Core\Form\Site\Page\TextareaBlockType;
|
||||
use App\Core\Form\Site\Page\TextBlockType;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
|
|
@ -5,8 +5,6 @@ namespace App\Entity;
|
|||
use App\Core\Doctrine\Timestampable;
|
||||
use App\Core\Entity\EntityInterface;
|
||||
use App\Repository\UserRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Scheb\TwoFactorBundle\Model\Google\TwoFactorInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
|
|
@ -5,12 +5,8 @@ namespace App\EventSuscriber\Blog;
|
|||
use App\Core\Entity\EntityInterface;
|
||||
use App\Core\Event\EntityManager\EntityManagerEvent;
|
||||
use App\Core\EventSuscriber\EntityManagerEventSubscriber;
|
||||
use App\Entity\Blog\Post;
|
||||
use App\Repository\Blog\PostRepositoryQuery;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use App\Entity\Blog\Category;
|
||||
use App\Core\Slugify\Slugify;
|
||||
use App\Entity\Blog\Category;
|
||||
|
||||
/**
|
||||
* class CategoryEventSubscriber.
|
||||
|
|
|
@ -5,11 +5,11 @@ namespace App\EventSuscriber\Blog;
|
|||
use App\Core\Entity\EntityInterface;
|
||||
use App\Core\Event\EntityManager\EntityManagerEvent;
|
||||
use App\Core\EventSuscriber\EntityManagerEventSubscriber;
|
||||
use App\Core\Slugify\Slugify;
|
||||
use App\Entity\Blog\Post;
|
||||
use App\Repository\Blog\PostRepositoryQuery;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use App\Core\Slugify\Slugify;
|
||||
|
||||
/**
|
||||
* class PostEventSubscriber.
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Factory\Blog;
|
||||
|
||||
use App\Entity\Blog\Post;
|
||||
use App\Entity\User;
|
||||
|
||||
/**
|
||||
* class PostFactory.
|
||||
|
|
|
@ -4,12 +4,12 @@ namespace App\Form\Blog;
|
|||
|
||||
use App\Entity\Blog\Category;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
|
||||
class CategoryType extends AbstractType
|
||||
{
|
||||
|
@ -81,7 +81,6 @@ class CategoryType extends AbstractType
|
|||
],
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
|
|
|
@ -3,25 +3,13 @@
|
|||
namespace App\Form\Blog\Filter;
|
||||
|
||||
use App\Entity\Blog\Category;
|
||||
use App\Entity\Blog\Post;
|
||||
use App\Entity\User;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\Date;
|
||||
use Symfony\Component\Validator\Constraints\Image;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||
use Symfony\Component\Validator\Constraints\Range;
|
||||
use Symfony\Component\Validator\Constraints\Url;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
|
||||
class PostFilterType extends AbstractType
|
||||
{
|
||||
|
@ -107,7 +95,7 @@ class PostFilterType extends AbstractType
|
|||
'attr' => [
|
||||
],
|
||||
'constraints' => [
|
||||
]
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -4,26 +4,22 @@ namespace App\Form\Blog;
|
|||
|
||||
use App\Entity\Blog\Category;
|
||||
use App\Entity\Blog\Post;
|
||||
use App\Entity\User;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\Date;
|
||||
use Symfony\Component\Validator\Constraints\Image;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||
use Symfony\Component\Validator\Constraints\Range;
|
||||
use Symfony\Component\Validator\Constraints\Url;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Validator\Constraints\DateTime;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
|
||||
|
||||
class PostType extends AbstractType
|
||||
{
|
||||
|
@ -178,7 +174,7 @@ class PostType extends AbstractType
|
|||
'attr' => [
|
||||
],
|
||||
'constraints' => [
|
||||
]
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
namespace App\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Constraints\Email;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\Email;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
class ContactType extends AbstractType
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ class Comment extends MarkdownParser
|
|||
/**
|
||||
* @var array Enabled features
|
||||
*/
|
||||
protected $features = array(
|
||||
protected $features = [
|
||||
'header' => true,
|
||||
'list' => true,
|
||||
'horizontal_rule' => false,
|
||||
|
@ -34,15 +34,17 @@ class Comment extends MarkdownParser
|
|||
'auto_mailto' => false,
|
||||
'entities' => false,
|
||||
'no_html' => true,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Disable mailto unless auto_mailto.
|
||||
*
|
||||
* @param mixed $text
|
||||
*/
|
||||
public function doAutoLinks($text)
|
||||
{
|
||||
if (!$this->features['auto_mailto']) {
|
||||
return preg_replace_callback('{((https?|ftp|dict):[^\'">\s]+)}i', array(&$this, '_doAutoLinks_url_callback'), $text);
|
||||
return preg_replace_callback('{((https?|ftp|dict):[^\'">\s]+)}i', [&$this, '_doAutoLinks_url_callback'], $text);
|
||||
}
|
||||
|
||||
return parent::doAutoLinks($text);
|
||||
|
@ -57,18 +59,18 @@ class Comment extends MarkdownParser
|
|||
*/
|
||||
protected function _doHeaders_callback_setext($matches)
|
||||
{
|
||||
if ($matches[3] == '-' && preg_match('{^- }', $matches[1])) {
|
||||
if ('-' == $matches[3] && preg_match('{^- }', $matches[1])) {
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
$level = $matches[3][0] == '=' ? 1 : 2;
|
||||
$level = '=' == $matches[3][0] ? 1 : 2;
|
||||
|
||||
$level += 2;
|
||||
|
||||
$defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[1]) : null;
|
||||
|
||||
$attr = $this->doExtraAttributes("h$level", $dummy = &$matches[2], $defaultId);
|
||||
$block = "<div class=\"h$level\" $attr>".$this->runSpanGamut($matches[1]).'</div>';
|
||||
$attr = $this->doExtraAttributes("h{$level}", $dummy = &$matches[2], $defaultId);
|
||||
$block = "<div class=\"h{$level}\" {$attr}>".$this->runSpanGamut($matches[1]).'</div>';
|
||||
|
||||
return "\n".$this->hashBlock($block)."\n\n";
|
||||
}
|
||||
|
@ -85,9 +87,9 @@ class Comment extends MarkdownParser
|
|||
$level = strlen($matches[1]);
|
||||
|
||||
$defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[2]) : null;
|
||||
$attr = $this->doExtraAttributes("h$level", $dummy = &$matches[3], $defaultId);
|
||||
$attr = $this->doExtraAttributes("h{$level}", $dummy = &$matches[3], $defaultId);
|
||||
$level += 2;
|
||||
$block = "<div class=\"h$level\" $attr>".$this->runSpanGamut($matches[2]).'</div>';
|
||||
$block = "<div class=\"h{$level}\" {$attr}>".$this->runSpanGamut($matches[2]).'</div>';
|
||||
|
||||
return "\n".$this->hashBlock($block)."\n\n";
|
||||
}
|
||||
|
|
|
@ -23,15 +23,14 @@ class Post extends MarkdownParser
|
|||
public function transformMarkdown($text)
|
||||
{
|
||||
$html = parent::transformMarkdown($text);
|
||||
$html = str_replace(' role="doc-endnote"', '', $html);
|
||||
|
||||
return $html;
|
||||
return str_replace(' role="doc-endnote"', '', $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doExtraAttributes($tag_name, $attr, $defaultIdValue = null, $classes = array())
|
||||
protected function doExtraAttributes($tag_name, $attr, $defaultIdValue = null, $classes = [])
|
||||
{
|
||||
if (empty($attr) && !$defaultIdValue && empty($classes)) {
|
||||
return '';
|
||||
|
@ -42,13 +41,13 @@ class Post extends MarkdownParser
|
|||
$elements = $matches[0];
|
||||
|
||||
// Handle classes and IDs (only first ID taken into account)
|
||||
$attributes = array();
|
||||
$attributes = [];
|
||||
$id = false;
|
||||
foreach ($elements as $element) {
|
||||
if ($element{0} == '.') {
|
||||
if ('.' == $element[0]) {
|
||||
$classes[] = substr($element, 1);
|
||||
} elseif ($element{0} == '#') {
|
||||
if ($id === false) {
|
||||
} elseif ('#' == $element[0]) {
|
||||
if (false === $id) {
|
||||
$id = substr($element, 1);
|
||||
}
|
||||
}
|
||||
|
@ -104,11 +103,11 @@ class Post extends MarkdownParser
|
|||
);
|
||||
|
||||
$codeblock = preg_replace_callback('/^\n+/',
|
||||
array($this, '_doFencedCodeBlocks_newlines'), $codeblock);
|
||||
[$this, '_doFencedCodeBlocks_newlines'], $codeblock);
|
||||
|
||||
$classes = array();
|
||||
if ($classname != '') {
|
||||
if ($classname{0} == '.') {
|
||||
$classes = [];
|
||||
if ('' != $classname) {
|
||||
if ('.' == $classname[0]) {
|
||||
$classname = substr($classname, 1);
|
||||
}
|
||||
$classes[] = $this->code_class_prefix.$classname;
|
||||
|
@ -116,7 +115,7 @@ class Post extends MarkdownParser
|
|||
$attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? 'pre' : 'code', $attrs, null, $classes);
|
||||
$pre_attr_str = $this->code_attr_on_pre ? $attr_str : '';
|
||||
$code_attr_str = $this->code_attr_on_pre ? '' : $attr_str;
|
||||
$codeblock = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>";
|
||||
$codeblock = "<pre{$pre_attr_str}><code{$code_attr_str}>{$codeblock}</code></pre>";
|
||||
|
||||
return "\n\n".$this->hashBlock($codeblock)."\n\n";
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ namespace App\Repository\Blog;
|
|||
use App\Entity\Blog\Post;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use App\Core\Manager\EntityManager;
|
||||
|
||||
class PostRepository extends ServiceEntityRepository
|
||||
{
|
||||
|
|
|
@ -14,10 +14,10 @@ class BlogExtension extends AbstractExtension
|
|||
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
new TwigFilter('comment', [$this, 'comment'], array('is_safe' => array('html'))),
|
||||
new TwigFilter('post', [$this, 'post'], array('is_safe' => array('html'))),
|
||||
);
|
||||
return [
|
||||
new TwigFilter('comment', [$this, 'comment'], ['is_safe' => ['html']]),
|
||||
new TwigFilter('post', [$this, 'post'], ['is_safe' => ['html']]),
|
||||
];
|
||||
}
|
||||
|
||||
public function comment($text)
|
||||
|
@ -48,11 +48,12 @@ class BlogExtension extends AbstractExtension
|
|||
function ($data) {
|
||||
if (preg_match('`^[ ]+`', $data[1])) {
|
||||
return '<p'.$data[1].'>'.nl2br(trim($data[2])).'</p>';
|
||||
} elseif (isset($data[1]) && $data[1] === '') {
|
||||
return '<p>'.nl2br(trim($data[2])).'</p>';
|
||||
} else {
|
||||
return $data[0];
|
||||
}
|
||||
if (isset($data[1]) && '' === $data[1]) {
|
||||
return '<p>'.nl2br(trim($data[2])).'</p>';
|
||||
}
|
||||
|
||||
return $data[0];
|
||||
},
|
||||
$text
|
||||
);
|
||||
|
@ -86,7 +87,7 @@ class BlogExtension extends AbstractExtension
|
|||
'`<object(.*)/object>`isU',
|
||||
'`smiley:([a-zA-Z]*)`is',
|
||||
'#<couper>#isU',
|
||||
"#onclick='window\.open\(this\.href\); return false'#",
|
||||
"#onclick='window\\.open\\(this\\.href\\); return false'#",
|
||||
'#<timestamp>#isU',
|
||||
'#<timestamp>#isU',
|
||||
] as $regex) {
|
||||
|
@ -128,20 +129,19 @@ class BlogExtension extends AbstractExtension
|
|||
}, $text);
|
||||
|
||||
$text = preg_replace_callback(
|
||||
array(
|
||||
[
|
||||
'#<code langage="([^"]*)">(.*)</code>#isU',
|
||||
'#<code langage=\'([^\']*)\'>(.*)</code>#isU',
|
||||
),
|
||||
],
|
||||
function ($data) {
|
||||
$lang = strtolower(str_replace(
|
||||
array('console', 'texte', 'apache'),
|
||||
array('bash', 'text', 'html'),
|
||||
['console', 'texte', 'apache'],
|
||||
['bash', 'text', 'html'],
|
||||
$data[1])
|
||||
);
|
||||
$class = 'language-'.$lang;
|
||||
$html = sprintf('<pre><code class="%s">%s</code></pre>', $class, trim(htmlentities($data[2])));
|
||||
|
||||
return $html;
|
||||
return sprintf('<pre><code class="%s">%s</code></pre>', $class, trim(htmlentities($data[2])));
|
||||
},
|
||||
$text
|
||||
);
|
||||
|
@ -163,7 +163,7 @@ class BlogExtension extends AbstractExtension
|
|||
|
||||
$elements = explode('|', $line);
|
||||
|
||||
if (count($elements) === 2 || count($elements) === 3) {
|
||||
if (2 === count($elements) || 3 === count($elements)) {
|
||||
$pictures[] = sprintf(
|
||||
'<li><a href="%1$s" target="_blank"><img class="border" src="%2$s" alt="%3$s" title="%3$s"></a></li>',
|
||||
$elements[0],
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Twig\Extension;
|
||||
|
||||
use Twig\TwigFilter;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFilter;
|
||||
|
||||
/**
|
||||
* class LazyLoadExtension.
|
||||
|
|
Loading…
Reference in New Issue