/**
     * Output the Project Editor interface.
     *
     * @since 1.2.0 Added comments/reference display/editing,
     *              Added Original link on PME edited versions.
     * @since 1.1.0 Updated add buttons to be advanced-mode-only,
     *              improved printf calls for localization purposes.
     * @since 1.0.0
     *
     * @global string $plugin_page The slug of the current admin page.
     */
    protected static function project_editor()
    {
        global $plugin_page;
        $file = $_REQUEST['pofile'];
        // Load
        $path = realpath(WP_CONTENT_DIR . '/' . $file);
        $project = new Project($path);
        $project->load();
        // Figure out the text direction for the translated text
        $direction = in_array(substr($project->language(true), 0, 2), Dictionary::$rtl_languages) ? 'rtl' : 'ltr';
        ?>
		<form method="post" action="tools.php?page=<?php 
        echo $plugin_page;
        ?>
" id="pomoeditor">
			<input type="hidden" name="pofile" value="<?php 
        echo $file;
        ?>
" />
			<?php 
        wp_nonce_field('pomoeditor-manage-' . md5($file), '_pomoeditor_nonce');
        ?>

			<h2><?php 
        /* Translators: %1$s = filename */
        printf(__('Editing: <code>%s</code>', 'pomo-editor'), $file);
        ?>
</h2>

			<?php 
        if ($project->is_modded()) {
            $original = $project->file();
            ?>
				<p><?php 
            /* Translators: %1$s = filename, %2$s = URL */
            printf(__('Original: <a href="%2$s" target="_blank">%1$s</a>', 'pomo-editor'), $original, admin_url("tools.php?page=pomo-editor&pofile={$original}&changes-saved=true"));
            ?>
</p>
			<?php 
        }
        ?>

			<p>
				<?php 
        /* Translators: %1$s = package name, %2$s = package type (system, theme, plugin) */
        printf(__('<strong>Package:</strong> %1$s (%2$s)', 'pomo-editor'), $project->package('name'), $project->package('type'));
        ?>
				<br />
				<?php 
        /* Translators: %1$s = language name */
        printf(__('<strong>Language:</strong> %1$s', 'pomo-editor'), $project->language());
        ?>
			</p>

			<p>
				<button type="button" id="pomoeditor_advanced" class="button button-secondary"><?php 
        _e('Enable Advanced Editing', 'pomo-editor');
        ?>
</button>
			</p>

			<h3><?php 
        _e('Translations', 'pomo-editor');
        ?>
</h3>

			<table id="pomoeditor_translations" class="fixed striped widefat pme-direction-<?php 
        echo $direction;
        ?>
">
				<thead>
					<tr>
						<th class="pme-edit-col">
							<button type="button" title="<?php 
        _e('Add Translation Entry', 'pomo-editor');
        ?>
" class="pme-button pme-add pomoeditor-advanced"><?php 
        _e('Add Entry', 'pomo-editor');
        ?>
</button>
						</th>
						<th class="pme-source"><?php 
        _e('Source Text', 'pomo-editor');
        ?>
</th>
						<th class="pme-translation"><?php 
        _e('Translated Text', 'pomo-editor');
        ?>
</th>
						<th class="pme-context"><?php 
        _e('Context', 'pomo-editor');
        ?>
</th>
					</tr>
				</thead>
				<tfoot></tfoot>
				<tbody></tbody>
			</table>

			<div class="pomoeditor-advanced">
				<h3><?php 
        _e('Headers', 'pomo-editor');
        ?>
</h3>

				<table id="pomoeditor_headers" class="fixed striped widefat">
					<thead>
						<tr>
							<th class="pme-edit-col">
								<button type="button" title="<?php 
        _e('Add Translation Entry', 'pomo-editor');
        ?>
" class="pme-button pme-add"><?php 
        _e('Add Translation Entry', 'pomo-editor');
        ?>
</button>
							</th>
							<th class="pme-header-name"><?php 
        _ex('Name', 'header name', 'pomo-editor');
        ?>
</th>
							<th class="pme-header-value"><?php 
        _ex('Value', 'header value', 'pomo-editor');
        ?>
</th>
						</tr>
					</thead>
					<tfoot></tfoot>
					<tbody></tbody>
				</table>

				<h3><?php 
        _e('Metadata', 'pomo-editor');
        ?>
</h3>

				<table id="pomoeditor_metadata" class="fixed striped widefat">
					<thead>
						<tr>
							<th class="pme-edit-col">&nbsp;</th>
							<th class="pme-header-name"><?php 
        _ex('Name', 'header name', 'pomo-editor');
        ?>
</th>
							<th class="pme-header-value"><?php 
        _ex('Value', 'header value', 'pomo-editor');
        ?>
</th>
						</tr>
					</thead>
					<tfoot></tfoot>
					<tbody></tbody>
				</table>
			</div>

			<p class="submit">
				<button type="submit" id="submit" class="button button-primary"><?php 
        _e('Save Translations', 'pomo-editor');
        ?>
</button>
			</p>

			<script type="text/template" id="pomoeditor_record_template">
				<th class="pme-edit-col">
					<button type="button" title="Delete Record" class="pme-button pme-delete"><?php 
        _e('Delete', 'pomo-editor');
        ?>
</button>
				</th>
				<td class="pme-record-name">
					<input type="text" class="pme-input pme-name-input" value="<%- name %>" />
				</td>
				<td class="pme-record-value">
					<input type="text" class="pme-input pme-value-input" value="<%- value %>" />
				</td>
			</script>

			<script type="text/template" id="pomoeditor_translation_template">
				<td class="pme-edit-col">
					<button type="button" title="Edit Entry" class="pme-button pme-edit"><?php 
        _e('Edit', 'pomo-editor');
        ?>
</button>
					<div class="pme-actions">
						<button type="button" title="Cancel (discard changes)" class="pme-button pme-cancel"><?php 
        _e('Cancel', 'pomo-editor');
        ?>
</button>
						<button type="button" title="Save Changes" class="pme-button pme-save"><?php 
        _e('Save', 'pomo-editor');
        ?>
</button>
						<button type="button" title="Delete Entry" class="pme-button pme-delete"><?php 
        _e('Delete', 'pomo-editor');
        ?>
</button>
					</div>
				</td>
				<td class="pme-source">
					<div class="pme-previews">
						<div class="pme-preview pme-singular" title="<?php 
        _e('Singular', 'pomo-editor');
        ?>
"></div>
						<div class="pme-preview pme-plural" title="<?php 
        _e('Plural', 'pomo-editor');
        ?>
"></div>
					</div>
					<div class="pme-inputs">
						<textarea class="pme-input pme-singular" title="<?php 
        _e('Singular', 'pomo-editor');
        ?>
" rows="4" readonly></textarea>
						<textarea class="pme-input pme-plural" title="<?php 
        _e('Plural', 'pomo-editor');
        ?>
" rows="4" readonly></textarea>
					</div>
					<div class="pme-comments pme-extracted-comments">
						<div class="pme-preview pomoeditor-basic"></div>
						<textarea class="pme-input pomoeditor-advanced" title="<?php 
        _e('Developer Comments', 'pomo-editor');
        ?>
" rows="4" readonly></textarea>
					</div>
				</td>
				<td class="pme-translated">
					<div class="pme-previews">
						<div class="pme-preview pme-singular" title="<?php 
        _e('Singular', 'pomo-editor');
        ?>
"></div>
						<div class="pme-preview pme-plural" title="<?php 
        _e('Plural', 'pomo-editor');
        ?>
"></div>
					</div>
					<div class="pme-inputs">
						<textarea class="pme-input pme-singular" title="<?php 
        _e('Singular', 'pomo-editor');
        ?>
" rows="4"></textarea>
						<textarea class="pme-input pme-plural" title="<?php 
        _e('Plural', 'pomo-editor');
        ?>
" rows="4"></textarea>
					</div>
					<div class="pme-comments pme-translator-comments">
						<textarea class="pme-input" title="<?php 
        _e('Translator Comments', 'pomo-editor');
        ?>
" rows="4"></textarea>
					</div>
				</td>
				<td class="pme-context">
					<div class="pme-previews">
						<div class="pme-preview"></div>
					</div>
					<div class="pme-inputs">
						<textarea class="pme-input" rows="4" readonly></textarea>
					</div>
					<div class="pme-comments pme-references">
						<ul class="pme-preview pomoeditor-basic"></ul>
						<textarea class="pme-input pomoeditor-advanced" title="<?php 
        _e('Code References', 'pomo-editor');
        ?>
" rows="4" readonly></textarea>
					</div>
				</td>
			</script>

			<script>
			POMOEditor.Project = new POMOEditor.Framework.Project(<?php 
        echo json_encode($project->dump());
        ?>
);

			POMOEditor.HeadersEditor = new POMOEditor.Framework.RecordsEditor( {
				el: document.getElementById( 'pomoeditor_headers' ),

				collection: POMOEditor.Project.Headers,

				rowTemplate: document.getElementById( 'pomoeditor_record_template' ),
			} );

			POMOEditor.MetadataEditor = new POMOEditor.Framework.RecordsEditor( {
				el: document.getElementById( 'pomoeditor_metadata' ),

				collection: POMOEditor.Project.Metadata,

				rowTemplate: document.getElementById( 'pomoeditor_record_template' ),
			} );

			POMOEditor.TranslationsEditor = new POMOEditor.Framework.TranslationsEditor( {
				el: document.getElementById( 'pomoeditor_translations' ),

				collection: POMOEditor.Project.Translations,

				rowTemplate: document.getElementById( 'pomoeditor_translation_template' ),
			} );
			</script>
		</form>
		<?php 
    }