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


PHP sfToolkit::pregtr方法代码示例

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


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

示例1: underscore

 /**
  * Returns an underscore-syntaxed version or the CamelCased string.
  *
  * @param  string $camel_cased_word  String to underscore.
  *
  * @return string Underscored string.
  */
 public static function underscore($camel_cased_word)
 {
     $tmp = $camel_cased_word;
     $tmp = str_replace('::', '/', $tmp);
     $tmp = sfToolkit::pregtr($tmp, array('/([A-Z]+)([A-Z][a-z])/' => '\\1_\\2', '/([a-z\\d])([A-Z])/' => '\\1_\\2'));
     return strtolower($tmp);
 }
开发者ID:Phennim,项目名称:symfony1,代码行数:14,代码来源:sfInflector.class.php

示例2: execute

 /**
  * Executes this configuration handler.
  *
  * @param array $configFiles An array of absolute filesystem path to a configuration file
  *
  * @return string Data to be written to a cache file
  *
  * @throws sfConfigurationException If a requested configuration file does not exist or is not readable
  * @throws sfParseException If a requested configuration file is improperly formatted
  */
 public function execute($configFiles)
 {
     // parse the yaml
     $config = self::getConfiguration($configFiles);
     // init our data
     $data = '';
     // let's do our fancy work
     foreach ($config as $file) {
         if (!is_readable($file)) {
             // file doesn't exist
             throw new sfParseException(sprintf('Configuration file "%s" specifies nonexistent or unreadable file "%s".', $configFiles[0], $file));
         }
         $contents = file_get_contents($file);
         // strip comments (not in debug mode)
         if (!sfConfig::get('sf_debug')) {
             $contents = sfToolkit::stripComments($contents);
         }
         // strip php tags
         $contents = sfToolkit::pregtr($contents, array('/^\\s*<\\?(php\\s*)?/m' => '', '/^\\s*\\?>/m' => ''));
         // replace windows and mac format with unix format
         $contents = str_replace("\r", "\n", $contents);
         // replace multiple new lines with a single newline
         $contents = preg_replace(array('/\\s+$/Sm', '/\\n+/S'), "\n", $contents);
         // append file data
         $data .= "\n" . $contents;
     }
     // compile data
     return sprintf("<?php\n" . "// auto-generated by sfCompileConfigHandler\n" . "// date: %s\n" . "%s\n", date('Y/m/d H:i:s'), $data);
 }
开发者ID:sabaki-dev,项目名称:symfony1,代码行数:39,代码来源:sfCompileConfigHandler.class.php

示例3: execute

 /**
  * Executes this configuration handler.
  *
  * @param array $configFiles An array of absolute filesystem path to a configuration file
  *
  * @return string Data to be written to a cache file
  *
  * @throws sfConfigurationException If a requested configuration file does not exist or is not readable
  * @throws sfParseException If a requested configuration file is improperly formatted
  */
 public function execute($configFiles)
 {
     // parse the yaml
     $config = self::getConfiguration($configFiles);
     // init our data
     $data = '';
     // let's do our fancy work
     foreach ($config as $file) {
         if (!is_readable($file)) {
             // file doesn't exist
             throw new sfParseException(sprintf('Configuration file "%s" specifies nonexistent or unreadable file "%s".', $configFiles[0], $file));
         }
         $contents = file_get_contents($file);
         // strip comments (not in debug mode)
         if (!sfConfig::get('sf_debug')) {
             $contents = sfToolkit::stripComments($contents);
         }
         // insert configuration files
         /*      $contents = preg_replace_callback(array('#(require|include)(_once)?\((sfContext::getInstance\(\)\->getConfigCache\(\)|\$configCache)->checkConfig\(\'config/([^\']+)\'\)\);#m',
                                                   '#()()(sfContext::getInstance\(\)\->getConfigCache\(\)|\$configCache)->import\(\'config/([^\']+)\'(, false)?\);#m'),
                                                 array($this, 'insertConfigFileCallback'), $contents);
         */
         // strip php tags
         $contents = sfToolkit::pregtr($contents, array('/^\\s*<\\?(php)?/m' => '', '/^\\s*\\?>/m' => ''));
         // replace windows and mac format with unix format
         $contents = str_replace("\r", "\n", $contents);
         // replace multiple new lines with a single newline
         $contents = preg_replace(array('/\\s+$/Sm', '/\\n+/S'), "\n", $contents);
         // append file data
         $data .= "\n" . $contents;
     }
     // compile data
     $retval = sprintf("<?php\n" . "// auto-generated by sfCompileConfigHandler\n" . "// date: %s\n%s\n", date('Y/m/d H:i:s'), $data);
     return $retval;
 }
