Exemplo n.º 1
0
function webify_file($file, $toc, $languageList, $versionList, $language, $version)
{
    $filename = basename($file);
    if ($filename == 'phpunit-book.html') {
        return;
    }
    $toc = str_replace('<a href="' . $filename . '">', '<a href="' . $filename . '" class="active">', $toc);
    $template = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'page.html');
    //i18n for title
    $title_text = array('en' => 'PHPUnit Manual', 'zh_cn' => 'PHPUnit 手册', 'ja' => 'PHPUnit マニュアル', 'pt_br' => 'Manual PHPUnit');
    $title = get_text_in_language($title_text, $language);
    $content = '';
    $prev = '';
    $next = '';
    $suggestions = '';
    $disqus = '';
    // i18n for text on page.
    $prev_text = array('en' => 'Prev', 'zh_cn' => '上一章', 'ja' => '戻る', 'pt_br' => 'Anterior');
    $next_text = array('en' => 'Next', 'zh_cn' => '下一章', 'ja' => '次へ', 'pt_br' => 'Próximo');
    $suggestions_text = array('en' => 'Please <a href="https://github.com/sebastianbergmann/phpunit-documentation/issues">open a ticket</a> on GitHub to suggest improvements to this page. Thanks!', 'zh_cn' => '如果对本页有改进建议,请 <a href="https://github.com/sebastianbergmann/phpunit-documentation/issues">在 GitHub 上开启任务单</a>。万分感谢!', 'ja' => 'このページの改善案を<a href="https://github.com/sebastianbergmann/phpunit-documentation/issues">GitHubで提案</a>してください!', 'pt_br' => 'Por favor, <a href="https://github.com/sebastianbergmann/phpunit-documentation/issues">abra um chamado</a> no GitHub para sugerir melhorias para esta página. Obrigado!');
    if ($filename !== 'index.html') {
        if (strpos($filename, 'appendixes') === 0) {
            $type = 'appendix';
        } elseif (strpos($filename, 'preface') === 0) {
            $type = 'preface';
        } else {
            $type = 'chapter';
        }
        $buffer = file_get_contents($file);
        $_title = get_substring($buffer, '<title>', '</title>', false, false);
        $content = get_substring($buffer, '<div class="' . $type . '"', '<div class="navfooter">', true, false);
        $prev = get_substring($buffer, '<link rel="prev" href="', '" title', false, false);
        $next = get_substring($buffer, '<link rel="next" href="', '" title', false, false);
        $suggestions = '<div class="row"><div class="col-md-2"></div><div class="col-md-8"><div class="alert alert-info" style="text-align: center;">' . get_text_in_language($suggestions_text, $language) . '</div></div><div class="col-md-2"></div></div>';
        $disqus = str_replace(array('{id}', '{url}'), array(sprintf('%s-%s-%s', $version, $language, str_replace('.html', '', $filename)), sprintf('https://phpunit.de/manual/%s/%s/%s', $version, $language, $filename)), file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'disqus.html'));
        if (!empty($prev)) {
            $prev = '<a accesskey="p" href="' . $prev . '">' . get_text_in_language($prev_text, $language) . '</a>';
        }
        if (!empty($next)) {
            $next = '<a accesskey="n" href="' . $next . '">' . get_text_in_language($next_text, $language) . '</a>';
        }
        if (!empty($_title)) {
            $title .= ' &#8211; ' . $_title;
        }
    }
    $buffer = str_replace(array('{filename}', '{title}', '{content}', '{toc}', '{languages}', '{language}', '{versions}', '{prev}', '{next}', '<div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;">', '<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">', '<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">', '{suggestions}', '{disqus}'), array($filename, $title, $content, $toc, $languageList, $language, $versionList, $prev, $next, '<div class="alert alert-warning">', '<div class="alert alert-danger">', '<div class="alert alert-info">', $suggestions, $disqus), $template);
    file_put_contents($file, $buffer);
}
Exemplo n.º 2
0
function printAllPermutations($str, $prefix)
{
    $strLen = strlen($str);
    if ($strLen === 1) {
        $res = put_string($prefix, $str, "\n");
    } else {
        $n = 0;
        while ($n < $strLen) {
            // We have to check case so that $n != $strLen because of get_substring
            if ($n < $strLen - 1) {
                $rest = get_substring($str, 0, $n) . get_substring($str, $n + 1, $strLen);
            } else {
                $rest = get_substring($str, 0, $n);
            }
            $pref = $prefix . get_substring($str, $n, $n + 1);
            $res = printAllPermutations($rest, $pref);
            $n = $n + 1;
        }
    }
}
Exemplo n.º 3
0
function webify_file($file, $toc, $editions)
{
    $filename = basename($file);
    if ($filename == 'phpunit-book.html') {
        return;
    }
    $toc = str_replace('<a href="' . $filename . '">', '<a href="' . $filename . '" class="active">', $toc);
    $template = file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'page.html');
    $title = '';
    $content = '';
    $prev = '';
    $next = '';
    if ($filename !== 'index.html') {
        if (strpos($filename, 'appendixes') === 0) {
            $type = 'appendix';
        } else {
            if (strpos($filename, 'preface') === 0) {
                $type = 'preface';
            } else {
                $type = 'chapter';
            }
        }
        $buffer = file_get_contents($file);
        $title = get_substring($buffer, '<title>', '</title>', FALSE, FALSE);
        $content = get_substring($buffer, '<div class="' . $type . '"', '<div class="navfooter">', TRUE, FALSE);
        $prev = get_substring($buffer, '<link rel="prev" href="', '" title', FALSE, FALSE);
        $next = get_substring($buffer, '<link rel="next" href="', '" title', FALSE, FALSE);
        if (!empty($prev)) {
            $prev = '<a accesskey="p" href="' . $prev . '">Prev</a>';
        }
        if (!empty($next)) {
            $next = '<a accesskey="n" href="' . $next . '">Next</a>';
        }
    }
    $buffer = str_replace(array('{title}', '{content}', '{toc}', '{editions}', '{prev}', '{next}'), array($title, $content, $toc, $editions, $prev, $next), $template);
    if (function_exists('tidy_repair_string')) {
        $buffer = tidy_repair_string($buffer, array('indent' => TRUE, 'output-xhtml' => TRUE, 'wrap' => 0), 'utf8');
    }
    file_put_contents($file, $buffer);
}
Exemplo n.º 4
0
<?php

