Adds the Aimeos template functions for Twig

@param \Aimeos\MW\View\Iface $view View object
@param \Twig_Environment $twig Twig environment object
325602
protected function initTwig( \Aimeos\MW\View\Iface $view, \Twig_Environment $twig )
	{
		$fcn = function( $key, $default = null ) use ( $view ) {
			return $view->config( $key, $default );
		};
		$twig->addFunction( new \Twig_SimpleFunction( 'aiconfig', $fcn ) );

		$fcn = function( $singular, array $values = array(), $domain = 'client' ) use ( $view ) {
			return vsprintf( $view->translate( $domain, $singular ), $values );
		};
		$twig->addFunction( new \Twig_SimpleFunction( 'aitrans', $fcn ) );

		$fcn = function( $singular, $plural, $number, array $values = array(), $domain = 'client' ) use ( $view ) {
			return vsprintf( $view->translate( $domain, $singular, $plural, $number ), $values );
		};
		$twig->addFunction( new \Twig_SimpleFunction( 'aitransplural', $fcn ) );
	}
866334
public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], &$expire = null )
	{
		$context = $this->getContext();
		$config = $context->getConfig();

		/** client/html/catalog/count/tree/aggregate
		 * Enables or disables generating product counts for the category catalog filter
		 *
		 * This configuration option allows shop owners to enable or disable product counts
		 * for the tree section of the catalog filter HTML client.
		 *
		 * @param boolean Disabled if "0", enabled if "1"
		 * @since 2014.03
		 * @see client/html/catalog/count/limit
		 */
		if( $config->get( 'client/html/catalog/count/tree/aggregate', true ) == true )
		{
			/** client/html/catalog/count/limit
			 * @see client/html/catalog/count/tree/aggregate
			 */
			$limit = $config->get( 'client/html/catalog/count/limit', 10000 );
			$startid = $view->config( 'client/html/catalog/filter/tree/startid' );
			$level = $view->config( 'client/html/catalog/lists/levels', \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE );

			$cntl = \Aimeos\Controller\Frontend::create( $context, 'catalog' )->root( $startid );
			$root = $cntl->getTree( \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE );

			if( ( $catId = $view->param( 'f_catid', $root->getId() ) ) != null && $catId != $root->getId() ) {
				$cntl->visible( array_keys( $cntl->getPath( $catId ) ) );
			} elseif( $level !== \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ) {
				$cntl->visible( [$root->getId()] );
			}

			$tree = $cntl->getTree();
			$view->treeCountList = \Aimeos\Controller\Frontend::create( $context, 'product' )
				->category( array_keys( $tree->toList() ) )->slice( 0, $limit )->sort()
				->aggregate( 'index.catalog.id' );

			if( $level === \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ) {
				$view->treeCountList = $this->counts( $this->traverse( $tree, $view->treeCountList ) );
			}
		}

		return parent::addData( $view, $tags, $expire );
	}
1090458
protected function addItem( \Aimeos\MW\Container\Content\Iface $contentItem, \Aimeos\MShop\Product\Item\Iface $item, $langid )
	{
		$listTypes = [];
		foreach( $item->getListItems( 'text' ) as $listItem ) {
			$listTypes[$listItem->getRefId()] = $listItem->getType();
		}

		foreach( $this->getTextTypes( 'product' ) as $textTypeItem )
		{
			$textItems = $item->getRefItems( 'text', $textTypeItem->getCode() );

			if( !empty( $textItems ) )
			{
				foreach( $textItems as $textItem )
				{
					$listType = ( isset( $listTypes[$textItem->getId()] ) ? $listTypes[$textItem->getId()] : '' );
					$items = array( $langid, $item->getType(), $item->getCode(), $listType, $textTypeItem->getCode(), '', '' );

					// use language of the text item because it may be null
					if( ( $textItem->getLanguageId() == $langid || is_null( $textItem->getLanguageId() ) )
						&& $textItem->getTypeId() == $textTypeItem->getId() )
					{
						$items[0] = $textItem->getLanguageId();
						$items[5] = $textItem->getId();
						$items[6] = $textItem->getContent();
					}

					$contentItem->add( $items );
				}
			}
			else
			{
				$items = array( $langid, $item->getType(), $item->getCode(), 'default', $textTypeItem->getCode(), '', '' );
				$contentItem->add( $items );
			}
		}
	}
