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


PHP dmString::str_replace_once方法代码示例

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


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

示例1: getPathFromWebDir

 public static function getPathFromWebDir($type, $asset)
 {
     $package = substr($asset, 0, strpos($asset, '.'));
     if (in_array($package, array('core', 'lib', 'front', 'admin'))) {
         $name = substr($asset, strpos($asset, '.') + 1);
     } else {
         $name = $asset;
     }
     switch ($type) {
         case 'js':
             switch ($package) {
                 case 'core':
                     $path = '/' . sfConfig::get('dm_core_asset') . '/js/' . $name . '.js';
                     break;
                 case 'lib':
                     $path = '/' . sfConfig::get('dm_core_asset') . '/lib/' . $name . '.js';
                     break;
                 case 'front':
                     $path = '/' . sfConfig::get('dm_front_asset') . '/js/' . $name . '.js';
                     break;
                 case 'admin':
                     $path = '/' . sfConfig::get('dm_admin_asset') . '/js/' . $name . '.js';
                     break;
                 default:
                     $path = '/' . dmString::str_replace_once('.', '/' . $type . '/', $asset) . '.js';
             }
             break;
         case 'css':
             switch ($package) {
                 case 'core':
                     $path = '/' . sfConfig::get('dm_core_asset') . '/css/' . $name . '.css';
                     break;
                 case 'lib':
                     $path = '/' . sfConfig::get('dm_core_asset') . '/lib/' . $name . '.css';
                     break;
                 case 'front':
                     $path = '/' . sfConfig::get('dm_front_asset') . '/css/' . $name . '.css';
                     break;
                 case 'admin':
                     $path = '/' . sfConfig::get('dm_admin_asset') . '/css/' . $name . '.css';
                     break;
                 default:
                     $path = '/' . dmString::str_replace_once('.', '/' . $type . '/', $asset) . '.css';
             }
             break;
         default:
             $path = '/' . dmString::str_replace_once('.', '/', $asset);
     }
     if (!isset($path)) {
         throw new dmException("Can not find path for asset {$type}.{$package}.{$asset}");
     }
     return $path;
 }
开发者ID:jdart,项目名称:diem,代码行数:53,代码来源:dmInlineAssetConfigHandler.php

示例2: formatGeshiCode

 protected function formatGeshiCode(array $matches)
 {
     $code = $matches[2];
     $language = $matches[1];
     $cacheKey = md5($code . $language);
     if ($this->getOption('use_cache') && ($cache = $this->cacheManager->getCache('markdown')->get($cacheKey))) {
         return $cache;
     }
     $code = html_entity_decode($code);
     require_once dmOs::join(sfConfig::get('sf_lib_dir'), 'vendor/geshi/geshi.php');
     $geshi = new GeSHi($code, $language);
     $geshi->enable_classes();
     $html = $geshi->parse_code();
     $html = dmString::str_replace_once('> ', '>', $html);
     $html = dmString::str_replace_once("\n<span class=\"kw2\">&lt;?php</span>", '', $html);
     $html = dmString::str_replace_once("\n", '', $html);
     $html = dmString::str_replace_once('  ', '', $html);
     if ($this->getOption('use_cache')) {
         $this->cacheManager->getCache('markdown')->set($cacheKey, $html);
     }
     return $html;
 }
开发者ID:Regmaya,项目名称:diem-project,代码行数:22,代码来源:myGeshiMarkdown.php

示例3: move

 /**
  * Move into another folder
  *
  * @param DmMediaFolder $folder
  */
 public function move(DmMediaFolder $folder)
 {
     if ($folder->id == $this->nodeParentId) {
         return $this;
     }
     if ($folder->getNode()->isDescendantOfOrEqualTo($this)) {
         throw new dmException('Can not move to a descendant');
     }
     if ($this->getNode()->isRoot()) {
         throw new dmException('The root folder cannot be moved');
     }
     if (!$this->isWritable()) {
         throw new dmException(sprintf('The folder %s is not writable.', dmProject::unRootify($this->fullPath)));
     }
     if (!$folder->isWritable()) {
         throw new dmException(sprintf('The folder %s is not writable.', dmProject::unRootify($folder->fullPath)));
     }
     if ($folder->hasSubFolder($this->name)) {
         throw new dmException(sprintf('The selected folder already contains a folder named "%s".', $this->name));
     }
     $oldRelPath = $this->get('rel_path');
     $newRelPath = $folder->get('rel_path') . '/' . $this->name;
     $fs = $this->getService('filesystem');
     $oldFullPath = $this->getFullPath();
     $newFullPath = dmOs::join($folder->getFullPath(), $this->name);
     if (!rename($oldFullPath, $newFullPath)) {
         throw new dmException('Can not move %s to %s', dmProject::unRootify($oldFullPath), dmProject::unRootify($newFullPath));
     }
     $this->set('rel_path', $newRelPath);
     $this->clearCache();
     $this->getNode()->moveAsFirstChildOf($folder);
     //update descendants
     if ($descendants = $this->getNode()->getDescendants()) {
         foreach ($descendants as $folder) {
             $folder->set('rel_path', dmString::str_replace_once($oldRelPath, $newRelPath, $folder->get('rel_path')));
             $folder->save();
         }
     }
     return $this;
 }
开发者ID:jdart,项目名称:diem,代码行数:45,代码来源:PluginDmMediaFolder.class.php

