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


PHP QString::LastCharacter方法代码示例

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


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

示例1: StripQuotes

 public static function StripQuotes($strText)
 {
     if (QString::FirstCharacter($strText) == '"' && QString::LastCharacter($strText) == '"' || QString::FirstCharacter($strText) == "'" && QString::LastCharacter($strText) == "'") {
         return substr($strText, 1, strlen($strText) - 2);
     }
     return $strText;
 }
开发者ID:qcodo,项目名称:qcodo-api,代码行数:7,代码来源:QBuildMaker.class.php

示例2: 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

示例3: btnFirstSubmit_Click

 protected function btnFirstSubmit_Click($strFormId, $strControlId, $strParameter)
 {
     if ($objPublicLogin = PublicLogin::LoadByUsername(trim(strtolower($this->txtUsername->Text)))) {
     } else {
         $this->txtUsername->Warning = 'Username does not exist';
         $this->txtUsername->Blink();
         $this->txtUsername->Focus();
         return;
     }
     $this->txtUsername->Visible = false;
     $this->btnFirstSubmit->Visible = false;
     $this->lblFirstMessage->Visible = true;
     $this->lblFirstMessage->HtmlEntities = false;
     $this->lblFirstMessage->Text = '<p>Before we can proceed, please answer the following security question that you specified when you registered for <strong>my.alcf</strong>.</p>';
     $this->lblQuestion->Visible = true;
     $this->lblQuestion->Name = 'Security Question';
     $this->lblQuestion->Text = $objPublicLogin->LostPasswordQuestion;
     if (QString::LastCharacter($objPublicLogin->LostPasswordQuestion) != '?') {
         $this->lblQuestion->Text .= '?';
     }
     $this->txtAnswer->Visible = true;
     $this->txtAnswer->Name = 'Your Answer';
     $this->txtAnswer->Required = true;
     $this->txtAnswer->CausesValidation = $this->txtAnswer;
     $this->txtAnswer->Focus();
     $this->btnFinalSubmit->Visible = true;
     $this->btnFinalSubmit->Text = 'Reset My Password';
     $this->btnFinalSubmit->CausesValidation = $this->txtAnswer;
     $this->txtAnswer->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnFinalSubmit_Click'));
     $this->txtAnswer->AddAction(new QEnterKeyEvent(), new QTerminateAction());
     $this->btnFinalSubmit->AddAction(new QClickEvent(), new QAjaxAction('btnFinalSubmit_Click'));
     $this->objPublicLogin = $objPublicLogin;
 }
开发者ID:alcf,项目名称:chms,代码行数:33,代码来源:forgot_password.php

示例4: 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

示例5: __construct

 public function __construct($strJavaScript)
 {
     $this->strJavaScript = trim($strJavaScript);
     if (QString::LastCharacter($this->strJavaScript) == ';') {
         $this->strJavaScript = substr($this->strJavaScript, 0, strlen($this->strJavaScript) - 1);
     }
 }
开发者ID:qcodo,项目名称:qcodo-api,代码行数:7,代码来源:_actions.inc.php

示例6: RenderJavaScript

 public static function RenderJavaScript($blnOutput = true)
 {
     $strScript = '';
     foreach (QApplication::$AlertMessageArray as $strAlert) {
         $strAlert = addslashes($strAlert);
         $strScript .= sprintf('alert("%s"); ', $strAlert);
     }
     foreach (QApplication::$JavaScriptArrayHighPriority as $strJavaScript) {
         $strJavaScript = trim($strJavaScript);
         if (QString::LastCharacter($strJavaScript) != ';') {
             $strScript .= sprintf('%s; ', $strJavaScript);
         } else {
             $strScript .= sprintf('%s ', $strJavaScript);
         }
     }
     foreach (QApplication::$JavaScriptArray as $strJavaScript) {
         $strJavaScript = trim($strJavaScript);
         if (QString::LastCharacter($strJavaScript) != ';') {
             $strScript .= sprintf('%s; ', $strJavaScript);
         } else {
             $strScript .= sprintf('%s ', $strJavaScript);
         }
     }
     QApplication::$AlertMessageArray = array();
     QApplication::$JavaScriptArrayHighPriority = array();
     QApplication::$JavaScriptArray = array();
     if ($strScript) {
         if ($blnOutput) {
             _p($strScript, false);
         } else {
             return $strScript;
         }
     } else {
         return null;
     }
 }
