function Page($id = null, $vs = 0) { if ($id === null) { return cms::$MainPage ? cms::$MainPage : cms::PageFromRequest(); } return cms::Page($id, $vs); }
function insertBefore($page, $before = null) { $Page = cms::Page($page); $OldParent = $Page->Parent(); $Before = cms::Page($before); if ($this->in($Page)) { return false; } $type = $Page->vs['type']; $sort = null; $i = 0; foreach ($this->Childs(array('type' => $type)) as $Child) { if ($Page === $Child) { continue; } if ($Before === $Child) { $sort = $i++; } $Child->set(array('sort' => $i++)); } $sort = $sort !== null ? $sort : $i++; $Page->set(array('basis' => $this, 'sort' => $sort)); // clear cache $Page->Parent = $Page->Path = null; $this->Childs = $this->Bough = $this->Named = null; $OldParent->Childs = $OldParent->Bough = $OldParent->Named = null; $Page->urlsSeoGen(); //cms::buildLftRgt(); return true; }