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


PHP task::create方法代码示例

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


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

示例1: start

 static function start($task_callback, $context = array())
 {
     $tasks = task::get_definitions();
     $task = task::create($tasks[$task_callback], array());
     $task->log(t("Task %task_name started (task id %task_id)", array("task_name" => $task->name, "task_id" => $task->id)));
     return $task;
 }
开发者ID:kandsten,项目名称:gallery3,代码行数:7,代码来源:task.php

示例2: start

 /**
  * Start a new task
  * @param string $task_callback
  */
 public function start($task_callback)
 {
     access::verify_csrf();
     $tasks = task::get_definitions();
     $task = task::create($tasks[$task_callback], array());
     $view = new View("admin_maintenance_task.html");
     $view->task = $task;
     log::info("tasks", t("Task %task_name started (task id %task_id)", array("task_name" => $task->name, "task_id" => $task->id)), html::anchor(url::site("admin/maintenance"), t("maintenance")));
     print $view;
 }
开发者ID:xafr,项目名称:gallery3,代码行数:14,代码来源:admin_maintenance.php

示例3: start

 /**
  * Begin the task of adding photos.
  */
 public function start()
 {
     access::verify_csrf();
     $item = ORM::factory("item", Input::instance()->get("item_id"));
     foreach (Input::instance()->post("paths") as $path) {
         if (server_add::is_valid_path($path)) {
             $paths[] = array($path, null);
         }
     }
     $task_def = Task_Definition::factory()->callback("Server_Add_Controller::add")->description(t("Add photos or movies from the local server"))->name(t("Add from server"));
     $task = task::create($task_def, array("item_id" => $item->id, "queue" => $paths));
     print json_encode(array("result" => "started", "status" => $task->status, "url" => url::site("server_add/run/{$task->id}?csrf=" . access::csrf_token())));
 }
开发者ID:hiwilson,项目名称:gallery3,代码行数:16,代码来源:server_add.php

示例4: startTask

 function startTask($operation, $id)
 {
     access::verify_csrf();
     $items = $this->input->post("item");
     $item = ORM::factory("item", $id);
     $definition = $this->_getOperationDefinition($item, $operation);
     $task_def = Task_Definition::factory()->callback("organize_task::run")->description($definition["description"])->name($definition["name"]);
     $task = task::create($task_def, array("items" => $items, "position" => 0, "target" => $id, "type" => $definition["type"], "batch" => ceil(count($items) * 0.1)));
     // @todo If there is only one item then call task_run($task->id); Maybe even change js so
     // we can call finish as well.
     batch::start();
     print json_encode(array("result" => "started", "runningMsg" => $definition["runningMsg"], "pauseMsg" => "<div class=\"gWarning\">{$definition['pauseMsg']}</div>", "resumeMsg" => "<div class=\"gWarning\">{$definition['resumeMsg']}</div>", "task" => array("id" => $task->id, "percent_complete" => $task->percent_complete, "type" => $task->get("type"), "status" => $task->status, "state" => $task->state, "done" => $task->done)));
 }
开发者ID:xafr,项目名称:gallery3,代码行数:13,代码来源:organize.php

