Example #1
0
 function login_get()
 {
     if (!GP::$user->logged_in()) {
         gp_tmpl_load('login', array());
     } else {
         gp_redirect(gp_url('/'));
     }
 }
Example #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());
 }
Example #3
0
<?php

gp_title(__('Create New Translation Set &lt; GlotPress'));
gp_breadcrumb(array(__('Create New Translation Set')));
gp_tmpl_header();
?>
<h2><?php 
_e('Create New Translation Set');
?>
</h2>
<form action="" method="post">
<?php 
gp_tmpl_load('translation-set-form', get_defined_vars());
?>
	<p><input type="submit" name="submit" value="<?php 
echo esc_attr(__('Create'));
?>
" id="submit" /></p>
</form>
<?php 
gp_tmpl_footer();
Example #4
0
function gp_tmpl_404($args = array())
{
    gp_tmpl_load('404', $args + array('title' => __('Not Found'), 'http_status' => 404));
    exit;
}
Example #5
0
_e('Original string', 'glotpress');
?>
</th>
		<th class="translation"><?php 
_e('Translation', 'glotpress');
?>
</th>
		<th>&mdash;</th>
	</tr>
	</thead>
<?php 
if ($glossary) {
    $translations = map_glossary_entries_to_translations_originals($translations, $glossary);
}
foreach ($translations as $t) {
    gp_tmpl_load('translation-row', get_defined_vars());
}
if (!$translations) {
    ?>
	<tr><td colspan="<?php 
    echo $can_approve ? 5 : 4;
    ?>
"><?php 
    _e('No translations were found!', 'glotpress');
    ?>
</td></tr>
<?php 
}
?>
</table>
<?php 
?>
</th>
		<?php 
if ($can_edit) {
    ?>
			<th style="width:10%">&mdash;</th>
		<?php 
}
?>
		</tr>
	</thead>
	<tbody>
<?php 
if (count($glossary_entries) > 0) {
    foreach ($glossary_entries as $entry) {
        gp_tmpl_load('glossary-entry-row', get_defined_vars());
    }
} else {
    ?>
		<tr>
			<td colspan="5">
				<?php 
    _e('No glossary entries yet.', 'glotpress');
    ?>
			</td>
		</tr>
		<?php 
}
?>
		<?php 
if ($can_edit) {
Example #7
0
 function new_post()
 {
     $post = gp_post('project');
     $parent_project_id = gp_array_get($post, 'parent_project_id', null);
     $this->can_or_redirect('write', 'project', $parent_project_id);
     $new_project = new GP_Project($post);
     $this->validate_or_redirect($new_project);
     $project = GP::$project->create_and_select($new_project);
     if (!$project) {
         $project = new GP_Project();
         $this->errors[] = __('Error in creating project!');
         $all_project_options = self::_options_from_projects(GP::$project->all());
         gp_tmpl_load('project-new', get_defined_vars());
     } else {
         $this->notices[] = __('The project was created!');
         gp_redirect(gp_url_project($project, '_edit'));
     }
 }
Example #8
0
 /**
  * Loads a template.
  *
  * @param string $template template name to load
  * @param array $args Associative array with arguements, which will be exported in the template PHP file
  * @param bool|string $honor_api If this is true or 'api' and the route is processing an API request
  * 		the template name will be suffixed with .api. The actual file loaded will be template.api.php
  */
 function tmpl($template, $args = array(), $honor_api = true)
 {
     if ($this->fake_request) {
         $this->rendered_template = true;
         $this->loaded_template = $template;
     }
     $this->set_notices_and_errors();
     if ($this->api && $honor_api !== false && 'no-api' !== $honor_api) {
         $template = $template . '.api';
         $this->header('Content-Type: application/json');
     } else {
         $this->header('Content-Type: text/html; charset=utf-8');
     }
     if ($this->fake_request) {
         $this->template_output = gp_tmpl_get_output($template, $args, $this->template_path);
         return true;
     }
     return gp_tmpl_load($template, $args, $this->template_path);
 }
Example #9
0
<?php

gp_title(__('Create New Project &lt; GlotPress'));
gp_breadcrumb(array(__('Create New Project')));
gp_tmpl_header();
?>
<h2><?php 
_e('Create New Project');
?>
</h2>
<form action="" method="post">
<?php 
gp_tmpl_load('project-form', get_defined_vars());
?>
	<p><input type="submit" name="submit" value="<?php 
echo esc_attr(__('Create'));
?>
" id="submit" /></p>
</form>
<?php 
gp_tmpl_footer();
Example #10
0
 function discard_warning($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();
     }
     $this->can_or_forbidden('write', 'project', $project->id);
     $translation = GP::$translation->get(gp_post('translation_id'));
     if (!$translation) {
         $this->die_with_error('Translation doesn&#8217;t exist!');
     }
     if (!isset($translation->warnings[gp_post('index')][gp_post('key')])) {
         $this->die_with_error('The warning doesn&#8217;exist!');
     }
     unset($translation->warnings[gp_post('index')][gp_post('key')]);
     if (empty($translation->warnings[gp_post('index')])) {
         unset($translation->warnings[gp_post('index')]);
     }
     $res = $translation->save();
     if (!$res) {
         $this->die_with_error('Error in saving the translation!');
     }
     $translations = GP::$translation->for_translation($project, $translation_set, 'no-limit', array('translation_id' => gp_post('translation_id')), array());
     if ($translations) {
         $t = $translations[0];
         $parity = returner('even');
         $can_edit = GP::$user->logged_in();
         $can_approve = $this->can('approve', 'translation-set', $translation_set->id);
         gp_tmpl_load('translation-row', get_defined_vars());
     } else {
         $this->die_with_error('Error in retrieving translation!');
     }
 }
Example #11
0
                    $errors[] = __('Please specify a password.');
                } elseif ($admin_password != $admin_password_check) {
                    $errors[] = __('Your passwords do not match. Please try again.');
                } else {
                    if (empty($admin_email)) {
                        $errors[] = __('You must provide an email address.');
                    } elseif (!is_email($admin_email)) {
                        $errors[] = __('You have an invalid email Address.');
                    }
                }
                if (!$errors) {
                    $errors = gp_install();
                    $success_message = __('GlotPress was successully installed!');
                    $success_message .= ' <a href="' . gp_url_login() . '">' . __('Log in') . '</a>';
                    if (!$errors) {
                        gp_create_initial_contents($user_name, $admin_password, $admin_email);
                    }
                    $show_htaccess_instructions = !gp_set_htaccess() && empty($errors);
                    $action = 'installed';
                } else {
                    $action = 'install';
                }
            } else {
                $action = 'install';
                $user_name = $admin_email = '';
            }
        }
    }
}
gp_tmpl_load('install', get_defined_vars());