<commit_before><?php

namespace Site\Controller;

use Api\Library\Shared\Palaso\StringUtil;
use Api\Library\Shared\SilexSessionHelper;
use Api\Library\Shared\Website;
use Api\Model\Shared\Command\SessionCommands;
use Api\Model\Shared\FeaturedProjectListModel;
use Api\Model\Shared\Rights\SystemRoles;
use Api\Model\Shared\Rights\Operation;
use Api\Model\Shared\Rights\Domain;
use Api\Model\Shared\UserModel;
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Acl\Exception\Exception;

require_once APPPATH."version.php";

class Base
{
    public function __construct() {
        $this->website = Website::get();
        $this->_showHelp = false;
        $this->_appName = '';
        $this->data['isAdmin'] = false;
        $this->data['projects'] = array();
        $this->data['smallAvatarUrl'] = '';
        $this->data['userName'] = '';
        $this->data['version'] = VERSION;
        $this->data['useMinifiedJs'] = USE_MINIFIED_JS;
        $this->data['http_host'] = $_SERVER['HTTP_HOST'];

        $this->data['jsFiles'] = array();
        $this->data['jsNotMinifiedFiles'] = array();
        $this->data['cssFiles'] = array();
        $this->data['vendorFilesJs'] = array();
        $this->data['vendorFilesMinJs'] = array();
        $this->data['isBootstrap4'] = true;
        $this->data['isAngular2'] = false;
    }

    /** @var array data used to render templates */
    public $data;

    /** @var Website */
    public $website;

    /** @var boolean Variable used to control visibility of help button in header menu bar */
    protected $_showHelp;

    /** @var boolean */
    protected $_isLoggedIn;

    /** @var UserModel */
    protected $_user;

    /** @var string */
    protected $_userId;

    /** @var string */
    protected $_projectId;

    /** @var string */
    protected $_appName;

    // all child classes should call this method first to setup base variables
    protected function setupBaseVariables(Application $app) {
        $this->_isLoggedIn = $this->isLoggedIn($app);
        $this->data['isLoggedIn'] = $this->_isLoggedIn;
        if ($this->_isLoggedIn) {
            try {
                $this->_userId = SilexSessionHelper::getUserId($app);

                if ($this->_userId) {
                    $this->_user = new UserModel($this->_userId);
                } else {
                    //TODO: load anonymous user here
                }
            } catch (\Exception $e) {
                return $app->redirect('/auth/logout');
            }
        }
    }

