function new_post() { $new_set = new GP_Translation_Set(gp_post('set')); if ($new_set->project_id) { $this->can_or_redirect('write', 'project', $new_set->project_id, gp_url_project(GP::$project->get($new_set->project_id))); } else { $this->can_or_redirect('write', 'project', null, gp_url_project('')); } $this->validate_or_redirect($new_set, gp_url('/sets/_new', array('project_id' => $new_set->project_id))); $set = GP::$translation_set->create_and_select($new_set); $project = GP::$project->get($set->project_id); if (!$set) { $this->errors[] = __('Error in creating translation set!'); gp_redirect(gp_url('/sets/_new', array('project_id' => $new_set['project_id']))); } else { $this->notices[] = __('The translation set was created!'); gp_redirect(gp_url_project_locale($project, $set->locale, $set->slug)); } }
function edit_post($set_id) { $items = $this->get_set_project_and_locale_from_set_id_or_404($set_id); if (!$items) { return; } list($set, $project, $locale) = $items; $new_set = new GP_Translation_Set(gp_post('set', array())); if ($this->cannot_edit_set_and_redirect($new_set)) { return; } if ($this->invalid_and_redirect($new_set, gp_url('/sets/-new'))) { return; } if (!$set->update($new_set)) { $this->errors[] = __('Error in updating translation set!'); $this->redirect(); return; } $project = GP::$project->get($new_set->project_id); $this->notices[] = __('The translation set was updated!'); $this->redirect(gp_url_project_locale($project, $new_set->locale, $new_set->slug)); }
?> " id="submit" /> </p> </form> </td> </tr> <?php } ?> </tbody> </table> <p class="clear actionlist secondary"> <?php if ($can_edit) { ?> <?php echo gp_link(gp_url_join(gp_url_project_locale($project_path, $locale_slug, $translation_set_slug), array('glossary', '-import')), __('Import', 'glotpress')); ?> • <?php } ?> <?php echo gp_link(gp_url_join(gp_url_project_locale($project_path, $locale_slug, $translation_set_slug), array('glossary', '-export')), __('Export as CSV', 'glotpress')); ?> </p> <?php gp_tmpl_footer();
<?php gp_title(__('Edit Glossary < GlotPress')); gp_breadcrumb(array(gp_project_links_from_root($project), gp_link_get(gp_url_project_locale($project->path, $locale->slug, $translation_set->slug), $translation_set->name), gp_link_get(gp_url_project_locale($project->path, $locale->slug, $translation_set->slug) . '/glossary', __('Glossary')), __('edit'))); gp_tmpl_header(); ?> <h2><?php _e('Edit Glossary'); ?> </h2> <form action="" method="post"> <p> <label for="glossary-edit-description"><?php _e('Description'); ?> </label> <span class="ternary"><?php _e('can include HTML'); ?> </span> <br/> <textarea class="glossary-description" id="glossary-edit-description" name="glossary[description]"><?php echo esc_html($glossary->description); ?> </textarea> </p> <p> <input type="hidden" name="glossary[id]" value="<?php echo esc_attr($glossary->id); ?>
<h2> <?php printf(__("Translation of %s"), esc_html($project->name)); ?> : <span><?php echo esc_html($translation_set->name); ?> </span> <?php gp_link_set_edit($translation_set, $project, __('Edit'), array('class' => 'btn btn-xs btn-primary')); ?> <?php if ($glossary) { echo gp_link(gp_url_project_locale($project, $locale->slug, $translation_set->slug) . '/glossary', __('glossary'), array('class' => 'btn btn-xs btn-primary')); } elseif ($can_approve) { echo gp_link_get(gp_url('/glossaries/-new', array('translation_set_id' => $translation_set->id)), __('Create glossary'), array('class' => 'btn btn-xs btn-primary')); } ?> </h2> <?php if ($can_approve) { ?> <form id="bulk-actions-toolbar" class="filters-toolbar bulk-actions form-inline pull-left" action="<?php echo $bulk_action; ?> " method="post" role="form"> <select name="bulk[action]" id="bulk-action" class="form-control input-sm"> <option value="" selected="selected"><?php
// WPCS: XSS ok. ?> </dd> <?php } ?> </dl> <?php $extra_args = $t->translation_status ? array('filters[translation_id]' => $t->id) : array(); ?> <dl> <?php $permalink_filters = $t->translation_status ? array('filters[status]' => 'either', 'filters[original_id]' => $t->original_id) : array('filters[original_id]' => $t->original_id); $permalink = gp_url_project_locale($project, $locale->slug, $translation_set->slug, array_merge($permalink_filters, $extra_args)); $original_history = gp_url_project_locale($project, $locale->slug, $translation_set->slug, array_merge(array('filters[status]' => 'either', 'filters[original_id]' => $t->original_id, 'sort[by]' => 'translation_date_added', 'sort[how]' => 'asc'))); ?> <dt><?php _e('More links:', 'glotpress'); ?> <ul> <?php if ($t->translation_status) { ?> <li><a tabindex="-1" href="<?php echo $permalink; ?> " title="<?php esc_attr_e('Permanent link to this translation', 'glotpress'); ?> "><?php
public function import_glossary_entries_post($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); if (!$glossary) { return $this->die_with_404(); } if ($this->cannot_and_redirect('approve', 'translation-set', $translation_set->id)) { return; } if (!is_uploaded_file($_FILES['import-file']['tmp_name'])) { $this->redirect_with_error(__('Error uploading the file.', 'glotpress')); return; } $glossary_entries_added = $this->read_glossary_entries_from_file($_FILES['import-file']['tmp_name'], $glossary->id, $locale->slug); if (empty($this->errors) && is_int($glossary_entries_added)) { $this->notices[] = sprintf(__('%s glossary entries were added', 'glotpress'), $glossary_entries_added); } $this->redirect(gp_url_join(gp_url_project_locale($project_path, $locale_slug, $translation_set_slug), array('glossary'))); }
/** * Get the path to the glossary. * * @return string */ public function path() { $translation_set = GP::$translation_set->get($this->translation_set_id); $project = GP::$project->get($translation_set->project_id); return gp_url_join(gp_url_project_locale($project->path, $translation_set->locale, $translation_set->slug), 'glossary'); }
<?php if ('originals' == $kind) { $title = sprintf(__('Import Originals < %s < GlotPress', 'glotpress'), esc_html($project->name)); $return_link = gp_url_project($project); } else { $title = sprintf(__('Import Translations < %s < GlotPress', 'glotpress'), esc_html($project->name)); $return_link = gp_url_project_locale($project, $locale->slug, $translation_set->slug); } gp_title($title); gp_breadcrumb_project($project); gp_tmpl_header(); ?> <h2><?php echo $kind == 'originals' ? __('Import Originals', 'glotpress') : __('Import Translations', 'glotpress'); ?> </h2> <form action="" method="post" enctype="multipart/form-data"> <dl> <dt><label for="import-file"><?php _e('Import File:', 'glotpress'); ?> </label></dt> <dd><input type="file" name="import-file" id="import-file" /></dd> <?php $format_options = array(); foreach (GP::$formats as $slug => $format) { $format_options[$slug] = $format->name; } $format_dropdown = gp_select('format', $format_options, 'po');
</textarea> </p> <p> <input type="hidden" name="glossary[id]" value="<?php echo esc_attr($glossary->id); ?> "/> <input type="hidden" name="glossary[translation_set_id]" value="<?php echo esc_attr($glossary->translation_set_id); ?> "/> <input type="submit" name="submit" value="<?php esc_attr_e('Save', 'glotpress'); ?> " id="submit" /> <span class="or-cancel"><?php _e('or', 'glotpress'); ?> <a href="<?php echo gp_url_join(gp_url_project_locale($project, $locale->slug, $translation_set->slug), '/glossary'); ?> "><?php _e('Cancel', 'glotpress'); ?> </a></span> </p> </form> <?php gp_tmpl_footer();
?> <h2><?php _e('Edit Translation Set', 'glotpress'); ?> </h2> <form action="" method="post"> <?php gp_tmpl_load('translation-set-form', get_defined_vars()); ?> <p> <input type="submit" name="submit" value="<?php esc_attr_e('Save', 'glotpress'); ?> " id="submit" /> <span class="or-cancel"><?php _e('or', 'glotpress'); ?> <a href="<?php echo gp_url_project_locale($project, $locale->slug, $set->slug); ?> "><?php esc_attr_e('Cancel', 'glotpress'); ?> </a></span> </p> <?php gp_route_nonce_field('edit-translation-set_' . $set->id); ?> </form> <?php gp_tmpl_footer();
_e('Delete Translation Set', 'glotpress'); ?> </h2> <form action="" method="post"> <p> <?php _e('Note this will delete all translations associated with this set!', 'glotpress'); ?> </p> <p> <input type="submit" name="submit" value="<?php esc_attr_e('Delete', 'glotpress'); ?> " id="submit" /> <span class="or-cancel"><?php _e('or', 'glotpress'); ?> <a href="<?php echo esc_url(gp_url_project_locale($project, $locale->slug, $set->slug)); ?> "><?php _e('Cancel', 'glotpress'); ?> </a></span> </p> <?php gp_route_nonce_field('delete-translation-set_' . $set->id); ?> </form> <?php gp_tmpl_footer();
<form action="" method="post"> <p> <?php _e('Note this will delete all entries associated with this glossary!', 'glotpress'); ?> </p> <p> <input type="submit" name="submit" value="<?php esc_attr_e('Delete', 'glotpress'); ?> " id="submit" /> <span class="or-cancel"><?php _e('or', 'glotpress'); ?> <a href="<?php echo esc_url(gp_url_join(gp_url_project_locale($project->path, $locale->slug, $translation_set->slug), '/glossary')); ?> "><?php _e('Cancel', 'glotpress'); ?> </a></span> </p> <?php gp_route_nonce_field('delete-glossary_' . $glossary->id); ?> </form> <?php gp_tmpl_footer();
?> </label> <span class="ternary"><?php _e('can include HTML', 'glotpress'); ?> </span><br/> <textarea class="glossary-description" id="glossary-new-description" name="glossary[description]"></textarea> </p> <p> <input type="hidden" name="glossary[translation_set_id]" value="<?php echo esc_attr($glossary->translation_set_id); ?> "/> <input type="submit" name="submit" value="<?php esc_attr_e('Create', 'glotpress'); ?> " id="submit" /> <span class="or-cancel"><?php _e('or', 'glotpress'); ?> <a href="<?php echo gp_url_project_locale($project, $locale->slug, $translation_set->slug); ?> "><?php _e('Cancel', 'glotpress'); ?> </a></span> </p> </form> <?php gp_tmpl_footer();
<?php gp_title(__('Create New Glossary < GlotPress', 'glotpress')); gp_breadcrumb(array(gp_project_links_from_root($project), gp_link_get(gp_url_project_locale($project->path, $locale->slug, $translation_set->slug), $translation_set->name), __('Create Glossary', 'glotpress'))); gp_tmpl_header(); ?> <h2><?php _e('Create New Glossary', 'glotpress'); ?> </h2> <form action="" method="post"> <p> <label for="glossary-new-description"><?php _e('Description (optional)', 'glotpress'); ?> </label> <span class="ternary"><?php _e('can include HTML', 'glotpress'); ?> </span><br/> <textarea class="glossary-description" id="glossary-new-description" name="glossary[description]"></textarea> </p> <p> <input type="hidden" name="glossary[translation_set_id]" value="<?php echo esc_attr($glossary->translation_set_id); ?> "/> <input type="submit" name="submit" value="<?php esc_attr_e('Create', 'glotpress'); ?> " id="submit" />