// cleaning up empty external data
		if(is_array($formData['EXTERNAL']) && !empty($formData['EXTERNAL']))
		{
			foreach($formData['EXTERNAL'] as $eId => $external)
			{
				if(!strlen($external['XML_ID']))
					unset($formData['EXTERNAL'][$eId]);
			}
		}
	}
	else
	{
		if($readAsId)
		{
			// load from database
			$formData = Helper::getFormData($readAsId);

			if($readAsId)
			{
				$langU = ToUpper(LANGUAGE_ID);
				$nameToDisplay = strlen($formData['NAME_'.$langU]) ? $formData['NAME_'.$langU] : $formData['CODE'];
			}
		}
		else
		{
			// load blank form, optionally with parent id filled up
			$formData = array();
			if($parentId)
				$formData['PARENT_ID'] = $parentId;
		}
	}
Esempio n. 2
0
 /**
  * Here we get some data that cannot be cached for a long time
  * @return void
  */
 protected function obtainNonCachedData()
 {
     $this->dbResult['FORM_DATA'] = array();
     if ($this->componentData['ACTION_FAILURE']) {
         $this->dbResult['FORM_DATA'] = $this->dbResult['REQUEST']['POST'];
     } else {
         if ($this->componentData['LOCATION_ID'] > 0) {
             $arLoc = Helper::getFormData($this->componentData['LOCATION_ID']);
             if (!$arLoc) {
                 $this->errors['FATAL'][] = Loc::getMessage('CRM_CLE2_LOC_NOT_FOUND');
                 @define('ERROR_404', 'Y');
                 if ($this->arParams['SET_STATUS_404'] === 'Y') {
                     CHTTP::SetStatus("404 Not Found");
                 }
                 return false;
             }
             $this->dbResult['FORM_DATA'] = $arLoc;
         }
     }
     // special case for PARENT_ID
     if (!isset($this->dbResult['FORM_DATA']['PARENT_ID']) && intval($this->dbResult['REQUEST']['GET']['PARENT_ID'])) {
         $this->dbResult['FORM_DATA']['PARENT_ID'] = intval($this->dbResult['REQUEST']['GET']['PARENT_ID']);
     }
     $this->dbResult['LOCATION_ID'] = $this->componentData['LOCATION_ID'];
     if (!$this->dbResult['CALCULATED_BACK_URL']) {
         // by default back url is root item list
         $this->dbResult['CALCULATED_BACK_URL'] = CComponentEngine::MakePathFromTemplate($this->arParams['PATH_TO_LOCATIONS_LIST']);
         // if element exists, back url will be to it`s parent list
         if ($this->componentData['LOCATION_ID']) {
             $this->dbResult['CALCULATED_BACK_URL'] . '?PARENT_ID=' . intval($this->dbResult['FORM_DATA']['PARENT_ID']);
         }
     }
     return true;
 }