Skip to content

remove smarty #4

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change log


## [2.4.0] 2020-06-17
- Smarty удален из репозитория
- Унифицирован интерфейс `LayoutInterface`
- Добавлена возможность использования своего пользовательского лэйаута, для этого в контейнере должен быть определен сервис `LayoutInterface::class`

## [2.3.25] 2020-06-17
- Испаравлены ошибки invalid argument supplied for foreach в `PXDisplayTypeFilesArray`

Expand Down
78 changes: 29 additions & 49 deletions lib/Engine/index.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use PP\Lib\Engine\AbstractEngine;
use PP\Lib\Html\Layout\LayoutInterface;
use PP\Lib\Html\Layout\NullLayout;

class PXEngineIndex extends AbstractEngine {
var $layout = ['factory' => 'PXUserHTMLLayout'];
var $layout = ['factory' => LayoutInterface::class, 'helper' => true];

/**
* Инициализация основных объектов приложения
Expand All @@ -17,72 +19,50 @@ class PXEngineIndex extends AbstractEngine {
$this->content->tree = new PXTreeObjects();
$this->content->objects = new PXObjects();
$this->content->subObjects = new PXSubObjects();

$this->layout->setApp($this->app);
}

protected function initModules() {
}

function fillLayout() {
$this->layout->setApp(PXRegistry::getApp());

// Передача данных в шаблонизатор
$this->layout->assign('app', PXRegistry::getApp(), true);
$this->layout->assign('user', PXRegistry::getUser(), true);
$this->layout->assign('request', PXRegistry::getRequest(), true);
$this->layout->assign('response', PXResponse::getInstance(), true);

$this->layout->assignRequest(PXRegistry::getRequest());

$this->layout->assign('tree', $this->content->tree);
$this->layout->assign('objects', $this->content->objects);
$this->layout->assign('subObjects', $this->content->subObjects);
protected function initLayout($layoutClass) {
if (!$this->container->has($layoutClass)) {
$this->layout = new NullLayout();

// Deprecated features
$currentSid = $this->content->tree->hasCurrent() ? $this->content->tree->getCurrent()->id : -1;
if($this->content->objects->hasCurrent()) {
$objs = $this->content->objects->getCurrent();
$currentCid = $objs['id'];
} else {
$currentCid = -1;
return;
}

if($this->content->subObjects->hasCurrent()) {
$objs = $this->content->subObjects->getCurrent();
$currentSCid = $objs['id'];
} else {
$currentSCid = -1;
}

$this->layout->assign('currentSid', $currentSid);
$this->layout->assign('currentCid', $currentCid);
$this->layout->assign('currentSCid', $currentSCid);
// TODO: Suppose init lang must be optional and must be done using container.
// TODO: Binding lang to layout is rather questionable too, because it's often needed in userAction/userJson.
/** @var LayoutInterface $layout */
$layout = $this->container->get($layoutClass);
require_once PPLIBPATH . 'HTML/lang.class.inc';
$lang = new PXUserHTMLLang();
$lang->setTree($this->app->langTree);
$layout->setLang($lang);

$this->layout->assign('currentCtype', $this->content->objects->getCurrentType());

$this->layout->assign('pathId', $this->content->tree->pathId);
$this->layout->assign('rootId', $this->content->tree->rootId);
$this->layout->assign('urlFile', PXRegistry::getRequest()->getFile());
$this->layout = $layout;
}

$this->layout->assign('requestHost', PXRegistry::getRequest()->getHttpHost());
$this->layout->assign('requestUri', PXRegistry::getRequest()->getRequestUri());
$this->layout->assign('requestReferer', PXRegistry::getRequest()->getHttpReferer());
$this->layout->assign('requestPath', PXRegistry::getRequest()->getPathAsString());
$this->layout->assign('REGEX_MOD', REGEX_MOD);
$this->layout->assign('DEFAULT_CHARSET', DEFAULT_CHARSET);
$this->layout->assign('CHARSET_UTF8', CHARSET_UTF8);
$this->layout->assign('CHARSET_WINDOWS', CHARSET_WINDOWS);
public function fillLayout() {
$this->layout->assign('app', PXRegistry::getApp());
$this->layout->assign('user', PXRegistry::getUser());
$this->layout->assign('request', PXRegistry::getRequest());
$this->layout->assign('response', PXResponse::getInstance());
$this->layout->assign('tree', $this->content->tree);
$this->layout->assign('rootContent', $this->content->tree->root->content);
$this->layout->assign('currentStructContent', $this->content->tree->current->content);
$this->layout->assign('objects', $this->content->objects);
$this->layout->assign('subObjects', $this->content->subObjects);
}

function html() {
public function html() {
$html = PXRegistry::getLayout()->display();

$response = PXResponse::getInstance();
$response->send($html);
}

function runModules() {
public function runModules() {
$queue = PXRegistry::getApp()->bindingsQueue;
$queue->getRequestBinding();

Expand Down
Loading