templator/_prepend.php
2022-12-07 21:58:18 +01:00

49 lines
1.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* @brief templator, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Osku and contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
Clearbricks::lib()->autoload([
'dcTemplator' => __DIR__ . '/inc/class.templator.php',
'templatorMedia' => __DIR__ . '/inc/class.templator.media.php',
'templatorPager' => __DIR__ . '/inc/class.templator.pager.php',
]);
dcCore::app()->templator = new dcTemplator();
dcCore::app()->addBehavior('initWidgets', ['templatorWidgets', 'initWidgets']);
class templatorWidgets
{
public static function initWidgets($w)
{
$w->create('templatorWidget', __('Templator Rendering'), ['widgetTemplator', 'getDataTpl']);
$tpl = ['&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.html' => ''];
foreach (dcCore::app()->templator->tpl as $k => $v) {
if (preg_match('/^widget-(.+)$/', $k)) {
$tpl = array_merge($tpl, [$k => $k]);
}
}
$w->templatorWidget->setting('template', __('Template:'), '', 'combo', $tpl);
}
}
class widgetTemplator
{
public static function getDataTpl($w)
{
if (dcCore::app()->tpl->getFilePath($w->template)) {
echo dcCore::app()->tpl->getData($w->template);
}
}
}