“技术”目录存档

div 实现长英文字母自动换行CSS

2009年05月5日,星期二

诸如邮件地址太长等……

自动换行问题,正常字符的换行是比较合理的,而连续的数字和英文字符常常将容器撑大,挺让人头疼,下面介绍的是CSS如何实现换行的方法

最佳CSS定义换行代码

.wrap { table-layout:fixed; word-break: break-all; overflow:hidden; }
这里 overflow:hidden;或者 auto;
=================================================================
对于div,p等块级元素
正常文字的换行(亚洲文字和非亚洲文字)元素拥有默认的white-space:normal,当定义的宽度之后自动换行
html
<div id=”wrap”>正常文字的换行(亚洲文字和非亚洲文字)元素拥有默认的white-space:normal,当定义</div>
css
#wrap{white-space:normal; width:200px; }

1.(IE浏览器)连续的英文字符和阿拉伯数字,使用word-wrap : break-word ;或者word-break:break-all;实现强制断行

#wrap{word-break:break-all; width:200px;}
或者
#wrap{word-wrap:break-word; width:200px;}

<div id=”wrap”>abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111</div>

效果:可以实现换行

2.(Firefox浏览器)连续的英文字符和阿拉伯数字的断行,Firefox的所有版本的没有解决这个问题,我们只有让超出边界的字符隐藏或者,给容器添加滚动条
#wrap{word-break:break-all; width:200px; overflow:auto;}

<div id=”wrap”>abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111</div>

效果:容器正常,内容隐藏

对于table
http://www.knowsky.com/
1. (IE浏览器)使用 table-layout:fixed;强制table的宽度,多余内容隐藏

<table style=”table-layout:fixed” width=”200″>
<tr>
<td>abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss
</td>
</tr>
</table>

效果:隐藏多余内容

2.(IE浏览器)使用 table-layout:fixed;强制table的宽度,内层td,th采用word-break : break-all;或者word-wrap : break-word ;换行

<table width=”200″ style=”table-layout:fixed;”>
<tr>
<td width=”25%” style=”word-break : break-all; “>abcdefghigklmnopqrstuvwxyz 1234567890
</td>
<td style=”word-wrap : break-word ;”>abcdefghigklmnopqrstuvwxyz 1234567890
</td>
</tr>
</table>

效果:可以换行

3. (IE浏览器)在td,th中嵌套div,p等采用上面提到的div,p的换行方法

4.(Firefox浏览器)使用 table-layout:fixed;强制table的宽度,内层td,th采用word-break : break-all;或者word-wrap : break-word ;换行,使用overflow:hidden;隐藏超出内容,这里overflow:auto;无法起作用
<table style=”table-layout:fixed” width=”200″>
<tr>
<td width=”25%” style=”word-break : break-all; overflow:hidden; “>abcdefghigklmnopqrstuvwxyz1234567890</td>
<td width=”75%” style=”word-wrap : break-word; overflow:hidden; “>abcdefghigklmnopqrstuvwxyz1234567890</td>
</tr>
</table>

效果:隐藏多于内容

5.(Firefox浏览器) 在td,th中嵌套div,p等采用上面提到的对付Firefox的方法
运行代码框
最后,这种现象出现的几率很小,但是不能排除网友的恶搞。

下面是提到的例子的效果

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml“>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″ />
<title>字符换行</title>
<style type=”text/css”>
table,td,th,div { border:1px green solid;}
code { font-family:”Courier New”, Courier, monospace;}
</style>
</head>
<body>
<h1><code>div</code></h1>
<h1><code>All white-space:normal;</code></h1>
<div style=”white-space:normal; width:200px;”>Wordwrap still occurs in a td element that has its WIDTH attribute set to a value smaller than the unwrapped content of the cell, even if the noWrap property is set to true. Therefore, the WIDTH attribute takes precedence over the noWrap property in this scenario</div>

<h1><code>IE \ word-wrap : break-word ;</code></h1>
<div style=”word-wrap : break-word ; width:200px;”>abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111</div>
<h1><code>IE \ word-break:break-all;</code></h1>
<div style=”word-break:break-all;width:200px;”>abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111</div>

