/** * Returns an array containing all the layouts particulars * @param int $layoutId The layout ID */ public function LayoutInformation($layoutId) { Debug::LogEntry('audit', '[IN]', 'layout', 'LayoutInformation'); // The array to ultimately return $info = array(); $info['regions'] = array(); try { $dbh = PDOConnect::init(); $sth = $dbh->prepare('SELECT * FROM `layout` WHERE layoutid = :layout_id'); $sth->execute(array('layout_id' => $layoutId)); $rows = $sth->fetchAll(); if (count($rows) <= 0) { $this->ThrowError(__('Unable to find layout')); } $row = $rows[0]; $info['layout'] = Kit::ValidateParam($row['layout'], _STRING); $modifiedDt = new DateTime($row['modifiedDT']); $info['updated'] = $modifiedDt->getTimestamp(); } catch (Exception $e) { Debug::LogEntry('error', $e->getMessage()); if (!$this->IsError()) { $this->SetError(1, __('Unknown Error')); } return false; } // Get the width and height $xml = new DOMDocument(); $xml->loadXML($row['xml']); // get the width and the height $info['width'] = $xml->documentElement->getAttribute('width'); $info['height'] = $xml->documentElement->getAttribute('height'); // Use the Region class to help Kit::ClassLoader('region'); // Dummy User Object $user = new User($this->db); $user->userid = 0; $user->usertypeid = 1; // Take the layout, loop through its regions, check them and call LayoutInformation on all media in them. $info['regions'] = $this->GetRegionList($layoutId); if (count($info['regions']) <= 0) { return $info; } // Loop through each and build an array foreach ($info['regions'] as &$region) { $region['media'] = array(); Debug::LogEntry('audit', 'Assessing Region: ' . $region['regionid'], 'layout', 'LayoutInformation'); // Create a layout object $regionObject = new Region($this->db); $mediaNodes = $regionObject->GetMediaNodeList($layoutId, $region['regionid']); // Create a data set to see if there are any requirements to serve an updated date time Kit::ClassLoader('dataset'); $dataSetObject = new DataSet($this->db); foreach ($mediaNodes as $mediaNode) { $node = array('mediaid' => $mediaNode->getAttribute('id'), 'lkid' => $mediaNode->getAttribute('lkid'), 'mediatype' => $mediaNode->getAttribute('type'), 'render' => $mediaNode->getAttribute('render'), 'userid' => $mediaNode->getAttribute('userid'), 'updated' => $info['updated']); // DataSets are a special case. We want to get the last updated time from the dataset. $dataSet = $dataSetObject->GetDataSetFromLayout($layoutId, $region['regionid'], $mediaNode->getAttribute('id')); if (count($dataSet) == 1) { $node['updated'] = $dataSet[0]['LastDataEdit']; } // Put this node vertically in the region time-line $region['media'][] = $node; } Debug::LogEntry('audit', 'Finished with Region', 'layout', 'LayoutInformation'); } return $info; }