function plugin_update_entities_create($do = FALSE)
{
    $files = array('xhtml-lat1.ent', 'xhtml-special.ent', 'xhtml-symbol.ent');
    $entities = array_map('plugin_update_entities_strtr', array_values(get_html_translation_table(HTML_ENTITIES)));
    $items = array('php:html_translation_table');
    $matches = array();
    foreach ($files as $file) {
        // FIXME: 'allow_url_fopen = Off' will stop this
        $source = file(W3C_XHTML_DTD_LOCATION . $file);
        //			or die_message('cannot receive ' . W3C_XHTML_DTD_LOCATION . $file . '.');
        if (!is_array($source)) {
            $items[] = 'w3c:' . $file . ' COLOR(red):not found.';
            continue;
        }
        $items[] = 'w3c:' . $file;
        if (preg_match_all('/<!ENTITY\\s+([A-Za-z0-9]+)/', join('', $source), $matches, PREG_PATTERN_ORDER)) {
            $entities = array_merge($entities, $matches[1]);
        }
    }
    if (!$do) {
        return $items;
    }
    $entities = array_unique($entities);
    sort($entities, SORT_STRING);
    $min = 999;
    $max = 0;
    foreach ($entities as $entity) {
        $len = strlen($entity);
        $max = max($max, $len);
        $min = min($min, $len);
    }
    $pattern = "(?=[a-zA-Z0-9]\\{{$min},{$max}})" . generate_trie_regex($entities);
    $fp = fopen(CACHE_DIR . PKWK_ENTITIES_REGEX_CACHE, 'w') or die_message('cannot write file PKWK_ENTITIES_REGEX_CACHE<br />' . "\n" . 'maybe permission is not writable or filename is too long');
    fwrite($fp, $pattern);
    fclose($fp);
    return $items;
}
예제 #2
0
function get_autolink_pattern_sub(&$pages, $start, $end, $pos)
{
    return generate_trie_regex(&$pages, $start, $end, $pos);
}