制作了一个wordpress的收藏插件
filed in PHP on May.25, 2008, by javafuns
花费了一下午加半个晚上时间,制作了这个供收藏用的插件。
对php不熟悉,什么都要查资料,太费时费力了。
不过,通过这个小插件,基本搞懂了如何开发wordpress插件了。
filed in PHP on May.25, 2008, by javafuns
花费了一下午加半个晚上时间,制作了这个供收藏用的插件。
对php不熟悉,什么都要查资料,太费时费力了。
不过,通过这个小插件,基本搞懂了如何开发wordpress插件了。
filed in PHP, WebService和SOA on May.24, 2008, by javafuns
UDDI 规范对简单类型数据的长度作出了限制, <2.3 Element and attribute types and lengths>
一. Containment and references
UDDI Registry 包含4种核心数据结构类型, 分别是businessEntity, businessService, bindingTemplate 和 tModel, 其中tModel不与其它3个数据结构发生包含关系, 而每个businessEntity则可以包含1个或多个不同的businessService, 每个businessService则可以包含bindingTemplate, bindingTemplate则包含有指向tModel的引用.
需要注意的是, 一个entity不会包含在2个或2个以上的其它entity中, 即一个entity只能包含在另一个(且只能是一个)entity中. 但这条规则不适用于 reference, 如bindingTemplate对tModel的reference.
二. Collections
一些简单的element如name, description只是简单的罗列出来, 而对于复杂的元素如contact, 则有一个容器container, 如contact的容器container是contacts.
三. Optional attributes
大部分可选的属性都有默认值(”"). 从UDDI的角度上来讲,忽略一个attribute和为attribute赋予空值(”")是等同的, 但对签名来说, 这二者则完全不同, 这二者的数字签名完全不同, 尽管在客户端认为它们是一样的.
这种区别加重了客户端发布实体的负担. 因此, UDDI API Schema 数据结构element为可选的attribute定义了默认值, 这样, 那些被忽略的attribute将被看作是被指定了默认值.
不过addressLine里的 xml:lang and keyValue 例外. 它们都禁止空的字符串. 空字符串不是有效的语言代码, 而keyValue要求字符串最小长度是1.
四. businessEntity Structure
每个 businessEntity entity 包含一个商业实体或者组织的描述性信息, 和通过它所包含的businessService实体, 这个商业实体或组织所提供的服务信息.
从一个 XML 角度来看, businessEntity 是顶级数据结构, 用于包含它所描述的该商业实体或组织的描述信息.
每个被包含的 businessService 描述了该商业实体或组织提供的一组逻辑服务.
类似的, 包含在businessService 的每个 bindingTemplate 提供了该businessService所描述的web service的技术描述信息.
1). businessKey是可选属性
当向一个 UDDI Registry发布一个 businessEntity时, 如果发布者想要registry生成一个key的话, 那么一定要忽略 businessKey. 当从一个 UDDI Registry取得一个 businessEntity 时, businessKey 也必定要存在于这个 businessEntity 中.
businessEntity 的 name, 简短业务 description 和 contacts 支持多语言. 必需的非空的 name 和可选的 description 可以出现多次. contacts 是一组 contact 的列表.
businessServices 是一组 businessEntity 所提供的业务服务列表.
除了 businessKey 用于唯一标识 businessEntity 外, identifierBag 也包含了一组其它标识符列表, 每个都在它们自己的标识符系统中有效.
2). discoveryURLs 是一组(至少1个) URL 列表(0..1)
一个 discoveryURL 是一个 URL , 指向通过 Web 可访问 (via HTTP GET) 文档. 至于返回什么样的文档则没有明确定义. Rather, a framework for establishing conventions is provided, and a particular convention is defined within this specification.
useType 是可选属性
每个 discoveryURL 都可能有一个 useType attribute, 通过给这个所赋值的名字表明当前引用的文档所遵从的惯例. 一个保留的惯例值是 “businessEntity”. 推荐以这个值进行限定的 discoveryURLs 指向 businessEntity 类型的 XML documents, 就如在 UDDI API Schema 中定义的那样.
如下面这个例子:
<discoveryURL useType=”businessEntity”>
http://www.example.com?businessKey=uddi:example.com:registry:sales:53
</discoveryURL>
另一个 discoveryURL 保留值是 “homepage”. 以这个值进行修饰的 discoveryURL 表示一个商业实体的主页可以通过这个 URL 找到.
3). name(1..∞)
businessEntity 可能包含不止1个 name, 比如有的表示法律名称, 有的用于缩写形式.
xml:lang 属性是可选的
当 name 是属于某种语言时, 应当(should)使用 xml:lang. 如果没有与之对应的语言, 那么忽略它.
当使用 xml:lang 时表示当前内容(及其子元素, 直到该属性被覆盖为止)需要在这种特定语言下解析. 该属性的值遵从 RFC 3066, 除了最大26个字符长度这个限制外.
4). description
一个 businessEntity 可以有多个 description, 例如使用了不同语言.
description 也有一个可选的 xml:lang 属性, 表明当前这个描述所属的语言. 对 description 的字数没有限制.
5). contacts
contacts 是 contact 的容器(1..∞).
6). contact
contact 记录了当前 businessEntity (商业实体) 的联系人或者职务角色的联系信息, 这样可以通过这些信息进行联系.
这些信息由一个或多个可选的element组成, personName则是至少要有一个.
useType attribute 用于描述联系类型, 如: “技术问题”, “技术联系方式”, “创建帐号”, “销售联系方式”, 等.
description 用于描述联系信息应当怎样使用.
personName 是用于联系的人的名字或者职务角色的名字.
phone 是用于联系的电话号码. 这个 element 有一个可选的 useType 属性可用于描述目的.
email 是用于联系的 email 地址. 这个 element 有一个可选的 useType 属性可用于描述目的.
address 是用于联系的邮政地址, 见下.
7). address
address 结构是一个 addressLine 的列表.
它有4个可选属性:
8). addressLine
addressLine 包含一部分文本形式的实际地址.
它有 2 个可选属性, keyName and keyValue.
如果在 address 中指定了一个 tModelKey , 那么在每个 addressLine 中这2个属性都必须存在. 当没有 tModelKey 时, keyName 和 keyValue 属性没有意义.
9). businessServices
businessServices 用于描述一组(1..∞)Web服务
10). identifierBag
将businessEntity使用identifier systems进行标识.
每个 identifierBag 都是一组由1个或多个 keyedReference 构成的列表, 每个 keyedReference 代表着一个标识.
11). keyedReference (in identifierBags)
identifierBag中的keyedReference代表着一个特定的标识系统.
keyedReference也是由tModelKey, keyName and keyValue这3个属性构成. 必需属性tModelKey引用着表示identifier system的tModel, 必需属性keyValue则是这个标识系统中的实际的标识. keyName是可选的, 可用于描述这个标识. 忽略keyName则会当作空的keyName对待.
12). categoryBag
categoryBag是可选的, 利用它可以对businessEntity按照已发布的分类法进行分类. categoryBag也包含一个或多个keyedReference. categoryBag也可能包含一个或多个keyedReferenceGroup.
但不管怎样, categoryBag里必须至少包含一个keyedReference或者一个 keyedReferenceGroup.
13). keyedReference (in categoryBags)
这个element上面已经解释过了. 不过, 如果keyedReference 的 tModelKey 指向的是 general_keywords 分类法系统, 那么必须提供keyName, 这个时候的keyName代表的是分类法中的一个值.
14). keyedReferenceGroup
一个keyedReferenceGroup是一列keyedReference, 且有一个 tModelKey 属性. keyedReferenceGroup 至少要包含一个keyedReference
filed in PHP on Apr.27, 2008, by javafuns
wordpress不能发邮件是很郁闷的,因为有些功能是需要邮件通知的,譬如说有新评论啦,等等。
《让 WordPress 通过 SMTP 发送邮件》介绍了可以让你的wordpress发送邮件的3个插件,这3个插件不是使用操作系统的邮件服务器而是实实在在的php函数:
filed in PHP on Apr.03, 2008, by javafuns
这是一个台湾人做的plugin,有了这个plugin就可以对每篇文章的访问量进行统计了。感谢作者的无私奉献。
filed in PHP on Mar.29, 2008, by co-writer
hiI just want to try this plugin.
filed in PHP on Mar.16, 2008, by javafuns
中午升级了wordpress到2.3.3,但却发现通过中文标签找不到相关文章,是由于URL附带中文参数的问题。后来在一位老兄博客上,发现了一篇文章,介绍如何解决这个问题。试了试还是不行,自己对php不熟悉,很是头疼啊。
这篇文章是wordpress.org.cn上的,讲的跟上面那位老兄是一个方法:
修改了 wp-includes/classes.php,把第 44 行开始的几行略做修改,修改前的代码:
if ( isset($_SERVER['PATH_INFO']) )
$pathinfo = $_SERVER['PATH_INFO'];
else
$pathinfo = '';
$pathinfo_array = explode('?', $pathinfo);
$pathinfo = str_replace("%", "%25", $pathinfo_array[0]);
$req_uri = $_SERVER['REQUEST_URI'];
修改后的代码:
if ( isset($_SERVER['PATH_INFO']) )
$pathinfo = mb_convert_encoding($_SERVER['PATH_INFO'], "UTF-8", "GBK");
else
$pathinfo = '';
$pathinfo_array = explode('?', $pathinfo);
$pathinfo = str_replace("%", "%25", $pathinfo_array[0]);
$req_uri = mb_convert_encoding($_SERVER['REQUEST_URI'], "UTF-8", "GBK");
既然两个人都是这样的解决办法,想必问题还是出在我这里。于是我按照 Java 定位问题的方式查找到底问题出在哪里了。
首先,我先单独把 mb_convert_encoding 函数拎出来,试试这个函数到底好用不,岂知页面根本无输出
接着,我用 function_exists 这个函数检查 mb_convert_encoding 到底在我的 windows2003+iis+php 上存不存在
果然,这个函数无效,也就是说一个叫 php_mbstring.dll 的库根本没有加载进来。
索性,直接把 php 安装包里的 php_mbstring.dll 复制到了 ext 目录下,然后修改了 php.ini 里面 [PHP_MBSTRING]
extension=php_mbstring.dll
这样重新启动后,便加载了这个 dll ,而且经过上述步骤测试,函数 mb_convert_encoding 能得到输出结果
最后,按照上面博文说明,修改 classes.php ,谢天谢地,中文 tag 终于可以正常使用了
filed in Java, PHP on Mar.09, 2008, by javafuns
IOC container, in spring framework is BeanFactory, contains the following functions:
BeanFactory is the base of the other modules in springframework.
Collection type for bean’s property:
Lazy init for bean: <bean id=”xxx” class=”xxx” lazy-init=”true”>
ApplicationContext: a more useful Ioc container which is BeanFactory’s subclass, is much more suitable for programmers to choose in their Enterprise Applications.
including more functions than BeanFactory:
filed in PHP on Jan.08, 2008, by javafuns
上个月就搭建了Windows 2003 + IIS + php + Mysql的服务器环境,但一直没多少时间把blog迁移到这上面来。
最近,花了几天时间做迁移,发现了不少问题,最头大的是迁移后blog访问不了,页面打不开,后来将问题定位到php的require函数在Windows上有个怪异的表现:require页面不能使用 ./ 这样的形式,否则保你程序不好用。这个问题不知道是不是在windows上apache也一样。
测试一下代码高亮
public class HelloWorld {
public static void main(String[] args) {
System.out.println("hello, world!");
}
}
public class HelloWorld {
public static void main(String[] args) {
System.out.println(”hello, world!”);
}
}
filed in PHP on Aug.24, 2007, by javafuns
All rights are reserved by original author, please see its licence for detail.
See its demo named My iTunes Store at right panel on my blog
Download here
Installation:
1.untar it and put in wp_content/plugins
2.check to modify the url used in coolplayer.php if necessary
3.go to Admin, activate it in Plugins tab
4.write the code as below:
<p id=”player2″><a href=“http://www.macromedia.com/go/getflashplayer”>Get the Flash Player</a> to see this player.</p>
5. ok, that’s all
Optional: it is only available if your blog supports widget
6. edit your wp_includes/widget.php file, add the following code in function wp_widgets_init():
$class[’classname’] = ‘widget_recent_entries’; //for css wp_register_sidebar_widget(’iTunes-Store’, __(’My iTunes Store’), ‘wp_widget_itunes’, $class); wp_register_widget_control(’iTunes-Store’, __(’My iTunes Store’), ‘wp_widget_itunes’, $dims90);
7. at last, add a new function called wp_widget_itunes like this:
function wp_widget_itunes($args) {
extract($args);
$title=”My iTunes Store”;
echo $before_widget . $before_title . $title . $after_title;
echo ‘