[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/gp-templates/ -> glossary-view.php (source)

   1  <?php
   2  gp_title( __( 'View Glossary &lt; GlotPress', 'glotpress' ) );
   3  gp_breadcrumb(
   4      array(
   5          gp_project_links_from_root( $project ),
   6          gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ), $translation_set->name ),
   7          __( 'Glossary', 'glotpress' ),
   8      )
   9  );
  10  
  11  $ge_delete_ays    = __( 'Are you sure you want to delete this entry?', 'glotpress' );
  12  $delete_url       = gp_url_join( $url, '-delete' );
  13  $glossary_options = compact( 'can_edit', 'url', 'delete_url', 'ge_delete_ays' );
  14  
  15  gp_enqueue_scripts( 'gp-glossary' );
  16  wp_localize_script( 'gp-glossary', '$gp_glossary_options', $glossary_options );
  17  
  18  gp_tmpl_header();
  19  
  20  /* translators: 1: Locale english name. 2: Project name. */
  21  $glossary_title = __( 'Glossary for %1$s translation of %2$s', 'glotpress' );
  22  if ( 0 === $project->id ) {
  23      /* translators: %s: Locale english name. */
  24      $glossary_title = __( 'Glossary for %s', 'glotpress' );
  25  }
  26  ?>
  27  
  28  <h2>
  29      <?php
  30      printf(
  31          // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  32          $glossary_title,
  33          esc_html( $translation_set->name ),
  34          esc_html( $project->name )
  35      );
  36      ?>
  37      <?php gp_link_glossary_edit( $glossary, $translation_set, _x( '(edit)', 'glossary', 'glotpress' ) ); ?>
  38      <?php gp_link_glossary_delete( $glossary, $translation_set, _x( '(delete)', 'glossary', 'glotpress' ) ); ?>
  39  </h2>
  40  
  41  <?php
  42  /**
  43   * Filter a glossary description.
  44   *
  45   * @since 3.0.0
  46   *
  47   * @param string      $description Glossary description.
  48   * @param GP_Glossary $project     The current glossary.
  49   */
  50  $glossary_description = apply_filters( 'gp_glossary_description', $glossary->description, $glossary );
  51  
  52  if ( $glossary_description ) {
  53      // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Sanitized via filters.
  54      echo '<div class="glossary-description">' . $glossary_description . '</div>';
  55  }
  56  ?>
  57  
  58  <table class="glossary" id="glossary">
  59      <thead>
  60          <tr>
  61              <th style="width:20%"><?php _ex( 'Item', 'glossary entry', 'glotpress' ); ?></th>
  62              <th style="width:20%"><?php _ex( 'Part of speech', 'glossary entry', 'glotpress' ); ?></th>
  63              <th style="width:20%"><?php _ex( 'Translation', 'glossary entry', 'glotpress' ); ?></th>
  64              <th style="width:30%"><?php _ex( 'Comments', 'glossary entry', 'glotpress' ); ?></th>
  65          <?php if ( $can_edit ) : ?>
  66              <th style="width:10%">&mdash;</th>
  67          <?php endif; ?>
  68          </tr>
  69      </thead>
  70      <tbody>
  71  <?php
  72      if ( count( $glossary_entries ) > 0 ) {
  73          foreach ( $glossary_entries as $entry ) {
  74              gp_tmpl_load( 'glossary-entry-row', get_defined_vars() );
  75          }
  76      } else {
  77          ?>
  78          <tr>
  79              <td colspan="5">
  80                  <?php _e( 'No glossary entries yet.', 'glotpress' ); ?>
  81              </td>
  82          </tr>
  83          <?php
  84      }
  85  ?>
  86          <?php if ( $can_edit ) : ?>
  87          <tr>
  88              <td colspan="5">
  89                  <h4><?php _e( 'Create an entry', 'glotpress' ); ?></h4>
  90  
  91                  <form action="<?php echo esc_url( gp_url_join( $url, '-new' ) ); ?>" method="post">
  92                      <dl>
  93                          <dt><label for="new_glossary_entry_term"><?php echo esc_html( _x( 'Original term:', 'glossary entry', 'glotpress' ) ); ?></label></dt>
  94                          <dd><input type="text" name="new_glossary_entry[term]" id="new_glossary_entry_term" value=""></dd>
  95                          <dt><label for="new_glossary_entry_post"><?php _ex( 'Part of speech', 'glossary entry', 'glotpress' ); ?></label></dt>
  96                          <dd>
  97                              <select name="new_glossary_entry[part_of_speech]" id="new_glossary_entry_post">
  98                              <?php
  99                                  foreach ( GP::$glossary_entry->parts_of_speech as $pos => $name ) {
 100                                      echo "\t<option value='" . esc_attr( $pos ) . "'>" . esc_html( $name ) . "</option>\n";
 101                                  }
 102                              ?>
 103                              </select>
 104                          </dd>
 105                          <dt><label for="new_glossary_entry_translation"><?php _ex( 'Translation', 'glossary entry', 'glotpress' ); ?></label></dt>
 106                          <dd><input type="text" name="new_glossary_entry[translation]" id="new_glossary_entry_translation" value=""></dd>
 107                          <dt><label for="new_glossary_entry_comments"><?php _ex( 'Comments', 'glossary entry', 'glotpress' ); ?></label></dt>
 108                          <dd><textarea type="text" name="new_glossary_entry[comment]" id="new_glossary_entry_comments"></textarea></dd>
 109                      </dl>
 110                      <p>
 111                          <input type="hidden" name="new_glossary_entry[glossary_id]" value="<?php echo esc_attr( $glossary->id ); ?>">
 112                          <input type="submit" name="submit" value="<?php esc_attr_e( 'Create', 'glotpress' ); ?>" id="submit" />
 113                      </p>
 114                      <?php gp_route_nonce_field( 'add-glossary-entry_' . $project->path . $locale->slug . $translation_set->slug ); ?>
 115                  </form>
 116              </td>
 117          </tr>
 118          <?php endif; ?>
 119      </tbody>
 120  </table>
 121  
 122  <p class="clear actionlist secondary">
 123      <?php if ( $can_edit ) : ?>
 124          <?php echo gp_link( gp_url_join( gp_url_project_locale( $project->path, $locale_slug, $translation_set_slug ), array( 'glossary', '-import' ) ), __( 'Import', 'glotpress' ) ); ?>  &bull;&nbsp;
 125      <?php endif; ?>
 126  
 127      <?php echo gp_link( gp_url_join( gp_url_project_locale( $project->path, $locale_slug, $translation_set_slug ), array( 'glossary', '-export' ) ), __( 'Export as CSV', 'glotpress' ) ); ?>
 128  </p>
 129  
 130  <?php
 131  gp_tmpl_footer();


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