feat:3.0.0版初次提交,新版将完全推倒重写

This commit is contained in:
sunxiyuan 2020-07-13 18:44:03 +08:00
parent e556c4b6d9
commit 39735249ee
293 changed files with 26908 additions and 475 deletions

View file

@ -0,0 +1,36 @@
<?php
/**
* Confirmation form for deleting a file
*/
$this->extend('../layout');
?>
<form action="" method="post" enctype="application/x-www-form-urlencoded" id="loco-del">
<div class="notice inline notice-danger">
<h3>
<span class="has-icon icon-trash"> </span>
<span><?php esc_html_e('Confirm delete','loco-translate')?></span>
</h3>
<p>
<?php
echo __('Are you sure you want to <strong>permanently</strong> delete the following file?','loco-translate')?>
</p>
<p>
<code><?php $info->e('relpath')?></code>
</p><?php
if( $params->has('deps') ):?>
<p>
<strong><?php $params->e('warn')?></strong><?php
foreach( $deps as $info ):?>
<div><?php $info->e('name')?></div><?php
endforeach?>
</p><?php
endif?>
<p class="submit">
<button type="submit" class="button button-danger" disabled><?php esc_html_e('Delete Permanently','default')?></button>
</p>
</div>
<?php
/* @var Loco_mvc_HiddenFields $hidden */
$hidden->_e();?>
</form>

View file

@ -0,0 +1,85 @@
<?php
/**
* File revisions and rollback UI
*/
$this->extend('../layout');
$dfmt = _x( 'j M @ H:i', 'revision date short format', 'default' );
?>
<div class="revisions loading" id="loco-ui">
<form class="revisions-control-frame" action="" method="post" enctype="application/x-www-form-urlencoded">
<div class="loco-clearfix">
<div class="revisions-previous jshide">
<button type="button" class="button" disabled><?php echo esc_attr_x( 'Previous', 'Button label for a previous revision' ); ?></button>
</div>
<div class="revisions-next jshide">
<button type="button" class="button" disabled><?php echo esc_attr_x( 'Next', 'Button label for a next revision' ); ?></button>
</div>
</div>
<div class="revisions-meta loco-clearfix">
<div class="diff-meta diff-right">
<span>Current revision saved <?php $master->e('reltime')?></span><br />
<time><?php $master->date('mtime',$dfmt)?></time><br />
<button type="button" class="button disabled" disabled>Restore</button>
</div><?php
/* @var $file Loco_mvc_FileParams */
foreach( $files as $i => $file ):?>
<div class="diff-meta jshide">
<span><?php $file->e('name')?></span><br />
<time><?php $file->date('potime',$dfmt)?></time><br />
<button type="submit" class="button button-primary" name="backup" value="<?php $file->e('relpath')?>"><?php esc_html_e('Restore','loco-translate')?></button>
<button type="submit" class="button button-danger" name="delete" value="<?php $file->e('relpath')?>"><?php esc_html_e('Delete','loco-translate')?></button>
</div><?php
endforeach?>
</div><?php
/* @var $hidden Loco_mvc_HiddenFields */
$hidden->_e();?>
</form>
<div class="revisions-diff-frame jsonly">
<div class="revisions-diff">
<div class="loading-indicator"><span class="spinner"></span></div>
<div class="diff"></div>
</div>
</div>
</div>
<?php /*
<!--hr />
<h3>Advanced</h3>
<form action="" method="post" enctype="application/x-www-form-urlencoded">
<table class="wp-list-table widefat striped">
<thead>
<tr>
<th>
<?php esc_html_e('Revision saved','loco-translate')?>
</th>
<th>
<?php esc_html_e('File info','loco-translate')?>
</th>
</tr>
</thead>
<tbody><?php
foreach( $files as $i => $file ):?>
<tr>
<td>
<label>
<input type="radio" name="backup" value="<?php $file->e('relpath')?>" />
<?php $file->date('mtime')?>
</label>
</td>
<td><code class="path"><?php $file->ls()?></code></td>
</tr><?php
endforeach?>
</tbody>
</table>
<p class="submit">
<button type="submit" class="button button-danger"><?php esc_html_e('Restore selected','default')?></button>
</p>
<?php
$hidden->_e();?>
</form-->
*/

