Exemple #1
0
 public function filter($value)
 {
     $value = parent::filter($value);
     $value = trim(preg_replace('#\\s+#usi', ' ', $value));
     return $value;
 }
    {
        return $this->h($text, 1);
    }
    function link($href, $text = null)
    {
        return '<a href="' . $href . '">' . ($text ? $text : $href) . '</a>';
    }
    function end()
    {
        return "</body>\n</html>\n";
    }
}
if (isset($_SERVER['REQUEST_METHOD'])) {
    $r = new HTML();
} else {
    $r = new PlainText();
}
function detect_math($r, &$out)
{
    $out .= $r->h2('Math support');
    $ext = Auth_OpenID_detectMathLibrary(Auth_OpenID_math_extensions());
    if (!isset($ext['extension']) || !isset($ext['class'])) {
        $out .= $r->p('Your PHP installation does not include big integer math ' . 'support. This support is required if you wish to run a ' . 'secure OpenID server without using SSL.');
        $out .= $r->p('To use this library, you have a few options:');
        $gmp_lnk = $r->link('http://www.php.net/manual/en/ref.gmp.php', 'GMP');
        $bc_lnk = $r->link('http://www.php.net/manual/en/ref.bc.php', 'bcmath');
        $out .= $r->ol(array('Install the ' . $gmp_lnk . ' PHP extension', 'Install the ' . $bc_lnk . ' PHP extension', 'If your site is low-security, call ' . 'Auth_OpenID_setNoMathSupport(), defined in Auth/OpenID/BigMath.php. ', 'The library will function, but ' . 'the security of your OpenID server will depend on the ' . 'security of the network links involved. If you are only ' . 'using consumer support, you should still be able to operate ' . 'securely when the users are communicating with a ' . 'well-implemented server.'));
        return false;
    } else {
        switch ($ext['extension']) {
            case 'bcmath':
        parent::__construct($target);
    }
    public function getText()
    {
        $str = parent::getText();
        $str = mb_convert_kana($str, "RANSKV");
        return $str;
    }
}
/*
 * Client
 */
$text = isset($_POST['text']) ? $_POST['text'] : '';
$decorate = isset($_POST['decorate']) ? $_POST['decorate'] : array();
if ($text !== '') {
    $text_object = new PlainText();
    $text_object->setText($text);
    //ココに注目!新たに生成されるDecoretorClassが、
    //以前のComponentClassやDecoratorクラスを保持するという構成になっている。
    foreach ($decorate as $val) {
        switch ($val) {
            case 'double':
                $text_object = new DoubleByteText($text_object);
                break;
            case 'upper':
                $text_object = new UpperCaseText($text_object);
                break;
            default:
                throw new RuntimeException('invalid decorator');
        }
    }