[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/gp-templates/ -> project.php (source)

   1  <?php
   2  gp_title(
   3      sprintf(
   4          /* translators: %s: Project name. */
   5          __( '%s &lt; GlotPress', 'glotpress' ),
   6          esc_html( $project->name )
   7      )
   8  );
   9  gp_breadcrumb_project( $project );
  10  gp_enqueue_scripts( array( 'gp-editor', 'tablesorter' ) );
  11  gp_enqueue_style( 'tablesorter-theme' );
  12  $edit_link   = gp_link_project_edit_get( $project, _x( '(edit)', 'project', 'glotpress' ) );
  13  $delete_link = gp_link_project_delete_get( $project, _x( '(delete)', 'project', 'glotpress' ) );
  14  
  15  if ( $project->active ) {
  16      add_filter(
  17          'gp_breadcrumb_items',
  18          function( $items ) {
  19              $items[ count( $items ) - 1 ] .= ' <span class="active bubble">' . __( 'Active', 'glotpress' ) . '</span>';
  20  
  21              return $items;
  22          }
  23      );
  24  }
  25  
  26  gp_tmpl_header();
  27  ?>
  28  <h2>
  29      <?php
  30      echo esc_html( $project->name );
  31      // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  32      echo $edit_link;
  33      // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  34      echo $delete_link;
  35      ?>
  36  </h2>
  37  
  38  <?php
  39  /**
  40   * Filter a project description.
  41   *
  42   * @since 1.0.0
  43   *
  44   * @param string     $description Project description.
  45   * @param GP_Project $project     The current project.
  46   */
  47  // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  48  $project_description = apply_filters( 'gp_project_description', $project->description, $project );
  49  
  50  if ( $project_description ) {
  51      // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Sanitized via filters.
  52      echo '<div class="project-description">' . $project_description . '</div>';
  53  }
  54  ?>
  55  
  56  <?php if ( $can_write ) : ?>
  57  
  58  <div class="actionlist">
  59      <a href="#" class="project-actions" id="project-actions-toggle"><?php echo __( 'Project actions', 'glotpress' ) . ' &darr;'; ?></a>
  60      <div class="project-actions hide-if-js">
  61          <?php gp_project_actions( $project, $translation_sets ); ?>
  62      </div>
  63  </div>
  64  <?php endif; ?>
  65  
  66  <?php
  67  $project_class = $sub_projects ? 'with-sub-projects' : '';
  68  ?>
  69  <div id="project" class="<?php echo esc_attr( $project_class ); ?>">
  70  
  71  <?php if ( $translation_sets ) : ?>
  72  <div id="translation-sets">
  73      <h3><?php _e( 'Translations', 'glotpress' ); ?></h3>
  74      <table class="translation-sets tablesorter tablesorter-glotpress">
  75          <thead>
  76              <tr class="tablesorter-headerRow">
  77                  <th class="header tablesorter-header tablesorter-headerUnSorted"><?php _e( 'Locale', 'glotpress' ); ?></th>
  78                  <th class="header tablesorter-header tablesorter-headerUnSorted"><?php _ex( '%', 'locale translation percent header', 'glotpress' ); ?></th>
  79                  <th class="header tablesorter-header tablesorter-headerDesc"><?php _e( 'Translated', 'glotpress' ); ?></th>
  80                  <th class="header tablesorter-header tablesorter-headerUnSorted"><?php _e( 'Fuzzy', 'glotpress' ); ?></th>
  81                  <th class="header tablesorter-header tablesorter-headerUnSorted"><?php _e( 'Untranslated', 'glotpress' ); ?></th>
  82                  <th class="header tablesorter-header tablesorter-headerUnSorted"><?php _e( 'Waiting', 'glotpress' ); ?></th>
  83                  <?php if ( has_action( 'gp_project_template_translation_set_extra' ) ) : ?>
  84                  <th class="header tablesorter-header tablesorter-headerUnSorted extra"><?php _e( 'Extra', 'glotpress' ); ?></th>
  85                  <?php endif; ?>
  86              </tr>
  87          </thead>
  88          <tbody>
  89          <?php
  90          $class = '';
  91  
  92          foreach ( $translation_sets as $set ) :
  93              $class = ( 'odd' === $class ) ? 'even' : 'odd';
  94  
  95          ?>
  96              <tr class="<?php echo esc_attr( $class ); ?>">
  97                  <td>
  98                      <strong><?php gp_link( gp_url_project( $project, gp_url_join( $set->locale, $set->slug ) ), $set->name_with_locale() ); ?></strong>
  99                      <?php
 100                      if ( $set->current_count && $set->current_count >= $set->all_count * 0.9 ) :
 101                              $percent = floor( $set->current_count / $set->all_count * 100 );
 102                      ?>
 103                          <span class="bubble morethan90"><?php echo number_format_i18n( $percent ); ?>%</span>
 104                      <?php endif; ?>
 105                  </td>
 106                  <td class="stats percent"><?php echo number_format_i18n( $set->percent_translated ); ?>%</td>
 107                  <td class="stats translated" title="translated">
 108                      <?php
 109                      gp_link(
 110                          gp_url_project(
 111                              $project,
 112                              gp_url_join( $set->locale, $set->slug ),
 113                              array(
 114                                  'filters[translated]' => 'yes',
 115                                  'filters[status]'     => 'current',
 116                              )
 117                          ),
 118                          number_format_i18n( $set->current_count )
 119                      );
 120                      ?>
 121                  </td>
 122                  <td class="stats fuzzy" title="fuzzy">
 123                      <?php
 124                      gp_link(
 125                          gp_url_project(
 126                              $project,
 127                              gp_url_join( $set->locale, $set->slug ),
 128                              array(
 129                                  'filters[translated]' => 'yes',
 130                                  'filters[status]'     => 'fuzzy',
 131                              )
 132                          ),
 133                          number_format_i18n( $set->fuzzy_count )
 134                      );
 135                      ?>
 136                  </td>
 137                  <td class="stats untranslated" title="untranslated">
 138                      <?php
 139                      gp_link(
 140                          gp_url_project(
 141                              $project,
 142                              gp_url_join( $set->locale, $set->slug ),
 143                              array(
 144                                  'filters[status]' => 'untranslated',
 145                              )
 146                          ),
 147                          number_format_i18n( $set->untranslated_count )
 148                      );
 149                      ?>
 150                  </td>
 151                  <td class="stats waiting">
 152                      <?php
 153                      gp_link(
 154                          gp_url_project(
 155                              $project,
 156                              gp_url_join( $set->locale, $set->slug ),
 157                              array(
 158                                  'filters[translated]' => 'yes',
 159                                  'filters[status]'     => 'waiting',
 160                              )
 161                          ),
 162                          number_format_i18n( $set->waiting_count )
 163                      );
 164                      ?>
 165                  </td>
 166                  <?php if ( has_action( 'gp_project_template_translation_set_extra' ) ) : ?>
 167                      <td class="extra">
 168                          <?php
 169                          /**
 170                           * Fires in an extra information column of a translation set.
 171                           *
 172                           * @since 1.0.0
 173                           *
 174                           * @param GP_Translation_Set $set     The translation set.
 175                           * @param GP_Project         $project The current project.
 176                           */
 177                          do_action( 'gp_project_template_translation_set_extra', $set, $project );
 178                          ?>
 179                      </td>
 180                  <?php endif; ?>
 181              </tr>
 182          <?php endforeach; ?>
 183          </tbody>
 184      </table>
 185  </div>
 186  <?php elseif ( ! $sub_projects ) : ?>
 187      <p><?php _e( 'There are no translations of this project.', 'glotpress' ); ?></p>
 188  <?php endif; ?>
 189  
 190  
 191  <?php if ( $sub_projects ) : ?>
 192  <div id="sub-projects">
 193  <h3><?php _e( 'Sub-projects', 'glotpress' ); ?></h3>
 194  <dl>
 195  <?php foreach ( $sub_projects as $sub_project ) : ?>
 196      <dt>
 197          <?php gp_link_project( $sub_project, esc_html( $sub_project->name ) ); ?>
 198          <?php gp_link_project_edit( $sub_project, null, array( 'class' => 'bubble' ) ); ?>
 199          <?php gp_link_project_delete( $sub_project, null, array( 'class' => 'bubble' ) ); ?>
 200          <?php
 201          if ( $sub_project->active ) {
 202              echo "<span class='active bubble'>" . __( 'Active', 'glotpress' ) . '</span>';
 203          }
 204          ?>
 205      </dt>
 206      <dd>
 207          <?php
 208          /**
 209           * Filter a sub-project description.
 210           *
 211           * @since 1.0.0
 212           *
 213           * @param string     $description Sub-project description.
 214           * @param GP_Project $project     The sub-project.
 215           */
 216          echo esc_html( gp_html_excerpt( apply_filters( 'gp_sub_project_description', $sub_project->description, $sub_project ), 111 ) );
 217          ?>
 218      </dd>
 219  <?php endforeach; ?>
 220  </dl>
 221  </div>
 222  <?php endif; ?>
 223  
 224  </div>
 225  
 226  <div class="clear"></div>
 227  
 228  
 229  <script type="text/javascript" charset="utf-8">
 230      $gp.showhide('a.personal-options', 'div.personal-options', {
 231          show_text: '<?php echo __( 'Personal project options', 'glotpress' ) . ' &darr;'; ?>',
 232          hide_text: '<?php echo __( 'Personal project options', 'glotpress' ) . ' &uarr;'; ?>',
 233          focus: '#source-url-template',
 234          group: 'personal'
 235      });
 236      jQuery('div.personal-options').hide();
 237      $gp.showhide('a.project-actions', 'div.project-actions', {
 238          show_text: '<?php echo __( 'Project actions', 'glotpress' ) . ' &darr;'; ?>',
 239          hide_text: '<?php echo __( 'Project actions', 'glotpress' ) . ' &uarr;'; ?>',
 240          focus: '#source-url-template',
 241          group: 'project'
 242      });
 243      jQuery(document).ready(function($) {
 244          $(".translation-sets").tablesorter({
 245              theme: 'glotpress',
 246              sortList: [[2,1]],
 247              headers: {
 248                  0: {
 249                      sorter: 'text'
 250                  }
 251              },
 252              widgets: ['zebra']
 253          });
 254      });
 255  </script>
 256  <?php
 257  gp_tmpl_footer();


Generated: Wed Apr 21 01:02:02 2021 Cross-referenced by PHPXref 0.7.1