forked from jgraph/mxgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmxImageBundle.php
More file actions
82 lines (76 loc) · 1.85 KB
/
mxImageBundle.php
File metadata and controls
82 lines (76 loc) · 1.85 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
<?php
/**
* Copyright (c) 2006-2013, Gaudenz Alder
*/
class mxImageBundle
{
/**
* Class: mxImageBundle
*
* Maps from keys to base64 encoded images or file locations. All values must
* be URLs or use the format data:image/format followed by a comma and the base64
* encoded image data, eg. "data:image/gif,XYZ", where XYZ is the base64 encoded
* image data.
*
* (code)
* $bundle = new mxImageBundle();
* $bundle->putImage("myImage", "data:image/gif,R0lGODlhEAAQAMIGAAAAAICAAICAgP".
* "//AOzp2O3r2////////yH+FUNyZWF0ZWQgd2l0aCBUaGUgR0lNUAAh+QQBCgAHACwAAAAAEA".
* "AQAAADTXi63AowynnAMDfjPUDlnAAJhmeBFxAEloliKltWmiYCQvfVr6lBPB1ggxN1hilaSS".
* "ASFQpIV5HJBDyHpqK2ejVRm2AAgZCdmCGO9CIBADs=");
* $graph->addImageBundle($bundle);
* (end);
*
* The image can then be referenced in any cell style using image=myImage.
*
* To convert an image at a given URL to a base64 encoded String, the following
* code can be used:
*
* (code)
* echo "base64=".base64_encode(file_get_contents($url));
* (end)
*
* The value is decoded in <mxUtils.loadImage>. The keys for images are
* resolved and the short format above is converted to a data URI in
* <mxGraph.postProcessCellStyle>.
*
* Variable: images
*
* Maps from keys to images.
*/
var $images = array();
/**
* Constructor: mxImageBundle
*
* Constructs a new image bundle.
*/
function mxImageBundle() { }
/**
* Function: getImages
*
* Returns the <images>.
*/
function getImages()
{
return $this->images;
}
/**
* Function: putImage
*
* Adds the specified entry to the map.
*/
function putImage($key, $value)
{
$this->images[$key] = $value;
}
/**
* Function: getImage
*
* Returns the value for the given key.
*/
function getImage($key)
{
return (array_key_exists($key, $this->images)) ? $this->images[$key] : null;
}
}
?>