1
0
mirror of https://github.com/monstra-cms/monstra.git synced 2025-08-09 06:37:01 +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,60 @@
<?php
class BackupAdmin extends Backend {
/**
* Backup admin
*/
public static function main() {
$backups_path = ROOT . DS . 'backups';
$backups_list = array();
// Create backup
// -------------------------------------
if (Request::post('create_backup')) {
@set_time_limit(0);
@ini_set("memory_limit", "512M");
$zip = Zip::factory();
// Add storage folder
$zip->readDir(STORAGE . DS, false);
// Add public folder
if (Request::post('add_public_folder')) $zip->readDir(ROOT . DS . 'public' . DS, false);
// Add plugins folder
if (Request::post('add_plugins_folder')) $zip->readDir(PLUGINS . DS, false);
$zip->archive($backups_path . DS . Date::format(time(), "Y-m-d-H-i-s").'.zip');
}
// Delete backup
// -------------------------------------
if (Request::get('sub_id') == 'backup') {
if (Request::get('delete_file')) {
File::delete($backups_path . DS . Request::get('delete_file'));
Request::redirect(Option::get('siteurl').'admin/index.php?id=backup');
}
}
// Download backup
// -------------------------------------
if (Request::get('download')) {
File::download('../backups/'.Request::get('download'));
}
// Get backup list
$backups_list = File::scan($backups_path, '.zip');
// Display view
View::factory('box/backup/views/backend/index')
->assign('backups_list', $backups_list)
->display();
}
}

View File

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

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<plugin_location>plugins/box/backup/backup.plugin.php</plugin_location>
<plugin_status>active</plugin_status>
<plugin_priority>8</plugin_priority>
<plugin_name>Backup</plugin_name>
<plugin_description>Backup plugin</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(
'backup' => array(
'Backups' => 'Backups',
'Backup date' => 'Backup date',
'Create backup' => 'Create backup',
'Delete' => 'Delete',
'storage' => 'storage',
'public' => 'public',
'plugins' => 'plugins',
'Size' => 'Size',
'Actions' => 'Actions',
'Delete backup: :backup' => 'Delete backup: :backup',
'Creating...' => 'Creating...',
)
);

View File

@@ -0,0 +1,17 @@
<?php
return array(
'backup' => array(
'Backups' => 'Бекапы',
'Backup date' => 'Бекап',
'Create backup' => 'Сделать бекап',
'Delete' => 'Удалить',
'storage' => 'данные',
'public' => 'публичная',
'plugins' => 'плагины',
'Size' => 'Размер',
'Actions' => 'Действия',
'Delete backup: :backup' => 'Удалить бекап: :backup',
'Creating...' => 'Создание...',
)
);

View File

@@ -0,0 +1,48 @@
<h2><?php echo __('Backups', 'backup'); ?></h2>
<br />
<?php if (Notification::get('success')) Alert::success(Notification::get('success')); ?>
<script>
$().ready(function(){$('[name=create_backup]').click(function(){$(this).button('loading');});});
</script>
<?php
echo (
Form::open() .
Form::checkbox('add_storage_folder', null, true, array('disabled' => 'disabled')) . ' ' . __('storage', 'backup') . ' ' . Html::nbsp(2) .
Form::checkbox('add_public_folder') . ' ' . __('public', 'backup') . ' ' . Html::nbsp(2) .
Form::checkbox('add_plugins_folder') . ' ' . __('plugins', 'backup') . ' ' . Html::nbsp(2) .
Form::submit('create_backup', __('Create backup', 'backup'), array('class' => 'btn default btn-small', 'data-loading-text' => __('Creating...', 'backup'))).
Form::close()
);
?>
<!-- Backup_list -->
<table class="table table-bordered">
<thead>
<tr>
<td><?php echo __('Backup date', 'backup'); ?></td>
<td><?php echo __('Size', 'backup'); ?></td>
<td width="30%"><?php echo __('Actions', 'backup'); ?></td>
</tr>
</thead>
<tbody>
<?php if (count($backups_list) > 0) rsort($backups_list); foreach ($backups_list as $backup) { ?>
<tr>
<td>
<?php $name = strtotime(str_replace('-', '', basename($backup, '.zip'))); ?>
<?php echo Html::anchor(Date::format($name, 'F jS, Y - g:i A'), Option::get('siteurl').'admin/index.php?id=backup&download='.$backup); ?>
</td>
<td><?php echo Number::byteFormat(filesize(ROOT . DS . 'backups' . DS . $backup)); ?></td>
<td>
<?php echo Html::anchor(__('Delete', 'backup'),
'index.php?id=system&sub_id=backup&delete_file='.$backup,
array('class' => 'btn btn-actions', 'onclick' => "return confirmDelete('".__('Delete backup: :backup', 'backup', array(':backup' => Date::format($name, 'F jS, Y - g:i A')))."')"));
?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<!-- /Backup_list -->