zoukankan      html  css  js  c++  java
  • 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);


  • 相关阅读:
    树的计数 + prufer序列与Cayley公式 学习笔记
    链表
    密码学摘要
    查找与排序
    匿名内部类 调用方法内局部变量
    <c:url>标签相关知识点
    Oracle 导入导出数据库
    oracle cursor
    Oracle 删除用户和表空间------创建表空间和用户
    iOS延迟执行方法
  • 原文地址:https://www.cnblogs.com/catcat811/p/2097984.html
Copyright © 2011-2022 走看看