AntonLV hace 8 años
padre
commit
7f111ba8c7

+ 9 - 2
modules/boonex/market/classes/BxMarketFormEntry.php

@@ -26,8 +26,15 @@ class BxMarketFormEntry extends BxBaseModTextFormEntry
         if(isset($this->aInputs[$CNF['FIELD_TITLE']], $this->aInputs[$CNF['FIELD_NAME']])) {
         	$sJsObject = $this->_oModule->_oConfig->getJsObject('entry');
 
-        	$this->aInputs[$CNF['FIELD_TITLE']]['attrs']['onblur'] = "javascript:" . $sJsObject . ".checkName('" . $CNF['FIELD_TITLE'] . "', '" . $CNF['FIELD_NAME'] . "');";
-        	$this->aInputs[$CNF['FIELD_NAME']]['attrs']['onblur'] = "javascript:" . $sJsObject . ".checkName('" . $CNF['FIELD_TITLE'] . "', '" . $CNF['FIELD_NAME'] . "');";
+        	$aMask = array('mask' => "javascript:%s.checkName('%s', '%s');", $sJsObject, $CNF['FIELD_TITLE'], $CNF['FIELD_NAME']);
+            if($this->aParams['display'] == $CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT'] && bx_get('id') !== false) {
+                $aMask['mask'] = "javascript:%s.checkName('%s', '%s', %d);";
+                $aMask[] = (int)bx_get('id');
+            }
+
+            $sOnBlur = call_user_func_array('sprintf', array_values($aMask)); 
+        	$this->aInputs[$CNF['FIELD_TITLE']]['attrs']['onblur'] = $sOnBlur;
+        	$this->aInputs[$CNF['FIELD_NAME']]['attrs']['onblur'] = $sOnBlur;
         }
 
 	    if(isset($this->aInputs[$CNF['FIELD_FILE']])) {

+ 12 - 1
modules/boonex/market/classes/BxMarketModule.php

@@ -59,13 +59,24 @@ class BxMarketModule extends BxBaseModTextModule
 
     public function actionCheckName()
     {
+        $CNF = &$this->_oConfig->CNF;
+
+        $sName = '';
+
     	$sTitle = bx_process_input(bx_get('title'));
     	if(empty($sTitle))
     		return echoJson(array());
 
+        $iId = (int)bx_get('id');
+        if(!empty($iId)) {
+            $aEntry = $this->_oDb->getContentInfoById($iId); 
+            if(strcmp($sTitle, $aEntry[$CNF['FIELD_NAME']]) == 0) 
+                $sName = $sTitle;
+        }
+
     	echoJson(array(
     		'title' => $sTitle,
-    		'name' => $this->_oConfig->getEntryName($sTitle)
+    		'name' => !empty($sName) ? $sName : $this->_oConfig->getEntryName($sTitle, $iId)
     	));
     }
 

+ 2 - 1
modules/boonex/market/js/entry.js

@@ -44,7 +44,7 @@ BxMarketEntry.prototype.perform = function(oLink, sAction, iId) {
     );
 };
 
-BxMarketEntry.prototype.checkName = function(sTitleId, sNameId) {
+BxMarketEntry.prototype.checkName = function(sTitleId, sNameId, iId) {
 	var oDate = new Date();
 
 	var oName = jQuery("[name='" + sNameId + "']");
@@ -73,6 +73,7 @@ BxMarketEntry.prototype.checkName = function(sTitleId, sNameId) {
 		this._sActionsUrl + 'check_name',
 		{
 			title: sTitleCheck,
+			id: iId && parseInt(iId) > 0 ? iId : 0,
     		_t: oDate.getTime()
     	},
     	function(oData) {