当前位置: 首页>>代码示例>>PHP>>正文


PHP task::run方法代码示例

本文整理汇总了PHP中task::run方法的典型用法代码示例。如果您正苦于以下问题:PHP task::run方法的具体用法?PHP task::run怎么用?PHP task::run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在task的用法示例。


在下文中一共展示了task::run方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: gallery_shutdown

 /**
  * At this point, the output has been sent to the browser, so we can take some time
  * to run a schedule task.
  */
 static function gallery_shutdown()
 {
     try {
         $schedule = ORM::factory("schedule")->where("next_run_datetime", "<=", time())->where("busy", "!=", 1)->order_by("next_run_datetime")->find_all(1);
         if ($schedule->count()) {
             $schedule = $schedule->current();
             $schedule->busy = true;
             $schedule->save();
             try {
                 if (empty($schedule->task_id)) {
                     $task = task::start($schedule->task_callback);
                     $schedule->task_id = $task->id;
                 }
                 $task = task::run($schedule->task_id);
                 if ($task->done) {
                     $schedule->next_run_datetime += $schedule->interval;
                     $schedule->task_id = null;
                 }
                 $schedule->busy = false;
                 $schedule->save();
             } catch (Exception $e) {
                 $schedule->busy = false;
                 $schedule->save();
                 throw $e;
             }
         }
     } catch (Exception $e) {
         Kohana_Log::add("error", (string) $e);
     }
 }
开发者ID:ady1503,项目名称:gallery3-contrib,代码行数:34,代码来源:scheduler_event.php

示例2: runTask

 function runTask($task_id)
 {
     access::verify_csrf();
     $task = task::run($task_id);
     if (!$task->loaded || $task->owner_id != user::active()->id) {
         access::forbidden();
     }
     print json_encode(array("result" => $task->done ? $task->state : "in_progress", "task" => array("id" => $task->id, "percent_complete" => $task->percent_complete, "type" => $task->get("type"), "post_process" => $task->get("post_process"), "status" => $task->status, "state" => $task->state, "done" => $task->done)));
 }
开发者ID:shai,项目名称:gallery3,代码行数:9,代码来源:organize.php

