Esempio n. 1
0
function parse(string $zen)
{
    if (strlen($zen) === 0) {
        throw new \InvalidArgumentException('htmlgen\\html expects a non-empty string');
    } else {
        return \htmlgen\element\element(parseTag($zen), ['id' => parseId($zen), 'class' => parseClass($zen)]);
    }
}
Esempio n. 2
0
function parseContenDetail($url, $data, &$x)
{
    global $logger, $filename, $conf;
    $content = getContent($url);
    if ($content != "") {
        $row_data = array();
        foreach ($data as $key => $value) {
            $row_data[] = StringHelper::handleStrNewline(parseTag($value, $content));
        }
        $row_data[] = $url;
        if (trim($row_data[0]) || trim($row_data[1]) || trim($row_data[2])) {
            File_CSV::write($filename, $row_data, $conf);
            echo "{$x} [Ok].\n";
            $logger->log("Get {$url} content.[Ok]");
        } else {
            echo "{$x} [Fail].\n";
            $logger->log("Get {$url} content.[Fail]");
        }
        $x++;
    }
}
Esempio n. 3
0
function parse($data)
{
    if (is_array($data)) {
        $array = [];
        foreach ($data as $key => $value) {
            if (str_contains('#hl#', $value)) {
                $value = parseTag('#hl#', $value, '<span class="highlight">', '</span>');
            }
            if (str_contains('#qo#', $value)) {
                $value = parseTag('#qo#', $value, '<blockquote>', '</blockquote>');
            }
            if (str_contains('#a#', $value)) {
                $value = parseTag('#a#', $value);
            }
            if (str_contains('#img#', $value)) {
                $value = parseTag('#img#', $value);
            }
            if (str_contains('#h#', $value)) {
                $value = parseTag('#h#', $value, '<h1>', '</h1>');
            }
            //Replace tags
            $value = str_replace('#nl#', '<br/>', $value);
            $value = str_replace('#np#', '<br/><br/>', $value);
            $array[$key] = $value;
        }
        return $array;
    } else {
        //Call to self with the text as an array
        return parse(["data" => $data], $source);
    }
}