开发者ID:alcf,项目名称:chms,代码行数:36,代码来源:QApplicationBase.class.php

示例7: EvaluateTemplate

 protected function EvaluateTemplate($strTemplate, $strModuleName, $mixArgumentArray)
 {
     // First remove all \r from the template (for Win/*nix compatibility)
     $strTemplate = str_replace("\r", '', $strTemplate);
     // Get all the arguments and set them locally
     if ($mixArgumentArray) {
         foreach ($mixArgumentArray as $strName => $mixValue) {
             ${$strName} = $mixValue;
         }
     }
     // Of course, we also need to locally allow "objCodeGen"
     $objCodeGen = $this;
     // Look for the Escape Begin
     $intPosition = strpos($strTemplate, QCodeGen::$TemplateEscapeBegin);
     // Get Database Escape Identifiers
     $strEscapeIdentifierBegin = QApplication::$Database[$this->intDatabaseIndex]->EscapeIdentifierBegin;
     $strEscapeIdentifierEnd = QApplication::$Database[$this->intDatabaseIndex]->EscapeIdentifierEnd;
     // Evaluate All Escaped Clauses
     while ($intPosition !== false) {
         $intPositionEnd = strpos($strTemplate, QCodeGen::$TemplateEscapeEnd, $intPosition);
         // Get and cleanup the Eval Statement
         $strStatement = substr($strTemplate, $intPosition + QCodeGen::$TemplateEscapeBeginLength, $intPositionEnd - $intPosition - QCodeGen::$TemplateEscapeEndLength);
         $strStatement = trim($strStatement);
         if (substr($strStatement, 0, 1) == '=') {
             // Remove Trailing ';' if applicable
             if (substr($strStatement, strlen($strStatement) - 1) == ';') {
                 $strStatement = trim(substr($strStatement, 0, strlen($strStatement) - 1));
             }
             // Remove Head '='
             $strStatement = trim(substr($strStatement, 1));
             // Add 'return' eval
             $strStatement = sprintf('return (%s);', $strStatement);
         } else {
             if (substr($strStatement, 0, 1) == '@') {
                 // Remove Trailing ';' if applicable
                 if (substr($strStatement, strlen($strStatement) - 1) == ';') {
                     $strStatement = trim(substr($strStatement, 0, strlen($strStatement) - 1));
                 }
                 // Remove Head '@'
                 $strStatement = trim(substr($strStatement, 1));
                 // Calculate Template Filename
                 $intVariablePosition = strpos($strStatement, '(');
                 if ($intVariablePosition === false) {
                     throw new Exception('Invalid include subtemplate Command: ' . $strStatement);
                 }
                 $strTemplateFile = substr($strStatement, 0, $intVariablePosition);
                 $strVariableList = substr($strStatement, $intVariablePosition + 1);
                 // Remove trailing ')'
                 $strVariableList = trim(substr($strVariableList, 0, strlen($strVariableList) - 1));
                 $strVariableArray = explode(',', $strVariableList);
                 // Clean Each Variable
                 for ($intIndex = 0; $intIndex < count($strVariableArray); $intIndex++) {
                     // Trim
                     $strVariableArray[$intIndex] = trim($strVariableArray[$intIndex]);
                     // Remove trailing and head "'"
                     $strVariableArray[$intIndex] = substr($strVariableArray[$intIndex], 1, strlen($strVariableArray[$intIndex]) - 2);
                     // Trim Again
                     $strVariableArray[$intIndex] = trim($strVariableArray[$intIndex]);
                 }
                 // Ensure each variable exists!
                 foreach ($strVariableArray as $strVariable) {
                     if (!isset(${$strVariable})) {
                         throw new Exception(sprintf('Invalid Variable %s in include subtemplate command: %s', $strVariable, $strStatement));
                     }
                 }
                 // Setup the ArgumentArray for this subtemplate
                 $mixTemplateArgumentArray = array();
                 foreach ($strVariableArray as $strVariable) {
                     $mixTemplateArgumentArray[$strVariable] = ${$strVariable};
                 }
                 // Get the Evaluated Template!
                 $strEvaledStatement = $this->EvaluateSubTemplate($strTemplateFile . '.tpl', $strModuleName, $mixTemplateArgumentArray);
                 // Set Statement to NULL so that the method knows to that the statement we're replacing
                 // has already been eval'ed
                 $strStatement = null;
             }
         }
         if (substr($strStatement, 0, 1) == '-') {
             // Backup a number of characters
             $intPosition = $intPosition - strlen($strStatement);
             $strStatement = '';
             // Check if we're starting an open-ended statemen
         } else {
             if (substr($strStatement, strlen($strStatement) - 1) == '{') {
                 // We ARE in an open-ended statement
                 // SubTemplate is the contents of this open-ended template
                 $strSubTemplate = substr($strTemplate, $intPositionEnd + QCodeGen::$TemplateEscapeEndLength);
                 // Parse through the rest of the template, and pull the correct SubTemplate,
                 // Keeping in account nested open-ended statements
                 $intLevel = 1;
                 $intSubPosition = strpos($strSubTemplate, QCodeGen::$TemplateEscapeBegin);
                 while ($intLevel > 0 && $intSubPosition !== false) {
                     $intSubPositionEnd = strpos($strSubTemplate, QCodeGen::$TemplateEscapeEnd, $intSubPosition);
                     $strFragment = substr($strSubTemplate, $intSubPosition + QCodeGen::$TemplateEscapeEndLength, $intSubPositionEnd - $intSubPosition - QCodeGen::$TemplateEscapeEndLength);
                     $strFragment = trim($strFragment);
                     $strFragmentLastCharacter = substr($strFragment, strlen($strFragment) - 1);
                     if ($strFragmentLastCharacter == '{') {
                         $intLevel++;
                     } else {
                         if ($strFragmentLastCharacter == '}') {
//.........这里部分代码省略.........
开发者ID:kmcelhinney,项目名称:qcodo,代码行数:101,代码来源:QCodeGenBase.class.php

示例8: Run

 public static function Run($strClassName, $strNamespace = null)
 {
     QApplication::$EncodingType = 'UTF-8';
     $objWsdlCache = new QCache('soap', QApplication::$ScriptName, 'wsdl', QApplication::$ScriptFilename);
     $objDiscoCache = new QCache('soap', QApplication::$ScriptName, 'disco', QApplication::$ScriptFilename);
     $objClassWrapperCache = new QCache('soap', QApplication::$ScriptName, 'class.php', QApplication::$ScriptFilename);
     // Reflect through this QSoapService
     $strDisco = $objDiscoCache->GetData();
     if ($strDisco === false || !$strNamespace) {
         $objReflection = new ReflectionClass($strClassName);
     }
     // Figure Out Namespace
     if (!$strNamespace) {
         $objReflectionProperties = $objReflection->getStaticProperties();
         $strNamespace = $objReflectionProperties['DefaultNamespace'];
     }
     $strNamespace = trim($strNamespace);
     if (QString::LastCharacter($strNamespace) == '/') {
         $strNamespace = substr($strNamespace, 0, strlen($strNamespace) - 1);
     }
     // Check for Cached Disco
     if ($strDisco === false) {
         // Instantiate Service and Setup new Soap Methods
         $objService = new $strClassName($strClassName, $strNamespace);
         // Setup SOAP Methods
         try {
             $objService->SetupSoapMethods($objReflection);
         } catch (QCallerException $objExc) {
             $objExc->IncrementOffset();
             throw $objExc;
         }
         // Get Disco, Wsdl and Wrapper, and cache them!
         $objWsdlCache->SaveData($objService->GetWsdl());
         $objDiscoCache->SaveData($objService->GetDisco());
         $objClassWrapperCache->SaveData($objService->GetClassWrapper());
     }
     // Process Service Browse (e.g. if accessed via GET)
     if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         if (array_key_exists('QUERY_STRING', $_SERVER)) {
             switch (strtolower($_SERVER['QUERY_STRING'])) {
                 case 'disco':
                     header('Content-Type: text/xml');
                     _p('<?xml version="1.0" encoding="' . QApplication::$EncodingType . '"?>', false);
                     _p($objDiscoCache->GetData(), false);
                     return;
                 case 'wsdl':
                     header('Content-Type: text/xml');
                     _p('<?xml version="1.0" encoding="' . QApplication::$EncodingType . '"?>', false);
                     _p($objWsdlCache->GetData(), false);
                     return;
             }
         }
         printf('<link rel="alternate" type="text/xml" href="%s?disco"/><a href="%s?disco">Web Service Discovery File</a> &nbsp;|&nbsp; <a href="%s?wsdl">Web Service Description File (WSDL)</a>', QApplication::$ScriptName, QApplication::$ScriptName, QApplication::$ScriptName);
         return;
     }
     // Process Service Execution (e.g. accessed via a POST)
     $objService = new $strClassName($strClassName, $strNamespace);
     // Get the Request
     $strRequest = file_get_contents("php://input");
     // Create the Service Class Wrapper
     require $objClassWrapperCache->GetFilePath();
     // Use PHP 5.1+'s SoapServer class to handle the actual work
     $objService->objSoapServer = new SoapServer($objWsdlCache->GetFilePath());
     $objService->objSoapServer->setClass($strClassName . 'Wrapper', $strClassName, $strNamespace);
     $objService->objSoapServer->handle($strRequest);
 }
开发者ID:qcodo,项目名称:qcodo-api,代码行数:66,代码来源:QSoapService.class.php

示例9: StringReversePosition

 /**
  * A better version of strrpos which also allows for the use of RegExp-based matching
  * @param string $strHaystack the text content to search through
  * @param string $strNeedle either a plain-text item or a regexp pattern item to search for - if regexp used, this will update as the actual string of the content found
  * @param integer $intOffset optional position offset
  * @return mixed the position number OR false if not found
  */
 public static function StringReversePosition($strHaystack, &$strNeedle, $intOffset = null)
 {
     if (strlen($strNeedle) >= 3 && QString::FirstCharacter($strNeedle) == '/' && QString::LastCharacter($strNeedle) == '/') {
         $arrMatches = array();
         preg_match_all($strNeedle, $strHaystack, $arrMatches);
         $arrMatches = $arrMatches[0];
         if (count($arrMatches)) {
             $strNeedle = $arrMatches[count($arrMatches) - 1];
         } else {
             return false;
         }
     }
     if (is_null($intOffset)) {
         return strrpos($strHaystack, $strNeedle);
     } else {
         return strrpos($strHaystack, $strNeedle, $intOffset);
     }
 }
开发者ID:klucznik,项目名称:qcodo,代码行数:25,代码来源:QString.class.php

示例10: checkTrailingSlash

 public static function checkTrailingSlash($strConstantName, &$result)
 {
     if (QString::LastCharacter(constant($strConstantName)) == '/') {
         $obj = new QInstallationValidationResult();
         $obj->strMessage = 'Remove the trailing slash from the ' . $strConstantName . ' constant in ' . '/includes/configuration/configuration.inc.php. ';
         $result[] = $obj;
     }
 }
开发者ID:vaibhav-kaushal,项目名称:qc-framework,代码行数:8,代码来源:QInstallationValidator.class.php

示例11: GenerateContent

 /**
  * Generates and returns random Content based on "Lorem Ipsum" text.  Caller must specify
  * the number of paragraphs to be generated, where the word count for each individual
  * paragraph is a random number selected between intMinimumWordsPerParagraph and intMaximumWordsPerParagraph.
  *   
  * @param integer $intParagraphCount number of paragraphs to generate, 
  * @param integer $intMinimumWordsPerParagraph the minimum number of words per paragraph
  * @param integer $intMaximumWordsPerParagraph the maximum number of words per paragraph
  * @return string
  */
 public static function GenerateContent($intParagraphCount, $intMinimumWordsPerParagraph = 20, $intMaximumWordsPerParagraph = 150)
 {
     $strContent = null;
     for ($intParagraph = 0; $intParagraph < $intParagraphCount; $intParagraph++) {
         $intWordCount = rand($intMinimumWordsPerParagraph, $intMaximumWordsPerParagraph);
         $strParagraph = null;
         // Add Sentences
         while (str_word_count($strParagraph) < $intWordCount) {
             $strParagraph .= QDataGen::$LipsumArray[rand(0, count(QDataGen::$LipsumArray) - 1)] . '  ';
         }
         $strParagraph = trim($strParagraph);
         // Remove Words
         while (str_word_count($strParagraph) > $intWordCount) {
             $strParagraph = trim(substr($strParagraph, 0, strrpos($strParagraph, ' ')));
         }
         // Remove Comma (if applicable)
         if (QString::LastCharacter($strParagraph) == ',') {
             $strParagraph = trim(substr($strParagraph, 0, strlen($strParagraph) - 1));
         }
         // Add Period (if applicable)
         if (QString::LastCharacter($strParagraph) != '.') {
             $strParagraph .= '.';
         }
         $strContent .= $strParagraph . "\r\n\r\n";
     }
     return trim($strContent);
 }
开发者ID:proxymoron,项目名称:tracmor,代码行数:37,代码来源:QDataGen.class.php

示例12: CalculateStyleAndOptionsFromDirectives

 /**
  * @param $strDirectives the directives to process
  * @param $strStyle the calculated style based on the directives
  * @param $strOptions the calculated options based on the directives
  * @return boolean returns false if the directives are malformed at all
  */
 protected static function CalculateStyleAndOptionsFromDirectives($strDirectives, &$strStyle, &$strOptions)
 {
     if ($strDirectives) {
         $strDirectives = preg_replace('/([\\}\\]])([\\{\\[])/', '$1\\\\$2', $strDirectives);
         $strDirectives = explode('\\', $strDirectives);
         for ($intDirectiveIndex = 0; $intDirectiveIndex < count($strDirectives); $intDirectiveIndex++) {
             $strDirective = $strDirectives[$intDirectiveIndex];
             if (QString::FirstCharacter($strDirective) == '{' && QString::LastCharacter($strDirective) == '}') {
                 $strStyle .= substr($strDirective, 1, strlen($strDirective) - 2);
             } else {
                 if (QString::FirstCharacter($strDirective) == '[' && QString::LastCharacter($strDirective) == ']') {
                     $strOptions = substr($strDirective, 1, strlen($strDirective) - 2);
                 } else {
                     return false;
                 }
             }
         }
     }
     // If we made it here, then the directives are either null or correctly formed
     return true;
 }
开发者ID:qcodo,项目名称:qcodo-website,代码行数:27,代码来源:QTextStyleBlock.class.php

示例13: 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

示例14: GetTableScript

function GetTableScript($objOdbc, $strTablePath, $strTableName, $strPrefix)
{
    $objResult = odbc_exec($objOdbc, "SELECT * FROM " . $strTablePath . ";");
    $intNumFields = odbc_num_fields($objResult);
    $strSql = 'CREATE TABLE `' . strtolower($strTableName) . "` (\r\n";
    $strSql .= "    pkid INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,\r\n";
    for ($intFieldNumber = 1; $intFieldNumber <= $intNumFields; $intFieldNumber++) {
        $strType = odbc_field_type($objResult, $intFieldNumber);
        switch ($strType) {
            case 'LONGVARCHAR':
            case 'LONGVARBINARY':
                $strType = 'TEXT';
                break;
            case 'VARCHAR':
            case 'WORD':
                $strType = 'VARCHAR(255)';
                break;
            case 'LARGEINT':
            case 'SMALLINT':
            case 'AUTOINC':
                $strType = 'INT';
                break;
            case 'Long':
                $strType = 'INT';
                break;
            case 'AlphaNumeric':
                $strType = 'VARCHAR(255)';
                break;
            case 'Timestamp':
                $strType = 'DATETIME';
                break;
            case 'Logical':
                $strType = 'VARCHAR(255)';
                break;
            case 'Memo':
                $strType = 'TEXT';
                break;
            case 'Number':
                $strType = 'DECIMAL(9,2)';
                break;
        }
        if (odbc_field_name($objResult, $intFieldNumber) == 'Family_Number') {
            $strType = 'INT';
        }
        $strFieldName = strtolower(odbc_field_name($objResult, $intFieldNumber));
        $strFieldName = str_replace('/', '_', $strFieldName);
        $strFieldName = str_replace('-', '_', $strFieldName);
        $strFieldName = str_replace(' ', '_', $strFieldName);
        $strFieldName = str_replace('#', '_', $strFieldName);
        // Cleanup Doubles
        while (strpos($strFieldName, '__') !== false) {
            $strFieldName = str_replace('__', '_', $strFieldName);
        }
        // Perform a "trim"
        if (QString::FirstCharacter($strFieldName) == '_') {
            $strFieldName = substr($strFieldName, 1);
        }
        if (QString::LastCharacter($strFieldName) == '_') {
            $strFieldName = substr($strFieldName, 0, strlen($strFieldName) - 1);
        }
        $strSql .= sprintf("    `%s%s` %s,\r\n", $strPrefix, $strFieldName, $strType);
    }
    $strSql .= "    PRIMARY KEY (pkid)\r\n);\r\n\r\n";
    return $strSql;
}
开发者ID:alcf,项目名称:chms,代码行数:65,代码来源:acs-make-mysql.cli.php


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