    // all child classes should use this method to render their pages
    protected function renderPage(Application $app, $viewName) {
        // TODO: move to app_dependencies once bootstrap4 migration is complete
        $sassDir = $this->getThemePath() . '/sass';
        if (!file_exists($sassDir)) {
            $sassDir = $this->getThemePath('default') . '/sass';
        }
        $this->addCssFiles($sassDir, array(), false);

        // Add bellows JS for every page because top container menubar needs it for helps
        $bellowsFolder = NG_BASE_FOLDER . 'bellows';
        $this->addJavascriptFiles($bellowsFolder . '/_js_module_definitions');
        $this->addJavascriptFiles($bellowsFolder . '/js', array('vendor', 'assets'));
        $this->addJavascriptFiles($bellowsFolder . '/directive');

        // Add general Angular app dependencies
        $dependencies = $this->getAngularAppDependencies();
        foreach ($dependencies['js'] as $dependencyFilePath) {
            $this->data['vendorFilesJs'][] = $dependencyFilePath;
        }
        foreach ($dependencies['min'] as $dependencyFilePath) {
            $this->data['vendorFilesMinJs'][] = $dependencyFilePath;
        }
        foreach ($dependencies['css'] as $dependencyFilePath) {
            $this->data['vendorFilesCss'][] = $dependencyFilePath;
        }

        $this->data['faviconPath'] = $this->getFilePath('image/favicon.ico');

        if (file_exists('appManifest/' . $this->website->domain . '.manifest.json')) {
            $this->data['manifestFilename'] = $this->website->domain . '.manifest.json';
        }

        $this->populateHeaderMenuViewdata();
        $this->data['useCdn'] = USE_CDN;

        if (empty($this->data)) {
            $app->abort(404, 'Error: cannot render without data');
        }

        try {
            return $app['twig']->render($viewName.'.html.twig', $this->data);
        } catch (\Twig_Error_Loader $e) {
            $app->abort(404, "Page not found: $viewName.twig\n" . $e->getMessage() . "\n" . $e->getTraceAsString());
        }
<commit_msg>fix broken manifest twig variable<commit_after><?php

namespace Site\Controller;

use Api\Library\Shared\Palaso\StringUtil;
use Api\Library\Shared\SilexSessionHelper;
use Api\Library\Shared\Website;
use Api\Model\Shared\Command\SessionCommands;
use Api\Model\Shared\FeaturedProjectListModel;
use Api\Model\Shared\Rights\SystemRoles;
use Api\Model\Shared\Rights\Operation;
use Api\Model\Shared\Rights\Domain;
use Api\Model\Shared\UserModel;
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Acl\Exception\Exception;

require_once APPPATH."version.php";

class Base
{
    public function __construct() {
        $this->website = Website::get();
        $this->_showHelp = false;
        $this->_appName = '';
        $this->data['isAdmin'] = false;
        $this->data['projects'] = array();
        $this->data['smallAvatarUrl'] = '';
        $this->data['userName'] = '';
        $this->data['version'] = VERSION;
        $this->data['useMinifiedJs'] = USE_MINIFIED_JS;
        $this->data['http_host'] = $_SERVER['HTTP_HOST'];

        $this->data['jsFiles'] = array();
        $this->data['jsNotMinifiedFiles'] = array();
        $this->data['cssFiles'] = array();
        $this->data['vendorFilesJs'] = array();
        $this->data['vendorFilesMinJs'] = array();
        $this->data['isBootstrap4'] = true;
        $this->data['isAngular2'] = false;
    }

    /** @var array data used to render templates */
    public $data;

    /** @var Website */
    public $website;

    /** @var boolean Variable used to control visibility of help button in header menu bar */
    protected $_showHelp;

    /** @var boolean */
    protected $_isLoggedIn;

    /** @var UserModel */
    protected $_user;

    /** @var string */
    protected $_userId;

    /** @var string */
    protected $_projectId;

    /** @var string */
    protected $_appName;

    // all child classes should call this method first to setup base variables
    protected function setupBaseVariables(Application $app) {
        $this->_isLoggedIn = $this->isLoggedIn($app);
        $this->data['isLoggedIn'] = $this->_isLoggedIn;
        if ($this->_isLoggedIn) {
            try {
                $this->_userId = SilexSessionHelper::getUserId($app);

                if ($this->_userId) {
                    $this->_user = new UserModel($this->_userId);
                } else {
                    //TODO: load anonymous user here
                }
            } catch (\Exception $e) {
                return $app->redirect('/auth/logout');
            }
        }
    }

    // all child classes should use this method to render their pages
    protected function renderPage(Application $app, $viewName) {
        // TODO: move to app_dependencies once bootstrap4 migration is complete
        $sassDir = $this->getThemePath() . '/sass';
        if (!file_exists($sassDir)) {
            $sassDir = $this->getThemePath('default') . '/sass';
        }
        $this->addCssFiles($sassDir, array(), false);

        // Add bellows JS for every page because top container menubar needs it for helps
        $bellowsFolder = NG_BASE_FOLDER . 'bellows';
        $this->addJavascriptFiles($bellowsFolder . '/_js_module_definitions');
        $this->addJavascriptFiles($bellowsFolder . '/js', array('vendor', 'assets'));
        $this->addJavascriptFiles($bellowsFolder . '/directive');

        // Add general Angular app dependencies
        $dependencies = $this->getAngularAppDependencies();
        foreach ($dependencies['js'] as $dependencyFilePath) {
            $this->data['vendorFilesJs'][] = $dependencyFilePath;
        }
        foreach ($dependencies['min'] as $dependencyFilePath) {
            $this->data['vendorFilesMinJs'][] = $dependencyFilePath;
        }
        foreach ($dependencies['css'] as $dependencyFilePath) {
            $this->data['vendorFilesCss'][] = $dependencyFilePath;
        }

        $this->data['faviconPath'] = $this->getFilePath('image/favicon.ico');

        $this->data['manifestFilename'] = '';
        if (file_exists('appManifest/' . $this->website->domain . '.manifest.json')) {
            $this->data['manifestFilename'] = $this->website->domain . '.manifest.json';
        }

        $this->populateHeaderMenuViewdata();
        $this->data['useCdn'] = USE_CDN;

        if (empty($this->data)) {
            $app->abort(404, 'Error: cannot render without data');
        }

        try {
            return $app['twig']->render($viewName.'.html.twig', $this->data);
        } catch (\Twig_Error_Loader $e) {
            $app->abort(404, "Page not found: $viewName.twig\n" . $e->getMessage() . "\n" . $e->getTraceAsString());
        }

{'fraction_non_alphanumeric': 0.1540008467400508, 'fraction_numerical': 0.001905165114309907, 'mean_word_length': 2.6161500191350937, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 110, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5297474', 'n_tokens_mistral': 2797, 'n_tokens_neox': 2729, 'n_words': 563}