Пример #1
0
 /**
  * All of the following names will be encoded to 'Émile Zola': 
  * '%C3%89mile_Zola', '%C3%A9mile_Zola', ' %C3%A9mile Zola ', ' %C3%A9mile _ Zola ', '  Émile _ Zola  '
  * 
  * TODO: maybe we should expect (require) the name to be normalized, e.g. with uppercase
  * first letter and without duplicate spaces or spaces at start or end? 
  * Would make this method much simpler.
  *   
  * @param $name encoded MediaWiki page name, e.g. '%C3%89mile_Zola'.
  * Must not include the namespace (e.g. 'Template:').
  */
 public static function wikiDecode($name)
 {
     PhpUtil::assertString($name, 'name');
     // make first character uppercase
     $name = StringUtil::mb_ucfirst(self::cleanSpace(urldecode($name)));
     return $name;
 }
Пример #2
0
 private function updateConfig($dir, $path, $source)
 {
     PhpUtil::assertString($path, 'path');
     PhpUtil::assertString($source, 'source');
     // TODO: add '#1' etc. if necessary on Windows for file names that only differ in case
     // TODO: make suffix configurable
     $file = $dir . $path . '.txt';
     return $this->buildConfigFile($file, $source);
 }
Пример #3
0
 public function setDestination($destinationId, $destination)
 {
     PhpUtil::assertString($destinationId, 'destination id');
     PhpUtil::assertType($destination, 'dbpedia\\destinations\\QuadDestination', 'destination');
     if (isset($this->destinations[$destinationId])) {
         throw new \InvalidArgumentException('destination for id [' . $destinationId . '] already set');
     }
     $this->destinations[$destinationId] = $destination;
 }
Пример #4
0
 /**
  * @param $baseDir must end with a directory separator (slash or backslash)
  * @param $skipNames names (not paths) of files and directories to skip, e.g. '.svn'. 
  * If not given, all files and directories will be included.
  * @param $paths array of strings, paths of files to use, relative to base dir,
  * using forward slashes. If not given, all files and directories will be included.
  */
 public function __construct($baseDir, $skipNames = null, $paths = null)
 {
     PhpUtil::assertString($baseDir, 'base dir');
     $baseDir = str_replace('\\', '/', realpath($baseDir));
     if (!is_dir($baseDir)) {
         throw new \InvalidArgumentException('base dir must be an existing directory, but is ' . $baseDir);
     }
     // make sure that $baseDir ends with /
     if (!StringUtil::endsWith($baseDir, '/')) {
         $baseDir .= '/';
     }
     if ($skipNames !== null) {
         PhpUtil::assertArray($skipNames, 'skip names');
     } else {
         $skipNames = array();
     }
     if ($paths !== null) {
         PhpUtil::assertArray($paths, 'paths');
     }
     $this->baseDir = $baseDir;
     $this->skipNames = $skipNames;
     $this->paths = $paths;
 }
Пример #5
0
 public function getDestination($destinationId)
 {
     PhpUtil::assertString($destinationId, 'destination id');
     return $this->destination;
 }
Пример #6
0
 /**
  * @param $nsCode namespace code
  * @param $decoded decoded page name. URL-decoded, using normalized spaces (not underscores), first letter uppercase.
  */
 public function __construct($nsCode, $decoded)
 {
     PhpUtil::assertInteger($nsCode, 'namespace code');
     if (!isset(self::$nsNames[$nsCode])) {
         throw new \InvalidArgumentException('unknown namespace code ' . $nsCode);
     }
     PhpUtil::assertString($decoded, 'page name');
     if (strlen($decoded) === 0) {
         throw new WikiParserException('page name must not be empty');
     }
     $this->nsCode = $nsCode;
     $this->nsName = self::$nsNames[$nsCode][0];
     $this->encoded = WikiUtil::wikiEncode($decoded);
     // re-decode to make sure name is normalized
     $this->decoded = WikiUtil::wikiDecode($this->encoded);
 }
Пример #7
0
 /**
  * Sets the label which has been defined for this property.
  *
  * @param string $label The label of this property or null to remove the current label.
  */
 public function setLabel($label)
 {
     PhpUtil::assertString($label, 'label');
     $this->label = $label;
 }
Пример #8
0
 public function __construct($file)
 {
     PhpUtil::assertString($file, 'file');
     $this->file = $file;
 }