-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcls_DropboxFile.php
More file actions
105 lines (77 loc) · 1.79 KB
/
cls_DropboxFile.php
File metadata and controls
105 lines (77 loc) · 1.79 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
class DropboxFile {
var $full_path = '';
var $parent_dir = '';
var $file_name = '';
var $public_url = '';
public function setFullPath($path) {
$this->full_path = $path;
}
public function getFullPath() {
return $this->full_path;
}
public function setParentDir($parent_dir) {
$this->parent_dir = $parent_dir;
}
public function getParentDir() {
return $this->parent_dir;
}
public function setFileName($file_name) {
$this->file_name = $file_name;
}
public function getFileName() {
return $this->file_name;
}
public function setPublicUrl($public_url) {
$this->public_url = $public_url;
}
public function getPublicUrl() {
return $this->public_url;
}
public function toHTML() {
$html = '';
$html .= '<li><a href="' . $this->getPublicUrl() . '" target="_blank">' .
$this->getFileName() .
'</a></li>';
return $html;
}
public static function startListToHTML() {
$html = '';
$html .= '<ul>';
return $html;
}
public static function endListToHTML() {
$html = '';
$html .= '</ul>';
return $html;
}
public function toJson() {
$str_base = array(
'full_path' => $this->getFullPath(),
'parent_dir' => $this->getParentDir(),
'file_name' => $this->getFileName(),
'public_url' => $this->getPublicUrl(),
);
return json_encode($str_base);
}
public static function fromJson($json) {
$str = json_decode($json, true);
if (! $str) {
return null;
}
$file_obj = new DropboxFile();
if (@$str['full_path']) {
$file_obj->setFullPath($str['full_path']);
}
if (@$str['parent_dir']) {
$file_obj->setParentDir($str['parent_dir']);
}
if (@$str['file_name']) {
$file_obj->setFileName($str['file_name']);
}
if (@$str['public_url']) {
$file_obj->setPublicUrl($str['public_url']);
}
return $file_obj;
}
}