Ejemplo n.º 1
0
Archivo: Text.php Proyecto: AllenLyu/ko
 public static function S2Html($sIn, $iMaxLength = 0)
 {
     if ($iMaxLength) {
         $sIn = Ko_Tool_Str::SSubStr_UTF8($sIn, $iMaxLength);
     }
     $sIn = Ko_View_Escape::VEscapeHtml($sIn);
     if ($iMaxLength) {
         $sIn = Ko_Html_WebParse::sParse($sIn, $iMaxLength, 'UTF-8');
     }
     return $sIn;
 }
Ejemplo n.º 2
0
Archivo: Html.php Proyecto: AllenLyu/ko
 public static function S2Text($sIn, $iMaxLength = 0, $sExt = '')
 {
     $sIn = strip_tags($sIn);
     $sIn = str_replace(' ', ' ', $sIn);
     $sIn = htmlspecialchars_decode($sIn);
     $sIn = Ko_Html_Utils::SDeleteUselessBlank($sIn);
     if ($iMaxLength) {
         $sIn = Ko_Tool_Str::SSubStr_UTF8($sIn, $iMaxLength, $sExt);
     }
     return $sIn;
 }
Ejemplo n.º 3
0
 public function iGetRangeC1($sIp)
 {
     $location = $this->sGetLocation($sIp);
     $head = Ko_Tool_Str::SConvert2UTF8(substr($location, 0, 4));
     if (isset(self::$s_aChineseMainlandPrefix[$head])) {
         return self::RANGE_C1_CHINESEMAINLAND;
     } else {
         if (isset(self::$s_aHkmotwPrefix[$head])) {
             return self::RANGE_C1_HKMOTW;
         }
     }
     return self::RANGE_C1_FOREIGN;
 }
Ejemplo n.º 4
0
 protected function vPreRun()
 {
     $this->aUser = $_SESSION['admin'];
     Ko_Tool_Str::VConvert2UTF8($this->aUser);
     $this->is_admin = in_array($_SESSION['admin']['uid'], KShequ_Conf::$super_users);
     $this->oGetSmarty()->vAssignHtml('__user', $this->aUser);
     $this->oGetSmarty()->vAssignHtml("is_super", $this->is_admin ? 1 : 0);
     //权限检查
     $this->_vCheckPriority();
     list($top_menus, $cur_menu, $left_nav_html) = $this->_aGetNavData();
     if (!$this->bIsAjaxRequest()) {
         $this->oGetSmarty()->vAssignHtml('__top_menus', $top_menus);
         $this->oGetSmarty()->vAssignHtml('__cur_menus', $cur_menu);
         $this->oGetSmarty()->vAssignRaw('__admin_nav', $left_nav_html);
         $this->oGetSmarty()->vAssignHtml('__admin_with', $this->_aGetRuntimeData());
     }
 }
Ejemplo n.º 5
0
 protected function _aGetRegionArr($sRegion)
 {
     $regions = preg_split('/;|,|\\s/', $sRegion);
     $ret = array();
     foreach ($regions as $region) {
         $region = trim($region);
         if (0 === strlen($region)) {
             continue;
         }
         $region = Ko_Tool_Str::AStr2Arr($region, $this->_aConf['isgb'] ? 'GB18030' : 'UTF-8');
         $region = implode('', array_slice($region, 0, 2));
         if (!$this->_aConf['isgb']) {
             $region = Ko_Tool_Str::SConvert2GB18030($region);
         }
         $ret[] = $region;
     }
     return $ret;
 }
Ejemplo n.º 6
0
 private static function _VFilterErrorCode($vData, $sCharset)
 {
     if (is_array($vData)) {
         Ko_Tool_Str::VFilterErrorCode($vData, $sCharset, 'strict');
         return $vData;
     }
     return Ko_Tool_Str::SFilterErrorCode($vData, $sCharset, 'strict');
 }
Ejemplo n.º 7
0
Archivo: Node.php Proyecto: AllenLyu/ko
 private function _sGetAbstractHtml($sHtml, $iMaxLength, $sCharset)
 {
     if ($iMaxLength <= 0) {
         return '';
     }
     $sExt = '...';
     $iExtLen = strlen($sExt);
     if ($iExtLen >= $iMaxLength) {
         return substr($sExt, 0, $iMaxLength);
     }
     $sRet = Ko_Tool_Str::SSubStr($sHtml, $iMaxLength, $sExt, $sCharset);
     $sConvert = htmlspecialchars(htmlspecialchars_decode($sRet));
     if ($sRet === $sConvert) {
         return $sRet;
     }
     return $this->_sGetAbstractHtml($sHtml, $iMaxLength - 1, $sCharset);
 }
