[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/gp-templates/ -> helper-functions.php (source)

   1  <?php
   2  function prepare_original( $text ) {
   3      $text = str_replace( array("\r", "\n"), "<span class='invisibles' title='".esc_attr(__('New line'))."'>&crarr;</span>\n", $text);
   4      $text = str_replace( "\t", "<span class='invisibles' title='".esc_attr(__('Tab character'))."'>&rarr;</span>\t", $text);
   5      return $text;
   6  }
   7  
   8  function textareas( $entry, $permissions, $index = 0 ) {
   9      list( $can_edit, $can_approve ) = $permissions;
  10      $disabled = $can_edit? '' : 'disabled="disabled"';
  11      ?>
  12      <div class="textareas">
  13          <?php 
  14          if( isset( $entry->warnings[$index] ) ):
  15              $referenceable = $entry->warnings[$index];
  16              $warning = each( $referenceable );
  17              ?>
  18              <div class="warning secondary">
  19                  <?php printf( __('<strong>Warning:</strong> %s'), esc_html( $warning['value'] ) ); ?>
  20                  
  21                  <?php if( $can_approve ): ?>
  22                      <a href="#" class="discard-warning" key="<?php echo $warning['key'] ?>" index="<?php echo $index; ?>"><?php _e('Discard'); ?></a>
  23                  <?php endif; ?>
  24              </div>
  25          <?php endif; ?>
  26          <textarea class="foreign-text" name="translation[<?php echo $entry->original_id; ?>][]" <?php echo $disabled; ?>><?php echo esc_translation(gp_array_get($entry->translations, $index)); ?></textarea>
  27  
  28          <?php if ( $can_edit ): ?>
  29              <p>
  30                  <a href="#" class="copy" tabindex="-1"><?php _e('Copy from original'); ?></a> &bull;
  31                  <a href="#" class="gtranslate" tabindex="-1"><?php _e('Translation from Google'); ?></a>
  32              </p>
  33          <?php else: ?>
  34              <p>
  35                  <?php printf( __('You <a href="%s">have to log in</a> to edit this translation.'), gp_url_login() ); ?>
  36              </p>
  37          <?php endif; ?>
  38      </div>
  39      <?php
  40  }
  41  
  42  /**
  43   * Similar to esc_html() but allows double-encoding.
  44   */
  45  function esc_translation( $text ) {
  46      return wp_specialchars( $text, ENT_NOQUOTES, false, true );
  47  }
  48  
  49  function display_status( $status ) {
  50      $status = preg_replace( '/^[+-]/', '', $status);
  51      return $status ? $status : 'untranslated';
  52  }
  53  
  54  function references( $project, $entry ) {
  55      if ( !$project->source_url_template() ) return;
  56      ?>
  57      <?php _e('References:'); ?>
  58      <ul class="refs">    
  59          <?php
  60          foreach( $entry->references as $reference ):
  61              list( $file, $line ) = array_pad( explode( ':', $reference ), 2, 0 );
  62              // TODO: allow the user to override the project setting
  63              if ( $source_url = $project->source_url( $file, $line ) ):
  64                  ?>
  65                  <li><a target="_blank" tabindex="-1" href="<?php echo $source_url; ?>"><?php echo $file.':'.$line ?></a></li>
  66                  <?php
  67              endif;
  68          endforeach;
  69          ?>
  70      </ul>
  71  <?php
  72  }


Generated: Thu May 24 03:59:35 2012 Hosted by follow the white rabbit.