示例3: task

                    //                    }
                    $data['chapter_id'] = $mapData['chapter'];
                    $data['page'] = $mapData['page'];
                    $data['chapter_info'] = json_encode($data['chapter_info']);
                    $res = $this->get_data('PlayerFB')->update_player_fb($player_id, $data);
                    var_dump($res);
                }
            }
        }
    }
}
if (!empty($_POST)) {
    $player_id = $_POST['player_id'];
    $task_id = $_POST['task_id'];
    $obj = new task();
    $obj->run($player_id, $task_id);
    //    $obj->open_func($player_id,$task_id);
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> Clear Task</TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
<style>
span{
	width:150px;
开发者ID:bluefan,项目名称:phpsource,代码行数:31,代码来源:clearTask.php

示例4: run

 /**
  * Run a task.  This will trigger the task to do a small amount of work, then it will report
  * back with status on the task.
  * @param string $task_id
  */
 public function run($task_id)
 {
     access::verify_csrf();
     try {
         $task = task::run($task_id);
     } catch (Exception $e) {
         Kohana::log("error", sprintf("%s in %s at line %s:\n%s", $e->getMessage(), $e->getFile(), $e->getLine(), $e->getTraceAsString()));
         throw $e;
     }
     if ($task->done) {
         switch ($task->state) {
             case "success":
                 log::success("tasks", t("Task %task_name completed (task id %task_id)", array("task_name" => $task->name, "task_id" => $task->id)), html::anchor("admin/maintenance", t("maintenance")));
                 message::success(t("Task completed successfully"));
                 break;
             case "error":
                 log::error("tasks", t("Task %task_name failed (task id %task_id)", array("task_name" => $task->name, "task_id" => $task->id)), html::anchor("admin/maintenance", t("maintenance")));
                 message::success(t("Task failed"));
                 break;
         }
         print json_encode(array("result" => "success", "task" => array("percent_complete" => $task->percent_complete, "status" => $task->status, "done" => $task->done), "location" => url::site("admin/maintenance")));
     } else {
         print json_encode(array("result" => "in_progress", "task" => array("percent_complete" => $task->percent_complete, "status" => $task->status, "done" => $task->done)));
     }
 }
开发者ID:Okat,项目名称:gallery3,代码行数:30,代码来源:admin_maintenance.php

示例5: add_photo

 function add_photo($task_id)
 {
     access::verify_csrf();
     $task = task::run($task_id);
     if ($task->done) {
         switch ($task->state) {
             case "success":
                 message::success(t("Add from server completed"));
                 break;
             case "error":
                 message::warning(t("Add from server completed with errors"));
                 break;
         }
         print json_encode(array("result" => "success", "task" => array("id" => $task->id, "percent_complete" => $task->percent_complete, "status" => $task->status, "done" => $task->done)));
     } else {
         print json_encode(array("result" => "in_progress", "task" => array("id" => $task->id, "percent_complete" => $task->percent_complete, "status" => $task->status, "done" => $task->done)));
     }
 }
开发者ID:xafr,项目名称:gallery3,代码行数:18,代码来源:server_add.php

示例6: run_task

 public function run_task($task_id)
 {
     access::verify_csrf();
     try {
         $task = task::run($task_id);
     } catch (Exception $e) {
         $error_msg = $e->getMessage();
         $task->done = true;
     }
     if ($task->done) {
         batch::stop();
         $context = unserialize($task->context);
         switch ($task->state) {
             case "success":
                 message::success($context["success_msg"]);
                 break;
             case "error":
                 message::success(empty($error_msg) ? $context["error_msg"] : $error_msg);
                 break;
         }
         print json_encode(array("result" => "success", "task" => $task->as_array()));
     } else {
         print json_encode(array("result" => "in_progress", "task" => $task->as_array()));
     }
 }
开发者ID:ChrisRut,项目名称:gallery3-contrib,代码行数:25,代码来源:admin_developer.php

示例7: item_created


//.........这里部分代码省略.........
         $srcAR = $fileObj->audio->samplerate;
         if ($srcAR > 44100) {
             $srcAR = 44100;
         }
         $accepted_sample_rates = array(11025, 22050, 44100);
         if (!in_array($srcAR, $accepted_sample_rates)) {
             // if the input sample rate isn't an accepted rate, find the next lowest rate that is
             $below = true;
             $rate = 0;
             if ($srcAR < 11025) {
                 $rate = 11025;
             } else {
                 foreach ($accepted_sample_rates as $r) {
                     transcode::log("testing audio rate '" . $r . "' against input rate '" . $srcAR . "'");
                     if ($r < $srcAR) {
                         $rate = $r;
                     }
                 }
             }
             $srcAR = $rate;
         }
         $srcACodec = module::get_var("transcode", "audio_codec");
         $heights = array();
         if (module::get_var("transcode", "resolution_240p")) {
             array_push($heights, 240);
         }
         if (module::get_var("transcode", "resolution_360p")) {
             array_push($heights, 360);
         }
         if (module::get_var("transcode", "resolution_480p")) {
             array_push($heights, 480);
         }
         if (module::get_var("transcode", "resolution_576p")) {
             array_push($heights, 576);
         }
         if (module::get_var("transcode", "resolution_720p")) {
             array_push($heights, 720);
         }
         if (module::get_var("transcode", "resolution_1080p")) {
             array_push($heights, 1080);
         }
         if (!is_dir(VARPATH . "modules/transcode/flv/" . $item->id)) {
             @mkdir(VARPATH . "modules/transcode/flv/" . $item->id);
         }
         $xtraFlags = module::get_var("transcode", "ffmpeg_flags", "");
         foreach ($heights as $destHeight) {
             transcode::log("srcHeight: " . $srcHeight . ", destheight: " . $destHeight);
             // don't bother upscaling, there's no advantage to it...
             if ($destHeight > $srcHeight) {
                 continue;
             }
             $destFormat = module::get_var("transcode", "format", "flv");
             $destWidth = floor($destHeight * $aspect);
             if ($destWidth % 2) {
                 $destWidth = ceil($destHeight * $aspect);
             }
             transcode::log("destination resolution: " . $destWidth . "x" . $destHeight);
             $destFile = VARPATH . "modules/transcode/flv/" . $item->id . "/" . $destWidth . "x" . $destHeight . ".flv";
             switch ($destHeight) {
                 case 240:
                     $destVB = 128;
                     $srcAB = 16 * ($fileObj->audio->channels ? $fileObj->audio->channels : 2);
                     break;
                 case 360:
                     $destVB = 384;
                     $srcAB = 16 * ($fileObj->audio->channels ? $fileObj->audio->channels : 2);
                     break;
                 case 480:
                     $destVB = 1024;
                     $srcAB = 32 * ($fileObj->audio->channels ? $fileObj->audio->channels : 2);
                     break;
                 case 576:
                     $destVB = 2048;
                     $srcAB = 32 * ($fileObj->audio->channels ? $fileObj->audio->channels : 2);
                     break;
                 case 720:
                     $destVB = 4096;
                     $srcAB = 64 * ($fileObj->audio->channels ? $fileObj->audio->channels : 2);
                     break;
                 case 1080:
                     $destVB = 8192;
                     $srcAB = 64 * ($fileObj->audio->channels ? $fileObj->audio->channels : 2);
                     break;
             }
             $destVB *= 1024;
             $srcAB *= 1024;
             $cmd = $ffmpegPath . " " . "-i \"" . $srcFile . "\" ";
             if ($fileObj->audio->has) {
                 $cmd .= "-y -acodec " . $srcACodec . " " . "-ar " . $srcAR . " " . "-ab " . $srcAB . " ";
             } else {
                 $cmd .= "-an ";
             }
             $cmd .= "-vb " . $destVB . " " . "-f " . $destFormat . " " . "-s " . $destWidth . "x" . $destHeight . " " . $xtraFlags . " " . "\"" . $destFile . "\"";
             transcode::log($cmd);
             $task_def = Task_Definition::factory()->callback("transcode_task::transcode")->name("Video Transcode to " . $destWidth . "x" . $destHeight)->severity(log::SUCCESS);
             $task = task::create($task_def, array("ffmpeg_cmd" => $cmd, "width" => $destWidth, "height" => $destHeight, "item_id" => $item->id));
             task::run($task->id);
         }
     }
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:101,代码来源:transcode_event.php

示例8: elseif

$C_sess->session_constant();
$C_translate = new CORE_translate();
$C_method = new CORE_method();
if (isset($VAR['_login']) && isset($VAR['_username']) && isset($VAR['_password'])) {
    require_once PATH_CORE . 'login.inc.php';
    $C_login = new CORE_login_handler();
    $C_login->login($VAR);
} elseif (isset($VAR['_logout'])) {
    require_once PATH_CORE . 'login.inc.php';
    $C_login = new CORE_login_handler();
    $C_login->logout($VAR);
}
$C_sess->session_constant_log();
$force = false;
$C_auth = new CORE_auth($force);
$smarty = new Smarty();
$C_list = new CORE_list();
$C_block = new CORE_block();
require_once PATH_MODULES . 'task/task.inc.php';
$task = new task();
if (!empty($VAR['id'])) {
    $task->id = $VAR['id'];
} elseif (!empty($_SERVER["argv"])) {
    $task->id = $_SERVER["argv"][0];
}
set_time_limit(0);
if (@$task->id) {
    $task->run($VAR, &$task);
} else {
    $task->run_all();
}
开发者ID:chiranjeevjain,项目名称:agilebill,代码行数:31,代码来源:task.php

示例9: run

 /**
  * Run the task of adding photos
  */
 function run($task_id)
 {
     access::verify_csrf();
     $task = ORM::factory("task", $task_id);
     if (!$task->loaded || $task->owner_id != user::active()->id) {
         access::forbidden();
     }
     $task = task::run($task_id);
     print json_encode(array("done" => $task->done, "status" => $task->status, "percent_complete" => $task->percent_complete));
 }
开发者ID:hiwilson,项目名称:gallery3,代码行数:13,代码来源:server_add.php

示例10: add_photo

 function add_photo($task_id)
 {
     if (!user::active()->admin) {
         access::forbidden();
     }
     access::verify_csrf();
     $task = task::run($task_id);
     // @todo the task is already run... its a little late to check the access
     if (!$task->loaded || $task->owner_id != user::active()->id) {
         access::forbidden();
     }
     if ($task->done) {
         switch ($task->state) {
             case "success":
                 message::success(t("Add from server completed"));
                 break;
             case "error":
                 message::warning(t("Add from server completed with errors"));
                 break;
         }
         print json_encode(array("result" => "success", "task" => array("id" => $task->id, "percent_complete" => $task->percent_complete, "status" => $task->status, "done" => $task->done)));
     } else {
         print json_encode(array("result" => "in_progress", "task" => array("id" => $task->id, "percent_complete" => $task->percent_complete, "status" => $task->status, "done" => $task->done)));
     }
 }
开发者ID:kstyrvoll,项目名称:gallery3,代码行数:25,代码来源:server_add.php

示例11: run

 /**
  * Run the task of creating the theme
  */
 static function run($task_id)
 {
     access::verify_csrf();
     $task = ORM::factory("task", $task_id);
     if (!$task->loaded() || $task->owner_id != identity::active_user()->id) {
         access::forbidden();
     }
     $task = task::run($task_id);
     // Prevent the JavaScript code from breaking by forcing a period as
     // decimal separator for all locales with sprintf("%F", $value).
     json::reply(array("done" => (bool) $task->done, "status" => (string) $task->status, "percent_complete" => sprintf("%F", $task->percent_complete)));
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:15,代码来源:admin_themeroller.php

示例12: runTask

 function runTask($task_id)
 {
     access::verify_csrf();
     $task = task::run($task_id);
     print json_encode(array("result" => $task->done ? $task->state : "in_progress", "task" => array("id" => $task->id, "percent_complete" => $task->percent_complete, "type" => $task->get("type"), "post_process" => $task->get("post_process"), "status" => $task->status, "state" => $task->state, "done" => $task->done)));
 }
开发者ID:xafr,项目名称:gallery3,代码行数:6,代码来源:organize.php


注:本文中的task::run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。