Example #1
0
 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')));
 }
Example #2
0
/**
 * Builds a URL relative to the GlotPress base
 * 
 * @param mixed $path string path or array of path components
 * @param array $query associative array of query arguments (optional)
 */
function gp_url($path, $query = null)
{
    $url = gp_url_join(gp_url_path(gp_get_option('url')), $path);
    if ($query && is_array($query)) {
        $url = add_query_arg(urlencode_deep($query), $url);
    } elseif ($query) {
        $url .= '?' . ltrim($query, '?');
    }
    return apply_filters('gp_url', $url, $path, $query);
}
Example #3
0
function gp_url_add_path_and_query($base, $path, $query)
{
    // todo: same domain with current url?
    $url = gp_url_join($base, $path);
    if ($query && is_array($query)) {
        $url = add_query_arg(urlencode_deep($query), $url);
    } elseif ($query) {
        $url .= '?' . ltrim($query, '?');
    }
    return apply_filters('gp_url_add_path_and_query', $url, $base, $path, $query);
}
 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());
 }
Example #5
0
 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')));
 }
Example #6
0
function gp_url_add_path_and_query($base, $path, $query)
{
    // todo: same domain with current url?
    $url = gp_url_join($base, $path);
    if ($query && is_array($query)) {
        $url = add_query_arg(urlencode_deep($query), $url);
    } elseif ($query) {
        $url .= '?' . ltrim($query, '?');
    }
    /**
     * Filter a GlotPress URL with path and query.
     *
     * @since 1.0.0
     *
     * @param string $url Generated URL.
     * @param string $base The base path.
     * @param array  $path The GlotPress path or the components as an array.
     * @param string $query The query part of the URL.
     */
    return apply_filters('gp_url_add_path_and_query', $url, $base, $path, $query);
}
Example #7
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());
 }
function gp_link_glossary_edit_get($glossary, $set, $text = false, $attrs = array())
{
    if (!GP::$user->current()->can('approve', 'translation_set', $set->id)) {
        return '';
    }
    $text = $text ? $text : __('Edit');
    return gp_link_get(gp_url(gp_url_join('/glossaries', $glossary->id, '-edit')), $text, gp_attrs_add_class($attrs, 'action edit'));
}
Example #9
0
 /**
  * Regenrate the paths of all projects from its parents slugs
  */
 function regenerate_paths($parent_project_id = null)
 {
     // TODO: do it with one query. Use the tree generation code from GP_Route_Main::_options_from_projects()
     if ($parent_project_id) {
         $parent_project = $this->get($parent_project_id);
         $path = $parent_project->path;
     } else {
         $path = '';
         $parent_project_id = null;
     }
     $projects = $this->find(array('parent_project_id' => $parent_project_id));
     foreach ((array) $projects as $project) {
         $project->update(array('path' => gp_url_join($path, $project->slug)));
         $this->regenerate_paths($project->id);
     }
 }
Example #10
0
		<tbody>
		<?php 
