Example #1
0
 case 'export_dashboard':
     $sMenuId = utils::ReadParam('id', '', false, 'raw_data');
     ApplicationMenu::LoadAdditionalMenus();
     $index = ApplicationMenu::GetMenuIndexById($sMenuId);
     $oMenu = ApplicationMenu::GetMenuNode($index);
     if ($oMenu instanceof DashboardMenuNode) {
         $oDashboard = $oMenu->GetDashboard();
         $oPage->TrashUnexpectedOutput();
         $oPage->SetContentType('text/xml');
         $oPage->SetContentDisposition('attachment', $oMenu->GetLabel() . '.xml');
         $oPage->add($oDashboard->ToXml());
     }
     break;
 case 'import_dashboard':
     $sMenuId = utils::ReadParam('id', '', false, 'raw_data');
     ApplicationMenu::LoadAdditionalMenus();
     $index = ApplicationMenu::GetMenuIndexById($sMenuId);
     $oMenu = ApplicationMenu::GetMenuNode($index);
     $aResult = array('error' => '');
     try {
         if ($oMenu instanceof DashboardMenuNode) {
             $oDoc = utils::ReadPostedDocument('dashboard_upload_file');
             $oDashboard = $oMenu->GetDashboard();
             $oDashboard->FromXml($oDoc->GetData());
             $oDashboard->Save();
         } else {
             $aResult['error'] = 'Dashboard id="' . $sMenuId . '" not found.';
         }
     } catch (DOMException $e) {
         $aResult = array('error' => Dict::S('UI:Error:InvalidDashboardFile'));
     } catch (Exception $e) {