-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathclass.ilInteractiveVideoVimeo.php
256 lines (227 loc) · 4.57 KB
/
class.ilInteractiveVideoVimeo.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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<?php
require_once 'Customizing/global/plugins/Services/Repository/RepositoryObject/InteractiveVideo/VideoSources/interface.ilInteractiveVideoSource.php';
/**
* Class ilInteractiveVideoVimeo
* @author Guido Vollbach <[email protected]>
*/
class ilInteractiveVideoVimeo implements ilInteractiveVideoSource
{
const FORM_FIELD = 'vimeo_url';
const TABLE_NAME = 'rep_robj_xvid_vimeo';
/**
* @var string
*/
protected $id;
/**
* @var string
*/
protected $version;
/**
* @var string
*/
protected $vimeo_id;
/**
* ilInteractiveVideoYoutube constructor.
*/
public function __construct()
{
if (is_file(dirname(__FILE__) . '/version.php'))
{
include(dirname(__FILE__) . '/version.php');
$this->version = $version;
$this->id = $id;
}
}
/**
* @param $obj_id
*/
public function doCreateVideoSource($obj_id)
{
$this->doUpdateVideoSource($obj_id);
}
/**
* @param $obj_id
*/
public function doReadVideoSource($obj_id)
{
global $ilDB;
$result = $ilDB->query('SELECT vimeo_id FROM '.self::TABLE_NAME.' WHERE obj_id = '.$ilDB->quote($obj_id, 'integer'));
$row = $ilDB->fetchAssoc($result);
$this->setVimeoId($row['vimeo_id']);
}
/**
* @param $obj_id
*/
public function doDeleteVideoSource($obj_id)
{
$this->beforeDeleteVideoSource($obj_id);
}
/**
* @param $original_obj_id
* @param $new_obj_id
*/
public function doCloneVideoSource($original_obj_id, $new_obj_id)
{
$this->doReadVideoSource($original_obj_id);
$this->saveData($new_obj_id, $this->getVimeoId());
}
/**
* @param $obj_id
* @param $vimeo_id
*/
protected function saveData($obj_id, $vimeo_id)
{
global $ilDB;
$ilDB->insert(
self::TABLE_NAME,
array(
'obj_id' => array('integer', $obj_id),
'vimeo_id' => array('text', $vimeo_id)
)
);
}
/**
* @param $obj_id
*/
public function beforeDeleteVideoSource($obj_id)
{
$this->removeEntryFromTable($obj_id);
}
/**
* @param $obj_id
*/
public function removeEntryFromTable($obj_id)
{
global $ilDB;
$ilDB->manipulateF('DELETE FROM '.self::TABLE_NAME.' WHERE obj_id = %s',
array('integer'), array($obj_id));
}
/**
* @param $obj_id
*/
public function doUpdateVideoSource($obj_id)
{
if(ilUtil::stripSlashes($_POST[self::FORM_FIELD]))
{
$vimeo_id = self::getVimeoIdentifier(ilUtil::stripSlashes($_POST[self::FORM_FIELD]));
}
else
{
$vimeo_id = $this->getVimeoId();
}
if($vimeo_id)
{
$this->removeEntryFromTable($obj_id);
$this->setVimeoId($vimeo_id);
$this->saveData($obj_id, $vimeo_id);
}
}
/**
* @return string
*/
public function getClass()
{
return __CLASS__;
}
/**
* @return bool
*/
public function isFileBased()
{
return false;
}
/**
* @return ilInteractiveVideoVimeoGUI
*/
public function getGUIClass()
{
require_once dirname(__FILE__) . '/class.ilInteractiveVideoVimeoGUI.php';
return new ilInteractiveVideoVimeoGUI();
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @return string
*/
public function getClassPath()
{
return 'VideoSources/plugin/InteractiveVideoVimeo/class.ilInteractiveVideoVimeo.php';
}
/**
* @return string
*/
public function getVersion()
{
return $this->version;
}
/**
* @return string
*/
public function getVimeoId()
{
return $this->vimeo_id;
}
/**
* @param string $vimeo_id
*/
public function setVimeoId($vimeo_id)
{
$this->vimeo_id = $vimeo_id;
}
/**
* @param $obj_id
* @return string
*/
public function getPath($obj_id)
{
return '';
}
/**
* @param $value
* @return string | boolean
*/
public static function getVimeoIdentifier($value)
{
$regex = '/(http|https):\/\/vimeo\.com\/(.+)/';
preg_match_all($regex, $value, $matches);
if(sizeof($matches) == 3 && array_key_exists(0, $matches[2]))
{
return $matches[2][0];
}
return false;
}
/**
* @param int $obj_id
* @param ilXmlWriter $xml_writer
* @param string $export_path
*/
public function doExportVideoSource($obj_id, $xml_writer, $export_path)
{
$this->doReadVideoSource($obj_id);
$xml_writer->xmlElement('VimeoId', null, (string)$this->getVimeoId());
}
/**
*
*/
public function getVideoSourceImportParser()
{
require_once 'Customizing/global/plugins/Services/Repository/RepositoryObject/InteractiveVideo/VideoSources/plugin/InteractiveVideoVimeo/class.ilInteractiveVideoVimeoXMLParser.php';
return 'ilInteractiveVideoVimeoXMLParser';
}
/**
* @param $obj_id
* @param $import_dir
*/
public function afterImportParsing($obj_id, $import_dir)
{
}
public function hasOwnPlayer()
{
return true;
}
}