View file

@ -0,0 +1,69 @@
<?php
/**
* PO file editor
*/
$this->extend('editor');
$this->start('header');
echo $this->render('../common/inc-po-header');
/* @var Loco_mvc_ViewParams $js */
$help = apply_filters('loco_external','https://localise.biz/wordpress/plugin/manual/providers');
// inline modal for auto-translate. Note that modal will be placed outside of #loco.wrap element
if( $js->apis ):?>
<div id="loco-auto" class="loco-batch" title="<?php esc_html_e('Auto-translate this file','loco-translate');?>">
<form action="#">
<fieldset>
<select name="api" id="auto-api"><?php foreach( $js->apis as $api ):?>
<option value="<?php self::e($api['id'])?>"><?php self::e($api['name'])?></option><?php
endforeach?>
</select>
</fieldset>
<fieldset>
<p>
<label for="auto-existing">
<input type="checkbox" id="auto-existing" name="existing" />
<?php esc_html_e('Overwrite existing translations','loco-translate')?>
</label>
</p>
<p>
<label for="auto-fuzzy">
<input type="checkbox" id="auto-fuzzy" name="fuzzy" />
<?php esc_html_e('Mark new translations as Fuzzy','loco-translate')?>
</label>
</p>
<blockquote id="loco-job-progress">
Initializing...
</blockquote>
<p>
<button type="submit" class="button button-primary has-icon icon-translate">
<span><?php esc_html_e('Translate','loco-translate')?></span>
</button>
<a href="<?php self::e($help)?>" class="button button-link has-icon icon-help" target="_blank"><?php
esc_html_e('Help','loco-translate');
?></a>
</p>
</fieldset>
</form>
</div><?php
// inline modal for when no APIs are configured.
else:?>
<div id="loco-auto" class="loco-alert" title="<?php esc_html_e('No translation APIs configured','loco-translate');?>">
<p>
<?php esc_html_e('Add automatic translation services in the plugin settings.','loco-translate')?>
</p>
<nav>
<a href="<?php $this->route('config-apis')->e('href')?>" class="has-icon icon-cog"><?php
esc_html_e('Settings','loco-translate');
?></a>
<a href="<?php self::e($help)?>" class="has-icon icon-help" target="_blank"><?php
esc_html_e('Help','loco-translate');
?></a>
</nav>
</div><?php
endif;

View file

@ -0,0 +1,22 @@
<?php
/**
* POT file editor
*/
$this->extend('editor');
$this->start('header');
?>
<h3 class="has-lang">
<span><?php esc_html_e('Template file','loco-translate')?>:</span>
<span class="loco-meta">
<span><?php echo esc_html_x('Updated','Modified time','loco-translate')?>:</span>
<span id="loco-po-modified"><?php $params->date('modified')?></span>
&ndash;
<span id="loco-po-status"></span>
</span>
</h3>
<div id="loco-auto" title="Error">
<p>Template files cannot be translated</p>
</div>

View file

