public static function Process($strInlineContent) { // Setup the Content QTextStyleInline::$strInlineContent = $strInlineContent; // Reset the stack QTextStyleInline::$objStateStack = new QTextStyleStateStack(); QTextStyleInline::$objStateStack->Push(QTextStyle::StateText); QTextStyleInline::$objStateStack->Push(QTextStyle::StateWordStartHint); // Continue iterating while there is content to parse and items on the stack while (strlen(QTextStyleInline::$strInlineContent) || !QTextStyleInline::$objStateStack->IsEmpty()) { // If there is content, parse it! if (strlen(QTextStyleInline::$strInlineContent)) { // Figure out the current character we are attempting to parse with $chrCurrent = QString::FirstCharacter(QTextStyleInline::$strInlineContent); // Pull out the StateRules for the top-most stack's state $arrStateRules = QTextStyle::$StateRulesArray[QTextStyleInline::$objStateStack->PeekTop()->State]; // Figure out the StateRule key to use based on the current character if (array_key_exists($chrCurrent, $arrStateRules)) { $strKey = $chrCurrent; } else { if (array_key_exists(QTextStyle::KeyAlpha, $arrStateRules) && preg_match('/[A-Za-z]/', $chrCurrent)) { $strKey = QTextStyle::KeyAlpha; } else { if (array_key_exists(QTextStyle::KeyNumeric, $arrStateRules) && preg_match('/[0-9]/', $chrCurrent)) { $strKey = QTextStyle::KeyNumeric; } else { if (array_key_exists(QTextStyle::KeyAlphaNumeric, $arrStateRules) && preg_match('/[A-Za-z0-9]/', $chrCurrent)) { $strKey = QTextStyle::KeyAlphaNumeric; } else { $strKey = QTextStyle::KeyDefault; } } } } // Go through the rules for our current state and key foreach ($arrStateRules[$strKey] as $mixRule) { // Pull the Command and the parameters for the commad (if any) if (is_array($mixRule)) { $strCommand = $mixRule[0]; $strParameterArray = $mixRule; array_shift($strParameterArray); } else { $strParameterArray = array(); $strCommand = $mixRule; } // Dump the stack to the output buffer (if requested) if (QTextStyleInline::$OutputDebugMessages) { if (is_array($mixRule)) { $strDisplayCommand = implode(', ', $mixRule); } else { $strDisplayCommand = $strCommand; } QTextStyleInline::DumpStack(QTextStyleInline::$strInlineContent . ' - [' . $chrCurrent . '] - Key(' . $strKey . ') - Command(' . $strDisplayCommand . ')'); } QTextStyleInline::$strCommand($chrCurrent, $strParameterArray); } // There is no Inline Content to process -- go ahead and call cancel on the top-most state } else { // Call the cancel method -- store any return vaue // If it is the last state on the stack, the return value will be returned $strToReturn = QTextStyleInline::CancelTopState(); } } return $strToReturn; }