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


PHP Text::insert方法代码示例

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


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

示例1: body

 public static function body($alias, $vars = null)
 {
     if (!$vars) {
         $vars = [];
     }
     $content = self::get($alias, 'body');
     return Text::insert($content, $vars);
 }
开发者ID:cakemanager,项目名称:cakephp-textblocks,代码行数:8,代码来源:TBlox.php

示例2: load

 /**
  * Wrapper para Configure::load().
  * Faz uma verificação para ver se o plugin está instalado. (@see PluginStarter::install()).
  * 
  * @param string $pluginName O nome do plugin a ser carregado.
  * @return bool              O retorno do chamado Configure::load().
  */
 public function load($pluginName)
 {
     $settingsFile = $this->pluginInstallationFolder . $pluginName . DS . 'settings.php';
     if (!file_exists($settingsFile)) {
         $this->install($pluginName);
     }
     $configPath = Text::insert('Plugins/:plugin/settings', ['plugin' => $pluginName]);
     return Configure::load($configPath);
 }
开发者ID:mswagencia,项目名称:msw-appcore,代码行数:16,代码来源:PluginStarter.php

示例3: register

 /**
  * Register a new collection.
  *
  * @param string $id The collection identifier.
  * @param array $options The collection options.
  */
 public static function register($id, $options)
 {
     $id = (string) $id;
     if (self::exists($id)) {
         user_error(Text::insert('A collection with id ":id" is already registered.', ['id' => $id]));
         return;
     }
     $defaults = ['model' => 'Plugin.Model', 'displayName' => 'Translated Name'];
     $options = array_merge($defaults, $options);
     self::_instance()->_items[$id] = $options;
 }
开发者ID:wasabi-cms,项目名称:cms,代码行数:17,代码来源:BaseCollection.php