@ -0,0 +1,76 @@
<?php
/**
* Editor layout for PO and POT files
*/
$this->extend('../layout');
echo $header;
/* @var Loco_mvc_ViewParams $js */
/* @var Loco_mvc_ViewParams $ui */
/* @var Loco_mvc_ViewParams $params */
/* @var Loco_mvc_HiddenFields $dlFields */
?>
<div id="loco-editor">
<nav id="loco-toolbar" class="wp-core-ui">
<form action="#" id="loco-actions">
<fieldset>
<button class="button has-icon icon-save" data-loco="save" disabled>
<span><?php $ui->e('save')?></span>
</button>
<button class="button has-icon icon-revert" data-loco="revert" disabled>
<span><?php $ui->e('revert')?></span>
</button>
<button class="button has-icon icon-sync" data-loco="sync" disabled>
<span><?php $ui->e('sync')?></span>
</button>
</fieldset><?php
if( $locale ):?>
<fieldset>
<button class="button has-icon icon-robot" data-loco="auto" disabled>
<span><?php $ui->e('auto')?></span>
</button>
</fieldset><?php
else:?>
<fieldset>
<button class="button has-icon icon-add" data-loco="add" disabled>
<span><?php $ui->e('add')?></span>
</button>
<button class="button has-icon icon-del" data-loco="del" disabled>
<span><?php $ui->e('del')?></span>
</button>
</fieldset><?php
endif?>
<fieldset class="loco-clearable">
<input type="text" maxlength="100" name="q" id="loco-search" placeholder="<?php $ui->e('filter')?>" autocomplete="off" disabled />
</fieldset>
<fieldset>
<button class="button has-icon only-icon icon-pilcrow" data-loco="invs" disabled title="<?php $ui->e('invs')?>">
<span><?php $ui->e('invs')?></span>
</button>
<button class="button has-icon only-icon icon-code" data-loco="code" disabled title="<?php $ui->e('code')?>">
<span><?php $ui->e('code')?></span>
</button>
</fieldset>
</form>
<form action="<?php $params->e('dlAction')?>" method="post" target="_blank" id="loco-download" class="aux">
<fieldset>
<button class="button button-link has-icon icon-download" data-loco="source" disabled title="<?php $ui->e('download')?>">
<span><?php $params->e('filetype')?></span>
</button>
<button class="button button-link has-icon icon-download" data-loco="binary" disabled title="<?php $ui->e('download')?> MO">
<span>MO</span>
</button>
</fieldset>
<?php
$dlFields->_e();?>
</form>
</nav>
<div id="loco-editor-inner" class="jsonly">
<div class="loco-loading"></div>
</div>
</div>

View file

@ -0,0 +1,44 @@
<?php
/**
* File info for a binary MO where the PO file is missing
*/
$this->extend('info');
$this->start('header');
?>
<div class="notice inline notice-info">
<h3>
<a href="<?php $locale->e('href')?>">
<span class="<?php $locale->e('icon')?>" lang="<?php $locale->e('lang')?>"><code><?php $locale->e('code')?></code></span>
<span><?php $locale->e('name')?></span>
</a>
<span>&mdash; <?php esc_html_e('compiled','loco-translate')?></span>
</h3>
<dl>
<dt><?php self::e( __('File size','loco-translate') )?>:</dt>
<dd><?php $file->e('size')?></dd>
<dt><?php esc_html_e('File modified','loco-translate')?>:</dt>
<dd><?php $file->date('mtime')?></dd>
<dt><?php esc_html_e('Last translation','loco-translate')?>:</dt>
<dd><?php $params->e('author')?> &mdash; <date><?php $params->date('potime')?></date></dd>
<dt><?php esc_html_e('Compiled translations','loco-translate')?>:</dt>
<dd>
<?php echo esc_html( $meta->getTotalSummary() )?>
</dd>
</dl>
</div>
<?php
if( ! $sibling->existent ):?>
<div class="notice inline notice-warning">
<h3 class="has-icon">
<?php esc_html_e('PO file missing','loco-translate')?>
</h3>
<p>
<?php esc_html_e("We can't find the original PO file from which this was compiled",'loco-translate')?>.
</p>
</div><?php
endif;

View file

@ -0,0 +1,17 @@
<?php
/**
* File info for a file type we know nothing about
*/
$this->extend('info');
$this->start('header');
?>
<div class="notice inline notice-error">
<h3 class="has-icon">
<?php esc_html_e('Unexpected file type','loco-translate')?>
</h3>
<p>
<?php $params->e('error')?>
</p>
</div>

View file