<h1><code>Firefox/ word-break:break-all; overflow:auto;</code></h1>
<div style=”word-break:break-all; width:200px; overflow:auto;”>abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111</div>
<h1><code>table</code></h1>
<h1><code>table-layout:fixed;</code></h1>
<table style=”table-layout:fixed” width=”200″>
<tr>
<td>abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss</td>
</tr>
</table>
<h1><code>table-layout:fixed; word-break : break-all; word-wrap : break-word ;</code></h1>
<table width=”200″ style=”table-layout:fixed;”>
<tr>
<td width=”25%” style=”word-break : break-all; “>abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss</td>
<td style=”word-wrap : break-word ;”>abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss</td>
</tr>
</table>
<h1><code>FF \ table-layout:fixed; overflow:hidden;</code></h1>
<table style=”table-layout:fixed” width=”200″>
<tr>
<td width=”25%” style=”word-break : break-all; overflow:hidden; “>abcdefghigklmnopqrstuvwxyz1234567890</td>
<td width=”75%” style=”word-wrap : break-word; overflow:hidden; “>abcdefghigklmnopqrstuvwxyz1234567890</td>
</tr>
</table>
</body>
</html>

template不被cache

2009年04月30日,星期四

{set-block scope=global variable=cache_ttl}0{/set-block}

XMLBOCK中添加
换行

2009年04月28日,星期二

按住shift+enter。
有个问题:想连续几个换行,但总不成功。解决办法:输入一个空格,然后shift+enter,就可以了

RemoveSiteAccessIfDefaultAccess

2009年04月28日,星期二

site.ini中,[SiteAccessSettings]设置

# Wheter to add siteaccess to the url if current siteaccess
# is the same as default siteaccess. Changing this setting will
# require clearing the cache.
#
# For instance if the default siteaccess is ‘en’ and you enable
# this you can access the siteacccess with ‘index.php’ instead of
# ‘index.php/en/’.
RemoveSiteAccessIfDefaultAccess=disabled

4.1 user subscription fatal error

2009年04月16日,星期四

when i try to subscribe as new user with user/register i obtain a
<code>PHP Fatal error: Call to a member function attribute() on a non-object in /ez/web/dev.visionova.it/kernel/classes/datatypes/eztext/eztexttype.php on line 99</code>
the problem is due to $classAttribute var that is declared inside if, just put the
<code>$classAttribute = $contentObjectAttribute->contentClassAttribute();</code>
few lines above.

http://issues.ez.no/IssueView.php?Id=14741&activeItem=2

把XMLBLOCK中的内容提取出来(转换成textblock)

2009年04月15日,星期三

因为PHP已经提供了strip_tags函数,可以创建一个template.ini.append.php,加入:PHPOperatorList[strip_tags]=strip_tags

然后通过$your_text|strip_tags()来调用就可以了。

关于strip_tags:

strip_tags

去掉 HTML 及 PHP 的标记。

语法: string strip_tags(string str);

返回值: 字符串

函数种类: 资料处理

内容说明

本函数可去掉字符串中包含的任何 HTML 及 PHP 的标记字符串。若是字符串的 HTML 及 PHP 标签原来就有错,例如少了大于的符号,则也会返回错误。而本函数和 fgetss() 有着相同的功能。

mysql远程备份+导入

2008年09月12日,星期五

mysqldump   -h172.20.6.250   -udev   -p123456   –opt   smis_test   |   mysql   -hlocalhost   -uroot   -C   smis_test

change_mysql_character.php

2008年09月12日,星期五

安装ez publish的时候,有时候需要修改mysql数据库的character,留个纪念:

<?php

// This program will alter the default character set to UTF8, which is required for the
// default settings of eZ Publish

