0

Взялся помочь человеку с сайтом на Bitrix, начал редактировать файл шаблона и испортил код, сейчас сайт не открывается с ошибкой "[ParseError] syntax error, unexpected end of file". Голову сломал, не могу найти ошибку, помогите, пожалуйста.

 <?php

use intec\core\collections\Arrays;
use intec\core\helpers\ArrayHelper;
use intec\core\helpers\FileHelper;
use intec\core\helpers\RegExp;
use intec\core\helpers\Html;
use intec\core\helpers\Type;
use intec\core\io\Path;
use intec\template\Properties;

/**
 * @var string $directory
 */

(function ($directory) { ?> <?php
    global $APPLICATION;

    $properties = Properties::getCollection();
    $page['path'] = $APPLICATION->GetCurPage(false);
    $page['main'] = $page['path'] === SITE_DIR;
    $page['background'] = $properties->get('template-background-show');
    $page['blocks'] = [
        'basket' => [
            'fixed' => [
                'use' =>
                    $properties->get('basket-use') &&
                    ArrayHelper::isIn($properties->get('header-template'), [2, 3, 7, 8, 9, 10, 12]),
                'template' => $properties->get('basket-fixed-template')
            ],
            'notifications' => [
                'use' =>
                    $properties->get('basket-use') &&
                    $properties->get('basket-notifications-use'),
                'template' => 'template.1'
            ]
        ],
        'blocks' => $page['main'],
        'breadcrumb' => !$page['main'],
        'header' => !$page['main'] && !RegExp::isMatchBy('/^'.RegExp::escape(SITE_DIR).'services\//i', $page['path']),
        'menu' => $properties->get('template-menu-show'),
        'panel' => true
    ];

    $template = $properties->get('pages-main-template');
    $blocks = $properties->get('pages-main-blocks');

    if (empty($template))
        $template = 'wide';

    foreach ($blocks as $code => &$block)
        $block['code'] = $code;

    unset($block);

    if (FileHelper::isFile($directory.'/parts/custom/header.php'))
        include($directory.'/parts/custom/header.php');
?>
<div class="intec-template">
    <div class="<span id=" title="Код PHP: &lt;?= Html::cssClassFromArray([ 'intec-template-content' =&gt; true, 'intec-conte...">
         <?= Html::cssClassFromArray([
            'intec-template-content' => true,
            'intec-content' => $page['background'],
            'intec-content-visible' => $page['background']
        ], true) ?><span class="bxhtmled-surrogate-inner"><span class="bxhtmled-right-side-item-icon"></span><span class="bxhtmled-comp-lable" unselectable="on" spellcheck="false">Код PHP</span></span>"&gt; <?php if ($page['background']) { ?> <?= Html::beginTag('div', [
                    'class' => 'intec-content-wrapper'
                ]) ?> <?php } ?>
        <div style="margin-bottom: 0px;">
             <?php if ($page['blocks']['panel']) { ?> <?php $APPLICATION->ShowPanel(); ?> <?php } ?> <?php if ($page['blocks']['basket']['fixed']['use']) { ?> <?$APPLICATION->IncludeComponent(
    "bitrix:main.include",
    ".default",
    Array(
        "AREA_FILE_SHOW" => "file",
        "PATH" => SITE_DIR.'/include/header/basket/fixed/'.$page['blocks']['basket']['fixed']['template'].'.php'
    ),
false,
Array(
    'HIDE_ICONS' => 'Y'
)
);?> <?php } ?> <?php if ($page['blocks']['basket']['notifications']['use']) { ?> <?$APPLICATION->IncludeComponent(
    "bitrix:main.include",
    ".default",
    Array(
        "AREA_FILE_SHOW" => "file",
        "PATH" => SITE_DIR.'/include/header/basket/notifications/'.$page['blocks']['basket']['notifications']['template'].'.php'
    ),
false,
Array(
    'HIDE_ICONS' => 'Y'
)
);?> <?php } ?> <?$APPLICATION->IncludeComponent(
    "bitrix:main.include",
    ".default",
    Array(
        "AREA_FILE_SHOW" => "file",
        "PATH" => SITE_DIR.'/include/header/base.php'
    ),
false,
Array(
    'HIDE_ICONS' => 'Y'
)
);?> <?php if ($page['blocks']['breadcrumb']) { ?>
            <div class="intec-breadcrumb-wrap">
                 <?$APPLICATION->IncludeComponent(
    "bitrix:main.include",
    ".default",
    Array(
        "AREA_FILE_SHOW" => "file",
        "PATH" => SITE_DIR.'/include/header/breadcrumb.php'
    ),
false,
Array(
    'HIDE_ICONS' => 'Y'
)
);?>
            </div>
             <?php } ?>
            <div class="intec-content-wrap">
                 <?php if ($page['blocks']['header']) { ?>
                <div class="intec-header-wrap">
                    <div class="intec-content">
                        <div class="intec-content-wrapper">
                            <h1 class="intec-header">
                            <?php $APPLICATION->ShowTitle(false) ?> </h1>
                        </div>
                    </div>
                </div>
                 <?php } ?> <?php if ($page['blocks']['menu']) { ?>
                <div class="intec-content intec-content-visible">
                    <div class="intec-content-wrapper">
                        <div class="intec-content-left">
                             <?$APPLICATION->IncludeComponent(
    "bitrix:main.include",
    ".default",
    Array(
        "AREA_FILE_SHOW" => "file",
        "PATH" => SITE_DIR.'/include/header/menu.php'
    ),
false,
Array(
    'HIDE_ICONS' => 'Y'
)
);?>
                        </div>
                        <div class="intec-content-right">
                            <div class="intec-content-right-wrapper">
                                 <?php } ?> <?php if ($page['main']) {
                    $blocks = Arrays::from($blocks);

                    //$render = function ($block, $data = []) use(&$blocks, &$template) {
        /*
                    foreach($blocks as $block){
                        global $APPLICATION;

                        if (!Type::isArray($block))
                            continue;

                        if (!$block['active'])
                            continue;

                        if (!Type::isArray($data))
                            $data = [];

                            $path = Path::from('@root'.SITE_DIR.'include/index/'.$template);


                        //print_r($block);
                        if (empty($block['template'])) {
                            $path = $path->add($block['code'].'.php');
                        } else {
                            $path = $path->add($block['code'])->add($block['template'].'.php');
                        }
                        if($block['template_path'])
                            include('include/index/'.$block['template_path'].".php");
                        elseif (FileHelper::isFile($path->value))
                            include($path->value);
                    };
*/
                    if (FileHelper::isFile($directory.'/parts/custom/blocks.php'))
                        include($directory.'/blocks/custom/blocks.php');
                    $path = Path::from('@root'.SITE_DIR.'include/index/'.$template.'.php');

                    if (FileHelper::isFile($path->value)) 
                        include($path->value);
                } ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
 <br>
 <?php } ?>
3
  • 1
    Хорошо начали... взялся помочь человеку... )) Ошибка unexpected end of file значит, что где то вы отставили лишнюю } или наоборот, она отсутствует. Вы там закоментировали код, но не заметили что от $render = .... кавычка осталась } ?> после include($path->value);
    – Arsen
    15 окт 2019 в 13:37
  • { - 13 штук, } - 12 штук. Где имеено не подскажу, удалите комменты, отформатируйте, сами найдете. Чтобы не "портить" код, используйте git. 15 окт 2019 в 13:39
  • Если без кода в комменте - фигурных скобок поровну. Попробуйте без него.. 15 окт 2019 в 15:45

1 ответ 1

0

Желательно отформатировать код (будет проще разбираться), да и в ошибке должен быть написан номер строки, где ошибка была совершена.

Первое что бросилось в глаза и из-за этого могла бы быть эта ошибка это не завершённая конструкция

(function(){});

у Вас в коде в конце просто

}  

а должно быть

});

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.