开发者ID:xfifix,项目名称:symfony-1.4,代码行数:45,代码来源:sfCompileConfigHandler.class.php

示例4: v_simple_format_text

function v_simple_format_text($text, $options = array(), $ender = "")
{
    $css = isset($options['class']) ? ' class="' . $options['class'] . '"' : '';
    $text = sfToolkit::pregtr($text, array("/(\r\n|\r)/" => "\n", "/\n{2,}/" => "</p><p{$css}>"));
    // turn two and more newlines into paragraph
    // turn single newline into <br/>
    $text = str_replace("\n", "\n<br />", $text);
    return '<p' . $css . '>' . $text . $ender . '</p>';
    // wrap the first and last line in paragraphs before we're done
}
开发者ID:voota,项目名称:voota,代码行数:10,代码来源:VoFormatHelper.php

示例5: upgrade

 public function upgrade()
 {
     $specVersion = sfYaml::getSpecVersion();
     $queue = array();
     $success = true;
     $finder = sfFinder::type('file')->name('*.yml')->prune('vendor');
     foreach ($finder->in(sfConfig::get('sf_root_dir')) as $file) {
         // attempt to upgrade booleans
         $original = file_get_contents($file);
         $upgraded = sfToolkit::pregtr($original, array('/^([^:]+: +)(?:on|y(?:es)?|\\+)(\\s*(#.*)?)$/im' => '\\1true\\2', '/^([^:]+: +)(?:off|no?|-)(\\s*(#.*)?)$/im' => '\\1false\\2'));
         try {
             sfYaml::setSpecVersion('1.1');
             $yaml11 = sfYaml::load($original);
             sfYaml::setSpecVersion('1.2');
             $yaml12 = sfYaml::load($upgraded);
         } catch (Exception $e) {
             // unable to load the YAML
             $yaml11 = 'foo';
             $yaml12 = 'bar';
         }
         if ($yaml11 == $yaml12) {
             if ($original != $upgraded) {
                 $this->getFilesystem()->touch($file);
                 file_put_contents($file, $upgraded);
             }
         } else {
             $this->logSection('yaml', 'Unable to upgrade ' . sfDebug::shortenFilePath($file), null, 'ERROR');
             // force project to use YAML 1.1 spec
             if ('1.1' != $specVersion) {
                 $specVersion = '1.1';
                 $class = sfClassManipulator::fromFile(sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php');
                 $original = $class->getCode();
                 $modified = $class->wrapMethod('setup', 'sfYaml::setSpecVersion(\'1.1\');');
                 if ($original != $modified && $this->askConfirmation(array('Unable to convert YAML file:', sfDebug::shortenFilePath($file), '', 'Would you like to force YAML to be parsed with the 1.1 specification? (Y/n)'), 'QUESTION_LARGE')) {
                     $this->logSection('yaml', 'Forcing YAML 1.1 spec');
                     $this->getFilesystem()->touch($class->getFile());
                     $class->save();
                 } else {
                     $this->logBlock(array('Unable to either upgrade YAML files or force 1.1 spec.', '(see UPGRADE_TO_1_3 file for more information)'), 'ERROR_LARGE');
                 }
             }
             $success = false;
         }
     }
     if ($success && '1.1' == $specVersion) {
         $file = sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php';
         $original = file_get_contents($file);
         $modified = preg_replace('/^\\s*sfYaml::setSpecVersion\\(\'1\\.1\'\\);\\n/im', '', $original);
         if ($original != $modified) {
             $this->logSection('yaml', 'Removing setting of YAML 1.1 spec');
             $this->getFilesystem()->touch($file);
             file_put_contents($file, $modified);
         }
     }
 }
开发者ID:souravmondal-cn,项目名称:symfonyweather,代码行数:55,代码来源:sfYamlUpgrade.class.php

示例6: formatLogLine

 /**
  * Formats a log line.
  *
  * @param string $logLine The log line to format
  *
  * @return string The formatted log lin
  */
 protected function formatLogLine($logLine)
 {
     static $constants;
     if (!$constants) {
         foreach (array('sf_app_dir', 'sf_root_dir', 'sf_symfony_lib_dir') as $constant) {
             $constants[realpath(sfConfig::get($constant)) . DIRECTORY_SEPARATOR] = $constant . DIRECTORY_SEPARATOR;
         }
     }
     // escape HTML
     $logLine = htmlspecialchars($logLine, ENT_QUOTES, sfConfig::get('sf_charset'));
     // replace constants value with constant name
     $logLine = str_replace(array_keys($constants), array_values($constants), $logLine);
     $logLine = sfToolkit::pregtr($logLine, array('/&quot;(.+?)&quot;/s' => '"<span class="sfWebDebugLogInfo">\\1</span>"', '/^(.+?)\\(\\)\\:/S' => '<span class="sfWebDebugLogInfo">\\1()</span>:', '/line (\\d+)$/' => 'line <span class="sfWebDebugLogInfo">\\1</span>'));
     // special formatting for SQL lines
     $logLine = preg_replace('/\\b(SELECT|FROM|AS|LIMIT|ASC|COUNT|DESC|WHERE|LEFT JOIN|INNER JOIN|RIGHT JOIN|ORDER BY|GROUP BY|IN|LIKE|DISTINCT|DELETE|INSERT|INTO|VALUES)\\b/', '<span class="sfWebDebugLogInfo">\\1</span>', $logLine);
     // remove username/password from DSN
     if (strpos($logLine, 'DSN') !== false) {
         $logLine = preg_replace("/=&gt;\\s+'?[^'\\s,]+'?/", "=&gt; '****'", $logLine);
     }
     return $logLine;
 }
开发者ID:ajith24,项目名称:ajithworld,代码行数:28,代码来源:sfWebDebug.class.php

示例7: formatLogLine

 /**
  * Formats a log line.
  *
  * @param string $logLine The log line to format
  *
  * @return string The formatted log lin
  */
 protected function formatLogLine($logLine)
 {
     static $constants;
     if (!$constants) {
         foreach (array('sf_app_dir', 'sf_root_dir', 'sf_symfony_lib_dir') as $constant) {
             $constants[realpath(sfConfig::get($constant)) . DIRECTORY_SEPARATOR] = $constant . DIRECTORY_SEPARATOR;
         }
     }
     // escape HTML
     $logLine = htmlspecialchars($logLine, ENT_QUOTES, sfConfig::get('sf_charset'));
     // replace constants value with constant name
     $logLine = str_replace(array_keys($constants), array_values($constants), $logLine);
     $logLine = sfToolkit::pregtr($logLine, array('/&quot;(.+?)&quot;/s' => '"<span class="sfWebDebugLogInfo">\\1</span>"', '/^(.+?)\\(\\)\\:/S' => '<span class="sfWebDebugLogInfo">\\1()</span>:', '/line (\\d+)$/' => 'line <span class="sfWebDebugLogInfo">\\1</span>'));
     // special formatting for SQL lines
     $logLine = $this->formatSql($logLine);
     // remove username/password from DSN
     if (strpos($logLine, 'DSN') !== false) {
         $logLine = preg_replace("/=&gt;\\s+'?[^'\\s,]+'?/", "=&gt; '****'", $logLine);
     }
     return $logLine;
 }
开发者ID:Phennim,项目名称:symfony1,代码行数:28,代码来源:sfWebDebugPanelLogs.class.php

示例8: execute

 /**
  * Executes this configuration handler.
  *
  * @param array An array of absolute filesystem path to a configuration file
  *
  * @return string Data to be written to a cache file
  *
  * @throws sfConfigurationException If a requested configuration file does not exist or is not readable
  * @throws sfParseException If a requested configuration file is improperly formatted
  */
 public function execute($configFiles)
 {
     // parse the yaml
     $config = array();
     foreach ($configFiles as $configFile) {
         $config = array_merge($config, $this->parseYaml($configFile));
     }
     // init our data
     $data = '';
     // let's do our fancy work
     foreach ($config as $file) {
         $file = $this->replaceConstants($file);
         $file = $this->replacePath($file);
         if (!is_readable($file)) {
             // file doesn't exist
             $error = sprintf('Configuration file "%s" specifies nonexistent or unreadable file "%s"', $configFiles[0], $file);
             throw new sfParseException($error);
         }
         $contents = file_get_contents($file);
         // strip comments (not in debug mode)
         if (!sfConfig::get('sf_debug')) {
             $contents = sfToolkit::stripComments($contents);
         }
         // insert configuration files
         $contents = preg_replace_callback(array('#(require|include)(_once)?\\((sfConfigCache::getInstance\\(\\)|\\$configCache)->checkConfig\\([^_]+sf_app_config_dir_name[^\\.]*\\.\'/([^\']+)\'\\)\\);#m', '#()()(sfConfigCache::getInstance\\(\\)|\\$configCache)->import\\(.sf_app_config_dir_name\\.\'/([^\']+)\'(, false)?\\);#m'), array($this, 'insertConfigFileCallback'), $contents);
         // strip php tags
         $contents = sfToolkit::pregtr($contents, array('/^\\s*<\\?(php)?/m' => '', '/^\\s*\\?>/m' => ''));
         // replace windows and mac format with unix format
         $contents = str_replace("\r", "\n", $contents);
         // replace multiple new lines with a single newline
         $contents = preg_replace(array('/\\s+$/Sm', '/\\n+/S'), "\n", $contents);
         // append file data
         $data .= "\n" . $contents;
     }
     // compile data
     $retval = sprintf("<?php\n" . "// auto-generated by sfCompileConfigHandler\n" . "// date: %s\n%s\n", date('Y/m/d H:i:s'), $data);
     // save current symfony release
     file_put_contents(sfConfig::get('sf_config_cache_dir') . '/VERSION', file_get_contents(sfConfig::get('sf_symfony_lib_dir') . '/VERSION'));
     return $retval;
 }
开发者ID:Daniel-Marynicz,项目名称:symfony1-legacy,代码行数:50,代码来源:sfCompileConfigHandler.class.php

示例9: camelize

 protected function camelize($text)
 {
     return sfToolkit::pregtr($text, array('#/(.?)#e' => "'::'.strtoupper('\\1')", '/(^|_|-)+(.)/e' => "strtoupper('\\2')"));
 }
开发者ID:pkdevbox,项目名称:mootools-forge,代码行数:4,代码来源:sfFormFilterPropel.class.php

示例10: stripComments

 public static function stripComments($source)
 {
     if (!sfConfig::get('sf_strip_comments', true)) {
         return $source;
     }
     // tokenizer available?
     if (!function_exists('token_get_all')) {
         $source = sfToolkit::pregtr($source, array('#/\\*((?!\\*/)[\\d\\D\\s])*\\*/#' => '', '#^\\s*//.*$#m' => ''));
         // remove // ...
         return $source;
     }
     $output = '';
     $tokens = token_get_all($source);
     foreach ($tokens as $token) {
         if (is_string($token)) {
             // simple 1-character token
             $output .= $token;
         } else {
             // token array
             list($id, $text) = $token;
             switch ($id) {
                 case T_COMMENT:
                 case T_DOC_COMMENT:
                     // no action on comments
                     break;
                 default:
                     // anything else -> output "as is"
                     $output .= $text;
                     break;
             }
         }
     }
     return $output;
 }
开发者ID:taryono,项目名称:school,代码行数:34,代码来源:sfToolkit.class.php

示例11: simple_format_text

function simple_format_text($text, $options = array())
{
    $css = isset($options['class']) ? ' class="' . $options['class'] . '"' : '';
    $text = sfToolkit::pregtr($text, array("/(\r\n|\r)/" => "\n", "/\n{3,}/" => "\n\n", "/\n\n/" => "</p>\\0<p{$css}>", "/([^\n])\n([^\n])/" => "\\1\n<br />\\2"));
    // turn single newline into <br/>
    return '<p' . $css . '>' . $text . '</p>';
    // wrap the first and last line in paragraphs before we're done
}
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:8,代码来源:TextHelper.php

示例12: simple_format_text

function simple_format_text($text, $options = array())
{
  $css = (isset($options['class'])) ? ' class="'.$options['class'].'"' : '';

  $text = sfToolkit::pregtr($text, array("/(\r\n|\r)/"        => "\n",               // lets make them newlines crossplatform
                                         "/\n{3,}/"           => "\n\n",             // zap dupes
                                         "/\n\n/"             => "</p>\\0<p$css>",   // turn two newlines into paragraph
                                         "/([^\n])\n([^\n])/" => "\\1\n<br />\\2")); // turn single newline into <br/>

  return '<p'.$css.'>'.$text.'</p>'; // wrap the first and last line in paragraphs before we're done
}
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:11,代码来源:TextHelper.php

示例13: _labelise

function _labelise($id)
{
    return sfToolkit::pregtr($id, array('#/(.?)#e' => "'::'.strtoupper('\\1')", '/(^|_)(.)/e' => "strtoupper(' \\2')"));
}
开发者ID:rayku,项目名称:rayku,代码行数:4,代码来源:MyFormHelper.php


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