コード例 #1
0
ファイル: typograf.php プロジェクト: arduanov/eco
            }
            unset($buf);
            while (!feof($fp)) {
                $buf .= fread($fp, 2048);
            }
            fclose($fp);
        } else {
            return "Server not responding";
        }
        return $buf;
    }
    $result = post("typograf.ru", "/webservice/", "chr=utf-8&text=" . urlencode($text) . '&xml=' . urlencode($params));
} elseif ($xml->type == "jare") {
    set_include_path(get_include_path() . PATH_SEPARATOR . MCETYPOGRAF_ENGINES);
    require "Jare/Typograph.php";
    $jareTypo = new Jare_Typograph($text);
    $jareTypo->getTof("etc")->disableBaseParam("paragraphs")->disableParsing(true);
    $result = $jareTypo->parse($jareTypo->getBaseTofsNames());
} else {
    // 1 — mixedEntities	— буквенными и числовыми кодами (для универсального кода. Совместимо со всеми основыми новыми и старыми браузерами)
    // 2 — xmlEntities		— только буквенными кодами (хорошо для XML, плохо для старых браузеров)
    // 3 — htmlEntities		— только числовыми кодами (кому-то нужно. Плохо для старых браузеров)
    // 4 — noEntities			— готовыми символами (символы выдаются в том виде, в каком их видит в результате читатель)
    set_include_path(get_include_path() . PATH_SEPARATOR . MCETYPOGRAF_ENGINES);
    require "remotetypograf.php";
    $remoteTypograf = new RemoteTypograf("UTF-8");
    $remoteTypograf->htmlEntities();
    $remoteTypograf->br(false);
    $remoteTypograf->p(false);
    $remoteTypograf->nobr(3);
    $result = $remoteTypograf->processText($text);
コード例 #2
0
ファイル: typo_off2.php プロジェクト: laiello/avecms
<?php

header('Content-Type: text/html; charset=utf-8');
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR . 'library');
if (empty($_POST['text'])) {
    $out_txt = '';
} else {
    $in_txt = urldecode($_POST['text']);
    require_once 'Jare/Typograph.php';
    $out_txt = Jare_Typograph::quickParse($in_txt);
}
echo $out_txt;
コード例 #3
0
ファイル: handler.php プロジェクト: m1has1k/Okay
<?php

// При ошибке мы не должны отправлять в редактор сообщение
error_reporting(0);
// Подключаем типограф Муравьева
require_once 'Jare/Typograph.php';
// Принимаем текст (html)
$text = $_POST['text'];
// Если нужно, убираем лишние кавычки
if (get_magic_quotes_gpc()) {
    $text = stripslashes($text);
}
$start_space = $end_space = '';
if ($text[0] == ' ') {
    $start_space = ' ';
}
if ($text[strlen($text) - 1] == ' ') {
    $end_space = ' ';
}
// Типографируем
$typograph = new Jare_Typograph($text);
$typograph->getTof('etc')->disableBaseParam('paragraphs');
$typograph->getTof('space')->disableBaseParam('many_spaces_to_one');
$text = $typograph->parse($typograph->getBaseTofsNames());
// Отдаем текст
print $start_space . $text . $end_space;