Skip to content

Commit

Permalink
RC 2.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzegit committed Nov 17, 2020
1 parent 78fdd8e commit ec6d8f9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 23 deletions.
49 changes: 26 additions & 23 deletions system/core/template.php
Expand Up @@ -2139,21 +2139,14 @@ public function renderInternal($controller, $tpl_file, $data = array()) {
*/
public function render($tpl_file, $data = [], $request = false) {

if(is_array($tpl_file)){
$data = $tpl_file; $tpl_file = $this->controller->current_template_name;
if (is_array($tpl_file)) {
$data = $tpl_file;
$tpl_file = $this->controller->current_template_name;
}

if(empty($this->controller->template_disable_auto_insert_css)){

$css_file = $this->getStylesFileName();

if ($css_file){ $this->addCSSFromContext($css_file, $request); }
}

$tpl_file = $this->getTemplateFileName('controllers/'.$this->controller->name.'/'.$tpl_file);

return $this->processRender($tpl_file, $data, $request);
$tpl_file = $this->getTemplateFileName('controllers/' . $this->controller->name . '/' . $tpl_file);

return $this->processRender($tpl_file, $data, $request, true);
}

/**
Expand All @@ -2162,16 +2155,16 @@ public function render($tpl_file, $data = [], $request = false) {
* @param string|array $tpl_file Название файла шаблона
* @param array $data Массив параметров, передаваемых в шаблон
*/
public function renderPlain($tpl_file, $data = array()) {
public function renderPlain($tpl_file, $data = []) {

if(is_array($tpl_file)){
$data = $tpl_file; $tpl_file = $this->controller->current_template_name;
if (is_array($tpl_file)) {
$data = $tpl_file;
$tpl_file = $this->controller->current_template_name;
}

$tpl_file = $this->getTemplateFileName('controllers/'.$this->controller->name.'/'.$tpl_file);
$tpl_file = $this->getTemplateFileName('controllers/' . $this->controller->name . '/' . $tpl_file);

$this->processRender($tpl_file, $data, new cmsRequest($this->controller->request->getData(), cmsRequest::CTX_AJAX));

}

/**
Expand All @@ -2181,13 +2174,14 @@ public function renderPlain($tpl_file, $data = array()) {
* @param string $tpl_file Полный путь к файлу шаблона
* @param array $data Массив параметров, передаваемых в шаблон
* @param object $request Объект запроса
* @param boolean $add_controller_css Нужно ли подключать CSS контроллера
* @return mixed
*/
public function processRender($tpl_file, $data = array(), $request = false) {
public function processRender($tpl_file, $data = [], $request = false, $add_controller_css = false) {

if (!$request) { $request = $this->controller->request; }

$hook_name = 'process_render_'.$this->controller->name.'_'.basename(str_replace('-', '_', $tpl_file), '.tpl.php');
$hook_name = 'process_render_' . $this->controller->name . '_' . basename(str_replace('-', '_', $tpl_file), '.tpl.php');

list($tpl_file, $data, $request) = cmsEventsManager::hook($hook_name, [$tpl_file, $data, $request]);

Expand All @@ -2197,22 +2191,31 @@ public function processRender($tpl_file, $data = array(), $request = false) {

extract($data); include($tpl_file);

// Регулировать подключение CSS контроллера можно
// Определив в самом шаблоне переменную $disable_auto_insert_css
if ($add_controller_css &&
!isset($disable_auto_insert_css) &&
empty($this->controller->template_disable_auto_insert_css)) {

$css_file = $this->getStylesFileName();
if ($css_file) { $this->addCSSFromContext($css_file, $request); }
}

$html = ob_get_clean();

if ($request->isAjax()) {
echo $html;
$this->controller->halt();
}

if ($request->isStandard()){
$this->addOutput( $html );
if ($request->isStandard()) {
$this->addOutput($html);
return $html;
}

if ($request->isInternal()){
if ($request->isInternal()) {
return $html;
}

}

/**
Expand Down
18 changes: 18 additions & 0 deletions templates/modern/controllers/sitemap/index.tpl.php
@@ -0,0 +1,18 @@
<?php $disable_auto_insert_css = true; ?>
<h1><?php echo LANG_SITEMAP_HTML; ?></h1>
<div class="row my-3">
<?php foreach ($items as $url){ ?>
<div class="col-sm-6 col-lg-4">
<a href="<?php echo $url['url']; ?>" class="my-1 d-inline-block">
<?php echo $url['title']; ?>
</a>
</div>
<?php } ?>
</div>
<?php if($show_back) { ?>
<div class="back_button">
<a href="<?php echo href_to('sitemap'); ?>" class="btn btn-primary">
<?php echo LANG_BACK; ?>
</a>
</div>
<?php } ?>

0 comments on commit ec6d8f9

Please sign in to comment.