[ 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      gp_link_glossary_edit(
  38          $glossary,
  39          $translation_set,
  40          __( '(edit)', 'glotpress' )
  41      );
  42      gp_link_glossary_delete(
  43          $glossary,
  44          $translation_set,
  45          __( '(delete)', 'glotpress' )
  46      );
  47      ?>
  48  </h2>
  49  
  50  <?php
  51  /**
  52   * Filter a glossary description.
  53   *
  54   * @since 3.0.0
  55   *
  56   * @param string      $description Glossary description.
  57   * @param GP_Glossary $project     The current glossary.
  58   */
  59  $glossary_description = apply_filters( 'gp_glossary_description', $glossary->description, $glossary );
  60  
  61  if ( $glossary_description ) {
  62      // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Sanitized via filters.
  63      echo '<div class="glossary-description">' . $glossary_description . '</div>';
  64  }
  65  ?>
  66  
  67  <table class="glossary" id="glossary">
  68      <thead>
  69          <tr>
  70              <th style="width:20%"><?php _ex( 'Item', 'glossary entry', 'glotpress' ); ?></th>
  71              <th style="width:20%"><?php _ex( 'Part of speech', 'glossary entry', 'glotpress' ); ?></th>
  72              <th style="width:20%"><?php _ex( 'Translation', 'glossary entry', 'glotpress' ); ?></th>
  73              <th style="width:30%"><?php _ex( 'Comments', 'glossary entry', 'glotpress' ); ?></th>
  74          <?php if ( $can_edit ) : ?>
  75              <th style="width:10%">&mdash;</th>
  76          <?php endif; ?>
  77          </tr>
  78      </thead>
  79      <tbody>
  80  <?php
  81      if ( count( $glossary_entries ) > 0 ) {
  82          foreach ( $glossary_entries as $entry ) {
  83              gp_tmpl_load( 'glossary-entry-row', get_defined_vars() );
  84          }
  85      } else {
  86          ?>
  87          <tr>
  88              <td colspan="5">
  89                  <?php _e( 'No glossary entries yet.', 'glotpress' ); ?>
  90              </td>
  91          </tr>
  92          <?php
  93      }
  94  ?>
  95          <?php if ( $can_edit ) : ?>
  96          <tr>
  97              <td colspan="5">
  98                  <h4><?php _e( 'Create an entry', 'glotpress' ); ?></h4>
  99  
 100                  <form action="<?php echo esc_url( gp_url_join( $url, '-new' ) ); ?>" method="post">
 101                      <dl>
 102                          <dt><label for="new_glossary_entry_term"><?php echo esc_html( _x( 'Original term:', 'glossary entry', 'glotpress' ) ); ?></label></dt>
 103                          <dd><input type="text" name="new_glossary_entry[term]" id="new_glossary_entry_term" value=""></dd>
 104                          <dt><label for="new_glossary_entry_post"><?php _ex( 'Part of speech', 'glossary entry', 'glotpress' ); ?></label></dt>
 105                          <dd>
 106                              <select name="new_glossary_entry[part_of_speech]" id="new_glossary_entry_post">
 107                              <?php
 108                                  foreach ( GP::$glossary_entry->parts_of_speech as $pos => $name ) {
 109                                      echo "\t<option value='" . esc_attr( $pos ) . "'>" . esc_html( $name ) . "</option>\n";
 110                                  }
 111                              ?>
 112                              </select>
 113                          </dd>
 114                          <dt><label for="new_glossary_entry_translation"><?php _ex( 'Translation', 'glossary entry', 'glotpress' ); ?></label></dt>
 115                          <dd><input type="text" name="new_glossary_entry[translation]" id="new_glossary_entry_translation" value=""></dd>
 116                          <dt><label for="new_glossary_entry_comments"><?php _ex( 'Comments', 'glossary entry', 'glotpress' ); ?></label></dt>
 117                          <dd><textarea type="text" name="new_glossary_entry[comment]" id="new_glossary_entry_comments"></textarea></dd>
 118                      </dl>
 119                      <p>
 120                          <input type="hidden" name="new_glossary_entry[glossary_id]" value="<?php echo esc_attr( $glossary->id ); ?>">
 121                          <input type="submit" name="submit" value="<?php esc_attr_e( 'Create', 'glotpress' ); ?>" id="submit" />
 122                      </p>
 123                      <?php gp_route_nonce_field( 'add-glossary-entry_' . $project->path . $locale->slug . $translation_set->slug ); ?>
 124                  </form>
 125              </td>
 126          </tr>
 127          <?php endif; ?>
 128      </tbody>
 129  </table>
 130  
 131  <p class="clear actionlist secondary">
 132      <?php if ( $can_edit ) : ?>
 133          <?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;
 134      <?php endif; ?>
 135  
 136      <?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' ) ); ?>
 137  </p>
 138  
 139  <?php
 140  gp_tmpl_footer();


Generated: Sat Nov 28 01:02:01 2020 Cross-referenced by PHPXref 0.7.1