复制代码 代码如下:
class operationLimit
// operating limit. When no user login or is not this user
{
/* for limit the user operat at post.
* @author:xiaoai 8.12 2011
*/
static $limitObject;
public function __construct() {}
// when call the function but does not exist
public static function getObject()
{
if( !(self::$limitObject instanceof self))
self::$limitObject = new self;
return self::$limitObject ;
}
protected function setLimit() {}
public function getReadA($postName)
{
return '<a herf=/'http://foodstory.me/post/'.$postname.
'.php/' class=/'readmoreLink/'>readmore</a>';
}
}
class operationUnlimit extends operationLimit
// when is this user
{
public static function getObject()
{
if( !(self::$limitObject instanceof self))
self::$limitObject = new self;
return self::$limitObject ;
}
public function getUpdateA($name)
{
return '<a href=/'http://foodstory.me/post/'.$name.
'.php?do=update/' id=/''.$name.'/' >update</a>';
}
public function getDelectA($name)
{
return '<a href=/'javascript:delectPOST('.$name
.');/' id=/'delectPOST/' >delect</a>';
}
}
class LimitFactory
{
public static function getLimitObject($userStatus)
// $userStatus = $session->get_status();
{
switch ( $userStatus )
{
case 0:
return operationLimit::getObject();
case 1:
return operationUnlimit::getObject();
default:
return limit::getObject();
}
}
}
复制代码 代码如下:
$limitObj = LimitFactory::getLimitObject($session->get_status());
echo $limitObj->getReadA('hi');
echo $limitObj->getDelectA('hah');
新闻热点
疑难解答