Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
2
<HTML>
3
<HEAD>
4
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
5
<LINK REL="Start" HREF="index.html">
6
<LINK REL="Contents" HREF="toc.html">
7
<LINK REL="Prev" HREF="62Specifyingtargetsforimagemapplots.html">
8
<LINK REL="Next" HREF="64ExamplesofImagemaps.html">
9
<STYLE TYPE="text/css"><!--
10
BODY { font-family: serif }
11
H1 { font-family: sans-serif }
12
H2 { font-family: sans-serif }
13
H3 { font-family: sans-serif }
14
H4 { font-family: sans-serif }
15
H5 { font-family: sans-serif }
16
H6 { font-family: sans-serif }
17
SUB { font-size: smaller }
18
SUP { font-size: smaller }
19
PRE { font-family: monospace }
20
A { text-decoration: none }
21
--></STYLE>
22
</HEAD>
23
<BODY>
24
<A HREF="toc.html">Contents</A>
25
<A HREF="62Specifyingtargetsforimagemapplots.html">Previous</A>
26
<A HREF="64ExamplesofImagemaps.html">Next</A>
27
<HR NOSHADE>
28
<H2><A NAME="6_3">6.3 Using StrokeCSIM()</A></H2>
29
<P> The simplest way of creating a creating a CSIM image is with the
30
 StrokeCSIM() method. As mentioned before this method actually returns a
31
 (small) HTML page containing both the image-tag as well as the image
32
 map specification. Hence it is<B> not</B> possible to use a script that
33
 ends with this method in a standard image-tags src property.</P>
34
<P> There are two ways to create CSIM (or get hold of) the image maps</P>
35
<OL>
36
<LI> Use the CSIM image script as the target in a standard anchor
37
 reference, for example <CODE>
38
<PRE>
39
&lt;a href=&quot;mycsimscript.html&quot;&gt;
40
</PRE>
41
</CODE> This has the drawback that the image page will only contain the
42
 image and nothing else.</LI>
43
<LI> The other way will allow the image script to be included in an
44
 arbitrary HTML page by just including the image script at the wanted
45
 place in the HTML page using any of the standard &quot;include&quot; php
46
 statement. For example <CODE>
47
<PRE>
48
&lt;h2&gt; This is an CSIM image &lt;/h2&gt;
49
 
50
&lt;?php
51
include &quot;mycsimscript.php&quot;
52
?&gt;
53
</PRE>
54
</CODE></LI>
55
</OL>
56
<P><DIV class="note"><B>Note:</B> If there are several CSIM images on
57
 the same page it is necessary to use &quot;include_once&quot; in the scripts for
58
 the inclusion of &quot;jpgraph.php&quot; and the other jpgraph library files
59
 since the files will be included multiple times on the same page and
60
 one or more &quot;Already defined error&quot; will be displayed.</DIV></P>
61
<P> The process to replace Stroke() with StrokeCSIM() is strait forward.
62
 Replace all existing calls to Stroke() with the equivalent calls to
63
 StrokeCSIM().</P>
64
<P> The only difference is that it is necessary ti supply a minimum of
65
 one file name in the StrokeCSIM() method. The first argument must be
66
 the name of the actual image script file including the extension. So
67
 for example if the image script is called &quot;mycsimscript.php&quot; it is
68
 necessary to write
69
<BR> &nbsp;<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
70
&nbsp;$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
71
StrokeCSIM</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
72
'mycsimscript.php'</FONT><FONT color="#007700">)</FONT><FONT color="#0000BB">
73
</FONT></FONT></CODE></DIV></P>
74
<P>
75
<BR> However, it is possible to apply a small &quot;trick&quot; here. PHP maintain
76
 a special variable called &quot;__FILE__&quot; which is always set to the current
77
 file name. This means you could use the following construction:</P>
78
<P><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
79
&nbsp;$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
80
StrokeCSIM</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
81
basename</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
82
__FILE__</FONT><FONT color="#007700">))</FONT><FONT color="#0000BB"></FONT>
83
</FONT></CODE></DIV></P>
84
<P>This is a better way since the script can now be renamed without
85
 having to change any code in the file which otherwise would be needed.<DIV
86
class="note"><B>Note:</B> Why does the script name need to be used as
87
 the first parameter? The reason is that in the creation of the HTML
88
 page which is sent back we need to refer to the script in the image
89
 tag. So why is it not possible to use the PHP_SELF reference? The
90
 problem with PHP_SELF is that in the case where we include the
91
 image-script in an HTML page and use the PHP_SELF we will get the name
92
 of the HTML page and not the actual script in which the PHP_SELF is
93
 used. We also can not use the __FILE__ trick in the library since in
94
 the context __FILE__ is set to &quot;jpgraph.php&quot;. Hence, this must be
95
 specified by the client as shown above.</DIV></P>
96
<P> The other arguments to StrokeCSIM() are optional. Please note that
97
 if several CSIM images are used in the same HTML page it is also
98
 necessary to specify the image map name as the second parameter since
99
 all image maps must be unique to properly match each image map against
100
 each image. Please consult the class reference <A href="../ref/Graph.html#_GRAPH_STROKECSIM">
101
 StrokeCSIM()</A> for more details.</P>
102
<HR NOSHADE>
103
<A HREF="toc.html">Contents</A>
104
<A HREF="62Specifyingtargetsforimagemapplots.html">Previous</A>
105
<A HREF="64ExamplesofImagemaps.html">Next</A>
106
</BODY>
107
</HTML>