Example #1
0
 function saveEditAndDeploy($oNewContent, $nChangeType, $sComment = "", $sChangeInfo = "", $nTime = null)
 {
     //TODO
     ini_set('max_execution_time', 600);
     ini_set('memory_limit', '64M');
     AnwDebug::startBench("saveEditAndDeploy");
     //----------------------------------------------------------
     //update all translations but don't save it now
     //----------------------------------------------------------
     $aoPageTranslations = $this->getPageGroup()->getPages($this);
     foreach ($aoPageTranslations as $oPageTranslation) {
         $this->debug("saveEditAndDeploy: updating translation : " . $oPageTranslation->getName());
         //print "saveEdit: updating translation : ".$oPageTranslation->getName();flush();
         $oContentNewTranslation = AnwAutoSync::propagateContentEdition($this->getContent(), $oNewContent, $oPageTranslation->getContent());
         $oPageTranslation->_setContent($oContentNewTranslation, $oNewContent);
     }
     $this->debug("saveEditAndDeploy: all updates OK, comitting...");
     //----------------------------------------------------------
     //all updates ok, comitting...
     //----------------------------------------------------------
     AnwStorage::transactionStart();
     try {
         //save changes to the current page
         $this->_setContent($oNewContent, -1);
         $this->doUpdate($nChangeType, $sComment, $nTime, $sChangeInfo);
         //save others translations
         foreach ($aoPageTranslations as $oPageTranslation) {
             $oPageTranslation->doUpdate(AnwChange::TYPE_PAGE_EDITION_DEPLOY, $sComment, $nTime, $this->getName());
         }
         AnwStorage::transactionCommit();
     } catch (AnwException $e) {
         AnwStorage::transactionRollback();
         throw $e;
     }
     AnwDebug::stopBench("saveEditAndDeploy");
 }
Example #2
0
 private function saveTranslation($nRevChangeId)
 {
     $bPageWasEditedDuringTranslation = $this->getoPage()->getChangeId() > $nRevChangeId ? true : false;
     if ($bPageWasEditedDuringTranslation) {
         //someone has edited the page since user was translating it, let's get the old revision from which we started the translation
         AnwDebug::log("Someone edited the page since we were translating it");
         $oPageRev = new AnwPageByName($this->getoPage()->getName(), $nRevChangeId);
         $oContentBeforeEdit = $oPageRev->getContent();
         $oContentAfterEdit = $this->getoPage()->getContent();
     } else {
         $oPageRev = $this->getoPage();
     }
     $oContent = clone $oPageRev->getContent();
     //preload original lang
     $fOnValue = "preloadOriginalLang_onContentFieldValue";
     AnwUtils::runCallbacksOnTranslatableField($this, $oPageRev->getContent(), $fOnValue);
     //update content from post
     $fOnValue = "saveTranslation_cbkOnValue";
     //$fBeforeContentField
     $fBeforeContentField = "saveTranslation_cbkBeforeField";
     $fAfterContentField = "saveTranslation_cbkAfterField";
     AnwUtils::runCallbacksOnTranslatableField($this, $oContent, $fOnValue, $fBeforeContentField, $fAfterContentField);
     //if needed, apply again the edit which was done since the translation
     if ($bPageWasEditedDuringTranslation) {
         AnwDebug::log("Someone edited the page since we were translating it --> reapplying changes");
         $oContent = AnwAutoSync::propagateContentEdition($oContentBeforeEdit, $oContentAfterEdit, $oContent);
     }
     //save changes to the current page
     $this->debug("Updating current page...");
     $this->getoPage()->saveTranslation($oContent);
     //unlock
     $this->unlockPageForEdition();
     //redirect
     AnwUtils::redirect(AnwUtils::link($this->getPageName()));
 }