700748
public function compose(View $view)
    {
        $strategy = $this->getValidatedStrategyFromConfig();
        $output = [];

        foreach((array)config("sharp.extensions.assets") as $position => $paths) {
            foreach((array)$paths as $assetPath) {
                if(!isset($output[$position])) {
                    $output[$position] = [];
                }

                // Only render valid assets
                if(ends_with($assetPath, $this->assetTypes)) {
                    // Grab the relevant template based on the filetype
                    $template = array_get($this->renderTemplates, $this->getAssetFileType($assetPath));

                    // Apply the strategy (run through asset() or mix()
                    $resolvedAssetPath = $this->getAssetPathWithStrategyApplied($strategy, $assetPath);

                    $output[$position][] = sprintf($template, $resolvedAssetPath);
                }
            }
        }

        // Build the strings to output in the blades
        $toBind = [];
        foreach((array)$output as $position => $toOutput) {
            $toBind[$position] = implode('', $toOutput);
        }

        $view->with('injectedAssets', $toBind);
    }
282109
protected function _render($view)
    {
        // get Smarty is important here as it sets template directory correct
        $smarty = \OxidEsales\Eshop\Core\Registry::getUtilsView()->getSmarty();

        // render it
        $templateName = $view->render();

        // check if template dir exists
        $templateFile = \OxidEsales\Eshop\Core\Registry::getConfig()->getTemplatePath($templateName, $this->isAdmin());
        if (!file_exists($templateFile)) {
            $ex = oxNew(\OxidEsales\Eshop\Core\Exception\SystemComponentException::class);
            $ex->setMessage('EXCEPTION_SYSTEMCOMPONENT_TEMPLATENOTFOUND' . ' ' . $templateName);
            $ex->setComponent($templateName);

            $templateName = "message/exception.tpl";

            if ($this->_isDebugMode()) {
                \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay($ex);
            }
            \OxidEsales\Eshop\Core\Registry::getLogger()->error($ex->getMessage(), [$ex]);
        }

        // Output processing. This is useful for modules. As sometimes you may want to process output manually.
        $outputManager = $this->_getOutputManager();
        $viewData = $outputManager->processViewArray($view->getViewData(), $view->getClassName());
        $view->setViewData($viewData);

        //add all exceptions to display
        $errors = $this->_getErrors($view->getClassName());
        if (is_array($errors) && count($errors)) {
            \OxidEsales\Eshop\Core\Registry::getUtilsView()->passAllErrorsToView($viewData, $errors);
        }

        foreach (array_keys($viewData) as $viewName) {
            $smarty->assign($viewName, $viewData[$viewName]);
        }

        // passing current view object to smarty
        $smarty->oxobject = $view;

        $output = $this->fetchSmartyOutput($smarty, $templateName, $view->getViewId());

        //Output processing - useful for modules as sometimes you may want to process output manually.
        $output = $outputManager->process($output, $view->getClassName());

        return $outputManager->addVersionTags($output);
    }
