Exemple #1
0
 private function ontologyPath()
 {
     if ($this->parsedTitle->nsCode() !== LocalConfiguration::ontologyNsCode) {
         return false;
     }
     $path = $this->parsedTitle->encoded();
     $prefix = LocalConfiguration::ontologyPrefix;
     if (!StringUtil::startsWith($path, $prefix)) {
         return false;
     }
     return substr($path, strlen($prefix));
 }
Exemple #2
0
 /**
  * Hack that cuts off 'dbpedia/' from the start of the string 
  * or replaces the first '/' by a ':', so 'dbpedia/Person' becomes 'Person'
  * and 'foaf/name' becomes 'foaf:name'.
  * @param $name wiki-encoded page title
  * @return $name without 'dbpedia/' prefix or with first '/' replaced by a ':'.
  * @throws InvalidArgumentException if $name does not include a '/'
  */
 public static function getName($name)
 {
     if (StringUtil::startsWith($name, 'dbpedia/')) {
         return substr($name, 8);
     } else {
         $slash = strpos($name, '/');
         if ($slash === false) {
             throw new \InvalidArgumentException('missing namespace in page title ' . $name);
         } else {
             $name[$slash] = ':';
             return $name;
         }
     }
 }