Drupal进度条

Drupal有一个内置的百分比进度条显示操作进度的工具batch.

使用方式如下:

batch_set(batch_example_batch_1());

batch_process(
' redirect_page.php ' );

function  batch_example_batch_1() {

    
for  ( $i   =   0 $i < 100 $i ++ ) {
        
$operations []  =   array ( ' batch_example_op_1 ' ,   array ( $nid ));
    }
    
$batch   =   array (
            
' operations '   =>   $operations ,
            
' finished '   =>   ' batch_example_finished ' ,
    );
    
return   $batch ;
}

function  batch_example_op_1( $nid ,   & $context ) {

    do_something();

    
//  Store some result for post-processing in the finished callback.
     $context [ ' results ' ][]  =   " do something " ;

    
//  Optional message displayed under the progressbar.
     $context [ ' message ' =  t( ' Loading @title ' ,   array ( ' @title '   =>   $node -> title));

}

function  batch_example_finished( $success ,   $results ,   $operations ) {
    
if  ( $success ) {
        
$message   =   count ( $results .   '  processed. ' ;
    }
    
else  {
        
$error_operation   =   reset ( $operations );
        
$message   =   ' An error occurred while processing  '   .   $error_operation [ 0 .   '  with arguments : '   .   print_r ( $error_operation [ 0 ] ,   TRUE );
    }
    drupal_set_message(
$message );


转载于:https://www.cnblogs.com/catcat811/archive/2011/07/05/2097984.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值