示例#1
0
 public function testDirectory()
 {
     $file = RESOURCE_DIR . '/';
     $relative = str_replace(__DIR__, '', $file);
     $resource = new Resource($file, $relative);
     $this->assertEquals('', $resource->getExtension());
     $this->assertEquals(rtrim($relative, '/'), $resource->getRelativePath());
     $this->assertEquals(rtrim($relative, '/'), $resource->getRelativePath(true));
     $this->assertFalse($resource->isIndexable());
     $this->assertEquals(basename($file), $resource->getFilenameShort(true));
     $this->assertEquals(basename($file), $resource->getFilenameShort(false));
     $this->assertEmpty($resource->getContents());
 }
示例#2
0
 /**
  * Returns the valid title of a resource
  *
  * @param object $resource
  * @param array $matter
  * @param array $chars Chars that should be converted to spaces
  * @return string
  */
 public function getTitle(Resource $resource, array $matter = array(), array $chars = array('_', '-', '.'))
 {
     if (!empty($matter['title'])) {
         return $matter['title'];
     }
     // Get the File name and convert
     return trim(str_replace($chars, ' ', trim($resource->getFilenameShort(), implode('', $chars))));
 }
示例#3
0
文件: Slug.php 项目: mpratt/bolido
 /**
  * Creates a link from the given resource
  *
  * @param object $resource
  * @return string
  */
 public function fromResource(Resource $resource)
 {
     $file = $resource->getFilenameShort(false);
     $path = $resource->getRelativePath(true);
     return $this->urlizeRecursive($path . '/' . $file);
 }