Translate a element
@param array $params
@param string $content
@param $smarty
@param $repeat
@return mixed
431810
final public static function translate(array $params, string $content = null)
    {
        if (!FEnv::isset("framework.smarty.called")) {
            FEnv::set("framework.smarty.called", 1);
        }

        if (isset($content)) {
            $locale = Locale::getInstance();
            return ($locale->trans($content, $params['lang'] ?? null));
        }
    }
997382
protected function doCompile($_content)
    {
        /* here is where the compiling takes place. Smarty
          tags in the templates are replaces with PHP code,
          then written to compiled files. */
        // init the lexer/parser to compile the template
        $this->lex = new $this->lexer_class($_content, $this);
        $this->parser = new $this->parser_class($this->lex, $this);
        if ($this->inheritance_child) {
            // start state on child templates
            $this->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBODY);
        }
        if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
            $mbEncoding = mb_internal_encoding();
            mb_internal_encoding('ASCII');
        } else {
            $mbEncoding = null;
        }

        if ($this->smarty->_parserdebug) {
            $this->parser->PrintTrace();
            $this->lex->PrintTrace();
        }
        // get tokens from lexer and parse them
        while ($this->lex->yylex() && !$this->abort_and_recompile) {
            if ($this->smarty->_parserdebug) {
                echo "<pre>Line {$this->lex->line} Parsing  {$this->parser->yyTokenName[$this->lex->token]} Token " .
                    htmlentities($this->lex->value) . "</pre>";
            }
            $this->parser->doParse($this->lex->token, $this->lex->value);
        }

        if ($this->abort_and_recompile) {
            // exit here on abort
            return false;
        }
        // finish parsing process
        $this->parser->doParse(0, 0);
        if ($mbEncoding) {
            mb_internal_encoding($mbEncoding);
        }
        // check for unclosed tags
        if (count($this->_tag_stack) > 0) {
            // get stacked info
            list($openTag, $_data) = array_pop($this->_tag_stack);
            $this->trigger_template_error("unclosed {$this->smarty->left_delimiter}" . $openTag . "{$this->smarty->right_delimiter} tag");
        }
        // return compiled code
        // return str_replace(array("? >\n<?php","? ><?php"), array('',''), $this->parser->retvalue);
        return $this->parser->retvalue;
    }
1151963
public function translate($string, $params = [], $domain = null)
    {
        $translationDomain = $domain ? $domain : $this->admin->getTranslationDomain();

        return $this->get('translator')->trans($string, $params, $translationDomain);
    }
696434
protected function translate($key, $params = null, $language = null) {
		return Translation :: translate($key, $params, $language, $this -> getViewmodel());
	}
454864
public static function parse($content, Document $document = null, &$offset = 0)
    {
        if (preg_match('/^\s*<<(?P<struct>.*)/is', $content)) {
            preg_match_all('/(.*?)(<<|>>)/s', trim($content), $matches);

            $level = 0;
            $sub   = '';
            foreach ($matches[0] as $part) {
                $sub .= $part;
                $level += (strpos($part, '<<') !== false ? 1 : -1);
                if ($level <= 0) {
                    break;
                }
            }

            $offset += strpos($content, '<<') + strlen(rtrim($sub));

            // Removes '<<' and '>>'.
            $sub = trim(preg_replace('/^\s*<<(.*)>>\s*$/s', '\\1', $sub));

            $position = 0;
            $elements = Element::parse($sub, $document, $position);
            $header   = new Header($elements, $document);

            return $header;
        }

        return false;
    }
467959
public function render($content) {
        $form = $this->getElement();
        if (!$form instanceof \Zend_Form) {
            return $content;
        }

        $this->_recurseForm($form);

        return $content;
    }
593490
public function translate(string $key, array $params, string $locale = null): string
    {
        $realKey = $this->getRealKey($key, $locale);
        $message = ArrayHelper::get($this->messages, $realKey);
        
        // not exist, return key
        if (!\is_string($message)) {
            return $key;
        }

        // no params
        if (!$params) {
            return $message;
        }

        return $this->formatMessage($message, $params);
    }
