Example #1
0
function gp_projects_dropdown($name_and_id, $selected_project_id = null, $attrs = array())
{
    $projects = GP::$project->all();
    // TODO: mark which nodes are editable by the current user
    $tree = array();
    $top = array();
    foreach ($projects as $p) {
        $tree[$p->id]['self'] = $p;
        if ($p->parent_project_id) {
            $tree[$p->parent_project_id]['children'][] = $p->id;
        } else {
            $top[] = $p->id;
        }
    }
    $options = array('' => __('— No parent —'));
    foreach ($top as $top_id) {
        $stack = array($top_id);
        while (!empty($stack)) {
            $id = array_pop($stack);
            $tree[$id]['level'] = gp_array_get($tree[$id], 'level', 0);
            $options[$id] = str_repeat('-', $tree[$id]['level']) . $tree[$id]['self']->name;
            foreach (gp_array_get($tree[$id], 'children', array()) as $child_id) {
                $stack[] = $child_id;
                $tree[$child_id]['level'] = $tree[$id]['level'] + 1;
            }
        }
    }
    return gp_select($name_and_id, $options, $selected_project_id, $attrs);
}
?>
			<div class="box has-warnings"></div>
			<div><?php 
_e('with warnings');
?>
</div>

		</div>

		<p class="clear form-inline">
			<?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'));
}
$export_url = gp_url_project($project, array($locale->slug, $translation_set->slug, 'export-translations'));
$export_link = gp_link_get($export_url, __('Export'), 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'), 'filtered' => _x('only matching the filter', 'export choice')), 'all', array('class' => 'form-control input-sm'));
$format_dropdown = gp_select('export-format', $format_options, 'po', array('class' => 'form-control input-sm'));
/* translators: 1: export 2: what to export dropdown (all/filtered) 3: export format */
$footer_links[] = sprintf(__('%1$s %2$s as %3$s'), $export_link, $what_dropdown, $format_dropdown);
echo implode(' &bull; ', apply_filters('translations_footer_links', $footer_links, $project, $locale, $translation_set));
?>
		</p>

<?php 
gp_tmpl_footer();
Example #3
0
	</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(' &bull; ', apply_filters('gp_translations_footer_links', $footer_links, $project, $locale, $translation_set));
?>
</p>
<?php 
gp_tmpl_footer();
Example #4
0
_e('Description');
?>
</label></dt>
	<dd><textarea name="project[description]" rows="4" cols="40" id="project[description]"><?php 
echo esc_html($project->description);
?>
</textarea></dd>

	<dt><label for="project[source_url_template]"><?php 
_e('Source file URL');
?>
</label></dt>
	<dd>
		<input type="text" value="<?php 
echo esc_html($project->source_url_template);
?>
" name="project[source_url_template]" id="project[source_url_template]" style="width: 30em;" />
		<small>Public URL to a source file in the project. You can use <code>%file%</code> and <code>%line%</code>. Ex. <code>http://trac.example.org/browser/%file%#L%line%</code></small>
	</dd>

	<dt><label for="project[parent_project_id]"><?php 
_e('Parent Project');
?>
</label></dt>
	<dd><?php 
echo gp_select('project[parent_project_id]', $all_project_options, $project->parent_project_id);
?>
</dd>
</dl>
<?php 
echo gp_js_focus_on('project[name]');
Example #5
0
}
?>
			<?php 
references($project, $t);
?>

			<dl>
			    <dt><?php 
_e('Priority of the original:', 'glotpress');
?>
</dt>
			<?php 
if ($can_write) {
    ?>
				<dd><?php 
    echo gp_select('priority-' . $t->original_id, GP::$original->get_static('priorities'), $t->priority, array('class' => 'priority', 'tabindex' => '-1', 'data-nonce' => wp_create_nonce('set-priority_' . $t->original_id)));
    ?>
</dd>
			<?php 
} else {
    ?>
				<dd><?php 
    echo gp_array_get(GP::$original->get_static('priorities'), $t->priority, 'unknown');
    // WPCS: XSS ok.
    ?>
</dd>
			<?php 
}
?>
			</dl>
