Ticket #95: new-project-page.1.patch

File new-project-page.1.patch, 17.8 KB (added by Nightgunner5, 22 months ago)

Implementation of the "split" layout

  • css/style.css

     
    5858        line-height: 1.5em; 
    5959        width: 40em; 
    6060}        
    61 table.translations { 
     61table.translations, table.translation-sets { 
    6262        font-size: 90%; 
    6363        width: 100%; 
    6464        border-spacing: 0.1em; 
    6565} 
    66 table.translations th { 
     66table.translations th, table.translation-sets th { 
    6767        font-weight: bold; 
    6868        color: #eee; 
    6969        background-color: #555;  
    7070} 
    71 table.translations tr { 
     71table.translations tr, table.translation-sets tr { 
    7272        border: 0; 
    7373} 
    7474table.translations td.translation ul { 
     
    9393    font-style: italic; 
    9494} 
    9595 
    96 table.translations td, table.translations th { 
     96table.translations td, table.translations th, table.translation-sets td, table.translation-sets th { 
    9797        padding: 0.5em; 
    9898        border: 1px solid #eee; 
    9999        /* white-space: pre-wrap; */ 
     
    414414} 
    415415p.description { 
    416416        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;*/ 
    420420} 
    421421span.added { 
    422422    color: green; 
     
    441441.text { 
    442442        width: 45em; 
    443443        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; 
    444504} 
     505 No newline at end of file 
  • gp-includes/tags.php

     
     1<?php 
     2 
     3class 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 
     31class GP_Translation_Set_Tag extends GP_Tag { 
     32        var $action = 'project_template_translation_set_extra'; 
     33        var $action_num_args = 2; 
     34} 
     35 
     36class 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} 
     46new 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
    
     
    8181        } 
    8282} 
    8383 
     84function 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 
    8495function gp_js_focus_on( $html_id ) { 
    8596        return '<script type="text/javascript">document.getElementById("'.$html_id.'").focus();</script>'; 
    8697} 
     
    217228function gp_array_of_array_of_things_to_json( $array ) { 
    218229        $map_to_fields = create_function( '$array', 'return array_map( lambda( \'$thing\', \'$thing->fields();\' ), $array );' ); 
    219230        return json_encode( array_map( $map_to_fields, $array ) ); 
    220 } 
    221  No newline at end of file 
     231} 
     232 
     233function 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 
     246function alt_class( $key, $others = '' ) { 
     247        echo get_alt_class( $key, $others ); 
     248} 
  • gp-includes/things/project.php

     
    147147                } 
    148148                return compact( 'added', 'removed' ); 
    149149        } 
     150 
     151        function original_count() { 
     152                return count( GP::$original->by_project_id( $this->id ) ); 
     153        } 
    150154} 
    151155GP::$project = new GP_Project(); 
     156 No newline at end of file 
  • gp-includes/things/translation-set.php

     
    144144                );  
    145145        } 
    146146 
     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        } 
    147151} 
    148152GP::$translation_set = new GP_Translation_Set(); 
  • gp-settings.php

     
    176176 
    177177require_once( GP_PATH . GP_INC . 'template.php' ); 
    178178require_once( GP_PATH . GP_INC . 'template-links.php' ); 
     179require_once( GP_PATH . GP_INC . 'tags.php' ); 
    179180 
    180181require_once( GP_PATH . GP_INC . 'cli.php' ); 
    181182 
  • gp-templates/project-edit.php

     
    11<?php 
    22gp_title( sprintf( __( 'Edit Project %s &lt; GlotPress' ),  $project->name ) ); 
    3 gp_breadcrumb( array( 
    4         gp_link_project_get( $project, $project->name ), 
    5 ) ); 
     3gp_breadcrumb( gp_breadcrumb_project( $project ) ); 
    64gp_tmpl_header(); 
    75?> 
    86<h2><?php _e( sprintf( __('Edit project <q>%s</q>'), esc_html( $project->name ) ) ); ?></h2> 
  • gp-templates/project-import.php

     
    22gp_title( $kind == 'originals'? 
    33        sprintf( __('Import Originals &lt; %s &lt; GlotPress'), esc_html( $project->name ) ) : 
    44        sprintf( __('Import Translations &lt; %s &lt; GlotPress'), esc_html( $project->name ) ) ); 
    5 gp_breadcrumb( array( 
    6         gp_link_project_get( $project, $project->name ), 
     5gp_breadcrumb( array_merge( gp_breadcrumb_project( $project ), array( 
    76        $kind == 'originals'? __('Import Originals') : __('Import Translations'), 
    8 ) ); 
     7) ) ); 
    98gp_tmpl_header(); 
    109?> 
    1110<form action="" method="post" enctype="multipart/form-data"> 
  • gp-templates/project-mass-create-sets.php

     
    11<?php 
    22gp_title( sprintf( __( 'Mass-create Translation Sets &lt; %s &lt; GlotPress' ),  $project->name ) ); 
    3 gp_breadcrumb( array( 
    4         gp_link_project_get( $project, $project->name ), 
    5 ) ); 
     3gp_breadcrumb( gp_breadcrumb_project( $project ) ); 
    64wp_enqueue_script( 'mass-create-sets-page' ); 
    75wp_localize_script( 'mass-create-sets-page', '$gp_mass_create_sets_options', array( 
    86        'url' => gp_url_join( gp_url_current(), 'preview'), 
  • gp-templates/project-permissions.php

     
    11<?php 
    22gp_title( sprintf( __( 'Permissions &lt; %s &lt; GlotPress' ), $project->name ) ); 
    3 gp_breadcrumb( array( 
    4         gp_link_project_get( $project, $project->name ), 
     3gp_breadcrumb( array_merge( gp_breadcrumb_project( $project ), array( 
    54        __('Permissions') 
    6 ) ); 
     5) ) ); 
    76gp_tmpl_header(); 
    87?> 
    98<h2><?php _e('Permissions'); ?></h2> 
     
    2827                        <span class="user"><?php echo esc_html( $permission->set_slug ); ?></span> 
    2928                        <a href="<?php echo gp_url_join( gp_url_current(), '-delete/'.$permission->id ); ?>" class="action delete"><?php _e('Remove'); ?></a> 
    3029                </li> 
    31         <? endforeach; ?> 
     30        <?php endforeach; ?> 
    3231</ul>    
    3332        <?php endif; ?> 
    3433        <?php  if ( $parent_permissions ): ?> 
     
    4544                                <span class="permission-action">in the project </span> 
    4645                                <span class="user"><?php gp_link_project( $permission->project, esc_html( $permission->project->name ) ); ?></span> 
    4746                        </li> 
    48                 <? endforeach; ?> 
     47                <?php endforeach; ?> 
    4948</ul>                            
    5049        <?php endif; ?> 
    5150        <?php if ( !$permissions && !$parent_permissions ): ?> 
  • gp-templates/project.php

     
    11<?php 
    22gp_title( sprintf( __('%s &lt; 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 ) ); 
     3gp_breadcrumb( gp_breadcrumb_project( $project ) ); 
    74wp_enqueue_script( 'common' ); 
    85gp_tmpl_header(); 
    96?> 
    107<p class="description"> 
    118        <?php echo $project->description; ?> 
    12         <span class="secondary"><?php if ( $can_write ) gp_link_project_edit( $project, __('Edit project') ); ?></span> 
    139</p> 
     10 
     11<?php if ( $can_write ): ?> 
     12        <p id="project-actions" class="secondary actionlist"> 
     13                <?php gp_link_project_edit( $project, __('Edit project') ); ?> &bull; 
     14                <?php gp_link( gp_url_project( $project, 'import-originals' ), __( 'Import originals' ) ); ?> &bull; 
     15                <?php gp_link( gp_url_project( $project, array( '-permissions' ) ), __('Permissions') ); ?> &bull; 
     16                <?php gp_link( gp_url_project( '', '-new', array('parent_project_id' => $project->id) ), __('New Sub-Project') ); ?> &bull; 
     17                <?php gp_link( gp_url( '/sets/-new', array( 'project_id' => $project->id ) ), __('New Translation Set') ); ?> &bull; 
     18                <?php gp_link( gp_url_project( $project, array( '-mass-create-sets' ) ), __('Mass-create Translation Sets') ); ?> 
     19        </p> 
     20<script type="text/javascript"> 
     21jQuery(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"> 
    1435<?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"> 
    1738<?php foreach($sub_projects as $sub_project): ?> 
    1839        <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 ); ?> 
    2142                <?php gp_link_project_delete( $sub_project ); ?> 
     43                <p class="secondary description"><?php echo $sub_project->description; ?></p> 
    2244        </li> 
    2345<?php endforeach; ?> 
    24 </ul>    
     46</ul> 
    2547<?php endif; ?> 
     48</div> 
     49        <div id="translation-sets"> 
    2650<?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> 
    2963        <?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> 
    4977        <?php endforeach; ?> 
    50         </ul> 
     78        </tbody> 
     79        </table> 
    5180<?php elseif ( !$sub_projects ): ?> 
    5281        <p><?php _e('There are no translations of this project.'); ?></p> 
    5382<?php endif; ?> 
     83        </div> 
    5484<?php if ( $can_write && $translation_sets ): ?> 
    55         <div class="secondary actionlist"> 
     85        <div class="secondary actionlist clear"> 
    5686        <a href="#" class="personal-options" id="personal-options-toggle"><?php _e('Personal project options &darr;'); ?></a> 
    5787        <div class="personal-options"> 
    5888                <form action="<?php echo gp_url_project( $project, '-personal' ); ?>" method="post"> 
     
    71101        </div> 
    72102        </div> 
    73103<?php endif; ?> 
    74 <?php if ( $can_write ): ?> 
    75         <p class="secondary actionlist"> 
    76                 <?php gp_link( gp_url_project( $project, 'import-originals' ), __( 'Import originals' ) ); ?> &bull; 
    77                 <?php gp_link( gp_url_project( $project, array( '-permissions' ) ), __('Permissions') ); ?> &bull; 
    78                 <?php gp_link( gp_url_project( '', '-new', array('parent_project_id' => $project->id) ), __('New Sub-Project') ); ?> &bull; 
    79                 <?php gp_link( gp_url( '/sets/-new', array( 'project_id' => $project->id ) ), __('New Translation Set') ); ?> &bull; 
    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> 
    83105<script type="text/javascript" charset="utf-8"> 
    84106        $gp.showhide('a.personal-options', 'Personal project options &darr;', 'Personal project options &uarr;', 'div.personal-options', '#source-url-template'); 
    85107        $('div.personal-options').hide(); 
  • gp-templates/translations.php

     
    11<?php 
    22gp_title( sprintf( __( 'Translations &lt; %s &lt; %s &lt; 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 ) ); 
     3gp_breadcrumb( array_merge( gp_breadcrumb_project( $project ), array( 
     4        gp_link_get( $url, $locale->english_name . 'default' != $translation_set->slug ? ' '.$translation_set->name : '' ), 
     5) ) ); 
    76wp_enqueue_script( 'editor' ); 
    87wp_enqueue_script( 'translations-page' ); 
    98// localizer adds var in front of the variable name, so we can't use $gp.editor.options