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


Generated: Mon Jun 27 01:01:04 2022 Cross-referenced by PHPXref 0.7.1