codiad/components/filemanager/dialog.php

200 lines
6.7 KiB
PHP
Executable File

<?php
/*
* Copyright (c) Codiad & Kent Safranski (codiad.com), distributed
* as-is and without warranty under the MIT License. See
* [root]/license.txt for more. This information must remain intact.
*/
require_once('../../common.php');
require_once('class.filemanager.php');
//////////////////////////////////////////////////////////////////
// Verify Session or Key
//////////////////////////////////////////////////////////////////
checkSession();
?><form><?php
switch( $_GET['action'] ) {
//////////////////////////////////////////////////////////////////
// Create
//////////////////////////////////////////////////////////////////
case 'create':
?>
<input type="hidden" name="path" value="<?php echo($_GET['path']); ?>">
<input type="hidden" name="type" value="<?php echo($_GET['type']); ?>">
<label><span class="icon-pencil"></span><?php echo i18n((ucfirst($_GET['type']))); ?></label>
<input type="text" name="object_name" autofocus="autofocus" autocomplete="off">
<button class="btn-left"><?php i18n("Create"); ?></button>
<button class="btn-right" onclick="codiad.modal.unload(); return false;"><?php i18n("Cancel"); ?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// Rename
//////////////////////////////////////////////////////////////////
case 'rename':
?>
<input type="hidden" name="path" value="<?php echo($_GET['path']); ?>">
<input type="hidden" name="type" value="<?php echo($_GET['type']); ?>">
<label><span class="icon-pencil"></span> <?php i18n("Rename"); ?> <?php echo i18n((ucfirst($_GET['type']))); ?></label>
<input type="text" name="object_name" autofocus="autofocus" autocomplete="off" value="<?php echo($_GET['short_name']); ?>">
<button class="btn-left"><?php i18n("Rename"); ?></button>
<button class="btn-right" onclick="codiad.modal.unload(); return false;"><?php i18n("Cancel"); ?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// Delete
//////////////////////////////////////////////////////////////////
case 'delete':
?>
<input type="hidden" name="path" value="<?php echo($_GET['path']); ?>">
<label><?php i18n("Are you sure you wish to delete the following:"); ?></label>
<pre><?php if(!FileManager::isAbsPath($_GET['path'])) { echo '/'; }; echo($_GET['path']); ?></pre>
<button class="btn-left"><?php i18n("Delete"); ?></button>
<button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Cancel"); ?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// Delete
//////////////////////////////////////////////////////////////////
case 'deleteInner':
?>
<input type="hidden" name="path" value="<?php echo($_GET['path']); ?>">
<label><?php i18n("Are you sure you wish to delete the contents of the following path:"); ?></label>
<pre><?php if(!FileManager::isAbsPath($_GET['path'])) { echo '/'; }; echo($_GET['path']); ?></pre>
<button class="btn-left"><?php i18n("Delete"); ?></button>
<button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Cancel"); ?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// Preview
//////////////////////////////////////////////////////////////////
case 'preview':
?>
<label><?php i18n("Inline Preview"); ?></label>
<div>
<?php
$path = $_GET['path'];
if( FileManager::isAbsPath( $path ) ) {
$path = FileManager::cleanPath( $path );
} else {
$path = WORKSPACE . "/" . FileManager::cleanPath( $path );
}
$type = mime_content_type( $path );
$source = str_replace( BASE_PATH . "/", "", $path );
if( strpos( $type, "audio" ) !== false ) {
?><audio controls><source src="<?php echo $source;?>"></audio><?php
} elseif( strpos( $type, "image" ) !== false ) {
?><img src="<?php echo $source;?>"><?php
} else {
?><p>Error, unknown file type.</p><?php
}
?>
</div>
<button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Close");?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// replace
//////////////////////////////////////////////////////////////////
case 'replace':
?>
<input type="hidden" name="path" value="<?php echo($_GET['path']); ?>">
<label><?php i18n("Would you like to replace or duplicate the following:"); ?></label>
<pre>
<?php
if( ! FileManager::isAbsPath( $_GET['path'] ) ) {
echo '/';
};
echo( $_GET['path'] );
?>
</pre>
<select name="or_action">
<option value="0"><?php i18n("Overwrite Original"); ?></option>
<option value="1"><?php i18n("Create Duplicate"); ?></option>
</select>
<button class="btn-left"><?php i18n("Continue"); ?></button>
<button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Cancel"); ?></button>
<?php
break;
//////////////////////////////////////////////////////////////////
// Search
//////////////////////////////////////////////////////////////////
case 'search':
?>
<input type="hidden" name="path" value="<?php echo($_GET['path']); ?>">
<table class="file-search-table">
<tr>
<td width="65%">
<label><?php i18n("Search Files:"); ?></label>
<input type="text" name="search_string" autofocus="autofocus">
</td>
<td width="5%">&nbsp;&nbsp;</td>
<td>
<label><?php i18n("In:"); ?></label>
<select name="search_type">
<option value="0"><?php i18n("Current Project"); ?></option>
<?php
if( checkAccess() ) {
?><option value="1"><?php i18n("Workspace Projects"); ?></option><?php
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="3">
<label><?php i18n("File Type:"); ?></label>
<input type="text" name="search_file_type" placeholder="<?php i18n("space seperated file types eg: js c php"); ?>">
</td>
</tr>
</table>
<pre id="filemanager-search-results"></pre>
<div id="filemanager-search-processing"></div>
<button class="btn-left"><?php i18n("Search"); ?></button>
<button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Cancel"); ?></button>
<?php
break;
case 'selector':
?>
<div>
<div id="modal-loading" style="display: inline-block;vertical-align: middle;min-width:25px;"></div>
<div style="display: inline-block;vertical-align: middle;">Loading File Selector ...</div>
</div>
<?php
break;
case 'upload':
?>
<div>
<div id="modal-loading" style="display: inline-block;vertical-align: middle;min-width:25px;"></div>
<div style="display: inline-block;vertical-align: middle;">Loading Uploader ...</div>
</div>
<?php
break;
}
?></form>