westdc-zf1/vendor/Westdc/MetadataSync/Handle/OutlinkHandle.php

56 lines
1.1 KiB
PHP
Raw Normal View History

2014-03-07 09:51:31 +00:00
<?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;
}
}