当前位置: 首页>>代码示例>>PHP>>正文


PHP QString::FirstCharacter方法代码示例

本文整理汇总了PHP中QString::FirstCharacter方法的典型用法代码示例。如果您正苦于以下问题:PHP QString::FirstCharacter方法的具体用法?PHP QString::FirstCharacter怎么用?PHP QString::FirstCharacter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QString的用法示例。


在下文中一共展示了QString::FirstCharacter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: SanitizeForToken

 /**
  * Given a string, this will create a sanitized token for it
  * @param string $strTokenCandidate
  * @return string
  */
 public static function SanitizeForToken($strTokenCandidate)
 {
     $strTokenCandidate = trim(strtolower($strTokenCandidate));
     $intLength = strlen($strTokenCandidate);
     $strToReturn = '';
     for ($intChar = 0; $intChar < $intLength; $intChar++) {
         $strChar = $strTokenCandidate[$intChar];
         $intOrd = ord($strChar);
         if ($intOrd >= ord('a') && $intOrd <= ord('z')) {
             $strToReturn .= $strChar;
         } else {
             if ($intOrd >= ord('0') && $intOrd <= ord('9')) {
                 $strToReturn .= $strChar;
             } else {
                 if ($strChar == ' ' || $strChar == '.' || $strChar == ':' || $strChar == '-' || $strChar == '/' || $strChar == '(' || $strChar == ')' || $strChar == '_') {
                     $strToReturn .= '_';
                 }
             }
         }
     }
     // Cleanup leading and trailing underscores
     while (QString::FirstCharacter($strToReturn) == '_') {
         $strToReturn = substr($strToReturn, 1);
     }
     while (QString::LastCharacter($strToReturn) == '_') {
         $strToReturn = substr($strToReturn, 0, strlen($strToReturn) - 1);
     }
     // Cleanup Dupe Underscores
     while (strpos($strToReturn, '__') !== false) {
         $strToReturn = str_replace('__', '_', $strToReturn);
     }
     return $strToReturn;
 }
开发者ID:klucznik,项目名称:qcodo-website,代码行数:38,代码来源:Package.class.php

示例2: Validate

 public function Validate()
 {
     if (parent::Validate()) {
         if (trim($this->strText) != "") {
             $this->strText = trim($this->strText);
             $strOriginal = $this->strText;
             $strFinal = '';
             while (strlen($strOriginal)) {
                 if (is_numeric(QString::FirstCharacter($strOriginal))) {
                     $strFinal .= QString::FirstCharacter($strOriginal);
                 }
                 if (strtolower(QString::FirstCharacter($strOriginal)) == 'x') {
                     $strFinal .= 'x';
                 }
                 $strOriginal = substr($strOriginal, 1);
             }
             if (strlen($strFinal) == 10 && strpos($strFinal, 'x') === false) {
                 $this->strText = substr($strFinal, 0, 3) . '-' . substr($strFinal, 3, 3) . '-' . substr($strFinal, 6);
                 $this->strValidationError = null;
                 return true;
             }
             if (strlen($strFinal) > 11 && strpos($strFinal, 'x') == 10 && strpos($strFinal, 'x', 11) === false && strlen($strFinal) <= 17) {
                 $this->strText = substr($strFinal, 0, 3) . '-' . substr($strFinal, 3, 3) . '-' . substr($strFinal, 6, 4) . ' ' . substr($strFinal, 10);
                 $this->strValidationError = null;
                 return true;
             }
             $this->strValidationError = 'For example "213-555-1212" or "213-555-1212 x123"';
             return false;
         }
     } else {
         return false;
     }
     $this->strValidationError = null;
     return true;
 }
开发者ID:alcf,项目名称:chms,代码行数:35,代码来源:PhoneTextBox.class.php