585769
public function renderFormCollection($params, $content, \Smarty_Internal_Template $template, &$repeat)
    {
        /**
         * Get parameters
         */
        $form = $this->getInstanceFromParams($params);
        $row = $this->getSymfonyFormFromParams($params, "row");
        $collection = $this->resolveCollection($this->getParam($params, "collection"), $form);

        $hash = $this->initializeCollection($form, $collection, $row);

        $limit = $this->getParam($params, "limit", -1);

        /**
         * Check if it has a limit
         */
        if (!preg_match("#^\-?\d+$#", $limit)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'limit' parameter in 'form_collection'. '%s' given, integer expected",
                    $limit
                )
            );
        }

        /**
         * Then load stack and create the stack count
         */
        $limit = (int)$limit;
        $hasLimit = $limit >= 0;

        /**
         * If we have reached the limit, stop
         */
        $collectionLimit = $this->formCollectionCount[$hash]["limit"];

        if (($hasLimit && $limit === $collectionLimit) ||
            null === $row = array_shift($this->formCollectionStack[$hash])
        ) {
            $repeat = false;

            /**
             * Reload stack limit
             */
            $this->formCollectionCount[$hash]["limit"] = 0;

            return $content;
        }

        /**
         * Assign variables into the template
         */
        $template->assign("row", $row);
        $template->assign("collection_current", $this->formCollectionCount[$hash]["count"]++);
        $template->assign("collection_count", $this->formCollectionCount[$hash]["total_count"]);

        /**
         * Increment the current limit state
         * Force the repeat
         */
        $this->formCollectionCount[$hash]["limit"]++;
        $repeat = true;

        /**
         * ANd return the content
         */

        return $content;
    }
587404
public static function convert($content, $mode = ParserAbstract::MODE_STRICT)
    {
        $parser = new self($mode);

        return $parser->parse($content);
    }
461239
public static function ask($param1, $param2 = null, $param3 = null) {
        self::init();
        if(is_array($param1)) {
            return self::smartSelect($param1, $param2, $param3);
        } else {
            switch(substr($param1, 0, 1)) {
                case '>':
                case '/':
                    return self::smartQuery($param1, $param2);
                    break;
                case '?':
                    return self::smartSelect(substr($param1, 1), $param2, $param3);
                    break;
                default:
                    if(is_array($param3)) {
                        return self::smartUpdate($param1, $param2, $param3);
                    } else {
                        return self::smartInsert($param1, $param2);
                    }
            }
        }
    }
161377
public function generateUrlFunction($params, &$smarty)
    {
        // the path to process
        $current = $this->getParam($params, 'current', false);
        $path  = $this->getParam($params, 'path', null);
        // Do not invoke index.php in URL (get a static file in web space
        $file = $this->getParam($params, 'file', null);
        $routeId = $this->getParam($params, 'route_id', null);
        // select default router
        if ($this->getRequest()->fromAdmin()) {
            $defaultRouter = 'admin';
        } elseif ($this->getRequest()->fromFront()) {
            $defaultRouter = 'front';
        } else {
            $defaultRouter = null;
        }

        $routerId = $this->getParam($params, 'router', $defaultRouter);

        $baseUrl = $this->getParam($params, 'base_url', null);

        if ($current) {
            $path = $this->getRequest()->getPathInfo();
            unset($params["current"]); // Delete the current param, so it isn't included in the url

            // build the query variables
            $params = array_merge(
                $this->getRequest()->query->all(),
                $params
            );
        }

        if ($routeId !== null && $routerId !== null) {
            $routerId = 'router.' . $routerId;

            // test if the router exists
            if (!$this->container->has($routerId)) {
                throw new \InvalidArgumentException(
                    'The router "' . $routerId . '" not found.'
                );
            }
            // get url by router and id
            /** @var Router $router */
            $router = $this->container->get($routerId);

            $url = $router->generate(
                $routeId,
                $this->getArgsFromParam($params, ['route_id', 'router', 'base_url']),
                Router::ABSOLUTE_URL
            );
        } else {
            if ($file !== null) {
                $path = $file;
                $mode = URL::PATH_TO_FILE;
            } elseif ($path !== null) {
                $mode = URL::WITH_INDEX_PAGE;
            } else {
                throw new \InvalidArgumentException(
                    "Please specify either 'path', 'file' or router and route_id on parameters in {url} function."
                );
            }

            $excludeParams = $this->resolvePath($params, $path, $smarty);

            $url = URL::getInstance()->absoluteUrl(
                $path,
                $this->getArgsFromParam($params, array_merge(['noamp', 'path', 'file', 'target', 'base_url'], $excludeParams)),
                $mode,
                $baseUrl
            );

            $request = $this->getRequest();
            $requestedLangCodeOrLocale = $params["lang"];
            $view = $request->attributes->get('_view', null);
            $viewId = $view === null ? null : $request->query->get($view . '_id', null);

            if (null !== $requestedLangCodeOrLocale) {
                if (strlen($requestedLangCodeOrLocale) > 2) {
                    $lang = LangQuery::create()->findOneByLocale($requestedLangCodeOrLocale);
                } else {
                    $lang = LangQuery::create()->findOneByCode($requestedLangCodeOrLocale);
                }

                if (ConfigQuery::isMultiDomainActivated()) {
                    $urlRewrite = RewritingUrlQuery::create()
                        ->filterByView($view)
                        ->filterByViewId($viewId)
                        ->filterByViewLocale($lang->getLocale())
                        ->findOneByRedirected(null)
                    ;

                    $path = '';
                    if (null != $urlRewrite) {
                        $path = "/".$urlRewrite->getUrl();
                    }
                    $url = rtrim($lang->getUrl(), "/").$request->getBaseUrl().$path;
                }

            }
        }
        return $this->applyNoAmpAndTarget($params, $url);
    }
