/** * Get a Version instance given the Collection and a version identifier. * * @param \Concrete\Core\Page\Collection $c The collection for which you want the version. * @param int|string $cvID The specific version ID (or 'ACTIVE', 'SCHEDULED', 'RECENT'). * * @return static */ public static function get($c, $cvID) { $app = Facade::getFacadeApplication(); $db = $app->make('database')->connection(); $cID = false; if ($c instanceof \Concrete\Core\Page\Page) { $cID = $c->getCollectionPointerID(); } if (!$cID) { $cID = $c->getCollectionID(); } $v = array($cID); $q = "select cvID, cvIsApproved, cvIsNew, cvHandle, cvName, cvDescription, cvDateCreated, cvDatePublic, " . "pTemplateID, cvAuthorUID, cvApproverUID, cvComments, pThemeID, cvPublishDate from CollectionVersions " . "where cID = ?"; switch ($cvID) { case 'ACTIVE': $q .= ' and cvIsApproved = 1 and cvPublishDate is NULL'; break; case 'SCHEDULED': $q .= ' and cvIsApproved = 1 and cvPublishDate is not NULL'; break; case 'RECENT': $q .= ' order by cvID desc'; break; default: $v[] = $cvID; $q .= ' and cvID = ?'; break; } $row = $db->fetchAssoc($q, $v); $cv = new static(); if ($row !== false) { $cv->setPropertiesFromArray($row); } $cv->cID = $c->getCollectionID(); return $cv; }