Example #6
0
?>

			<?php 
references($project, $t);
?>

			<dl>
			    <dt><?php 
_e('Priority of the original:', 'glotpress');
?>
</dt>
			<?php 
if ($can_write) {
    ?>
			    <dd><?php 
    echo gp_select('priority-' . $t->original_id, GP::$original->get_static('priorities'), $t->priority, array('class' => 'priority', 'tabindex' => '-1'));
    ?>
</dd>
			<?php 
} else {
    ?>
			    <dd><?php 
    echo gp_array_get(GP::$original->get_static('priorities'), $t->priority, 'unknown');
    ?>
</dd>
			<?php 
}
?>
			</dl>

			<?php 
					<?php 
echo GP_Bootstrap_Theme_Hacks::gp_radio_buttons('default_sort[how]', array('asc' => __('Ascending'), 'desc' => __('Descending')), gp_array_get($default_sort, 'how', 'desc'));
?>
				</div>
			</div>


			<div class="form-group">
				<label for="default_theme" class="col-sm-4 col-md-3 control-label"><?php 
_e("Theme:");
?>
</label>
				<div class="col-sm-4">
					<?php 
$default_theme = 'default' == GP::$user->current()->get_meta('default_theme') ? 'default' : 'bootstrap';
echo gp_select('default_theme', array('default' => __('Default theme'), 'bootstrap' => __('Bootstrap theme')), $default_theme, array('class' => 'form-control'));
?>
				</div>
			</div>


			<br />

			<div class="form-group">
				<div class="col-sm-offset-4 col-md-offset-3 col-sm-8">
					<button type="submit" name="submit" class="btn btn-primary"><?php 
esc_attr_e("Change Settings");
?>
</button>
				</div>
			</div>
					<input type="file" id="import-file" class="form-control" name="import-file" />
				</div>
			</div>

			<div class="form-group">
				<label for="format" class="col-sm-4 col-md-3 control-label"><?php 
_e('Format:');
?>
</label>
				<div class="col-sm-4">
					<?php 
$format_options = array();
foreach (GP::$formats as $slug => $format) {
    $format_options[$slug] = $format->name;
}
echo gp_select('format', $format_options, 'po', array('class' => 'form-control'));
?>
				</div>
			</div>

			<div class="form-group">
				<div class="col-sm-offset-4 col-md-offset-3 col-sm-8">
					<button type="submit" class="btn btn-primary"><?php 
echo esc_attr(__('Import'));
?>
</button>
				</div>
			</div>
		</form>

<?php 
	<!-- TODO: make slug edit WordPress style -->
	<dt><label for="set[slug]"><?php 
_e('Slug');
?>
</label></dt>
	<dd><input type="text" name="set[slug]" value="<?php 
echo esc_html($set->slug ? $set->slug : 'default');
?>
" id="set[slug]"></dd>

	<dt><label for="set[project_id]"><?php 
_e('Project');
?>
</label></dt>
	<dd><?php 
echo gp_select('set[project_id]', $all_project_options, $set->project_id);
?>
</dd>
	
	
</dl>
<?php 
echo gp_js_focus_on('set[locale]');
?>
<script type="text/javascript">
	jQuery(function($){
		$('#copy').click(function() {
			$('#set\\[name\\]').val($('#set\\[locale\\] option:selected').html().replace(/^\S+\s+\S+\s+/, ''));
			return false;
		});
	});
Example #10
0
	<dd>
		<?php 
    if (count($status_options) === 1) {
        ?>
			<input type="hidden" name="status" value="<?php 
        echo esc_attr(reset(array_keys($status_options)));
        ?>
" />
			<?php 
        echo esc_html(reset(array_values($status_options)));
        ?>
		<?php 
    } elseif (count($status_options) > 1) {
        ?>
			<?php 
        echo gp_select('status', $status_options, 'current');
        ?>
		<?php 
    }
    ?>
	</dd>
<?php 
}
?>
	<dt>
	<p>
		<input type="submit" name="submit" value="<?php 
esc_attr_e('Import', 'glotpress');
?>
" id="submit" />
		<span class="or-cancel"><?php