@ -0,0 +1,86 @@
<?php
/**
* File info for a translation source PO
*/
$this->extend('info');
$this->start('header');
/* @var Loco_mvc_FileParams $file */
/* @var Loco_gettext_Metadata $meta */
?>
<div class="notice inline notice-info">
<h3>
<a href="<?php $locale->e('href')?>" class="has-lang">
<span class="<?php $locale->e('icon')?>" lang="<?php $locale->e('lang')?>"><code><?php $locale->e('code')?></code></span>
<span><?php $locale->e('name')?></span>
</a>
</h3>
<dl>
<dt><?php self::e( __('File size','loco-translate') )?>:</dt>
<dd><?php $file->e('size')?></dd>
<dt><?php self::e( __('File modified','loco-translate') )?>:</dt>
<dd><time><?php $file->date('mtime')?></time></dd>
<dt><?php self::e( __('Last translation','loco-translate') )?>:</dt>
<dd><?php $params->e('author')?> &mdash; <date><?php $params->date('potime')?></date></dd>
<dt><?php self::e( __('Translation progress','loco-translate') )?>:</dt>
<dd>
<?php self::e( $meta->getProgressSummary() )?>
</dd>
<dd>
<?php $meta->printProgress()?>
</dd>
</dl>
</div>
<?php
if( ! $sibling->existent ):?>
<div class="notice inline notice-warning">
<h3 class="has-icon">
<?php self::e( __('Binary file missing','loco-translate') )?>
</h3>
<p>
<?php self::e( __("We can't find the binary MO file that belongs with these translations",'loco-translate') )?>.
</p>
</div><?php
endif;
if( $params->has('potfile') ):
if( $potfile->synced ):?>
<div class="notice inline notice-success">
<h3 class="has-icon">
<?php self::e( __('In sync with template','loco-translate') )?>
</h3>
<p>
<?php // Translators: Where %s is the name of a template file
self::e( __('PO file has the same source strings as "%s"','loco-translate'), $potfile->name )?>.
</p>
</div><?php
else:?>
<div class="notice inline notice-info">
<h3 class="has-icon">
<?php self::e( __('Out of sync with template','loco-translate') )?>
</h3>
<p>
<?php // Translators: Where %s is the name of a template file
self::e( __('PO file has different source strings to "%s". Try running Sync before making any changes.','loco-translate'), $potfile->name )?>
</p>
</div><?php
endif;
// only showing missing template warning when project was matched. Avoids confusion if something went wrong
elseif( $params->has('project') ):?>
<div class="notice inline notice-debug">
<h3 class="has-icon">
<?php self::e( __('Missing template','loco-translate') )?>
</h3>
<p>
<?php
self::e( __('These translations are not linked to a POT file. Sync operations will extract strings directly from source code.','loco-translate') )?>
</p>
</div><?php
endif;

View file

@ -0,0 +1,39 @@
<?php
/**
* File info for a template file (POT)
*/
$this->extend('info');
$this->start('header');
/* @var Loco_mvc_FileParams $file */
/* @var Loco_gettext_Metadata $meta */
?>
<div class="notice inline notice-info">
<h3><?php esc_html_e('Template file','loco-translate')?></h3>
<dl>
<dt><?php self::e( __('File size','loco-translate') )?>:</dt>
<dd><?php $file->e('size')?></dd>
<dt><?php esc_html_e('File modified','loco-translate')?>:</dt>
<dd><time><?php $file->date('mtime')?></time></dd>
<dt><?php esc_html_e('Last extracted','loco-translate')?>:</dt>
<dd><time><?php $params->date('potime')?></time></dd>
<dt><?php echo esc_html_x('Source text','Editor','loco-translate')?>:</dt>
<dd><?php echo esc_html( $meta->getTotalSummary() )?> <span>(<?php echo sprintf( _n('1 word','%s words', $words, 'loco-translate'), number_format_i18n($words) )?>)</span></dd>
</dl>
</div>
<?php
if( 'POT' !== $file->type && ! $params->isTemplate ):?>
<div class="notice inline notice-debug">
<h3 class="has-icon">
Unconventional file name
</h3>
<p>
Template files should have the extension ".pot".<br />
If this is intended to be a translation file it should end with a language code.
</p>
</div><?php
endif;

