⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fe_adminlib.inc

📁 Typo3, 开源里边最强大的
💻 INC
📖 第 1 页 / 共 5 页
字号:
			if (!trim($this->dataArr[$theField]))	{				$tempArr[]=$theField;			}		}		// Evaluate: This evaluates for more advanced things than 'required' does. But it returns the same error code, so you must let the required-message tell, if further evaluation has failed!		$recExist=0;		if (is_array($this->conf[$this->cmdKey.'.']['evalValues.']))	{			switch($this->cmd)	{				case 'edit':					if (isset($this->dataArr['pid']))	{			// This may be tricked if the input has the pid-field set but the edit-field list does NOT allow the pid to be edited. Then the pid may be false.						$recordTestPid = intval($this->dataArr['pid']);					} else {						$tempRecArr = $GLOBALS['TSFE']->sys_page->getRawRecord($this->theTable,$this->dataArr['uid']);						$recordTestPid = intval($tempRecArr['pid']);					}					$recExist=1;				break;				default:					$recordTestPid = $this->thePid ? $this->thePid : t3lib_div::intval_positive($this->dataArr['pid']);				break;			}			reset($this->conf[$this->cmdKey.'.']['evalValues.']);			while(list($theField,$theValue)=each($this->conf[$this->cmdKey.'.']['evalValues.']))	{				$listOfCommands = t3lib_div::trimExplode(',',$theValue,1);				while(list(,$cmd)=each($listOfCommands))	{					$cmdParts = split('\[|\]',$cmd);	// Point is to enable parameters after each command enclosed in brackets [..]. These will be in position 1 in the array.					$theCmd = trim($cmdParts[0]);					switch($theCmd)	{						case 'uniqueGlobal':							if ($DBrows = $GLOBALS['TSFE']->sys_page->getRecordsByField($this->theTable,$theField,$this->dataArr[$theField],'','','','1'))	{								if (!$recExist || $DBrows[0]['uid']!=$this->dataArr['uid'])	{	// Only issue an error if the record is not existing (if new...) and if the record with the false value selected was not our self.									$tempArr[]=$theField;									$this->failureMsg[$theField][] = $this->getFailure($theField, $theCmd, 'The value existed already. Enter a new value.');								}							}						break;						case 'uniqueLocal':							if ($DBrows = $GLOBALS['TSFE']->sys_page->getRecordsByField($this->theTable,$theField,$this->dataArr[$theField], 'AND pid IN ('.$recordTestPid.')','','','1'))	{								if (!$recExist || $DBrows[0]['uid']!=$this->dataArr['uid'])	{	// Only issue an error if the record is not existing (if new...) and if the record with the false value selected was not our self.									$tempArr[]=$theField;									$this->failureMsg[$theField][] = $this->getFailure($theField, $theCmd, 'The value existed already. Enter a new value.');								}							}						break;						case 'twice':							if (strcmp($this->dataArr[$theField], $this->dataArr[$theField.'_again']))	{								$tempArr[]=$theField;								$this->failureMsg[$theField][] = $this->getFailure($theField, $theCmd, 'You must enter the same value twice');							}						break;						case 'email':							if (!$this->cObj->checkEmail($this->dataArr[$theField]))	{								$tempArr[]=$theField;								$this->failureMsg[$theField][] = $this->getFailure($theField, $theCmd, 'You must enter a valid email address');							}						break;						case 'required':							if (!trim($this->dataArr[$theField]))	{								$tempArr[]=$theField;								$this->failureMsg[$theField][] = $this->getFailure($theField, $theCmd, 'You must enter a value!');							}						break;						case 'atLeast':							$chars=intval($cmdParts[1]);							if (strlen($this->dataArr[$theField])<$chars)	{								$tempArr[]=$theField;								$this->failureMsg[$theField][] = sprintf($this->getFailure($theField, $theCmd, 'You must enter at least %s characters!'), $chars);							}						break;						case 'atMost':							$chars=intval($cmdParts[1]);							if (strlen($this->dataArr[$theField])>$chars)	{								$tempArr[]=$theField;								$this->failureMsg[$theField][] = sprintf($this->getFailure($theField, $theCmd, 'You must enter at most %s characters!'), $chars);							}						break;						case 'inBranch':							$pars = explode(';',$cmdParts[1]);							if (intval($pars[0]))	{								$pid_list = $this->cObj->getTreeList(									intval($pars[0]),									intval($pars[1]) ? intval($pars[1]) : 999,									intval($pars[2])								);								if (!$pid_list || !t3lib_div::inList($pid_list,$this->dataArr[$theField]))	{									$tempArr[]=$theField;									$this->failureMsg[$theField][] = sprintf($this->getFailure($theField, $theCmd, 'The value was not a valid valud from this list: %s'), $pid_list);								}							}						break;						case 'unsetEmpty':							if (!$this->dataArr[$theField])	{								$hash = array_flip($tempArr);								unset($hash[$theField]);								$tempArr = array_keys($hash);								unset($this->failureMsg[$theField]);								unset($this->dataArr[$theField]);	// This should prevent the field from entering the database.							}						break;					}				}				$this->markerArray['###EVAL_ERROR_FIELD_'.$theField.'###'] = is_array($this->failureMsg[$theField]) ? implode('<br />',$this->failureMsg[$theField]) : '';			}		}		$this->failure=implode(',',$tempArr);	 //$failure will show which fields were not OK	}	/**	 * Preforms user processing of input array - triggered right after the function call to evalValues() IF TypoScript property "evalFunc" was set.	 *	 * @param	string		Key pointing to the property in TypoScript holding the configuration for this processing (here: "evalFunc.*"). Well: at least its safe to say that "parentObj" in this array passed to the function is a reference back to this object.	 * @param	array		The $this->dataArr passed for processing	 * @return	array		The processed $passVar ($this->dataArr)	 * @see init(), evalValues()	 */	function userProcess($mConfKey,$passVar)	{		if ($this->conf[$mConfKey])	{			$funcConf = $this->conf[$mConfKey.'.'];			$funcConf['parentObj']=&$this;			$passVar = $GLOBALS['TSFE']->cObj->callUserFunction($this->conf[$mConfKey], $funcConf, $passVar);		}		return $passVar;	}	/**	 * User processing of contnet	 *	 * @param	string		Value of the TypoScript object triggering the processing.	 * @param	array		Properties of the TypoScript object triggering the processing. The key "parentObj" in this array is passed to the function as a reference back to this object.	 * @param	mixed		Input variable to process	 * @return	mixed		Processed input variable, $passVar	 * @see userProcess(), save(), modifyDataArrForFormUpdate()	 */	function userProcess_alt($confVal,$confArr,$passVar)	{		if ($confVal)	{			$funcConf = $confArr;			$funcConf['parentObj']=&$this;			$passVar = $GLOBALS['TSFE']->cObj->callUserFunction($confVal, $funcConf, $passVar);		}		return $passVar;	}	/*****************************************	 *	 * Database manipulation functions	 *	 *****************************************/	/**	 * Performs the saving of records, either edited or created.	 *	 * @return	void	 * @see init()	 */	function save()	{		switch($this->cmd)	{			case 'edit':				$theUid = $this->dataArr['uid'];				$origArr = $GLOBALS['TSFE']->sys_page->getRawRecord($this->theTable,$theUid);		// Fetches the original record to check permissions				if ($this->conf['edit'] && ($GLOBALS['TSFE']->loginUser || $this->aCAuth($origArr)))	{	// Must be logged in in order to edit  (OR be validated by email)					$newFieldList = implode(',',array_intersect(explode(',',$this->fieldList),t3lib_div::trimExplode(',',$this->conf['edit.']['fields'],1)));					if ($this->aCAuth($origArr) || $this->cObj->DBmayFEUserEdit($this->theTable,$origArr,$GLOBALS['TSFE']->fe_user->user,$this->conf['allowedGroups'],$this->conf['fe_userEditSelf']))	{						$this->cObj->DBgetUpdate($this->theTable, $theUid, $this->dataArr, $newFieldList, TRUE);						$this->currentArr = $GLOBALS['TSFE']->sys_page->getRawRecord($this->theTable,$theUid);						$this->userProcess_alt($this->conf['edit.']['userFunc_afterSave'],$this->conf['edit.']['userFunc_afterSave.'],array('rec'=>$this->currentArr, 'origRec'=>$origArr));						$this->saved=1;					} else {						$this->error='###TEMPLATE_NO_PERMISSIONS###';					}				}			break;			default:				if ($this->conf['create'])	{					$newFieldList = implode(',',array_intersect(explode(',',$this->fieldList),t3lib_div::trimExplode(',',$this->conf['create.']['fields'],1)));					$this->cObj->DBgetInsert($this->theTable, $this->thePid, $this->dataArr, $newFieldList, TRUE);					$newId = $GLOBALS['TYPO3_DB']->sql_insert_id();					if ($this->theTable=='fe_users' && $this->conf['fe_userOwnSelf'])	{		// enables users, creating logins, to own them self.						$extraList='';						$dataArr = array();						if ($GLOBALS['TCA'][$this->theTable]['ctrl']['fe_cruser_id'])		{							$field=$GLOBALS['TCA'][$this->theTable]['ctrl']['fe_cruser_id'];							$dataArr[$field]=$newId;							$extraList.=','.$field;						}						if ($GLOBALS['TCA'][$this->theTable]['ctrl']['fe_crgroup_id'])	{							$field=$GLOBALS['TCA'][$this->theTable]['ctrl']['fe_crgroup_id'];							list($dataArr[$field])=explode(',',$this->dataArr['usergroup']);							$dataArr[$field]=intval($dataArr[$field]);							$extraList.=','.$field;						}						if (count($dataArr))	{							$this->cObj->DBgetUpdate($this->theTable, $newId, $dataArr, $extraList, TRUE);						}					}					$this->currentArr = $GLOBALS['TSFE']->sys_page->getRawRecord($this->theTable,$newId);					$this->userProcess_alt($this->conf['create.']['userFunc_afterSave'],$this->conf['create.']['userFunc_afterSave.'],array('rec'=>$this->currentArr));					$this->saved=1;				}			break;		}	}	/**	 * Deletes the record from table/uid, $this->theTable/$this->recUid, IF the fe-user has permission to do so.	 * If the deleted flag should just be set, then it is done so. Otherwise the record truely is deleted along with any attached files.	 * Called from init() if "cmd" was set to "delete" (and some other conditions)	 *	 * @return	string		void	 * @see init()	 */	function deleteRecord()	{		if ($this->conf['delete'])	{	// If deleting is enabled			$origArr = $GLOBALS['TSFE']->sys_page->getRawRecord($this->theTable,  $this->recUid);			if ($GLOBALS['TSFE']->loginUser || $this->aCAuth($origArr))	{	// Must be logged in OR be authenticated by the aC code in order to delete					// If the recUid selects a record.... (no check here)				if (is_array($origArr))	{					if ($this->aCAuth($origArr) || $this->cObj->DBmayFEUserEdit($this->theTable,$origArr, $GLOBALS['TSFE']->fe_user->user,$this->conf['allowedGroups'],$this->conf['fe_userEditSelf']))	{	// Display the form, if access granted.						if (!$GLOBALS['TCA'][$this->theTable]['ctrl']['delete'])	{	// If the record is fully deleted... then remove the image (or any file) attached.							$this->deleteFilesFromRecord($this->recUid);						}						$this->cObj->DBgetDelete($this->theTable, $this->recUid, TRUE);						$this->currentArr = $origArr;						$this->saved = 1;					} else {						$this->error = '###TEMPLATE_NO_PERMISSIONS###';					}				}			}		}	}	/**	 * Deletes the files attached to a record and updates the record.	 * Table/uid is $this->theTable/$uid	 *	 * @param	integer		Uid number of the record to delete from $this->theTable	 * @return	void	 * @access private	 * @see deleteRecord()	 */	function deleteFilesFromRecord($uid)	{		$table = $this->theTable;		$rec = $GLOBALS['TSFE']->sys_page->getRawRecord($table,$uid);		$GLOBALS['TSFE']->includeTCA();		t3lib_div::loadTCA($table);		reset($GLOBALS['TCA'][$table]['columns']);		$iFields=array();		while(list($field,$conf)=each($GLOBALS['TCA'][$table]['columns']))	{			if ($conf['config']['type']=='group' && $conf['config']['internal_type']=='file')	{				$GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid='.intval($uid), array($field => ''));				$delFileArr = explode(',',$rec[$field]);				reset($delFileArr);				while(list(,$n)=each($delFileArr))	{					if ($n)	{						$fpath = $conf['config']['uploadfolder'].'/'.$n;						unlink($fpath);					}				}			}		}	}	/*****************************************	 *	 * Command "display" functions	 *	 *****************************************/	/**	 * Creates the preview display of delete actions	 *	 * @return	string		HTML content	 * @see init()	 */	function displayDeleteScreen()	{		if ($this->conf['delete'])	{	// If deleting is enabled			$origArr = $GLOBALS['TSFE']->sys_page->getRawRecord($this->theTable,  $this->recUid);			if ($GLOBALS['TSFE']->loginUser || $this->aCAuth($origArr))	{	// Must be logged in OR be authenticated by the aC code in order to delete					// If the recUid selects a record.... (no check here)				if (is_array($origArr))	{					if ($this->aCAuth($origArr) || $this->cObj->DBmayFEUserEdit($this->theTable,$origArr, $GLOBALS['TSFE']->fe_user->user,$this->conf['allowedGroups'],$this->conf['fe_userEditSelf']))	{	// Display the form, if access granted.						$this->markerArray['###HIDDENFIELDS###'].= '<input type="hidden" name="rU" value="'.$this->recUid.'" />';						$content = $this->getPlainTemplate('###TEMPLATE_DELETE_PREVIEW###', $origArr);					} else {	// Else display error, that you could not edit that particular record...						$content = $this->getPlainTemplate('###TEMPLATE_NO_PERMISSIONS###');					}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -