function new_get()
 {
     $set = new GP_Translation_Set();
     $set->project_id = gp_get('project_id');
     $project = $set->project_id ? GP::$project->get($set->project_id) : null;
     if ($this->cannot_edit_set_and_redirect($set)) {
         return;
     }
     $this->tmpl('translation-set-new', get_defined_vars());
 }
Exemple #2
0
 function new_get()
 {
     $set = new GP_Translation_Set();
     $set->project_id = gp_get('project_id');
     if ($set->project_id) {
         $this->can_or_redirect('write', 'project', $set->project_id, gp_url_project(GP::$project->get($set->project_id)));
     }
     $all_project_options = self::_options_from_projects(GP::$project->all());
     $all_locale_options = self::_options_from_locales(GP_Locales::locales());
     gp_tmpl_load('translation-set-new', get_defined_vars());
 }
Exemple #3
0
 public function locales_get()
 {
     if (NULL !== gp_get('all', NULL)) {
         $locales = GP_Locales::locales();
     } else {
         $existing_locales = GP::$translation_set->existing_locales();
         $locales = array();
         foreach ($existing_locales as $locale) {
             $locales[] = GP_Locales::by_slug($locale);
         }
         usort($locales, array($this, 'sort_locales'));
     }
     $this->tmpl('locales', get_defined_vars());
 }
 function new_get()
 {
     $glossary = new GP_Glossary();
     $glossary->translation_set_id = gp_get('translation_set_id');
     $translation_set = $glossary->translation_set_id ? GP::$translation_set->get($glossary->translation_set_id) : null;
     if (!$translation_set) {
         $this->redirect_with_error(__('Cannot find translation set with this ID.'));
         return;
     }
     $project = GP::$project->get($translation_set->project_id);
     if (GP::$glossary->by_set_id($glossary->translation_set_id)) {
         $glossary_url = gp_url_join(gp_url_project($project, array($translation_set->locale, $translation_set->slug)), array('glossary'));
         $this->redirect_with_error(__('The glossary for this translation set already exists.'), $glossary_url);
         return;
     }
     if ($this->cannot_edit_glossary_and_redirect($glossary)) {
         return;
     }
     $locale = GP_Locales::by_slug($translation_set->locale);
     $this->tmpl('glossary-new', get_defined_vars());
 }
Exemple #5
0
 function translations_get($project_path, $locale_slug, $translation_set_slug)
 {
     $project = GP::$project->by_path($project_path);
     $locale = GP_Locales::by_slug($locale_slug);
     $translation_set = GP::$translation_set->by_project_id_slug_and_locale($project->id, $translation_set_slug, $locale_slug);
     if (!$project || !$locale || !$translation_set) {
         gp_tmpl_404();
     }
     $page = gp_get('page', 1);
     $filters = gp_get('filters', array());
     $sort = gp_get('sort', array());
     if ('random' == gp_array_get($sort, 'by')) {
         add_filter('gp_pagination', create_function('$html', 'return "";'));
     }
     $translations = GP::$translation->for_translation($project, $translation_set, $page, $filters, $sort);
     $total_translations_count = GP::$translation->found_rows;
     $per_page = GP::$translation->per_page;
     $can_edit = GP::$user->logged_in();
     $can_approve = $this->can('approve', 'translation-set', $translation_set->id);
     $url = gp_url_project($project, gp_url_join($locale->slug, $translation_set->slug));
     $discard_warning_url = gp_url_project($project, gp_url_join($locale->slug, $translation_set->slug, '_discard-warning'));
     $approve_action = gp_url_join($url, '_approve');
     gp_tmpl_load('translations', get_defined_vars());
 }