View file

@ -0,0 +1,127 @@
<?php
/**
* File information for ony type of file. Extended by specific views for supported types
*/
$this->extend('../layout');
echo $header;
?>
<?php
if( ! $file->existent ):?>
<div class="notice inline notice-error">
<h3 class="has-icon">
<?php esc_html_e("File doesn't exist",'loco-translate')?>
</h3>
<p>
<code><?php $file->e('relpath')?></code>
</p>
</div><?php
elseif( $file->writable ):?>
<div class="notice inline notice-success">
<h3 class="has-icon">
<?php // Translators: Where %s is the type of file, e.g. "po"
self::e( __('%s file is writeable','loco-translate'), $file->type )?>
</h3>
<p>
<?php esc_html_e('You can update these translations directly from the editor to the file system','loco-translate')?>.
</p>
<p>
<code><?php $file->ls()?></code>
</p>
</div><?php
else:?>
<div class="notice inline notice-locked">
<h3 class="has-icon">
<?php esc_html_e('Write protected','loco-translate')?>
</h3>
<p>
<?php esc_html_e("This file can't be updated directly by the web server",'loco-translate')?>.
</p>
<p>
<?php // Translators: Where %s is the name (or number) of an operating system user
self::e( __("To make changes you'll have to connect to the remote file system, or make the file writeable by %s",'loco-translate'), $params->httpd )?>.
</p>
<p>
<code><?php $file->ls()?></code>
</p>
</div><?php
endif;
if( ! $dir->existent ):?>
<div class="notice inline notice-error">
<h3 class="has-icon">
<?php esc_html_e("Directory doesn't exist",'loco-translate')?>
</h3>
<p>
<?php // Translators: "either" meaning that the file itself can't exist without a containing directory
esc_html_e("The containing directory for this file doesn't exist either",'loco-translate')?>.
</p>
<p>
<code><?php $dir->e('relpath')?></code>
</p>
</div><?php
elseif( $dir->writable ):?>
<div class="notice inline notice-success">
<h3 class="has-icon">
<?php esc_html_e('Directory is writeable','loco-translate')?>
</h3>
<p>
<?php // Translators: Where %s is the name (or number) of an operating system user
self::e( __('The containing directory is writeable by %s, so you can add new files in the same location','loco-translate'), $params->httpd )?>.
</p>
<p>
<code><?php $dir->ls()?></code>
</p><?php
if( ! $file->deletable ):?>
<p>
<span class="has-icon icon-warn"></span>
<?php esc_html_e('Note that the file may not be deletable due to additional ownership permissions','loco-translate')?>.
</p><?php
endif;?>
</div><?php
else:?>
<div class="notice inline notice-locked">
<h3 class="has-icon">
<?php esc_html_e('Write protected','loco-translate')?>
</h3>
<p>
<?php esc_html_e("This directory can't be written to directly by the web server",'loco-translate')?>.
</p>
<p>
<?php // Translators: Where %s is the name (or number) of an operating system user
self::e( __("To create new files here you'll have to connect to the remote file system, or make the directory writeable by %s",'loco-translate'), $params->httpd )?>.
</p>
<p>
<code><?php $dir->ls()?></code>
</p>
</div><?php
endif;
if( $file->autoupdate ):?>
<div class="notice inline notice-info">
<h3 class="has-icon"><?php
esc_html_e('WordPress updates','loco-translate')?>
</h3>
<p><?php
esc_html_e("Files in this location can be modified or deleted by WordPress automatic updates",'loco-translate')?>.
<a target="_blank" href="<?php
echo esc_url( apply_filters('loco_external','https://localise.biz/wordpress/plugin/faqs/files-deleted') )?>"><?php
esc_html_e("What's this?",'loco-translate');
?></a>
</p>
</div><?php
endif;
if( $params->has('debug') ):?>
<div class="notice inline notice-debug">
<h3 class="has-icon">Developer notes</h3>
<div><?php
foreach( $debug as $prop => $raw ):?>
<p><?php $debug->e($prop)?></p><?php
endforeach?>
</div><?php
endif;

