function saveExportTemplatesPeekAction() { if (null == ($active_worker = CerberusApplication::getActiveWorker()) || !$active_worker->is_superuser) { exit; } @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', '')); @($portal = DevblocksPlatform::importGPC($_REQUEST['portal'], 'string', '')); @($filename = DevblocksPlatform::importGPC($_REQUEST['filename'], 'string', '')); @($author = DevblocksPlatform::importGPC($_REQUEST['author'], 'string', '')); @($email = DevblocksPlatform::importGPC($_REQUEST['email'], 'string', '')); // Build XML file $xml = simplexml_load_string('<?xml version="1.0" encoding="' . LANG_CHARSET_CODE . '"?>' . '<cerb5>' . '<templates>' . '</templates>' . '</cerb5>'); /* @var $xml SimpleXMLElement */ // Author $eAuthor =& $xml->templates->addChild('author'); /* @var $eAuthor SimpleXMLElement */ $eAuthor->addChild('name', htmlspecialchars($author)); $eAuthor->addChild('email', htmlspecialchars($email)); // Load view if (null == ($view = C4_AbstractViewLoader::getView($view_id))) { exit; } // Load all data $view->renderLimit = -1; $view->renderPage = 0; list($results, $null) = $view->getData(); // Add template if (is_array($results)) { foreach ($results as $result) { // Load content if (null == ($template = DAO_DevblocksTemplate::get($result[SearchFields_DevblocksTemplate::ID]))) { continue; } $eTemplate =& $xml->templates->addChild('template', htmlspecialchars($template->content)); /* @var $eTemplate SimpleXMLElement */ $eTemplate->addAttribute('plugin_id', htmlspecialchars($template->plugin_id)); $eTemplate->addAttribute('path', htmlspecialchars($template->path)); } } // Format download file $imp = new DOMImplementation(); $doc = $imp->createDocument("", ""); $doc->encoding = LANG_CHARSET_CODE; $doc->formatOutput = true; $simplexml = dom_import_simplexml($xml); /* @var $dom DOMElement */ $simplexml = $doc->importNode($simplexml, true); $simplexml = $doc->appendChild($simplexml); header("Content-type: text/xml"); header("Content-Disposition: attachment; filename=\"{$filename}\""); echo $doc->saveXML(); exit; }