示例3: DisplayAsHtml

 public static function DisplayAsHtml($strContent)
 {
     // Let's get started
     $strResult = null;
     // Normalize all linebreaks and tabs
     $strContent = str_replace("\r\n", "\n", $strContent);
     $strContent = str_replace("\t", "    ", $strContent);
     while ($strContent) {
         // See if we are declaring a special block
         $strMatches = array();
         // Any Blank Lines get processed as such
         if (QString::FirstCharacter($strContent) == "\n") {
             $strContent = substr($strContent, 1);
             $strResult .= "<br/>\n";
             // Any Blocks matched by the PatternBlock regexp should be processed as a block
         } else {
             if (preg_match(self::PatternBlock, $strContent, $strMatches) && count($strMatches) >= 3 && ($strProcessorResult = QTextStyleBlock::Process($strMatches, $strContent)) !== false) {
                 $strResult .= $strProcessorResult;
                 // Any ListBlocks matched by the PatternListBlock regexp should be processed as a listblock (uses the same QTSBP::Process method)
             } else {
                 if (preg_match(self::PatternListBlock, $strContent, $strMatches) && count($strMatches) >= 3 && ($strProcessorResult = QTextStyleBlock::Process($strMatches, $strContent)) !== false) {
                     $strResult .= $strProcessorResult;
                     // Finally, anything that doesn't match any of the above will be processed as "Default"
                 } else {
                     $strContent = QTextStyle::KeyDefault . '. ' . $strContent;
                 }
             }
         }
     }
     // Return the resulting HTML
     return $strResult;
 }
开发者ID:qcodo,项目名称:qcodo-website,代码行数:32,代码来源:QTextStyle.class.php

示例4: StripDollar

 public static function StripDollar($strText)
 {
     if (QString::FirstCharacter($strText) == '$') {
         return substr($strText, 1);
     } else {
         return $strText;
     }
 }
开发者ID:qcodo,项目名称:qcodo-api,代码行数:8,代码来源:QBuildMaker.class.php

示例5: UnderscoreFromCamelCase

 public static function UnderscoreFromCamelCase($strName)
 {
     if (strlen($strName) == 0) {
         return '';
     }
     $strToReturn = QString::FirstCharacter($strName);
     for ($intIndex = 1; $intIndex < strlen($strName); $intIndex++) {
         $strChar = substr($strName, $intIndex, 1);
         if (strtoupper($strChar) == $strChar) {
             $strToReturn .= '_' . $strChar;
         } else {
             $strToReturn .= $strChar;
         }
     }
     return strtolower($strToReturn);
 }
开发者ID:heshuai64,项目名称:einv2,代码行数:16,代码来源:QConvertNotationBase.class.php

示例6: SetProperty

 public function SetProperty($strName, $intState)
 {
     if (QString::FirstCharacter($strName) == '"' && QString::LastCharacter($strName) == '"') {
         $strName = substr($strName, 1, strlen($strName) - 2);
     } else {
         if (QString::FirstCharacter($strName) == "'" && QString::LastCharacter($strName) == "'") {
             $strName = substr($strName, 1, strlen($strName) - 2);
         }
     }
     if (array_key_exists($strName, $this->PropertyArray)) {
         $objProperty = $this->PropertyArray[$strName];
     } else {
         $objProperty = new QScriptParserProperty();
         $objProperty->Name = $strName;
         $this->PropertyArray[$strName] = $objProperty;
     }
     if ($intState == STATE_GET) {
         $objProperty->Read = true;
     } else {
         if ($intState == STATE_SET) {
             $objProperty->Write = true;
         }
     }
 }
开发者ID:qcodo,项目名称:qcodo-api,代码行数:24,代码来源:QScriptParser.class.php

