56 lines
1.1 KiB
PHP
56 lines
1.1 KiB
PHP
<?php
|
||
namespace Westdc\Metadata\Handle;
|
||
|
||
use Sookon\Helpers\PDO as Pdo;
|
||
use Sookon\Helpers\Config;
|
||
use Sookon\Helpers\View as view;
|
||
use Sookon\Mail\Mail;
|
||
use Sookon\Search\Search;
|
||
use Zend\EventManager\EventInterface;
|
||
use Westdc\Metadata\Event\OutlinkEvent as Event;
|
||
|
||
class OutlinkHandle implements Event
|
||
{
|
||
private $db;
|
||
private $config;
|
||
|
||
function __construct($db = NULL)
|
||
{
|
||
$this->db = new Pdo();
|
||
|
||
$this->config = Config::get();
|
||
}
|
||
|
||
//检查字段
|
||
public function checkParam(EventInterface $e){
|
||
|
||
$data = $e->getParam('data');
|
||
|
||
if(!is_array($data))
|
||
{
|
||
return "参数错误";
|
||
}
|
||
|
||
if(empty($data['url']))
|
||
{
|
||
return "请填写要跳转的目标地址";
|
||
}
|
||
|
||
if(!preg_match("/(http|ftp|https):\/\/(.*)/i",$data['url']))
|
||
{
|
||
return "请填写完整的url,必须包含协议名称,例如 https://www.google.com.hk";
|
||
}
|
||
|
||
return true;
|
||
}//checkParam
|
||
|
||
//处理字段
|
||
public function processData(EventInterface $e)
|
||
{
|
||
$data = $e->getParam('data');
|
||
|
||
return $data;
|
||
}
|
||
|
||
|
||
} |