Ticket #95: new-project-page.1.patch
| File new-project-page.1.patch, 17.8 KB (added by Nightgunner5, 22 months ago) |
|---|
-
css/style.css
58 58 line-height: 1.5em; 59 59 width: 40em; 60 60 } 61 table.translations {61 table.translations, table.translation-sets { 62 62 font-size: 90%; 63 63 width: 100%; 64 64 border-spacing: 0.1em; 65 65 } 66 table.translations th {66 table.translations th, table.translation-sets th { 67 67 font-weight: bold; 68 68 color: #eee; 69 69 background-color: #555; 70 70 } 71 table.translations tr {71 table.translations tr, table.translation-sets tr { 72 72 border: 0; 73 73 } 74 74 table.translations td.translation ul { … … 93 93 font-style: italic; 94 94 } 95 95 96 table.translations td, table.translations th {96 table.translations td, table.translations th, table.translation-sets td, table.translation-sets th { 97 97 padding: 0.5em; 98 98 border: 1px solid #eee; 99 99 /* white-space: pre-wrap; */ … … 414 414 } 415 415 p.description { 416 416 max-width: 60em; 417 margin -left:1em;418 padding-left: 1em;419 border-left: 3px solid #aaa; 417 margin: 0 0 0 1em; 418 /*padding-left: 1em; 419 border-left: 3px solid #aaa;*/ 420 420 } 421 421 span.added { 422 422 color: green; … … 441 441 .text { 442 442 width: 45em; 443 443 margin-left: 6em; 444 } 445 446 #sub-projects h2, #translation-sets h2 { 447 font-weight: normal; 448 font-size: 1.2em; 449 } 450 451 #sub-projects { 452 float: left; 453 min-width: 300px; 454 } 455 #sub-projects h2 { 456 margin-right: 1em; /* Make the break between columns more obvious */ 457 } 458 459 .sub-projects { 460 list-style: none; 461 padding: 0; 462 } 463 .sub-projects a { 464 font-weight: bold; 465 color: #000; 466 text-decoration: none; 467 } 468 .sub-projects a.action { 469 font-weight: normal; 470 } 471 472 #translation-sets { 473 min-width: 500px; 474 width: 50%; 475 float: left; 476 } 477 478 .translation-sets .percent { 479 font-weight: bold; 480 } 481 .translation-sets .stats { 482 text-align: center; 483 } 484 .translation-sets tr { 485 background-color: #eee; 486 } 487 .translation-sets tr.alt { 488 background-color: #fff; 489 } 490 .translation-sets tr:hover { 491 background-color: #dee; 492 } 493 .translation-sets tr.alt:hover { 494 background-color: #eff; 495 } 496 497 .tag { 498 font-size: 80%; 499 padding: 0.2em 0.2em 0.1em; 500 text-decoration: none; 501 -webkit-border-radius: 0.2em; 502 -moz-border-radius: 0.2em; 503 text-align: center; 444 504 } 505 No newline at end of file -
gp-includes/tags.php
1 <?php 2 3 class GP_Tag { 4 var $name; 5 var $callback; 6 var $color; 7 var $text_color; 8 9 var $action; 10 var $action_num_args = 0; 11 12 function __construct( $name, $callback, $color = '#ff0', $text_color = '#000' ) { 13 $this->name = $name; 14 $this->callback = $callback; 15 $this->color = $color; 16 $this->text_color = $text_color; 17 18 if ( !empty( $this->action ) ) 19 add_action( $this->action, array( &$this, 'display' ), 10, $this->action_num_args ); 20 } 21 22 function display() { 23 $args = func_get_args(); 24 25 if ( call_user_func_array( $this->callback, $args ) ) { 26 echo ' <span class="tag" style="background-color: ', $this->color, '; color: ', $this->text_color, '">', $this->name, '</span>'; 27 } 28 } 29 } 30 31 class GP_Translation_Set_Tag extends GP_Tag { 32 var $action = 'project_template_translation_set_extra'; 33 var $action_num_args = 2; 34 } 35 36 class GP_Default_Tags { 37 function __construct() { 38 add_action( 'init', array( &$this, 'init' ) ); 39 } 40 41 function init() { 42 new GP_Translation_Set_Tag( __( '90%+' ), lambda( '$set, $project', '$project->original_count() && $set->current_count() / $project->original_count() >= .9' ), '#070', '#fff' ); 43 new GP_Translation_Set_Tag( __( 'My language' ), lambda( '$set, $project', 'GP::$user->logged_in() && $set->locale == GP::$user->current()->get_meta( "language" )' ) ); 44 } 45 } 46 new GP_Default_Tags; 47 No newline at end of file -
gp-includes/template.php
Property changes on: gp-includes\tags.php ___________________________________________________________________ Added: svn:eol-style + native
81 81 } 82 82 } 83 83 84 function gp_breadcrumb_project( $project ) { 85 $ret = array(); 86 87 while ( $project ) { 88 array_unshift( $ret, gp_link_project_get( $project, $project->name ) ); 89 $project = $project->parent_project_id ? GP::$project->get( $project->parent_project_id ) : null; 90 } 91 92 return $ret; 93 } 94 84 95 function gp_js_focus_on( $html_id ) { 85 96 return '<script type="text/javascript">document.getElementById("'.$html_id.'").focus();</script>'; 86 97 } … … 217 228 function gp_array_of_array_of_things_to_json( $array ) { 218 229 $map_to_fields = create_function( '$array', 'return array_map( lambda( \'$thing\', \'$thing->fields();\' ), $array );' ); 219 230 return json_encode( array_map( $map_to_fields, $array ) ); 220 } 221 No newline at end of file 231 } 232 233 function get_alt_class( $key, $others = '' ) { 234 global $gp_alt; 235 $class = ''; 236 if ( !isset( $gp_alt[$key] ) ) $gp_alt[$key] = -1; 237 ++$gp_alt[$key]; 238 $others = trim($others); 239 if ( $others xor $gp_alt[$key] % 2 ) 240 $class = ' class="' . ( ($others) ? $others : 'alt' ) . '"'; 241 elseif ( $others && $gp_alt[$key] % 2 ) 242 $class = ' class="' . $others . ' alt"'; 243 return $class; 244 } 245 246 function alt_class( $key, $others = '' ) { 247 echo get_alt_class( $key, $others ); 248 } -
gp-includes/things/project.php
147 147 } 148 148 return compact( 'added', 'removed' ); 149 149 } 150 151 function original_count() { 152 return count( GP::$original->by_project_id( $this->id ) ); 153 } 150 154 } 151 155 GP::$project = new GP_Project(); 156 No newline at end of file -
gp-includes/things/translation-set.php
144 144 ); 145 145 } 146 146 147 function percent_translated() { 148 $original_count = count( GP::$original->by_project_id( $this->project_id ) ); 149 return sprintf( _x( '%d%%', 'language translation percent' ), $original_count ? $this->current_count() / $original_count * 100 : 0 ); 150 } 147 151 } 148 152 GP::$translation_set = new GP_Translation_Set(); -
gp-settings.php
176 176 177 177 require_once( GP_PATH . GP_INC . 'template.php' ); 178 178 require_once( GP_PATH . GP_INC . 'template-links.php' ); 179 require_once( GP_PATH . GP_INC . 'tags.php' ); 179 180 180 181 require_once( GP_PATH . GP_INC . 'cli.php' ); 181 182 -
gp-templates/project-edit.php
1 1 <?php 2 2 gp_title( sprintf( __( 'Edit Project %s < GlotPress' ), $project->name ) ); 3 gp_breadcrumb( array( 4 gp_link_project_get( $project, $project->name ), 5 ) ); 3 gp_breadcrumb( gp_breadcrumb_project( $project ) ); 6 4 gp_tmpl_header(); 7 5 ?> 8 6 <h2><?php _e( sprintf( __('Edit project <q>%s</q>'), esc_html( $project->name ) ) ); ?></h2> -
gp-templates/project-import.php
2 2 gp_title( $kind == 'originals'? 3 3 sprintf( __('Import Originals < %s < GlotPress'), esc_html( $project->name ) ) : 4 4 sprintf( __('Import Translations < %s < GlotPress'), esc_html( $project->name ) ) ); 5 gp_breadcrumb( array( 6 gp_link_project_get( $project, $project->name ), 5 gp_breadcrumb( array_merge( gp_breadcrumb_project( $project ), array( 7 6 $kind == 'originals'? __('Import Originals') : __('Import Translations'), 8 ) ) ;7 ) ) ); 9 8 gp_tmpl_header(); 10 9 ?> 11 10 <form action="" method="post" enctype="multipart/form-data"> -
gp-templates/project-mass-create-sets.php
1 1 <?php 2 2 gp_title( sprintf( __( 'Mass-create Translation Sets < %s < GlotPress' ), $project->name ) ); 3 gp_breadcrumb( array( 4 gp_link_project_get( $project, $project->name ), 5 ) ); 3 gp_breadcrumb( gp_breadcrumb_project( $project ) ); 6 4 wp_enqueue_script( 'mass-create-sets-page' ); 7 5 wp_localize_script( 'mass-create-sets-page', '$gp_mass_create_sets_options', array( 8 6 'url' => gp_url_join( gp_url_current(), 'preview'), -
gp-templates/project-permissions.php
1 1 <?php 2 2 gp_title( sprintf( __( 'Permissions < %s < GlotPress' ), $project->name ) ); 3 gp_breadcrumb( array( 4 gp_link_project_get( $project, $project->name ), 3 gp_breadcrumb( array_merge( gp_breadcrumb_project( $project ), array( 5 4 __('Permissions') 6 ) ) ;5 ) ) ); 7 6 gp_tmpl_header(); 8 7 ?> 9 8 <h2><?php _e('Permissions'); ?></h2> … … 28 27 <span class="user"><?php echo esc_html( $permission->set_slug ); ?></span> 29 28 <a href="<?php echo gp_url_join( gp_url_current(), '-delete/'.$permission->id ); ?>" class="action delete"><?php _e('Remove'); ?></a> 30 29 </li> 31 <? endforeach; ?>30 <?php endforeach; ?> 32 31 </ul> 33 32 <?php endif; ?> 34 33 <?php if ( $parent_permissions ): ?> … … 45 44 <span class="permission-action">in the project </span> 46 45 <span class="user"><?php gp_link_project( $permission->project, esc_html( $permission->project->name ) ); ?></span> 47 46 </li> 48 <? endforeach; ?>47 <?php endforeach; ?> 49 48 </ul> 50 49 <?php endif; ?> 51 50 <?php if ( !$permissions && !$parent_permissions ): ?> -
gp-templates/project.php
1 1 <?php 2 2 gp_title( sprintf( __('%s < GlotPress'), esc_html( $project->name ) ) ); 3 gp_breadcrumb( array( 4 // TODO: add parent projects to breadcrumb 5 gp_link_project_get( $project, $project->name ), 6 ) ); 3 gp_breadcrumb( gp_breadcrumb_project( $project ) ); 7 4 wp_enqueue_script( 'common' ); 8 5 gp_tmpl_header(); 9 6 ?> 10 7 <p class="description"> 11 8 <?php echo $project->description; ?> 12 <span class="secondary"><?php if ( $can_write ) gp_link_project_edit( $project, __('Edit project') ); ?></span>13 9 </p> 10 11 <?php if ( $can_write ): ?> 12 <p id="project-actions" class="secondary actionlist"> 13 <?php gp_link_project_edit( $project, __('Edit project') ); ?> • 14 <?php gp_link( gp_url_project( $project, 'import-originals' ), __( 'Import originals' ) ); ?> • 15 <?php gp_link( gp_url_project( $project, array( '-permissions' ) ), __('Permissions') ); ?> • 16 <?php gp_link( gp_url_project( '', '-new', array('parent_project_id' => $project->id) ), __('New Sub-Project') ); ?> • 17 <?php gp_link( gp_url( '/sets/-new', array( 'project_id' => $project->id ) ), __('New Translation Set') ); ?> • 18 <?php gp_link( gp_url_project( $project, array( '-mass-create-sets' ) ), __('Mass-create Translation Sets') ); ?> 19 </p> 20 <script type="text/javascript"> 21 jQuery(function($){ 22 var project_actions = $('<select/>').html('<option value=""><?php echo addslashes( __( 'Project actions' ) ); ?></option>').change(function(){ 23 if ($(this).val()) 24 location.href = $(this).val(); 25 }); 26 $('#project-actions').children('a').each(function(){ 27 project_actions.append($('<option/>').text($(this).text()).val($(this).attr('href'))); 28 }).end().replaceWith(project_actions); 29 }); 30 </script> 31 <div class="clear"></div> 32 <?php endif; ?> 33 34 <div id="sub-projects"> 14 35 <?php if ($sub_projects): ?> 15 < p class="secondary"><?php printf( __('Sub-projects of %s:'), $project->name ); ?></p>16 <ul >36 <h2><?php printf( __('Sub-projects of %s:'), $project->name ); ?></h2> 37 <ul class="sub-projects"> 17 38 <?php foreach($sub_projects as $sub_project): ?> 18 39 <li> 19 <?php gp_link_project( $sub_project, esc_html( $sub_project->name )); ?> 20 <?php gp_link_project_edit( $sub_project ); ?> 40 <?php gp_link_project( $sub_project, esc_html( $sub_project->name )); ?> 41 <?php gp_link_project_edit( $sub_project ); ?> 21 42 <?php gp_link_project_delete( $sub_project ); ?> 43 <p class="secondary description"><?php echo $sub_project->description; ?></p> 22 44 </li> 23 45 <?php endforeach; ?> 24 </ul> 46 </ul> 25 47 <?php endif; ?> 48 </div> 49 <div id="translation-sets"> 26 50 <?php if ( $translation_sets ): ?> 27 <?php _e('Translations:'); ?> 28 <ul class="translation-sets"> 51 <h2><?php _e('Translations:'); ?></h2> 52 <table class="translation-sets"> 53 <thead> 54 <tr> 55 <th><?php _e( 'Language' ); ?></th> 56 <th><?php echo _x( '%', 'language translation percent header' ); ?></th> 57 <th><?php _e( 'Translated' ); ?></th> 58 <th><?php _e( 'Untranslated' ); ?></th> 59 <th><?php _e( 'Waiting' ); ?></th> 60 </tr> 61 </thead> 62 <tbody> 29 63 <?php foreach( $translation_sets as $set ): ?> 30 <li> 31 <?php gp_link( gp_url_project( $project, gp_url_join( $set->locale, $set->slug ) ), $set->name_with_locale() ); ?> 32 <span class="stats secondary"> 33 <!-- 34 <span class="translated" title="translated"><?php echo $set->current_count(); ?></span> 35 <span class="untranslated" title="untranslated"><?php echo $set->untranslated_count(); ?></span> 36 --> 37 <?php if ( GP::$user->can( 'approve', 'translation-set', $set->id ) && $waiting = $set->waiting_count() ): ?> 38 <?php gp_link( gp_url_project( $project, gp_url_join( $set->locale, $set->slug ), 39 array('filters[translated]' => 'yes', 'filters[status]' => 'waiting') ), $waiting, array('class' => 'waiting', 'title' => 'waiting') ); ?> 40 <?php endif; ?> 41 <?php if ( GP::$user->can( 'approve', 'translation-set', $set->id ) && $warnings = $set->warnings_count() ): ?> 42 <?php gp_link( gp_url_project( $project, gp_url_join( $set->locale, $set->slug ), 43 array('filters[translated]' => 'yes', 'filters[warnings]' => 'yes' ) ), $warnings, array('class' => 'warnings', 'title' => 'with warnings') ); ?> 44 <?php endif; ?> 45 46 <?php do_action( 'project_template_translation_set_extra', $set, $project ); ?> 47 </span> 48 </li> 64 <tr<?php echo alt_class( 'set' ); ?>> 65 <td> 66 <strong><?php gp_link( gp_url_project( $project, gp_url_join( $set->locale, $set->slug ) ), $set->name_with_locale() ); ?></strong> 67 <?php do_action( 'project_template_translation_set_extra', $set, $project ); ?> 68 </td> 69 <td class="stats percent"><?php echo $set->percent_translated(); ?></td> 70 <td class="stats translated" title="translated"><?php gp_link( gp_url_project( $project, gp_url_join( $set->locale, $set->slug ), 71 array('filters[translated]' => 'yes', 'filters[status]' => 'current') ), $set->current_count() );; ?></td> 72 <td class="stats untranslated" title="untranslated"><?php gp_link( gp_url_project( $project, gp_url_join( $set->locale, $set->slug ), 73 array('filters[translated]' => 'no', 'filters[status]' => 'either') ), $set->untranslated_count() ); ?></td> 74 <td class="stats waiting"><?php gp_link( gp_url_project( $project, gp_url_join( $set->locale, $set->slug ), 75 array('filters[translated]' => 'yes', 'filters[status]' => 'waiting') ), $set->waiting_count() ); ?></td> 76 </tr> 49 77 <?php endforeach; ?> 50 </ul> 78 </tbody> 79 </table> 51 80 <?php elseif ( !$sub_projects ): ?> 52 81 <p><?php _e('There are no translations of this project.'); ?></p> 53 82 <?php endif; ?> 83 </div> 54 84 <?php if ( $can_write && $translation_sets ): ?> 55 <div class="secondary actionlist ">85 <div class="secondary actionlist clear"> 56 86 <a href="#" class="personal-options" id="personal-options-toggle"><?php _e('Personal project options ↓'); ?></a> 57 87 <div class="personal-options"> 58 88 <form action="<?php echo gp_url_project( $project, '-personal' ); ?>" method="post"> … … 71 101 </div> 72 102 </div> 73 103 <?php endif; ?> 74 <?php if ( $can_write ): ?> 75 <p class="secondary actionlist"> 76 <?php gp_link( gp_url_project( $project, 'import-originals' ), __( 'Import originals' ) ); ?> • 77 <?php gp_link( gp_url_project( $project, array( '-permissions' ) ), __('Permissions') ); ?> • 78 <?php gp_link( gp_url_project( '', '-new', array('parent_project_id' => $project->id) ), __('New Sub-Project') ); ?> • 79 <?php gp_link( gp_url( '/sets/-new', array( 'project_id' => $project->id ) ), __('New Translation Set') ); ?> • 80 <?php gp_link( gp_url_project( $project, array( '-mass-create-sets' ) ), __('Mass-create Translation Sets') ); ?> 81 </p> 82 <?php endif; ?> 104 <div class="clear"></div> 83 105 <script type="text/javascript" charset="utf-8"> 84 106 $gp.showhide('a.personal-options', 'Personal project options ↓', 'Personal project options ↑', 'div.personal-options', '#source-url-template'); 85 107 $('div.personal-options').hide(); -
gp-templates/translations.php
1 1 <?php 2 2 gp_title( sprintf( __( 'Translations < %s < %s < GlotPress' ), $translation_set->name, $project->name ) ); 3 gp_breadcrumb( array( 4 gp_link_project_get( $project, $project->name ), 5 gp_link_get( $url, $locale->english_name . 'default' != $translation_set->slug? ' '.$translation_set->name : '' ), 6 ) ); 3 gp_breadcrumb( array_merge( gp_breadcrumb_project( $project ), array( 4 gp_link_get( $url, $locale->english_name . 'default' != $translation_set->slug ? ' '.$translation_set->name : '' ), 5 ) ) ); 7 6 wp_enqueue_script( 'editor' ); 8 7 wp_enqueue_script( 'translations-page' ); 9 8 // localizer adds var in front of the variable name, so we can't use $gp.editor.options