foreach ($locales as $locale) {
    ?>
			<tr class="<?php 
    echo $parity();
    ?>
">
				<?php 
    echo "<td>" . gp_link_get(gp_url_join(gp_url_current(), $locale->slug), $locale->english_name) . "</td>";
    ?>
				<?php 
    echo "<td>" . gp_link_get(gp_url_join(gp_url_current(), $locale->slug), $locale->native_name) . "</td>";
    ?>
				<?php 
    echo "<td>" . gp_link_get(gp_url_join(gp_url_current(), $locale->slug), $locale->slug) . "</td>";
    ?>
			</tr>
		<?php 
}
?>
		</tbody>
	</table>

	<script type="text/javascript" charset="utf-8">
		jQuery(document).ready(function($) {
			$('.locales').tablesorter({
				headers: {
					0: {
						sorter: 'text'
					}
Example #11
0
 function test_gp_url_project_should_join_its_array_arguments()
 {
     $url_from_gp_url_project = gp_url_project('/x', array('slug', 'slugslug', 'import-translations'));
     $url_manually_joined = gp_url_join(gp_url_project('/x'), 'slug', 'slugslug', 'import-translations');
     $this->assertEquals($url_manually_joined, $url_from_gp_url_project);
 }
Example #12
0
            ?>
						</td>
						<td class="stats translated"><?php 
            gp_link(gp_url_project($set_data->project_path, gp_url_join($locale->slug, $set_data->slug), array('filters[translated]' => 'yes', 'filters[status]' => 'current')), absint($set_data->current_count));
            ?>
</td>
						<td class="stats fuzzy"><?php 
            gp_link(gp_url_project($set_data->project_path, gp_url_join($locale->slug, $set_data->slug), array('filters[status]' => 'fuzzy')), absint($set_data->fuzzy_count));
            ?>
</td>
						<td class="stats untranslated"><?php 
            gp_link(gp_url_project($set_data->project_path, gp_url_join($locale->slug, $set_data->slug), array('filters[status]' => 'untranslated')), absint($set_data->all_count) - absint($set_data->current_count));
            ?>
</td>
						<td class="stats waiting"><?php 
            gp_link(gp_url_project($set_data->project_path, gp_url_join($locale->slug, $set_data->slug), array('filters[translated]' => 'yes', 'filters[status]' => 'waiting')), absint($set_data->waiting_count));
            ?>
</td>
						</tr>
					<?php 
        }
        //sub project slugs
        ?>
					</tr>
				<?php 
    }
    //sub projects
    ?>
				</tbody>
			</table>
		</div>
        ?>
</td>
					<td><?php 
        echo esc_html($permission->action);
        ?>
</td>
					<td><?php 
        echo esc_html($permission->locale_slug);
        ?>
</td>
					<td><?php 
        echo esc_html($permission->set_slug);
        ?>
</td>
					<td><a href="<?php 
        echo esc_url(gp_route_nonce_url(gp_url_join(gp_url_current(), '-delete/' . $permission->id), 'delete-project-permission_' . $permission->id));
        ?>
" class="action delete"><?php 
        _e('Delete', 'glotpress');
        ?>
</a></td>
				</tr>
			<?php 
    }
    ?>
		</tbody>
	</table>
	<?php 
}
?>
	<?php 
        ?>
</span>
			<span class="user"><?php 
        echo esc_html($permission->locale_slug);
        ?>
</span>
			<span class="permission-action"><?php 
        _e('and slug');
        ?>
</span>
			<span class="user"><?php 
        echo esc_html($permission->set_slug);
        ?>
</span>
			<a href="<?php 
        echo gp_url_join(gp_url_current(), '-delete/' . $permission->id);
        ?>
" class="action delete"><?php 
        _e('Remove');
        ?>
</a>
		</li>
	<?php 
    }
    ?>
</ul>
	<?php 
}
?>
	<?php 
if ($parent_permissions) {
Example #15
0
/**
 * Creates a HTML link to the delete page for translations sets.
 *
 * Does the heavy lifting for gp_link_glossary_delete.
 *
 * @since 2.0.0
 *
 * @param GP_Glossary        $glossary The glossary to link to.
 * @param GP_Translation_Set $set      The translation set the glossary is for.
 * @param string             $text     The text to use for the link.
 * @param array              $attrs    Additional attributes to use to determine the classes for the link.
 * @return string The HTML link.
 */
function gp_link_glossary_delete_get($glossary, $set, $text = false, $attrs = array())
{
    if (!GP::$permission->current_user_can('delete', 'translation-set', $set->id)) {
        return '';
    }
    $text = $text ? $text : __('Delete', 'glotpress');
    return gp_link_get(gp_url(gp_url_join('/glossaries', $glossary->id, '-delete')), $text, gp_attrs_add_class($attrs, 'action edit'));
}
Example #16
0
				-->
			<?php 
        if ($can_write && ($waiting = $set->waiting_count())) {
            // TODO: check if the user can approve this locale
            ?>
				<?php 
            gp_link(gp_url_project($project, gp_url_join($set->locale, $set->slug), array('filters[translated]' => 'yes', 'filters[status]' => 'waiting')), $waiting, array('class' => 'waiting', 'title' => 'waiting'));
            ?>
			<?php 
        }
        ?>
			<?php 
        if ($warnings = $set->warnings_count()) {
            ?>
				<?php 
            gp_link(gp_url_project($project, gp_url_join($set->locale, $set->slug), array('filters[translated]' => 'yes', 'filters[warnings]' => 'yes')), $warnings, array('class' => 'warnings', 'title' => 'with warnings'));
            ?>
			<?php 
        }
        ?>
			
			<?php 
        do_action('project_template_translation_set_extra', $set, $project);
        ?>
			</span>
		</li>
	<?php 
    }
    ?>
	</ul>
<?php 
    ?>
" 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'));
    ?>
  &bull;&nbsp;
	<?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();