1356878
public function form_fieldset($params, $content, $smarty, &$repeat) {
        //$content is null when repeat is true and has block content when repeat is false
        if ($repeat) {
            $attributes = isset($params['attrs']) ? $params['attrs'] : array();
            $legend = isset($params['legend']) ? $params['legend'] : null;
            return Form::fieldset_open($attributes, $legend);
        } else {
            return $content . Form::fieldset_close();
        }
    }
4612
public function generateSearchText($content)
    {
        $searchText = '';
        $repeaterRows = PageBlockRepeaterData::loadRepeaterData($content, $this->_block->getVersionId());
        $repeaterBlocks = BlockRepeater::getRepeaterBlocks($this->_block->id);

        foreach ($repeaterRows as $rowId => $repeaterRow) {
            foreach ($repeaterBlocks as $blockId => $repeaterBlock) {
                if(($blockContent = array_key_exists($blockId, $repeaterRow) ? $repeaterRow[$blockId] : null) !== null) {
                    $block = Block::preloadClone($blockId)->setRepeaterData($this->_block->getRepeaterId(), $this->_block->getRepeaterRowId())->setPageId($this->_block->getPageId());
                    if ($block->exists && $block->search_weight > 0) {
                        $blockSearchText = $block->getTypeObject()->generateSearchText($blockContent);
                        $searchText .= ($blockSearchText !== null) ? $blockSearchText . "\n" : '';
                    }
                }
            }
        }

        return parent::generateSearchText($searchText);
    }
138089
public static function replaceTpl($content, array $placeholders = null, Template $template)
    {
        $template = clone $template;
        $template->removeAllPlaceholders();

        return $template->replace($content, $placeholders);
    }
782540
public function folderDataAccess($params, &$smarty)
    {
        $folderId = $this->getRequest()->get('folder_id');

        if ($folderId === null) {
            $contentId = $this->getRequest()->get('content_id');

            if ($contentId !== null) {
                if (null !== $content = ContentQuery::create()->findPk($contentId)) {
                    $folderId = $content->getDefaultFolderId();
                }
            }
        }

        if ($folderId !== null) {
            return $this->dataAccessWithI18n(
                "Folder",
                $params,
                FolderQuery::create()->filterByPrimaryKey($folderId)
            );
        }

        return '';
    }
1088550
public function postage($params, $content, $template, &$repeat)
    {
        if (!$repeat) {
            return (null !== $this->countryId) ? $content : "";
        }

        $customer = $this->getCurrentRequest()->getSession()->getCustomerUser();
        /** @var Address $address */
        /** @var Country $country */
        list($address, $country, $state) = $this->getDeliveryInformation($customer);

        if (null !== $country) {
            $this->countryId = $country->getId();
            // try to get the cheapest delivery for this country
            $this->getCheapestDelivery($address, $country);
        }

        $template->assign('country_id', $this->countryId);
        $template->assign('delivery_id', $this->deliveryId);
        $template->assign('postage', $this->postage ?: 0.0);
        $template->assign('postage_tax', $this->postageTax ?: 0.0);
        $template->assign('postage_title', $this->postageTaxRuleTitle ?: 0.0);
        $template->assign('is_customizable', $this->isCustomizable);
    }
1047280
public function process($content, array $options = [])
    {
        $found = false;
        if (is_string($content)) {
            $tagNames = array_keys($this->tagNames);
            $tagNames[] = 'component';
            foreach ($tagNames as $tagName) {
                if (strpos($content, '<' . $tagName) !== false) {
                    $found = true;
                    break;
                }
            }
        }
        if ($content instanceof \IvoPetkov\HTMLServerComponent) {
            $found = true;
        }
        if ($found) {
            if (self::$newCompilerCache === null) {
                self::$newCompilerCache = new \IvoPetkov\BearFramework\Addons\HTMLServerComponents\Internal\Compiler();
            }
            $compiler = clone(self::$newCompilerCache);
            foreach ($this->aliases as $alias => $original) {
                $compiler->addAlias($alias, $original);
            }
            foreach ($this->tagNames as $tagName => $src) {
                $compiler->addTag($tagName, $src);
            }
            return $compiler->process($content, $options);
        }
        return $content;
    }