Browse Source

#779 It is possible to record a wrong OQL in the phrase book, but then it cannot be edited anymore!

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2874 a333f486-631f-4898-b8df-5754b55c2be0
romainq 11 năm trước cách đây
mục cha
commit
1d6f682e41
2 tập tin đã thay đổi với 23 bổ sung7 xóa
  1. 18 5
      application/query.class.inc.php
  2. 5 2
      core/oql/oqlexception.class.inc.php

+ 18 - 5
application/query.class.inc.php

@@ -94,13 +94,26 @@ class QueryOQL extends Query
 		{
 			$sUrl = utils::GetAbsoluteUrlAppRoot().'webservices/export.php?format=spreadsheet&login_mode=basic&query='.$this->GetKey();
 			$sOql = $this->Get('oql');
-			$oSearch = DBObjectSearch::FromOQL($sOql);
-			$aParameters = $oSearch->GetQueryParams();
-			foreach($aParameters as $sParam => $val)
+			$sMessage = null;
+			try
 			{
-				$sUrl .= '&arg_'.$sParam.'=["'.$sParam.'"]';
+				$oSearch = DBObjectSearch::FromOQL($sOql);
+				$aParameters = $oSearch->GetQueryParams();
+				foreach($aParameters as $sParam => $val)
+				{
+					$sUrl .= '&arg_'.$sParam.'=["'.$sParam.'"]';
+				}
 			}
-			$oPage->p(Dict::S('UI:Query:UrlForExcel').':<br/><textarea cols="80" rows="3" READONLY>'.$sUrl.'</textarea>');		
+			catch (OQLException $e)
+			{
+				$sMessage = '<div class="message message_error" style="padding-left: 30px;"><div style="padding: 10px;">'.Dict::Format('UI:RunQuery:Error', $e->getHtmlDesc()).'</div></div>';
+			}
+
+			$oPage->p(Dict::S('UI:Query:UrlForExcel').':<br/><textarea cols="80" rows="3" READONLY>'.$sUrl.'</textarea>');
+			if (!is_null($sMessage))
+			{
+				$oPage->p($sMessage);
+			}		
 		}
 		return $aFieldsMap;
 	}

+ 5 - 2
core/oql/oqlexception.class.inc.php

@@ -65,8 +65,11 @@ class OQLException extends CoreException
 
 		if (!is_null($this->m_aExpecting) && (count($this->m_aExpecting) > 0))
 		{
-			$sExpectations = '{'.implode(', ', $this->m_aExpecting).'}';
-			$sRet .= ", expecting ".htmlentities($sExpectations, ENT_QUOTES, 'UTF-8'); 
+			if (count($this->m_aExpecting) < 30)
+			{
+				$sExpectations = '{'.implode(', ', $this->m_aExpecting).'}';
+				$sRet .= ", expecting ".htmlentities($sExpectations, ENT_QUOTES, 'UTF-8');
+			} 
 			$sSuggest = self::FindClosestString($this->m_sUnexpected, $this->m_aExpecting);
 			if (strlen($sSuggest) > 0)
 			{