function clean_up_global_scope() { parent::clean_up_global_scope(); $locales =& GP_Locales::instance(); $locales->locales = array(); $_GET = array(); $_POST = array(); /** * @todo re-initialize all thing objects */ GP::$translation_set = new GP_Translation_Set(); GP::$original = new GP_Original(); }
function clean_up_global_scope() { GP::$user->reintialize_wp_users_object(); $locales =& GP_Locales::instance(); $locales->locales = array(); $_GET = array(); $_POST = array(); $this->flush_cache(); /** * @todo re-initialize all thing objects */ GP::$translation_set = new GP_Translation_Set(); GP::$original = new GP_Original(); }
function update_status_breakdown() { $counts = wp_cache_get($this->id, 'translation_set_status_breakdown'); if (!is_array($counts)) { /* * TODO: * - calculate weighted coefficient by priority to know how much of the strings are translated * - calculate untranslated */ $t = GP::$translation->table; $o = GP::$original->table; $counts = GP::$translation->many_no_map("\n\t\t\t\tSELECT t.status as translation_status, COUNT(*) as n\n\t\t\t\tFROM {$t} AS t INNER JOIN {$o} AS o ON t.original_id = o.id WHERE t.translation_set_id = %d AND o.status LIKE '+%%' GROUP BY t.status", $this->id); $warnings_count = GP::$translation->value_no_map("\n\t\t\t\tSELECT COUNT(*) FROM {$t} AS t INNER JOIN {$o} AS o ON t.original_id = o.id\n\t\t\t\tWHERE t.translation_set_id = %d AND o.status LIKE '+%%' AND (t.status = 'current' OR t.status = 'waiting') AND warnings IS NOT NULL", $this->id); $counts[] = (object) array('translation_status' => 'warnings', 'n' => $warnings_count); wp_cache_set($this->id, $counts, 'translation_set_status_breakdown'); } $statuses = GP::$translation->get_static('statuses'); $statuses[] = 'warnings'; foreach ($statuses as $status) { $this->{$status . '_count'} = 0; } $this->untranslated_count = 0; foreach ($counts as $count) { if (in_array($count->translation_status, $statuses)) { $this->{$count->translation_status . '_count'} = $count->n; } } } } GP::$translation_set = new GP_Translation_Set();
function test_edit_post_error_redirect_if_create_was_unsuccessful() { $this->set_admin_user_as_current(); GP::$translation_set = $this->getMock('GP_Translation_Set', array('update')); $_POST['set'] = $this->factory->translation_set->generate_args(); $this->route->edit_post($this->set->id); $this->assertErrorRedirect(); }
function test_edit_post_error_redirect_if_create_was_unsuccessful() { $this->set_admin_user_as_current(); GP::$translation_set = $this->getMockBuilder('GP_Translation_Set')->setMethods(array('update'))->getMock(); $_POST['set'] = $this->factory->translation_set->generate_args(); $_REQUEST['_gp_route_nonce'] = wp_create_nonce('edit-translation-set_' . $this->set->id); $this->route->edit_post($this->set->id); $this->assertErrorRedirect(); }