You are here

protected function AbstractFeed::_validateTagUri in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-feed/src/Writer/AbstractFeed.php \Zend\Feed\Writer\AbstractFeed::_validateTagUri()

Validate a URI using the tag scheme (RFC 4151)

Parameters

string $id:

Return value

bool

1 call to AbstractFeed::_validateTagUri()
AbstractFeed::setId in vendor/zendframework/zend-feed/src/Writer/AbstractFeed.php
Set the feed ID - URI or URN (via PCRE pattern) supported

File

vendor/zendframework/zend-feed/src/Writer/AbstractFeed.php, line 286

Class

AbstractFeed

Namespace

Zend\Feed\Writer

Code

protected function _validateTagUri($id) {
  if (preg_match('/^tag:(?P<name>.*),(?P<date>\\d{4}-?\\d{0,2}-?\\d{0,2}):(?P<specific>.*)(.*:)*$/', $id, $matches)) {
    $dvalid = false;
    $date = $matches['date'];
    $d6 = strtotime($date);
    if (strlen($date) == 4 && $date <= date('Y')) {
      $dvalid = true;
    }
    elseif (strlen($date) == 7 && $d6 < strtotime("now")) {
      $dvalid = true;
    }
    elseif (strlen($date) == 10 && $d6 < strtotime("now")) {
      $dvalid = true;
    }
    $validator = new Validator\EmailAddress();
    if ($validator
      ->isValid($matches['name'])) {
      $nvalid = true;
    }
    else {
      $nvalid = $validator
        ->isValid('info@' . $matches['name']);
    }
    return $dvalid && $nvalid;
  }
  return false;
}