예제 #1
0
/**
 * Parse the input, strip stop/non-words, remove accents, lower case and
 * add to the index.
 *
 * @uses filter_words The function that strips the stop/non-words
 * @uses add_to_index The function that adds the filtered words to the index
 * @return void
 */
function strip_words($arr)
{
    global $allowed_chars;
    $words = $arr['title'] . " " . $arr['subtitle'] . " " . $arr['introduction'] . " " . $arr['body'] . " " . $arr['keywords'];
    $words = unentify(strip_tags(str_replace(">", "> ", str_replace("<", " <", $words))));
    $words = transliterate_accents($words);
    $words = strtolower($words);
    $result = preg_split('/[^' . preg_quote($allowed_chars) . ']/', $words);
    $filter = filter_words($result);
    add_to_index($filter, $arr['code']);
}
예제 #2
0
            $content = file_get_contents(build_path($docsetPath, $file));
            if (preg_match('/<h1>\\n*(?:Abstract\\s)?(Class|Interface|Trait)\\s([0-9a-zA-Z\\\\]+)\\n*<\\/h1>/', $content, $m)) {
                $class = trim($m[2]);
                add_to_index($db, $class, $m[1], $file);
                foreach ($extTypes as $type) {
                    if (stripos($m[2], $type) !== false) {
                        add_to_index($db, $class, $type, $file);
                    }
                }
            } else {
                trigger_error('Can\'t find class name in file ' . $file . PHP_EOL, E_ERROR);
            }
            echo $class . PHP_EOL;
            if (preg_match_all('/<div class="summary doc-(property|method|event|const)">.*<table[^>]*>(.+)<\\/table>.*<\\/div>/sU', $content, $m, PREG_SET_ORDER)) {
                foreach ($m as $item) {
                    if (preg_match_all('/<tr[^>]*id="(.+)"[^>]*>.*<td[^>]*><a[^>]*href="(.+)".*<\\/tr>/sU', $item[2], $k, PREG_SET_ORDER)) {
                        foreach ($k as $elem) {
                            $type = ucfirst($item[1]);
                            if ($type == 'Const') {
                                $type = 'Constant';
                            }
                            add_to_index($db, $class . '::' . $elem[1], $type, $elem[2]);
                        }
                    }
                }
            } else {
                trigger_error('Can\'t find any sections in file ' . $file . PHP_EOL, E_ERROR);
            }
        }
    }
}
예제 #3
0
function make_entry_indexline($write = 1)
{
    global $row;
    if (strlen($row['title']) > 2) {
        $title = $row['title'];
    } else {
        $title = substr($row['introduction'], 0, 300);
        $title = strip_tags($title);
        $title = str_replace("\n", "", $title);
        $title = str_replace("\r", "", $title);
        $title = substr($title, 0, 60);
    }
    $size = strlen($row['introduction']) + strlen($row['body']);
    $filename = str_replace("blog-", "entry", add_code_padding($row['code']) . ".php");
    $index_line = sprintf('"%d","%s","%s","%s","%s"', $row['id'], add_code_padding($row['code']), addslashes($row['date']), addslashes($row['user']), addslashes($title));
    $index_line .= sprintf(',"%s"', $filename);
    $index_line .= sprintf(',"%s"', $row['template']);
    $index_line .= sprintf(',"%s"', $size);
    if (isset($row['comments'])) {
        for ($i = 0; $i < count($row['comments']); $i++) {
            $comment_names[] = $row['comments'][$i]['name'];
        }
    }
    if (isset($comment_names)) {
        $comment_names = implode("|", $comment_names);
    }
    if (isset($row['comments'])) {
        $index_line .= sprintf(',"%s","%s"', count($row['comments']), $comment_names);
    } else {
        $index_line .= sprintf(',"0",""');
    }
    //debug($index_line);
    add_to_index($index_line);
    if ($write == 1) {
        write_index();
        //debug("write index");
    }
}