Skip navigation.

极湖

无不用其“极”

November 2009

( Monthly archive )

ExtJS 2.x 的多行工具条实现

,

通常的写法
tbar: [{
    ... ...
}, {
    ... ...
}]

这样实现的工具条只有一行。

有时候工具条按钮比较多,一行放不下,需要加行。
简单的做法是:
tbar: new Ext.Panel({
    border: false,
    items:[{
        xtype: 'toolbar',
        items: [
            ... ...
        ]
    }, {
        xtype: 'toolbar',
        items: [
            ... ...
        ]
    }, {
        xtype: 'toolbar',
        items: [
            ... ...
        ]
    }]
})

让 Zend_Db 支持 MySQL 的 SQL_CALC_FOUND_ROWS

, ,

修改 Zend/Db/Select.php, 增加以下代码

const FOUND_ROWS     = 'foundrows'; 
const SQL_FOUND_ROWS = 'SQL_CALC_FOUND_ROWS'; 

protected static $_partsInit = array(
    self::FOUND_ROWS   => false,  
    ... ...
);

/**
 * Makes the query SELECT SQL_CALC_FOUND_ROWS.  
 *
 * @param bool $flag Whether or not add SQL_CALC_FOUND_ROWS to SELECT.
 * @return Zend_Db_Select This Zend_Db_Select object.
 */
public function foundRows($flag = true)
{
    $this->_parts[self::FOUND_ROWS] = (bool) $flag;
    return $this;
}

/**
 * Render FOUND_ROWS clause  
 *
 * @param string   $sql SQL query
 * @return string
 */
protected function _renderFoundRows($sql)
{
    if ($this->_parts[self::FOUND_ROWS]) {
        $sql .= ' ' . self::SQL_FOUND_ROWS;
    }

    return $sql;
}


以上代码的具体位置不再详述。

调用方法如下:

$select = $db->select()->foundRows()->from(
  ... ...
)->where(
  ... ...
);

$data = $db->fetchAll($select);

$stmt = $db->query("SELECT FOUND_ROWS() as cnt");
list($rec) = $stmt->fetchAll();
$count = $rec['cnt'];

三个 JavaScript 工具 + 批处理

,

收集了三个针对 JavaScript 的工具:

1. JavaScript Lint
用于 js 查错。

2. YUI Compressor
用于压缩 js 文件。

3. Closure Compiler
用于压缩和优化 js 文件。

我把以上三个工具都放在 C:\jsl 下面,并把该目录加入系统变量 PATH。
随后在 C:\jsl 下新作三个 bat 文件,分别如下:

jsl.bat
@echo off
c:\jsl\jsl.exe -conf c:\jsl\jsl.default.conf -process "%1"


yuic.bat
@echo off
java -jar C:\jsl\yuicompressor-2.4.2.jar  -v --charset utf-8 -o "%2" "%1"


jsc.bat
@echo off
java -jar c:\jsl\compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --js "%1" > "%2"


使用例:

> jsl test.js
> yuic test.js test.min.js
> jsc test.js test.compiled.js

GAE 开发最常用的两个命令

GAE开发离不开两个很简单的命令,我是想起来才用一下,每次都上搜索引擎查询用法,费时费力,因此这儿做个笔记。

命令一
dev_appserver.py appname

命令二
appcfg.py update appname

详细用法请参考 Google 的文档:
dev_appserver.py
appcfg.py

November 2009
S M T W T F S
October 2009December 2009
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30