当前位置: 首页>>代码示例>>PHP>>正文


PHP utils::IsModeCLI方法代码示例

本文整理汇总了PHP中utils::IsModeCLI方法的典型用法代码示例。如果您正苦于以下问题:PHP utils::IsModeCLI方法的具体用法?PHP utils::IsModeCLI怎么用?PHP utils::IsModeCLI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils的用法示例。


在下文中一共展示了utils::IsModeCLI方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: UsageAndExit

function UsageAndExit($oP)
{
    $bModeCLI = utils::IsModeCLI();
    if ($bModeCLI) {
        $oP->p("USAGE:\n");
        $oP->p("php cron.php --auth_user=<login> --auth_pwd=<password> [--param_file=<file>] [--verbose=1] [--debug=1] [--status_only=1]\n");
    } else {
        $oP->p("Optional parameters: verbose, param_file, status_only\n");
    }
    $oP->output();
    exit - 2;
}
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:12,代码来源:cron.php

示例2: UsageAndExit

function UsageAndExit($oP)
{
    global $aPageParams;
    $bModeCLI = utils::IsModeCLI();
    if ($bModeCLI) {
        $oP->p("USAGE:\n");
        $oP->p("php -q synchro_exec.php --auth_user=<login> --auth_pwd=<password> --data_sources=<comma_separated_list_of_data_sources> [max_chunk_size=<limit the count of replica loaded in a single pass>]\n");
    } else {
        $oP->p("The parameter 'data_sources' is mandatory, and must contain a comma separated list of data sources\n");
    }
    $oP->output();
    exit - 2;
}
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:13,代码来源:synchro_exec.php

示例3: UsageAndExit

function UsageAndExit($oP)
{
    global $aPageParams;
    $bModeCLI = utils::IsModeCLI();
    $oP->p("USAGE:\n");
    foreach ($aPageParams as $sParam => $aParamData) {
        $aModes = explode(',', $aParamData['modes']);
        if ($bModeCLI) {
            if (in_array('cli', $aModes)) {
                $sDesc = $aParamData['description'] . ', ' . ($aParamData['mandatory'] ? 'mandatory' : 'optional, defaults to [' . $aParamData['default'] . ']');
                $oP->p("{$sParam} = {$sDesc}");
            }
        } else {
            if (in_array('http', $aModes)) {
                $sDesc = $aParamData['description'] . ', ' . ($aParamData['mandatory'] ? 'mandatory' : 'optional, defaults to [' . $aParamData['default'] . ']');
                $oP->p("{$sParam} = {$sDesc}");
            }
        }
    }
    $oP->output();
    exit;
}
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:22,代码来源:synchro_import.php

示例4: ReadMandatoryParam

require_once APPROOT . '/application/webpage.class.inc.php';
require_once APPROOT . '/application/csvpage.class.inc.php';
require_once APPROOT . '/application/clipage.class.inc.php';
require_once APPROOT . '/application/startup.inc.php';
function ReadMandatoryParam($oP, $sParam, $sSanitizationFilter = 'parameter')
{
    $sValue = utils::ReadParam($sParam, null, true, $sSanitizationFilter);
    if (is_null($sValue)) {
        $oP->p("ERROR: Missing argument '{$sParam}'\n");
        exit(29);
    }
    return trim($sValue);
}
/////////////////////////////////
// Main program
if (!utils::IsModeCLI()) {
    $oP = new WebPage(Dict::S("TitleSynchroExecution"));
    $oP->p("This page is used internally by iTop");
    $oP->output();
    exit - 2;
}
$oP = new CLIPage(Dict::S("TitleSynchroExecution"));
try {
    utils::UseParamFile();
} catch (Exception $e) {
    $oP->p("Error: " . $e->GetMessage());
    $oP->output();
    exit - 2;
}
// Next steps:
//   specific arguments: 'csvfile'
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:31,代码来源:priv_sync_chunk.php

示例5: InteractiveShell

