Widget
What`s widget platform
A widget is a little application that you put on webpage to get specific information or functionality like iGoogle, MyYahoo, Netvibes. But it`s magically works with weblog, because all widget not only works for blog`s owners but viewers, therefore it makes game, informations sharing, interacting widget possible.
CatFan is providing widget platform making weblog more funny and functional. It`s easy to build widget just using some PHP, JavaScript, CSS and HTML technologies.
Introduction
Building widget is extremely easy and fast here. All widget is only a php files processing information and displaying HTML codes. It call method if it needs.
This a flickr widget demonstrational code:
/**
Class flickr
*/
class flickr
{
/**
$UserInf['UserID'] = User`s id.
$UserInf['UserName'] = User name.
$Data is a array for widget to store data.
$POST is the processed $_POST for security when the setting form is posted or the ajax request is called.
You can use "$Text=langinit(__CLASS__)" to initialize the $Text variable for displaying the text according by the user preferred language .
*/
//This is the text variable for displaying multilingual words. (Optional)
public $Text=array(
'hi'=>array(
'en'=>'hi',
'zh'=>'你好',
'zh-tr'=>'您好'),
);
//It will be run when the widget is added at the first time. (Optional)
function init($Data)
{
//widget initialization
$Data['text']='this is a example';
return $Data;
}
//It uses to display the HTML code
function display($Data,$UserInf)
{
//Display HTML ,Javascript ,CSS code.
echo '$lt;span>hi '.$UserInf['UserName'].'!</span>';
echo $Data['text'];
}
//Display the setting.
function set($Data)
{
echo '<label>Title</label>
<input type="text" name="Title" value="'.$Data['Title'].'" />
}
//Process the setting data.
function update($Data,$POST)
{
$Data['Title']=$POST['Title'];
$Data['count']=$POST['count'];
$Data['display']=$POST['display'];
return $Data;
}
//It will be run when ajax request is called.
function ajax($Data,$POST,$UserInf)
{
}
}
Warning!
All the development documents and widget system is incomplete. If you want to develop a better widget please contact catfan.me(at)gmail.com to discuss.