本文整理汇总了PHP中site_status类的典型用法代码示例。如果您正苦于以下问题:PHP site_status类的具体用法?PHP site_status怎么用?PHP site_status使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了site_status类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_index
/**
* @return string An error message suitable for inclusion in the task log
*/
static function check_index()
{
list($remaining) = search::stats();
if ($remaining) {
site_status::warning(t('Your search index needs to be updated. <a href="%url" class="g-dialog-link">Fix this now</a>', array("url" => html::mark_clean(url::site("admin/maintenance/start/search_task::update_index?csrf=__CSRF__")))), "search_index_out_of_date");
}
}
示例2: index
public function index()
{
// require_once(MODPATH . "aws_s3/lib/s3.php");
$form = $this->_get_s3_form();
if (request::method() == "post") {
access::verify_csrf();
if ($form->validate()) {
module::set_var("aws_s3", "enabled", isset($_POST['enabled']) ? true : false);
module::set_var("aws_s3", "access_key", $_POST['access_key']);
module::set_var("aws_s3", "secret_key", $_POST['secret_key']);
module::set_var("aws_s3", "bucket_name", $_POST['bucket_name']);
module::set_var("aws_s3", "g3id", $_POST['g3id']);
module::set_var("aws_s3", "url_str", $_POST['url_str']);
module::set_var("aws_s3", "sig_exp", $_POST['sig_exp']);
module::set_var("aws_s3", "use_ssl", isset($_POST['use_ssl']) ? true : false);
if (module::get_var("aws_s3", "enabled") && !module::get_var("aws_s3", "synced", false)) {
site_status::warning(t('Your site has not yet been syncronised with your Amazon S3 bucket. Content will not appear correctly until you perform syncronisation. <a href="%url" class="g-dialog-link">Fix this now</a>', array("url" => html::mark_clean(url::site("admin/maintenance/start/aws_s3_task::sync?csrf=__CSRF__")))), "aws_s3_not_synced");
}
message::success(t("Settings have been saved"));
url::redirect("admin/aws_s3");
} else {
message::error(t("There was a problem with the submitted form. Please check your values and try again."));
}
}
$v = new Admin_View("admin.html");
$v->page_title = t("Amazon S3 Configuration");
$v->content = new View("admin_aws_s3.html");
$v->content->form = $form;
$v->content->end = "";
echo $v;
}
示例3: uninstall
static function uninstall()
{
$db = Database::instance();
$db->query("DROP TABLE `search_records`");
site_status::clear("search_index_out_of_date");
module::delete("search");
}
示例4: confirm
public function confirm($hash)
{
$pending_user = ORM::factory("pending_user")->where("hash", "=", $hash)->where("state", "=", 0)->find();
if ($pending_user->loaded()) {
// @todo add a request date to the pending user table and check that it hasn't expired
$policy = module::get_var("registration", "policy");
$pending_user->state = 1;
$pending_user->save();
if ($policy == "vistor") {
$user = register::create_new_user($pending_user->id);
message::success(t("Your registration request has been approved"));
auth::login($user);
Session::instance()->set("registration_first_usage", true);
$pending_user->delete();
} else {
site_status::warning(t("There are pending user registration. <a href=\"%url\">Review now!</a>", array("url" => html::mark_clean(url::site("admin/register")), "locale" => module::get_var("gallery", "default_locale"))), "pending_user_registrations");
message::success(t("Your registration request is awaiting administrator approval"));
// added by Shad Laws, v2
if (module::get_var("registration", "admin_notify") == 1) {
register::send_admin_notify($pending_user);
}
}
} else {
message::error(t("Your registration request is no longer valid, Please re-register."));
}
url::redirect(item::root()->abs_url());
}
示例5: 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;
}
示例6: 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());
}
}
示例7: 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);
}
}
示例8: upgrade
static function upgrade($version)
{
log::info("aws_s3", "Commencing module upgrade (" . $version . ")");
switch ($version) {
case 0:
log::info("aws_s3", "Installing version 1");
@mkdir(VARPATH . "modules/aws_s3");
@mkdir(VARPATH . "modules/aws_s3/log");
// installation's unique identifier - allows multiple g3's pointing to the same s3 bucket.
if (!module::get_var("aws_s3", "g3id")) {
module::set_var("aws_s3", "g3id", md5(time()));
}
module::set_var("aws_s3", "synced", false);
module::set_var("aws_s3", "enabled", false);
module::set_var("aws_s3", "access_key", "");
module::set_var("aws_s3", "secret_key", "");
module::set_var("aws_s3", "bucket_name", "");
module::set_version("aws_s3", 1);
case 1:
log::info("aws_s3", "Upgrading to version 2");
$db = Database::instance();
$db->query("CREATE TABLE {aws_s3_meta} (\n `item_id` int(9) NOT NULL,\n `item_hash` varchar(32) NOT NULL DEFAULT '',\n `thumb_uploaded` smallint(1) NOT NULL DEFAULT 0,\n `resize_uploaded` smallint(1) NOT NULL DEFAULT 0,\n `fullsize_uploaded` smallint(1) NOT NULL DEFAULT 0,\n `local_deleted` smallint(1) NOT NULL DEFAULT 0,\n PRIMARY KEY (`item_id`)\n ) DEFAULT CHARSET=utf8;");
module::set_var("aws_s3", "upload_thumbs", true);
module::set_var("aws_s3", "upload_resizes", true);
module::set_var("aws_s3", "upload_fullsizes", true);
module::set_var("aws_s3", "s3_storage_only", false);
if (module::get_var("aws_s3", "synced")) {
// v1 has already synced this installation to s3. mark all the items with the relevant meta data
$items = ORM::factory("item")->find_all();
foreach ($items as $item) {
aws_s3::log("Updating S3 meta for item ID: " . $item->id);
$item->s3_thumb_uploaded = true;
if (!$item->is_album()) {
$item->s3_resize_uploaded = true;
$item->s3_fullsize_uploaded = true;
}
$item->s3_local_deleted = false;
$item->s3_item_hash = md5($item->relative_path());
$item->save_s3_meta();
}
} else {
// check various states after upgrade from v1..
if (module::get_var("aws_s3", "access_key") != "" && module::get_var("aws_s3", "secret_key") != "" && module::get_var("aws_s3", "bucket_name") != "" && aws_s3::validate_access_details(module::get_var("aws_s3", "access_key"), module::get_var("aws_s3", "secret_key"), module::get_var("aws_s3", "bucket_name"))) {
// details are correct but hasn't been synced.
if (aws_s3::can_schedule()) {
// i can schedule this task
aws_s3::schedule_full_sync2();
site_status::warning("Your site has been scheduled for full Amazon S3 re-synchronisation. This message will clear when this has been completed.", "aws_s3_not_synced");
} else {
// i CAN'T schedule it..
site_status::warning(t('Your site has not been synchronised to Amazon S3. Until it has, your server will continue to serve image content to your visitors.<br />Click <a href="%url" class="g-dialog-link">here</a> to start the synchronisation task.', array("url" => html::mark_clean(url::site("admin/maintenance/start/aws_s3_task::manual_sync?csrf=__CSRF__")))), "aws_s3_not_synced");
}
} else {
site_status::warning(t('Amazon S3 module needs configuration. Click <a href="%url">here</a> to go to the configuration page.', array("url" => html::mark_clean(url::site("admin/aws_s3")))), "aws_s3_not_configured");
}
}
module::set_version("aws_s3", 2);
}
log::info("aws_s3", "Module upgrade complete");
}
示例9: 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");
}
}
示例10: 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);
}
示例11: 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);
}
}
示例12: 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);
}
}
示例13: module_change
static function module_change($changes)
{
if (!module::is_active("tag") || in_array("tag", $changes->deactivate)) {
site_status::warning(t("The DisplayTags module requires the Tags module. <a href=\"%url\">Activate the Tags module now</a>", array("url" => html::mark_clean(url::site("admin/modules")))), "displaytags_needs_tag");
} else {
site_status::clear("displaytags_needs_tag");
}
}
示例14: 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");
}
}
示例15: 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);
}
}