function InteractiveShell($sExpression, $sQueryId, $sFormat, $sFileName, $sMode)
{
    if ($sMode == 'dialog') {
        $oP = new ajax_page('');
        $oP->add('<div id="interactive_export_dlg">');
        $sExportBtnLabel = json_encode(Dict::S('UI:Button:Export'));
        $sJSTitle = json_encode(htmlentities(utils::ReadParam('dialog_title', '', false, 'raw_data'), ENT_QUOTES, 'UTF-8'));
        $oP->add_ready_script(<<<EOF
\t\t\$('#interactive_export_dlg').dialog({
\t\t\tautoOpen: true,
\t\t\tmodal: true,
\t\t\twidth: '80%',
\t\t\ttitle: {$sJSTitle},
\t\t\tclose: function() { \$('#export-form').attr('data-state', 'cancelled'); \$(this).remove(); },
\t\t\tbuttons: [
\t\t\t\t{text: {$sExportBtnLabel}, id: 'export-dlg-submit', click: function() {} }
\t\t\t]
\t\t});
\t\t\t
\t\tsetTimeout(function() { \$('#interactive_export_dlg').dialog('option', { position: { my: "center", at: "center", of: window }}); \$('#export-btn').hide(); ExportInitButton('#export-dlg-submit'); }, 100);
EOF
);
    } else {
        $oP = new iTopWebPage('iTop Export');
    }
    if ($sExpression === null) {
        // No expression supplied, let's check if phrasebook entry is given
        if ($sQueryId !== null) {
            $oSearch = DBObjectSearch::FromOQL('SELECT QueryOQL WHERE id = :query_id', array('query_id' => $sQueryId));
            $oQueries = new DBObjectSet($oSearch);
            if ($oQueries->Count() > 0) {
                $oQuery = $oQueries->Fetch();
                $sExpression = $oQuery->Get('oql');
                $sFields = trim($oQuery->Get('fields'));
            } else {
                ReportErrorAndExit("Invalid query phrasebook identifier: '{$sQueryId}'");
            }
        } else {
            if (utils::IsModeCLI()) {
                Usage();
                ReportErrorAndExit("No expression or query phrasebook identifier supplied.");
            } else {
                // form to enter an OQL query or pick a query phrasebook identifier
                DisplayForm($oP, utils::GetAbsoluteUrlAppRoot() . 'webservices/export-v2.php', $sExpression, $sQueryId, $sFormat);
                $oP->output();
                exit;
            }
        }
    }
    if ($sFormat !== null) {
        $oExporter = BulkExport::FindExporter($sFormat);
        if ($oExporter === null) {
            $aSupportedFormats = BulkExport::FindSupportedFormats();
            ReportErrorAndExit("Invalid output format: '{$sFormat}'. The supported formats are: " . implode(', ', array_keys($aSupportedFormats)));
        } else {
            DisplayForm($oP, utils::GetAbsoluteUrlAppRoot() . 'webservices/export-v2.php', $sExpression, $sQueryId, $sFormat);
        }
    } else {
        DisplayForm($oP, utils::GetAbsoluteUrlAppRoot() . 'webservices/export-v2.php', $sExpression, $sQueryId, $sFormat);
    }
    if ($sMode == 'dialog') {
        $oP->add('</div>');
    }
    $oP->output();
}
开发者ID:henryavila,项目名称:itop,代码行数:65,代码来源:export-v2.php

