-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathImageUploader.php
executable file
·63 lines (56 loc) · 1.62 KB
/
ImageUploader.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* A library for uploading image to some hosting services like picasa, imgur, imageshack, etc..
*
* @author Phan Thanh Cong <[email protected]>
* @copyright 2010-2014 Phan Thanh Cong.
* @license http://www.opensource.org/licenses/mit-license.php MIT License
* @version 2.2
* @release Mar 07, 2014
*/
class ChipVN_ImageUploader_ImageUploader
{
/**
* Get a plugin instance.
* @param string $name
* @return \ChipVN\ImageUploaderPlugins\Plugin
*/
public function getPlugin($name)
{
$class = 'ChipVN_ImageUploader_Plugins_' . $name;
if (!class_exists($class, false)) {
$this->loadPlugin($name);
}
return new $class;
}
/**
* Create a plugin for uploading.
*
* @param string $plugin
* @return \ChipVN\ImageUploaderPlugins
*/
public static function make($plugin)
{
$instance = new self;
return $instance->getPlugin($plugin);
}
/**
* Load a plugin by name, if file not found, system will load all plugins.
* This to ensure that the plugin will be loaded to use.
*
* @param string $name
* @return void
*/
protected function loadPlugin($name)
{
$pluginDir = dirname(__FILE__) . '/Plugins/';
require_once $pluginDir . 'Abstract.php';
if (file_exists($file = $pluginDir . $name . '.php')) {
require_once $file;
} else {
foreach (glob($pluginDir . '*.php') as $file) {
require_once $file;
}
}
}
}