public function get(&$c, $cvID) { if (is_string($cvID)) { $cvID = CollectionVersion::getNumericalVersionID($c->getCollectionID(), $cvID); } $ca = new Cache(); $cv = $ca->get('collection_version', $c->getCollectionID() . ':' . $cvID); if ($cv instanceof CollectionVersion) { return $cv; } $cv = new CollectionVersion(); $db = Loader::db(); $q = "select cvID, cvIsApproved, cvIsNew, cvHandle, cvName, cvDescription, cvDateCreated, cvDatePublic, cvAuthorUID, cvApproverUID, cvComments from CollectionVersions where cID = ? and cvID = ?"; $r = $db->query($q, array($c->getCollectionID(), $cvID)); if ($r) { $row = $r->fetchRow(); if ($row) { $cv->setPropertiesFromArray($row); } } if ($cv->cvAuthorUID > 0) { $uAuthor = UserInfo::getByID($cv->cvAuthorUID); if (is_object($uAuthor)) { $cv->cvAuthorUname = $uAuthor->getUserName(); } } if ($cv->cvApproverUID > 0) { $uApprover = UserInfo::getByID($cv->cvApproverUID); if (is_object($uApprover)) { $cv->cvApproverUname = $uApprover->getUserName(); } } // load the attributes for a particular version object Loader::model('attribute/categories/collection'); $cv->attributes = CollectionAttributeKey::getAttributes($c->getCollectionID(), $cvID); $cv->cID = $c->getCollectionID(); $cv->cvIsMostRecent = $cv->_checkRecent(); $r = $db->GetAll('select csrID, arHandle from CollectionVersionAreaStyles where cID = ? and cvID = ?', array($c->getCollectionID(), $cvID)); foreach ($r as $styles) { $cv->customAreaStyles[$styles['arHandle']] = $styles['csrID']; } $ca = new Cache(); $ca->set('collection_version', $c->getCollectionID() . ':' . $cvID, $cv); return $cv; }
public function get(&$c, $cvID) { if (is_string($cvID)) { $cvID = CollectionVersion::getNumericalVersionID($c->getCollectionID(), $cvID); } $cv = new CollectionVersion(); $db = Loader::db(); $q = "select cvID, cvIsApproved, cvIsNew, cvHandle, cvName, cvDescription, cvDateCreated, cvDatePublic, cvAuthorUID, cvApproverUID, cvComments, ptID, CollectionVersions.ctID, ctHandle, ctName from CollectionVersions left join PageTypes on CollectionVersions.ctID = PageTypes.ctID where cID = ? and cvID = ?"; $r = $db->query($q, array($c->getCollectionID(), $cvID)); if ($r) { $row = $r->fetchRow(); if ($row) { $cv->setPropertiesFromArray($row); } } // load the attributes for a particular version object Loader::model('attribute/categories/collection'); $cv->attributes = CollectionAttributeKey::getAttributes($c->getCollectionID(), $cvID); $cv->cID = $c->getCollectionID(); $cv->cvIsMostRecent = $cv->_checkRecent(); $r = $db->GetAll('select csrID, arHandle from CollectionVersionAreaStyles where cID = ? and cvID = ?', array($c->getCollectionID(), $cvID)); foreach ($r as $styles) { $cv->customAreaStyles[$styles['arHandle']] = $styles['csrID']; } return $cv; }