htm = File::readAllText($filePath); $this->v = array(); // INI ファイルを読んで $conf に格納する。 $inifile = Directory::getCurrentDirectory() . "/" . INIFILE; $this->conf = $this->readIniFile($inifile); } // HTML 文字列を返す。 public function toString() : string { foreach (array_keys($this->v ) as $key) { $this->htm = str_replace('(*'.$key.'*)', $this->v[$key], $this->htm); } return $this->htm; } // HTML を出力する。 public function echo() { echo $this->toString(); } // パラメータがあれば true, なければ false public function isPostback() { return (count($_POST) + count($_GET) > 0); } // 生のヘッダーを送る。 public static function sendHttpHeader(string $header) : void { header($header); } // リダイレクト public static function redirect(string $loc) : void { header('Location: ' . $loc); } // 画像ヘッダーを送る。 public static function sendImageHeader(string $img) { $img = strtolower($img); if ($img == 'jpg') $img = 'jpeg'; header("Content-Type: image/" . $img); } // INI ファイルを読む。 public static function readIniFile(string $inifile) { if (File::exists($inifile)) return parse_ini_file($inifile); else return false; } } // タグ作成関連関数 // タグを作る。 function tag($tagname, $value, $style=null) : string { $s = "<" . $tagname ; if (isset($style)) { $s .= " " . $style; } $s .= ">"; $s .= $value; $s .= "\n"; return $s; } // Anchor タグ function anchor($href, $text, $target="") { $s = ""; if ($target != "") { $s = ""; } $s .= $text; $s .= "\n"; return $s; } // HTML テーブル行 function HtmlTableRow(array $arr, string $tr = null, string $td = null) : string { $s = ""; } else { $s .= ">"; } foreach ($arr as $c) { if (isset($td)) { $s .= ""; } else { $s .= ""; } $s .= $c; $s .= ""; } $s .= "\n"; return $s; } // HTMLテーブルを作る。 function HtmlTable(array $arr, string $tab = null, string $td = null, string $th = null) : string { $s = "\n"; if (isset($tag)) { $s = "
\n"; } $i = 0; foreach ($arr as $row) { $s .= ""; foreach ($row as $c) { if ($i == 0) { if (isset($th)) { $s .= ""; } else { $s .= ""; } } else { if (isset($td)) { $s .= ""; } else { $s .= ""; } } } $s .= "\n"; $i += 1; } $s .= "
" . $c . "" . $c . "" . $c . "" . $c . "
\n"; return $s; } // HTMLリストを作る。 function HtmlList(array $arr, bool $ol = false, string $style1 = null, string $style2 = null) { if ($ol) { if (isset($style1)) { $s = "
    \n"; } else { $s = "
      \n"; } } else { if (isset($style1)) { $s = "
        \n"; } else { $s = "
          \n"; } } foreach ($arr as $it) { if (isset($style2)) { $s .= "
        • " . $it . "
        • \n"; } else { $s .= "
        • " . $it . "
        • \n"; } } if ($ol) $s .= "
    \n"; else $s .= "\n"; return $s; } // 定義を作る。 function HtmlDefine(array $titles, array $defs, string $style1 = null, string $style2 = null) : string { $s = ""; for ($i = 0; $i < count($titles); $i++) { $s .= "
    \n"; if (isset($style1)) { $s .= "
    " . $titles[$i] . "
    \n"; } else { $s .= "
    " . $titles[$i] . "
    \n"; } if (isset($style2)) { $s .= "
    " . $defs[$i] . "
    \n"; } else { $s .= "
    " . $defs[$i] . "
    \n"; } $s .= "
    \n"; } return $s; } ?>