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


PHP StringUtil::endsWith方法代码示例

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


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

示例1: getUniqueFileNameWithinTarget

 /**
  * Get a unique filename within given target folder, remove uniqid() suffix from file (optional, add $strPrefix) and append file count by name to
  * file if file with same name already exists in target folder
  *
  * @param string $strTarget The target file path
  * @param string $strPrefix A uniqid prefix from the given target file, that was added to the file before and should be removed again
  * @param        $i         integer Internal counter for recursion usage or if you want to add the number to the file
  *
  * @return string | false The filename with the target folder and unique id or false if something went wrong (e.g. target does not exist)
  */
 public static function getUniqueFileNameWithinTarget($strTarget, $strPrefix = null, $i = 0)
 {
     $objFile = new \File($strTarget, true);
     $strTarget = ltrim(str_replace(TL_ROOT, '', $strTarget), '/');
     $strPath = str_replace('.' . $objFile->extension, '', $strTarget);
     if ($strPrefix && ($pos = strpos($strPath, $strPrefix)) !== false) {
         $strPath = str_replace(substr($strPath, $pos, strlen($strPath)), '', $strPath);
         $strTarget = $strPath . '.' . $objFile->extension;
     }
     // Create the parent folder
     if (!file_exists($objFile->dirname)) {
         $objFolder = new \Folder(ltrim(str_replace(TL_ROOT, '', $objFile->dirname), '/'));
         // something went wrong with folder creation
         if ($objFolder->getModel() === null) {
             return false;
         }
     }
     if (file_exists(TL_ROOT . '/' . $strTarget)) {
         // remove suffix
         if ($i > 0 && StringUtil::endsWith($strPath, '_' . $i)) {
             $strPath = rtrim($strPath, '_' . $i);
         }
         // increment counter & add extension again
         $i++;
         // for performance reasons, add new unique id to path to make recursion come to end after 100 iterations
         if ($i > 100) {
             return static::getUniqueFileNameWithinTarget(static::addUniqIdToFilename($strPath . '.' . $objFile->extension, null, false));
         }
         return static::getUniqueFileNameWithinTarget($strPath . '_' . $i . '.' . $objFile->extension, $strPrefix, $i);
     }
     return $strTarget;
 }
开发者ID:heimrichhannot,项目名称:contao-haste_plus,代码行数:42,代码来源:Files.php

示例2: __construct

 /**
  * @param string|array $mConfig navigation name/navigation config
  * each navigation part needs configuration in section called 'navigation' in the site/config/config.yml
  * @return void
  * @throws Exception on missing configuration
  */
 public function __construct($mConfig, $sLinkPrefix = null, $sTemplatesDir = null)
 {
     if ($sTemplatesDir === null) {
         $this->sTemplatesDir = array(DIRNAME_TEMPLATES, DIRNAME_NAVIGATION);
     } else {
         $this->sTemplatesDir = $sTemplatesDir;
     }
     if (is_string($mConfig)) {
         $this->aConfig = Settings::getSetting("navigations", $mConfig, null);
         $this->sNavigationName = $mConfig;
     } else {
         if (is_array($mConfig)) {
             $this->aConfig = $mConfig;
         }
     }
     if ($this->aConfig === null) {
         throw new Exception("Navigation {$mConfig} not configured");
     }
     if ($sLinkPrefix === null) {
         $sLinkPrefix = LinkUtil::link();
     }
     if (!StringUtil::endsWith($sLinkPrefix, "/")) {
         $sLinkPrefix .= "/";
     }
     $this->sLinkPrefix = $sLinkPrefix;
     $this->iMaxLevel = max(array_keys($this->aConfig));
     if (!is_numeric($this->iMaxLevel) || isset($this->aConfig['all'])) {
         $this->iMaxLevel = null;
     }
     $this->bShowOnlyEnabledChildren = isset($this->aConfig["show_inactive"]) ? $this->aConfig["show_inactive"] !== true : true;
     $this->bShowOnlyVisibleChildren = isset($this->aConfig["show_hidden"]) ? $this->aConfig["show_hidden"] !== true : true;
     $this->bExcludeDuplicates = isset($this->aConfig["exclude_duplicates"]) ? $this->aConfig["exclude_duplicates"] === true : false;
     $this->bPrintNewline = isset($this->aConfig["no_newline"]) ? $this->aConfig["no_newline"] !== true : true;
     $this->sLanguageId = isset($this->aConfig["language"]) ? $this->aConfig["language"] : Session::language();
 }
开发者ID:rapila,项目名称:cms-base,代码行数:41,代码来源:Navigation.php

