#162 Implemented the non interactive bulk load (REST, CLI not implemented)

SVN:trunk[818]
This commit is contained in:
Romain Quetiez
2010-09-11 13:36:16 +00:00
parent 500767c582
commit 2ad6c0594d
8 changed files with 909 additions and 163 deletions

View File

@@ -45,12 +45,51 @@ class CSVPage extends WebPage
echo trim($this->s_content);
}
public function small_p($sText)
{
public function small_p($sText)
{
}
public function add($sText)
{
$this->s_content .= $sText;
}
public function p($sText)
{
$this->s_content .= $sText."\n";
}
public function add_comment($sText)
{
$this->s_content .= "#".$sText."\n";
}
public function table($aConfig, $aData, $aParams = array())
{
$aCells = array();
foreach($aConfig as $sName=>$aDef)
{
if (strlen($aDef['description']) > 0)
{
$aCells[] = $aDef['label'].' ('.$aDef['description'].')';
}
else
{
$aCells[] = $aDef['label'];
}
}
$this->s_content .= implode(';', $aCells)."\n";
foreach($aData as $aRow)
{
$aCells = array();
foreach($aConfig as $sName=>$aAttribs)
{
$sValue = $aRow["$sName"];
$aCells[] = $sValue;
}
$this->s_content .= implode(';', $aCells)."\n";
}
}
}

View File

@@ -42,9 +42,40 @@ class utils
private static $m_sConfigFile = ITOP_CONFIG_FILE;
private static $m_oConfig = null;
public static function ReadParam($sName, $defaultValue = "")
public static function IsModeCLI()
{
return isset($_REQUEST[$sName]) ? $_REQUEST[$sName] : $defaultValue;
global $argv;
if (isset($argv))
{
return true;
}
else
{
return false;
}
}
public static function ReadParam($sName, $defaultValue = "", $bAllowCLI = false)
{
global $argv;
$retValue = $defaultValue;
if (isset($_REQUEST[$sName]))
{
$retValue = $_REQUEST[$sName];
}
elseif ($bAllowCLI && isset($argv))
{
foreach($argv as $iArg => $sArg)
{
if (preg_match('/^--'.$sName.'=(.*)$/', $sArg, $aMatches))
{
$retValue = $aMatches[1];
}
}
}
return $retValue;
}
public static function ReadPostedParam($sName, $defaultValue = "")