Ejemplo n.º 8
0
Archivo: XList.php Proyecto: nuaazdh/ko
 private function _aHttpBuildQuery($aPara)
 {
     if ($this->_bPageIsGb() != $this->_bIsGb()) {
         if ($this->_bIsGb()) {
             Ko_Tool_Str::VConvert2UTF8($aPara);
         } else {
             Ko_Tool_Str::VConvert2GB18030($aPara);
         }
     }
     return http_build_query($aPara);
 }
Ejemplo n.º 9
0
 private static function _IWritePhrase($image, $phrase, $font, $fontsize, $width, $height, $textcolor, $maxangle, $maxoffset)
 {
     $size = abs(intval($fontsize));
     if ($size === 0) {
         $size = $width / strlen($phrase) - mt_rand(0, 3) - 1;
     }
     $box = imagettfbbox($size, 0, $font, $phrase);
     $textWidth = $box[2] - $box[0];
     $textHeight = $box[1] - $box[7];
     $x = ($width - $textWidth) / 2;
     $y = ($height - $textHeight) / 2 + $size;
     if (!count($textcolor)) {
         $textColor = array(mt_rand(0, 150), mt_rand(0, 150), mt_rand(0, 150));
     } else {
         $textColor = $textcolor;
     }
     $color = imagecolorallocate($image, $textColor[0], $textColor[1], $textColor[2]);
     $phraseChar = Ko_Tool_Str::AStr2Arr($phrase);
     foreach ($phraseChar as $char) {
         $box = imagettfbbox($size, 0, $font, $char);
         $pos = $box[2] - $box[0];
         $angle = mt_rand(-$maxangle, $maxangle);
         $offset = mt_rand(-$maxoffset, $maxoffset);
         imagettftext($image, $size, $angle, $x, $y + $offset, $color, $font, $char);
         $x += $pos;
     }
     return $color;
 }
Ejemplo n.º 10
0
 private function _aGetTags($tags)
 {
     if ('回收站' === $tags) {
         return array('回收站');
     }
     $tags = explode(' ', $tags);
     $tags[] = '全部';
     $tags = array_values(array_diff(array_unique($tags), array('', '未分类', '回收站')));
     if (1 === count($tags)) {
         $tags[] = '未分类';
     }
     foreach ($tags as &$tag) {
         $tag = Ko_Tool_Str::SSubStr_UTF8($tag, 60);
     }
     unset($tag);
     return $tags;
 }
Ejemplo n.º 11
0
    $oPriApi->vDeleteOneMenuPri($_POST['admin_uid'], $_POST['menu_id']);
    echo 1;
    exit;
});
Ko_Web_Route::VGet('suggest', function () {
    $sName = Ko_Web_Request::SInput("name");
    $suggest_result = KDuizhang_Tool::suggest($sName, "admin_user");
    Ko_Tool_Str::VConvert2UTF8($suggest_result);
    echo json_encode(array('ret' => 1, 'msg' => $suggest_result));
    exit;
});
Ko_Web_Route::VGet('suggestmenu', function () {
    $sName = Ko_Web_Request::SInput("name");
    $sName = Ko_Tool_Str::SConvert2GB18030(trim($sName));
    $suggest_result = KDuizhang_Tool::suggest($sName, "sq_menu", 'id', 'text');
    Ko_Tool_Str::VConvert2UTF8($suggest_result);
    $oApi = new KOperation_Menu_Api();
    $tree_api = new KOperation_Menu_TreeApi();
    $aList = $oApi->aGetAll();
    $result = array();
    if (!empty($suggest_result)) {
        foreach ($suggest_result as $v) {
            $relations = $tree_api->aGetParent($v['id'], 0);
            unset($relations[count($relations) - 1]);
            array_unshift($relations, $v['id']);
            if (!empty($relations)) {
                $relations = array_reverse($relations);
                $msg = '';
                foreach ($relations as $menu_id) {
                    $msg .= $aList[$menu_id]['text'] . '=>';
                }
Ejemplo n.º 12
0
 private static function _SGetHighlightSubStr($sText, $iLength, $sExt, $iMinPos)
 {
     $clen = mb_strlen($sText);
     $iMinPos = $iMinPos - min(floor($iLength / 10), 10);
     //回退若干个字符
     $iMinPos = min($iMinPos, $clen - floor($iLength / 2));
     //保证末尾有足够字符
     $iMinPos = max(0, $iMinPos);
     //保证大于0
     if ($iMinPos) {
         $sText = mb_substr($sText, $iMinPos);
         $sText = $sExt . Ko_Tool_Str::SShowStr_UTF8($sText, $iLength - strlen($sExt), $sExt);
     } else {
         $sText = Ko_Tool_Str::SShowStr_UTF8($sText, $iLength, $sExt);
     }
     return $sText;
 }