Ejemplo n.º 1
0
function DocTest($IsCompressed)
{
    $d = new PalmDoc('Title Goes Here', $IsCompressed);
    $text = "Mary had a little lamb,\n" . "little lamb,\n" . "little lamb.\n" . "Mary had a little lamb,\n" . "its fleece as white as snow.\n" . "\n" . "It followed her to school one day,\n" . "school one day,\n" . "school one day.\n" . "It followed her to school one day.\n" . "and I hope this doc text test works well.\n" . "\n" . "(Yeah, I know.  It does not rhyme.)\n";
    // Just in case the file is edited and the newlines are changed a bit.
    $text = str_replace("\r\n", "\n", $text);
    $text = str_replace("\r", "\n", $text);
    $text = explode("\n", $text);
    $newText = '';
    foreach ($text as $t) {
        trim($t);
        $newText .= $t . "\n";
    }
    $d->AddText($newText);
    return GenerateMd5($d);
}
Ejemplo n.º 2
0
stored bookmarks.</p>

<p>The easiest way to avoid being tricked is to just download and HotSync a
new copy of the test for each type of bookmark for each DOC reader you wish
to test.</p>
<?php 
    TinyFooter();
    ?>
</body></html>
<?php 
    exit;
}
if ($Stored) {
    $pdb = new PalmDoc("Stored Bookmark Test");
} else {
    $pdb = new PalmDoc("Embedded Bookmark Test");
}
if ($Stored) {
    $ThisTest = "stored";
    $OtherTest = "embedded";
    $UcFirst = "Stored";
} else {
    $ThisTest = "embedded";
    $OtherTest = "stored";
    $UcFirst = "Embedded";
}
$pdb->AddText("This is a test file to see if {$ThisTest} " . "bookmarks are recognized by a document reader.  To determine if " . "{$OtherTest} bookmarks are supported, you'll need to use the " . "other bookmark test, which is available from " . "https://github.com/fidian/php-pdb (in the examples)." . "To figure out if it worked, look for the bookmark list in this " . "document reader.  If it has a bookmark named \"{$UcFirst} " . "Bookmark\", then it worked.  If not, then this document reader " . "doesn't support {$ThisTest} style bookmarks.\n\n" . "This document was automatically generated using the PHP-PDB " . "library -- a free, GPL'd PHP library that manipulates PDB " . "files.  Feel free to give it a look at\n" . "https://github.com/fidian/php-pdb\n\n");
// Add the bookmark
if ($Stored) {
    $pdb->AddBookmark("Stored Bookmark");
} else {
Ejemplo n.º 3
0
function StoreAsPRC($title, $rawData)
{
    // echo "<h1>$title</h1>\n<pre>$rawData\n</pre>\n"; return;
    global $SavedPDB, $UncompressedDoc, $TargetType, $CompressWarningDisplayed;
    $fileName = preg_replace('/[^-a-zA-Z_0-9]/', '_', $title);
    if (!isset($SavedPDB) || !is_array($SavedPDB)) {
        $SavedPDB = array();
        session_register('SavedPDB');
    }
    $SavedInfo['Title'] = $title;
    $SavedInfo['Type'] = $TargetType;
    $SavedInfo['Time'] = time();
    if ($TargetType == 'DOC') {
        if (isset($UncompressedDoc) && $UncompressedDoc) {
            $prc = new PalmDoc($title, false);
        } else {
            $prc = new PalmDoc($title);
        }
        $prc->AddDocText($rawData);
        if (!isset($CompressWarningDisplayed)) {
            $WarningTime = '';
            if (count($prc->Records) > 5) {
                $WarningTime = 'a bit';
            }
            if (count($prc->Records) > 10) {
                $WarningTime = 'a while';
            }
            if (count($prc->Records) > 15) {
                $WarningTime = 'a long time';
            }
            if (count($prc->Records) > 25) {
                $WarningTime = 'a very long time';
            }
            if (count($prc->Records) > 40) {
                $WarningTime = 'enough time to write a poem';
            }
            if (count($prc->Records) > 60) {
                $WarningTime = 'enough time for you learn a new hobby';
            }
            if (count($prc->Records) > 100) {
                $WarningTime = 'so long that PHP will likely time out and ' . 'kill this conversion';
            }
            if ($WarningTime != '') {
                ShowStatus("Compressing the DOC.\nThis could take " . $WarningTime . '.');
            }
            $CompressWarningDisplayed = true;
        }
    } elseif ($TargetType == 'SmallBASIC') {
        $prc = new PalmSmallBASIC($title);
        $result = $prc->ConvertFromText($rawData);
        if (is_array($result)) {
            ShowError('Error converting the file.  The section "' . $result[1] . '" is too big.  It must be broken into ' . 'multiple sections for the conversion to work.');
            return;
        }
    }
    ob_start();
    $prc->WriteToStdout();
    $prc = ob_get_contents();
    ob_end_clean();
    $SavedInfo['Data'] = $prc;
    $key = $fileName;
    $num = 1;
    while (isset($SavedPDB[$key])) {
        $num++;
        $key = $fileName . '-' . $num;
    }
    $SavedPDB[$key] = $SavedInfo;
}
Ejemplo n.º 4
0
function DocTest($IsCompressed)
{
    $d = new PalmDoc("Title Goes Here", $IsCompressed);
    $text = <<<EOS
Mary had a little lamb,
little lamb,
little lamb.
Mary had a little lamb,
its fleece as white as snow.

It followed her to school one day,
school one day,
school one day.
It followed her to school one day.
and I hope this doc text test works well.

(Yeah, I know.  It doesn't rhyme.)
EOS;
    $text = str_replace("\r\n", "\n", $text);
    $text = str_replace("\r", "\n", $text);
    $text = explode("\n", $text);
    $newText = '';
    foreach ($text as $t) {
        trim($t);
        $newText .= $t . "\n";
    }
    $d->AddDocText($newText);
    return GenerateMd5($d);
}