Example #1
0
 public function testConstruction()
 {
     $kirby = $this->kirbyInstance();
     $site = $this->siteInstance($kirby);
     $page = new Page($site, '1-a');
     $this->assertInstanceOf('Kirby', $page->kirby());
     $this->assertEquals($kirby, $page->kirby());
     $this->assertInstanceOf('Site', $page->site());
     $this->assertEquals($site, $page->site());
     $this->assertInstanceOf('Site', $page->parent());
     $this->assertEquals($site, $page->parent());
     $this->assertEquals('1-a', $page->dirname());
     $this->assertEquals(1, $page->depth());
     $this->assertEquals($kirby->roots()->content() . DS . '1-a', $page->root());
     $this->assertEquals('1', $page->num());
     $this->assertEquals('a', $page->uid());
     $this->assertEquals('a', $page->id());
     $this->assertEquals('1-a', $page->diruri());
     $this->assertEquals('/a', $page->url());
     $this->assertTrue($page->isCachable());
     $this->assertEquals('a', $page->slug());
     $this->assertTrue($page->is($page));
     $this->assertTrue($page->equals($page));
     $this->assertFalse($page->isSite());
     $this->assertFalse($page->isActive());
     $this->assertFalse($page->isOpen());
     $this->assertTrue($page->isVisible());
     $this->assertFalse($page->isInvisible());
     $this->assertFalse($page->isHomePage());
     $this->assertFalse($page->isErrorPage());
     $this->assertEquals($page->id(), (string) $page);
 }
Example #2
0
 /**
  * Constructor
  *
  * @param Page $parent
  * @param string $dirname
  */
 public function __construct($parent, $dirname)
 {
     $this->parent = $parent;
     $this->site = $parent->site();
     $this->dirname = $dirname;
     $this->root = $parent->root() . DS . $dirname;
     $this->depth = $parent->depth() + 1;
     // extract the uid and num of the directory
     if (preg_match('/^([0-9]+[\\-]+)(.*)/', $this->dirname, $match)) {
         $this->uid = $match[2];
         $this->num = trim(rtrim($match[1], '-'));
     } else {
         $this->num = null;
         $this->uid = $this->dirname;
     }
     // assign the uid
     $this->id = $this->uri = ltrim($parent->id() . '/' . $this->uid, '/');
 }