runexample.php
9.86 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
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
<?php
ob_start();
session_start();
//Global var
$rootFolder = "../../../..";
$CoolControlsFolder = "../../../../CoolControls";
$rootURL = "../../../../index.php";
$xmlControls = "../../../../controls.xml";
$controlsURL = "../../../..";
$cssURL = "../../../../Resources/css";
$imgURL = "../../../../Resources/images";
$resourcesURL = "../../../../Resources";
$installURL = "../../../../Install";
$xmlNav = "../../navigation.xml";
$navURL = "../..";
$controlImgUrl = "../../Images";
$xmlExample = "example.xml";
$example = array();
$xmlOverview = "../../overview.xml";
//Check PHP version
if(phpversion() < 5)
header("Location: $resourcesURL/err.html");
//load database infomation
include($resourcesURL.'/config.php');
//load Overview.xml
$ex_html = "";
$xml = simplexml_load_file($xmlOverview);
$control["name"] = $xml->name;
echo $xml->version;
//load Example.xml
$xml = simplexml_load_file($xmlExample);
$example["id"] = $xml["id"];
$example["usedb"] = ($xml["usedb"]=="true")?true:false;
$example["title"] = $xml->title;
$example["meta-description"] = $xml->metadescription;
$example["meta-keywords"] = $xml->metakeywords;
$example["description"] = $xml->description;
$navid = $example["id"];//Use to mark the selected id for navigation
$totalCode = count($xml->samplecodes->code);
for($i = 0; $i < $totalCode; $i++) {
$example["samplecodes"]["header"][$i] = trim($xml->samplecodes->code[$i]["header"]);
$example["samplecodes"]["code"][$i] = trim($xml->samplecodes->code[$i]);
}
$example["samplecodes"]["total"] = $i;
$docs_html = "";
$totalDocs = count($xml->docs->doc);
for($i = 0; $i < $totalDocs; $i++) {
$docs_html .= "<li class='list-docs'>";
$docs_html .= "• <a href='".$xml->docs->doc[$i]["link"]."' target='_blank'>".$xml->docs->doc[$i]."</a>";
$docs_html .= "</li>";
}
//load Code Highighter
include($resourcesURL."/geshi.php");
$id = isset($_GET['id']) ? $_GET['id'] : 1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="<?php echo $example["meta-description"]?>" />
<meta name="keywords" content="<?php echo $example["meta-keywords"]?>" />
<meta name="author" content="KoolPHP.NET" />
<meta name="ResourceType" content="Demo" />
<meta name="classification" content="PHP, User Interface, PHP UI, Computer, Software, Internet, Web Design" />
<link rel="stylesheet" href="<?php echo $cssURL?>/main.css" />
<!--[if IE 6]><link rel="stylesheet" href="<?php echo "$resourcesURL/ie6.css.php?imgURL=$imgURL";?>" /><![endif]-->
<link rel="stylesheet" href="<?php echo $cssURL?>/tab-view.css" />
<link rel="stylesheet" href="<?php echo $cssURL?>/example.css" />
<title>{example_title}</title>
</head>
<body>
<!-- Wrap all -->
<div id="wrap-all" class="fix-float">
<div id="top-examples">
<div id="banner">
<div id="logo">
<?php include($resourcesURL."/header.php");?>
</div>
</div><!-- end banner -->
</div><!-- end top-home -->
<!-- Body -->
<div id="body" class="fix-float">
<div class="ie6hack">
<table class="hack-ie"><tr valign="top">
<td class="content-L hack-ie">
<div id="nav">
<?php include($resourcesURL."/nav.php");?>
</div>
<div class="break10px"></div>
<div id="controls">
<?php include($resourcesURL."/controls.php");?>
</div>
</td>
<td class="content-R">
<div id="main-content">
<table class="maintop"><tr><td class="tl"><img src="<?php echo $imgURL?>/none.gif" alt="" /></td><td class="tc"><div> </div></td><td class="tr"><img src="<?php echo $imgURL?>/none.gif" alt="" /></td></tr></table>
<div id="middle">
<div id="main">
<div class="component-title fix-float"><h1><span class="left"><img src="<?php echo $controlImgUrl; ?>/icon.png" class="absbottom" alt="<?php echo $control["name"];?>" /><?php echo $control["name"];?></span><span class="version right"><?php echo $control["version_type"]." ".$control["version"]." released on ".$control["releasedate"];?></span></h1></div>
<div class="example">
<div class="title"><h4><?php echo $example_category." - ".$example["title"]?></h4></div>
<div class="show-it show-example">
<div style="font-size:0pt;height:1px;"></div>
<?php
if($example["usedb"])
{
if(!defined('INSTALLED'))
{
include($installURL."/install.php");
}
else
{
//Connect database here
$db_con = mysql_connect($dbhost,$dbuser,$dbpass);
if(mysql_select_db($dbname))
{
include("example.php");
mysql_close($db_con);
}
else
{
?>
<div class="install-err">
<table style="width:500px;">
<tr>
<td><img src="<?php echo $imgURL?>/attention.png" class="absbottom" alt="" /></td>
<td>Could not connect to database! <a href="<?php echo $installURL?>/index.php?step=1">Click here to re-install</a> </td>
</tr>
</table>
</div>
<?php
}
}
}
else
{
include("example.php");
}
?>
</div>
</div>
<div class="detail">
<div class="title"><h4>Description & Sample code</h4></div>
<div class="show-it">
<div class="TabView" id="TabView">
<!-- ***** Tabs ************************************************************ -->
<div class="Tabs" style="width: 600px;">
<a <?=($id == 0) ? 'class="Current"' : 'href="?id=0"';?>>Description</a>
<?php for($i=1; $i <= $example["samplecodes"]["total"]; $i++){
if(!empty($example["samplecodes"]["code"][$i-1])){
?>
<a <?=($id == $i) ? 'class="Current"' : 'href="?id=$i"';?>>
<?php echo $example["samplecodes"]["header"][$i-1]?>
</a>
<?php }}?>
<a <?=($id == 100) ? 'class="Current"' : 'href="?id=4"';?>>Documentation</a>
</div>
<!-- ***** Pages *********************************************************** -->
<div class="Pages" style="width: 650px; height: 300px;">
<div class="Page" style="width: 650px;height: 300px;display: <?=($id == 0) ? 'block' : 'none';?>">
<div class="Pad"><?php echo $example["description"]?></div>
</div>
<?php for($i=1; $i <= $example["samplecodes"]["total"]; $i++){
if(!empty($example["samplecodes"]["code"][$i-1])){
?>
<div class="Page" style="width: 650px;height: 300px;display: <?=($id == 2) ? 'block' : 'none';?>">
<div class="Pad">
<?php
$geshi = new GeSHi($example["samplecodes"]["code"][$i-1]);
echo $geshi->parse_code();
?>
</div>
</div>
<?php }}?>
<div class="Page" style="width: 650px;height: 300px;display: <?=($id == 4) ? 'block' : 'none';?>">
<div class="Pad"><ul><?php echo $docs_html?></ul></div>
</div>
</div>
</div>
<script type="text/javascript" src="<?php echo $resourcesURL?>/js/tab-view.js"></script>
<script type="text/javascript">
tabview_initialize('TabView');
</script>
</div>
</div>
<div class="clear-this"></div>
</div>
</div>
<table class="mainbottom"><tr><td class="bl"><img src="<?php echo $imgURL?>/none.gif" alt="" /></td><td class="tc"><div> </div></td><td class="br"><img src="<?php echo $imgURL?>/none.gif" alt="" /></td></tr></table>
</div>
<div class="break20px"></div>
<div id="footer"><?php include($resourcesURL."/footer.php");?></div>
</td>
</tr></table>
</div>
</div><!-- end Body -->
</div><!-- end Wrap all -->
</body>
</html>
<?php
$all_html = ob_get_contents();
ob_end_clean();
$example_title.= " - ".$example["title"];
$all_html = str_replace("{example_title}",$example_title,$all_html);
echo $all_html;
?>