links for 2007-07-31


修正 Wordpress 2.2 Widget 的 bug


尽管Wordpress 2.2的Widget和Automattic的Sidebar Widget插件兼容,但是却存在一个不大不小的bug:

在调用register_sidebar注册超过一个Sidebar的时候,如果同时指定了Sidebar的名称,那么最终只能注册成功一个

Sidebar,例如按照Automattic的API应该可以使用register_sidebar (2, array (‘name’ => ‘aaa %d’))注册依次为aaa 1,aaa 2的sidebar,而在wordpress中的结果则是只有一个名为aaa的sidebar,看看代码(WORDPRESS DIR/wp-include/widgets.php)

function register_sidebars($number
= 1, $args = array()) {
$number = (int) $number;
if ( is_string($args) )
parse_str($args, $args);

$i = 1;

while ( $i < = $number ) {
$_args = $args;
if ( $number > 1 ) {
$_args['name'] = isset($args['name']) ? $args['name'] : sprintf(__
(
'Sidebar %d'), $i);
} else {
$_args['name'] = isset($args['name']) ? $args['name'] : __('Sidebar');
}

$_args['id'] = isset($args['id']) ? $args['id'] : "sidebar-$i";
register_sidebar($_args);
++$i;
}
}

嗯。。。相信已经有同学看出来了,在注册多于一个sidebar时,sidebar的名字是

 

isset($args[’name’]) ? $args[’name’] : sprintf(__(’Sidebar %d’), $i);

就是说如果指定了名字则已指定的名字为准,没有指定名称时才会按数字递增,那么修改就很容易了(其实照抄Automattic Sidebar Widget的就可以了,嘿嘿)

 

function register_sidebars($number = 1, $args = array()) {
$number = (int) $number;
if ( is_string($args) )
parse_str($args, $args);

$name = $args['name'] ? $args['name'] : __('Sidebar');

$i = 1;
while ( $i < = $number ) {
if ( isset($args['name']) && $number > 1 ) {
if ( !strstr($name, '%d') )
$name = "$name %d";
$args['name'] = sprintf($name, $i);
}
register_sidebar($args);
++$i;
}
}

ok,收工

 

转用Zooomr了


嗯。。。flickr被和谐了,没办法

大概选择在巴巴变,yupoo和zooomr,yupoo似乎不错,而且没什么流量容量的限制,但是我这里的速度实在是不可忍受,巴巴变的速度还可以,不过每个月50m的限制让我最终决定选择zooomr

不过有点担心zooomr会不会什么时候也被我们伟大的墙和谐了

不管了,和谐了再说吧

The Sad Cafe




Out in the shiny night, the rain
Was softly falling
The tracks that ran down the boulevard had
All been washed away

Out of the silver light, the past came softly calling
And I remember the times we spent
Inside the sad cafe

Oh, it seemed like a holy place,
Protected by amazing grace
And we would sing right out loud, the
Things we could not say
We thought we could change this world
With words like “love” and “freedom”
We were part of the lonely crowd
Inside the sad cafe

Oh, expecting to fly,
We would meet on that beautiful shore in the
Sweet by and by

Some of their dreams came true,
Some just passed away
And some of the stayed behind
Inside the sad cafe.

The clouds rolled in and hid that shore
Now that glory train, it don’t stop here no more
Now I look at the years gone by,
And wonder at the powers that be.
I don’t know why fortune smiles on some
And let’s the rest go free

Maybe the time has drawn the faces I recall
But things in this life change very slowly,
If they ever change at all
There’s no use in asking why,
It just turned out that way
So meet me at midnight baby
Inside the sad cafe.
Why don’t you meet me at midnight baby,
Inside the sad cafe.

segmentation fault


在继我被一个不知道什么人写的程序的segmentation fault搞到segmentation fault之后,没想到gdb自己也segmentation fault了

Program received signal SIGABRT, Aborted.
[Switching to Thread -1209059648 (LWP 3740)]
0×006bd402 in __kernel_vsyscall ()
(gdb) bt
#0 0×006bd402 in __kernel_vsyscall ()
#1 0×00b0bd40 in raise () from /lib/libc.so.6
#2 0×00b0d591 in abort () from /lib/libc.so.6
#3 0×00b0538b in __assert_fail () from /lib/libc.so.6

#36 0×00cb5342 in g_main_context_dispatch () from /lib/libglib-2.0.so.0
#37 0×00cb831f in g_main_context_check () from /lib/libglib-2.0.so.0
#38 0×00cb86c9 in g_main_loop_run () from /lib/libglib-2.0.so.0
#39 0×0664dbe4 in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
#40 0×08052578 in GNFLCDeco_Start (deco=0×8bf3de0) at gnflcdeco.c:232
#41 0×0804c3fb in main (argc=146784256, argv=0×8be2df0) at main.c:50
(gdb) p deco
Segmentation fault


真不知道是程序太烂还是我水平太烂……