|
@@ -15,38 +15,54 @@ class View
|
|
|
# 根据配置生成缩略图 暂时支持缩略图
|
|
|
public function get($file)
|
|
|
{
|
|
|
- if (strstr($file, '_t')) {
|
|
|
- $host = Dever::config('host')->uploadRes;
|
|
|
- $root = Dever::data() . 'upload/';
|
|
|
- $dest = str_replace($host, $root, $file);
|
|
|
+ $array = $this->getFile($file);
|
|
|
+ $source = $array[0];
|
|
|
+ $type = $array[1];
|
|
|
+ $id = $array[2];
|
|
|
|
|
|
- if (!strstr($dest, 'http://') && !is_file($dest)) {
|
|
|
- $temp = explode('_t', $dest);
|
|
|
- $temp1 = explode('.', $temp[1]);
|
|
|
- $id = $temp1[0];
|
|
|
- $source = $temp[0] . '.' . $temp1[1];
|
|
|
+ if ($id > 0) {
|
|
|
+ $host = Dever::config('host')->uploadRes;
|
|
|
+ $root = Dever::data() . 'upload/';
|
|
|
+ $dest = str_replace($host, $root, $file);
|
|
|
|
|
|
- $handle = new Handle();
|
|
|
-
|
|
|
- $handle->handle_t($id, $source, $dest);
|
|
|
- }
|
|
|
- }
|
|
|
+ if (!strstr($dest, 'http://') && !is_file($dest)) {
|
|
|
+ $handle = new Handle();
|
|
|
+ $method = 'handle_' . $type;
|
|
|
+ $handle->$method($id, $source, $dest);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
return $file;
|
|
|
}
|
|
|
|
|
|
public function source($file)
|
|
|
{
|
|
|
- # 查看原图
|
|
|
- if (strstr($file, '_t')) {
|
|
|
- $temp = explode('_t', $file);
|
|
|
- $temp1 = explode('.', $temp[1]);
|
|
|
- $file = $temp[0] . '.' . $temp1[1];
|
|
|
- }
|
|
|
-
|
|
|
- return $file;
|
|
|
+ # 搜索文件信息
|
|
|
+ $array = $this->getFile($file);
|
|
|
+ return $array[0];
|
|
|
}
|
|
|
|
|
|
+ private function getFile($file)
|
|
|
+ {
|
|
|
+ $type = $id = false;
|
|
|
+
|
|
|
+ if (strstr($file, '_c')) {
|
|
|
+ $array = explode('_c', $file);
|
|
|
+ $type = 'c';
|
|
|
+ } elseif (strstr($file, '_t')) {
|
|
|
+ $array = explode('_t', $file);
|
|
|
+ $type = 't';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($array)) {
|
|
|
+ $temp = explode('.', $array[1]);
|
|
|
+ $id = $temp[0];
|
|
|
+ $file = $array[0] . '.' . $temp[1];
|
|
|
+ }
|
|
|
+
|
|
|
+ return array($file, $type, $id);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* create 生成图片
|
|
|
* @param array $config
|