<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
class iTool
{
    public static $ubbMap = array(
        'find' => array('[h]', '[kk]', '[k]', '[kk]', '[k]'),
        'replace' => array("\n" ,'&nbsp;&nbsp;', '&nbsp;', '  ', ' '),
    );

    public static function filter($content)
    {
        return preg_replace('/[\x00-\x20]/i', '', $content);
    }

    public static function ubbInfo()
    {
        return '换行符:[h]<br/>空格:[k]<br/>多个空格:[kk]';
    }

    public static function ubb($content)
    {
        return str_replace(array('[h]','[k]','[kk]'), array('<br/>','&nbsp;','&nbsp;&nbsp;'), $content);
    }

    public static function filterUbb($content)
    {
        return str_replace(array('[h]','[k]','[kk]'), '', $content);
    }

    public static function editAnalyze($content)
    {
        return str_replace(self::$ubbMap['replace'], self::$ubbMap['find'], $content);
    }

    public static function saveAnalyze($content)
    {
        return filter_content(analyzeText(str_replace(self::$ubbMap['find'], self::$ubbMap['replace'], $content)));
    }
}