解析模板中的布局标签
@access private
@param string $content 要解析的模板内容
@return void
347172
private function parseLayout(&$content) {
        // 读取模板中的布局标签
        if (preg_match($this->getRegex('layout'), $content, $matches)) {
            // 替换Layout标签
            $content = str_replace($matches[0], '', $content);
            // 解析Layout标签
            $array = $this->parseAttr($matches[0]);
            if (!$this->config['layout_on'] || $this->config['layout_name'] != $array['name']) {
                // 读取布局模板
                $layoutFile = $this->parseTemplateFile($array['name']);
                if ($layoutFile) {
                    $replace = isset($array['replace']) ? $array['replace'] : $this->config['layout_item'];
                    // 替换布局的主体内容
                    $content = str_replace($replace, $content, file_get_contents($layoutFile));
                }
            }
        }
        else {
            $content = str_replace('{__NOLAYOUT__}', '', $content);
        }
        return;
    }
76217
public function prepare($content = null)
    {
        is_null($content) || $this->setContent($content);

        $content = $this->getContent();

        $content = $this->arrayToJson($content);

        $content = $this->objectToJson($content);

        $content = $this->printRecursiveNonAlphaNum($content);

        if (! $this->jsonErrors($content)) {
            $this->header('Content-Type: application/json');
        }

        $this->setContent($content);

        return $this;
    }
518632
public function append($content = null)
        {
            if (null === $content) {
                return;
            } else if (is_array($content)) {
                foreach ($content as $row) {
                    $this->content[] = $row;
                }
            } else {
                $this->content[] = $content;
            }
            return $this;
        }
969678
public function write($content) {
        if (is_string($content) || is_numeric($content)) {
            $this->writeString($content);
        } elseif (is_bool($content)) {
            $this->writeString($content ? "TRUE" : "FALSE");
        } elseif (is_array($content)) {
            $this->writeString("Array(" . count($content) . ")");
        } elseif (is_object($content) && method_exists($content, "__toString")) {
            $this->writeString(strval($content));
        } elseif (is_null($content)) {
            $this->writeString("NULL");
        } elseif (is_resource($content)) {
            $this->writeString("Resource###");
        } else {
            throw new InvalidContentException();
        }
    }
638921
public function appendContent($content)
    {
        if (!empty($content)) {
            if (is_array($this->content)) {
                $this->content[] = $content;
            } else {
                $this->content .= $content;
            }
        }
        return $this;
    }
693290
public function addContent($content)
    {
        if ($content instanceof Page) {
            $this->addPage($content);
        }
        else {
            if ($content) {
                $this->addChild($content);
            }
            else {
                throw new Exception("Unknown content type.");
            }
        }
    }
581308
public function changeShortEchoTag($content = '')
    {
        $content = str_replace(["\r\n", "\r"], "\n", $content); //统一换行符
        if ($this->options['alternativeSyntax']) {
            $finders = ['!<\?php\s+/\*ECHO\*/echo!m', '!;/\*ENDECHO\*/\s+\?>!m'];
            $content = preg_replace($finders, ['<?=', '?>'], $content);
            $content = str_replace(['/*ECHO*/', '/*ENDECHO*/'], '', $content);
        }
        return $content;
    }
1262860
private function setContent($content)
    {
        if (is_array($content))
            $this->content = $content;
        elseif (is_string($content))
            $this->content = trim($content);

        return $this;
    }
207935
public static function log($content)
    {
        if (is_string($content)) {
            $log = $content;
        } else {
            $log = var_export($content, true);
        }
        file_put_contents('php://stdout', $log . "\n");
    }
244484
public function setContent(Content $content)
    {
        $this->contentTypeName = $content->getType()->getName();
        $this->contentId = $content->getContentId();

        return parent::setContent($content);
    }
1372197
public function setContent(string $content): void {
		if ($this->compiled) {
			throw new ViewException("Attempt to alter view after compilation.", ViewException::AFTER_COMPILE_ALTERATION);
		}
		
		// like the header above, $content might be a file or the
		// actual content
		
		$this->content = is_file($content)
			? file_get_contents($content)
			: $content;
	}
111032
protected function processLoop(string &$content): void
    {
        $paramsRexp = '\\$[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*';
        $pattern = $this->getTagPattern('loop\s+(.+?)\s+(' . $paramsRexp . ')(\s+(' . $paramsRexp . '))?');
        $content = preg_replace_callback($pattern, function ($match) {
            if (isset($match[4])) {
                return '<?php foreach(' . $match[1] . ' as ' . $match[2] . ' => ' . $match[4] . '){ ?>';
            } else {
                return '<?php foreach(' . $match[1] . ' as ' . $match[2] . '){ ?>';
            }
        }, $content);
    }
256729
private function parseInclude(&$content) {
        $regex = $this->getRegex('include');
        $func = function ($template) use (&$func, &$regex, &$content) {
            if (preg_match_all($regex, $template, $matches, PREG_SET_ORDER)) {
                foreach ($matches as $match) {
                    $array = $this->parseAttr($match[0]);
                    $file = $array['file'];
                    unset($array['file']);
                    // 分析模板文件名并读取内容
                    $parseStr = $this->parseTemplateName($file);
                    foreach ($array as $k => $v) {
                        // 以$开头字符串转换成模板变量
                        if (0 === strpos($v, '$')) {
                            $v = $this->get(substr($v, 1));
                        }
                        $parseStr = str_replace('[' . $k . ']', $v, $parseStr);
                    }
                    $content = str_replace($match[0], $parseStr, $content);
                    // 再次对包含文件进行模板分析
                    $func($parseStr);
                }
                unset($matches);
            }
        };
        // 替换模板中的include标签
        $func($content);
        return;
    }
502442
public function setDataContent($content)
    {
        if (is_array($content)) {
            $this->headers->set('Content-Type', 'application/json');
            $content = json_encode($content);
        }

        $this->setContent($content);
    }
910766
public function write ($content)
	{
		$this->createPath($this->path);
		file_put_contents($this->getName(), $content, FILE_APPEND);
	}
99922
private function writeAndRunContent($content)
    {
        $output = [];
        $this->property['debug'] = Sdopx::$debug;
        $output[] = '$_property = ' . Utils::export($this->property) . ';';
        $output[] = '$_property[\'runFunc\']=function($_sdopx,$__out){';
        $output[] = $content;
        $output[] = '};';
        $content = join("\n", $output);
        //装入变量
        $_property = null;
        try {
            @eval($content);
        } catch (\ParseError $error) {
            $this->sdopx->rethrow($error);
        }
        if (is_array($_property) && isset($_property['runFunc'])) {
            Template::$complieCache[$this->tplId] = $_property;
        }
        //装入文件
        $file = Utils::path($this->sdopx->compileDir, $this->tplId . '.php');
        file_put_contents($file, '<?php ' . $content . 'return $_property;', LOCK_EX);
        if (isset($_property['runFunc']) && is_callable($_property['runFunc'])) {
            return $this->run($_property['runFunc']);
        }
        return '';
    }
748248
public function setContent(string $content)
    {
        if (self::VISUAL === $this->getMode()) {
            $this->getDriver()->switchToIFrame(self::$wysiwyg_iframe_id);
            $this->getDriver()->executeScript(
                ';document.body.innerHTML = \'<p>' . addslashes(htmlspecialchars($content)) . '</p>\';'
            );
            $this->getDriver()->switchToIFrame();
        } else {
            $this->fillField(self::$textarea_id, $content);
        }
    }