當前位置: 首頁>>代碼示例>>PHP>>正文


PHP graphics::find_dirty_images_query方法代碼示例

本文整理匯總了PHP中graphics::find_dirty_images_query方法的典型用法代碼示例。如果您正苦於以下問題:PHP graphics::find_dirty_images_query方法的具體用法?PHP graphics::find_dirty_images_query怎麽用?PHP graphics::find_dirty_images_query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在graphics的用法示例。


在下文中一共展示了graphics::find_dirty_images_query方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: rebuild_dirty_images

 /**
  * Task that rebuilds all dirty images.
  * @param Task_Model the task
  */
 static function rebuild_dirty_images($task)
 {
     $errors = array();
     try {
         $result = graphics::find_dirty_images_query()->select("id")->execute();
         $total_count = $task->get("total_count", $result->count());
         $mode = $task->get("mode", "init");
         if ($mode == "init") {
             $task->set("total_count", $total_count);
             $task->set("mode", "process");
             batch::start();
         }
         $completed = $task->get("completed", 0);
         $ignored = $task->get("ignored", array());
         $i = 0;
         foreach ($result as $row) {
             if (array_key_exists($row->id, $ignored)) {
                 continue;
             }
             $item = ORM::factory("item", $row->id);
             if ($item->loaded()) {
                 try {
                     graphics::generate($item);
                     $completed++;
                     $errors[] = t("Successfully rebuilt images for '%title'", array("title" => html::purify($item->title)));
                 } catch (Exception $e) {
                     $errors[] = t("Unable to rebuild images for '%title'", array("title" => html::purify($item->title)));
                     $errors[] = (string) $e;
                     $ignored[$item->id] = 1;
                 }
             }
             if (++$i == 2) {
                 break;
             }
         }
         $task->status = t2("Updated: 1 image. Total: %total_count.", "Updated: %count images. Total: %total_count.", $completed, array("total_count" => $total_count));
         if ($completed < $total_count) {
             $task->percent_complete = (int) (100 * ($completed + count($ignored)) / $total_count);
         } else {
             $task->percent_complete = 100;
         }
         $task->set("completed", $completed);
         $task->set("ignored", $ignored);
         if ($task->percent_complete == 100) {
             $task->done = true;
             $task->state = "success";
             batch::stop();
             site_status::clear("graphics_dirty");
         }
     } catch (Exception $e) {
         Kohana_Log::add("error", (string) $e);
         $task->done = true;
         $task->state = "error";
         $task->status = $e->getMessage();
         $errors[] = (string) $e;
     }
     if ($errors) {
         $task->log($errors);
     }
 }
開發者ID:andyst,項目名稱:gallery3,代碼行數:64,代碼來源:gallery_task.php

示例2: rebuild_dirty_images

 /**
  * Task that rebuilds all dirty images.
  * @param Task_Model the task
  */
 static function rebuild_dirty_images($task)
 {
     $result = graphics::find_dirty_images_query();
     $remaining = $result->count();
     $completed = $task->get("completed", 0);
     $i = 0;
     foreach ($result as $row) {
         $item = ORM::factory("item", $row->id);
         if ($item->loaded) {
             graphics::generate($item);
         }
         $completed++;
         $remaining--;
         if (++$i == 2) {
             break;
         }
     }
     $task->status = t2("Updated: 1 image. Total: %total_count.", "Updated: %count images. Total: %total_count.", $completed, array("total_count" => $remaining + $completed));
     if ($completed + $remaining > 0) {
         $task->percent_complete = (int) (100 * $completed / ($completed + $remaining));
     } else {
         $task->percent_complete = 100;
     }
     $task->set("completed", $completed);
     if ($remaining == 0) {
         $task->done = true;
         $task->state = "success";
         site_status::clear("graphics_dirty");
     }
 }
開發者ID:Juuro,項目名稱:Dreamapp-Website,代碼行數:34,代碼來源:core_task.php