Exemple #6
0
 function translations_get($project_path, $locale_slug, $translation_set_slug)
 {
     $project = GP::$project->by_path($project_path);
     $locale = GP_Locales::by_slug($locale_slug);
     if (!$project || !$locale) {
         return $this->die_with_404();
     }
     $translation_set = GP::$translation_set->by_project_id_slug_and_locale($project->id, $translation_set_slug, $locale_slug);
     if (!$translation_set) {
         return $this->die_with_404();
     }
     $glossary = GP::$glossary->by_set_or_parent_project($translation_set, $project);
     $page = gp_get('page', 1);
     $filters = gp_get('filters', array());
     $sort = gp_get('sort', array());
     if ('random' == gp_array_get($sort, 'by')) {
         add_filter('gp_pagination', '__return_null');
     }
     $per_page = get_user_option('gp_per_page');
     if (0 == $per_page) {
         $per_page = GP::$translation->per_page;
     } else {
         GP::$translation->per_page = $per_page;
     }
     $translations = GP::$translation->for_translation($project, $translation_set, $page, $filters, $sort);
     $total_translations_count = GP::$translation->found_rows;
     $can_edit = $this->can('edit', 'translation-set', $translation_set->id);
     $can_write = $this->can('write', 'project', $project->id);
     $can_approve = $this->can('approve', 'translation-set', $translation_set->id);
     $url = gp_url_project($project, gp_url_join($locale->slug, $translation_set->slug));
     $set_priority_url = gp_url('/originals/%original-id%/set_priority');
     $discard_warning_url = gp_url_project($project, gp_url_join($locale->slug, $translation_set->slug, '-discard-warning'));
     $set_status_url = gp_url_project($project, gp_url_join($locale->slug, $translation_set->slug, '-set-status'));
     $bulk_action = gp_url_join($url, '-bulk');
     // Add action to use different font for translations
     add_action('gp_head', function () use($locale) {
         return gp_preferred_sans_serif_style_tag($locale);
     });
     $this->tmpl('translations', get_defined_vars());
 }
Exemple #7
0
 function new_get()
 {
     $project = new GP_Project();
     $project->parent_project_id = gp_get('parent_project_id', null);
     $this->can_or_redirect('write', 'project', $project->parent_project_id);
     $all_project_options = self::_options_from_projects(GP::$project->all());
     gp_tmpl_load('project-new', get_defined_vars());
 }
 public function new_get()
 {
     $project = new GP_Project();
     $project->parent_project_id = gp_get('parent_project_id', null);
     if ($this->cannot_and_redirect('write', 'project', $project->parent_project_id)) {
         return;
     }
     $this->tmpl('project-new', get_defined_vars());
 }
			<?php 
do_action('before_login_form');
?>

			<input name="user_login" type="text" class="form-control" placeholder="<?php 
_e('Username');
?>
" required="" autofocus="">
			<input name="user_pass" type="password" class="form-control" placeholder="<?php 
_e('Password');
?>
" required="">

			<input type="hidden" value="<?php 
echo esc_attr(gp_get('redirect_to'));
?>
" id="redirect_to" name="redirect_to" />

			<button class="btn btn-lg btn-primary btn-block" type="submit" name="submit"><?php 
_e('Login');
?>
</button>

			<?php 
do_action('after_login_form');
?>
		</form>

		<?php 
gp_js_focus_on('user_login');
<?php

$meta = array('meta' => array('user_display_name' => $user->display_name, 'user_registered' => $user->user_registered));
foreach ($recent_projects as $project) {
    $project->set_name = html_entity_decode($project->set_name);
    unset($project->project_id);
    unset($project->set_id);
}
$arr = array_merge($meta, compact('locales', 'recent_projects'));
switch (gp_get('filter')) {
    case 'meta':
        echo json_encode($meta);
        break;
    case 'recent_projects':
        echo json_encode(compact('recent_projects'));
        break;
    default:
        echo json_encode($arr);
        break;
}
 private function _export_to_file($format, $dir, $project, $locale, $set)
 {
     // Get the entries we going to export.
     $entries = GP::$translation->for_export($project, $set);
     // Get the slug for this locale.
     $locale_slug = $set->locale;
     // Get the locale object by the slug.
     $locale = GP_Locales::by_slug($locale_slug);
     // Apply any filters that other plugins may have implemented.
     $export_locale = apply_filters('export_locale', $locale->slug, $locale);
     // Get the format object to create the export with.
     $format_obj = gp_array_get(GP::$formats, gp_get('format', $format), null);
     // Create the default file name.
     $filename = sprintf('%s-%s.' . $format_obj->extension, str_replace('/', '-', $project->path), $export_locale);
     // Apply any filters that other plugins may have implemented to the filename.
     $filename = apply_filters('export_filename', $filename, $project->path, $set->slug, $export_locale, $format_obj->extension);
     // Get the contents from the formatter.
     $contents = $format_obj->print_exported_file($project, $locale, $set, $entries);
     // Write the contents out to the file.
     $fh = fopen($dir . '/' . $filename, 'w');
     fwrite($fh, $contents);
     fclose($fh);
     // Return the filename for future reference.
     return $filename;
 }
