Пример #1
0
 protected static function ListBlockItem($strListItemContent, $strBlockIdentifier)
 {
     // Build pattern to identify sublist
     $intBlockIdentifierLength = strlen($strBlockIdentifier);
     $strPattern = sprintf('/\\n(%s|%s) /', str_repeat('\\#', $intBlockIdentifierLength + 1), str_repeat('\\*', $intBlockIdentifierLength + 1));
     $strToReturn = null;
     preg_match($strPattern, $strListItemContent, $strMatches);
     if (count($strMatches) >= 1) {
         $intPosition = strpos($strListItemContent, $strMatches[0]);
         $strToReturn .= QTextStyleInline::Process(substr($strListItemContent, 0, $intPosition));
         $strListItemContent = substr($strListItemContent, $intPosition + strlen($strMatches[0]));
         $strToReturn .= QTextStyleBlock::ListBlockRecursion($strListItemContent, $strMatches[1]);
     } else {
         $strToReturn .= QTextStyleInline::Process($strListItemContent);
     }
     return $strToReturn;
 }
 protected static function ProcessLinkLocationWikiPage($chrCurrent = null)
 {
     // Pop off LinkLocation
     $objState = self::$objStateStack->Pop();
     $strLocation = $objState->Buffer;
     // Pop off LinkProtocol
     $objState = self::$objStateStack->Pop();
     $strProtocol = $objState->Buffer;
     // Pop off End Quote
     $objState = self::$objStateStack->Pop();
     if ($objState->State != QTextStyle::StateEndQuote) {
         throw new Exception('Could not find In-LinkContent EndQuote State');
     }
     // Cancel everything through the matching start quote
     self::CancelToState(QTextStyle::StateStartQuote);
     // Pop off the Start Quote at the top of the stack
     $objState = self::$objStateStack->Pop();
     $strContent = $objState->Buffer;
     // Clean up the Location string so that it starts with one and exactly one forward slash
     $strLocation = '/' . $strLocation;
     while (strpos($strLocation, '//') === 0) {
         $strLocation = substr($strLocation, 1);
     }
     // Calculate end-of-location
     $strNeedle = '/[A-Za-z0-9\\_\\/\\:]/';
     $intValue = QString::StringReversePosition($strLocation, $strNeedle);
     // Clean Up the URL Path for a Wiki Link
     $strPath = WikiItem::SanitizeForPath(substr($strLocation, 0, $intValue + 1), $intWikiItemTypeId);
     $strSanitizedFullPath = WikiItem::GenerateFullPath($strPath, $intWikiItemTypeId);
     // Process as a URL-based link to the wiki
     $strUrlLink = sprintf('<a href="/wiki%s">%s</a>', $strSanitizedFullPath, $strContent);
     self::$objStateStack->AddToTopBuffer($strUrlLink);
     // Add any tail/unprocessed stuff back to the content stack
     QTextStyleInline::$strInlineContent = substr($strLocation, $intValue + 1) . QTextStyleInline::$strInlineContent;
 }