コード例 #1
0
 function meth_Locator_Replace(&$Txt, &$Loc, &$Value, $SubStart)
 {
     // This function enables to merge a locator with a text and returns the position just after the replaced block
     // This position can be useful because we don't know in advance how $Value will be replaced.
     // Found the value if there is a subname
     if ($SubStart !== false and $Loc->SubOk) {
         for ($i = $SubStart; $i < $Loc->SubNbr; $i++) {
             $x = $Loc->SubLst[$i];
             // &$Loc... brings an error with Event Example, I don't know why.
             if (is_array($Value)) {
                 if (isset($Value[$x])) {
                     $Value =& $Value[$x];
                 } elseif (array_key_exists($x, $Value)) {
                     // can happens when value is NULL
                     $Value =& $Value[$x];
                 } else {
                     if (!isset($Loc->PrmLst['noerr'])) {
                         $this->meth_Misc_Alert($Loc, 'item \'' . $x . '\' is not an existing key in the array.', true);
                     }
                     unset($Value);
                     $Value = '';
                     break;
                 }
             } elseif (is_object($Value)) {
                 $ArgLst = $this->f_Misc_CheckArgLst($x);
                 if (method_exists($Value, $x)) {
                     if ($this->MethodsAllowed or !in_array(strtok($Loc->FullName, '.'), array('onload', 'onshow', 'var'))) {
                         $x = call_user_func_array(array(&$Value, $x), $ArgLst);
                     } else {
                         if (!isset($Loc->PrmLst['noerr'])) {
                             $this->meth_Misc_Alert($Loc, '\'' . $x . '\' is a method and the current TBS settings do not allow to call methods on automatic fields.', true);
                         }
                         $x = '';
                     }
                 } elseif (property_exists($Value, $x)) {
                     $x =& $Value->{$x};
                 } elseif (isset($Value->{$x})) {
                     $x = $Value->{$x};
                     // useful for overloaded property
                 } else {
                     if (!isset($Loc->PrmLst['noerr'])) {
                         $this->meth_Misc_Alert($Loc, 'item ' . $x . '\' is neither a method nor a property in the class \'' . get_class($Value) . '\'.', true);
                     }
                     unset($Value);
                     $Value = '';
                     break;
                 }
                 $Value =& $x;
                 unset($x);
                 $x = '';
             } else {
                 if (!isset($Loc->PrmLst['noerr'])) {
                     $this->meth_Misc_Alert($Loc, 'item before \'' . $x . '\' is neither an object nor an array. Its type is ' . gettype($Value) . '.', true);
                 }
                 unset($Value);
                 $Value = '';
                 break;
             }
         }
     }
     $CurrVal = $Value;
     // Unlink
     if (isset($Loc->PrmLst['onformat'])) {
         if ($Loc->FirstMerge) {
             $Loc->OnFrmInfo = $Loc->PrmLst['onformat'];
             $Loc->OnFrmArg = array($Loc->FullName, '', &$Loc->PrmLst, &$this);
             $ErrMsg = false;
             if (!$this->meth_Misc_UserFctCheck($Loc->OnFrmInfo, 'f', $ErrMsg, $ErrMsg, true)) {
                 unset($Loc->PrmLst['onformat']);
                 if (!isset($Loc->PrmLst['noerr'])) {
                     $this->meth_Misc_Alert($Loc, '(parameter onformat) ' . $ErrMsg);
                 }
                 $Loc->OnFrmInfo = 'pi';
                 // Execute the function pi() just to avoid extra error messages
             }
         } else {
             $Loc->OnFrmArg[3] =& $this;
             // bugs.php.net/51174
         }
         $Loc->OnFrmArg[1] =& $CurrVal;
         if (isset($Loc->PrmLst['subtpl'])) {
             $this->meth_Misc_ChangeMode(true, $Loc, $CurrVal);
             call_user_func_array($Loc->OnFrmInfo, $Loc->OnFrmArg);
             $this->meth_Misc_ChangeMode(false, $Loc, $CurrVal);
             $Loc->ConvProtect = false;
             $Loc->ConvStr = false;
         } else {
             call_user_func_array($Loc->OnFrmInfo, $Loc->OnFrmArg);
         }
     }
     if ($Loc->FirstMerge) {
         if (isset($Loc->PrmLst['frm'])) {
             $Loc->ConvMode = 0;
             // Frm
             $Loc->ConvProtect = false;
         } else {
             // Analyze parameter 'htmlconv'
             if (isset($Loc->PrmLst['htmlconv'])) {
                 $x = strtolower($Loc->PrmLst['htmlconv']);
                 $x = '+' . str_replace(' ', '', $x) . '+';
                 if (strpos($x, '+esc+') !== false) {
                     $this->f_Misc_ConvSpe($Loc);
                     $Loc->ConvStr = false;
                     $Loc->ConvEsc = true;
                 }
                 if (strpos($x, '+wsp+') !== false) {
                     $this->f_Misc_ConvSpe($Loc);
                     $Loc->ConvWS = true;
                 }
                 if (strpos($x, '+js+') !== false) {
                     $this->f_Misc_ConvSpe($Loc);
                     $Loc->ConvStr = false;
                     $Loc->ConvJS = true;
                 }
                 if (strpos($x, '+url+') !== false) {
                     $this->f_Misc_ConvSpe($Loc);
                     $Loc->ConvStr = false;
                     $Loc->ConvUrl = true;
                 }
                 if (strpos($x, '+utf8+') !== false) {
                     $this->f_Misc_ConvSpe($Loc);
                     $Loc->ConvStr = false;
                     $Loc->ConvUtf8 = true;
                 }
                 if (strpos($x, '+no+') !== false) {
                     $Loc->ConvStr = false;
                 }
                 if (strpos($x, '+yes+') !== false) {
                     $Loc->ConvStr = true;
                 }
                 if (strpos($x, '+nobr+') !== false) {
                     $Loc->ConvStr = true;
                     $Loc->ConvBr = false;
                 }
             } else {
                 if ($this->Charset === false) {
                     $Loc->ConvStr = false;
                 }
                 // No conversion
             }
             // Analyze parameter 'protect'
             if (isset($Loc->PrmLst['protect'])) {
                 $x = strtolower($Loc->PrmLst['protect']);
                 if ($x === 'no') {
                     $Loc->ConvProtect = false;
                 } elseif ($x === 'yes') {
                     $Loc->ConvProtect = true;
                 }
             } elseif ($this->Protect === false) {
                 $Loc->ConvProtect = false;
             }
         }
         if ($Loc->Ope = isset($Loc->PrmLst['ope'])) {
             $OpeLst = explode(',', $Loc->PrmLst['ope']);
             $Loc->OpeAct = array();
             $Loc->OpeArg = array();
             foreach ($OpeLst as $i => $ope) {
                 if ($ope === 'list') {
                     $Loc->OpeAct[$i] = 1;
                     $Loc->OpePrm[$i] = isset($Loc->PrmLst['valsep']) ? $Loc->PrmLst['valsep'] : ',';
                     if ($Loc->ConvMode === 1 && $Loc->ConvStr) {
                         $Loc->ConvMode = -1;
                     }
                     // special mode for item list conversion
                 } elseif ($ope === 'minv') {
                     $Loc->OpeAct[$i] = 11;
                     $Loc->MSave = $Loc->MagnetId;
                 } elseif ($ope === 'attbool') {
                     // this operation key is set when a loc is cached with paremeter atttrue
                     $Loc->OpeAct[$i] = 14;
                 } else {
                     $x = substr($ope, 0, 4);
                     if ($x === 'max:') {
                         if (isset($Loc->PrmLst['maxhtml'])) {
                             $Loc->OpeAct[$i] = 2;
                         } elseif (isset($Loc->PrmLst['maxutf8'])) {
                             $Loc->OpeAct[$i] = 4;
                         } else {
                             $Loc->OpeAct[$i] = 3;
                         }
                         $Loc->OpePrm[$i] = intval(trim(substr($ope, 4)));
                         $Loc->OpeEnd = isset($Loc->PrmLst['maxend']) ? $Loc->PrmLst['maxend'] : '...';
                         if ($Loc->OpePrm[$i] <= 0) {
                             $Loc->Ope = false;
                         }
                     } elseif ($x === 'mod:') {
                         $Loc->OpeAct[$i] = 5;
                         $Loc->OpePrm[$i] = '0' + trim(substr($ope, 4));
                     } elseif ($x === 'add:') {
                         $Loc->OpeAct[$i] = 6;
                         $Loc->OpePrm[$i] = '0' + trim(substr($ope, 4));
                     } elseif ($x === 'mul:') {
                         $Loc->OpeAct[$i] = 7;
                         $Loc->OpePrm[$i] = '0' + trim(substr($ope, 4));
                     } elseif ($x === 'div:') {
                         $Loc->OpeAct[$i] = 8;
                         $Loc->OpePrm[$i] = '0' + trim(substr($ope, 4));
                     } elseif ($x === 'mok:') {
                         $Loc->OpeAct[$i] = 9;
                         $Loc->OpeMOK[] = trim(substr($ope, 4));
                         $Loc->MSave = $Loc->MagnetId;
                     } elseif ($x === 'mko:') {
                         $Loc->OpeAct[$i] = 10;
                         $Loc->OpeMKO[] = trim(substr($ope, 4));
                         $Loc->MSave = $Loc->MagnetId;
                     } elseif ($x === 'nif:') {
                         $Loc->OpeAct[$i] = 12;
                         $Loc->OpePrm[$i] = trim(substr($ope, 4));
                     } elseif ($x === 'msk:') {
                         $Loc->OpeAct[$i] = 13;
                         $Loc->OpePrm[$i] = trim(substr($ope, 4));
                     } elseif (isset($this->_piOnOperation)) {
                         $Loc->OpeAct[$i] = 0;
                         $Loc->OpePrm[$i] = $ope;
                         $Loc->OpeArg[$i] = array($Loc->FullName, &$CurrVal, &$Loc->PrmLst, &$Txt, $Loc->PosBeg, $Loc->PosEnd, &$Loc);
                         $Loc->PrmLst['_ope'] = $Loc->PrmLst['ope'];
                     } elseif (!isset($Loc->PrmLst['noerr'])) {
                         $this->meth_Misc_Alert($Loc, 'parameter ope doesn\'t support value \'' . $ope . '\'.', true);
                     }
                 }
             }
         }
         $Loc->FirstMerge = false;
     }
     $ConvProtect = $Loc->ConvProtect;
     // Plug-in OnFormat
     if ($this->_piOnFrm_Ok) {
         if (isset($Loc->OnFrmArgPi)) {
             $Loc->OnFrmArgPi[1] =& $CurrVal;
             $Loc->OnFrmArgPi[3] =& $this;
             // bugs.php.net/51174
         } else {
             $Loc->OnFrmArgPi = array($Loc->FullName, &$CurrVal, &$Loc->PrmLst, &$this);
         }
         $this->meth_PlugIn_RunAll($this->_piOnFormat, $Loc->OnFrmArgPi);
     }
     // Operation
     if ($Loc->Ope) {
         foreach ($Loc->OpeAct as $i => $ope) {
             switch ($ope) {
                 case 0:
                     $Loc->PrmLst['ope'] = $Loc->OpePrm[$i];
                     // for compatibility
                     $OpeArg =& $Loc->OpeArg[$i];
                     $OpeArg[1] =& $CurrVal;
                     $OpeArg[3] =& $Txt;
                     if (!$this->meth_PlugIn_RunAll($this->_piOnOperation, $OpeArg)) {
                         return $Loc->PosBeg;
                     }
                     break;
                 case 1:
                     if ($Loc->ConvMode === -1) {
                         if (is_array($CurrVal)) {
                             foreach ($CurrVal as $k => $v) {
                                 if (!is_string($v)) {
                                     $v = (string) $v;
                                 }
                                 $this->meth_Conv_Str($v, $Loc->ConvBr);
                                 $CurrVal[$k] = $v;
                             }
                             $CurrVal = implode($Loc->OpePrm[$i], $CurrVal);
                         } else {
                             if (!is_string($CurrVal)) {
                                 $CurrVal = (string) $CurrVal;
                             }
                             $this->meth_Conv_Str($CurrVal, $Loc->ConvBr);
                         }
                     } else {
                         if (is_array($CurrVal)) {
                             $CurrVal = implode($Loc->OpePrm[$i], $CurrVal);
                         }
                     }
                     break;
                 case 2:
                     if (strlen('' . $CurrVal) > $Loc->OpePrm[$i]) {
                         $this->f_Xml_Max($CurrVal, $Loc->OpePrm[$i], $Loc->OpeEnd);
                     }
                     break;
                 case 3:
                     if (strlen('' . $CurrVal) > $Loc->OpePrm[$i]) {
                         $CurrVal = substr('' . $CurrVal, 0, $Loc->OpePrm[$i]) . $Loc->OpeEnd;
                     }
                     break;
                 case 4:
                     if (strlen('' . $CurrVal) > $Loc->OpePrm[$i]) {
                         $CurrVal = mb_substr('' . $CurrVal, 0, $Loc->OpePrm[$i], 'UTF-8') . $Loc->OpeEnd;
                     }
                     break;
                 case 5:
                     $CurrVal = ('0' + $CurrVal) % $Loc->OpePrm[$i];
                     break;
                 case 6:
                     $CurrVal = '0' + $CurrVal + $Loc->OpePrm[$i];
                     break;
                 case 7:
                     $CurrVal = ('0' + $CurrVal) * $Loc->OpePrm[$i];
                     break;
                 case 8:
                     $CurrVal = ('0' + $CurrVal) / $Loc->OpePrm[$i];
                     break;
                 case 9:
                 case 10:
                     if ($ope === 9) {
                         $CurrVal = in_array((string) $CurrVal, $Loc->OpeMOK) ? ' ' : '';
                     } else {
                         $CurrVal = in_array((string) $CurrVal, $Loc->OpeMKO) ? '' : ' ';
                     }
                     // no break here
                 // no break here
                 case 11:
                     if ((string) $CurrVal === '') {
                         if ($Loc->MagnetId === 0) {
                             $Loc->MagnetId = $Loc->MSave;
                         }
                     } else {
                         if ($Loc->MagnetId !== 0) {
                             $Loc->MSave = $Loc->MagnetId;
                             $Loc->MagnetId = 0;
                         }
                         $CurrVal = '';
                     }
                     break;
                 case 12:
                     if ((string) $CurrVal === $Loc->OpePrm[$i]) {
                         $CurrVal = '';
                     }
                     break;
                 case 13:
                     $CurrVal = str_replace('*', $CurrVal, $Loc->OpePrm[$i]);
                     break;
                 case 14:
                     $CurrVal = clsTinyButStrong::f_Loc_AttBoolean($CurrVal, $Loc->PrmLst['atttrue'], $Loc->AttName);
                     break;
             }
         }
     }
     // String conversion or format
     if ($Loc->ConvMode === 1) {
         // Usual string conversion
         if (!is_string($CurrVal)) {
             $CurrVal = (string) $CurrVal;
         }
         // (string) is faster than strval() and settype()
         if ($Loc->ConvStr) {
             $this->meth_Conv_Str($CurrVal, $Loc->ConvBr);
         }
     } elseif ($Loc->ConvMode === 0) {
         // Format
         $CurrVal = $this->meth_Misc_Format($CurrVal, $Loc->PrmLst);
     } elseif ($Loc->ConvMode === 2) {
         // Special string conversion
         if (!is_string($CurrVal)) {
             $CurrVal = (string) $CurrVal;
         }
         if ($Loc->ConvStr) {
             $this->meth_Conv_Str($CurrVal, $Loc->ConvBr);
         }
         if ($Loc->ConvEsc) {
             $CurrVal = str_replace('\'', '\'\'', $CurrVal);
         }
         if ($Loc->ConvWS) {
             $check = '  ';
             $nbsp = '&nbsp;';
             do {
                 $pos = strpos($CurrVal, $check);
                 if ($pos !== false) {
                     $CurrVal = substr_replace($CurrVal, $nbsp, $pos, 1);
                 }
             } while ($pos !== false);
         }
         if ($Loc->ConvJS) {
             $CurrVal = addslashes($CurrVal);
             // apply to ('), ("), (\) and (null)
             $CurrVal = str_replace(array("\n", "\r", "\t"), array('\\n', '\\r', '\\t'), $CurrVal);
         }
         if ($Loc->ConvUrl) {
             $CurrVal = urlencode($CurrVal);
         }
         if ($Loc->ConvUtf8) {
             $CurrVal = utf8_encode($CurrVal);
         }
     }
     // if/then/else process, there may be several if/then
     if ($Loc->PrmIfNbr) {
         $z = false;
         $i = 1;
         while ($i !== false) {
             if ($Loc->PrmIfVar[$i]) {
                 $Loc->PrmIfVar[$i] = $this->meth_Merge_AutoVar($Loc->PrmIf[$i], true);
             }
             $x = str_replace($this->_ChrVal, $CurrVal, $Loc->PrmIf[$i]);
             if ($this->f_Misc_CheckCondition($x)) {
                 if (isset($Loc->PrmThen[$i])) {
                     if ($Loc->PrmThenVar[$i]) {
                         $Loc->PrmThenVar[$i] = $this->meth_Merge_AutoVar($Loc->PrmThen[$i], true);
                     }
                     $z = $Loc->PrmThen[$i];
                 }
                 $i = false;
             } else {
                 $i++;
                 if ($i > $Loc->PrmIfNbr) {
                     if (isset($Loc->PrmLst['else'])) {
                         if ($Loc->PrmElseVar) {
                             $Loc->PrmElseVar = $this->meth_Merge_AutoVar($Loc->PrmLst['else'], true);
                         }
                         $z = $Loc->PrmLst['else'];
                     }
                     $i = false;
                 }
             }
         }
         if ($z !== false) {
             if ($ConvProtect) {
                 $CurrVal = str_replace($this->_ChrOpen, $this->_ChrProtect, $CurrVal);
                 // TBS protection
                 $ConvProtect = false;
             }
             $CurrVal = str_replace($this->_ChrVal, $CurrVal, $z);
         }
     }
     if (isset($Loc->PrmLst['file'])) {
         $x = $Loc->PrmLst['file'];
         if ($x === true) {
             $x = $CurrVal;
         }
         $this->meth_Merge_AutoVar($x, false);
         $x = trim(str_replace($this->_ChrVal, $CurrVal, $x));
         $CurrVal = '';
         if ($x !== '') {
             if ($this->f_Misc_GetFile($CurrVal, $x, $this->_LastFile)) {
                 if (isset($Loc->PrmLst['getbody'])) {
                     $CurrVal = $this->f_Xml_GetPart($CurrVal, $Loc->PrmLst['getbody'], true);
                 }
                 if (isset($Loc->PrmLst['rename'])) {
                     $this->meth_Locator_Rename($CurrVal, $Loc->PrmLst['rename']);
                 }
             } else {
                 if (!isset($Loc->PrmLst['noerr'])) {
                     $this->meth_Misc_Alert($Loc, 'the file \'' . $x . '\' given by parameter file is not found or not readable.', true);
                 }
             }
             $ConvProtect = false;
         }
     }
     if (isset($Loc->PrmLst['script'])) {
         // Include external PHP script
         $x = $Loc->PrmLst['script'];
         if ($x === true) {
             $x = $CurrVal;
         }
         $this->meth_Merge_AutoVar($x, false);
         $x = trim(str_replace($this->_ChrVal, $CurrVal, $x));
         if ($x !== '') {
             $this->_Subscript = $x;
             $this->CurrPrm =& $Loc->PrmLst;
             $sub = isset($Loc->PrmLst['subtpl']);
             if ($sub) {
                 $this->meth_Misc_ChangeMode(true, $Loc, $CurrVal);
             }
             if ($this->meth_Misc_RunSubscript($CurrVal, $Loc->PrmLst) === false) {
                 if (!isset($Loc->PrmLst['noerr'])) {
                     $this->meth_Misc_Alert($Loc, 'the file \'' . $x . '\' given by parameter script is not found or not readable.', true);
                 }
             }
             if ($sub) {
                 $this->meth_Misc_ChangeMode(false, $Loc, $CurrVal);
             }
             if (isset($Loc->PrmLst['getbody'])) {
                 $CurrVal = $this->f_Xml_GetPart($CurrVal, $Loc->PrmLst['getbody'], true);
             }
             if (isset($Loc->PrmLst['rename'])) {
                 $this->meth_Locator_Rename($CurrVal, $Loc->PrmLst['rename']);
             }
             unset($this->CurrPrm);
             $ConvProtect = false;
         }
     }
     if (isset($Loc->PrmLst['att'])) {
         $this->f_Xml_AttFind($Txt, $Loc, true, $this->AttDelim);
         if (isset($Loc->PrmLst['atttrue'])) {
             $CurrVal = clsTinyButStrong::f_Loc_AttBoolean($CurrVal, $Loc->PrmLst['atttrue'], $Loc->AttName);
             $Loc->PrmLst['magnet'] = '#';
         }
     }
     // Case when it's an empty string
     if ($CurrVal === '') {
         if ($Loc->MagnetId === false) {
             if (isset($Loc->PrmLst['.'])) {
                 $Loc->MagnetId = -1;
             } elseif (isset($Loc->PrmLst['ifempty'])) {
                 $Loc->MagnetId = -2;
             } elseif (isset($Loc->PrmLst['magnet'])) {
                 $Loc->MagnetId = 1;
                 $Loc->PosBeg0 = $Loc->PosBeg;
                 $Loc->PosEnd0 = $Loc->PosEnd;
                 if ($Loc->PrmLst['magnet'] === '#') {
                     if (isset($Loc->AttBeg)) {
                         $Loc->MagnetId = -3;
                     } else {
                         $this->meth_Misc_Alert($Loc, 'parameter \'magnet=#\' cannot be processed because parameter \'att\' is not set or the attribute is not found.', true);
                     }
                 } elseif (isset($Loc->PrmLst['mtype'])) {
                     switch ($Loc->PrmLst['mtype']) {
                         case 'm+m':
                             $Loc->MagnetId = 2;
                             break;
                         case 'm*':
                             $Loc->MagnetId = 3;
                             break;
                         case '*m':
                             $Loc->MagnetId = 4;
                             break;
                     }
                 }
             } elseif (isset($Loc->PrmLst['attadd'])) {
                 // In order to delete extra space
                 $Loc->PosBeg0 = $Loc->PosBeg;
                 $Loc->PosEnd0 = $Loc->PosEnd;
                 $Loc->MagnetId = 5;
             } else {
                 $Loc->MagnetId = 0;
             }
         }
         switch ($Loc->MagnetId) {
             case 0:
                 break;
             case -1:
                 $CurrVal = '&nbsp;';
                 break;
                 // Enables to avoid null cells in HTML tables
             // Enables to avoid null cells in HTML tables
             case -2:
                 $CurrVal = $Loc->PrmLst['ifempty'];
                 break;
             case -3:
                 $Loc->Enlarged = true;
                 $Loc->PosBeg = $Loc->AttBegM;
                 $Loc->PosEnd = $Loc->AttEnd;
                 break;
             case 1:
                 $Loc->Enlarged = true;
                 $this->f_Loc_EnlargeToTag($Txt, $Loc, $Loc->PrmLst['magnet'], false);
                 break;
             case 2:
                 $Loc->Enlarged = true;
                 $CurrVal = $this->f_Loc_EnlargeToTag($Txt, $Loc, $Loc->PrmLst['magnet'], true);
                 break;
             case 3:
                 $Loc->Enlarged = true;
                 $Loc2 = $this->f_Xml_FindTag($Txt, $Loc->PrmLst['magnet'], true, $Loc->PosBeg, false, 1, false);
                 if ($Loc2 !== false) {
                     $Loc->PosBeg = $Loc2->PosBeg;
                     if ($Loc->PosEnd < $Loc2->PosEnd) {
                         $Loc->PosEnd = $Loc2->PosEnd;
                     }
                 }
                 break;
             case 4:
                 $Loc->Enlarged = true;
                 $Loc2 = $this->f_Xml_FindTag($Txt, $Loc->PrmLst['magnet'], true, $Loc->PosBeg, true, 1, false);
                 if ($Loc2 !== false) {
                     $Loc->PosEnd = $Loc2->PosEnd;
                 }
                 break;
             case 5:
                 $Loc->Enlarged = true;
                 if (substr($Txt, $Loc->PosBeg - 1, 1) == ' ') {
                     $Loc->PosBeg--;
                 }
                 break;
         }
         $NewEnd = $Loc->PosBeg;
         // Useful when mtype='m+m'
     } else {
         if ($ConvProtect) {
             $CurrVal = str_replace($this->_ChrOpen, $this->_ChrProtect, $CurrVal);
         }
         // TBS protection
         $NewEnd = $Loc->PosBeg + strlen($CurrVal);
     }
     $Txt = substr_replace($Txt, $CurrVal, $Loc->PosBeg, $Loc->PosEnd - $Loc->PosBeg + 1);
     return $NewEnd;
     // Return the new end position of the field
 }