Generate content with `shortcode` and `x_fields`.

@return string
763785
public function getContentAttribute()
    {
        if (empty($content = $this->attributes['content'])) {
            return null;
        }

        // Give shortcodes from app settings. static::$shortcodes ???
        $shortcodes = [
            'app_url' => setting('system.app_url'),
            'organization' => setting('system.organization'),
            'contact_telephone' => setting('system.contact_telephone'),
            'contact_email' => setting('system.contact_email'),
            'address' => setting('system.address_locality').', '.setting('system.address_street'),
        ];

        // Give shortcode from extra fields. static::$x_shortcode ???
        // $x_shortcode = $this->x_fields->keyBy('name')->toArray();
        $x_shortcode = $this->x_fields->pluck('name')->toArray();

        preg_match_all("/\[\[(.*?)\]\]/u", $content, $matches);

        foreach ($matches[1] as $row) {
            if (array_key_exists($row, $shortcodes)) {
                $content = str_ireplace('[[' . $row . ']]', $shortcodes[$row], $content);
            } elseif (in_array($row, $x_shortcode)) {
                $content = str_ireplace('[[' . $row . ']]', $this->{$row}, $content);
            } elseif (starts_with($row, 'picture_box_')) {
                $id = (int) str_ireplace('picture_box_', '', $row);
                if ($image = $this->images->where('id', $id)->first()) {
                    $content = str_ireplace("[[picture_box_$id]]", $image->picture_box, $content);
                } else {
                    $content = str_ireplace("[[picture_box_$id]]", '<code>IMG WITH ID #'.$id.' IN THIS ARTICLE NOT FOUND.</code>', $content);
                }
            } elseif (starts_with($row, 'media_player_')) {
                $id = (int) str_ireplace('media_player_', '', $row);
                if ($file = $this->files->where('id', $id)->first()) {
                    $content = str_ireplace("[[media_player_$id]]", $file->media_player, $content);
                } else {
                    $content = str_ireplace("[[media_player_$id]]", '<code>FILE WITH ID #'.$id.' IN THIS ARTICLE NOT FOUND.</code>', $content);
                }
            } elseif (starts_with($row, 'download_button_')) {
                $id = (int) str_ireplace('download_button_', '', $row);
                if ($file = $this->files->where('id', $id)->first()) {
                    $content = str_ireplace("[[download_button_$id]]", $file->download_button, $content);
                } else {
                    $content = str_ireplace("[[download_button_$id]]", '<code>FILE WITH ID #'.$id.' IN THIS ARTICLE NOT FOUND.</code>', $content);
                }
            } elseif (starts_with($row, 'file_')) {
                $id = (int) str_ireplace('file_', '', $row);
                if ($file = $this->files->where('id', $id)->first()) {
                    $content = str_ireplace("[[file_$id]]", $file->url, $content);
                } else {
                    $content = str_ireplace("[[file_$id]]", '<code>FILE WITH ID #'.$id.' IN THIS ARTICLE NOT FOUND.</code>', $content);
                }
            }
        }

        return $content;
    }
835016
public function generate()
    {
        return sprintf(
            '<%s %s>%s</%s>%s',
            $this->tag,
            parent::generate(),
            $this->label,
            $this->tag,
            PHP_EOL
        );
    }
1226165
private function generateFromGeneric()
    {
        $ctypes = $this->app['config']->get('contenttypes');

        $translatables = array_filter(
            array_keys($this->translatables),
            function ($key) {
                return substr($key, 0, 21) === 'contenttypes.generic.' && substr($key, 21, 6) !== 'group.';
            }
        );

        foreach ($translatables as $key) {
            foreach ($ctypes as $ctname => $ctype) {
                $setkey = 'contenttypes.' . $ctname . '.text.' . substr($key, 21);
                $this->translation[$setkey] = isset($this->saved[$setkey]) ? $this->saved[$setkey] : '';
                if ($this->translation[$setkey] === '') {
                    $generic = Trans::__($key);
                    // If not translated, add hint
                    if ($generic !== $key) {
                        $replacement = [];
                        if (strpos($generic, '%contenttypes%') !== false) {
                            $replacement['%contenttypes%'] = $ctname;
                        } elseif (strpos($generic, '%contenttype%') !== false) {
                            $replacement['%contenttype%'] = $ctname;
                        }
                        $this->hints[$setkey] = Trans::__($key, $replacement);
                    }
                }
            }
        }
    }