View file

@ -0,0 +1,43 @@
<?php
/**
* Confirmation form for moving localized files to a new location.
*/
$this->extend('move');
$this->start('source');
/* @var Loco_mvc_ViewParams $current */
/* @var Loco_mvc_ViewParams[] $locations */
?>
<div class="notice inline notice-generic">
<h2>
<?php self::e( __('Choose a new location for these translations','loco-translate') );?>
</h2>
<table class="form-table">
<tbody class="loco-paths"><?php
foreach( $locations as $typeId => $location ):?>
<tr class="compact">
<td>
<p class="description"><?php $location->e('label')?>:</p>
</td>
<td><?php
/* @var Loco_mvc_FileParams $choice */
foreach( $location['paths'] as $choice ):?>
<p><?php
if( $choice->active ):?>
<label>
<input type="radio" name="dest" value="" disabled checked /><?php
else:?>
<label>
<input type="radio" name="dest" value="<?php $choice->e('path')?>" /><?php
endif?>
<code class="path"><?php $choice->e('path')?></code>
</label>
</p><?php
endforeach?>
</td>
</tr><?php
endforeach?>
</tbody>
</table>
</div>

View file

@ -0,0 +1,19 @@
<?php
/**
* Confirmation form for moving file or group of files to an exact/custom location.
* Use for moving POT file, but also moving PO siblings when locale or text domain is unknown
*/
$this->extend('move');
$this->start('source');
/* @var Loco_mvc_FileParams $file */
/* @var Loco_mvc_ViewParams $current */
?>
<div class="notice inline notice-generic">
<h2>
<?php self::e( __('Enter a new location for this file','loco-translate') );?>
</h2>
<p>
<input type="text" name="dest" value="<?php $file->e('relpath')?>" class="large-text" />
</p>
</div>

View file

@ -0,0 +1,31 @@
<?php
/**
* Confirmation form for moving any file or group of file siblings.
*/
$this->extend('../layout');
?>
<form action="" method="post" enctype="application/x-www-form-urlencoded" id="loco-move"><?php
/* @var Loco_mvc_HiddenFields $hidden */
$hidden->_e();
echo $source?>
<div class="notice inline notice-info">
<h2>
<?php self::e( __('Confirm relocation','loco-translate') );?>
</h2>
<p>
<?php self::e(_n('The following file will be moved/renamed to the new location:','The following files will be moved/renamed to the new location:',count($files),'loco-translate'));
/* @var Loco_fs_File[] $files */
foreach( $files as $file ):
echo '<div>',$params->escape( $file->basename() ),'</div>';
endforeach?>
</p>
<p class="submit">
<button type="submit" class="button button-primary" disabled><?php esc_html_e('Move files','loco-translate')?></button><?php
if( $params->has('advanced') ):?>
<a href="<?php $params->e('advanced')?>" class="button button-link"><?php esc_html_e('Advanced','loco-translate')?></a><?php
endif?>
</p>
</div>
</form>

View file