示例6: DoSynchronize

 /**
  * Do the entire synchronization job
  */
 protected function DoSynchronize()
 {
     $this->m_oStatLog->Set('status_curr_job', 1);
     $this->m_oStatLog->Set('status_curr_pos', -1);
     $iMaxChunkSize = utils::ReadParam('max_chunk_size', 0, true);
     if ($iMaxChunkSize > 0) {
         // Split the execution into several processes
         // Each process will call DoSynchronizeChunk()
         // The loop will end when a process does not reply "continue" on the last line of its output
         if (!utils::IsModeCLI()) {
             throw new SynchroExceptionNotStarted(Dict::S('Core:SyncSplitModeCLIOnly'));
         }
         $aArguments = array();
         $aArguments['source'] = $this->m_oDataSource->GetKey();
         $aArguments['log'] = $this->m_oStatLog->GetKey();
         $aArguments['change'] = $this->m_oChange->GetKey();
         $aArguments['chunk'] = $iMaxChunkSize;
         if ($this->m_oLastFullLoadStartDate) {
             $aArguments['last_full_load'] = $this->m_oLastFullLoadStartDate->Format('Y-m-d H:i:s');
         } else {
             $aArguments['last_full_load'] = '';
         }
         $this->m_oStatLog->DBUpdate($this->m_oChange);
         $iStepCount = 0;
         do {
             $aArguments['step_count'] = $iStepCount;
             $iStepCount++;
             list($iRes, $aOut) = utils::ExecITopScript('synchro/priv_sync_chunk.php', $aArguments);
             // Reload the log that has been modified by the processes
             $this->m_oStatLog->Reload();
             $sLastRes = strtolower(trim(end($aOut)));
             switch ($sLastRes) {
                 case 'continue':
                     $bContinue = true;
                     break;
                 case 'finished':
                     $bContinue = false;
                     break;
                 default:
                     $this->m_oStatLog->AddTrace("The script did not reply with the expected keywords:");
                     $aIndentedOut = array();
                     foreach ($aOut as $sOut) {
                         $aIndentedOut[] = "-> {$sOut}";
                         $this->m_oStatLog->AddTrace(">>> {$sOut}");
                     }
                     throw new Exception("Encountered an error in an underspinned process:\n" . implode("\n", $aIndentedOut));
             }
         } while ($bContinue);
     } else {
         $this->PrepareProcessing();
         $this->DoJob1();
         $this->DoJob2();
         $this->DoJob3();
     }
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:58,代码来源:synchrodatasource.class.inc.php

示例7: catch

                    $oP->add("Unsupported format '{$sFormat}'. Possible values are: html, csv, spreadsheet or xml.");
            }
        }
    } catch (Exception $e) {
        $oP = new WebPage("iTop - Export");
        $oP->p("Error the query can not be executed.");
        if ($e instanceof CoreException) {
            $oP->p($e->GetHtmlDesc());
        } else {
            $oP->p($e->getMessage());
        }
    }
}
if (!$oP) {
    // Display a short message about how to use this page
    $bModeCLI = utils::IsModeCLI();
    if ($bModeCLI) {
        $oP = new CLIPage("iTop - Export");
    } else {
        $oP = new WebPage("iTop - Export");
    }
    $oP->p("General purpose export page.");
    $oP->p("Parameters:");
    $oP->p(" * expression: an OQL expression (URL encoded if needed)");
    $oP->p(" * query: (alternative to 'expression') the id of an entry from the query phrasebook");
    $oP->p(" * arg_xxx: (needed if the query has parameters) the value of the parameter 'xxx'");
    $oP->p(" * format: (optional, default is html) the desired output format. Can be one of 'html', 'spreadsheet', 'csv', 'xlsx' or 'xml'");
    $oP->p(" * fields: (optional, no effect on XML format) list of fields (attribute codes, or alias.attcode) separated by a coma");
    $oP->p(" * fields_advanced: (optional, no effect on XML/HTML formats ; ignored is fields is specified) If set to 1, the default list of fields will include the external keys and their reconciliation keys");
    $oP->p(" * filename: (optional, no effect in CLI mode) if set then the results will be downloaded as a file");
}
开发者ID:henryavila,项目名称:itop,代码行数:31,代码来源:export.php

示例8: Usage

function Usage($oP)
{
    $oP->p('Perform a backup of the iTop database by running mysqldump');
    $oP->p('Parameters:');
    if (utils::IsModeCLI()) {
        $oP->p('auth_user: login, must be administrator');
        $oP->p('auth_pwd: ...');
    }
    $oP->p('backup_file [optional]: name of the file to store the backup into. Follows the PHP strftime format spec. The following placeholders are available: __HOST__, __DB__, __SUBNAME__');
    $oP->p('simulate [optional]: set to check the name of the file that would be created');
    $oP->p('mysql_bindir [optional]: specify the path for mysqldump');
    if (utils::IsModeCLI()) {
        $oP->p('Example: php -q backup.php --auth_user=admin --auth_pwd=myPassw0rd');
        $oP->p('Known limitation: the current directory must be the directory of backup.php');
    } else {
        $oP->p('Example: .../backup.php?backup_file=/tmp/backup.__DB__-__SUBNAME__.%Y-%m');
    }
}
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:18,代码来源:backup.php


注:本文中的utils::IsModeCLI方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。