$link = mysql_connect(”localhost”, “uername”, “password”)
or die(”Could not connect: ” . mysql_error());
$result = mysql_query(”ALTER DATABASE `database` DEFAULT CHARACTER SET utf8″, $link);
if($result) {
echo “Success :-) ”;
} else
echo “Failure :-( ”;
mysql_close($link);

?>

记录:修正FluxBB的中文URL

2008年09月9日,星期二

问题见:http://www.fluxbb.cn/forum/post/138/#p138

中文的子论坛以及帖子名称成了空的,试着读了下代码,发现是一个sef_friendly的函数的问题,去掉,可以显示中文的URL地址,但是寻思着不安全(谁让你去掉人家一个函数的);一不做二不休,找个wp拼音插件,然后直接编辑了FluxBB的内核代码——俺知道错了,应该用extension的形式,谁让咱还不熟悉呢,因此这篇日志仅仅做个记录而已,不推荐使用。

1、下载拼音插件,上传到FluxBB的目录下(除了pinyin-slug.php我都穿到inculde下面了)

2、把pinyin-slug.php的函数加到了functions.php里,同时做了点修改,函数如下:

//added by Mingxing Chen 9/9/2008

function pinyin_slugs($title) {

//global $wpdb;

require_once FORUM_ROOT.’include/class.Chinese.php’;
$codeTablesDir = dirname(__FILE__).”/config/”;

$chs = new Chinese(”UTF8″,”GB2312″, $title,$codeTablesDir);
$title = $chs->ConvertIT();
$chs = new Chinese(”GB2312″,”PinYin”,$title,$codeTablesDir);
$title = $chs->ConvertIT();
$title = str_replace(” “,”",$title);

return $title;
}
//end

3、编辑index.php 162行,替换sef_friendly($cur_forum['forum_name'])为sef_friendly(pinyin_slugs($cur_forum['forum_name']))

4、编辑viewforum.php和viewtopic.php,替换sef_friendly($cur_topic['forum_name'])为sef_friendly(pinyin_slugs($cur_forum['forum_name'])),sef_friendly($cur_topic['subject'])替为sef_friendly(pinyin_slugs($cur_topic['subject']))

5、因为有个warning,顺便编辑了class.Chinese.php的169行,加了个变量声明$bindata = “”;

over

先这样,做个记录

玩了下FluxBB,一个字——快

2008年09月9日,星期二

从ez上面看到一个fluxbb的extension,通过ez的template operator把论坛的东东与ez关联起来。就这样,偶遇fluxbb,顺便找到了FluxBB 中文下载了个测试了把,速度真不错。关于FluxBB的介绍如下:

PHP论坛,我想接触过的人大多不会陌生。国外,PHPBB, IPB, vBulletin 等杰出论坛程序群雄逐鹿,国内则是Discuz! 的一统天下。然而听说过 FluxBB 的人则比较少。

那么就先让我们来了解一下历史,FluxBB 原名为 PunBB,由于之前 PunBB 被一家俄国公司(informer)收购后,几位主要的开发人员对现状产生了不满的情绪(开发的过程不想让他人干扰),因此分道扬镳,成立了 FluxBB。 PunBB 的产生也纯属偶然,当时其创始人 Rickard Andersson 正在为一个项目寻找一套论坛程序,然而在现有论坛程序中,他并没有找到合适的 (有效的 XHTML 输出,快速,简洁)论坛程序。因此他决定自己开发一套轻量级的论坛程序,PunBB 于2003年8月诞生了。

根据 PunBB 的简洁理念,其论坛程序只包含最最基本的功能,就连论坛短信,附件,投票这些功能都不存在。当然,因为遵循 GPL 开源协议,任何人都可以对程序经行修改,再发布,因而很多第三方的MOD孕育而生。这些MOD的出现,解决了 PunBB 功能上的缺陷,不过由于添加 MOD 需要修改大量的核心代码,因此每次程序上的升级都让人苦不堪言。因而就出现了随后的 1.3 版本,以及随后的 FluxBB

1.3版本的出现,对于 PunBB 或者 FluxBB 来说无疑是一个质的飞跃,最值得一提的便是其强大的插件扩展系统,和FireFox 一 样,几乎所有的功能都可以以扩展(Extension)的形式来开发,并且论坛管理员可以轻松地通过一键式的扩展安装系统来无限制地扩充论坛的功能。并且 论坛内核程序的更新并不会影响到扩展的使用。用户可以根据自己的需要来下载所需的插件,或者通过插件开发,来扩展论坛的功能。和其他论坛程序相比,从扩展 性,执行效率,以及易用性来看,FluxBB 有着明显的优势。

几大论坛的成功我们有目共睹,然而 FluxBB 所带来的体验,是前所未有的。其他论坛在实际运用中,半数甚至多的数功能并不被经常使用,可是为了满足所有用户的需求,这些功能则必须强制性地被安装在论 坛程序中,而管理员所能做的,只是选择关闭或开启部分功能。对于初级用户来说,设置一个论坛程序无疑是一次挑战,面对数目繁多的设置选项,往往会无从下 手。而对于高级用户来说,扩展论坛也不是一件轻松的事情。更重要的是,这些让人无从下手的设置往往是不必要的,比如,在一个非娱乐性论坛上计算用户在线时 长或等级是一件很难理解的事情,而且这些多余的功能应用在专业性比较强论坛上,不免有些滑稽。而 FluxBB 则有效地避免了这些尴尬。

http://www.fluxbb.cn/blog/2008/06/03/%E6%AC%A2%E8%BF%8E%E6%9D%A5%E5%88%B0-fluxbb-%E4%B8%AD%E5%9B%BD/