コード例 #1
0
 function meth_Locator_FindTbs(&$Txt, $Name, $Pos, $ChrSub)
 {
     // Find a TBS Locator
     $PosEnd = false;
     $PosMax = strlen($Txt) - 1;
     $Start = $this->_ChrOpen . $Name;
     do {
         // Search for the opening char
         if ($Pos > $PosMax) {
             return false;
         }
         $Pos = strpos($Txt, $Start, $Pos);
         // If found => next chars are analyzed
         if ($Pos === false) {
             return false;
         } else {
             $Loc = new clsTbsLocator();
             $ReadPrm = false;
             $PosX = $Pos + strlen($Start);
             $x = $Txt[$PosX];
             if ($x === $this->_ChrClose) {
                 $PosEnd = $PosX;
             } elseif ($x === $ChrSub) {
                 $Loc->SubOk = true;
                 // it is no longer the false value
                 $ReadPrm = true;
                 $PosX++;
             } elseif (strpos(';', $x) !== false) {
                 $ReadPrm = true;
                 $PosX++;
             } else {
                 $Pos++;
             }
             $Loc->PosBeg = $Pos;
             if ($ReadPrm) {
                 clsTinyButStrong::f_Loc_PrmRead($Txt, $PosX, false, '\'', $this->_ChrOpen, $this->_ChrClose, $Loc, $PosEnd);
                 if ($PosEnd === false) {
                     $this->meth_Misc_Alert('', 'can\'t found the end of the tag \'' . substr($Txt, $Pos, $PosX - $Pos + 10) . '...\'.');
                     $Pos++;
                 }
             }
         }
     } while ($PosEnd === false);
     $Loc->PosEnd = $PosEnd;
     if ($Loc->SubOk) {
         $Loc->FullName = $Name . '.' . $Loc->SubName;
         $Loc->SubLst = explode('.', $Loc->SubName);
         $Loc->SubNbr = count($Loc->SubLst);
     } else {
         $Loc->FullName = $Name;
     }
     if ($ReadPrm and isset($Loc->PrmLst['comm'])) {
         $Loc->PosBeg0 = $Loc->PosBeg;
         $Loc->PosEnd0 = $Loc->PosEnd;
         $comm = $Loc->PrmLst['comm'];
         if ($comm === true or $comm === '') {
             $Loc->Enlarged = clsTinyButStrong::f_Loc_EnlargeToStr($Txt, $Loc, '<!--', '-->');
         } else {
             $Loc->Enlarged = clsTinyButStrong::f_Loc_EnlargeToTag($Txt, $Loc, $comm, false);
         }
     }
     return $Loc;
 }