/**
  * Guarda la cache full
  * 
  * @access private
  * @param string   source filename, relative to root directory
  * @param string   name of the block to save into file
  * @return mixed   SIGMA_OK on success, error object on failure
  */
 function _writeFullCache($filename)
 {
     /* no guarda nada si no esta seteado el directorio de cache full*/
     if (null !== $this->_fullCacheRoot) {
         $cachedName = $this->_fullCachedName($filename);
         if (!($fh = @fopen($cachedName, 'w'))) {
             return $this->raiseError($this->errorMessage(SIGMAX_FULL_CACHE_ERROR, $cachedName), SIGMAX_FULL_CACHE_ERROR);
         }
         fwrite($fh, parent::get());
         fclose($fh);
     }
     return SIGMA_OK;
 }
 /**
  * show()
  *
  * @access public
  * @return void
  */
 function show()
 {
     $sBuff = parent::get();
     if (0 < $this->_iHtmlCacheExpire) {
         $this->_objCache->save($this->_sCacheId, $sBuff, $this->_iHtmlCacheExpire, $this->_sCacheGrp);
     }
     $this->_show($sBuff);
 }
 private function getTreeCode()
 {
     if (count($this->arrMigrateLangIds) === 1) {
         return true;
     }
     $jsSimilarPages = array();
     $this->similarPages = $this->findSimilarPages();
     foreach ($this->similarPages as $nodeId => $arrPageIds) {
         $jsSimilarPages[$nodeId] = array_values($arrPageIds);
         foreach ($this->arrMigrateLangIds as $migrateLangId) {
             if (!isset($arrPageIds[$migrateLangId])) {
                 $this->similarPages[$nodeId][$migrateLangId] = 0;
             }
         }
         ksort($this->similarPages[$nodeId]);
     }
     $objCx = \ContrexxJavascript::getInstance();
     $objCx->setVariable('similarPages', json_encode($jsSimilarPages), 'update/contentMigration');
     $objTemplate = new \HTML_Template_Sigma(UPDATE_TPL);
     $objTemplate->setErrorHandling(PEAR_ERROR_DIE);
     $objTemplate->loadTemplateFile('page_grouping.html');
     $groupedBorderWidth = count($this->arrMigrateLangIds) * 325 - 48;
     $objTemplate->setGlobalVariable(array('USERNAME' => $_SESSION['contrexx_update']['username'], 'PASSWORD' => $_SESSION['contrexx_update']['password'], 'CMS_VERSION' => $_SESSION['contrexx_update']['version'], 'MIGRATE_LANG_IDS' => $this->migrateLangIds, 'LANGUAGE_WRAPPER_WIDTH' => 'width: ' . count($this->arrMigrateLangIds) * 330 . 'px;', 'GROUPED_SCROLL_WIDTH' => 'width: ' . count($this->arrMigrateLangIds) * 325 . 'px;', 'GROUPED_BORDER_WIDTH' => 'width: ' . $groupedBorderWidth . 'px;'));
     $cl = \Env::get('ClassLoader');
     $cl->loadFile(ASCMS_CORE_PATH . '/Tree.class.php');
     $cl->loadFile(UPDATE_CORE . '/UpdateTree.class.php');
     $pageRepo = self::$em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
     $nodeRepo = self::$em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Node');
     foreach ($this->arrMigrateLangIds as $lang) {
         $objContentTree = new \UpdateContentTree($lang);
         foreach ($objContentTree->getTree() as $arrPage) {
             $pageId = $arrPage['catid'];
             $nodeId = $arrPage['node_id'];
             $langId = $arrPage['lang'];
             $level = $arrPage['level'];
             $title = $arrPage['catname'];
             $sort = $nodeRepo->find($nodeId)->getLft();
             $grouped = $this->isGrouppedPage($this->similarPages, $pageId) ? 'grouped' : '';
             $objTemplate->setVariable(array('TITLE' => $title, 'ID' => $pageId, 'NODE' => $nodeId, 'LANG' => strtoupper(\FWLanguage::getLanguageCodeById($langId)), 'LEVEL' => $level + 1, 'SORT' => $sort, 'GROUPED' => $grouped, 'MARGIN' => 'margin-left: ' . $level * 15 . 'px;'));
             $objTemplate->parse('page');
         }
         $langFull = \FWLanguage::getLanguageParameter($lang, 'name');
         $langShort = strtoupper(\FWLanguage::getLanguageParameter($lang, 'lang'));
         $objTemplate->setVariable(array('LANG_FULL' => $langFull, 'LANG_SHORT' => $langShort));
         $objTemplate->parse('language');
     }
     $groupedBorderWidth -= 2;
     foreach ($this->similarPages as $nodeId => $arrPageIds) {
         $node = $nodeRepo->find($nodeId);
         $margin = ($node->getLvl() - 1) * 15;
         $nodeWidth = $groupedBorderWidth - $margin;
         $width = ($groupedBorderWidth - 10) / count($this->arrMigrateLangIds);
         $index = 0;
         $last = count($arrPageIds) - 1;
         foreach ($arrPageIds as $pageLangId => $pageId) {
             if ($index === 0) {
                 $pageWidth = $width - 24;
             } elseif ($index === $last) {
                 $pageWidth = $width - $margin;
             } else {
                 $pageWidth = $width;
             }
             $index++;
             $page = $pageRepo->find($pageId);
             if ($page) {
                 $langCode = strtoupper(\FWLanguage::getLanguageCodeById($page->getLang()));
                 $objTemplate->setVariable(array('CLASS' => '', 'DATA_ID' => 'data-id="' . $pageId . '"', 'DATA_LANG' => 'data-lang="' . $langCode . '"', 'TITLE' => $page->getTitle(), 'LANG' => $langCode, 'WIDTH' => 'width: ' . $pageWidth . 'px;'));
             } else {
                 $langCode = strtoupper(\FWLanguage::getLanguageCodeById($pageLangId));
                 $objTemplate->setVariable(array('CLASS' => 'no-page', 'DATA_ID' => '', 'DATA_LANG' => '', 'TITLE' => 'Keine Seite', 'LANG' => $langCode, 'WIDTH' => 'width: ' . $pageWidth . 'px;'));
             }
             $objTemplate->parse('groupedPage');
         }
         $objTemplate->setVariable(array('ID' => $nodeId, 'LEVEL' => $node->getLvl(), 'SORT' => $node->getLft(), 'STYLE' => 'width: ' . $nodeWidth . 'px; margin-left: ' . $margin . 'px;'));
         $objTemplate->parse('groupedNode');
     }
     return $objTemplate->get();
 }