Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins / Extensions #13

Open
MioVisman opened this issue Feb 25, 2023 · 2 comments
Open

Plugins / Extensions #13

MioVisman opened this issue Feb 25, 2023 · 2 comments

Comments

@MioVisman
Copy link
Member

Какие варианты? / What are the options?

Вариантов у меня, кот наплакал / I have few options:

  1. Хуки / Hooks:
    Отрицательная сторона - нужно добавить в код множество вызовом хуков и все эти вызовы стандартизировать / The negative side is that you need to add a lot of hook calls to the code and standardize all these calls;
  2. Наследование / Object Inheritance:
    Расширения содержат измененные классы, эти классы регистрируются в конфиге движка вместо базовых классов / Extensions contain modified classes, these classes are registered in the engine config instead of base classes;
    Сразу вижу проблему - два расширения изменяющие один класс будут несовместимы между собой / I immediately see the problem - two extensions that change one class will be incompatible with each other;

Есть идеи? / Any ideas?

@dragomano
Copy link

  1. Множество хуков и их стандартизация — совсем не отрицательная сторона. Приведу в качестве примера Wedge и дополнения к нему — они работают с помощью хуков, устанавливаются простым копированием папки плагина в папку plugins и включаются по кнопке:
    sshot-3

  2. Если применять абстрактные классы и интерфейсы, то проблемы быть не должно. Например, в случае 2 плагинов, изменяющих оформление поста форума (например, один плагин делает фоновый цвет красным, а другой — синим), действовать будет только тот, который админ выберет в настройках, а не оба сразу, иначе смысла не будет (какой фон должен быть в случае работы сразу 2 плагинов - красно-синий что-ли? — либо в зависимости от плагина, включаемого последним).

@MioVisman
Copy link
Member Author

MioVisman commented Oct 11, 2023

Для шаблонов решил использовать метки вида <!-- PRE имя --> на место которых будут вставляться "подшаблоны" зарегистрированные при установке расширений или метки будут удаляться, если таких "подшаблонов" не зарегистрировано.
Все это будет выполнятся на момент компиляции шаблонов, а не в момент вывода страниц.

For templates, I decided to use labels like in place of which “subtemplates” registered when installing extensions will be inserted, or labels will be deleted if such “subtemplates” are not registered.
All this will be performed at the time of template compilation, and not at the time of page output.

Пример/Example:
layouts/main.forkbb.php

    <footer id="fork-footer">
      <p class="f-sim-header">{!! __('Board footer') !!}</p>
      <div id="fork-footer-in">
        <div>
        <!-- PRE footerLeft -->
        </div>
        <div><p id="id-fpoweredby">{!! __('Powered by') !!}</p></div>
      </div>
<!-- debuginfo -->
    </footer>

изменение из расширения/change from extension:

    'layouts/main' => [
        'footerLeft' => '{{ $p->user->username }}',
    ],

скомпилированный шаблон/compiled template:

    <footer id="fork-footer">
      <p class="f-sim-header"><?= __('Board footer') ?></p>
      <div id="fork-footer-in">
        <div>
<?= \htmlspecialchars((string) $p->user->username, \ENT_HTML5 | \ENT_QUOTES | \ENT_SUBSTITUTE, 'UTF-8') ?>

        </div>
        <div><p id="id-fpoweredby"><?= __('Powered by') ?></p></div>
      </div>
<!-- debuginfo -->
    </footer>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants