object.diff
/dev/null | ||
---|---|---|
1 |
<?php |
|
2 | ||
3 |
require_once('ryzom_api/ryzom_api.php'); |
|
4 | ||
5 |
if(isset($_POST['key']) && $_POST['key'] != '') header('Location: ?ckey='.ryzom_encrypt($_POST['key'])); |
|
6 | ||
7 |
ryzom_ckey_handle(); |
|
8 | ||
9 |
header('Content-Type:text/html; charset=UTF-8'); |
|
10 | ||
11 |
echo ' |
|
12 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
13 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
|
14 |
<head> |
|
15 |
<title>Character Profile</title> |
|
16 |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> |
|
17 |
'.ryzom_render_header().' |
|
18 |
'.ryzom_render_header_www().' |
|
19 |
</head> |
|
20 |
<body> |
|
21 |
'; |
|
22 | ||
23 |
if (isset($_GET['ckey']) && $_GET['ckey'] != '') { |
|
24 | ||
25 |
ryzom_log_start('example_profile'); |
|
26 | ||
27 |
// Display the profile |
|
28 |
$ckey = $_GET['ckey']; |
|
29 |
$key = ryzom_decrypt($ckey); |
|
30 | ||
31 |
$uid=0;$gid=0;$slot=0;$full=false; |
|
32 |
if(ryzom_character_valid_key($key, $uid, $slot, $full)) { |
|
33 |
$xml = ryzom_character_simplexml($key, 'full'); |
|
34 |
} else if(ryzom_guild_valid_key($key, $gid)) { |
|
35 |
$xml = ryzom_guild_simplexml($key); |
|
36 |
} else { |
|
37 |
$xml = ryzom_error('Not valid character or guild key', 'simplexml'); |
|
38 |
} |
|
39 |
if($xml->getName() == 'error') { |
|
40 |
$content = '<div class="error">'.$xml.'</div>'; |
|
41 |
$content.= '<hr/><a class="ryzom-ui-button" href="?">back</a>'; |
|
42 |
die(ryzom_render_www(ryzom_render_window('API error', $content))); |
|
43 |
} |
|
44 | ||
45 |
// Display the profile |
|
46 |
if((string)$xml->getName()=='character') { |
|
47 |
$title='Character profile'; |
|
48 |
$content=render_character($xml,$key); |
|
49 |
} else { |
|
50 |
$title='Guild profile'; |
|
51 |
$content=render_guild($xml); |
|
52 |
} |
|
53 | ||
54 |
ryzom_log_end(); |
|
55 |
} else { |
|
56 |
// Display the form to enter the API Key |
|
57 |
$title = 'Profile'; |
|
58 |
$content = '<form action="" method="post">'; |
|
59 |
$content .= 'Please enter the API Key (guild or character) that you can find on <a href="https://secure.ryzom.com/payment_profile">your profile page</a>:</br>'; |
|
60 |
$content .= '<input type="text" name="key"><br/>'; |
|
61 |
$content .= '<input type="submit" value="Submit" />'; |
|
62 |
$content .= '</form>'; |
|
63 |
} |
|
64 | ||
65 |
echo ryzom_render_www(ryzom_render_window($title, $content)); |
|
66 |
echo '</body></html>'; |
|
67 | ||
68 |
function render_guild($xml){ |
|
69 |
$content = '<h1>'.$xml->name.'</h1>'; |
|
70 | ||
71 |
$content .= '<ul>'; |
|
72 |
$content .= '<li>Created: <b>'.ryzom_time_txt(ryzom_time_array($xml->creation_date, '')).'</b></li>'; |
|
73 |
$content .= '<li>Cult: <b>'.$xml->cult.'</b></li>'; |
|
74 |
$content .= '<li>Civilization: <b>'.$xml->civ.'</b></li>'; |
|
75 | ||
76 |
$guild_icon = ryzom_guild_icon_image($xml->icon, 'b'); |
|
77 |
$guild_icon_small = ryzom_guild_icon_image($xml->icon, 's'); |
|
78 |
$content .= "<li>Guild Icon: $guild_icon $guild_icon_small</li>"; |
|
79 | ||
80 |
$content .= '</ul>'; |
|
81 | ||
82 |
// read the members, then sort them by grade and name |
|
83 |
$result = $xml->xpath('/guild/members/*'); |
|
84 |
$members=array(); |
|
85 |
$s_gk=array();// multi array sort keys |
|
86 |
$s_nk=array(); |
|
87 |
$key=0; |
|
88 |
while(list(,$item)=each($result)) { |
|
89 |
$members[$key]=array( |
|
90 |
'joined' => intval($item->joined_date), // joined_date is in server tick (ingame date) |
|
91 |
'grade' => (string)$item->grade, |
|
92 |
'name' => (string)$item->name, |
|
93 |
); |
|
94 |
$s_gk[$key]=memberGrade($members[$key]['grade']); |
|
95 |
$s_nk[$key]=$members[$key]['name']; |
|
96 |
$key++; |
|
97 |
} |
|
98 |
// sort members by grade, then by name |
|
99 |
array_multisort($s_gk, SORT_ASC, $s_nk, SORT_ASC, $members); |
|
100 |
$content .= '<h2>Members:'.count($members).'</h2>'; |
|
101 |
$content .= '<table width="500px" border="1" cellpadding="1" cellspacing="0">'; |
|
102 |
$content .= '<thead><tr><td>Name</td><td>Rank</td><td>Joined</td></thead>'; |
|
103 |
foreach($members as $member) { |
|
104 |
$content .= |
|
105 |
'<tr>'. |
|
106 |
'<td>'.$member['name'].'</td>'. |
|
107 |
'<td>'.$member['grade'].'</td>'. |
|
108 |
'<td>'.ryzom_time_txt(ryzom_time_array($member['joined'], '')).'</td>'. |
|
109 |
'</tr>'; |
|
110 |
} |
|
111 |
$content .= '</table>'; |
|
112 | ||
113 |
$content.= '<hr/><a class="ryzom-ui-button" href="?">Back</a>'; |
|
114 |
return $content; |
|
115 |
} |
|
116 | ||
117 |
/** |
|
118 |
* memberGrade will convert memebr grade string value to int for sorting |
|
119 |
* |
|
120 |
* @param string $grade one of 'Leader', 'HighOfficer', 'Officer', 'Member' |
|
121 |
* @return int |
|
122 |
*/ |
|
123 |
function memberGrade($grade) { |
|
124 |
switch(strtolower($grade)) { |
|
125 |
case 'leader': return 0; |
|
126 |
case 'highofficer': return 1; |
|
127 |
case 'officer': return 2; |
|
128 |
case 'member': |
|
129 |
default: return 3; |
|
130 |
} |
|
131 |
} |
|
132 | ||
133 |
function render_character($xml, $key) { |
|
134 |
$content = '<h1>'.$xml->name.'</h1>'; |
|
135 |
$content .= '<ul>'; |
|
136 |
$content .= '<li>Shard: <b>'.$xml->shard.'</b></li>'; |
|
137 |
$content .= '<li>Race: <b>'.$xml->race.'</b></li>'; |
|
138 |
$gender = $xml->gender; |
|
139 |
$content .= '<li>Gender: <b>'.($gender=='f'?'Female':'Male').'</b></li>'; |
|
140 |
$title = ryzom_title_txt($xml->titleid, 'en', $gender); |
|
141 |
$content .= '<li>Title: <b>'.$title.'</b></li>'; |
|
142 |
$content .= '</ul>'; |
|
143 | ||
144 |
$content .= '<h2>Hands</h2>'; |
|
145 |
$result = $xml->xpath('/character/hands/*'); |
|
146 |
while(list( , $item) = each($result)) |
|
147 |
{ |
|
148 |
$content .= ryzom_item_icon_image_from_simplexml($item).' '; |
|
149 |
} |
|
150 | ||
151 |
$content .= '<h2>Equipments</h2>'; |
|
152 |
$result = $xml->xpath('/character/equipments/*'); |
|
153 |
while(list( , $item) = each($result)) |
|
154 |
{ |
|
155 |
$content .= ryzom_item_icon_image_from_simplexml($item).' '; |
|
156 |
} |
|
157 | ||
158 |
if($xml->guild->name != '') { |
|
159 |
$content .= '<h2>Guild</h2>'; |
|
160 |
$content .= '<ul>'; |
|
161 |
$content .= '<li>Name: <b>'.$xml->guild->name.'</b></li>'; |
|
162 |
$guild_icon = ryzom_guild_icon_image($xml->guild->icon, 'b'); |
|
163 |
$guild_icon_small = ryzom_guild_icon_image($xml->guild->icon, 's'); |
|
164 |
$content .= "<li>Guild Icon: $guild_icon $guild_icon_small</li>"; |
|
165 |
$content .= '</ul>'; |
|
166 |
} else { |
|
167 |
$content .= '<h2>No Guild</h2>'; |
|
168 |
} |
|
169 | ||
170 |
// inventories |
|
171 | ||
172 |
$inv_xml = ryzom_character_simplexml($key, 'items'); |
|
173 | ||
174 |
if(isset($inv_xml->inventories->bag)) { |
|
175 |
$content .= '<h2>Bag</h2>'; |
|
176 |
$content .= '<p>(leave the mouse on an item to display its custom text, if any)</p>'; |
|
177 |
$result = $inv_xml->xpath('/items/inventories/bag/*'); |
|
178 |
while(list( , $item) = each($result)) |
|
179 |
{ |
|
180 |
$content .= ryzom_item_icon_image_from_simplexml($item); |
|
181 |
} |
|
182 |
} |
|
183 | ||
184 |
if(isset($inv_xml->item_in_store)) { |
|
185 |
$content .= '<h2>Item in store</h2>'; |
|
186 |
$content .= '<p>(leave the mouse on an item to display its price)</p>'; |
|
187 |
$result = $inv_xml->xpath('/items/item_in_store/*'); |
|
188 |
while(list( , $item) = each($result)) |
|
189 |
{ |
|
190 |
$content .= ryzom_item_icon_image_from_simplexml($item, "Price: ".$item['price']); |
|
191 |
} |
|
192 |
} |
|
193 | ||
194 |
$content.= '<hr/><a class="ryzom-ui-button" href="?">Back</a>'; |
|
195 |
return $content; |
|
196 |
} |
b/examples/example_profile.php | ||
---|---|---|
1 |
<?php |
|
2 | ||
3 |
require_once('ryzom_api/ryzom_api.php'); |
|
4 | ||
5 |
if(!empty($_POST['key'])) |
|
6 |
header('Location: ?ckey='.ryzom_encrypt($_POST['key'])); |
|
7 | ||
8 |
ryzom_ckey_handle(); |
|
9 | ||
10 |
header('Content-Type:text/html; charset=UTF-8'); |
|
11 | ||
12 |
echo ' |
|
13 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
14 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
|
15 |
<head> |
|
16 |
<title>Character Profile</title> |
|
17 |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> |
|
18 |
'.ryzom_render_header().' |
|
19 |
'.ryzom_render_header_www().' |
|
20 |
</head> |
|
21 |
<body> |
|
22 |
'; |
|
23 | ||
24 |
if (!empty($_GET['ckey'])) { |
|
25 | ||
26 |
ryzom_log_start('example_profile'); |
|
27 | ||
28 |
// Display the profile |
|
29 |
$ckey = $_GET['ckey']; |
|
30 |
$key = ryzom_decrypt($ckey); |
|
31 | ||
32 |
$uid=0;$gid=0;$slot=0;$full=false; |
|
33 |
if(ryzom_character_valid_key($key, $uid, $slot, $full)) { |
|
34 |
$xml = ryzom_character_simplexml($key, 'full'); |
|
35 |
} else if(ryzom_guild_valid_key($key, $gid)) { |
|
36 |
$xml = ryzom_guild_simplexml($key); |
|
37 |
} else { |
|
38 |
$xml = ryzom_error('Not valid character or guild key', 'simplexml'); |
|
39 |
} |
|
40 |
if($xml->getName() == 'error') { |
|
41 |
$content = '<div class="error">'.$xml.'</div>'; |
|
42 |
$content.= '<hr/><a class="ryzom-ui-button" href="?">back</a>'; |
|
43 |
die(ryzom_render_www(ryzom_render_window('API error', $content))); |
|
44 |
} |
|
45 | ||
46 |
// Display the profile |
|
47 |
if((string)$xml->getName()=='character') { |
|
48 |
$title='Character profile'; |
|
49 |
$content=render_character($xml,$key); |
|
50 |
} else { |
|
51 |
$title='Guild profile'; |
|
52 |
$content=render_guild($xml); |
|
53 |
} |
|
54 | ||
55 |
ryzom_log_end(); |
|
56 |
} else { |
|
57 |
// Display the form to enter the API Key |
|
58 |
$title = 'Profile'; |
|
59 |
$content = '<form action="" method="post">'; |
|
60 |
$content .= 'Please enter the API Key (guild or character) that you can find on <a href="https://secure.ryzom.com/payment_profile">your profile page</a>:</br>'; |
|
61 |
$content .= '<input type="text" name="key"><br/>'; |
|
62 |
$content .= '<input type="submit" value="Submit" />'; |
|
63 |
$content .= '</form>'; |
|
64 |
} |
|
65 | ||
66 |
echo ryzom_render_www(ryzom_render_window($title, $content)); |
|
67 |
echo '</body></html>'; |
|
68 | ||
69 |
function render_guild($xml){ |
|
70 |
$content = '<h1>'.$xml->name.'</h1>'; |
|
71 | ||
72 |
$content .= '<ul>'; |
|
73 |
$content .= '<li>Created: <b>'.ryzom_time_txt(ryzom_time_array($xml->creation_date, '')).'</b></li>'; |
|
74 |
$content .= '<li>Cult: <b>'.$xml->cult.'</b></li>'; |
|
75 |
$content .= '<li>Civilization: <b>'.$xml->civ.'</b></li>'; |
|
76 | ||
77 |
$guild_icon = ryzom_guild_icon_image($xml->icon, 'b'); |
|
78 |
$guild_icon_small = ryzom_guild_icon_image($xml->icon, 's'); |
|
79 |
$content .= "<li>Guild Icon: $guild_icon $guild_icon_small</li>"; |
|
80 | ||
81 |
$content .= '</ul>'; |
|
82 | ||
83 |
// read the members, then sort them by grade and name |
|
84 |
$result = $xml->xpath('/guild/members/*'); |
|
85 |
$members=array(); |
|
86 |
$s_gk=array();// multi array sort keys |
|
87 |
$s_nk=array(); |
|
88 |
$key=0; |
|
89 |
while(list(,$item)=each($result)) { |
|
90 |
$members[$key]=array( |
|
91 |
'joined' => intval($item->joined_date), // joined_date is in server tick (ingame date) |
|
92 |
'grade' => (string)$item->grade, |
|
93 |
'name' => (string)$item->name, |
|
94 |
); |
|
95 |
$s_gk[$key]=memberGrade($members[$key]['grade']); |
|
96 |
$s_nk[$key]=$members[$key]['name']; |
|
97 |
$key++; |
|
98 |
} |
|
99 |
// sort members by grade, then by name |
|
100 |
array_multisort($s_gk, SORT_ASC, $s_nk, SORT_ASC, $members); |
|
101 |
$content .= '<h2>Members:'.count($members).'</h2>'; |
|
102 |
$content .= '<table width="500px" border="1" cellpadding="1" cellspacing="0">'; |
|
103 |
$content .= '<thead><tr><td>Name</td><td>Rank</td><td>Joined</td></thead>'; |
|
104 |
foreach($members as $member) { |
|
105 |
$content .= |
|
106 |
'<tr>'. |
|
107 |
'<td>'.$member['name'].'</td>'. |
|
108 |
'<td>'.$member['grade'].'</td>'. |
|
109 |
'<td>'.ryzom_time_txt(ryzom_time_array($member['joined'], '')).'</td>'. |
|
110 |
'</tr>'; |
|
111 |
} |
|
112 |
$content .= '</table>'; |
|
113 | ||
114 |
$content.= '<hr/><a class="ryzom-ui-button" href="?">Back</a>'; |
|
115 |
return $content; |
|
116 |
} |
|
117 | ||
118 |
/** |
|
119 |
* memberGrade will convert memebr grade string value to int for sorting |
|
120 |
* |
|
121 |
* @param string $grade one of 'Leader', 'HighOfficer', 'Officer', 'Member' |
|
122 |
* @return int |
|
123 |
*/ |
|
124 |
function memberGrade($grade) { |
|
125 |
switch(strtolower($grade)) { |
|
126 |
case 'leader': return 0; |
|
127 |
case 'highofficer': return 1; |
|
128 |
case 'officer': return 2; |
|
129 |
case 'member': |
|
130 |
default: return 3; |
|
131 |
} |
|
132 |
} |
|
133 | ||
134 |
function render_character($xml, $key) { |
|
135 |
$content = '<h1>'.$xml->name.'</h1>'; |
|
136 |
$content .= '<ul>'; |
|
137 |
$content .= '<li>Shard: <b>'.$xml->shard.'</b></li>'; |
|
138 |
$content .= '<li>Race: <b>'.$xml->race.'</b></li>'; |
|
139 |
$gender = $xml->gender; |
|
140 |
$content .= '<li>Gender: <b>'.($gender=='f'?'Female':'Male').'</b></li>'; |
|
141 |
$title = ryzom_title_txt($xml->titleid, 'en', $gender); |
|
142 |
$content .= '<li>Title: <b>'.$title.'</b></li>'; |
|
143 |
$content .= '</ul>'; |
|
144 | ||
145 |
$content .= '<h2>Hands</h2>'; |
|
146 |
$result = $xml->xpath('/character/hands/*'); |
|
147 |
while(list( , $item) = each($result)) |
|
148 |
{ |
|
149 |
$content .= ryzom_item_icon_image_from_simplexml($item).' '; |
|
150 |
} |
|
151 | ||
152 |
$content .= '<h2>Equipments</h2>'; |
|
153 |
$result = $xml->xpath('/character/equipments/*'); |
|
154 |
while(list( , $item) = each($result)) |
|
155 |
{ |
|
156 |
$content .= ryzom_item_icon_image_from_simplexml($item).' '; |
|
157 |
} |
|
158 | ||
159 |
if($xml->guild->name != '') { |
|
160 |
$content .= '<h2>Guild</h2>'; |
|
161 |
$content .= '<ul>'; |
|
162 |
$content .= '<li>Name: <b>'.$xml->guild->name.'</b></li>'; |
|
163 |
$guild_icon = ryzom_guild_icon_image($xml->guild->icon, 'b'); |
|
164 |
$guild_icon_small = ryzom_guild_icon_image($xml->guild->icon, 's'); |
|
165 |
$content .= "<li>Guild Icon: $guild_icon $guild_icon_small</li>"; |
|
166 |
$content .= '</ul>'; |
|
167 |
} else { |
|
168 |
$content .= '<h2>No Guild</h2>'; |
|
169 |
} |
|
170 | ||
171 |
// inventories |
|
172 | ||
173 |
$inv_xml = ryzom_character_simplexml($key, 'items'); |
|
174 | ||
175 |
if(isset($inv_xml->inventories->bag)) { |
|
176 |
$content .= '<h2>Bag</h2>'; |
|
177 |
$content .= '<p>(leave the mouse on an item to display its custom text, if any)</p>'; |
|
178 |
$result = $inv_xml->xpath('/items/inventories/bag/*'); |
|
179 |
while(list( , $item) = each($result)) |
|
180 |
{ |
|
181 |
$content .= ryzom_item_icon_image_from_simplexml($item); |
|
182 |
} |
|
183 |
} |
|
184 | ||
185 |
if(isset($inv_xml->item_in_store)) { |
|
186 |
$content .= '<h2>Item in store</h2>'; |
|
187 |
$content .= '<p>(leave the mouse on an item to display its price)</p>'; |
|
188 |
$result = $inv_xml->xpath('/items/item_in_store/*'); |
|
189 |
while(list( , $item) = each($result)) |
|
190 |
{ |
|
191 |
$content .= ryzom_item_icon_image_from_simplexml($item, "Price: ".$item['price']); |
|
192 |
} |
|
193 |
} |
|
194 | ||
195 |
$content.= '<hr/><a class="ryzom-ui-button" href="?">Back</a>'; |
|
196 |
return $content; |
|
197 |
} |
b/examples/example_profile_object.php | ||
---|---|---|
1 |
<?php |
|
2 | ||
3 |
require_once('ryzom_api/ryzom_api.php'); |
|
4 | ||
5 |
if(!empty($_POST['key'])) header('Location: ?ckey='.ryzom_encrypt($_POST['key'])); |
|
6 | ||
7 |
ryzom_ckey_handle(); |
|
8 | ||
9 |
header('Content-Type:text/html; charset=UTF-8'); |
|
10 | ||
11 |
echo ' |
|
12 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
13 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
|
14 |
<head> |
|
15 |
<title>Character Profile</title> |
|
16 |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> |
|
17 |
'.ryzom_render_header().' |
|
18 |
'.ryzom_render_header_www().' |
|
19 |
</head> |
|
20 |
<body> |
|
21 |
'; |
|
22 | ||
23 |
if (isset($_GET['ckey']) && $_GET['ckey'] != '') { |
|
24 | ||
25 |
ryzom_log_start('example_profile'); |
|
26 | ||
27 |
// Display the profile |
|
28 |
$ckey = $_GET['ckey']; |
|
29 |
$key = ryzom_decrypt($ckey); |
|
30 | ||
31 |
$uid=0;$gid=0;$slot=0;$full=false; |
|
32 |
if(ryzom_character_valid_key($key, $uid, $slot, $full)) { |
|
33 |
$xml = ryzom_character_simplexml($key, 'full'); |
|
34 |
} else if(ryzom_guild_valid_key($key, $gid)) { |
|
35 |
$xml = ryzom_guild_simplexml($key); |
|
36 |
} else { |
|
37 |
$xml = ryzom_error('Not valid character or guild key', 'simplexml'); |
|
38 |
} |
|
39 |
if($xml->getName() == 'error') { |
|
40 |
$content = '<div class="error">'.$xml.'</div>'; |
|
41 |
$content.= '<hr/><a class="ryzom-ui-button" href="?">back</a>'; |
|
42 |
die(ryzom_render_www(ryzom_render_window('API error', $content))); |
|
43 |
} |
|
44 | ||
45 |
// Display the profile |
|
46 |
if((string)$xml->getName()=='character') { |
|
47 |
$title='Character profile'; |
|
48 |
$content=render_character($xml,$key); |
|
49 |
} else { |
|
50 |
$title='Guild profile'; |
|
51 |
$content=render_guild($xml); |
|
52 |
} |
|
53 | ||
54 |
ryzom_log_end(); |
|
55 |
} else { |
|
56 |
// Display the form to enter the API Key |
|
57 |
$title = 'Profile'; |
|
58 |
$content = '<form action="" method="post">'; |
|
59 |
$content .= 'Please enter the API Key (guild or character) that you can find on <a href="https://secure.ryzom.com/payment_profile">your profile page</a>:</br>'; |
|
60 |
$content .= '<input type="text" name="key"><br/>'; |
|
61 |
$content .= '<input type="submit" value="Submit" />'; |
|
62 |
$content .= '</form>'; |
|
63 |
} |
|
64 | ||
65 |
echo ryzom_render_www(ryzom_render_window($title, $content)); |
|
66 |
echo '</body></html>'; |
|
67 | ||
68 |
function render_guild($xml){ |
|
69 |
$content = '<h1>'.$xml->name.'</h1>'; |
|
70 | ||
71 |
$content .= '<ul>'; |
|
72 |
$content .= '<li>Created: <b>'.ryzom_time_txt(ryzom_time_array($xml->creation_date, '')).'</b></li>'; |
|
73 |
$content .= '<li>Cult: <b>'.$xml->cult.'</b></li>'; |
|
74 |
$content .= '<li>Civilization: <b>'.$xml->civ.'</b></li>'; |
|
75 | ||
76 |
$guild_icon = ryzom_guild_icon_image($xml->icon, 'b'); |
|
77 |
$guild_icon_small = ryzom_guild_icon_image($xml->icon, 's'); |
|
78 |
$content .= "<li>Guild Icon: $guild_icon $guild_icon_small</li>"; |
|
79 | ||
80 |
$content .= '</ul>'; |
|
81 | ||
82 |
// read the members, then sort them by grade and name |
|
83 |
$result = $xml->xpath('/guild/members/*'); |
|
84 |
$members=array(); |
|
85 |
$s_gk=array();// multi array sort keys |
|
86 |
$s_nk=array(); |
|
87 |
$key=0; |
|
88 |
while(list(,$item)=each($result)) { |
|
89 |
$members[$key]=array( |
|
90 |
'joined' => intval($item->joined_date), // joined_date is in server tick (ingame date) |
|
91 |
'grade' => (string)$item->grade, |
|
92 |
'name' => (string)$item->name, |
|
93 |
); |
|
94 |
$s_gk[$key]=memberGrade($members[$key]['grade']); |
|
95 |
$s_nk[$key]=$members[$key]['name']; |
|
96 |
$key++; |
|
97 |
} |
|
98 |
// sort members by grade, then by name |
|
99 |
array_multisort($s_gk, SORT_ASC, $s_nk, SORT_ASC, $members); |
|
100 |
$content .= '<h2>Members:'.count($members).'</h2>'; |
|
101 |
$content .= '<table width="500px" border="1" cellpadding="1" cellspacing="0">'; |
|
102 |
$content .= '<thead><tr><td>Name</td><td>Rank</td><td>Joined</td></thead>'; |
|
103 |
foreach($members as $member) { |
|
104 |
$content .= |
|
105 |
'<tr>'. |
|
106 |
'<td>'.$member['name'].'</td>'. |
|
107 |
'<td>'.$member['grade'].'</td>'. |
|
108 |
'<td>'.ryzom_time_txt(ryzom_time_array($member['joined'], '')).'</td>'. |
|
109 |
'</tr>'; |
|
110 |
} |
|
111 |
$content .= '</table>'; |
|
112 | ||
113 |
$content.= '<hr/><a class="ryzom-ui-button" href="?">Back</a>'; |
|
114 |
return $content; |
|
115 |
} |
|
116 | ||
117 |
/** |
|
118 |
* memberGrade will convert memebr grade string value to int for sorting |
|
119 |
* |
|
120 |
* @param string $grade one of 'Leader', 'HighOfficer', 'Officer', 'Member' |
|
121 |
* @return int |
|
122 |
*/ |
|
123 |
function memberGrade($grade) { |
|
124 |
switch(strtolower($grade)) { |
|
125 |
case 'leader': return 0; |
|
126 |
case 'highofficer': return 1; |
|
127 |
case 'officer': return 2; |
|
128 |
case 'member': |
|
129 |
default: return 3; |
|
130 |
} |
|
131 |
} |
|
132 | ||
133 |
function render_character($xml, $key) { |
|
134 |
$content = '<h1>'.$xml->name.'</h1>'; |
|
135 |
$content .= '<ul>'; |
|
136 |
$content .= '<li>Shard: <b>'.$xml->shard.'</b></li>'; |
|
137 |
$content .= '<li>Race: <b>'.$xml->race.'</b></li>'; |
|
138 |
$gender = $xml->gender; |
|
139 |
$content .= '<li>Gender: <b>'.($gender=='f'?'Female':'Male').'</b></li>'; |
|
140 |
$title = ryzom_title_txt($xml->titleid, 'en', $gender); |
|
141 |
$content .= '<li>Title: <b>'.$title.'</b></li>'; |
|
142 |
$content .= '</ul>'; |
|
143 | ||
144 |
$content .= '<h2>Hands</h2>'; |
|
145 |
$result = $xml->xpath('/character/hands/*'); |
|
146 |
while(list( , $item) = each($result)) |
|
147 |
{ |
|
148 |
$content .= ryzom_item_icon_image_from_simplexml($item).' '; |
|
149 |
} |
|
150 | ||
151 |
$content .= '<h2>Equipments</h2>'; |
|
152 |
$result = $xml->xpath('/character/equipments/*'); |
|
153 |
while(list( , $item) = each($result)) |
|
154 |
{ |
|
155 |
$content .= ryzom_item_icon_image_from_simplexml($item).' '; |
|
156 |
} |
|
157 | ||
158 |
if($xml->guild->name != '') { |
|
159 |
$content .= '<h2>Guild</h2>'; |
|
160 |
$content .= '<ul>'; |
|
161 |
$content .= '<li>Name: <b>'.$xml->guild->name.'</b></li>'; |
|
162 |
$guild_icon = ryzom_guild_icon_image($xml->guild->icon, 'b'); |
|
163 |
$guild_icon_small = ryzom_guild_icon_image($xml->guild->icon, 's'); |
|
164 |
$content .= "<li>Guild Icon: $guild_icon $guild_icon_small</li>"; |
|
165 |
$content .= '</ul>'; |
|
166 |
} else { |
|
167 |
$content .= '<h2>No Guild</h2>'; |
|
168 |
} |
|
169 | ||
170 |
// inventories |
|
171 | ||
172 |
$inv_xml = ryzom_character_simplexml($key, 'items'); |
|
173 | ||
174 |
if(isset($inv_xml->inventories->bag)) { |
|
175 |
$content .= '<h2>Bag</h2>'; |
|
176 |
$content .= '<p>(leave the mouse on an item to display its custom text, if any)</p>'; |
|
177 |
$result = $inv_xml->xpath('/items/inventories/bag/*'); |
|
178 |
while(list( , $item) = each($result)) |
|
179 |
{ |
|
180 |
$content .= ryzom_item_icon_image_from_simplexml($item); |
|
181 |
} |
|
182 |
} |
|
183 | ||
184 |
if(isset($inv_xml->item_in_store)) { |
|
185 |
$content .= '<h2>Item in store</h2>'; |
|
186 |
$content .= '<p>(leave the mouse on an item to display its price)</p>'; |
|
187 |
$result = $inv_xml->xpath('/items/item_in_store/*'); |
|
188 |
while(list( , $item) = each($result)) |
|
189 |
{ |
|
190 |
$content .= ryzom_item_icon_image_from_simplexml($item, "Price: ".$item['price']); |
|
191 |
} |
|
192 |
} |
|
193 | ||
194 |
$content.= '<hr/><a class="ryzom-ui-button" href="?">Back</a>'; |
|
195 |
return $content; |
|
196 |
} |
b/render/ryzom_ui.css | ||
---|---|---|
1 |
/* Copyright (C) 2009 Winch Gate Property Limited |
|
2 |
* |
|
3 |
* This file is part of ryzom_api. |
|
4 |
* ryzom_api is free software: you can redistribute it and/or modify |
|
5 |
* it under the terms of the GNU Lesser General Public License as published by |
|
6 |
* the Free Software Foundation, either version 3 of the License, or |
|
7 |
* (at your option) any later version. |
|
8 |
* |
|
9 |
* ryzom_api is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU Lesser General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU Lesser General Public License |
|
15 |
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>. |
|
16 |
*/ |
|
17 | ||
18 |
/* |
|
19 |
* Check ryzom_api/functions_render.php for easy php function to render ryzom layout or use this following html: |
|
20 |
* |
|
21 |
<div class="ryzom-ui"> |
|
22 |
<div class="ryzom-ui-tl"><div class="ryzom-ui-tr"> |
|
23 |
<div class="ryzom-ui-t"><!-- title --></div> |
|
24 |
</div></div> |
|
25 |
<div class="ryzom-ui-l"><div class="ryzom-ui-r"><div class="ryzom-ui-m"> |
|
26 |
<div class="ryzom-ui-body"><!-- content --></div> |
|
27 |
</div></div></div> |
|
28 |
<div class="ryzom-ui-bl"><div class="ryzom-ui-br"><div class="ryzom-ui-b"></div></div></div> |
|
29 |
</div><!-- .ryzom-ui --> |
|
30 |
*/ |
|
31 | ||
32 |
.ryzom-ui { |
|
33 |
color: white; |
|
34 |
opacity: .95; |
|
35 |
} |
|
36 |
.ryzom-ui input, .ryzom-ui select { |
|
37 |
border-top: 1px solid #030403; |
|
38 |
border-right: 1px solid #6e7f57; |
|
39 |
border-bottom: 1px solid #889e6c; |
|
40 |
border-left: 1px solid #272d1f; |
|
41 |
background-color: #37402b; |
|
42 |
color: #ddd; |
|
43 |
font-size: 12px; |
|
44 |
margin: 2px 0 5px 0; |
|
45 |
} |
|
46 |
.ryzom-ui input[type=text] { |
|
47 |
width: 100%; |
|
48 |
} |
|
49 |
/* input[type=submit] will make IE6 to ignore whole CSS rule, so cant combine this with .ryzom-ui-button below */ |
|
50 |
input[type=submit] { |
|
51 |
border-bottom: 1px solid #030403; |
|
52 |
border-left: 1px solid #6e7f57; |
|
53 |
border-top: 1px solid #889e6c; |
|
54 |
border-right: 1px solid #272d1f; |
|
55 |
background-color: #435120; |
|
56 |
} |
|
57 |
input.ryzom-ui-button, .ryzom-ui-button { |
|
58 |
border-bottom: 1px solid #030403; |
|
59 |
border-left: 1px solid #6e7f57; |
|
60 |
border-top: 1px solid #889e6c; |
|
61 |
border-right: 1px solid #272d1f; |
|
62 |
background-color: #435120; |
|
63 |
} |
|
64 |
a.ryzom-ui-button, a.ryzom-ui-button:visited { |
|
65 |
color: white; |
|
66 |
padding: 0 .5em; |
|
67 |
text-decoration: none; |
|
68 |
} |
|
69 |
a.ryzom-ui-button:hover { |
|
70 |
background: #536130; |
|
71 |
color: #ddd; |
|
72 |
} |
|
73 |
/* window without title - just borders */ |
|
74 |
.ryzom-ui-tl { |
|
75 |
background-image: url(skin_tl.gif); |
|
76 |
background-repeat: no-repeat; |
|
77 |
background-position: left top; |
|
78 |
width: 100%; height: 8px; |
|
79 |
} |
|
80 |
.ryzom-ui-tr { |
|
81 |
background-image: url(skin_tr.gif); |
|
82 |
background-repeat: no-repeat; |
|
83 |
background-position: right top; |
|
84 |
height: 8px; |
|
85 |
} |
|
86 |
.ryzom-ui-t { |
|
87 |
background-image: url(skin_t.gif); |
|
88 |
background-repeat: repeat-x; |
|
89 |
background-position: left top; |
|
90 |
height: 8px; |
|
91 |
margin: 0 8px; |
|
92 |
} |
|
93 |
/* window with proper header */ |
|
94 |
.ryzom-ui-header .ryzom-ui-tl { |
|
95 |
margin: 0px 0px; |
|
96 |
line-height: 32px; |
|
97 |
background-image: url(skin_header_l.gif); |
|
98 |
background-repeat: no-repeat; |
|
99 |
background-position: left top; |
|
100 |
height: 32px; |
|
101 |
} |
|
102 |
.ryzom-ui-header .ryzom-ui-tr { |
|
103 |
background-image: url(skin_header_r.gif); |
|
104 |
background-repeat: no-repeat; |
|
105 |
background-position: right top; |
|
106 |
height: 32px; |
|
107 |
} |
|
108 |
.ryzom-ui-header .ryzom-ui-t { |
|
109 |
background-image: url(skin_header_m.gif); |
|
110 |
background-repeat: repeat-x; |
|
111 |
background-position: left top; |
|
112 |
margin-left: 12px; |
|
113 |
margin-right: 26px; |
|
114 |
height: 32px; |
|
115 |
text-transform: uppercase; |
|
116 |
color: white; |
|
117 |
} |
|
118 |
/* window body */ |
|
119 |
.ryzom-ui-l { |
|
120 |
background-image: url(skin_l.gif); |
|
121 |
background-position: left top; |
|
122 |
background-repeat: repeat-y; |
|
123 |
width: 100%; |
|
124 |
} |
|
125 |
.ryzom-ui-r { |
|
126 |
background-image: url(skin_r.gif); |
|
127 |
background-position: right top; |
|
128 |
background-repeat: repeat-y; |
|
129 |
width: 100%; |
|
130 |
} |
|
131 |
.ryzom-ui-m { |
|
132 |
margin: 0 8px; |
|
133 |
padding: 8px; |
|
134 |
background-image: url(skin_blank.png); |
|
135 |
background-repeat: repeat; |
|
136 |
} |
|
137 |
.ryzom-ui-body { |
|
138 |
background-image: url(skin_blank_inner.png); |
|
139 |
background-repeat: repeat; |
|
140 |
/* leave 5px room after bottom border */ |
|
141 |
margin: 0px 0 5px 0; |
|
142 |
padding: 10px 10px 5px 10px; |
|
143 |
border-top: 1px solid #030403; |
|
144 |
border-right: 1px solid #6e7f57; |
|
145 |
border-bottom: 1px solid #889e6c; |
|
146 |
border-left: 1px solid #272d1f; |
|
147 |
} |
|
148 |
/* window bottom border */ |
|
149 |
.ryzom-ui-bl { |
|
150 |
background-image: url(skin_bl.gif); |
|
151 |
background-repeat: no-repeat; |
|
152 |
background-position: left top; |
|
153 |
height: 8px; |
|
154 |
} |
|
155 |
.ryzom-ui-br { |
|
156 |
background-image: url(skin_br.gif); |
|
157 |
background-repeat: no-repeat; |
|
158 |
background-position: right top; |
|
159 |
height: 8px; |
|
160 |
} |
|
161 |
.ryzom-ui-b { |
|
162 |
background-image: url(skin_b.gif); |
|
163 |
background-repeat: repeat-x; |
|
164 |
background-position: left top; |
|
165 |
height: 8px; |
|
166 |
margin: 0 8px; |
|
167 |
} |
|
168 |
.ryzom-ui-notice { |
|
169 |
margin: 0px; |
|
170 |
padding: 0px; |
|
171 |
color: #333; |
|
172 |
text-align: center; |
|
173 |
} |
|
174 |
a.ryzom-ui-notice, a.ryzom-ui-notice:visited { |
|
175 |
margin: 0px; |
|
176 |
padding: 0px; |
|
177 |
color: #555; |
|
178 |
padding: 0 .5em; |
|
179 |
text-decoration: underline; |
|
180 |
} |
|
181 |
a.ryzom-ui-notice:hover { |
|
182 |
color: grey; |
|
183 |
} |
b/ryzom_api/client_functions_character.php | ||
---|---|---|
16 | 16 |
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 |
*/ |
18 | 18 | |
19 |
function ryzom_character_url($key, $part='') { |
|
20 |
$params = array('key' => $key) ; |
|
21 |
if(!empty($part)) |
|
22 |
$params['part'] = $part ; |
|
23 | ||
24 |
return ryzom_url('character.php', $params) ; |
|
25 |
} |
|
26 | ||
19 | 27 |
function ryzom_character_simplexml($key, $part='') { |
20 |
$url = ryzom_api_base_url()."character.php?key=$key".($part!=''?"&part=$part":''); |
|
28 | ||
29 |
$url = ryzom_character_url($key, $part) ; |
|
30 | ||
21 | 31 |
$ch = curl_init(); |
22 | 32 |
curl_setopt($ch, CURLOPT_URL, $url); |
23 | 33 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
... | ... | |
28 | 38 |
} |
29 | 39 | |
30 | 40 |
function ryzom_character_xmlgz($key, $part='') { |
31 |
return file_get_contents(ryzom_api_base_url()."character.php?key=$key".($part!=''?"&part=$part":''));
|
|
41 |
return file_get_contents(ryzom_character_url($key, $part));
|
|
32 | 42 |
} |
33 | 43 | |
34 | 44 |
function ryzom_character_valid_key($key, &$uid, &$slot, &$full) { |
... | ... | |
40 | 50 |
return true; |
41 | 51 |
} |
42 | 52 | |
43 |
?> |
|
53 |
?> |
b/ryzom_api/client_functions_guild.php | ||
---|---|---|
24 | 24 |
return true; |
25 | 25 |
} |
26 | 26 | |
27 |
function ryzom_guild_url($key) { |
|
28 |
return $ryzom_url('guild.php', array('key' => $key)) ; |
|
29 |
} |
|
30 | ||
27 | 31 |
function ryzom_guild_simplexml($key) { |
28 |
$url = ryzom_api_base_url()."guild.php?key=$key";
|
|
32 |
$url = ryzom_guild_url($key) ;
|
|
29 | 33 |
$ch = curl_init(); |
30 | 34 |
curl_setopt($ch, CURLOPT_URL, $url); |
31 | 35 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
... | ... | |
36 | 40 |
} |
37 | 41 | |
38 | 42 |
function ryzom_guild_xmlgz($key) { |
39 |
return file_get_contents(ryzom_api_base_url()."guild.php?key=$key");
|
|
43 |
return file_get_contents(ryzom_guild_url($key)) ;
|
|
40 | 44 |
} |
41 | 45 | |
42 |
?> |
|
46 |
?> |
b/ryzom_api/client_functions_guilds.php | ||
---|---|---|
16 | 16 |
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 |
*/ |
18 | 18 | |
19 |
function ryzom_guilds_url($shardid) { |
|
20 |
return ryzom_url('guilds.php', array('shardid', $shardid)) ; |
|
21 |
} |
|
22 | ||
19 | 23 |
function ryzom_guilds_simplexml($shardid) { |
20 |
$url = ryzom_api_base_url()."guilds.php?shardid=$shardid";
|
|
24 |
$url = ryzom_guild_url($shardid) ;
|
|
21 | 25 |
$ch = curl_init(); |
22 | 26 |
curl_setopt($ch, CURLOPT_URL, $url); |
23 | 27 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
... | ... | |
28 | 32 |
} |
29 | 33 | |
30 | 34 |
function ryzom_guilds_xmlgz($shardid) { |
31 |
return file_get_contents(ryzom_api_base_url()."guilds.php?shardid=$shardid");
|
|
35 |
return file_get_contents(ryzom_guild_url('guilds.php', array('shardid' => $shardid)));
|
|
32 | 36 |
} |
33 | 37 | |
34 |
?> |
|
38 |
?> |
b/ryzom_api/client_functions_status.php | ||
---|---|---|
16 | 16 |
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 |
*/ |
18 | 18 | |
19 |
function ryzom_status_url($format) { |
|
20 |
return ryzom_url('status.php', array('format', $format)) ; |
|
21 |
} |
|
22 | ||
19 | 23 |
function ryzom_status_array() { |
20 | 24 |
$xml = ryzom_status_simplexml(); |
21 | 25 |
$array = array(); |
... | ... | |
26 | 30 |
} |
27 | 31 | |
28 | 32 |
function ryzom_status_simplexml() { |
29 |
$xml_txt = file_get_contents(ryzom_api_base_url().'status.php?format=xml');
|
|
33 |
$xml_txt = file_get_contents(ryzom_status_url($status)) ;
|
|
30 | 34 |
return new SimpleXMLElement($xml_txt); |
31 | 35 |
} |
32 | 36 | |
33 |
?> |
|
37 |
?> |
b/ryzom_api/client_functions_time.php | ||
---|---|---|
16 | 16 |
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 |
*/ |
18 | 18 | |
19 |
function ryzom_time_url($shardid) { |
|
20 |
return ryzom_url('time.php', array('shardid', $shardid)) ; |
|
21 |
} |
|
22 | ||
19 | 23 |
// return the tick for a specific shard |
20 | 24 |
function ryzom_time_tick($shardid) { |
21 |
return file_get_contents(ryzom_api_base_url()."time.php?shardid=$shardid");
|
|
25 |
return file_get_contents(ryzom_url($shardid));
|
|
22 | 26 |
} |
23 | 27 | |
24 | 28 |
/** |
... | ... | |
28 | 32 |
return ryzom_time_xml_without_cache($rytime); |
29 | 33 |
} |
30 | 34 | |
31 |
?> |
|
35 |
?> |
b/ryzom_api/client_functions_title.php | ||
---|---|---|
16 | 16 |
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 |
*/ |
18 | 18 | |
19 |
function ryzom_title_url($titleid, $langid, $gender, $format) { |
|
20 |
$params = array |
|
21 |
( 'titleid' => $titleid |
|
22 |
, 'langid' => $langid |
|
23 |
) ; |
|
24 | ||
25 |
if(!empty($gender)) |
|
26 |
$params['gender'] = $gender ; |
|
27 | ||
28 |
return ryzom_url('title.php', $params) ; |
|
29 |
} |
|
30 | ||
19 | 31 |
function ryzom_title_simplexml($titleid, $langid) { |
20 |
return simplexml_load_string(file_get_contents(ryzom_api_base_url()."title.php?titleid=$titleid&langid=$langid&format=xml"));
|
|
32 |
return simplexml_load_string(file_get_contents(ryzom_title_url($titleid, $langid, null, 'xml'))) ;
|
|
21 | 33 |
} |
22 | 34 | |
23 | 35 |
function ryzom_title_txt($titleid, $langid, $gender) { |
24 |
return file_get_contents(ryzom_api_base_url()."title.php?titleid=$titleid&langid=$langid&gender=$gender&format=txt");
|
|
36 |
return file_get_contents(ryzom_title_url($titleid, $langid, $gender, 'txt'));
|
|
25 | 37 |
} |
26 | 38 | |
27 |
?> |
|
39 |
?> |
b/ryzom_api/functions_banner.php | ||
---|---|---|
16 | 16 |
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 |
*/ |
18 | 18 | |
19 |
require_once 'ryzom_url.php' ; |
|
20 | ||
19 | 21 |
function ryzom_banner_image($ckey, $langid, $width=500) { |
20 | 22 |
return '<img src="'.ryzom_banner_url($ckey, $langid, $width).'"/>'; |
21 | 23 |
} |
22 | 24 | |
23 | 25 |
function ryzom_banner_url($ckey, $langid, $width=500) { |
24 |
return ryzom_api_base_url()."banner.php?ckey=$ckey&langid=$langid&w=$width"; |
|
26 |
return ryzom_url |
|
27 |
( 'banner.php', array |
|
28 |
( 'ckey' => $ckey |
|
29 |
, 'langid '=> $langid |
|
30 |
, 'w' => $width |
|
31 |
) |
|
32 |
) ; |
|
25 | 33 |
} |
26 | 34 | |
27 |
?> |
|
35 |
?> |
b/ryzom_api/functions_common.php | ||
---|---|---|
38 | 38 |
} |
39 | 39 |
} |
40 | 40 | |
41 |
function ryzom_api_base_url() { |
|
42 |
return 'http://atys.ryzom.com/api/'; |
|
43 |
} |
|
44 | ||
45 | 41 |
function ryzom_display_xml_header() { |
46 | 42 |
header('Content-Type: application/xml; charset=UTF-8'); |
47 | 43 |
} |
... | ... | |
114 | 110 |
if($ryzom_fn!==false) file_put_contents($ryzom_fn, date("Y-m-d H:i:s") .' '. $_SERVER['REMOTE_ADDR'] .' '. $_SERVER['REQUEST_URI'] ." $str\n", FILE_APPEND); |
115 | 111 |
} |
116 | 112 | |
117 |
?> |
|
113 |
?> |
b/ryzom_api/functions_guild_icon.php | ||
---|---|---|
21 | 21 |
} |
22 | 22 | |
23 | 23 |
function ryzom_guild_icon_url($icon, $size) { |
24 |
return ryzom_api_base_url()."guild_icon.php?icon=$icon&size=$size"; |
|
24 |
return ryzom_url('guild_icon.php?' |
|
25 |
, array('icon' => $icon, 'size' => $size)) ; |
|
25 | 26 |
} |
26 | 27 | |
27 |
?> |
|
28 |
?> |
b/ryzom_api/functions_item_icon.php | ||
---|---|---|
21 | 21 |
} |
22 | 22 | |
23 | 23 |
function ryzom_item_icon_url($sheetid, $c=-1, $q=-1, $s=-1, $sap=-1, $destroyed=false) { |
24 |
return ryzom_api_base_url()."item_icon.php?sheetid=$sheetid&c=$c&q=$q&s=$s&sap=$sap".($destroyed?'&destroyed=1':''); |
|
24 |
$params = array |
|
25 |
( 'sheetid' => $sheetid |
|
26 |
, 'c' => $c |
|
27 |
, 'q' => $q |
|
28 |
, 's' => $s |
|
29 |
, 'sap' => $sap |
|
30 |
) ; |
|
31 | ||
32 |
if($destroyed) |
|
33 |
$params['destroyed'] = 1 ; |
|
34 | ||
35 |
return ryzom_url('item_icon.php', $params) ; |
|
25 | 36 |
} |
26 | 37 | |
27 | 38 |
function ryzom_item_icon_image_from_simplexml($item, $add_text='') { |
... | ... | |
39 | 50 |
return "<img title=\"$text\" src=\"$url\"/> "; |
40 | 51 |
} |
41 | 52 | |
42 |
?> |
|
53 |
?> |
b/ryzom_api/functions_render.php | ||
---|---|---|
18 | 18 | |
19 | 19 |
// Call this inside the <head> part if you wan to use ryzom_render_window() |
20 | 20 |
function ryzom_render_header() { |
21 |
return '<link type="text/css" href="ryzom_api/render/ryzom_ui.css" rel="stylesheet" media="all" />';
|
|
21 |
return '<link type="text/css" href="render/ryzom_ui.css" rel="stylesheet" media="all" />'; |
|
22 | 22 |
} |
23 | 23 | |
24 | 24 |
// Render a Ryzom style window |
... | ... | |
68 | 68 |
'; |
69 | 69 |
} |
70 | 70 | |
71 |
?> |
|
71 |
?> |
/dev/null | ||
---|---|---|
1 |
/* Copyright (C) 2009 Winch Gate Property Limited |
|
2 |
* |
|
3 |
* This file is part of ryzom_api. |
|
4 |
* ryzom_api is free software: you can redistribute it and/or modify |
|
5 |
* it under the terms of the GNU Lesser General Public License as published by |
|
6 |
* the Free Software Foundation, either version 3 of the License, or |
|
7 |
* (at your option) any later version. |
|
8 |
* |
|
9 |
* ryzom_api is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU Lesser General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU Lesser General Public License |
|
15 |
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>. |
|
16 |
*/ |
|
17 | ||
18 |
/* |
|
19 |
* Check ryzom_api/functions_render.php for easy php function to render ryzom layout or use this following html: |
|
20 |
* |
|
21 |
<div class="ryzom-ui"> |
|
22 |
<div class="ryzom-ui-tl"><div class="ryzom-ui-tr"> |
|
23 |
<div class="ryzom-ui-t"><!-- title --></div> |
|
24 |
</div></div> |
|
25 |
<div class="ryzom-ui-l"><div class="ryzom-ui-r"><div class="ryzom-ui-m"> |
|
26 |
<div class="ryzom-ui-body"><!-- content --></div> |
|
27 |
</div></div></div> |
|
28 |
<div class="ryzom-ui-bl"><div class="ryzom-ui-br"><div class="ryzom-ui-b"></div></div></div> |
|
29 |
</div><!-- .ryzom-ui --> |
|
30 |
*/ |
|
31 | ||
32 |
.ryzom-ui { |
|
33 |
color: white; |
|
34 |
opacity: .95; |
|
35 |
} |
|
36 |
.ryzom-ui input, .ryzom-ui select { |
|
37 |
border-top: 1px solid #030403; |
|
38 |
border-right: 1px solid #6e7f57; |
|
39 |
border-bottom: 1px solid #889e6c; |
|
40 |
border-left: 1px solid #272d1f; |
|
41 |
background-color: #37402b; |
|
42 |
color: #ddd; |
|
43 |
font-size: 12px; |
|
44 |
margin: 2px 0 5px 0; |
|
45 |
} |
|
46 |
.ryzom-ui input[type=text] { |
|
47 |
width: 100%; |
|
48 |
} |
|
49 |
/* input[type=submit] will make IE6 to ignore whole CSS rule, so cant combine this with .ryzom-ui-button below */ |
|
50 |
input[type=submit] { |
|
51 |
border-bottom: 1px solid #030403; |
|
52 |
border-left: 1px solid #6e7f57; |
|
53 |
border-top: 1px solid #889e6c; |
|
54 |
border-right: 1px solid #272d1f; |
|
55 |
background-color: #435120; |
|
56 |
} |
|
57 |
input.ryzom-ui-button, .ryzom-ui-button { |
|
58 |
border-bottom: 1px solid #030403; |
|
59 |
border-left: 1px solid #6e7f57; |
|
60 |
border-top: 1px solid #889e6c; |
|
61 |
border-right: 1px solid #272d1f; |
|
62 |
background-color: #435120; |
|
63 |
} |
|
64 |
a.ryzom-ui-button, a.ryzom-ui-button:visited { |
|
65 |
color: white; |
|
66 |
padding: 0 .5em; |
|
67 |
text-decoration: none; |
|
68 |
} |
|
69 |
a.ryzom-ui-button:hover { |
|
70 |
background: #536130; |
|
71 |
color: #ddd; |
|
72 |
} |
|
73 |
/* window without title - just borders */ |
|
74 |
.ryzom-ui-tl { |
|
75 |
background-image: url(skin_tl.gif); |
|
76 |
background-repeat: no-repeat; |
|
77 |
background-position: left top; |
|
78 |
width: 100%; height: 8px; |
|
79 |
} |
|
80 |
.ryzom-ui-tr { |
|
81 |
background-image: url(skin_tr.gif); |
|
82 |
background-repeat: no-repeat; |
|
83 |
background-position: right top; |
|
84 |
height: 8px; |
|
85 |
} |
|
86 |
.ryzom-ui-t { |
|
87 |
background-image: url(skin_t.gif); |
|
88 |
background-repeat: repeat-x; |
|
89 |
background-position: left top; |
|
90 |
height: 8px; |
|
91 |
margin: 0 8px; |
|
92 |
} |
|
93 |
/* window with proper header */ |
|
94 |
.ryzom-ui-header .ryzom-ui-tl { |
|
95 |
margin: 0px 0px; |
|
96 |
line-height: 32px; |
|
97 |
background-image: url(skin_header_l.gif); |
|
98 |
background-repeat: no-repeat; |
|
99 |
background-position: left top; |
|
100 |
height: 32px; |
|
101 |
} |
|
102 |
.ryzom-ui-header .ryzom-ui-tr { |
|
103 |
background-image: url(skin_header_r.gif); |
|
104 |
background-repeat: no-repeat; |
|
105 |
background-position: right top; |
|
106 |
height: 32px; |
|
107 |
} |
|
108 |
.ryzom-ui-header .ryzom-ui-t { |
|
109 |
background-image: url(skin_header_m.gif); |
|
110 |
background-repeat: repeat-x; |
|
111 |
background-position: left top; |
|
112 |
margin-left: 12px; |
|
113 |
margin-right: 26px; |
|
114 |
height: 32px; |
|
115 |
text-transform: uppercase; |
|
116 |
color: white; |
|
117 |
} |
|
118 |
/* window body */ |
|
119 |
.ryzom-ui-l { |
|
120 |
background-image: url(skin_l.gif); |
|
121 |
background-position: left top; |
|
122 |
background-repeat: repeat-y; |
|
123 |
width: 100%; |
|
124 |
} |
|
125 |
.ryzom-ui-r { |
|
126 |
background-image: url(skin_r.gif); |
|
127 |
background-position: right top; |
|
128 |
background-repeat: repeat-y; |
|
129 |
width: 100%; |
|
130 |
} |
|
131 |
.ryzom-ui-m { |
|
132 |
margin: 0 8px; |
|
133 |
padding: 8px; |
|
134 |
background-image: url(skin_blank.png); |
|
135 |
background-repeat: repeat; |
|
136 |
} |
|
137 |
.ryzom-ui-body { |
|
138 |
background-image: url(skin_blank_inner.png); |
|
139 |
background-repeat: repeat; |
|
140 |
/* leave 5px room after bottom border */ |
|
141 |
margin: 0px 0 5px 0; |
|
142 |
padding: 10px 10px 5px 10px; |
|
143 |
border-top: 1px solid #030403; |
|
144 |
border-right: 1px solid #6e7f57; |
|
145 |
border-bottom: 1px solid #889e6c; |
|
146 |
border-left: 1px solid #272d1f; |
|
147 |
} |
|
148 |
/* window bottom border */ |
|
149 |
.ryzom-ui-bl { |
|
150 |
background-image: url(skin_bl.gif); |
|
151 |
background-repeat: no-repeat; |
|
152 |
background-position: left top; |
|
153 |
height: 8px; |
|
154 |
} |
|
155 |
.ryzom-ui-br { |
|
156 |
background-image: url(skin_br.gif); |
|
157 |
background-repeat: no-repeat; |
|
158 |
background-position: right top; |
|
159 |
height: 8px; |
|
160 |
} |
|
161 |
.ryzom-ui-b { |
|
162 |
background-image: url(skin_b.gif); |
|
163 |
background-repeat: repeat-x; |
|
164 |
background-position: left top; |
|
165 |
height: 8px; |
|
166 |
margin: 0 8px; |
|
167 |
} |
|
168 |
.ryzom-ui-notice { |
|
169 |
margin: 0px; |
|
170 |
padding: 0px; |
|
171 |
color: #333; |
|
172 |
text-align: center; |
|
173 |
} |
|
174 |
a.ryzom-ui-notice, a.ryzom-ui-notice:visited { |
|
175 |
margin: 0px; |
|
176 |
padding: 0px; |
|
177 |
color: #555; |
|
178 |
padding: 0 .5em; |
|
179 |
text-decoration: underline; |
|
180 |
} |
|
181 |
a.ryzom-ui-notice:hover { |
|
182 |
color: grey; |
|
183 |
} |
b/ryzom_api/ryzom_concept.php | ||
---|---|---|
1 |
<?php |
|
2 |
/* Copyright (C) 2009 Winch Gate Property Limited |
|
3 |
* |
|
4 |
* This file is part of ryzom_api. |
|
5 |
* ryzom_api is free software: you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU Lesser General Public License as published by |
|
7 |
* the Free Software Foundation, either version 3 of the License, or |
|
8 |
* (at your option) any later version. |
|
9 |
* |
|
10 |
* ryzom_api is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU Lesser General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU Lesser General Public License |
|
16 |
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>. |
|
17 |
*/ |
|
18 | ||
19 |
class ryzom_server |
|
20 |
{ |
|
21 |
public $hostname ; |
|
22 |
public $pathname ; |
|
23 |
} |
|
24 | ||
25 |
class ryzom_concept_state |
|
26 |
{ |
|
27 |
public $class ; |
|
28 |
public $scriptname ; |
|
29 |
public $attributes ; |
|
30 |
public $formats ; |
|
31 | ||
32 |
protected $_config ; |
|
33 | ||
34 |
public function __construct(registry $config, $name) |
|
35 |
{ |
|
36 |
$this->class = $name ; |
|
37 |
$this->_feed($config) ; |
|
38 |
} |
|
39 | ||
40 |
protected function _feed($config) |
|
41 |
{ |
|
42 |
$config->cd('/concepts/' . $this->class) ; |
|
43 | ||
44 |
$this->attributes = $config['attributes'] ; |
|
45 |
$this->scriptname = isset($config['scriptname']) |
|
46 |
? $config['scriptname'] : "{$this->class}.php" ; |
|
47 | ||
48 |
$this->formats = array('url' => true, 'raw' => true) ; |
|
49 |
if(isset($config['formats'])) |
|
50 |
$config->cd('formats') ; |
|
51 |
foreach($config->childs() as $format) |
|
52 |
$this->formats[$format] = $config[$format] ; |
|
53 |
} |
|
54 |
} |
|
55 | ||
56 |
class ryzom_concept |
|
57 |
{ |
|
58 |
protected $_server ; |
|
59 |
protected $_state ; |
|
60 |
protected $_attributes = array() ; |
|
61 | ||
62 |
public function __construct(ryzom_server $server, ryzom_concept_state $state) |
|
63 |
{ |
|
64 |
$this->_server = $server ; |
|
65 |
$this->_state = $state ; |
|
66 |
} |
|
67 | ||
68 |
public function __invoke() |
|
69 |
{ |
|
70 |
$values = func_get_args() ; |
|
71 |
$attributes = $this->_state->attributes ; |
|
72 | ||
73 |
// Todo handle default values for function arguments |
|
74 |
$idx = 0 ; |
|
75 |
$provided = count($values) ; |
|
76 |
foreach($attributes as $name => $default) |
|
77 |
{ |
|
78 |
$this->_attributes[$name] = $idx < $provided |
|
79 |
? $values[$idx] : $default ; |
|
80 |
$idx++ ; |
|
81 |
} |
|
82 |
} |
|
83 | ||
84 |
public function & __get($name) |
|
85 |
{ |
|
86 |
if(isset($this->_state->$name)) |
|
87 |
return $this->_state->$name ; |
|
88 |
else |
|
89 |
throw new exception(sprintf('No attribute \'%s\'.', $name)) ; |
|
90 |
} |
|
91 | ||
92 |
public function support($format) |
|
93 |
{ |
|
94 |
return isset($this->_state->formats[$format]) |
|
95 |
&& $this->_state->formats[$format] ; |
|
96 |
} |
|
97 | ||
98 |
public function as_url() |
|
99 |
{ |
|
100 |
if(!$this->support('url')) |
|
101 |
return $this->_not_supported('url') ; |
|
102 | ||
103 |
return (string) http_url |
|
104 |
( $this->_server->hostname |
|
105 |
, $this->_server->pathname |