Sfoglia il codice sorgente

#47 Replaced every occurence of deprecated verb split() by explode()

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@224 a333f486-631f-4898-b8df-5754b55c2be0
romainq 15 anni fa
parent
commit
72e5bcf5e2

+ 5 - 5
core/csvparser.class.inc.php

@@ -70,7 +70,7 @@ class CSVParser
 			$aStatsBySeparator[$sSep] = array();
 		}
 	
-		foreach(split("\n", $this->m_sCSVData) as $sLine)
+		foreach(explode("\n", $this->m_sCSVData) as $sLine)
 		{
 			$sLine = trim($sLine);
 			if (substr($sLine, 0, 1) == '#') continue;
@@ -106,13 +106,13 @@ class CSVParser
 		// Take the FIRST -valuable- LINE ONLY
 		// If there is a number, then for sure this is not a header line
 		// Otherwise, we may consider that there is one line to skip
-		foreach(split("\n", $this->m_sCSVData) as $sLine)
+		foreach(explode("\n", $this->m_sCSVData) as $sLine)
 		{
 			$sLine = trim($sLine);
 			if (substr($sLine, 0, 1) == '#') continue;
 			if (empty($sLine)) continue;
 	
-			foreach (split($this->m_sSep, $sLine) as $value)
+			foreach (explode($this->m_sSep, $sLine) as $value)
 			{
 				if (is_numeric($value))
 				{
@@ -133,7 +133,7 @@ class CSVParser
 	
 		$iCount = 0;
 		$iSkipped = 0;
-		foreach(split("\n", $this->m_sCSVData) as $sLine)
+		foreach(explode("\n", $this->m_sCSVData) as $sLine)
 		{
 			$sLine = trim($sLine);
 			if (substr($sLine, 0, 1) == '#') continue;
@@ -145,7 +145,7 @@ class CSVParser
 				continue;
 			}
 	
-			foreach (split($this->m_sSep, $sLine) as $iCol=>$sValue)
+			foreach (explode($this->m_sSep, $sLine) as $iCol=>$sValue)
 			{
 				if (is_array($aFieldMap)) $sColRef = $aFieldMap[$iCol];
 				else                      $sColRef = $iCol;

+ 2 - 2
core/data.generator.class.inc.php

@@ -206,7 +206,7 @@ class cmdbDataGenerator
 	function GenerateString($sTemplate)
 	{
 		$sResult = "";
-		$aParts = split("\|", $sTemplate);
+		$aParts = explode("\|", $sTemplate);
 		foreach($aParts as $sPart)
 		{
 			if (preg_match("/domain\(\)/", $sPart, $aMatches))
@@ -216,7 +216,7 @@ class cmdbDataGenerator
 			elseif (preg_match("/enum\((.+)\)/", $sPart, $aMatches))
 			{
 				$sEnumValues = $aMatches[1];
-				$aEnumValues = split(",", $sEnumValues);
+				$aEnumValues = explode(",", $sEnumValues);
 				$sResult .= $aEnumValues[rand(0, count($aEnumValues) - 1)];
 			}
 			elseif (preg_match("/number\((\d+)-(\d+)\)/", $sPart, $aMatches))

+ 11 - 4
core/dbobjectsearch.class.php

@@ -163,7 +163,14 @@ class DBObjectSearch
 	
 	public function __DescribeHTML()
 	{
-		$sConditionDesc = $this->DescribeConditions();
+		try
+		{
+			$sConditionDesc = $this->DescribeConditions();
+		}
+		catch (MissingQueryArgument $e)
+		{
+			$sConditionDesc = '?missing query argument?';
+		}
 		if (!empty($sConditionDesc))
 		{
 			return "Objects of class '$this->m_sClass', $sConditionDesc";
@@ -525,14 +532,14 @@ class DBObjectSearch
 		// -> return (unserialize(base64_decode($sValue)));
 
 		$sClearText = base64_decode($sValue);
-		$aValues = split("\n", $sClearText);
+		$aValues = explode("\n", $sClearText);
 		$i = 0;
 		$sClass = $aValues[$i++];
 		$sClassAlias = $aValues[$i++];
 		$oFilter = new DBObjectSearch($sClass, $sClassAlias);
 		while($i < count($aValues) && !empty($aValues[$i]))
 		{
-			$aCondition = split(":", $aValues[$i++]);
+			$aCondition = explode(":", $aValues[$i++]);
 			switch ($aCondition[0])
 			{
 			case "A":
@@ -940,7 +947,7 @@ class DBObjectSearch
 		{
 			$sClass = trim(substr($sQuery, 0, $iSepPos));
 			$sConds = trim(substr($sQuery, $iSepPos + 1));
-			$aValues = split(" AND ", $sConds);
+			$aValues = explode(" AND ", $sConds);
 	
 			$oFilter = new DBObjectSearch($sClass);