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