Exemple #12
0
<?php

/**
 * Landing point for GlotPress installation
 */
define('GP_INSTALLING', true);
require_once 'gp-load.php';
require_once BACKPRESS_PATH . 'class.bp-sql-schema-parser.php';
require_once GP_PATH . GP_INC . 'install-upgrade.php';
require_once GP_PATH . GP_INC . 'schema.php';
$show_htaccess_instructions = true;
if (gp_get_option('gp_db_version') <= gp_get_option_from_db('gp_db_version') && !isset($_GET['force'])) {
    $success_message = __('You already have the latest version, no need to upgrade!');
    $errors = array();
    $show_htaccess_instructions = false;
} else {
    if (gp_get('action', 'install') == 'upgrade') {
        $success_message = __('GlotPress was successully upgraded!');
        $errors = gp_upgrade();
    } else {
        $success_message = __('GlotPress was successully installed!');
        $errors = gp_install();
    }
}
// TODO: check if the .htaccess is in place or try to write it
$show_htaccess_instructions = $show_htaccess_instructions && empty($errors);
$path = gp_add_slash(gp_url_path());
$action = gp_get('action', 'install');
gp_tmpl_load('install', get_defined_vars());
Exemple #13
0
 function translations_get($project_path, $locale_slug, $translation_set_slug)
 {
     $project = GP::$project->by_path($project_path);
     $locale = GP_Locales::by_slug($locale_slug);
     if (!$project || !$locale) {
         return $this->die_with_404();
     }
     $translation_set = GP::$translation_set->by_project_id_slug_and_locale($project->id, $translation_set_slug, $locale_slug);
     if (!$translation_set) {
         return $this->die_with_404();
     }
     $glossary = GP::$glossary->by_set_id($translation_set->id);
     $page = gp_get('page', 1);
     $filters = gp_get('filters', array());
     $sort = gp_get('sort', array());
     if ('random' == gp_array_get($sort, 'by')) {
         add_filter('gp_pagination', create_function('$html', 'return "";'));
     }
     $per_page = GP::$user->current()->get_meta('per_page');
     if (0 == $per_page) {
         $per_page = GP::$translation->per_page;
     } else {
         GP::$translation->per_page = $per_page;
     }
     $translations = GP::$translation->for_translation($project, $translation_set, $page, $filters, $sort);
     $total_translations_count = GP::$translation->found_rows;
     $can_edit = GP::$user->logged_in();
     $can_write = $this->can('write', 'project', $project->id);
     $can_approve = $this->can('approve', 'translation-set', $translation_set->id);
     $url = gp_url_project($project, gp_url_join($locale->slug, $translation_set->slug));
     $set_priority_url = gp_url('/originals/%original-id%/set_priority');
     $discard_warning_url = gp_url_project($project, gp_url_join($locale->slug, $translation_set->slug, '-discard-warning'));
     $set_status_url = gp_url_project($project, gp_url_join($locale->slug, $translation_set->slug, '-set-status'));
     $bulk_action = gp_url_join($url, '-bulk');
     $this->tmpl('translations', get_defined_vars());
 }