616305
public function generate()
    {
        if (TL_MODE === 'BE') {
            $template = new BackendTemplate('be_wildcard');

            $template->wildcard = '### '.Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['newscategories'][0]).' ###';
            $template->title = $this->headline;
            $template->id = $this->id;
            $template->link = $this->name;
            $template->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id='.$this->id;

            return $template->parse();
        }

        $this->news_archives = $this->sortOutProtected(StringUtil::deserialize($this->news_archives, true));

        // Return if there are no archives
        if (0 === \count($this->news_archives)) {
            return '';
        }

        $this->manager = System::getContainer()->get('codefog_news_categories.manager');
        $this->currentNewsCategories = $this->getCurrentNewsCategories();

        return parent::generate();
    }
945831
public function generate(): string
    {
        $classCode = $this->generator->generate();

        return $classCode
            // Inject advices on call
            . '\\' . __CLASS__ . '::injectJoinPoints(' . $this->generator->getName() . '::class);';
    }
1011780
public function generate()
    {
        $content = $this->content;
        if (is_object($content) && $content instanceof CellContentInterface) {
            $content = $content->generate();
        }
        Html::addCssClass($this->htmlOptions, $this->classes);

        return Html::tag('div', implode($this->_prepend) . $content . implode($this->_append), $this->htmlOptions);
    }
1229523
public function generate()
	{
		$title         = $this->getTitle();
		$description   = $this->getDescription();
		$keywords      = $this->getKeywords();
		$miscellaneous = $this->getMiscellaneous();
		$canonical     = $this->getCanonical();

		$html[] = '<title>'.$title.'</title>'.PHP_EOL;

		if (! is_null($description)) {
			$html[] = '<meta name="description" content="'.$description.'">';
		}

		if (! is_null($keywords)) {
			$html[] = '<meta name="keywords" content="'.$keywords.'">';
		}

		if (! is_null($miscellaneous)) {
			foreach ($miscellaneous as $name => $content) {
				$html[] = '<meta name="'.$name.'" content="'.$content.'">';
			}
		}

		if (! is_null($canonical)) {
			$currentUrl = $this->request->fullUrl();

			if ($canonical != $currentUrl) {
				$html[] = PHP_EOL.'<link rel="canonical" href="'.$canonical.'">';
			}
		}

		return implode(PHP_EOL, $html);
	}
598275
public function generate()
    {
        $code = array();

        $doc = $this->generateDocumentation();
        if ($doc !== null) {
            $code[] = $doc;
        }

        if ($this->isAbstract() === true) {
            $code[] = $this->generateSignature() . ';';
        } else {
            $code[] = $this->generateSignature();
            $code[] = $this->getIndentation() . $this->generateBody();
        }

        return implode($this->getLineFeed(), $code);
    }
828257
public function generate(): string
    {
        $elements = [];
        if ($this->label != '') {
            $elements[] = Tags::legend($this->label, []);
        }
        foreach ($this->elements as $element) {
            /** @noinspection PhpUndefinedMethodInspection */
            $elements[] = $element->generate();
        }
        return Tags::fieldset($elements, $this->attributes);
    }