535920
protected static function addLogger( \Aimeos\MShop\Context\Item\Iface $context )
	{
		if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_logger'] )
			&& is_callable( ( $fcn = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_logger'] ) )
		) {
			return $fcn( $context );
		}

		return $context->setLogger( \Aimeos\MAdmin::create( $context, 'log' ) );
	}
1058540
public function compose(View $view)
    {
        $view->withAboutApp(Markdown::convertToHtml($this->config->get('setting.app_about')));
        $view->withAppAnalytics($this->config->get('setting.app_analytics'));
        $view->withAppAnalyticsGoSquared($this->config->get('setting.app_analytics_gs'));
        $view->withAppAnalyticsPiwikUrl($this->config->get('setting.app_analytics_piwik_url'));
        $view->withAppAnalyticsPiwikSiteId($this->config->get('setting.app_analytics_piwik_site_id'));
        $view->withAppBanner($this->config->get('setting.app_banner'));
        $view->withAppBannerStyleFullWidth($this->config->get('setting.style_fullwidth_header'));
        $view->withAppBannerType($this->config->get('setting.app_banner_type'));
        $view->withAppDomain($this->config->get('setting.app_domain'));
        $view->withAppGraphs($this->config->get('setting.display_graphs'));
        $view->withAppLocale($this->config->get('setting.app_locale'));
        $view->withAppStylesheet($this->config->get('setting.stylesheet'));
        $view->withAppUrl($this->config->get('app.url'));
        $view->withAppHeader($this->config->get('setting.header'));
        $view->withAppFooter($this->config->get('setting.footer'));
        $view->withAppName($this->config->get('setting.app_name'));
        $view->withShowSupport($this->config->get('setting.show_support'));
        $view->withAutomaticLocalization($this->config->get('setting.automatic_localization'));
        $view->withEnableExternalDependencies($this->config->get('setting.enable_external_dependencies'));
        $view->withShowTimezone($this->config->get('setting.show_timezone'));
        $view->withAppRefreshRate($this->config->get('setting.app_refresh_rate'));
        $view->withTimezone($this->dates->getTimezone());
        $view->withSiteTitle($this->config->get('setting.app_name'));
        $view->withFontSubset($this->config->get('langs.'.$this->config->get('app.locale').'.subset', 'latin'));
        $view->withOnlyDisruptedDays($this->config->get('setting.only_disrupted_days'));
        $view->withDashboardLink($this->config->get('setting.dashboard_login_link'));
        $view->withEnableSubscribers($this->config->get('setting.enable_subscribers'));
    }
955569
public function addView(string $view, array $data): void
    {
        $num = count($this->views) + 1;
        $key = '#' . $num . ' ' . $view;

        $this->views[$key] = $this->getDataFormatter()->formatVar($data);
    }
1224996
protected function addCsrf( \Aimeos\MW\View\Iface $view )
	{
		$helper = new \Aimeos\MW\View\Helper\Csrf\Standard( $view, '_token', csrf_token() );
		$view->addHelper( 'csrf', $helper );

		return $view;
	}
316849
public function composeShow(View $view)
    {
        $this->composeWithTitle($view);
        $this->composeWithLayout($view);
        $this->composeWithAllRouteNames($view);
        $this->composeWithPartialsLocation($view);
        $this->composeWithResourceLocation($view);
    }
1048343
protected function generateView($view, $data = [])
    {
        if(is_null($this->viewPath)) {
            return $view;
        }

        $twig = new Twig_Environment(
            new Twig_Loader_Filesystem(realpath($this->viewPath))
        );

        return $twig->render($view, $data);
    }
605229
public function & SetView (\MvcCore\IView & $view) {
		parent::SetView($view);
		return $this->SetLangAndLocale($this->request->GetLang(), $this->request->GetLocale());
	}
694302
protected static function addResponse( \Aimeos\MW\View\Iface $view )
	{
		if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_view_response'] )
			&& is_callable( ( $fcn = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_view_response'] ) )
		) {
			return $fcn( $view );
		}

		$helper = new \Aimeos\MW\View\Helper\Response\Typo3( $view );
		$view->addHelper( 'response', $helper );

		return $view;
	}
436282
protected function getAllowedResources( \Aimeos\MW\View\Iface $view, array $resources )
	{
		$config = $this->getContext()->getConfig();
		$allowed = [];

		foreach( $resources as $resource )
		{
			if( $view->access( $config->get( 'admin/jsonadm/resource/' . $resource . '/groups', [] ) ) === true ) {
				$allowed[] = $resource;
			}
		}

		return $allowed;
	}
436587
def add_template_events_to_ifo(self, ifo, columns, vectors):
        
        # Just call through to the standard function
        self.template_events = self.template_event_dict[ifo]
        self.add_template_events(columns, vectors)
        self.template_event_dict[ifo] = self.template_events
        self.template_events = None
113260
protected function getParts( \Aimeos\MW\View\Iface $view )
	{
		$available = array(
			'basket/address' => \Aimeos\MShop\Order\Item\Base\Base::PARTS_ADDRESS,
			'basket/coupon' => \Aimeos\MShop\Order\Item\Base\Base::PARTS_COUPON,
			'basket/product' => \Aimeos\MShop\Order\Item\Base\Base::PARTS_PRODUCT,
			'basket/service' => \Aimeos\MShop\Order\Item\Base\Base::PARTS_SERVICE,
		);

		$included = explode( ',', $view->param( 'included', 'basket/address,basket/coupon,basket/product,basket/service' ) );

		$parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_NONE;
		foreach( $included as $type )
		{
			if( isset( $available[$type] ) ) {
				$parts |= $available[$type];
			}
		}

		return $parts;
	}
285977
protected static function addRequest( \Aimeos\MW\View\Iface $view, \TYPO3\CMS\Extbase\Mvc\RequestInterface $request = null )
	{
		if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_view_request'] )
			&& is_callable( ( $fcn = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_view_request'] ) )
		) {
			return $fcn( $view, $request );
		}

		$target = $GLOBALS["TSFE"]->id;
		$get = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET();
		$post = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST();

		$helper = new \Aimeos\MW\View\Helper\Request\Typo3( $view, $target, $_FILES, $get, $post, $_COOKIE, $_SERVER );
		$view->addHelper( 'request', $helper );

		return $view;
	}