示例3: callNestedGetter

 /**
  * $value = callNestedGetter($person, "name.firstName")
  */
 public static function callNestedGetter($object, $nestedProperty)
 {
     StringUtil::checkTypes($nestedProperty);
     if ($nestedProperty === "") {
         return $object;
     }
     $properties = explode(".", $nestedProperty);
     if (empty($properties) || !is_object($object)) {
         throw new InvalidTypeException("Should be called on object");
     }
     foreach ($properties as $property) {
         if (is_null($object)) {
             throw new NullPointerException();
         }
         $className = get_class($object);
         $isListItem = StringUtil::endsWith($property, ")");
         $strippedProperty = $isListItem ? substr($property, 0, strpos($property, "(")) : $property;
         try {
             $getterMethod = new ReflectionMethod($className, StringUtil::getter($strippedProperty));
         } catch (ReflectionException $e) {
             try {
                 $getterMethod = new ReflectionMethod($className, StringUtil::boolGetter($strippedProperty));
             } catch (ReflectionException $e) {
                 throw new MethodNotExistsException($className, StringUtil::getter($strippedProperty));
             }
         }
         $object = $getterMethod->invoke($object);
         if ($isListItem) {
             $index = StringUtil::getSubstringBetween($property, "(", ")");
             $object = $object[$index];
         }
     }
     return $object;
 }
开发者ID:aeberh,项目名称:php-movico,代码行数:37,代码来源:ReflectionUtil.php

示例4: nullifyEmptyParams

 private static function nullifyEmptyParams(&$params)
 {
     foreach ($params as $key => $value) {
         if ($value === '' && StringUtil::endsWith($key, '_value')) {
             unset($params[$key]);
         }
     }
 }
开发者ID:cbsistem,项目名称:appflower_engine,代码行数:8,代码来源:NullFilter.class.php

示例5: suite

 public static function suite()
 {
     $oResult = new PHPUnit_Framework_TestSuite("ResourceFinder test suite");
     foreach (ResourceFinder::getFolderContents(dirname(__FILE__)) as $sFileName => $sFilePath) {
         if (StringUtil::endsWith($sFileName, "Tests.php") && (StringUtil::startsWith($sFileName, "ResourceFinder") || StringUtil::startsWith($sFileName, "FileResource") || StringUtil::startsWith($sFileName, "ResourceIncluder"))) {
             $oResult->addTestFile($sFilePath);
         }
     }
     return $oResult;
 }
开发者ID:rapila,项目名称:cms-base,代码行数:10,代码来源:TestResourceFinder.php

示例6: suite

 public static function suite()
 {
     $oResult = new PHPUnit_Framework_TestSuite("Complete test suite");
     foreach (ResourceFinder::getFolderContents(dirname(__FILE__)) as $sFileName => $sFilePath) {
         if (StringUtil::endsWith($sFileName, ".php") && StringUtil::startsWith($sFileName, "Test") && !StringUtil::startsWith($sFileName, "TestUtil") && $sFilePath !== __FILE__) {
             require_once $sFilePath;
             $oResult->addTest(call_user_func(array(substr($sFileName, 0, -strlen('.php')), "suite")));
         }
     }
     return $oResult;
 }
开发者ID:rapila,项目名称:cms-base,代码行数:11,代码来源:TestEverything.php

示例7: getFieldValues

 private static function getFieldValues($instance, $fields)
 {
     $values = array();
     foreach ($fields as $field) {
         if (StringUtil::endsWith(strtolower($field->get('@type')), 'combo')) {
             $values[$field->get('@name') . '_value'] = $field->get('@selected', null);
         } else {
             $values[$field->get('@name')] = afEditView::getFieldValue($field, $instance);
         }
     }
     return $values;
 }
开发者ID:cbsistem,项目名称:appflower_engine,代码行数:12,代码来源:afEditJsonRenderer.class.php

示例8: assertDir

 /**
  * @param $name name of variable to check, for error message
  * @throws \InvalidArgumentException if $dir is not a string pointing to an existing directory
  * @return absolute path for given string, using forward slashes, ending with a slash.
  */
 public static function assertDir($var, $name)
 {
     self::assertString($var, $name);
     $dir = str_replace('\\', '/', realpath($var));
     if (!is_dir($dir)) {
         throw new \InvalidArgumentException($name . ' must be an existing directory, but is ' . $var);
     }
     if (!StringUtil::endsWith($dir, '/')) {
         $dir .= '/';
     }
     return $dir;
 }
开发者ID:ljarray,项目名称:dbpedia,代码行数:17,代码来源:PhpUtil.php

