コード例 #1
0
ファイル: export-v2.php プロジェクト: henryavila/itop
    $sFormat = utils::ReadParam('format', null, true);
    $sFileName = utils::ReadParam('filename', '', true, 'string');
    $bInteractive = utils::ReadParam('interactive', false);
    $sMode = utils::ReadParam('mode', '');
    if ($bInteractive) {
        InteractiveShell($sExpression, $sQueryId, $sFormat, $sFileName, $sMode);
    } else {
        $oExporter = CheckParameters($sExpression, $sQueryId, $sFormat);
        $sMimeType = $oExporter->GetMimeType();
        if ($sMimeType == 'text/html') {
            $oP = new NiceWebPage('iTop export');
            $oP->add_style("body { overflow: auto; }");
            $oP->add_ready_script("\$('table.listResults').tablesorter({widgets: ['MyZebra']});");
        } else {
            $oP = new ajax_page('iTop export');
            $oP->SetContentType($oExporter->GetMimeType());
        }
        DoExport($oP, $oExporter, false);
        $oP->output();
    }
} catch (BulkExportMissingParameterException $e) {
    $oP = new ajax_page('iTop Export');
    $oP->add($e->getMessage());
    Usage($oP);
    $oP->output();
} catch (Exception $e) {
    $oP = new WebPage('iTop Export');
    $oP->add('Error: ' . $e->getMessage());
    IssueLog::Error($e->getMessage() . "\n" . $e->getTraceAsString());
    $oP->output();
}
コード例 #2
0
ファイル: ajax.render.php プロジェクト: kira8565/ITOP203-ZHCN
 require_once APPROOT . '/application/startup.inc.php';
 require_once APPROOT . '/application/user.preferences.class.inc.php';
 require_once APPROOT . '/application/loginwebpage.class.inc.php';
 LoginWebPage::DoLogin(false, true);
 // Check user rights and prompt if needed
 $oPage = new ajax_page("");
 $oPage->no_cache();
 $operation = utils::ReadParam('operation', '');
 $sFilter = stripslashes(utils::ReadParam('filter', '', false, 'raw_data'));
 $sEncoding = utils::ReadParam('encoding', 'serialize');
 $sClass = utils::ReadParam('class', 'MissingAjaxParam', false, 'class');
 $sStyle = utils::ReadParam('style', 'list');
 switch ($operation) {
     case 'datatable':
     case 'pagination':
         $oPage->SetContentType('text/html');
         $extraParams = utils::ReadParam('extra_param', '', false, 'raw_data');
         $aExtraParams = array();
         if (is_array($extraParams)) {
             $aExtraParams = $extraParams;
         } else {
             $sExtraParams = stripslashes($extraParams);
             if (!empty($sExtraParams)) {
                 $val = json_decode(str_replace("'", '"', $sExtraParams), true);
                 if ($val !== null) {
                     $aExtraParams = $val;
                 }
             }
         }
         if ($sEncoding == 'oql') {
             $oFilter = CMDBSearchFilter::FromOQL($sFilter);
コード例 #3
0
ファイル: ajax.csvimport.php プロジェクト: henryavila/itop
 case 'get_csv_template':
     $sClassName = utils::ReadParam('class_name');
     $sFormat = utils::ReadParam('format', 'csv');
     if (MetaModel::IsValidClass($sClassName)) {
         $oSearch = new DBObjectSearch($sClassName);
         $oSearch->AddCondition('id', 0, '=');
         // Make sure we create an empty set
         $oSet = new CMDBObjectSet($oSearch);
         $sResult = cmdbAbstractObject::GetSetAsCSV($oSet, array('showMandatoryFields' => true));
         $sClassDisplayName = MetaModel::GetName($sClassName);
         $sDisposition = utils::ReadParam('disposition', 'inline');
         if ($sDisposition == 'attachment') {
             switch ($sFormat) {
                 case 'xlsx':
                     $oPage = new ajax_page("");
                     $oPage->SetContentType('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
                     $oPage->SetContentDisposition('attachment', $sClassDisplayName . '.xlsx');
                     require_once APPROOT . '/application/excelexporter.class.inc.php';
                     $writer = new XLSXWriter();
                     $writer->setAuthor(UserRights::GetUserFriendlyName());
                     $aHeaders = array(0 => explode(',', $sResult));
                     // comma is the default separator
                     $writer->writeSheet($aHeaders, $sClassDisplayName, array());
                     $oPage->add($writer->writeToString());
                     break;
                 case 'csv':
                 default:
                     $oPage = new CSVPage("");
                     $oPage->add_header("Content-type: text/csv; charset=utf-8");
                     $oPage->add_header("Content-disposition: attachment; filename=\"{$sClassDisplayName}.csv\"");
                     $oPage->no_cache();
コード例 #4
0
ファイル: rest.php プロジェクト: leandroborgeseng/bhtm
} catch (Exception $e) {
    $oResult = new RestResult();
    if ($e->GetCode() == 0) {
        $oResult->code = RestResult::INTERNAL_ERROR;
    } else {
        $oResult->code = $e->GetCode();
    }
    $oResult->message = "Error: " . $e->GetMessage();
}
// Output the results
//
$sResponse = json_encode($oResult);
$oP->add_header('Access-Control-Allow-Origin: *');
$sCallback = utils::ReadParam('callback', null);
if ($sCallback == null) {
    $oP->SetContentType('application/json');
    $oP->add($sResponse);
} else {
    $oP->SetContentType('application/javascript');
    $oP->add($sCallback . '(' . $sResponse . ')');
}
$oP->Output();
// Log usage
//
if (MetaModel::GetConfig()->Get('log_rest_service')) {
    $oLog = new EventRestService();
    $oLog->SetTrim('userinfo', UserRights::GetUser());
    $oLog->Set('version', $sVersion);
    $oLog->Set('operation', $sOperation);
    $oLog->SetTrim('json_input', $sJsonString);
    $oLog->Set('provider', $sProvider);
コード例 #5
0
 /**
  * Helper to download the file directly from the browser	
  */
 public function DownloadBackup($sFile)
 {
     $oP = new ajax_page('backup');
     $oP->SetContentType("multipart/x-zip");
     $oP->SetContentDisposition('inline', basename($sFile));
     $oP->add(file_get_contents($sFile));
     $oP->output();
 }
コード例 #6
0
ファイル: ajax.render.php プロジェクト: leandroborgeseng/bhtm
     if (count($aExcludedClasses) > 0) {
         $oIterator = new RelationTypeIterator($oRelGraph, 'Node');
         foreach ($oIterator as $oNode) {
             $oObj = $oNode->GetProperty('object');
             if ($oObj && in_array(get_class($oObj), $aExcludedClasses)) {
                 $oRelGraph->FilterNode($oNode);
             }
         }
     }
     $oGraph = DisplayableGraph::FromRelationGraph($oRelGraph, $iGroupingThreshold, $sDirection == 'down');
     $oGraph->InitFromGraphviz();
     if ($aPositions != null) {
         $oGraph->UpdatePositions($aPositions);
     }
     $oPage->add($oGraph->GetAsJSON($sContextKey));
     $oPage->SetContentType('application/json');
     break;
 case 'relation_groups':
     $aGroups = utils::ReadParam('groups');
     $iBlock = 1;
     // Zero is not a valid blockid
     foreach ($aGroups as $idx => $aDefinition) {
         $sListClass = $aDefinition['class'];
         $oSearch = new DBObjectSearch($sListClass);
         $oSearch->AddCondition('id', $aDefinition['keys'], 'IN');
         $oPage->add("<h1>" . Dict::Format('UI:RelationGroupNumber_N', 1 + $idx) . "</h1>\n");
         $oPage->add("<div id=\"relation_group_{$idx}\" class=\"page_header\">\n");
         $oPage->add("<h2>" . MetaModel::GetClassIcon($sListClass) . "&nbsp;<span class=\"hilite\">" . Dict::Format('UI:Search:Count_ObjectsOf_Class_Found', count($aDefinition['keys']), Metamodel::GetName($sListClass)) . "</h2>\n");
         $oPage->add("</div>\n");
         $oBlock = new DisplayBlock($oSearch, 'list');
         $oBlock->Display($oPage, 'group_' . $iBlock++);