$x = "0123456789";
$c = 1 - 2;
$a = get_substring($x, $c, 1);
$b = put_string($a, "\n");
Exemplo n.º 5
0
<?php

$x = "0123456789";
$c = 1 - 2;
$a = get_substring($x, 0, $c);
$b = put_string($a, "\n");
Exemplo n.º 6
0
 $xp_time_iso = date("H:i:s", $xp_time_unix);
 $xp_date_iso = date("Y-m-d", $xp_time_unix);
 $xp_date_full = $headers->Date;
 $xp_subject_text = decode_header($headers->subject);
 if (strlen($xp_subject_text) > 30 && strpos(substr($xp_subject_text, 0, 30), " ") < 1) {
     $xp_subject_show = substr($xp_subject_text, 0, 30) . ' ' . substr($xp_subject_text, 31);
 } else {
     $xp_subject_show = $xp_subject_text;
 }
 $xp_subject_inreplyto = $headers->in_reply_to;
 $xp_from_full = decode_header($headers->fromaddress);
 $xp_from_address = get_substring($xp_from_full, '<', '>');
 $xp_from_name = get_name($xp_from_full);
 $xp_from_replyto = decode_header($headers->reply_toaddress);
 $xp_to_full = decode_header($headers->toaddress);
 $xp_to_address = get_substring($xp_to_full, '<', '>');
 $xp_to_name = get_name($xp_to_full);
 /* leave the imap-prefs-file alone */
 if (substr_count($xp_from_name, "Mail System Internal Data") > 0) {
     continue;
 }
 /* construct message-id if missing */
 if (!$xp_id) {
     $xp_id = md5(imap_fetchheader($inbox, $x));
 }
 $attachments = array();
 //print_r($structure);
 if (isset($structure) && count($structure)) {
     for ($i = 0; $i < count($structure); $i++) {
         //echo 19;
         $attachments[$i] = array('is_attachment' => false, 'filename' => '', 'name' => '', 'attachment' => '', 'ver' => '');