示例9: getTemplateList

 /**
  * Scan the $PAGE_TEMPLATE_PATH dir and return the list of file finished by $TEMPLATE_SUFFIX
  * @return multitype:unknown
  */
 public static function getTemplateList()
 {
     $fileList = scandir(TemplateUtil::getPageTemplateAbsolutePath());
     $templateList = array();
     //Filter
     foreach ($fileList as $file) {
         if (StringUtil::endsWith($file, TemplateUtil::getTemplateSuffix())) {
             $templateList[$file] = $file;
         }
     }
     return $templateList;
 }
开发者ID:predever,项目名称:keosu,代码行数:16,代码来源:TemplateUtil.php

示例10: collectOptions

 private static function collectOptions($params)
 {
     $options = array();
     $messages = array();
     foreach ($params as $key => $param) {
         if (StringUtil::endsWith($key, '_error')) {
             $messages[preg_replace('/_error$/', '', $key)] = $param;
         } else {
             $options[$key] = $param === 'false' ? false : $param;
         }
     }
     return array($options, $messages);
 }
开发者ID:cbsistem,项目名称:appflower_engine,代码行数:13,代码来源:afValidatorFactory.class.php

示例11: getPatches

function getPatches($dir, $after)
{
    $result = array();
    if ($dirHandle = opendir($dir)) {
        while (($fileName = readdir($dirHandle)) !== false) {
            if (preg_match(PATCH_REGEXP, $fileName) && stripExtension($fileName) > $after && !StringUtil::endsWith($fileName, '~')) {
                $result[] = $fileName;
            }
        }
        closedir($dirHandle);
        sort($result);
    }
    return $result;
}
开发者ID:nastasie-octavian,项目名称:DEXonline,代码行数:14,代码来源:migration.php

示例12: loadFromBackup

 public function loadFromBackup($sFileName = null)
 {
     $sFilePath = ResourceFinder::findResource(array(DIRNAME_DATA, 'sql', $sFileName));
     $oConnection = Propel::getConnection();
     $bFileError = false;
     if ($sFilePath === null) {
         $bFileError = true;
     }
     if (!$bFileError) {
         if (!is_readable($sFilePath)) {
             $bFileError = true;
         }
         if (!$bFileError) {
             $rFile = fopen($sFilePath, 'r');
             if (!$rFile) {
                 $bFileError = true;
             }
         }
     }
     // throw error and filename on error
     if ($bFileError) {
         throw new LocalizedException('wns.backup.loader.load_error', array('filename' => $sFilePath));
     }
     // continue importing from local file
     $sStatement = "";
     $sReadLine = "";
     $iQueryCount = 1;
     while (($sReadLine = fgets($rFile)) !== false) {
         if ($sReadLine !== "\n" && !StringUtil::startsWith($sReadLine, "#") && !StringUtil::startsWith($sReadLine, "--")) {
             $sStatement .= $sReadLine;
         }
         if ($sReadLine === "\n" || StringUtil::endsWith($sReadLine, ";\n")) {
             if (trim($sStatement) !== "") {
                 $oConnection->exec($sStatement);
                 $iQueryCount++;
             }
             $sStatement = "";
         }
     }
     if (trim($sStatement) !== "") {
         $oConnection->exec($sStatement);
     }
     Cache::clearAllCaches();
     return $iQueryCount;
 }
开发者ID:rapila,项目名称:cms-base,代码行数:45,代码来源:BackupWidgetModule.php

示例13: __construct

 /**
  * Used to create FileResource instances. ResourceFinder will call this with given full path, instance prefix, relative path;
  * other uses will likely let the function figure out instance prefix and relative path.
  * Setting relative path to non-null and instance prefix null is not allowed.
  * Setting instance prefix but not relative path is redundant.
  * @param string $sFullPath The absolute file path
  * @param string $sInstancePrefix The part of the CMS’ folder which this file belongs to (base, site or plugins/*); includes trailing slash
  * @param string $sRelativePath The file path following the instance prefix. There can be multiple files in the installation with the same relative paths if the instance prefix differs.
  */
 public function __construct($sFullPath, $sInstancePrefix = null, $sRelativePath = null)
 {
     if (file_exists($sFullPath)) {
         if (($sRealPath = realpath($sFullPath)) === false) {
             throw new Exception("File resource does not have the permissions for realpath({$sFullPath})");
         }
         $sFullPath = $sRealPath;
     }
     if ($sInstancePrefix !== null && !StringUtil::endsWith($sInstancePrefix, '/')) {
         $sInstancePrefix .= '/';
     }
     if ($sRelativePath === null) {
         if (strpos($sFullPath, self::mainDirCanonical()) !== 0) {
             throw new Exception("Tried to instanciate file resource {$sFullPath}, which is not inside main dir (" . self::mainDirCanonical() . ")");
         }
         //Also remove leading slash
         $sRelativePath = substr($sFullPath, strlen(self::mainDirCanonical()) + 1);
         $sPreviousRelativePath = $sRelativePath;
         $sTempInstancePrefix = '';
         do {
             if (strpos($sRelativePath, '/') === false) {
                 $sTempInstancePrefix = '';
                 $sRelativePath = $sPreviousRelativePath;
                 break;
             }
             $sTempInstancePrefix .= substr($sRelativePath, 0, strpos($sRelativePath, '/') + 1);
             if ($sInstancePrefix !== null && $sTempInstancePrefix !== $sInstancePrefix) {
                 throw new Exception("Error in FileResource::__construct(): Supplied instance prefix {$sInstancePrefix} does not match supplied path’s {$sTempInstancePrefix}");
             }
             $sRelativePath = substr($sPreviousRelativePath, strlen($sTempInstancePrefix));
         } while ($sTempInstancePrefix === 'plugins/');
         $sInstancePrefix = $sTempInstancePrefix;
     }
     $this->sFullPath = $sFullPath;
     $this->sInstancePrefix = $sInstancePrefix;
     $this->sRelativePath = $sRelativePath;
 }