740384
public function getContent()
    {
        $content = '';

        switch ($this->_alignment) {
            case self::TEXT_ALIGN_RIGHT:
                $content .= '\qr ';
                break;

            case self::TEXT_ALIGN_CENTER:
                $content .= '\qc ';
                break;

            case self::TEXT_ALIGN_JUSTIFY:
                $content .= '\qj ';
                break;

            default:
                $content .= '\ql ';
                break;
        }

        if ($this->_indentFirstLine != 0) {
            $content .= '\fi' . PHPRtfLite_Unit::getUnitInTwips($this->_indentFirstLine) . ' ';
        }

        if ($this->_indentLeft > 0) {
            $content .= '\li' . PHPRtfLite_Unit::getUnitInTwips($this->_indentLeft) . ' ';
        }

        if ($this->_indentRight > 0) {
            $content .= '\ri' . PHPRtfLite_Unit::getUnitInTwips($this->_indentRight) .' ';
        }

        if ($this->_spaceBefore > 0) {
            $content .= '\sb' . $this->_spaceBefore.' ';
        }

        if ($this->_spaceAfter > 0) {
            $content .= '\sa' . $this->_spaceAfter.' ';
        }

        if ($this->_spaceBetweenLines > 0) {
            $content .= '\sl' . $this->_spaceBetweenLines.' ';
        }

        if ($this->_border) {
            $content .= $this->_border->getContent('\\');
        }

        if ($this->_shading > 0) {
            $content .= '\shading' . $this->_shading . ' ';
        }

        if ($this->_backgroundColor && $this->_colorTable) {
            $colorIndex = $this->_colorTable->getColorIndex($this->_backgroundColor);
            if ($colorIndex !== false) {
                $content .= '\cbpat' . $colorIndex . ' ';
            }
        }

        return $content;
    }
619088
public function generate()
	{
		$this->loadWebmasterTags();

		$title       = $this->getTitle();
		$description = $this->getDescription();
		$keywords    = $this->getKeywords();
		$metatags    = $this->metatags;

		$html = array();

		$html[] = "<title>$title</title>";
		$html[] = sprintf('<meta name="description" itemprop="description" content="%s" />%s', $description, PHP_EOL);

		if (!empty($keywords)) {
			$html[] = sprintf('<meta name="keywords" content="%s" />%s', $keywords, PHP_EOL);
		}

		foreach ($metatags as $key => $value):
			$name    = $value[0];
			$content = $value[1];
			$html[] = sprintf('<meta %s="%s" content="%s" />%s', $name, $key, $content, PHP_EOL);
		endforeach;

		return implode(PHP_EOL, $html);
	}
174464
public function generate()
	{
		if (TL_MODE === 'BE') {
			return parent::generate();
		}

		$parentKey = ($this->arrData['ptable'] ?: 'tl_article') . '__' . $this->arrData['pid'];
		if (isset($GLOBALS['TL_RS_COLUMNS'][$parentKey])) {
			if (!$GLOBALS['TL_RS_COLUMNS'][$parentKey]['active']) {
				trigger_error('Missing column stop element before column wrapper stop element ID ' . $this->id . '.', E_USER_WARNING);
			}
			unset($GLOBALS['TL_RS_COLUMNS'][$parentKey]);
		}
		else {
			trigger_error('Missing column wrapper start element before column wrapper stop element ID ' . $this->id . '.', E_USER_WARNING);
		}

		$htmlSuffix = '';

		if (!empty($GLOBALS['TL_RS_COLUMNS_STACK'][$parentKey])) {
			$GLOBALS['TL_RS_COLUMNS'][$parentKey] = array_pop($GLOBALS['TL_RS_COLUMNS_STACK'][$parentKey]);
			if ($GLOBALS['TL_RS_COLUMNS'][$parentKey]['active']) {
				$htmlSuffix .= '</div>';
			}
		}

		return parent::generate() . $htmlSuffix;
	}
859985
public function generate(): string
    {
        // The tag name is required
        if ($this->getTag() === '') {
            return '';
        }

        // Generate the attribute string
        $tagAttributes = $this->generateTagAttributes();

        // When attributes are provided, add a space between the tag and the attributes
        $tagSeparator = '';
        if ($tagAttributes !== '') {
            $tagSeparator = ' ';
        }

        // Create the opening tag
        $openingTag = sprintf(
            '<%s%s%s>',
            $this->getTag(),
            $tagSeparator,
            $tagAttributes
        );

        // Create the closing tag
        $closingTag = '';
        if (! in_array($this->getTag(), self::SELF_CLOSING_TAGS)) {
            $closingTag = sprintf('</%s>', $this->getTag());
        }

        // Collect the tag information
        return $openingTag . $this->getText() . $closingTag;
    }
