1
0
mirror of https://github.com/monstra-cms/monstra.git synced 2025-07-31 02:10:37 +02:00

Add Monstra from HG Commit 683dcb70c4cc

This commit is contained in:
Awilum
2012-09-25 19:09:50 +03:00
parent d2db42b2bb
commit 4a5fea5f5b
251 changed files with 35026 additions and 0 deletions

View File

@@ -0,0 +1,146 @@
<?php
Navigation::add(__('Files', 'filesmanager'), 'content', 'filesmanager', 2);
class FilesmanagerAdmin extends Backend {
/**
* Main function
*/
public static function main() {
// Array of forbidden types
$forbidden_types = array('php', 'htaccess', 'html', 'htm', 'empty');
// Array of image types
$image_types = array('jpg', 'png', 'bmp', 'gif', 'tif');
// Get Site url
$site_url = Option::get('siteurl');
// Init vars
if (Request::get('path')) $path = Request::get('path'); else $path = 'uploads/';
// Add slash if not exists
if (substr($path, -1, 1) != '/') {
$path .= '/';
Request::redirect($site_url.'admin/index.php?id=filesmanager&path='.$path);
}
// Upload corectly!
if ($path == 'uploads' || $path == 'uploads//') {
$path = 'uploads/';
Request::redirect($site_url.'admin/index.php?id=filesmanager&path='.$path);
}
// Only 'uploads' folder!
if (strpos($path, 'uploads') === false) {
$path = 'uploads/';
Request::redirect($site_url.'admin/index.php?id=filesmanager&path='.$path);
}
// Set default path value if path is empty
if ($path == '') {
$path = 'uploads/';
Request::redirect($site_url.'admin/index.php?id=filesmanager&path='.$path);
}
$files_path = ROOT . DS . 'public' . DS . $path;
$files_list = array();
$current = explode('/', $path);
// Get information about current path
$_list = FilesmanagerAdmin::fdir($files_path);
$files_list = array();
// Get files
if (isset($_list['files'])) {
foreach ($_list['files'] as $files) {
$files_list[] = $files;
}
}
$dir_list = array();
// Get dirs
if (isset($_list['dirs'])) {
foreach ($_list['dirs'] as $dirs) {
if (strpos($dirs, '.') === false) $dir_list[] = $dirs;
}
}
// Delete file
// -------------------------------------
if (Request::get('id') == 'filesmanager') {
if (Request::get('delete_file')) {
File::delete($files_path.Request::get('delete_file'));
Request::redirect($site_url.'admin/index.php?id=filesmanager&path='.$path);
}
}
// Delete dir
// -------------------------------------
if (Request::get('id') == 'filesmanager') {
if (Request::get('delete_dir')) {
Dir::delete($files_path.Request::get('delete_dir'));
Request::redirect($site_url.'admin/index.php?id=filesmanager&path='.$path);
}
}
// Upload file
// -------------------------------------
if (Request::post('upload_file')) {
if ($_FILES['file']) {
if ( ! in_array(File::ext($_FILES['file']['name']), $forbidden_types)) {
move_uploaded_file($_FILES['file']['tmp_name'], $files_path.Security::safeName(basename($_FILES['file']['name'], File::ext($_FILES['file']['name'])), '-', true).'.'.File::ext($_FILES['file']['name']));
Request::redirect($site_url.'admin/index.php?id=filesmanager&path='.$path);
}
}
}
// Display view
View::factory('box/filesmanager/views/backend/index')
->assign('path', $path)
->assign('current', $current)
->assign('files_list', $files_list)
->assign('dir_list', $dir_list)
->assign('forbidden_types', $forbidden_types)
->assign('image_types', $image_types)
->assign('site_url', $site_url)
->assign('files_path', $files_path)
->display();
}
/**
* Get directories and files in current path
*/
protected static function fdir($dir, $type = null) {
$files = array();
$c = 0;
$_dir = $dir;
if (is_dir($dir)) {
$dir = opendir ($dir);
while (false !== ($file = readdir($dir))) {
if (($file !=".") && ($file !="..")) {
$c++;
if (is_dir($_dir.$file)) {
$files['dirs'][$c] = $file;
} else {
$files['files'][$c] = $file;
}
}
}
closedir($dir);
return $files;
} else {
return false;
}
}
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Files manager plugin
*
* @package Monstra
* @subpackage Plugins
* @author Romanenko Sergey / Awilum
* @copyright 2012 Romanenko Sergey / Awilum
* @version 1.0.0
*
*/
// Register plugin
Plugin::register( __FILE__,
__('Files manager', 'filesmanager'),
__('Files manager', 'filesmanager'),
'1.0.0',
'Awilum',
'http://monstra.org/',
null,
'box');
if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin', 'editor'))) {
// Include Admin
Plugin::admin('filesmanager', 'box');
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<plugin_location>plugins/box/filesmanager/filesmanager.plugin.php</plugin_location>
<plugin_status>active</plugin_status>
<plugin_priority>2</plugin_priority>
<plugin_name>FilesManager</plugin_name>
<plugin_description>Simple file manger for Monstra</plugin_description>
<plugin_version>1.0.0</plugin_version>
<plugin_author>Awilum</plugin_author>
<plugin_author_uri>http://monstra.org/</plugin_author_uri>
</root>

View File

@@ -0,0 +1,17 @@
<?php
return array(
'filesmanager' => array(
'Files' => 'Files',
'Files manager' => 'Files manager',
'Name' => 'Name',
'Actions' => 'Actions',
'Delete' => 'Delete',
'Upload' => 'Upload',
'directory' => 'directory',
'Delete directory: :dir' => 'Delete directory: :dir',
'Delete file: :file' => 'Delete file :file',
'Extension' => 'Extension',
'Size' => 'Size',
)
);

View File

@@ -0,0 +1,17 @@
<?php
return array(
'filesmanager' => array(
'Files' => 'Файлы',
'Files manager' => 'Менеджер файлов',
'Name' => 'Название',
'Actions' => 'Действия',
'Delete' => 'Удалить',
'Upload' => 'Загрузить',
'directory' => 'директория',
'Delete directory: :dir' => 'Удалить директорию: :dir',
'Delete file: :file' => 'Удалить файл :file',
'Extension' => 'Расширение',
'Size' => 'Размер',
)
);

View File

@@ -0,0 +1,80 @@
<h2><?php echo __('Files', 'filesmanager'); ?></h2>
<br />
<!-- Filesmanager_upload_files -->
<?php
echo (
Form::open(null, array('enctype' => 'multipart/form-data')).
Form::input('file', null, array('type' => 'file', 'size' => '25')).Html::br().
Form::submit('upload_file', __('Upload', 'filesmanager'), array('class' => 'btn default btn-small')).
Form::close()
)
?>
<!-- /Filesmanager_upload_files -->
<!-- Filesmanger_path -->
<ul class="breadcrumb">
<?php
$path_parts = explode ('/',$path);
$s = '';
foreach ($path_parts as $p) {
$s .= $p.'/';
if($p == $current[count($current)-2]) $active = ' class="active"'; else $active = '';
echo '<span class="divider">/<span> <li'.$active.'><a href="index.php?id=filesmanager&path='.$s.'">'.$p.'</a></li>';
}
?>
</ul>
<!-- /Filesmanger_path -->
<table class="table table-bordered">
<thead>
<tr>
<td><?php echo __('Name', 'filesmanager'); ?></td>
<td><?php echo __('Extension', 'filesmanager'); ?></td>
<td><?php echo __('Size', 'filesmanager'); ?></td>
<td width="30%"><?php echo __('Actions', 'filesmanager'); ?></td>
</tr>
</thead>
<tbody>
<?php if (isset($dir_list)) foreach ($dir_list as $dir) { ?>
<tr>
<td>
<b><?php echo Html::anchor($dir, 'index.php?id=filesmanager&path='.$path.$dir.'/'); ?></b>
</td>
<td>
</td>
<td>
<?php echo Number::byteFormat(Dir::size(UPLOADS . DS . $dir)); ?>
</td>
<td>
<?php echo Html::anchor(__('Delete', 'filesmanager'),
'index.php?id=filesmanager&delete_dir='.$dir.'&path='.$path,
array('class' => 'btn', 'onclick' => "return confirmDelete('".__('Delete directory: :dir', 'filesmanager', array(':dir' => $dir))."')"));
?>
</td>
</tr>
<?php } ?>
<?php if (isset($files_list)) foreach ($files_list as $file) { $ext = File::ext($file); ?>
<?php if ( ! in_array($ext, $forbidden_types)) { ?>
<tr>
<td>
<?php echo Html::anchor(File::name($file), $site_url.'public' . DS .$path.$file, array('target'=>'_blank'));?>
</td>
<td>
<?php echo $ext; ?>
</td>
<td>
<?php echo Number::byteFormat(filesize($files_path. DS .$file)); ?>
</td>
<td>
<?php echo Html::anchor(__('Delete', 'filesmanager'),
'index.php?id=filesmanager&delete_file='.$file.'&path='.$path,
array('class' => 'btn btn-actions', 'onclick' => "return confirmDelete('".__('Delete file: :file', 'filesmanager', array(':file' => $file))."')"));
?>
</td>
</tr>
<?php } } ?>
</tbody>
</table>