function export($option) { global $database, $my, $mainframe, $booklibrary_configuration; $catid = mosGetParam($_POST, 'export_catid', 0); //$lend = mosGetParam($_POST, 'export_lend', null); //$pub = mosGetParam($_POST, 'export_pub', null); $type = mosGetParam($_POST, 'export_type', 0); $where = array(); $wherecatid = ''; if ($catid > 0) { array_push($where, "ac.catid='{$catid}'"); $wherecatid = " AND c.id ='{$catid}'"; } $selectstring = "SELECT a.id FROM #__booklibrary AS a\n \nLEFT JOIN #__booklibrary_categories AS ac ON a.id = ac.bookid" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "") . "\nGROUP BY ac.bookid" . "\nORDER BY a.ordering"; $database->setQuery($selectstring); $booksids = $database->loadResultArray(); if (version_compare(JVERSION, '3.0', 'lt')) { $booksids = $database->loadResultArray(); } else { $booksids = $database->loadColumn(); } echo $database->getErrorMsg(); if ($database->getErrorNum()) { echo $database->stderr(); return; } /*************************************************************************************************/ $cats = ''; if ($type == '4') { $selectstring = "SELECT c.* FROM #__booklibrary_main_categories AS c" . "\nWHERE c.section='com_booklibrary' " . $wherecatid . "\nORDER BY c.parent_id"; $database->setQuery($selectstring); $cats = $database->loadAssocList(); } $order = array("\r\n", "\n", "\r"); $strXmlDoc = ""; $strXmlDoc .= "<?xml version='1.0' encoding='utf-8' ?>\n"; $strXmlDoc .= "<data>\n"; $strXmlDoc .= "<version>" . $booklibrary_configuration['release']['version'] . "</version>\n"; $strXmlDoc .= "<books>\n"; foreach ($booksids as $bid) { $tmp = new mosBooklibrary($database); if ($catid > 0) { $tmp->categs = array($catid); } if ($tmp->load(intval($bid))) { $tmp->title = str_replace('|', '-', $tmp->title); $tmp->title = str_replace('\\n', ' ', $tmp->title); $tmp->title = str_replace('\\r', ' ', $tmp->title); $tmp->comment = str_replace('|', '-', $tmp->comment); $tmp->comment = str_replace('\\n', ' ', $tmp->comment); $tmp->comment = str_replace('\\r', ' ', $tmp->comment); $tmp->featured_clicks = str_replace('|', '-', $tmp->featured_clicks); $tmp->featured_clicks = str_replace($order, ' ', $tmp->featured_clicks); $tmp->featured_shows = str_replace('|', '-', $tmp->featured_shows); $tmp->featured_shows = str_replace($order, ' ', $tmp->featured_shows); //$books[]=$tmp; $strXmlDoc .= $tmp->toXML2(); } } $strXmlDoc .= "</books>\n"; $strXmlDoc2 = ""; $strXmlDoc2 .= "<categories>\n"; if ($type == '4') { foreach ($cats as $cat) { $strXmlDoc2 .= "<category>\n"; foreach ($cat as $field => $value) { $strXmlDoc2 .= '<' . $field . '><![CDATA[' . $value . ']]></' . $field . ">\n"; } $strXmlDoc2 .= "</category>\n"; } } $strXmlDoc2 .= "</categories>\n"; if ($type == '4') { $strXmlDoc .= $strXmlDoc2; } $strXmlDoc .= "</data>\n"; /* print_r(":11111111111111:"); print_r("<pre>"); print_r($cats); print_r("</pre>"); exit; */ /*************************************************************************************************/ /* $books = array(); $order = array("\r\n", "\n", "\r"); foreach($booksids as $bid){ $tmp = new mosBooklibrary($database); // __constructor JTable if($tmp->load(intval($bid))){ $books[]=$tmp; } } //parsing in title and commenr symbol '|' foreach ($books as $key => $book) { $books[$key]->title = str_replace('|', '-', $book->title); $books[$key]->title = str_replace('\n', ' ', $book->title); $books[$key]->title = str_replace('\r', ' ', $book->title); $books[$key]->comment = str_replace('|', '-', $book->comment); $books[$key]->comment = str_replace('\n', ' ', $book->comment); $books[$key]->comment = str_replace('\r', ' ', $book->comment); $books[$key]->featured_clicks = str_replace('|', '-', $books[$key]->featured_clicks); $books[$key]->featured_clicks = str_replace($order, ' ', $books[$key]->featured_clicks); $books[$key]->featured_shows = str_replace('|', '-', $books[$key]->featured_shows); $books[$key]->featured_shows = str_replace($order, ' ', $books[$key]->featured_shows); if ($catid > 0){ $books[$key]->categs = array($catid); } } $cats = ''; if ($type == '4') { $selectstring = "SELECT c.* FROM #__booklibrary_main_categories AS c" . "\nWHERE c.section='com_booklibrary' " . $wherecatid . "\nORDER BY c.parent_id"; $database->setQuery($selectstring); $cats = $database->loadAssocList(); } */ //$retVal = mosBooklibraryImportExport :: exportBooksXML($books, $cats); $retVal = $strXmlDoc; $type2 = 'xml'; switch ($type) { case '1': $type2 = 'csv'; break; case '2': $type2 = 'xml'; break; } $InformationArray = mosBooklibraryImportExport::storeExportFile($retVal, $type2); HTML_booklibrary::showExportResult($InformationArray, $option); }