示例3: rebuild_dirty_images

 /**
  * Task that rebuilds all dirty images.
  * @param Task_Model the task
  */
 static function rebuild_dirty_images($task)
 {
     $errors = array();
     try {
         $result = graphics::find_dirty_images_query();
         $completed = $task->get("completed", 0);
         $ignored = $task->get("ignored", array());
         $remaining = $result->count() - count($ignored);
         $i = 0;
         foreach ($result as $row) {
             if (array_key_exists($row->id, $ignored)) {
                 continue;
             }
             $item = ORM::factory("item", $row->id);
             if ($item->loaded) {
                 try {
                     graphics::generate($item);
                     $ignored[$item->id] = 1;
                     $errors[] = t("Successfully rebuilt images for '%title'", array("title" => html::purify($item->title)));
                 } catch (Exception $e) {
                     $errors[] = t("Unable to rebuild images for '%title'", array("title" => html::purify($item->title)));
                     $errors[] = $e->__toString();
                 }
             }
             $completed++;
             $remaining--;
             if (++$i == 2) {
                 break;
             }
         }
         $task->status = t2("Updated: 1 image. Total: %total_count.", "Updated: %count images. Total: %total_count.", $completed, array("total_count" => $remaining + $completed));
         if ($completed + $remaining > 0) {
             $task->percent_complete = (int) (100 * $completed / ($completed + $remaining));
         } else {
             $task->percent_complete = 100;
         }
         $task->set("completed", $completed);
         $task->set("ignored", $ignored);
         if ($remaining == 0) {
             $task->done = true;
             $task->state = "success";
             site_status::clear("graphics_dirty");
         }
     } catch (Exception $e) {
         $task->done = true;
         $task->state = "error";
         $task->status = $e->getMessage();
         $errors[] = $e->__toString();
     }
     if ($errors) {
         $task->log($errors);
     }
 }
開發者ID:Okat,項目名稱:gallery3,代碼行數:57,代碼來源:gallery_task.php

示例4: mark_dirty

 /**
  * Mark thumbnails and resizes as dirty.  They will have to be rebuilt.
  */
 static function mark_dirty($thumbs, $resizes)
 {
     if ($thumbs || $resizes) {
         $db = db::build()->update("items");
         if ($thumbs) {
             $db->set("thumb_dirty", 1);
         }
         if ($resizes) {
             $db->set("resize_dirty", 1);
         }
         $db->execute();
     }
     $count = graphics::find_dirty_images_query()->count_records();
     if ($count) {
         site_status::warning(t2("One of your photos is out of date. <a %attrs>Click here to fix it</a>", "%count of your photos are out of date. <a %attrs>Click here to fix them</a>", $count, array("attrs" => html::mark_clean(sprintf('href="%s" class="g-dialog-link"', url::site("admin/maintenance/start/gallery_task::rebuild_dirty_images?csrf=__CSRF__"))))), "graphics_dirty");
     }
 }
開發者ID:assad2012,項目名稱:gallery3-appfog,代碼行數:20,代碼來源:graphics.php

示例5: rebuild_dirty_images

 /**
  * Task that rebuilds all dirty images.
  * @param Task_Model the task
  */
 static function rebuild_dirty_images($task)
 {
     $errors = array();
     try {
         // Choose the dirty images in a random order so that if we run this task multiple times
         // concurrently each task is rebuilding different images simultaneously.
         $result = graphics::find_dirty_images_query()->select("id")->select(db::expr("RAND() as r"))->order_by("r", "ASC")->execute();
         $total_count = $task->get("total_count", $result->count());
         $mode = $task->get("mode", "init");
         if ($mode == "init") {
             $task->set("total_count", $total_count);
             $task->set("mode", "process");
             batch::start();
         }
         $completed = $task->get("completed", 0);
         $ignored = $task->get("ignored", array());
         $i = 0;
         // If there's no work left to do, skip to the end.  This can happen if we resume a task long
         // after the work got done in some other task.
         if (!$result->count()) {
             $completed = $total_count;
         }
         foreach ($result as $row) {
             if (array_key_exists($row->id, $ignored)) {
                 continue;
             }
             $item = ORM::factory("item", $row->id);
             if ($item->loaded()) {
                 try {
                     graphics::generate($item);
                     $completed++;
                     $errors[] = t("Successfully rebuilt images for '%title'", array("title" => html::purify($item->title)));
                 } catch (Exception $e) {
                     $errors[] = t("Unable to rebuild images for '%title'", array("title" => html::purify($item->title)));
                     $errors[] = (string) $e;
                     $ignored[$item->id] = 1;
                 }
             }
             if (++$i == 2) {
                 break;
             }
         }
         $task->status = t2("Updated: 1 image. Total: %total_count.", "Updated: %count images. Total: %total_count.", $completed, array("total_count" => $total_count));
         if ($completed < $total_count) {
             $task->percent_complete = (int) (100 * ($completed + count($ignored)) / $total_count);
         } else {
             $task->percent_complete = 100;
         }
         $task->set("completed", $completed);
         $task->set("ignored", $ignored);
         if ($task->percent_complete == 100) {
             $task->done = true;
             $task->state = "success";
             batch::stop();
             site_status::clear("graphics_dirty");
         }
     } catch (Exception $e) {
         Kohana_Log::add("error", (string) $e);
         $task->done = true;
         $task->state = "error";
         $task->status = $e->getMessage();
         $errors[] = (string) $e;
     }
     if ($errors) {
         $task->log($errors);
     }
 }
開發者ID:JasonWiki,項目名稱:docs,代碼行數:71,代碼來源:gallery_task.php


注:本文中的graphics::find_dirty_images_query方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。