Add option to delete sources with support in all three backends
This commit is contained in:
@@ -169,6 +169,21 @@ class RippingCluster_Main {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function rmdir_recursive($dir) {
|
||||
if (is_dir($dir)) {
|
||||
$objects = scandir($dir);
|
||||
foreach ($objects as $object) {
|
||||
if ($object != "." && $object != "..") {
|
||||
if (filetype($dir."/".$object) == "dir") self::rmdir_recursive($dir."/".$object); else unlink($dir."/".$object);
|
||||
}
|
||||
}
|
||||
reset($objects);
|
||||
rmdir($dir);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function issetelse($var, $default = null) {
|
||||
if (isset($var)) {
|
||||
return $var;
|
||||
|
||||
@@ -105,6 +105,14 @@ class RippingCluster_Source {
|
||||
return $longest_index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permanently deletes this source from disk
|
||||
*
|
||||
*/
|
||||
public function delete() {
|
||||
RippingCluster_Source_PluginFactory::delete($this->plugin, $this->filename);
|
||||
}
|
||||
|
||||
public function filename() {
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
@@ -41,13 +41,21 @@ interface RippingCluster_Source_IPlugin extends RippingCluster_IPlugin {
|
||||
public static function loadEncoded($encoded_filename, $scan = true, $use_cache = true);
|
||||
|
||||
/**
|
||||
* Determins if a filename is a valid source loadable using this plugin
|
||||
* Determines if a filename is a valid source loadable using this plugin
|
||||
*
|
||||
* @param string $source_filename Filename of the source
|
||||
* @return bool
|
||||
*/
|
||||
public static function isValidSource($source_filename);
|
||||
|
||||
/**
|
||||
* Permanently deletes the given source from disk
|
||||
*
|
||||
* @param RippingCluster_Source $source Source object to be deleted
|
||||
* @return bool
|
||||
*/
|
||||
public static function delete($source_filename);
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -117,6 +117,20 @@ class RippingCluster_Source_Plugin_Bluray extends RippingCluster_PluginBase impl
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permanently deletes the given source from disk
|
||||
*
|
||||
* @param RippingCluster_Source $source Source object to be deleted
|
||||
* @return bool
|
||||
*/
|
||||
public static function delete($source_filename) {
|
||||
if ( ! self::isValidSource($source_filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return RippingCluster_Main::rmdir_recursive($source_filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -217,6 +217,21 @@ class RippingCluster_Source_Plugin_HandBrake extends RippingCluster_PluginBase i
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permanently deletes the given source from disk
|
||||
*
|
||||
* @param RippingCluster_Source $source Source object to be deleted
|
||||
* @return bool
|
||||
*/
|
||||
public static function delete($source_filename) {
|
||||
if ( ! self::isValidSource($source_filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return RippingCluster_Main::rmdir_recursive($source_filename);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -244,6 +244,20 @@ class RippingCluster_Source_Plugin_MkvInfo extends RippingCluster_PluginBase imp
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permanently deletes the given source from disk
|
||||
*
|
||||
* @param RippingCluster_Source $source Source object to be deleted
|
||||
* @return bool
|
||||
*/
|
||||
public static function delete($source_filename) {
|
||||
if ( ! self::isValidSource($source_filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return unlink($source_filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -67,6 +67,22 @@ class RippingCluster_Source_PluginFactory extends RippingCluster_PluginFactory {
|
||||
return call_user_func(array(self::classname($plugin), 'isValidSource'), source_filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Permanently deletes the given source from disk
|
||||
*
|
||||
* @param string $plugin Name of the plugin used to load the source
|
||||
* @param string $source_filename Filename of the source to be deleted
|
||||
*/
|
||||
public static function delete($plugin, $source_filename) {
|
||||
self::ensureScanned();
|
||||
|
||||
if ( ! self::isValidPlugin($plugin)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return call_user_func(array(self::classname($plugin), 'delete'), $source_filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
28
webui/pages/sources/delete.php
Normal file
28
webui/pages/sources/delete.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
$main = RippingCluster_Main::instance();
|
||||
$req = $main->request();
|
||||
$config = $main->config();
|
||||
|
||||
// Grab the name of this source
|
||||
$encoded_filename = null;
|
||||
if ($req->get('confirm')) {
|
||||
$plugin = $req->get('plugin', 'RippingCluster_Exception_InvalidParameters');
|
||||
$encoded_filename = $req->get('id', 'RippingCluster_Exception_InvalidParameters');
|
||||
|
||||
$source = RippingCluster_Source_PluginFactory::loadEncoded($plugin, $encoded_filename, false);
|
||||
$source->delete();
|
||||
|
||||
// Redirect back to the sources page
|
||||
RippingCluster_Page::redirect('rips/sources');
|
||||
|
||||
} else {
|
||||
$plugin = $req->get('plugin', 'RippingCluster_Exception_InvalidParameters');
|
||||
$encoded_filename = $req->get('id', 'RippingCluster_Exception_InvalidParameters');
|
||||
|
||||
$source = RippingCluster_Source_PluginFactory::loadEncoded($plugin, $encoded_filename, false);
|
||||
|
||||
$this->smarty->assign('source', $source);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -20,7 +20,8 @@
|
||||
{assign var='source_cached' value="$source->isCached()}
|
||||
<li>
|
||||
[ <a href="{$base_uri}rips/source-details/plugin/{$source_plugin}/id/{$source_filename_encoded}" title="Browse source details">Browse</a> |
|
||||
<a href="{$base_uri}rips/setup-rip/plugin/{$source_plugin}/id/{$source_filename_encoded}" title="Rip this source">Rip</a> ]
|
||||
<a href="{$base_uri}rips/setup-rip/plugin/{$source_plugin}/id/{$source_filename_encoded}" title="Rip this source">Rip</a> |
|
||||
<a href="{$base_uri}sources/delete/plugin/{$source_plugin}/id/{$source_filename_encoded}" title="Delete this source">Delete</a> ]
|
||||
{$source_filename|escape:'html'}{if $source_cached} (cached){/if}
|
||||
</li>
|
||||
{/foreach}
|
||||
|
||||
7
webui/templates/sources/delete.tpl
Normal file
7
webui/templates/sources/delete.tpl
Normal file
@@ -0,0 +1,7 @@
|
||||
<h2>Delete Source</h2>
|
||||
|
||||
<p>
|
||||
Are you sure you want to delete {$source->plugin()|escape:"html"}:{$source->filename()|escape:"html"}?
|
||||
[ <a href="{$base_uri}sources/delete/plugin/{$source->plugin()}/id/{$source->filenameEncoded()}/confirm" title="Delete it">Delete</a>
|
||||
| <a href="{$base_uri}rips/sources" title="Return to sources list">Cancel</a> ]
|
||||
</p>
|
||||
Reference in New Issue
Block a user