</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();
Example #19
0
 public function single($locale_slug, $current_set_slug = 'default')
 {
     $locale = GP_Locales::by_slug($locale_slug);
     $sets = GP::$translation_set->by_locale($locale_slug);
     usort($sets, array($this, 'sort_sets_by_project_id'));
     $locale_projects = $projects_data = $projects = $parents = $set_slugs = $set_list = array();
     //TODO: switch to wp_list_pluck
     foreach ($sets as $key => $value) {
         $locale_projects[$key] = $value->project_id;
     }
     foreach ($sets as $set) {
         $set_slugs[$set->slug] = $set;
         if ($current_set_slug != $set->slug) {
             continue;
         }
         // Store project data for later use
         if (isset($projects[$set->project_id])) {
             $set_project = $projects[$set->project_id];
         } else {
             $set_project = GP::$project->get($set->project_id);
             $projects[$set->project_id] = $set_project;
         }
         // We only want to list active projects
         if (!isset($set_project->active) || $set_project->active == false) {
             continue;
         }
         $parent_id = is_null($set_project->parent_project_id) ? $set_project->id : $set_project->parent_project_id;
         // Store parent project data for later use
         if (isset($projects[$parent_id])) {
             $parent_project = $projects[$parent_id];
         } else {
             $parent_project = GP::$project->get($parent_id);
             $projects[$parent_id] = $parent_project;
         }
         // Store parent id for
         $parents[$set_project->id] = $parent_id;
         if (!in_array($set_project->parent_project_id, $locale_projects)) {
             $projects_data[$parent_id][$set_project->id]['project'] = $set_project;
             $projects_data[$parent_id][$set_project->id]['sets'][$set->id] = $this->set_data($set, $set_project);
             $projects_data[$parent_id][$set_project->id]['totals'] = $this->set_data($set, $set_project);
             if (!isset($projects_data[$parent_id][$set_project->id]['project'])) {
                 $projects_data[$parent_id][$set_project->id]['project'] = $set_project;
             }
         } else {
             while (!in_array($parent_id, array_keys($projects_data)) && isset($parents[$parent_id])) {
                 $previous_parent = $parent_id;
                 $parent_id = $parents[$parent_id];
             }
             //Orphan project - a sub project is set to active, while it's parent isn't
             if (!isset($projects_data[$parent_id])) {
                 continue;
             }
             //For when root project has sets, and sub projects.
             if (!isset($previous_parent) || !isset($projects_data[$parent_id][$previous_parent])) {
                 $previous_parent = $parent_id;
             }
             $set_data = $projects_data[$parent_id][$previous_parent]['totals'];
             $projects_data[$parent_id][$previous_parent]['sets'][$set->id] = $this->set_data($set, $set_project);
             $projects_data[$parent_id][$previous_parent]['totals'] = $this->set_data($set, $set_project, $set_data);
         }
     }
     if ('default' !== $current_set_slug && !isset($set_slugs[$current_set_slug])) {
         return $this->die_with_404();
     }
     if ($set_slugs) {
         // Make default the first item.
         if (!empty($set_slugs['default'])) {
             $default = $set_slugs['default'];
             unset($set_slugs['default']);
             array_unshift($set_slugs, $default);
         }
         foreach ($set_slugs as $set) {
             if ('default' == $set->slug) {
                 if ('default' != $current_set_slug) {
                     $set_list[$set->slug] = gp_link_get(gp_url_join('/languages', $locale->slug), __('Default'));
                 } else {
                     $set_list[$set->slug] = __('Default');
                 }
             } else {
                 if ($set->slug != $current_set_slug) {
                     $set_list[$set->slug] = gp_link_get(gp_url_join('/languages', $locale->slug, $set->slug), esc_html($set->name));
                 } else {
                     $set_list[$set->slug] = esc_html($set->name);
                 }
             }
         }
     }
     $this->tmpl('locale', get_defined_vars());
 }
