📄 fe_adminlib.inc
字号:
} } else { // Finally this is if there is no login user. This must tell that you must login. Perhaps link to a page with create-user or login information. $content = $this->getPlainTemplate('###TEMPLATE_AUTH###'); } } else { $content.='Delete-option is not set in TypoScript'; } return $content; } /** * Creates the "create" screen for records * * @return string HTML content * @see init() */ function displayCreateScreen() { if ($this->conf['create']) { $templateCode = $this->cObj->getSubpart($this->templateCode, ((!$GLOBALS['TSFE']->loginUser||$this->conf['create.']['noSpecialLoginForm'])?'###TEMPLATE_CREATE'.$this->previewLabel.'###':'###TEMPLATE_CREATE_LOGIN'.$this->previewLabel.'###')); $failure = t3lib_div::_GP('noWarnings')?'':$this->failure; if (!$failure) $templateCode = $this->cObj->substituteSubpart($templateCode, '###SUB_REQUIRED_FIELDS_WARNING###', ''); $templateCode = $this->removeRequired($templateCode,$failure); $this->setCObjects($templateCode); $markerArray = $this->cObj->fillInMarkerArray($this->markerArray, $this->dataArr, '', TRUE, 'FIELD_', $this->recInMarkersHSC); if ($this->conf['create.']['preview'] && !$this->previewLabel) {$markerArray['###HIDDENFIELDS###'].= '<input type="hidden" name="preview" value="1" />';} $content = $this->cObj->substituteMarkerArray($templateCode, $markerArray); $content.=$this->cObj->getUpdateJS($this->modifyDataArrForFormUpdate($this->dataArr), $this->theTable.'_form', 'FE['.$this->theTable.']', $this->fieldList.$this->additionalUpdateFields); } return $content; } /** * Creates the edit-screen for records * * @return string HTML content * @see init() */ function displayEditScreen() { if ($this->conf['edit']) { // If editing is enabled $origArr = $GLOBALS['TSFE']->sys_page->getRawRecord($this->theTable, $this->dataArr['uid']?$this->dataArr['uid']:$this->recUid); if ($GLOBALS['TSFE']->loginUser || $this->aCAuth($origArr)) { // Must be logged in OR be authenticated by the aC code in order to edit // 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. $content=$this->displayEditForm($origArr); } else { // Else display error, that you could not edit that particular record... $content = $this->getPlainTemplate('###TEMPLATE_NO_PERMISSIONS###'); } } elseif ($GLOBALS['TSFE']->loginUser) { // If the recUid did not select a record, we display a menu of records. (eg. if no recUid) $lockPid = $this->conf['edit.']['menuLockPid'] ? ' AND pid='.intval($this->thePid) : ''; $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->theTable, '1 '.$lockPid.$this->cObj->DBmayFEUserEditSelect($this->theTable,$GLOBALS['TSFE']->fe_user->user, $this->conf['allowedGroups'],$this->conf['fe_userEditSelf']).$GLOBALS['TSFE']->sys_page->deleteClause($this->theTable)); if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) { // If there are menu-items ... $templateCode = $this->getPlainTemplate('###TEMPLATE_EDITMENU###'); $out=''; $itemCode = $this->cObj->getSubpart($templateCode, '###ITEM###'); while($menuRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $markerArray = $this->cObj->fillInMarkerArray(array(), $menuRow, '', TRUE, 'FIELD_', $this->recInMarkersHSC); $markerArray = $this->setCObjects($itemCode,$menuRow,$markerArray,'ITEM_'); $out.= $this->cObj->substituteMarkerArray($itemCode, $markerArray); } $content=$this->cObj->substituteSubpart($templateCode, '###ALLITEMS###', $out); } else { // If there are not menu items.... $content = $this->getPlainTemplate('###TEMPLATE_EDITMENU_NOITEMS###'); } } else { $content = $this->getPlainTemplate('###TEMPLATE_AUTH###'); } } else { // Finally this is if there is no login user. This must tell that you must login. Perhaps link to a page with create-user or login information. $content = $this->getPlainTemplate('###TEMPLATE_AUTH###'); } } else { $content.='Edit-option is not set in TypoScript'; } return $content; } /** * Subfunction for displayEditScreen(); Takes a record and creates an edit form based on the template code for it. * This function is called if the user is editing a record and permitted to do so. Checked in displayEditScreen() * * @param array The array with the record to edit * @return string HTML content * @access private * @see displayEditScreen() */ function displayEditForm($origArr) { $currentArr = is_array($this->dataArr) ? $this->dataArr+$origArr : $origArr; if ($this->conf['debug']) debug('displayEditForm(): '.'###TEMPLATE_EDIT'.$this->previewLabel.'###',1); $templateCode = $this->cObj->getSubpart($this->templateCode, '###TEMPLATE_EDIT'.$this->previewLabel.'###'); $failure = t3lib_div::_GP('noWarnings')?'':$this->failure; if (!$failure) {$templateCode = $this->cObj->substituteSubpart($templateCode, '###SUB_REQUIRED_FIELDS_WARNING###', '');} $templateCode = $this->removeRequired($templateCode,$failure); $this->setCObjects($templateCode,$currentArr); $markerArray = $this->cObj->fillInMarkerArray($this->markerArray, $currentArr, '', TRUE, 'FIELD_', $this->recInMarkersHSC); $markerArray['###HIDDENFIELDS###'].= '<input type="hidden" name="FE['.$this->theTable.'][uid]" value="'.$currentArr['uid'].'" />'; if ($this->conf['edit.']['preview'] && !$this->previewLabel) {$markerArray['###HIDDENFIELDS###'].= '<input type="hidden" name="preview" value="1" />';} $content = $this->cObj->substituteMarkerArray($templateCode, $markerArray); $content.=$this->cObj->getUpdateJS($this->modifyDataArrForFormUpdate($currentArr), $this->theTable.'_form', 'FE['.$this->theTable.']', $this->fieldList.$this->additionalUpdateFields); return $content; } /** * Processes socalled "setfixed" commands. These are commands setting a certain field in a certain record to a certain value. Like a link you can click in an email which will unhide a record to enable something. Or likewise a link which can delete a record by a single click. * The idea is that only some allowed actions like this is allowed depending on the configured TypoScript. * * @return string HTML content displaying the status of the action */ function procesSetFixed() { if ($this->conf['setfixed']) { $theUid = intval($this->recUid); $origArr = $GLOBALS['TSFE']->sys_page->getRawRecord($this->theTable, $theUid); $fD = t3lib_div::_GP('fD'); $sFK = t3lib_div::_GP('sFK'); $fieldArr=array(); if (is_array($fD) || $sFK=='DELETE') { if (is_array($fD)) { reset($fD); while(list($field,$value)=each($fD)) { $origArr[$field]=$value; $fieldArr[]=$field; } } $theCode = $this->setfixedHash($origArr,$origArr['_FIELDLIST']); if (!strcmp($this->authCode,$theCode)) { if ($sFK=='DELETE') { $this->cObj->DBgetDelete($this->theTable, $theUid, TRUE); } else { $newFieldList = implode(',',array_intersect(t3lib_div::trimExplode(',',$this->fieldList),t3lib_div::trimExplode(',',implode($fieldArr,','),1))); $this->cObj->DBgetUpdate($this->theTable, $theUid, $fD, $newFieldList, TRUE); $this->currentArr = $GLOBALS['TSFE']->sys_page->getRawRecord($this->theTable,$theUid); $this->userProcess_alt($this->conf['setfixed.']['userFunc_afterSave'],$this->conf['setfixed.']['userFunc_afterSave.'],array('rec'=>$this->currentArr, 'origRec'=>$origArr)); } // Outputting template $this->markerArray = $this->cObj->fillInMarkerArray($this->markerArray, $origArr, '', TRUE, 'FIELD_', $this->recInMarkersHSC); $content = $this->getPlainTemplate('###TEMPLATE_SETFIXED_OK_'.$sFK.'###'); if (!$content) {$content = $this->getPlainTemplate('###TEMPLATE_SETFIXED_OK###');} // Compiling email $this->compileMail( 'SETFIXED_'.$sFK, array($origArr), $origArr[$this->conf['email.']['field']], $this->conf['setfixed.'] ); // Clearing cache if set: $this->clearCacheIfSet(); } else $content = $this->getPlainTemplate('###TEMPLATE_SETFIXED_FAILED###'); } else $content = $this->getPlainTemplate('###TEMPLATE_SETFIXED_FAILED###'); } return $content; } /***************************************** * * Template processing functions * *****************************************/ /** * Remove required parts from template code string * Works like this: * - You insert subparts like this ###SUB_REQUIRED_FIELD_'.$theField.'### in the template that tells what is required for the field, if it's not correct filled in. * - These subparts are all removed, except if the field is listed in $failure string! * * Only fields that are found in $this->requiredArr is processed. * * @param string The template HTML code * @param string Comma list of fields which has errors (and therefore should not be removed) * @return string The processed template HTML code */ function removeRequired($templateCode,$failure) { reset($this->requiredArr); while(list(,$theField)=each($this->requiredArr)) { if (!t3lib_div::inList($failure,$theField)) { $templateCode = $this->cObj->substituteSubpart($templateCode, '###SUB_REQUIRED_FIELD_'.$theField.'###', ''); } } return $templateCode; } /** * Returns template subpart HTML code for the key given * * @param string Subpart marker to return subpart for. * @param array Optional data record array. If set, then all fields herein will also be substituted if found as markers in the template * @return string The subpart with all markers found in current $this->markerArray substituted. * @see tslib_cObj::fillInMarkerArray() */ function getPlainTemplate($key,$r='') { if ($this->conf['debug']) debug('getPlainTemplate(): '.$key,1); $templateCode = $this->cObj->getSubpart($this->templateCode, $key); $this->setCObjects($templateCode,is_array($r)?$r:array()); return $this->cObj->substituteMarkerArray( $templateCode, is_array($r) ? $this->cObj->fillInMarkerArray($this->markerArray, $r, '', TRUE, 'FIELD_', $this->recInMarkersHSC) : $this->markerArray ); } /** * Modifies input array for passing on to tslib_cObj::getUpdateJS() which produces some JavaScript for form evaluation or the like. * * @param array The data array * @return array The processed input array * @see displayCreateScreen(), displayEditForm(), tslib_cObj::getUpdateJS() */ function modifyDataArrForFormUpdate($inputArr) { if (is_array($this->conf[$this->cmdKey.'.']['evalValues.'])) { 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 'twice': if (isset($inputArr[$theField])) { if (!isset($inputArr[$theField.'_again'])) { $inputArr[$theField.'_again'] = $inputArr[$theField]; } $this->additionalUpdateFields.=','.$theField.'_again'; } break; } } } } if (is_array($this->conf['parseValues.'])) { reset($this->conf['parseValues.']); while(list($theField,$theValue)=each($this->conf['parseValues.'])) { $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 'multiple': if (isset($inputArr[$theField]) && !$this->isPreview()) { $inputArr[$theField] = explode(',',$inputArr[$theField]); } break; case 'checkArray': if ($inputArr[$theField] && !$this->isPreview()) { for($a=0;$a<=30;$a++) { if ($inputArr[$theField] & pow(2,$a)) { $alt_theField = $theField.']['.$a; $inputArr[$alt_theField] = 1; $this->additionalUpdateFields.=','.$alt_theField; } } } break; } } } } $inputArr = $this->userProcess_alt( $this->conf['userFunc_updateArray'], $this->conf['userFunc_updateArray.'], $inputArr ); return $inputArr; } /** * Will render TypoScript cObjects (configured in $this->conf['cObjects.']) and add their content to keys in a markerArray, either the array passed to the function or the internal one ($this->markerArray) if the input $markerArray is not set. * * @param string The current template code string. Is used to check if the marker string is found and if not, the content object is not rendered! * @param array An alternative data record array (if empty then $this->dataArr is used) * @param mixed An alternative markerArray to fill in (instead of $this->markerArray). If you want to set the cobjects in the internal $this->markerArray, then just set this to non-array value. * @param string Optional prefix to set for the marker strings. * @return array The processed $markerArray (if given). */ function setCObjects($templateCode,$currentArr=array(),$markerArray='',$specialPrefix='') { if (is_array($this->conf['cObjects.'])) { reset($this->conf['cObjects.']); while(list($theKey,$theConf)=each($this->conf['cObjects.'])) { if (!strstr($theKey,'.')) { if (strstr($templateCode,'###'.$specialPrefix.'CE_'.$theKey.'###')) { $cObjCode = $this->cObj->cObjGetSingle($this->conf['cObjects.'][$theKey], $this->conf['cObjects.'][$theKey.'.'], 'cObjects.'.$theKey); if (!is_array($markerArray)) { $this->markerArray['###'.$specialPrefix.'CE_'.$theKey.'###'] = $cObjCode; } else { $markerArray['###'.$specialPrefix.'CE_'.$theKey.'###'] = $cObjCode; } } if (strstr($templateCode,'###'.$specialPrefix.'PCE_'.$theKey.'###')) { $local_cObj =t3lib_div::makeInstance('tslib_cObj'); $local_cObj->start(count($currentArr)?$currentArr:$this->dataArr,$this->theTable); $cObjCode = $local_cObj->cObjGetSingle($this->conf['cObjects.'][$theKey], $this->conf['cObjects.'][$theKey.'.'], 'cObjects.'.$theKey); if (!is_array($markerArray)) { $this->markerArray['###'.$specialPrefix.'PCE_'.$theKey.'###'] = $cObjCode; } else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -