1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/yunxi59-luohu

В этом репозитории не указан файл с открытой лицензией (LICENSE). При использовании обратитесь к конкретному описанию проекта и его зависимостям в коде.
Клонировать/Скачать
JYSmarty.php 1.3 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
邓云溪 Отправлено 21.05.2018 06:02 82b8225
<?php
require 'inc/Smarty/Smarty.class.php';
$template_config = array(
"default" => array(
"name" => "普通样式",
"img" => "../images/style_default.jpg"
),
"sky" => array(
"name" => "蓝色天空",
"img" => "../images/style_default.jpg"
),
);
$smarty = new Smarty;
// 目录
$smarty->template_dir = "template/jiuyi";
$smarty->compile_dir = "template/tmp";
// 配置左右限定符
$smarty->left_delimiter = "{";
$smarty->right_delimiter = "}";
// 配置环境
$smarty->compile_check = true;
$smarty->debugging = false;
$smarty->force_compile = true;
$smarty->register_function("jy_word", "jy_set_word");
$smarty->register_function("jy_pager", "jy_api_pager");
function jy_set_word ($params) {
extract($params);
if(empty($length)) $length=300;
if(empty($etc)) $etc="...";
$strLength = 0;
$width = 0;
if(strlen($words) > $length) {
for($i = 0; $i < $length; $i++) {
if ( $strLength >= strlen($words) ){
break;
}
if ( $width>=$length){
break;
}
if( ord($words[$strLength]) > 127 ){
$strLength += 3;
$width += 2;
}else{
$strLength += 1;
$width += 1;
}
}
return substr($words, 0, $strLength).$etc;
} else {
return $words;
}
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/yunxi59-luohu.git
git@api.gitlife.ru:oschina-mirror/yunxi59-luohu.git
oschina-mirror
yunxi59-luohu
yunxi59-luohu
master