示例4: _results

 /**
  * Prints calculated results
  *
  * @param array $times Array of time values
  * @return void
  */
 protected function _results($times)
 {
     $duration = array_sum($times);
     $requests = count($times);
     $this->out(Text::insert(__d('debug_kit', 'Total Requests made: :requests'), compact('requests')));
     $this->out(Text::insert(__d('debug_kit', 'Total Time elapsed: :duration (seconds)'), compact('duration')));
     $this->out("");
     $this->out(Text::insert(__d('debug_kit', 'Requests/Second: :rps req/sec'), ['rps' => round($requests / $duration, 3)]));
     $this->out(Text::insert(__d('debug_kit', 'Average request time: :average-time seconds'), ['average-time' => round($duration / $requests, 3)]));
     $this->out(Text::insert(__d('debug_kit', 'Standard deviation of average request time: :std-dev'), ['std-dev' => round($this->_deviation($times, true), 3)]));
     $this->out(Text::insert(__d('debug_kit', 'Longest/shortest request: :longest sec/:shortest sec'), ['longest' => round(max($times), 3), 'shortest' => round(min($times), 3)]));
     $this->out("");
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:19,代码来源:BenchmarkShell.php

示例5: link

 /**
  * {@inheritdoc}
  */
 public function link($title, $url = null, array $options = array())
 {
     $url = Router::url($url, ['full' => true]);
     if ('html' == $this->getType()) {
         return parent::link($title, $url, $this->_mergeAttributes($options, $this->config('attributes.link')));
     }
     if (empty($url)) {
         return $title;
     }
     $options += ['templates' => []];
     $options['templates'] += ['link' => ':title: :url'];
     return Text::insert($options['templates']['link'], compact('title', 'url'));
 }
开发者ID:gourmet,项目名称:email,代码行数:16,代码来源:EmailHelper.php

示例6: generate

 /**
  * Turns a string (and optionally a dynamic, data-injected string) into a slugged value
  * @param $pattern string a simple string (e.g. 'slug me') or Text::insert-friendly string (e.g. ':id-:name')
  * @param $data mixed an Array or Entity of data to Text::insert inject into $pattern
  * @param $replacement string the character to replace non-slug-friendly characters with (default '-')
  * @return string the slugged string
  */
 public static function generate($pattern, $data = [], $replacement = '-')
 {
     # if given an Entity object, covert it to a hydrated array
     $data = $data instanceof \Cake\ORM\Entity ? json_decode(json_encode($data->jsonSerialize()), true) : $data;
     # build the slug
     $value = Text::insert($pattern, $data);
     # inject data into pattern (if applicable)
     $value = Inflector::slug($value, $replacement);
     # slug it
     $value = strtolower($value);
     # convert to lowercase
     return $value;
 }
开发者ID:cwbit,项目名称:cakephp-sluggable,代码行数:20,代码来源:Slug.php

示例7: _post

 /**
  * @param string $url
  * @param mixed $data
  * @param string $requestType
  * @return mixed
  * @author   Gustav Wellner Bou <wellner@solutica.de>
  */
 protected function _post($url, $data, $requestType = 'POST')
 {
     $slug = Text::insert($url, $this->settings, ['before' => '{', 'after' => '}']);
     $slug = str_replace(static::BASE_URL, '', $slug);
     $slug = strtolower($requestType) . '_' . Inflector::slug($slug) . '_' . md5($data);
     $file = Plugin::path('Transifex') . 'tests/test_files/json/' . $slug . '.json';
     if (!$this->settings['debug'] && file_exists($file)) {
         $content = file_get_contents($file);
         return json_decode($content, true);
     }
     $result = parent::_post($url, $data, $requestType);
     if ($this->settings['debug']) {
         $file = Plugin::path('Transifex') . 'tests/test_files/json/' . $slug . '.json';
         file_put_contents($file, json_encode($result, JSON_OPTIONS));
     }
     return $result;
 }
开发者ID:dereuromark,项目名称:cakephp-transifex,代码行数:24,代码来源:TransifexLib.php

示例8: renderSidebarMenuItems

 /**
  * Renders
  *
  * @param string|array $config Either the config file to load or the menu config as an array
  * @return string   rendered HTML
  */
 public function renderSidebarMenuItems($config)
 {
     $config = $this->prepareMenuConfig($config);
     $this->setPageTitle($config);
     $out = '';
     foreach ($config as $mainItem => $mainData) {
         $childrenContainer = '';
         if (!empty($mainData['children'])) {
             $children = '';
             foreach ($mainData['children'] as $child) {
                 $children .= Text::insert($this->_defaultConfig['templates']['item'], ['class' => $child['active'] ? 'active' : '', 'title' => $child['title'], 'icon' => isset($child['icon']) ? Text::insert($this->_defaultConfig['templates']['icon'], ['icon' => $child['icon']]) : '', 'href' => isset($child['url']) ? Router::url($child['url']) : '', 'childrenArrow' => '', 'childrenContainer' => '', 'liclass' => '']);
             }
             $childrenContainer = Text::insert($this->_defaultConfig['templates']['childrenContainer'], ['children' => $children]);
         }
         $out .= Text::insert($this->_defaultConfig['templates']['item'], ['class' => $mainData['active'] ? 'active' : '', 'liclass' => $mainData['active'] ? 'active' : '', 'title' => '<span class="mm-text">' . $mainData['title'] . '</span>', 'icon' => isset($mainData['icon']) ? Text::insert($this->_defaultConfig['templates']['icon'], ['icon' => $mainData['icon']]) : '', 'href' => isset($mainData['url']) ? Router::url($mainData['url']) : '', 'childrenArrow' => !empty($mainData['children']) ? $this->_defaultConfig['templates']['childrenArrow'] : '', 'childrenContainer' => $childrenContainer]);
     }
     return $out;
 }
开发者ID:codekanzlei,项目名称:cake-cktools,代码行数:24,代码来源:MenuHelper.php

示例9: setHistoryContext

 /**
  * Sets a context given through a request to identify the creation
  * point of the revision.
  *
  * @param string  $type        Context type
  * @param object  $dataObject  Optional dataobject to get additional data from
  * @param string  $slug        Optional slug. Must implement getContexts() when using
  */
 public function setHistoryContext($type, $dataObject = null, $slug = null)
 {
     if (!in_array($type, array_keys(ModelHistory::getContextTypes()))) {
         throw new InvalidArgumentException("{$type} is not allowed as context type. Allowed types are: " . implode(', ', ModelHistory::getContextTypes()));
     }
     switch ($type) {
         case ModelHistory::CONTEXT_TYPE_SHELL:
             if (!$dataObject instanceof Shell) {
                 throw new InvalidArgumentException('You have to specify a Shell data object for this context type.');
             }
             $context = ['OptionParser' => $dataObject->OptionParser, 'interactive' => $dataObject->interactive, 'params' => $dataObject->params, 'command' => $dataObject->command, 'args' => $dataObject->args, 'name' => $dataObject->name, 'plugin' => $dataObject->plugin, 'tasks' => $dataObject->tasks, 'taskNames' => $dataObject->taskNames];
             $contextSlug = null;
             if ($slug !== null) {
                 $contextSlug = $slug;
             }
             break;
         case ModelHistory::CONTEXT_TYPE_CONTROLLER:
             if (!$dataObject instanceof Request) {
                 throw new InvalidArgumentException('You have to specify a Request data object for this context type.');
             }
             $context = ['params' => $dataObject->params, 'method' => $dataObject->method()];
             if ($slug !== null) {
                 $contextSlug = $slug;
             } else {
                 $contextSlug = Text::insert(':plugin/:controller/:action', ['plugin' => $context['params']['plugin'], 'controller' => $context['params']['controller'], 'action' => $context['params']['action']]);
             }
             break;
         case ModelHistory::CONTEXT_TYPE_SLUG:
         default:
             $context = [];
             if ($slug === null) {
                 throw new InvalidArgumentException('You have to specify a slug for this context type.');
             }
             $contextSlug = $slug;
             break;
     }
     $this->_context = Hash::merge(['type' => $type], $context);
     $this->_contextSlug = $contextSlug;
     $this->_contextType = $type;
 }
开发者ID:codekanzlei,项目名称:cake-model-history,代码行数:48,代码来源:HistoryContextTrait.php

示例10: testReplaceWithQuestionMarkInString

 public function testReplaceWithQuestionMarkInString()
 {
     $string = ':a, :b and :c?';
     $expected = '2 and 3?';
     $result = Text::insert($string, ['b' => 2, 'c' => 3], ['clean' => true]);
     $this->assertEquals($expected, $result);
 }
开发者ID:Slayug,项目名称:castor,代码行数:7,代码来源:TextTest.php

示例11: image

 /**
  * @param float $value (0...X)
  * @param array $options
  * - stars (defaults to 5)
  * - steps per image (defaults to 4 => 1/4 accuracy)
  * - ...
  * @param array $attributes for div container (id, style, ...)
  * @return string $divContainer with rating images
  */
 public function image($value, array $options = array(), array $attr = array())
 {
     $defaults = ['data-symbol' => '&#xf005;', 'escape' => false, 'data-rating-class' => 'rating-fa', 'stars' => 5, 'steps' => 4];
     $options += $defaults;
     if ($value <= 0) {
         $roundedValue = 0;
     } else {
         $roundedValue = round($value * $options['steps']) / $options['steps'];
     }
     $percent = $this->percentage($roundedValue, $options['stars']);
     $precision = 2;
     if ((int) $roundedValue == $roundedValue) {
         $precision = 0;
     } elseif ((int) (2 * $roundedValue) == 2 * $roundedValue) {
         $precision = 1;
     }
     $title = __d('ratings', '{0} of {1} stars', number_format(min($roundedValue, $options['stars']), $precision, ',', '.'), $options['stars']);
     $attrContent = ['class' => 'rating-stars', 'data-content' => str_repeat($options['data-symbol'], $options['stars']), 'escape' => $options['escape'], 'style' => 'width: ' . $percent . '%'];
     $content = $this->Html->div(null, '', $attrContent);
     //<div class="rating-container rating-fa" data-content="&#xf005;&#xf005;&#xf005;&#xf005;&#xf005;" title="x of y stars">
     //	<div class="rating-stars" data-content="&#xf005;&#xf005;&#xf005;&#xf005;&#xf005;" style="width: 20%;"></div>
     //</div>
     $attr += ['title' => $title];
     $attr = ['data-content' => str_repeat($options['data-symbol'], $options['stars']), 'escape' => $options['escape']] + $attr;
     return $this->Html->div('rating-container ' . $options['data-rating-class'], $content, $attr);
     $size = !empty($options['size']) ? $options['size'] : '';
     if (!empty($size)) {
         $options['pixels'] = $this->sizes[$size];
     }
     $pixels = !empty($options['pixels']) ? $options['pixels'] : 16;
     $steps = !empty($options['steps']) ? $options['steps'] : 4;
     if ($value <= 0) {
         $roundedValue = 0;
     } else {
         $roundedValue = round($value * $steps) / $steps;
     }
     $stars = !empty($options['stars']) ? $options['stars'] : 5;
     $array = array(0 => '<div class="ui-stars-star' . ($size ? '-' . $size : '') . ' ui-stars-star' . ($size ? '-' . $size : '') . '-on" style="cursor: default; width: {width}px;"><a style="margin-left: {margin}px;">#</a></div>', 1 => '<div class="ui-stars-star' . ($size ? '-' . $size : '') . ' ui-stars-star' . ($size ? '-' . $size : '') . '-disabled" style="cursor: default; width: {width}px;"><a style="margin-left: {margin}px;">#</a></div>');
     $res = '';
     $disable = 0;
     for ($i = 0; $i < $stars; $i++) {
         for ($j = 0; $j < $steps; $j++) {
             if (!$disable && $i + $j * (1 / $steps) >= $roundedValue) {
                 $disable = 1;
             }
             $v = $array[$disable];
             if ($j === 0) {
                 # try to use a single image if possible
                 if ($i < floor($roundedValue) || $i >= ceil($roundedValue) || $i === 0 && $roundedValue >= 1) {
                     $res .= Text::insert($v, array('margin' => 0, 'width' => $pixels), array('before' => '{', 'after' => '}'));
                     break;
                 }
             }
             $margin = 0 - $pixels / $steps * $j;
             $res .= Text::insert($v, array('margin' => $margin, 'width' => $pixels / $steps), array('before' => '{', 'after' => '}'));
         }
     }
     $precision = 2;
     if ((int) $roundedValue == $roundedValue) {
         $precision = 0;
     } elseif ((int) (2 * $roundedValue) == 2 * $roundedValue) {
         $precision = 1;
     }
     $defaults = array('title' => number_format(min($roundedValue, $stars), $precision, ',', '.') . ' ' . __('von') . ' ' . $stars . ' ' . __('Sternen'));
     $attr = array_merge($defaults, $attr);
     return $this->Html->div('ratingStars clearfix', $res, $attr);
 }
开发者ID:ayman-alkom,项目名称:cakephp-ratings,代码行数:76,代码来源:RatingHelper.php

示例12: _url

 /**
  * Build url
  *
  * @return string url (full)
  */
 protected function _url()
 {
     $params = ['host' => $this->options['host']];
     $url = Text::insert(static::BASE_URL, $params, ['before' => '{', 'after' => '}', 'clean' => true]);
     return $url;
 }
开发者ID:edukondaluetg,项目名称:cakephp-geo,代码行数:11,代码来源:Geocode.php

示例13: _expandPath

 /**
  * Expand all scalar values from a CrudSubject
  * and use them for a Text::insert() interpolation
  * of a path
  *
  * @param \Crud\Event\Subject $subject Subject
  * @param string $path Path
  * @return string
  */
 protected function _expandPath(Subject $subject, $path)
 {
     $keys = [];
     $subjectArray = (array) $subject;
     foreach (array_keys($subjectArray) as $key) {
         if (!is_scalar($subjectArray[$key])) {
             continue;
         }
         $keys[$key] = $subjectArray[$key];
     }
     return Text::insert($path, $keys, ['before' => '{', 'after' => '}']);
 }
开发者ID:AmuseXperience,项目名称:api,代码行数:21,代码来源:ApiListener.php

示例14: render

 /**
  * Render a field by replacing the placeholders
  *
  * @param string $field field name
  * @param Notification $notification notification containing the view vars
  * @return string
  */
 public function render($field, Notification $notification)
 {
     return Text::insert($this->get($field), $notification->config, ['before' => '{{', 'after' => '}}']);
 }
开发者ID:codekanzlei,项目名称:cake-notifications,代码行数:11,代码来源:NotificationContent.php

示例15: nestedResource

 /**
  * Checks if a set of conditions match a nested resource
  *
  * @param array $conditions The conditions in a query
  *
  * @return bool|string Either a URL or false in case no nested resource matched
  */
 public function nestedResource(array $conditions)
 {
     foreach ($this->_nestedResources as $url => $options) {
         if (count(array_intersect_key(array_flip($options['requiredFields']), $conditions)) !== count($options['requiredFields'])) {
             continue;
         }
         return Text::insert($url, $conditions);
     }
     return false;
 }
开发者ID:kwadwo,项目名称:Webservice,代码行数:17,代码来源:Webservice.php


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