/** * Copy all revision data (page map, elemtnts) from one to other * @param AM_Model_Db_Revision $oRevisionFrom * @return AM_Model_Db_Revision */ public function copyFromRevision(AM_Model_Db_Revision $oRevisionFrom) { $oVocabularyToc = $oRevisionFrom->getVocabularyToc(); $oVocabularyTag = $oRevisionFrom->getVocabularyTag(); $aPages = $oRevisionFrom->getPages(); if (!empty($oVocabularyToc)) { $oVocabularyToc->copyToRevision($this, $oRevisionFrom); } if (!empty($oVocabularyTag)) { $oVocabularyTag->copyToRevision($this, $oRevisionFrom); } foreach ($aPages as $oPage) { /* @var $oPage AM_Model_Db_Page */ $oPage->copyToRevision($this); } foreach ($aPages as $oPage) { /* @var $oPage AM_Model_Db_Page */ $oPage->savePageImposition(); } return $this; }
/** * Returns tree structure as array - each root element contains 2 childs * [ * [id1, id2, id3, title1, title2, title3] * ] * * @param AM_Model_Db_Revision $oRevision * @return array */ protected function _getTree(AM_Model_Db_Revision $oRevision) { $oVocabulary = $oRevision->getVocabularyToc(); $oQuery = $this->getAdapter()->select()->from(array('t1' => 'term'), null)->joinLeft(array('t2' => 'term'), 't2.parent_term = t1.id AND t2.deleted = "no"' . $this->getAdapter()->quoteInto(' AND (t2.revision = ? OR t2.revision IS NULL)', $oRevision->id), null)->joinLeft(array('t3' => 'term'), 't3.parent_term = t2.id AND t3.deleted = "no"' . $this->getAdapter()->quoteInto(' AND (t3.revision = ? OR t3.revision IS NULL)', $oRevision->id), null)->where('t1.vocabulary = ?', $oVocabulary->id)->where('t1.revision = ? OR t1.revision IS NULL', $oRevision->id)->where('t1.parent_term is null')->where('t1.deleted = ?', 'no')->order(array('t1.position', 't2.position', 't3.position', 't1.id', 't2.id', 't3.id'))->columns(array('id1' => 't1.id', 'id2' => 't2.id', 'id3' => 't3.id', 'title1' => 't1.title', 'title2' => 't2.title', 'title3' => 't3.title')); $aResult = $this->getAdapter()->fetchAll($oQuery); return $aResult; }
/** * Copy term data from one revision to other * @param AM_Model_Db_Revision $oRevisionTo * @return AM_Model_Db_Term */ public function copyToRevision(AM_Model_Db_Revision $oRevisionTo, AM_Model_Db_Revision $oRevisionFrom) { $oTocVocabulary = $oRevisionTo->getVocabularyToc(); if ($this->_isToc() && !empty($this->revision) && $oRevisionFrom->id == $this->revision) { $oResources = $this->getResources(); $this->vocabulary = $oTocVocabulary->id; $this->revision = $oRevisionTo->id; $aData = array(); $aData['updated'] = null; $aData['vocabulary'] = $this->vocabulary; $aData['revision'] = $this->revision; $this->copy($aData); $oResources->copy(); } return $this; }