@ -0,0 +1,55 @@
<?php
echo $this->render('../common/inc-table-filter');?>
<div class="panel loco-loading" id="loco-po">
<ol class="msgcat"><?php
foreach( $lines as $i => $line ):?>
<li id="po-l<?php printf('%u',$i+1)?>"><?php
// may be totally blank line
if( '' === $line ){
echo '<span class="po-none"></span>';
continue;
}
// may be a comment line
if( '#' === substr($line,0,1) ){
// may be able to parse out references
$symbol = (string) substr($line,1,1);
if( '' !== $symbol ){
$line = substr($line,2);
if( ':' === $symbol ){
echo '<span class="po-refs">#:',preg_replace('/\\S+:\d+/', '<a href="#\\0" class="po-text">\\0</a>', $params->escape($line) ),'</span>';
}
// parse out flags and formatting directives
else if( ',' === $symbol ){
echo '<span class="po-flags">#,<span class="po-text">',preg_replace('/[-a-z]+/', '<em>\\0</em>', $params->escape($line) ),'</span></span>';
}
// else treat as normal comment even if empty
else {
echo '<span class="po-comment">#',$symbol,'<span class="po-text">',$params->escape($line),'</span></span>';
}
}
// else probably an empty comment
else {
echo '<span class="po-comment">',$params->escape($line),'</span>';
}
continue;
}
// grab keyword if there is one before quoted string
if( preg_match('/^(msg[_a-z0-9\\[\\]]+)(\\s+)/', $line, $r ) ){
echo '<span class="po-word">',$params->escape($r[1]),'</span><span class="po-space">',$params->escape($r[2]),'</span>';
$line = substr( $line, strlen($r[0]) );
}
// remainder of line (or whole line) should be a quoted string
if( preg_match('/^"(.*)"\s*$/', $line, $r ) ){
echo '<span class="po-string">&quot;<span class="po-text">',$params->escape($r[1]),'</span>&quot;</span>';
continue;
}
// else print whatever junk is left of line
echo '<span class="po-junk">',$params->escape($line),'</span>';
?></li><?php
endforeach?>
</ol>
</div>

View file

@ -0,0 +1,62 @@
<?php
/**
* Binary MO hex view
*/
$this->extend('view');
$this->start('source');
?>
<div class="notice inline notice-info">
<p>
<?php esc_html_e('File is in binary MO format','loco-translate')?>.
</p>
</div>
<div class="panel">
<pre><?php
// crude hex dump
// TODO make dynamic - flowing to width + clicking bytes highlights right-hand character ranges
$i = 0;
$r = 0;
$cols = 24;
$line = array();
$bytes = strlen($bin);
// establish formatting of row offset, nbased on largest row number
$rowfmt = sprintf( '%%0%uX | ', strlen( sprintf( '%02X', $cols * floor( $bytes / $cols ) ) ) );
for( $b = 0; $b < $bytes; $b++ ){
$c = substr($bin,$b,1);
$n = ord($c);
// print byte offset
if( ! $line ){
printf( $rowfmt, $b );
}
// print actual byte
printf('%02X ', $n );
// add printable to line
if( $n === 9 ){
$line[] = ' '; // <- tab?
}
else if ( $n < 32 || $n > 126 ) {
$line[] = '.'; // <- unprintable
}
else {
$line[] = $params->escape($c); // <- printable
}
// wrap at cols, and print plain text
if( ++$i === $cols ){
echo ' ', implode('', $line ), "\n";
$line = array();
$i = 0;
$r++;
}
}
if( $line ){
if( $r ){
echo str_repeat( ' ', $cols - $i );
}
echo ' ', implode('', $line ), "\n";
}
?></pre>
</div>

View file

@ -0,0 +1,9 @@
<?php
/**
* PO source view
*/
$this->extend('view');
$this->start('source');
echo $this->render('../common/inc-po-header');
echo $this->render('msgcat');

View file

@ -0,0 +1,19 @@
<?php
/**
* POT source view
*/
$this->extend('view');
$this->start('source');
?>
<h3 class="has-lang">
<span><?php esc_html_e('Template file','loco-translate')?>:</span>
<span class="loco-meta">
<span><?php echo esc_html_x('Updated','Modified time','loco-translate')?>:</span>
<span id="loco-po-modified"><?php $params->date('modified')?></span>
&ndash;
<span id="loco-po-status"><?php echo esc_html( $meta->getTotalSummary() )?></span>
</span>
</h3>
<?php
echo $this->render('msgcat');

View file

@ -0,0 +1,6 @@
<?php
/**
* Source view - displays file in raw form if possible
*/
$this->extend('../layout');
echo $source;