/** * Gets the first child of the item * @param ContainerContent $item The item * @return ContainerContent Returns the first child */ public function FirstChildOf($item) { if ($item) { $sql = Access::SqlBuilder(); $tbl = ContainerContent::Schema()->Table(); $where = $sql->Equals($tbl->Field('Parent'), $sql->Value($item->GetID()))->And_($sql->IsNull($tbl->Field('Previous'))); return ContainerContent::Schema()->First($where); } else { return $this->TopMost(); } }
/** * Gets the last container modification log item * @param Container $container The container * @return LogItem Returns the last log item that changed anything related to the container */ static function LastContainerModLog(Container $container) { $lastLog = self::LastContainerLog($container); $containerContents = ContainerContent::Schema()->FetchByContainer(false, $container); foreach ($containerContents as $containerContent) { $content = $containerContent->GetContent(); $contentLog = self::LastContentModLog($content, null); if (self::IsAfter($contentLog, $lastLog)) { $lastLog = $contentLog; } } return $lastLog; }
protected function Init() { $this->container = new Container(Request::GetData('container')); $selectedID = Request::GetData('selected'); $this->selected = $selectedID ? ContainerContent::Schema()->ByID($selectedID) : null; if (!$this->container->Exists()) { //TODO: error Response::Redirect(BackendRouter::ModuleUrl(new ContainerList())); return true; } $this->tree = new ContainerContentTreeProvider($this->container); $this->containerContent = $this->tree->TopMost(); $this->hasContents = (bool) $this->containerContent; return parent::Init(); }
protected function TableSchema() { return ContainerContent::Schema(); }