<?php define('SFC_TOOLS', true); include 'sfc.php'; $manager = new Manager(); if (file_exists('sfc.dat')) { $manager->load('sfc.dat'); } else { $desktop = new Desktop($manager); } $data = file('anki.txt'); foreach ($data as $d) { if (preg_match('|(.*?) : ([^-]+)(-\\s*(.*))?|', $d, $m)) { $card = new Card(trim($m[1]), trim($m[2]) . "\n" . trim($m[4]), ''); if ($manager->desktop->ids[$card->id] != null) { continue; } $manager->addCard($card); } } $desktop->save('sfc.dat');
<?php define('SFC_TOOLS', true); include 'sfc.php'; $manager = new Manager(); if (file_exists('toefl5k.dat')) { $manager->load('toefl5k.dat'); $desktop = $manager->desktop; } else { if (!file_exists('toefl5k.txt')) { echo "File toefl5k.txt not found.\n"; return; } $desktop = new Desktop($manager); $data = file('toefl5k.txt'); foreach ($data as $d) { list($w, $t, $m) = explode(' ', trim($d), 3); $card = new Card($w, '- ' . $m, ''); $manager->addCard($card); } } $cards = array(); $total = count($desktop->cards); $count = isset($argv[1]) ? intval($argv[1]) : 10; if ($count <= 0 || $count > $total) { $count = 10; } $request = $count; while ($count > 0 && $total > 0) { $n = mt_rand(0, $total - 1); $c = $desktop->cards[$n];
function export($fn, $fmt = SFC_FORMAT_RAW) { if ($fmt == SFC_FORMAT_TXT) { $fp = fopen($fn, 'w'); foreach ($this->desktop->cards as $card) { fputs($fp, $card->question . ' : ' . $card->answer . "\n"); } fclose($fp); } else { $desktop = new Desktop(); foreach ($this->desktop->cards as $card) { $desktop->add(new Card($card->question, $card->answer, $card->examples), true); } $desktop->save($fn); } }
<?php /** * Created by PhpStorm. * User: jim * Date: 2015/11/5 * Time: 22:54 */ require_once 'hello1.php'; $h = new Hello(); $h->sayHello(); $d = new Desktop(); $d->work();