Example #20
0
foreach ($locales as $locale) {
    $class = 'odd' === $class ? 'even' : 'odd';
    ?>
			<tr class="<?php 
    echo $class;
    // WPCS: XSS ok.
    ?>
">
				<?php 
    echo '<td>' . gp_link_get(gp_url_join(gp_url_current(), $locale->slug), $locale->english_name) . '</td>';
    ?>
				<?php 
    echo '<td>' . gp_link_get(gp_url_join(gp_url_current(), $locale->slug), $locale->native_name) . '</td>';
    ?>
				<?php 
    echo '<td>' . gp_link_get(gp_url_join(gp_url_current(), $locale->slug), $locale->slug) . '</td>';
    ?>
			</tr>
		<?php 
}
?>
		</tbody>
	</table>

	<script type="text/javascript" charset="utf-8">
		jQuery(document).ready(function($) {
			$('.locales').tablesorter({
				theme: 'glotpress',
				sortList: [[0,0]],
				headers: {
					0: {
Example #21
0
 /**
  * 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');
 }
Example #22
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());
 }
Example #23
0
 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')));
 }
Example #24
0
<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();
Example #25
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());
 }
Example #26
0
 private function get_translation_set($set)
 {
     if (!isset($this->projects[$set->project_id])) {
         $this->projects[$set->project_id] = GP::$project->get($set->project_id);
     }
     $project = $this->projects[$set->project_id];
     if (!$project) {
         return false;
     }
     $project_url = gp_url_project($project, gp_url_join($set->locale, $set->slug));
     $set_name = gp_project_names_from_root($project) . ' | ' . $set->name_with_locale();
     return (object) array('project_id' => $project->id, 'project_url' => $project_url, 'set_name' => $set_name);
 }
Example #27
0
        ?>
%</td>
				<td class="stats translated" title="translated"><?php 
        gp_link(gp_url_project($project, gp_url_join($set->locale, $set->slug), array('filters[translated]' => 'yes', 'filters[status]' => 'current')), $set->current_count);
        ?>
</td>
				<td class="stats fuzzy" title="fuzzy"><?php 
        gp_link(gp_url_project($project, gp_url_join($set->locale, $set->slug), array('filters[status]' => 'fuzzy')), $set->fuzzy_count);
        ?>
</td>
				<td class="stats untranslated" title="untranslated"><?php 
        gp_link(gp_url_project($project, gp_url_join($set->locale, $set->slug), array('filters[status]' => 'untranslated')), $set->untranslated_count);
        ?>
</td>
				<td class="stats waiting"><?php 
        gp_link(gp_url_project($project, gp_url_join($set->locale, $set->slug), array('filters[translated]' => 'yes', 'filters[status]' => 'waiting')), $set->waiting_count);
        ?>
</td>
				<?php 
        if (has_action('gp_project_template_translation_set_extra')) {
            ?>
				<td class="extra">
					<?php 
            do_action('gp_project_template_translation_set_extra', $set, $project);
            ?>
				</td>
				<?php 
        }
        ?>
			</tr>
		<?php 
<?php

gp_title(sprintf(__('Mass-create Translation Sets &lt; %s &lt; GlotPress', 'glotpress'), $project->name));
gp_breadcrumb_project($project);
gp_enqueue_script('mass-create-sets-page');
wp_localize_script('mass-create-sets-page', '$gp_mass_create_sets_options', array('url' => gp_url_join(gp_url_current(), 'preview'), 'loading' => __('Loading translation sets to create&hellip;', 'glotpress')));
gp_tmpl_header();
?>
<h2><?php 
_e('Mass-create Translation Sets', 'glotpress');
?>
</h2>
<p><?php 
_e('Here you can mass-create translation sets in this project.
The list of translation sets will be mirrored with the sets of a project you choose.
Usually this is one of the parent projects.', 'glotpress');
?>
</p>
<form action="<?php 
echo esc_url(gp_url_current());
?>
" method="post">
	<dl>
		<dt><label for="project_id"><?php 
_e('Project to take translation sets from:', 'glotpress');
?>
</label></dt>
		<dd><?php 
echo gp_projects_dropdown('project_id', null);
?>
</dd>
Example #29
0
 public function duplicate_project_contents_from($source_project)
 {
     $source_sub_projects = $source_project->inclusive_sub_projects();
     //Duplicate originals, translations sets and translations for the root project
     $this->copy_originals_from($source_project->id);
     $this->copy_sets_and_translations_from($source_project->id);
     //Keep a list of parents to preserve hierarchy
     $parents = array();
     $parents[$source_project->id] = $this->id;
     //Duplicate originals, translations sets and translations for the child projects
     foreach ($source_sub_projects as $sub) {
         $copy_project = new GP_Project($sub->fields());
         $copy_project->parent_project_id = $parents[$sub->parent_project_id];
         $parent_project = $copy_project->get($copy_project->parent_project_id);
         $copy_project->path = gp_url_join($parent_project->path, $copy_project->slug);
         $copy = GP::$project->create($copy_project);
         $parents[$sub->id] = $copy->id;
         $copy->copy_originals_from($sub->id);
         $copy->copy_sets_and_translations_from($sub->id);
     }
 }
Example #30
0
 /**
  * Delete a glossary.
  *
  * @since 2.0.0
  *
  * @param int $glossary_id The id of the glossary to delete.
  */
 public function delete_post($glossary_id)
 {
     if ($this->invalid_nonce_and_redirect('delete-glossary_' . $glossary_id)) {
         return;
     }
     $glossary = GP::$glossary->get($glossary_id);
     if ($this->cannot_delete_glossary_and_redirect($glossary)) {
         return;
     }
     $translation_set = GP::$translation_set->get($glossary->translation_set_id);
     $project = GP::$project->get($translation_set->project_id);
     if (!$glossary->delete()) {
         $this->errors[] = __('Error deleting glossary!', 'glotpress');
         $this->redirect();
         return;
     }
     $this->notices[] = __('The glossary was deleted!', 'glotpress');
     $this->redirect(gp_url_join(gp_url_project($project), array($translation_set->locale, $translation_set->slug)));
 }