555123
public function GenerateDescriptionFromContent()
    {
        // check for content
        if ($content = trim($this->owner->Content)) {
            // pillage first paragraph from page content
            if (preg_match('/<p>(.*?)<\/p>/i', $content, $match)) {
                // is HTML
                $content = $match[0];
            } else {
                // is plain text
                $content = explode(PHP_EOL, $content);
                $content = $content[0];
            }
            // decode (no harm done) & return
            return trim(html_entity_decode(strip_tags($content)));
        } else {
            return null;
        }
    }
447568
public function generate()
    {
        $code = array();

        $body = $this->getExtraBody();
        $bodyHasOpenTag = preg_match('#(?:\s*)<\?php#', $body);
        $code[] = '<?php';
        $code[] = null;

        // Documentation.
        $doc = $this->generateDocumentation();
        if ($doc !== null) {
            $code[] = $doc;
            $code[] = null;
        }

        foreach ($this->objects as $object) {
            foreach ($object->getUses() as $use => $alias) {
                $this->addUse($use, $alias);
            }
        }

        // If there are objects in different namespaces or some objects are in a different namespace compared to the file namespace.
        if ($this->areMultipleNamespacesInFile() === true) {
            $code = array_merge($code, $this->renderObjects(true));

            $code[] = $this->getIndentation() . 'namespace ' . $this->namespace;
            $code[] = '{';
            $code[] = null;

            // Temporarily add one more level of indentation.
            $this->addIndentationLevel(1);

            $code = array_merge($code, $this->renderRequiredFilesLines());

            $code = array_merge($code, $this->renderUsesLines());

            if ($bodyHasOpenTag > 0) {
                $code[] = '?>';
            }

            if ($this->extraBody !== null) {
                $code[] = $this->extraBody;
            }

            // Set back the indentation.
            $this->addIndentationLevel(-1);

            $code[] = $this->getIndentation() . '}';
        } else {
            if ($this->namespace !== null) {
                $code[] = $this->getIndentation() . 'namespace ' . $this->namespace . ';';
                $code[] = null;
            }

            $code = array_merge($code, $this->renderRequiredFilesLines());

            $code = array_merge($code, $this->renderUsesLines());

            $code = array_merge($code, $this->renderObjects(false));

            if ($bodyHasOpenTag > 0) {
                $code[] = '?>';
            }

            if ($this->extraBody !== null) {
                $code[] = $this->extraBody;
            }
        }

        return implode($this->getLineFeed(), $code);
    }
850800
public function generate(): string
    {
        $setID = (string)$this->attributes['data-set-id'];
        $getState = $this->vHandler->get->get($setID.'_state', Variables::TYPE_INT) == 1;
        $postState = $this->vHandler->post->get($setID.'_state', Variables::TYPE_INT) == 1;
        $expanded = $getState || $postState;
        $this->attributes['class'] .= $expanded === true ? ' expanded' : '';

        $title = [];
        $title[] = Tags::span($this->name, ['class' => 'name']);
        $title[] = Tags::span('',
            ['class' => 'expand', 'title' => $this->getConstant('TXT_PANEL_DATA_FORM_SET_EXPAND')]);
        $title[] = Tags::span('',
            ['class' => 'collapse', 'title' => $this->getConstant('TXT_PANEL_DATA_FORM_SET_COLLAPSE')]);
        $title[] = Controlls\Text::inputHidden($setID.'_state', (int)$expanded, ['method-get' => true, 'id' => '']);

        $elements = [];
        foreach ($this->elements as $element) {
            /** @noinspection PhpUndefinedMethodInspection */
            $elements[] = $element->generate();
        }

        $set = [];
        $set[] = Tags::div($title, ['class' => 'title cf']);
        $set[] = Tags::div($elements, ['class' => 'content border-radius-5']);

        return Tags::div($set, $this->attributes);
    }
487888
public function generateForm(): string
    {
        foreach ($this->fields as $field) {
            if (is_array($field)) {
                $this->renderGroup($field);
                continue;
            }

            $this->form .= $this->render($field);
        }

        return $this->form;
    }