public static function exportFrom($intElementId, $intTemplateId, $arrElementFilters, $arrTemplateFilters, $intAccountId = 0, $exportElements = true, $exportFiles = true, $includeSelf = false) { global $objLiveAdmin, $_CONF, $_PATHS; $arrFiles = array(); //*** Init DOM object. $objDoc = new DOMDocument("1.0", "UTF-8"); $objDoc->formatOutput = false; $objDoc->preserveWhiteSpace = true; //*** Init Zip archive. $strZipName = $_PATHS['upload'] . "exportZip_" . rand() . ".zip"; $objZip = new dZip($strZipName, true); $objStructure = $objDoc->createElement('structure'); $objStructure->setAttribute("version", "1.0"); $objStructure->setAttribute("type", "element"); $objStructure = $objDoc->appendChild($objStructure); $objLogic = $objDoc->createElement('logic'); $objLogic = $objStructure->appendChild($objLogic); //*** export templates $includeTemplateSelf = $intElementId === NULL || $includeSelf; $objTemplates = self::exportTemplate($objDoc, $intAccountId, $intTemplateId, $arrTemplateFilters, $includeTemplateSelf); $objTemplates = $objLogic->appendChild($objTemplates); //*** export elements if ($exportElements) { //*** export languages $objLanguages = $objDoc->createElement('languages'); $objLanguages = $objLogic->appendChild($objLanguages); $objContentLangs = ContentLanguage::select(); foreach ($objContentLangs as $objContentLang) { $objLanguage = $objDoc->createElement('language'); $objLanguage->setAttribute("id", $objContentLang->getId()); $objLanguage->setAttribute("name", $objContentLang->getName()); $objLanguage->setAttribute("abbr", $objContentLang->getAbbr()); $objLanguage->setAttribute("default", $objContentLang->default); $objLanguage->setAttribute("active", $objContentLang->getActive()); $objLanguage->setAttribute("sort", $objContentLang->getSort()); $objLanguage->setAttribute("username", $objContentLang->getUsername()); $objLanguages->appendChild($objLanguage); } //*** export elements if ($intElementId == NULL) { // export all elements with given template id $strSql = sprintf("SELECT * FROM pcms_element WHERE templateId = '%s' AND accountId = '%s' ORDER BY sort", $intTemplateId, $_CONF['app']['account']->getId()); $objElements = Element::select($strSql); foreach ($objElements as $objElement) { $objElements = self::exportElement($objDoc, $intAccountId, $objElement->getId(), $arrFiles, $arrTemplateFilters, $arrElementFilters, $includeTemplateSelf); $objElements = $objLogic->appendChild($objElements); } } else { // export from one element $objElements = self::exportElement($objDoc, $intAccountId, $intElementId, $arrFiles, $arrTemplateFilters, $arrElementFilters, $includeTemplateSelf); $objElements = $objLogic->appendChild($objElements); } //*** export aliases $objAliases = $objDoc->createElement('aliases'); $objAliases = $objLogic->appendChild($objAliases); $objDbAliases = Alias::select(); foreach ($objDbAliases as $objDbAlias) { if (in_array($objDbAlias->getUrl(), $arrElementFilters)) { $objAlias = $objDoc->createElement('alias'); $objAlias->setAttribute("language", $objDbAlias->getLanguageId()); $objAlias->setAttribute("cascade", $objDbAlias->getCascade()); $objAlias->setAttribute("alias", $objDbAlias->getAlias()); $objAlias->setAttribute("url", $objDbAlias->getUrl()); $objAlias->setAttribute("active", $objDbAlias->getActive()); $objAlias->setAttribute("sort", $objDbAlias->getSort()); $objAlias->setAttribute("created", $objDbAlias->getCreated()); $objAlias->setAttribute("modified", $objDbAlias->getModified()); $objAliases->appendChild($objAlias); } } } //*** Files. if ($exportFiles) { $strServer = Setting::getValueByName("ftp_server"); $webServer = Setting::getValueByName("web_server"); if ($strServer != "localhost") { $strLocation = "http://" . $strServer . Setting::getValueByName("file_folder"); } else { if (!empty($webServer)) { $strLocation = $webServer . Setting::getValueByName("file_folder"); } } $objZip = self::exportFilesToZip($objZip, $arrFiles, $strLocation); } //*** Destroy temporary account object. unset($_CONF['app']['account']); //*** Return XML. $objZip->addFile(NULL, 'data.xml', "", $objDoc->saveXML()); $objZip->save(); return $strZipName; }