Ejemplo n.º 1
0
 public function testReadFileText()
 {
     $this->assertEquals("BagIt-Version: 0.96\n" . "Tag-File-Character-Encoding: UTF-8\n", readFileText(__DIR__ . '/TestBag/bagit.txt', 'UTF-8'));
 }
Ejemplo n.º 2
0
        $menus = array();
        if ($directory) {
            asort($directory);
            foreach ($directory as $k => $v) {
                $file = getFile(__API__ . '/' . $v);
                $menus[$k]['num'] = count($file);
                $menus[$k]['name'] = $v;
            }
        } else {
            $menus = $directory;
        }
    }
    /* 读取解析文档内容 */
    if ($file) {
        $file_name = __API__ . '/' . $class . '/' . $file;
        $content = readFileText($file_name);
        $content = $content ? Parsedown::instance()->parse($content) : $content;
    } else {
        $content = '';
    }
} else {
    // 未登录
    $menus = '';
    $content = '';
}
/* ------------------------------------- 以上 为正式代码 --------------------------------------- */
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
Ejemplo n.º 3
0
/**
 * This reads the information from the bag it file.
 *
 * @param string $filename The bagit.txt file to read.
 *
 * @return array An array triple of the version, the file encoding, and any 
 * errors encountered.
 */
function BagIt_readBagItFile($filename)
{
    $errors = array();
    if (file_exists($filename)) {
        $data = readFileText($filename, 'UTF-8');
        $versions = BagIt_parseVersionString($data);
        if ($versions === null) {
            array_push($errors, array('bagit', 'Error reading version information from bagit.txt file.'));
        }
        $fileEncoding = BagIt_parseEncodingString($data);
    } else {
        $versions = array('major' => 0, 'minor' => 96);
        $fileEncoding = 'UTF-8';
    }
    return array($versions, $fileEncoding, $errors);
}