本文整理汇总了PHP中gp_url_project函数的典型用法代码示例。如果您正苦于以下问题:PHP gp_url_project函数的具体用法?PHP gp_url_project怎么用?PHP gp_url_project使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gp_url_project函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bulk_translate
public function bulk_translate($project_path)
{
$project_path = urldecode($project_path);
$url = gp_url_project($project_path);
// If we don't have rights, just redirect back to the project.
if (!GP::$user->current()->can('write', 'project')) {
gp_redirect($url);
}
// Create a project class to use to get the project object.
$project_class = new GP_Project();
// Get the project object from the project path that was passed in.
$project_obj = $project_class->by_path($project_path);
// Get the translations sets from the project ID.
$translation_sets = GP::$translation_set->by_project_id($project_obj->id);
// Loop through all the sets.
foreach ($translation_sets as $set) {
//Array ( [action] => gtranslate [priority] => 0 [redirect_to] => http://localhost/wp40/gp/projects/sample/bg/my [row-ids] => Array ( [0] => 1 [1] => 2 ) )
$bulk = array('action' => 'gtranslate', 'priority' => 0, 'row-ids' => array());
$translation = new GP_Translation();
$strings = $translation->for_translation($project_obj, $set, null, array('status' => 'untranslated'));
foreach ($strings as $string) {
$bulk['row-ids'][] .= $string->row_id;
}
$locale = GP_Locales::by_slug($set->locale);
$this->gp_translation_set_bulk_action_post($project_obj, $locale, $set, $bulk);
}
$url = gp_url_project($project_path);
gp_redirect($url);
}
示例2: gp_link_project_delete_get
function gp_link_project_delete_get($project, $text = false, $attrs = array())
{
if (!GP::$permission->current_user_can('delete', 'project', $project->id)) {
return '';
}
$text = $text ? $text : __('Delete', 'glotpress');
return gp_link_get(gp_url_project($project, '-delete'), $text, gp_attrs_add_class($attrs, 'action edit'));
}
示例3: gp_link_project_delete_get
function gp_link_project_delete_get($project, $text = false, $attrs = array())
{
if (!current_user_can('manage_options')) {
return '';
}
$text = $text ? $text : __('Delete', 'glotpress');
return gp_link_get(gp_url_project($project, '-delete'), $text, gp_attrs_add_class($attrs, 'action delete'));
}
示例4: gp_link_project_delete_get
function gp_link_project_delete_get($project, $text = false, $attrs = array())
{
if (!GP::$user->current()->can('write', 'project', $project->id)) {
return '';
}
$text = $text ? $text : __('Delete');
return gp_link_get(gp_url_project($project, '-delete'), $text, gp_attrs_add_class($attrs, 'action delete'));
}
示例5: test_gp_url_with_arrays
function test_gp_url_with_arrays()
{
$this->assertEquals('baba', gp_url_join(array('baba')));
$this->assertEquals('baba/dyado', gp_url_join(array('baba', 'dyado')));
// test some shortcuts -- arrays instead of gp_url_join calls
$this->assertEquals(gp_url_join(gp_url_project('/x'), 'import-originals'), gp_url_project('/x', 'import-originals'));
$this->assertEquals(gp_url_project('/x', gp_url_join('slug', 'slugslug', 'import-translations')), gp_url_project('/x', array('slug', 'slugslug', 'import-translations')));
}
示例6: edit_get
function edit_get($set_id)
{
$items = $this->get_set_project_and_locale_from_set_id_or_404($set_id);
if (!$items) {
return;
}
list($set, $project, $locale) = $items;
if ($this->cannot_and_redirect('write', 'project', $set->project_id, gp_url_project($project))) {
return;
}
$url = gp_url_project($project, gp_url_join($set->locale, $set->slug));
$this->tmpl('translation-set-edit', get_defined_vars());
}
示例7: edit_post
function edit_post($glossary_id)
{
$glossary = GP::$glossary->get($glossary_id);
$new_glossary = new GP_Glossary(gp_post('glossary'));
if ($this->cannot_edit_glossary_and_redirect($glossary)) {
return;
}
if (!$glossary->update($new_glossary)) {
$this->errors[] = __('Error in updating glossary!');
$this->redirect();
return;
}
$this->notices[] = __('The glossary was updated!');
$translation_set = $new_glossary->translation_set_id ? GP::$translation_set->get($new_glossary->translation_set_id) : null;
$set_project = GP::$project->get($translation_set->project_id);
$this->redirect(gp_url_join(gp_url_project($set_project, array($translation_set->locale, $translation_set->slug)), array('glossary')));
}
示例8: new_post
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));
}
}
示例9: auto_extract
public function auto_extract($project_path)
{
// First let's ensure we have decoded the project path for use later.
$project_path = urldecode($project_path);
// Get the URL to the project for use later.
$url = gp_url_project($project_path);
// Create a project class to use to get the project object.
$project_class = new GP_Project();
// Get the project object from the project path that was passed in.
$project_obj = $project_class->by_path($project_path);
if (GP::$permission->user_can(wp_get_current_user(), 'write', 'project', $project->id)) {
// Get the project settings.
$project_settings = (array) get_option('gp_auto_extract', array());
// Since we're running on the front end we need to load the download_url() function from the wp-admin/includes directory.
include ABSPATH . 'wp-admin/includes/file.php';
// Extract the strings, the third parameter disables HTML formating of the returned messages as GP doesn't need them.
$message = $this->extract_project($project_obj, $project_settings, false);
} else {
$message = 'You do not have rights to auto extract originals!';
}
gp_notice_set($message);
// Redirect back to the project home.
wp_redirect($url);
}
示例10: gp_url_project_locale
/**
* Constructs URL for a project and locale.
* /<project-path>/<locale>/<path>/<page>
*/
function gp_url_project_locale($project_or_path, $locale, $path = '', $query = null)
{
return gp_url_project($project_or_path, array($locale, $path), $query);
}
示例11: gp_link_project
gp_link_project($project, esc_html($project->name));
?>
<?php
gp_link_project_edit($project, null, array('class' => 'btn btn-xs btn-primary'));
?>
</li>
<?php
}
?>
</ul>
<p>
<?php
gp_link(gp_url('/languages'), __('Projects by language'), array('class' => 'btn btn-primary'));
?>
<?php
if (GP::$user->current()->can('write', 'project')) {
?>
<?php
gp_link(gp_url_project('-new'), __('Create a New Project'), array('class' => 'btn btn-default'));
?>
<?php
}
?>
</p>
<?php
gp_tmpl_footer();
示例12: gp_link
<a class="ternary" href="#" onclick="jQuery('#personal-options-toggle').click();return false;">Cancel</a>
</p>
</form>
</div>
</div>
<?php
}
if ($can_write) {
?>
<p class="secondary actionlist">
<?php
gp_link(gp_url_project($project, 'import-originals'), __('Import originals'));
?>
•
<?php
gp_link(gp_url_project('', '_new', array('parent_project_id' => $project->id)), __('Create a New Sub-Project'));
?>
•
<?php
gp_link(gp_url('/sets/_new', array('project_id' => $project->id)), __('Create a New Translation Set'));
?>
</p>
<?php
}
?>
<script type="text/javascript" charset="utf-8">
$gp.showhide('a.personal-options', 'Personal project options ↓', 'Personal project options ↑', 'div.personal-options', '#source-url-template');
$('div.personal-options').hide();
</script>
<?php
gp_tmpl_footer();
示例13: foreach
foreach ($translations as $t) {
gp_tmpl_load('translation-row', get_defined_vars());
?>
<?php
}
if (!$translations) {
?>
<tr><td colspan="4">No translations were found!</td></tr>
<?php
}
?>
</table>
<?php
echo gp_pagination($page, $per_page, $total_translations_count);
?>
<p class="clear actionlist secondary">
<?php
$footer_links = array();
if ($can_approve) {
$footer_links[] = gp_link_get(gp_url_project($project, array($locale->slug, $translation_set->slug, 'import-translations')), __('Import translations'));
}
if (GP::$user->logged_in()) {
$footer_links[] = gp_link_get(gp_url_project($project, array($locale->slug, $translation_set->slug, 'export-translations')), __('Export as PO file'));
}
$footer_links[] = gp_link_get(gp_url_project($project, array($locale->slug, $translation_set->slug, '_permissions')), 'Permissions');
echo implode(' • ', $footer_links);
?>
</p>
<?php
gp_tmpl_footer();
示例14: _e
</div><?php
}
?>
<div class="box has-warnings"></div>
<div><?php
_e('with warnings', 'glotpress');
?>
</div>
</div>
<p class="clear actionlist secondary">
<?php
$footer_links = array();
if ($can_approve) {
$footer_links[] = gp_link_get(gp_url_project($project, array($locale->slug, $translation_set->slug, 'import-translations')), __('Import translations', 'glotpress'));
}
$export_url = gp_url_project($project, array($locale->slug, $translation_set->slug, 'export-translations'));
$export_link = gp_link_get($export_url, __('Export', 'glotpress'), array('id' => 'export', 'filters' => add_query_arg(array('filters' => $filters), $export_url)));
$format_options = array();
foreach (GP::$formats as $slug => $format) {
$format_options[$slug] = $format->name;
}
$what_dropdown = gp_select('what-to-export', array('all' => _x('all current', 'export choice', 'glotpress'), 'filtered' => _x('only matching the filter', 'export choice', 'glotpress')), 'all');
$format_dropdown = gp_select('export-format', $format_options, 'po');
/* translators: 1: export 2: what to export dropdown (all/filtered) 3: export format */
$footer_links[] = sprintf(__('%1$s %2$s as %3$s', 'glotpress'), $export_link, $what_dropdown, $format_dropdown);
echo implode(' • ', apply_filters('gp_translations_footer_links', $footer_links, $project, $locale, $translation_set));
?>
</p>
<?php
gp_tmpl_footer();
示例15: gp_project_options_form
function gp_project_options_form($project)
{
return '
<a href="#" class="personal-options" id="personal-options-toggle"> ' . __('Personal project options ↓') . '</a>
<div class="personal-options">
<form action="' . gp_url_project($project, '-personal') . '" method="post">
<dl>
<dt><label for="source-url-template">' . __('Source file URL') . '</label></dt>
<dd>
<input type="text" value="' . esc_html($project->source_url_template()) . '" name="source-url-template" id="source-url-template" />
<small>' . __('URL to a source file in the project. You can use <code>%file%</code> and <code>%line%</code>. Ex. <code>https://trac.example.org/browser/%file%#L%line%</code>') . '</small>
</dd>
</dl>
<p>
<input type="submit" name="submit" value="' . esc_attr(__('Save →')) . '" id="save" />
<a class="ternary" href="#" onclick="jQuery(\'#personal-options-toggle\').click();return false;">' . __('Cancel') . '</a>
</p>
</form>
</div>';
}