[Phpfreechat-svn] SF.net SVN: phpfreechat: [806] trunk/demo
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-10-04 01:48:42
|
Revision: 806 http://svn.sourceforge.net/phpfreechat/?rev=806&view=rev Author: kerphi Date: 2006-09-30 15:47:11 -0700 (Sat, 30 Sep 2006) Log Message: ----------- [en] Add demo50 which shows how to use user metadata : add avatar (images) to each connected users. [40min] [fr] Ajout de la demo50 qui montre comment utiliser les m?\195?\169tadonn?\195?\169es utilisateurs : ajout d'un avatar (image) dans la boite whois de chaque utilisateur connect?\195?\169. [40min] Modified Paths: -------------- trunk/demo/index.php Added Paths: ----------- trunk/demo/demo50_customized_usermetadata.php trunk/demo/demo50_data/ trunk/demo/demo50_data/avatar1.jpg trunk/demo/demo50_data/avatar2.jpg trunk/demo/demo50_data/avatar3.jpg trunk/demo/demo50_data/avatar4.jpg trunk/demo/demo50_data/avatar5.jpg trunk/demo/demo50_data/avatar6.jpg trunk/demo/demo50_data/avatar7.jpg trunk/demo/demo50_data/avatar8.jpg trunk/demo/demo50_data/avatar9.jpg trunk/demo/demo50_data/mytheme/ trunk/demo/demo50_data/mytheme/customize.js trunk/demo/demo50_data/mytheme/style.css Added: trunk/demo/demo50_customized_usermetadata.php =================================================================== --- trunk/demo/demo50_customized_usermetadata.php (rev 0) +++ trunk/demo/demo50_customized_usermetadata.php 2006-09-30 22:47:11 UTC (rev 806) @@ -0,0 +1,40 @@ +<?php + +require_once dirname(__FILE__)."/../src/phpfreechat.class.php"; + +$params["serverid"] = md5(__FILE__); // calculate a unique id for this chat +$params["title"] = "A chat which shows how to use user metadata : add avatar (images) to each connected users"; +$params["nick"] = "guest".rand(1,1000); +$params["nickmeta"] = array("avatar" => "demo50_data/avatar".rand(1,10).".jpg"); +$params["themepath"] = dirname(__FILE__)."/demo50_data"; +$params["theme"] = "mytheme"; +$chat = new phpFreeChat( $params ); + +?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html> + <head> + <meta http-equiv="content-type" content="text/html; charset=utf-8" /> + <title>phpFreeChat demo</title> + + <?php $chat->printJavascript(); ?> + <?php $chat->printStyle(); ?> + + </head> + + <body> + <?php $chat->printChat(); ?> + +<?php + // print the current file + echo "<h2>The source code</h2>"; + $filename = __FILE__; + echo "<p><code>".$filename."</code></p>"; + echo "<pre style=\"margin: 0 50px 0 50px; padding: 10px; background-color: #DDD;\">"; + $content = file_get_contents($filename); + echo htmlentities($content); + echo "</pre>"; +?> + + </body> +</html> \ No newline at end of file Added: trunk/demo/demo50_data/avatar1.jpg =================================================================== (Binary files differ) Property changes on: trunk/demo/demo50_data/avatar1.jpg ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/demo/demo50_data/avatar2.jpg =================================================================== (Binary files differ) Property changes on: trunk/demo/demo50_data/avatar2.jpg ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/demo/demo50_data/avatar3.jpg =================================================================== (Binary files differ) Property changes on: trunk/demo/demo50_data/avatar3.jpg ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/demo/demo50_data/avatar4.jpg =================================================================== (Binary files differ) Property changes on: trunk/demo/demo50_data/avatar4.jpg ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/demo/demo50_data/avatar5.jpg =================================================================== (Binary files differ) Property changes on: trunk/demo/demo50_data/avatar5.jpg ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/demo/demo50_data/avatar6.jpg =================================================================== (Binary files differ) Property changes on: trunk/demo/demo50_data/avatar6.jpg ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/demo/demo50_data/avatar7.jpg =================================================================== (Binary files differ) Property changes on: trunk/demo/demo50_data/avatar7.jpg ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/demo/demo50_data/avatar8.jpg =================================================================== (Binary files differ) Property changes on: trunk/demo/demo50_data/avatar8.jpg ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/demo/demo50_data/avatar9.jpg =================================================================== (Binary files differ) Property changes on: trunk/demo/demo50_data/avatar9.jpg ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/demo/demo50_data/mytheme/customize.js =================================================================== --- trunk/demo/demo50_data/mytheme/customize.js (rev 0) +++ trunk/demo/demo50_data/mytheme/customize.js 2006-09-30 22:47:11 UTC (rev 806) @@ -0,0 +1,99 @@ +pfcClient.prototype.updateNickWhoisBox = function(nickid) + { + var div = document.createElement('div'); + div.setAttribute('class', 'pfc_nickwhois'); + div.setAttribute('className', 'pfc_nickwhois'); // for IE6 + + var ul = document.createElement('ul'); + div.appendChild(ul); + + // add the close button + var li = document.createElement('li'); + li.setAttribute('class', 'pfc_nickwhois_close'); + li.setAttribute('className', 'pfc_nickwhois_close'); // for IE6 + ul.appendChild(li); + var a = document.createElement('a'); + a.setAttribute('href', ''); + a.pfc_parent = div; + a.onclick = function(evt){ + this.pfc_parent.style.display = 'none'; + return false; + } + var img = document.createElement('img'); + img.setAttribute('src', this.res.getFileUrl('images/close-whoisbox.gif')); + img.alt = document.createTextNode(this.res.getLabel('Close')); + a.appendChild(img); + li.appendChild(a); + + // add the privmsg link (do not add it if this button is yourself) + if (pfc.getUserMeta(nickid,'nick') != this.nickname) + { + var li = document.createElement('li'); + li.setAttribute('class', 'pfc_nickwhois_pv'); + li.setAttribute('className', 'pfc_nickwhois_pv'); // for IE6 + ul.appendChild(li); + var a = document.createElement('a'); + a.setAttribute('href', ''); + a.pfc_nickid = nickid; + a.pfc_parent = div; + a.onclick = function(evt){ + var nick = pfc.getUserMeta(this.pfc_nickid,'nick'); + pfc.sendRequest('/privmsg', nick); + this.pfc_parent.style.display = 'none'; + return false; + } + var img = document.createElement('img'); + img.setAttribute('src', this.res.getFileUrl('images/openpv.gif')); + img.alt = document.createTextNode(this.res.getLabel('Private message')); + a.appendChild(img); + a.appendChild(document.createTextNode(this.res.getLabel('Private message'))); + li.appendChild(a); + } + + + // add the whois information table + var table = document.createElement('table'); +// table.setAttribute('cellspacing',0); +// table.setAttribute('cellpadding',0); +// table.setAttribute('border',0); + var tbody = document.createElement('tbody'); + table.appendChild(tbody); + var um = this.getAllUserMeta(nickid); + var um_keys = um.keys(); + var msg = ''; + for (var i=0; i<um_keys.length; i++) + { + var k = um_keys[i]; + var v = um[k]; + if (v && k != 'nickid' + && k != 'floodtime' + && k != 'flood_nbmsg' + && k != 'flood_nbchar' + && k != 'avatar' + ) + { + var tr = document.createElement('tr'); + var td1 = document.createElement('td'); + td1.setAttribute('class', 'pfc_nickwhois_c1'); + td1.setAttribute('className', 'pfc_nickwhois_c1'); // for IE6 + var td2 = document.createElement('td'); + td2.setAttribute('class', 'pfc_nickwhois_c2'); + td2.setAttribute('className', 'pfc_nickwhois_c2'); // for IE6 + td1.appendChild(document.createTextNode(k)); + td2.appendChild(document.createTextNode(v)); + tr.appendChild(td1); + tr.appendChild(td2); + tbody.appendChild(tr); + } + } + div.appendChild(table); + + // append the avatar image + var img = document.createElement('img'); + img.setAttribute('src',this.getUserMeta(nickid,'avatar')); + img.setAttribute('class', 'pfc_nickwhois_avatar'); + img.setAttribute('className', 'pfc_nickwhois_avatar'); // for IE6 + div.appendChild(img); + + this.nickwhoisbox[nickid] = div; + } \ No newline at end of file Added: trunk/demo/demo50_data/mytheme/style.css =================================================================== --- trunk/demo/demo50_data/mytheme/style.css (rev 0) +++ trunk/demo/demo50_data/mytheme/style.css 2006-09-30 22:47:11 UTC (rev 806) @@ -0,0 +1,3 @@ +img.pfc_nickwhois_avatar { + margin: 10px; +} \ No newline at end of file Modified: trunk/demo/index.php =================================================================== --- trunk/demo/index.php 2006-09-30 22:44:49 UTC (rev 805) +++ trunk/demo/index.php 2006-09-30 22:47:11 UTC (rev 806) @@ -74,6 +74,7 @@ <li><a href="demo35_shared_memory.php">demo35 - demo which show how to use the shared memory container</a> (not yet working)</li> <li><a href="demo43_change_the_nicknames_colors.php">demo43 - demo which show how to change the nicknames automatic colors</a></li> + <li><a href="demo50_customized_usermetadata.php">demo50 - demo which shows how to use user metadata : add avatar (images) to each connected users</a></li> </ul> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |