示例#1
0
 public function getExtensions()
 {
     $extensions = new \SplObjectStorage();
     foreach ($this->extensions as $iri => $value) {
         $extensions->attach(IRI::fromString($iri), $value);
     }
     return $extensions;
 }
function makeAbsoluteStr($base, $url)
{
    $base = new IRI($base);
    // remove '//' in URL path (causes URLs not to resolve properly)
    if (isset($base->ipath)) {
        $base->ipath = preg_replace('!//+!', '/', $base->ipath);
    }
    if (preg_match('!^https?://!i', $url)) {
        // already absolute
        return $url;
    } else {
        $absolute = IRI::absolutize($base, $url);
        if ($absolute) {
            return $absolute;
        }
        return false;
    }
}
示例#3
0
文件: Verb.php 项目: php-xapi/model
 /**
  * Creates a Verb that can be used to void a {@link Statement}.
  *
  * @return Verb
  */
 public static function createVoidVerb()
 {
     return new Verb(IRI::fromString('http://adlnet.gov/expapi/verbs/voided'));
 }
function makeAbsoluteAttr($base, $e, $attr)
{
    if ($e->hasAttribute($attr)) {
        // Trim leading and trailing white space. I don't really like this but
        // unfortunately it does appear on some sites. e.g.  <img src=" /path/to/image.jpg" />
        $url = trim(str_replace('%20', ' ', $e->getAttribute($attr)));
        $url = str_replace(' ', '%20', $url);
        if (!preg_match('!https?://!i', $url)) {
            $absolute = IRI::absolutize($base, $url);
            if ($absolute) {
                $e->setAttribute($attr, $absolute);
            }
        }
    }
}