concrete/src/Page/Collection/Version/Version.php
public static function get($c, $cvID)
    {
        $app = Facade::getFacadeApplication();
        $db = $app->make('database')->connection();
        $now = $app->make('date')->getOverridableNow();

        $cID = false;
        if ($c instanceof \Concrete\Core\Page\Page) {
            $cID = $c->getCollectionPointerID();
        }
        if (!$cID) {
            $cID = $c->getCollectionID();
        }
        $v = array($cID);

        $q = "select * from CollectionVersions where cID = ?";

        switch ($cvID) {
            case 'ACTIVE':
                $q .= ' and cvIsApproved = 1 and (cvPublishDate is null or cvPublishDate <= ?) and (cvPublishEndDate is null or cvPublishEndDate >= ?) order by cvPublishDate desc limit 1';
                $v[] = $now;
                $v[] = $now;
                break;
            case 'SCHEDULED':
                $q .= ' and cvIsApproved = 1 and (cvPublishDate is not null and cvPublishDate > ?) order by cvPublishDate limit 1';
                $v[] = $now;
                break;
            case 'RECENT':
                $q .= ' order by cvID desc limit 1';
                break;
            case 'RECENT_UNAPPROVED':
                $q .= 'and (cvIsApproved = 0 or cvIsApproved IS NULL) order by cvID desc limit 1';
                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;
    }
public static function get($c, $cvID)
    {
        $app = Facade::getFacadeApplication();
        $db = $app->make('database')->connection();
        $now = $app->make('date')->getOverridableNow();

        $cID = false;
        if ($c instanceof \Concrete\Core\Page\Page) {
            $cID = $c->getCollectionPointerID();
        }
        if (!$cID) {
            $cID = $c->getCollectionID();
        }
        $v = array($cID);

        $q = "select * from CollectionVersions where cID = ?";

        switch ($cvID) {
            case 'ACTIVE':
                $q .= ' and cvIsApproved = 1 and (cvPublishDate is null or cvPublishDate <= ?) and (cvPublishEndDate is null or cvPublishEndDate >= ?) order by cvPublishDate desc limit 1';
                $v[] = $now;
                $v[] = $now;
                break;
            case 'SCHEDULED':
                $q .= ' and cvIsApproved = 1 and (cvPublishDate is not null and cvPublishDate > ?) order by cvPublishDate limit 1';
                $v[] = $now;
                break;
            case 'RECENT':
                $q .= ' order by cvID desc limit 1';
                break;
            case 'RECENT_UNAPPROVED':
                $q .= 'and (cvIsApproved = 0 or cvIsApproved IS NULL) order by cvID desc limit 1';
                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;
    }
public static function get ( $ c , $ cvID ) { $ app = Facade :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ now = $ app -> make ( 'date' ) -> getOverridableNow ( ) ; $ cID = false ; if ( $ c instanceof \ Concrete \ Core \ Page \ Page ) { $ cID = $ c -> getCollectionPointerID ( ) ; } if ( ! $ cID ) { $ cID = $ c -> getCollectionID ( ) ; } $ v = array ( $ cID ) ; $ q = "select * from CollectionVersions where cID = ?" ; switch ( $ cvID ) { case 'ACTIVE' : $ q .= ' and cvIsApproved = 1 and (cvPublishDate is null or cvPublishDate <= ?) and (cvPublishEndDate is null or cvPublishEndDate >= ?) order by cvPublishDate desc limit 1' ; $ v [ ] = $ now ; $ v [ ] = $ now ; break ; case 'SCHEDULED' : $ q .= ' and cvIsApproved = 1 and (cvPublishDate is not null and cvPublishDate > ?) order by cvPublishDate limit 1' ; $ v [ ] = $ now ; break ; case 'RECENT' : $ q .= ' order by cvID desc limit 1' ; break ; case 'RECENT_UNAPPROVED' : $ q .= 'and (cvIsApproved = 0 or cvIsApproved IS NULL) order by cvID desc limit 1' ; 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 ; }
Get a Version instance given the Collection and a version identifier.

@param \Concrete\Core\Page\Collection\Collection $c the collection for which you want the version
@param int|string $cvID the specific version ID (or 'ACTIVE', 'SCHEDULED', 'RECENT')

@return static
Get a Version instance given the Collection and a version identifier .