-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathImageReference.php
More file actions
33 lines (29 loc) · 821 Bytes
/
ImageReference.php
File metadata and controls
33 lines (29 loc) · 821 Bytes
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
<?php
namespace ProcessWire;
class ImageReference extends WireData
{
public function __construct() {
$this->set('filename', '');
$this->set('pageid', 0);
$this->set('value', 0);
}
public function set($key, $value)
{
if ($key == 'filename') {
$value = wire('sanitizer')->filename($value);
} else if ($key == 'pageid') {
$value = (int) $value;
} else if ($key == 'value') {
$value = wire('sanitizer')->text($value);
}
return parent::set($key, $value);
}
/**
* If accessed as a string, then just output as a JSON string
*
*/
public function __toString()
{
return json_encode(array('pageid' => $this->pageid, 'filename' => $this->filename, 'value' => $this->value));
}
}