开发者ID:rapila,项目名称:cms-base,代码行数:46,代码来源:FileResource.php

示例14: regenerateLongInfinitive

 public function regenerateLongInfinitive()
 {
     $infl = Inflection::loadLongInfinitive();
     $f107 = FlexModel::get_by_modelType_number('F', '107');
     $f113 = FlexModel::get_by_modelType_number('F', '113');
     // Iterate through all the participle forms of this Lexem
     foreach ($this->getLexemModels() as $lm) {
         $ifs = InflectedForm::get_all_by_lexemModelId_inflectionId($lm->id, $infl->id);
         foreach ($ifs as $if) {
             $model = StringUtil::endsWith($if->formNoAccent, 'are') ? $f113 : $f107;
             $lexem = Model::factory('Lexem')->select('l.*')->table_alias('l')->distinct()->join('LexemModel', 'l.id = lm.lexemId', 'lm')->where('l.formNoAccent', $if->formNoAccent)->where_raw("(lm.modelType = 'T' or (lm.modelType = 'F' and lm.modelNumber = '{$model->number}'))")->find_one();
             if ($lexem) {
                 $infLm = $lexem->getFirstLexemModel();
                 if ($infLm->modelType != 'F' || $infLm->modelNumber != $model->number || $inf->restriction != '') {
                     $infLm->modelType = 'F';
                     $infLm->modelNumber = $model->number;
                     $infLm->restriction = '';
                     if ($this->isLoc() && !$infLm->isLoc) {
                         $infLm->isLoc = true;
                         FlashMessage::add("Lexemul {$lexem->formNoAccent}, care nu era în LOC, a fost inclus automat în LOC.", 'info');
                     }
                     $lexem->deepSave();
                 }
             } else {
                 $lexem = Lexem::deepCreate($if->form, 'F', $model->number, '', $this->isLoc());
                 $lexem->deepSave();
                 // Also associate the new lexem with the same definitions as $this.
                 $ldms = LexemDefinitionMap::get_all_by_lexemId($this->id);
                 foreach ($ldms as $ldm) {
                     LexemDefinitionMap::associate($lexem->id, $ldm->definitionId);
                 }
                 FlashMessage::add("Am creat automat lexemul {$lexem->formNoAccent} (F{$model->number}) și l-am asociat cu toate definițiile verbului.", 'info');
             }
         }
     }
 }
开发者ID:florinp,项目名称:dexonline,代码行数:36,代码来源:Lexem.php

示例15: getSiteTemplatesForListOutput

 /**
  * @param string $sPostfix string of template 'list item' identifier
  * retrieve all templates from site template dir that follow a naming convention
  * list template name: examplename.tmpl
  * list_item template name: examplename_item.tmpl
  * @return array assoc of path to examplename in key and value
  */
 public static function getSiteTemplatesForListOutput($sPostfix = '_item')
 {
     $aTemplateList = ArrayUtil::arrayWithValuesAsKeys(Template::listTemplates(DIRNAME_TEMPLATES, true));
     $aListTemplates = array();
     foreach ($aTemplateList as $sPath => $sListName) {
         if (StringUtil::endsWith($sListName, $sPostfix)) {
             $sPath = substr($sListName, 0, -strlen($sPostfix));
             $aListTemplates[$sPath] = $sPath;
         }
     }
     foreach ($aListTemplates as $sListPath) {
         if (!in_array($sListPath, $aTemplateList)) {
             unset($aListTemplates[$sListPath]);
         }
     }
     return $aListTemplates;
 }
开发者ID:rapila,项目名称:cms-base,代码行数:24,代码来源:AdminManager.php


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