示例5: create

 public function create()
 {
     access::verify_csrf();
     $form = $this->_get_theme_form();
     if ($form->validate()) {
         $session = Session::instance();
         $extract_path = $session->get_once("theme_extract_path");
         $v = new View("admin_themeroller_progress.html");
         $task_def = Task_Definition::factory()->callback("themeroller_task::create_theme")->description(t("Generate theme from a themeroller archive"))->name(t("Generate theme"));
         $v->task = task::create($task_def, array("path" => $extract_path, "user_name" => SafeString::purify(identity::active_user()->name), "original_name" => SafeString::purify($form->theme->original->value), "theme_name" => SafeString::purify($form->theme->theme_name->value), "display_name" => SafeString::purify($form->theme->display_name->value), "description" => SafeString::purify($form->theme->description->value), "author_url" => SafeString::purify($form->theme->author_url->value), "info_url" => SafeString::purify($form->theme->info_url->value), "discuss_url" => SafeString::purify($form->theme->discuss_url->value), "is_admin" => $session->get("themeroller_is_admin")));
         json::reply(array("html" => (string) $v));
     } else {
         json::reply(array("result" => "error", "html" => (string) $form));
     }
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:15,代码来源:admin_themeroller.php

示例6: start

 /**
  * Begin the task of adding photos.
  */
 public function start()
 {
     access::verify_csrf();
     $item = ORM::factory("item", Input::instance()->get("item_id"));
     $task_def = Task_Definition::factory()->callback("Server_Add_Controller::add")->description(t("Add photos or movies from the local server"))->name(t("Add from server"));
     $task = task::create($task_def, array("item_id" => $item->id));
     foreach (Input::instance()->post("paths") as $path) {
         if (server_add::is_valid_path($path)) {
             $entry = ORM::factory("server_add_entry");
             $entry->path = $path;
             $entry->is_directory = intval(is_dir($path));
             $entry->parent_id = null;
             $entry->task_id = $task->id;
             $entry->save();
         }
     }
     json::reply(array("result" => "started", "status" => (string) $task->status, "url" => url::site("server_add/run/{$task->id}?csrf=" . access::csrf_token())));
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:21,代码来源:server_add.php

示例7: start

 function start($id)
 {
     access::verify_csrf();
     $paths = unserialize(module::get_var("server_add", "authorized_paths"));
     $input_files = $this->input->post("path");
     $files = array();
     $total_count = 0;
     foreach (array_keys($paths) as $valid_path) {
         $path_length = strlen($valid_path);
         foreach ($input_files as $key => $path) {
             if ($valid_path != $path && strpos($path, $valid_path) === 0) {
                 $relative_path = substr(dirname($path), $path_length);
                 $name = basename($path);
                 $files[$valid_path][] = array("path" => $relative_path, "parent_id" => $id, "name" => basename($path), "type" => is_dir($path) ? "album" : "file");
                 $total_count++;
                 unset($input_files[$key]);
             }
         }
     }
     if ($total_count == 0) {
         print json_encode(array("result" => "success", "url" => "", "task" => array("id" => -1, "done" => 1, "percent_complete" => 100, "status" => t("No Eligible files, import cancelled"))));
         return;
     }
     $task_def = Task_Definition::factory()->callback("server_add_task::add_from_server")->description(t("Add photos or movies from the local server"))->name(t("Add from server"));
     $task = task::create($task_def, array("item_id" => $id, "next_path" => 0, "files" => $files, "counter" => 0, "position" => 0, "total" => $total_count));
     batch::start();
     print json_encode(array("result" => "started", "url" => url::site("server_add/add_photo/{$task->id}?csrf=" . access::csrf_token()), "task" => array("id" => $task->id, "percent_complete" => $task->percent_complete, "status" => $task->status, "done" => $task->done)));
 }
开发者ID:xafr,项目名称:gallery3,代码行数:28,代码来源:server_add.php

示例8: test_data_create

 public function test_data_create()
 {
     access::verify_csrf();
     list($form, $errors) = $this->_get_test_data_form();
     $post = new Validation($_POST);
     $post->add_rules("albums", "numeric");
     $post->add_rules("photos", "numeric");
     $post->add_rules("comments", "numeric");
     $post->add_rules("tags", "numeric");
     $post->add_callbacks("albums", array($this, "_set_default"));
     $post->add_callbacks("photos", array($this, "_set_default"));
     $post->add_callbacks("comments", array($this, "_set_default"));
     $post->add_callbacks("tags", array($this, "_set_default"));
     if ($post->validate()) {
         $task_def = Task_Definition::factory()->callback("developer_task::create_content")->description(t("Create test content"))->name(t("Create Test Data"));
         $total = $post->albums + $post->photos + $post->comments + $post->tags;
         $success_msg = t("Successfully generated test data");
         $error_msg = t("Problems with test data generation was encountered");
         $task = task::create($task_def, array("total" => $total, "batch" => (int) ceil($total / 10), "success_msg" => $success_msg, "current" => 0, "error_msg" => $error_msg, "albums" => $post->albums, "photos" => $post->photos, "comments" => $post->comments, "tags" => $post->tags));
         batch::start();
         print json_encode(array("result" => "started", "max_iterations" => $total + 5, "url" => url::site("admin/developer/run_task/{$task->id}?csrf=" . access::csrf_token()), "task" => $task->as_array()));
     } else {
         $v = $this->_get_test_data_view(arr::overwrite($form, $post->as_array()), arr::overwrite($errors, $post->errors()));
         print json_encode(array("result" => "error", "form" => $v->__toString()));
     }
 }
开发者ID:ChrisRut,项目名称:gallery3-contrib,代码行数:26,代码来源:admin_developer.php

示例9: item_created

 static function item_created($item)
 {
     if ($item->is_movie()) {
         transcode::log("Item created - is a movie. Let's create a transcode task or 2..");
         $ffmpegPath = module::get_var("transcode", "ffmpeg_path");
         $fileObj = self::_getVideoInfo($item->file_path());
         transcode::log($fileObj);
         // Save our needed variables
         $srcFile = $item->file_path();
         $srcWidth = transcode::makeMultipleTwo($fileObj->video->width);
         $srcHeight = transcode::makeMultipleTwo($fileObj->video->height);
         $aspect = $srcWidth / $srcHeight;
         $srcFPS = $fileObj->video->fps;
         $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 . "\" ";
//.........这里部分代码省略.........
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:101,代码来源:transcode_event.php

示例10: schedule_item_sync

 static function schedule_item_sync($item)
 {
     if (!self::can_schedule()) {
         throw new Exception("Unable to initialize schedule");
     }
     $item_id = null;
     if (is_object($item) && $item instanceof Item_Model) {
         $item_id = $item->id;
     } else {
         if (is_numeric($item)) {
             $item_id = $item;
         } else {
             throw new Exception("Un-intelligible item reference passed.");
         }
     }
     $task_def = Task_Definition::factory()->callback("aws_s3_task::upload_item")->name("Amazon S3 item upload (ID: " . $item_id . ")")->severity(log::SUCCESS);
     $task = task::create($task_def, array("item_id" => $item_id));
     self::schedule_task($task);
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:19,代码来源:aws_s3.php


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