本文整理汇总了PHP中Zend_Filter_Input::setData方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Filter_Input::setData方法的具体用法?PHP Zend_Filter_Input::setData怎么用?PHP Zend_Filter_Input::setData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Filter_Input
的用法示例。
在下文中一共展示了Zend_Filter_Input::setData方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createDataInput
/**
* @return Zend_Filter_Input
*/
public function createDataInput($data)
{
$filters = array('name' => 'StringTrim', 'group_id' => 'Digits');
$validators = array();
if (!($isGroup = $data['type'] == 'group')) {
$filters['url'] = 'StringTrim';
$validators['url'] = array(new UrlValidator(), new UrlDuplicateValidator($this, @$data['id']));
}
$input = new Zend_Filter_Input($filters, $validators);
$input->setData($data);
return $input;
}
示例2: testValidatorIsValid
public function testValidatorIsValid()
{
$data = array('field1' => 'abc123', 'field2' => 'abcdef');
$validators = array('field1' => 'alpha', 'field2' => 'alpha');
$input = new Zend_Filter_Input(null, $validators, $data);
$this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false');
$this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true');
$this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false');
$this->assertTrue($input->hasValid(), 'Expected hasValid() to return true');
$this->assertFalse($input->isValid());
$this->assertFalse($input->isValid('field1'));
$this->assertTrue($input->isValid('field2'));
$input->setData(array('field2' => 'abcdef'));
$this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false');
$this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false');
$this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false');
$this->assertTrue($input->hasValid(), 'Expected hasValid() to return true');
$this->assertTrue($input->isValid());
$this->assertFalse($input->isValid('field1'));
$this->assertTrue($input->isValid('field2'));
}
示例3: VerifyStream
/**
*
* @param string $UserID
* @param string $StreamID
* @return boolean
*/
public function VerifyStream($UserID, $StreamID)
{
//check if UserID and StreamID are vaild
//
//return false;
//if true return guid else return INVALID_CREDENTIALS
$data = array('UserName' => $UserID, 'streamid' => $StreamID);
$filters = array('UserName' => array('HtmlEntities', 'StringTrim', 'StripTags'), 'streamid' => array('HtmlEntities', 'StringTrim', 'StripTags'));
$validators = array('UserName' => array('NotEmpty'), 'streamid' => array('NotEmpty'));
$input = new Zend_Filter_Input($filters, $validators);
$input->setData($data);
if ($input->isValid()) {
$q = Doctrine_Query::create()->from('Webteam_Model_Video r')->where('r.StreamID = ?', $input->streamid)->addWhere('r.UserName = ?', $input->UserName);
$result = $q->fetchArray();
if (count($result) >= 1) {
return true;
} else {
return false;
}
} else {
return false;
//returns false if input is not valid
}
}
示例4: displayAction
public function displayAction()
{
// set filters and validators for GET input
$filters = array('id' => array('HtmlEntities', 'StripTags', 'StringTrim'));
$validators = array('id' => array('NotEmpty', 'Int'));
$input = new Zend_Filter_Input($filters, $validators);
$input->setData($this->getRequest()->getParams());
// test if input is valid
// retrieve requested record
// attach to view
if ($input->isValid()) {
$q = Doctrine_Query::create()->from('Webteam_Model_Video i')->where('i.VideoID = ?', $input->id);
$result = $q->fetchArray();
if (count($result) == 1) {
$this->view->item = $result[0];
} else {
throw new Zend_Controller_Action_Exception('Page not found', 404);
}
} else {
throw new Zend_Controller_Action_Exception('Invalid input');
}
}
示例5: displayAction
public function displayAction()
{
// set filters and validators for GET input
$filters = array('id' => array('HtmlEntities', 'StripTags', 'StringTrim'));
$validators = array('id' => array('NotEmpty', 'Int'));
// test if input is valid
// retrieve requested record
// attach to view
$input = new Zend_Filter_Input($filters, $validators);
$input->setData($this->getRequest()->getParams());
if ($input->isValid()) {
$q = Doctrine_Query::create()->from('Webteam_Model_Video i')->where('i.VideoID = ?', $input->id);
$result = $q->fetchArray();
if (count($result) == 1) {
$this->view->item = $result[0];
// initialize logging engine
$logger = new Zend_Log();
// add Doctrine writer
//values on the right represent database attritubtes
$columnMap = array('message' => 'LogMessage', 'user' => 'UserName', 'videoid' => 'VideoID');
$dbWriter = new Webteam_Log_Writer_Doctrine('Webteam_Model_Log', $columnMap);
$logger->addWriter($dbWriter);
// add additional data to log message
$auth = Zend_Auth::getInstance();
$identity = $auth->getIdentity();
$user = $identity['UserName'];
$logger->setEventItem('user', $user);
$logger->setEventItem('videoid', $result[0]['VideoID']);
// write log message
$logger->log('user trace', Zend_Log::INFO);
} else {
throw new Zend_Controller_Action_Exception('Page not found', 404);
}
} else {
throw new Zend_Controller_Action_Exception('Invalid input');
}
}
示例6: videoTraceAction
public function videoTraceAction()
{
// set filters and validators for GET input
$filters = array('VideoID' => array('HtmlEntities', 'StripTags', 'StringTrim'));
$validators = array('VideoID' => array('Int'));
$input = new Zend_Filter_Input($filters, $validators);
$data = array('VideoID' => $this->getRequest()->getParam('q'));
$input->setData($data);
if ($input->isValid()) {
//check if vidoe id exists
$q = Doctrine_Query::create()->from('Webteam_Model_Video i')->where('i.VideoID = ?', $input->VideoID);
$result = $q->fetchArray();
$count = count($result);
if ($count >= 1) {
$q = Doctrine_Query::create()->from('Webteam_Model_Log i')->where('i.VideoID = ?', $input->VideoID);
$result = $q->fetchArray();
//$this->view->records = $result;
//$this->view->VideoID = $input->VideoID;
$this->view->VideoID = $input->VideoID;
$filters = array('page' => array('HtmlEntities', 'StripTags', 'StringTrim'));
$validators = array('page' => array('Int'));
$input = new Zend_Filter_Input($filters, $validators);
$page = $this->getRequest()->getParam('page');
if (!isset($page)) {
$data = array('page' => 1);
} else {
$data = array('page' => $this->getRequest()->getParam('page'));
}
$input->setData($data);
if ($input->isValid()) {
$perPage = 10;
$numPageLinks = 9;
// initialize pager
$pager = new Doctrine_Pager($q, $input->page, $perPage);
// execute paged query
$result = $pager->execute(array(), Doctrine::HYDRATE_ARRAY);
// initialize pager layout
$pagerRange = new Doctrine_Pager_Range_Sliding(array('chunk' => $numPageLinks), $pager);
$pagerUrlBase = $this->view->url(array(), 'report-video-trace', 1) . '?q=' . $this->view->VideoID . '&page=' . "{%page}";
$pagerLayout = new Doctrine_Pager_Layout($pager, $pagerRange, $pagerUrlBase);
// set page link display template
$pagerLayout->setTemplate('<a href="{%url}">{%page}</a>');
$pagerLayout->setSelectedTemplate('<span class="current">{%page}</span>');
$pagerLayout->setSeparatorTemplate(' ');
// set view variables
$this->view->records = $result;
$this->view->pages = $pagerLayout->display(null, true);
} else {
//invalid page
}
} else {
//die('VideoID does not exits');
$this->_helper->getHelper('FlashMessenger')->addMessage('Vidoe ID does not exists.');
$this->_redirect('/report');
}
} else {
//die('invalid user');
$this->_helper->getHelper('FlashMessenger')->addMessage('Invalid Video ID.');
$this->_redirect('/report');
}
}