示例7: GenerateIndividual

 /**
  * Generates a single Individual record
  * @param boolean $blnMaleFlag
  * @param boolean $blnAdultFlag whether this Individual should be a child or an adult
  * @param string $strLastName optional last name
  * @return Person
  */
 protected static function GenerateIndividual($blnMaleFlag, $blnAdultFlag, $strLastName = null)
 {
     $objPerson = new Person();
     $objPerson->Gender = $blnMaleFlag ? 'M' : 'F';
     // Generate the name
     $objPerson->FirstName = $blnMaleFlag ? QDataGen::GenerateMaleFirstName() : QDataGen::GenerateFemaleFirstName();
     switch (rand(1, 10)) {
         case 1:
         case 2:
         case 3:
             $objPerson->MiddleName = chr(rand(ord('A'), ord('Z'))) . '.';
             break;
         case 4:
         case 5:
             $objPerson->MiddleName = $blnMaleFlag ? QDataGen::GenerateMaleFirstName() : QDataGen::GenerateFemaleFirstName();
             break;
     }
     $objPerson->LastName = $strLastName ? $strLastName : QDataGen::GenerateLastName();
     $objPerson->CanEmailFlag = rand(0, 1);
     $objPerson->CanMailFlag = rand(0, 1);
     $objPerson->CanPhoneFlag = rand(0, 1);
     if (!rand(0, 10)) {
         $objPerson->Nickname = $blnMaleFlag ? QDataGen::GenerateMaleFirstName() : QDataGen::GenerateFemaleFirstName();
     }
     if (!rand(0, 5) && !$blnMaleFlag) {
         $objPerson->PriorLastNames = QDataGen::GenerateLastName();
     }
     if (!rand(0, 10)) {
         $objPerson->MailingLabel = QString::FirstCharacter($objPerson->FirstName) . '. ' . $objPerson->LastName;
     }
     if (!rand(0, 10)) {
         $arrTitleArray = $blnMaleFlag ? array('Mr.', 'Dr.', 'Sir') : array('Ms.', 'Miss', 'Mrs.', 'Dr.', 'Lady');
         $objPerson->Title = QDataGen::GenerateFromArray($arrTitleArray);
     }
     if (!rand(0, 10)) {
         $arrSuffixArray = array('Sr.', 'Jr.', 'III', 'PhD', 'MD');
         $objPerson->Suffix = QDataGen::GenerateFromArray($arrSuffixArray);
     }
     // Date of Birth
     if ($blnAdultFlag) {
         if (rand(0, 1)) {
             $objPerson->DateOfBirth = QDataGen::GenerateDateTime(self::$LifeStartDate, self::$OldestChildBirthDate);
         }
     } else {
         $objPerson->DateOfBirth = QDataGen::GenerateDateTime(self::$OldestChildBirthDate, QDateTime::Now());
     }
     if ($objPerson->DateOfBirth) {
         $objPerson->DobGuessedFlag = !rand(0, 12);
         $objPerson->DobYearApproximateFlag = !rand(0, 12);
     }
     // Refresh Membership and Marital Statuses
     $objPerson->RefreshMembershipStatusTypeId(false);
     $objPerson->RefreshMaritalStatusTypeId(false);
     $objPerson->RefreshAge(false);
     // Setup Deceased Information
     $objPerson->DeceasedFlag = !rand(0, 200);
     if ($objPerson->DeceasedFlag && rand(0, 1)) {
         $objPerson->DateDeceased = QDataGen::GenerateDateTime(self::$LifeStartDate, QDateTime::Now());
     }
     $objPerson->Save();
     $objPerson->RefreshNameItemAssociations();
     // Head Shots
     $objHeadShotArray = array();
     $intHeadShotCount = rand(0, 3);
     for ($i = 0; $i < $intHeadShotCount; $i++) {
         $objHeadShotArray[] = $objPerson->SaveHeadShot(self::GetRandomHeadShot($objPerson->Gender == 'M'), QDataGen::GenerateDateTime(self::$SystemStartDate, QDateTime::Now()));
     }
     if (count($objHeadShotArray)) {
         $objPerson->SetCurrentHeadShot(QDataGen::GenerateFromArray($objHeadShotArray));
     }
     // Membership
     $intMembershipCount = 0;
     if ($blnAdultFlag) {
         if (!rand(0, 2)) {
             $intMembershipCount = rand(1, 3);
         }
     } else {
         if (!rand(0, 10)) {
             $intMembershipCount = rand(1, 2);
         }
     }
     if ($intMembershipCount) {
         $dttEarliestPossible = new QDateTime($objPerson->DateOfBirth ? $objPerson->DateOfBirth : self::$SystemStartDate);
         self::GenerateMembershipsForIndividual($objPerson, $dttEarliestPossible, $intMembershipCount);
     }
     // Past or non-defined marriage
     if ($blnAdultFlag && !rand(0, 10)) {
         $objMarriage = new Marriage();
         $objMarriage->Person = $objPerson;
         $objMarriage->MarriageStatusTypeId = QDataGen::GenerateFromArray(array_keys(MarriageStatusType::$NameArray));
         if (rand(0, 1)) {
             $dttStart = QDateTime::Now();
             $dttStart = QDataGen::GenerateDateTime(self::$LifeStartDate, $dttStart);
//.........这里部分代码省略.........
开发者ID:alcf,项目名称:chms,代码行数:101,代码来源:datagen.cli.php

示例8: objParticipationArray_Sort

 public function objParticipationArray_Sort(GroupParticipation $objParticipation1, GroupParticipation $objParticipation2)
 {
     if ($objParticipation1->GroupRoleId != $objParticipation2->GroupRoleId) {
         return ord(QString::FirstCharacter($objParticipation1->GroupRole->Name)) < ord(QString::FirstCharacter($objParticipation2->GroupRole->Name)) ? -1 : 1;
     }
     return $objParticipation1->DateStart->IsEarlierThan($objParticipation2->DateStart) ? -1 : 1;
 }
开发者ID:alcf,项目名称:chms,代码行数:7,代码来源:EditGroupParticipationDelegate.class.php

示例9: PathInfo

 /**
  * Gets the value of the PathInfo item at index $intIndex.  Will return NULL if it doesn't exist.
  * If no $intIndex is given will return an array with PathInfo contents.
  *
  * The way PathInfo index is determined is, for example, given a URL '/folder/page.php/id/15/blue',
  * QApplication::PathInfo(0) will return 'id'
  * QApplication::PathInfo(1) will return '15'
  * QApplication::PathInfo(2) will return 'blue'
  *
  * @return mixed
  */
 public static function PathInfo($intIndex = null)
 {
     // Lookup PathInfoArray from cache, or create it into cache if it doesn't yet exist
     if (!isset(self::$arrPathInfo)) {
         $strPathInfo = QApplication::$PathInfo;
         self::$arrPathInfo = array();
         if ($strPathInfo != '') {
             if ($strPathInfo == '/') {
                 self::$arrPathInfo[0] = '';
             } else {
                 // Remove Trailing '/'
                 if (QString::FirstCharacter($strPathInfo) == '/') {
                     $strPathInfo = substr($strPathInfo, 1);
                 }
                 self::$arrPathInfo = explode('/', $strPathInfo);
             }
         }
     }
     if ($intIndex === null) {
         return self::$arrPathInfo;
     } elseif (array_key_exists($intIndex, self::$arrPathInfo)) {
         return self::$arrPathInfo[$intIndex];
     } else {
         return null;
     }
 }
开发者ID:alcf,项目名称:chms,代码行数:37,代码来源:QApplicationBase.class.php

示例10: ProcessDirectory

 /**
  * Given the path of a directory, process all the directories and files in it that have NOT been seen in SeenRealPath.
  * Assumes: the path is a valid directory that exists and has NOT been SeenRealPath
  * @param string $strPath
  * @return void
  */
 protected function ProcessDirectory($strPath, QDirectoryToken $objDirectoryToken)
 {
     $strRealPath = realpath($strPath);
     $this->strSeenRealPath[$strRealPath] = true;
     $objDirectory = opendir($strPath);
     while ($strName = readdir($objDirectory)) {
         // Only Process Files/Folders that do NOT start with a single "."
         if (QString::FirstCharacter($strName) != '.') {
             // Put Together the Entire Full Path of the File in Question
             $strFullPath = $strPath . '/' . $strName;
             // Process if it's a file
             if (is_file($strFullPath)) {
                 $this->ProcessFile($strFullPath, $objDirectoryToken);
                 // Process if it's a directory
             } else {
                 if (is_dir($strFullPath)) {
                     // Only continue if we haven't visited it and it's not a folder that we are ignoring
                     $strRealPath = realpath($strFullPath);
                     if (!array_key_exists($strRealPath, $this->strSeenRealPath) && !array_key_exists(strtolower($strName), $this->blnIgnoreFolderArray)) {
                         $this->ProcessDirectory($strFullPath, $objDirectoryToken);
                     }
                     // It's neither a file nor a directory?!
                 } else {
                     throw new Exception('Not a valid file or folder: ' . $strFullPath);
                 }
             }
         }
     }
 }
开发者ID:klucznik,项目名称:qcodo-website,代码行数:35,代码来源:QPackageManagerUpload.class.php

示例11: PathInfo

		/**
		 * Gets the value of the PathInfo item at index $intIndex.  Will return NULL if it doesn't exist.
		 *
		 * The way PathInfo index is determined is, for example, given a URL '/folder/page.php/id/15/blue',
		 * QApplication::PathInfo(0) will return 'id'
		 * QApplication::PathInfo(1) will return '15'
		 * QApplication::PathInfo(2) will return 'blue'
		 *
		 * @return void
		 */
		public static function PathInfo($intIndex) {
			// TODO: Cache PathInfo
			$strPathInfo = QApplication::$PathInfo;
			
			// Remove Trailing '/'
			if (QString::FirstCharacter($strPathInfo) == '/')			
				$strPathInfo = substr($strPathInfo, 1);
			
			$strPathInfoArray = explode('/', $strPathInfo);

			if (array_key_exists($intIndex, $strPathInfoArray))
				return $strPathInfoArray[$intIndex];
			else
				return null;
		}
开发者ID:rommelxcastro,项目名称:CRI-Online-Sales---Admin,代码行数:25,代码来源:QApplicationBase.class.php

示例12: ListBlockRecursion

 protected static function ListBlockRecursion($strBlockContent, $strBlockIdentifier, $strStyle = null, $strOptions = null)
 {
     if (QString::FirstCharacter($strBlockIdentifier) == '#') {
         $strTag = 'ol';
     } else {
         $strTag = 'ul';
     }
     $strToReturn = sprintf("<%s%s>\n", $strTag, $strStyle);
     $strListItemArray = explode("\n" . $strBlockIdentifier . ' ', $strBlockContent);
     foreach ($strListItemArray as $strListItem) {
         $strToReturn .= '<li>' . QTextStyleBlock::ListBlockItem($strListItem, $strBlockIdentifier) . "</li>\n";
     }
     $strToReturn .= sprintf("</%s>\n\n", $strTag);
     return $strToReturn;
 }
开发者ID:qcodo,项目名称:qcodo-website,代码行数:15,代码来源:QTextStyleBlock.class.php

示例13: ParseShortIdentifier

 /**
  * Given a "-"-based argument, this will parse out the information, pulling out and validating any/all ShortIdentifiers.
  * If it is a single or clustered FlagParameter, it will set the flag(s) to true.
  * If it is a NamedParameter, then if a value is specified using "=", then the value will be applied to the ShortIdentifier, otherwise, it will set $intCurrentValueIndex to the ValueIndex of the ShortIdentifier.
  * @param string $strArgument the full "-"-based argument
  * @param integer $intCurrentValueIndex the new current ValueIndex that should be evaluated (if applicable)
  * @return string any error message (if any)
  */
 protected function ParseShortIdentifier($strArgument, &$intCurrentValueIndex)
 {
     // Parse out the leading "-"
     $strArgument = substr($strArgument, 1);
     // Clean Out and Verify the ShortIdentifier
     $chrShortIdentifier = substr($strArgument, 0, 1);
     try {
         $chrShortIdentifier = QCliParameterProcessor::CleanShortIdentifier($chrShortIdentifier);
     } catch (QCallerException $objExc) {
         return 'invalid argument "' . $chrShortIdentifier . '"';
     }
     // Get the ValueIndex
     if (array_key_exists($chrShortIdentifier, $this->chrShortIdentifierArray)) {
         $intValueIndex = $this->chrShortIdentifierArray[$chrShortIdentifier];
     } else {
         return 'invalid argument "' . $chrShortIdentifier . '"';
     }
     // See if this is a Flag- or a Named-Parameter
     if (array_key_exists($intValueIndex, $this->blnFlagArray)) {
         // Flag!  This also may be clustered, so go through all of the letters in the argument and set the flag value to true
         return $this->ParseShortIdentifierCluster($strArgument);
     } else {
         // NamedParameter -- Do we Have a Value?
         $strArgument = substr($strArgument, 1);
         if (strlen($strArgument)) {
             // Yes -- Set it
             // Take out any leading "="
             if (QString::FirstCharacter($strArgument) == '=') {
                 $strArgument = substr($strArgument, 1);
             }
             // Set the Value
             try {
                 $this->mixValueArray[$intValueIndex] = QCliParameterProcessor::CleanValue($strArgument, $this->intParameterTypeArray[$intValueIndex]);
             } catch (QCallerException $objExc) {
                 return $objExc->GetMessage();
             }
         } else {
             // No -- so let's update the Currently-processing ValueIndex
             $intCurrentValueIndex = $intValueIndex;
         }
     }
     // Success - no errors
     return null;
 }
开发者ID:proxymoron,项目名称:tracmor,代码行数:52,代码来源:QCliParameterProcessor.class.php

示例14: SanitizeForPath

 /**
  * Sanitizes any string to be used as a good-looking WikiItem path.
  * Result will only contain lower-case alphanumeric characters, 
  * underscores and forward-slashes.  If a type prefix exists,
  * (e.g. "file:" or "image:") then the type prefix is stripped
  * out and the type id is returned as an output parameter.  If
  * there is no valid type prefix, a type of Wiki Page is assumed.
  * @param string $strPath the path to sanitize
  * @param integer $intWikiItemTypeId the wiki item type is returned
  * @return string
  */
 public static function SanitizeForPath($strPath, &$intWikiItemTypeId)
 {
     $strPath = strtolower($strPath);
     $intWikiItemTypeId = null;
     // Figure out and strip any wiki type prefix
     foreach (WikiItemType::$NameArray as $intId => $strWikiType) {
         $strWikiTypePrefix = sprintf('/%s:', strtolower($strWikiType));
         if (substr($strPath, 0, strlen($strWikiTypePrefix)) == $strWikiTypePrefix) {
             $strPath = '/' . substr($strPath, strlen($strWikiTypePrefix));
             $intWikiItemTypeId = $intId;
             break;
         }
     }
     if (is_null($intWikiItemTypeId)) {
         $intWikiItemTypeId = WikiItemType::Page;
     }
     $strPathParts = explode('/', $strPath);
     $strToReturn = '/';
     foreach ($strPathParts as $strPathPart) {
         $strPathPart = trim($strPathPart);
         $intLength = strlen($strPathPart);
         if ($intLength) {
             $strPath = '';
             for ($intChar = 0; $intChar < $intLength; $intChar++) {
                 $strChar = $strPathPart[$intChar];
                 $intOrd = ord($strChar);
                 if ($intOrd >= ord('a') && $intOrd <= ord('z')) {
                     $strPath .= $strChar;
                 } else {
                     if ($intOrd >= ord('0') && $intOrd <= ord('9')) {
                         $strPath .= $strChar;
                     } else {
                         if ($strChar == ' ' || $strChar == '.' || $strChar == ':' || $strChar == '-' || $strChar == '/' || $strChar == '(' || $strChar == ')' || $strChar == '_') {
                             $strPath .= '_';
                         }
                     }
                 }
             }
             // Cleanup leading and trailing underscores
             while (QString::FirstCharacter($strPath) == '_') {
                 $strPath = substr($strPath, 1);
             }
             while (QString::LastCharacter($strPath) == '_') {
                 $strPath = substr($strPath, 0, strlen($strPath) - 1);
             }
             // Cleanup Dupe Underscores
             while (strpos($strPath, '__') !== false) {
                 $strPath = str_replace('__', '_', $strPath);
             }
             // At this pathpart to the path
             $strToReturn .= $strPath . '/';
         }
     }
     // Take off trailing '/' if applicable
     if (strlen($strToReturn) > 1) {
         $strToReturn = substr($strToReturn, 0, strlen($strToReturn) - 1);
     }
     // Any blank path MUST be set to an itemtype of wikipage
     if ($strToReturn == '/') {
         $intWikiItemTypeId = WikiItemType::Page;
     }
     return $strToReturn;
 }
开发者ID:qcodo,项目名称:qcodo-website,代码行数:74,代码来源:WikiItem.class.php

示例15: Process

 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;
 }
开发者ID:qcodo,项目名称:qcodo-website,代码行数:65,代码来源:QTextStyleInline.class.php


注:本文中的QString::FirstCharacter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。