示例4: getPathFromWebDir

 public static function getPathFromWebDir($type, $asset)
 {
     $package = substr($asset, 0, strpos($asset, '.'));
     if (in_array($package, array('core', 'lib', 'front', 'admin'))) {
         $name = substr($asset, strpos($asset, '.') + 1);
     } else {
         $name = $asset;
     }
     switch ($type) {
         case 'js':
             switch ($package) {
                 case 'core':
                     $path = '/' . sfConfig::get('dm_core_asset') . '/js/' . $name . '.js';
                     break;
                 case 'lib':
                     $path = '/' . sfConfig::get('dm_core_asset') . '/lib/' . $name . '.js';
                     break;
                 case 'front':
                     $path = '/' . sfConfig::get('dm_front_asset') . '/js/' . $name . '.js';
                     break;
                 case 'admin':
                     $path = '/' . sfConfig::get('dm_admin_asset') . '/js/' . $name . '.js';
                     break;
                 default:
                     $path = '/' . dmString::str_replace_once('.', '/' . $type . '/', $asset) . '.js';
             }
             break;
         case 'css':
             switch ($package) {
                 case 'core':
                     $path = '/' . sfConfig::get('dm_core_asset') . '/css/' . $name . '.css';
                     break;
                 case 'lib':
                     $path = '/' . sfConfig::get('dm_core_asset') . '/lib/' . $name . '.css';
                     break;
                 case 'front':
                     $path = '/' . sfConfig::get('dm_front_asset') . '/css/' . $name . '.css';
                     break;
                 case 'admin':
                     $path = '/' . sfConfig::get('dm_admin_asset') . '/css/' . $name . '.css';
                     break;
                 default:
                     $path = '/' . dmString::str_replace_once('.', '/' . $type . '/', $asset) . '.css';
             }
             break;
         default:
             $path = '/' . dmString::str_replace_once('.', '/', $asset);
     }
     if (!isset($path)) {
         throw new dmException("Can not find path for asset {$type}.{$package}.{$asset}");
     }
     // check for source version of the file in `dev` environment
     if (sfConfig::get('sf_environment') == 'dev') {
         $webPath = sfConfig::get('sf_web_dir');
         $fsPath = $webPath . $path;
         $fsSourceFilePath = null;
         $fsDirName = dirname($fsPath);
         $fsFilename = basename($fsPath);
         if (strpos($fsFilename, '.min.')) {
             $possibleFsSourceFilePath = $fsDirName . DIRECTORY_SEPARATOR . str_replace('.min.', '.', $fsFilename);
             if (file_exists($possibleFsSourceFilePath)) {
                 $fsSourceFilePath = $possibleFsSourceFilePath;
             }
         }
         if (is_null($fsSourceFilePath)) {
             $fsPathDirectories = explode(DIRECTORY_SEPARATOR, $fsDirName);
             $fsFilename = str_replace('.min.', '.', $fsFilename);
             foreach ($fsPathDirectories as $fsDirectory) {
                 if (in_array($fsDirectory, array('min', 'minified', 'compressed', 'minimized'))) {
                     foreach (array('source', 'unminified', 'uncompressed', 'unminimized') as $possibleSourceDirName) {
                         $search = DIRECTORY_SEPARATOR . $fsDirectory . DIRECTORY_SEPARATOR;
                         $replace = DIRECTORY_SEPARATOR . $possibleSourceDirName . DIRECTORY_SEPARATOR;
                         $possibleFsSourceFilePath = str_replace($search, $replace, $fsDirName . DIRECTORY_SEPARATOR) . $fsFilename;
                         if (file_exists($possibleFsSourceFilePath)) {
                             $fsSourceFilePath = $possibleFsSourceFilePath;
                             break;
                         }
                     }
                     //break after a directory with minified files is found
                     break;
                 }
             }
             unset($fsDirectory);
         }
         if (!is_null($fsSourceFilePath)) {
             $fs = dmContext::getInstance()->getFilesystem();
             $path = '/' . $fs->getRelativeDir($webPath . DIRECTORY_SEPARATOR, $fsSourceFilePath);
         }
     }
     return $path;
 }
开发者ID:theolymp,项目名称:diem,代码行数:91,代码来源:dmInlineAssetConfigHandler.php

示例5: _doAnchors_inline_callback

 public function _doAnchors_inline_callback($matches)
 {
     $text = $this->runSpanGamut($matches[2]);
     $url = $matches[3] == '' ? $matches[4] : $matches[3];
     $title = $matches[7];
     $attrs = $matches[9];
     if (false !== strpos($url, '#')) {
         $anchor = preg_replace('{.*\\#([\\w\\d\\-\\:]+).*}i', '$1', $url);
         $url = dmString::str_replace_once('#' . $anchor, '', $url);
     } else {
         $anchor = null;
     }
     if (strlen($url) == 0 && $anchor) {
         $link = $this->helper->link('#' . $anchor)->text($text);
     } else {
         $link = $this->helper->link($url)->text($text);
         if ($anchor) {
             $link->anchor($anchor);
         }
     }
     if ($title) {
         $link->title($title);
     }
     if ($attrs) {
         $link->set($attrs);
     }
     return $this->hashPart($link->render());
 }
开发者ID:theolymp,项目名称:diem,代码行数:28,代码来源:dmMarkdown.php


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