本文整理汇总了PHP中site_status::clear方法的典型用法代码示例。如果您正苦于以下问题:PHP site_status::clear方法的具体用法?PHP site_status::clear怎么用?PHP site_status::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类site_status
的用法示例。
在下文中一共展示了site_status::clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_index
static function update_index($task)
{
try {
$completed = $task->get("completed", 0);
$start = microtime(true);
foreach (ORM::factory("item")->join("exif_records", "items.id", "exif_records.item_id", "left")->where("type", "=", "photo")->and_open()->where("exif_records.item_id", "IS", null)->or_where("exif_records.dirty", "=", 1)->close()->find_all() as $item) {
// The query above can take a long time, so start the timer after its done
// to give ourselves a little time to actually process rows.
if (!isset($start)) {
$start = microtime(true);
}
exif::extract($item);
$completed++;
if (microtime(true) - $start > 1.5) {
break;
}
}
list($remaining, $total, $percent) = exif::stats();
$task->set("completed", $completed);
if ($remaining == 0 || !($remaining + $completed)) {
$task->done = true;
$task->state = "success";
site_status::clear("exif_index_out_of_date");
$task->percent_complete = 100;
} else {
$task->percent_complete = round(100 * $completed / ($remaining + $completed));
}
$task->status = t2("one record updated, index is %percent% up-to-date", "%count records updated, index is %percent% up-to-date", $completed, array("percent" => $percent));
} catch (Exception $e) {
$task->done = true;
$task->state = "error";
$task->status = $e->getMessage();
$task->log((string) $e);
}
}
示例2: activate
public function activate()
{
access::verify_csrf();
$post = new Validation($_POST);
$post->add_rules("activate_users", "required");
$post->add_rules("activate", "alpha_numeric");
if ($post->validate()) {
$names = array();
if (!empty($post->activate)) {
foreach ($post->activate as $id) {
$user = register::create_new_user($id);
$names[] = $user->name;
}
message::success(t("Activated %users.", array("users" => implode(", ", $names))));
}
$count = ORM::factory("pending_user")->where("state", "!=", 2)->count_all();
if ($count == 0) {
site_status::clear("pending_user_registrations");
}
url::redirect("admin/register");
}
list($form, $errors) = $this->_get_form();
$form = array_merge($form, $post->as_array());
$errors = array_merge($errors, $post->errors());
print $this->_get_admin_view($form, $errors);
}
示例3: update_index
static function update_index($task)
{
try {
$completed = $task->get("completed", 0);
$start = microtime(true);
foreach (ORM::factory("item")->join("exif_records", "items.id", "exif_records.item_id", "left")->where("type", "photo")->open_paren()->where("exif_records.item_id", null)->orwhere("exif_records.dirty", 1)->close_paren()->find_all() as $item) {
if (microtime(true) - $start > 1.5) {
break;
}
$completed++;
exif::extract($item);
}
list($remaining, $total, $percent) = exif::stats();
$task->set("completed", $completed);
if ($remaining == 0 || !($remaining + $completed)) {
$task->done = true;
$task->state = "success";
site_status::clear("exif_index_out_of_date");
$task->percent_complete = 100;
} else {
$task->percent_complete = round(100 * $completed / ($remaining + $completed));
}
$task->status = t2("one record updated, index is %percent% up-to-date", "%count records updated, index is %percent% up-to-date", $completed, array("percent" => $percent));
} catch (Exception $e) {
$task->done = true;
$task->state = "error";
$task->status = $e->getMessage();
$task->log($e->__toString());
}
}
示例4: saveprefs
public function saveprefs()
{
// Prevent Cross Site Request Forgery
access::verify_csrf();
// Save Settings.
module::set_var("ratings", "showunderphoto", Input::instance()->post("showunderphoto"));
module::set_var("ratings", "showinsidebar", Input::instance()->post("showinsidebar"));
module::set_var("ratings", "imageword", Input::instance()->post("imageword"));
module::set_var("ratings", "votestring", Input::instance()->post("votestring"));
module::set_var("ratings", "castyourvotestring", Input::instance()->post("castyourvotestring"));
# module::set_var("ratings", "bgcolor", Input::instance()->post("bgcolor"));
module::set_var("ratings", "fillcolor", Input::instance()->post("fillcolor"));
module::set_var("ratings", "votedcolor", Input::instance()->post("votedcolor"));
module::set_var("ratings", "hovercolor", Input::instance()->post("hovercolor"));
module::set_var("ratings", "textcolor", Input::instance()->post("textcolor"));
module::set_var("ratings", "regonly", Input::instance()->post("regonly"));
$iconset = Input::instance()->post("iconset");
$iconset = preg_replace("/\\/index\\.php/", "", $iconset);
module::set_var("ratings", "iconset", $iconset);
message::success(t("Your Settings Have Been Saved."));
site_status::clear("ratings_configuration");
// Load Admin page.
$view = new Admin_View("admin.html");
$view->content = new View("admin_ratings.html");
$view->content->ratings_form = $this->_get_admin_form();
print $view;
}
示例5: 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");
}
}
示例6: uninstall
static function uninstall()
{
$db = Database::instance();
$db->query("DROP TABLE `search_records`");
site_status::clear("search_index_out_of_date");
module::delete("search");
}
示例7: 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);
}
}
示例8: report_ppm_support
static function report_ppm_support($toolkit_id)
{
if (array_key_exists($toolkit_id, rawphoto_graphics::get_supported_toolkits())) {
site_status::clear("rawphoto_needs_ppm_support");
} else {
site_status::warning(t('The <em>Raw Photos</em> module requires a supporting graphics toolkit. ' . '<a href="%activate_url">Activate</a> either ImageMagick or GraphicsMagick.', array("activate_url" => url::site("admin/graphics"))), "rawphoto_needs_ppm_support");
}
}
示例9: upgrade
static function upgrade($version)
{
if ($version < 4) {
// No longer necessary, make sure that it's cleared.
site_status::clear("organize_needs_rest");
module::set_version("organize", $version = 4);
}
}
示例10: module_change
static function module_change($changes)
{
if (!module::is_active("rss") || in_array("rss", $changes->deactivate)) {
site_status::warning(t("The Slideshow module requires the RSS module. <a href=\"%url\">Activate the RSS module now</a>", array("url" => html::mark_clean(url::site("admin/modules")))), "slideshow_needs_rss");
} else {
site_status::clear("slideshow_needs_rss");
}
}
示例11: module_change
static function module_change($changes)
{
// If EXIF is deactivated, display a warning that it is required for this module to function properly.
if (!module::is_active("exif") || in_array("exif", $changes->deactivate)) {
site_status::warning(t("The EXIF_GPS module requires the EXIF module. " . "<a href=\"%url\">Activate the EXIF module now</a>", array("url" => html::mark_clean(url::site("admin/modules")))), "exif_gps_needs_exif");
} else {
site_status::clear("exif_gps_needs_exif");
}
}
示例12: update_overlays
static function update_overlays($task)
{
$errors = array();
try {
$mode = $task->get('mode', 'init');
switch ($mode) {
case 'init':
$q = emboss::find_dirty();
foreach ($q as $item) {
$ids[] = array('id' => $item->id, 'image_id' => $item->image_id, 'overlay_id' => $item->best_overlay_id);
}
$count = count($ids);
if ($count > 0) {
$task->set('ids', $ids);
$task->set('count', $count);
$task->set('current', 0);
$task->set('mode', 'continue');
} else {
$task->done = true;
$task->state = 'success';
$task->percent_complete = 100;
site_status::clear('emboss_dirty');
return;
}
break;
case 'continue':
$ids = $task->get('ids');
$count = $task->get('count');
$current = $task->get('current');
break;
}
$i = 1 * $current;
$id = $ids[$i];
$current++;
$task->set('current', $current);
emboss_task::do_embossing($id['id'], $id['image_id'], $id['overlay_id']);
if ($current >= $count) {
$task->done = true;
$task->state = 'success';
$task->percent_complete = 100;
$task->status = 'Complete';
site_status::clear('emboss_dirty');
} else {
$task->percent_complete = $current / $count * 100;
$task->status = t("Reembossed {$current} of {$count} photos");
}
} 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);
}
}
示例13: module_change
static function module_change($changes)
{
// Display a warning message if the RSS module is not installed.
if (!module::is_active("rss") || in_array("rss", $changes->deactivate)) {
site_status::warning(t("The MiniSlide Show module requires the RSS module. " . "<a href=\"%url\">Activate the RSS module now</a>", array("url" => url::site("admin/modules"))), "minislideshow_needs_rss");
} else {
site_status::clear("minislideshow_needs_rss");
}
}
示例14: module_change
static function module_change($changes)
{
// Gallery version must be >= 32
if (module::get_version("gallery") < 32) {
site_status::warning(t("The module 'Module Order' requires Gallery core version of 32 or higher."), "moduleorder_needs_higherversion");
} else {
site_status::clear("moduleorder_needs_higherversion");
}
}
示例15: index
public function index()
{
// If modules need upgrading, this will get recreated in module::available()
site_status::clear("upgrade_now");
$view = new Admin_View("admin.html");
$view->page_title = t("Modules");
$view->content = new View("admin_modules.html");
$view->content->available = module::available();
print $view;
}