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


PHP Inflector::slug方法代码示例

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


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

示例1: file

 /**
  * Get content of file, parse it with lessc and return formatted css
  *
  * @todo allow for css-file name only, and search it in all avail. webroots
  * @param string $file full path to file
  * @param array $options Additional options to control flow of method
  *                       - header - controls, whether to prepend a header
  *                       - cache - controls, whether to cache the result
  *                       - cachePath - Where to cache files, defaults to
  *                                     resources/tmp/cache
  * @return string|boolean generated css, false in case of error
  */
 public static function file($file, array $options = array())
 {
     $defaults = array('header' => true, 'cache' => true, 'cachePath' => Libraries::get(true, 'resources') . '/tmp/cache', 'cacheKey' => Inflector::slug(str_replace(array(LITHIUM_APP_PATH, '.less'), array('', '.css'), $file)));
     $options += $defaults;
     $css_file = $options['cachePath'] . '/' . $options['cacheKey'];
     if (file_exists($css_file) && filemtime($css_file) >= filemtime($file)) {
         return file_get_contents($css_file);
     }
     if (!file_exists($file)) {
         return false;
     }
     try {
         $less = static::_getLess($file);
         $output = $less->parse();
     } catch (Exception $e) {
         $output = "/* less compiler exception: {$e->getMessage()} */";
     }
     if ($options['header']) {
         $output = static::_prependHeader($output);
     }
     if ($options['cache']) {
         file_put_contents($css_file, $output);
     }
     return $output;
 }
开发者ID:raisinbread,项目名称:li3_less,代码行数:37,代码来源:Less.php

示例2: render

 public function render($data, $contents = array(), array $options = array())
 {
     $this->_mustache();
     $defaults = array('id' => '', 'class' => '', 'hash' => true, 'right' => '');
     $options += $defaults;
     $tabs = $panes = array();
     foreach ($data as $slug => $tab) {
         if (!is_array($tab)) {
             $tab = array('name' => $tab);
         }
         $slug = is_numeric($slug) ? strtolower(Inflector::slug($tab['name'])) : $slug;
         $tab = $this->_tab($tab, array('id' => $slug));
         if (empty($tab['url'])) {
             $tab['url'] = $options['hash'] ? sprintf('#%s', $slug) : $slug;
         } else {
             $slug = str_replace('#', '', $tab['url']);
         }
         if (isset($tab['content'])) {
             $panes[] = $this->_pane($tab['content'], $tab);
             unset($tab['content']);
         }
         $tabs[] = $tab;
     }
     $params = $options += compact('tabs', 'panes');
     return $this->mustache->render('tabs', $params, array('library' => 'li3_bootstrap'));
 }
开发者ID:bruensicke,项目名称:li3_bootstrap,代码行数:26,代码来源:Tab.php

示例3: testTransliteration

	public function testTransliteration() {
		$data = array(
			'transliteration' => array(
				'\$' => 'dollar',
				'&' => 'and'
			)
		);
		Catalog::write('runtime', 'inflection', 'en', $data);

		Inflector::rules(
			'transliteration', Catalog::read('runtime', 'inflection.transliteration', 'en')
		);

		$result = Inflector::slug('this & that');
		$expected = 'this-and-that';
		$this->assertEqual($expected, $result);

		$data = array(
			'transliteration' => array(
				't' => 'd',
				'&' => 'und'
			)
		);
		Catalog::write('runtime', 'inflection', 'de', $data);

		Inflector::rules(
			'transliteration', Catalog::read('runtime', 'inflection.transliteration', 'de')
		);

		$result = Inflector::slug('this & that');
		$expected = 'dhis-und-dhad';
		$this->assertEqual($expected, $result);
	}
开发者ID:niel,项目名称:lithium,代码行数:33,代码来源:CatalogInflectorTest.php

示例4: add

 public static function add($name, array $config = array())
 {
     $session = static::$_classes['session'];
     $name = strtolower(Inflector::slug($name));
     $defaults = array('adapter' => '', 'name' => $name);
     return static::$_configurations[$name] = $config + $defaults;
 }
开发者ID:joseym,项目名称:li3_analytics,代码行数:7,代码来源:Trackers.php

示例5: _init

 /**
  * Initialization of the cookie adapter.
  *
  * @return void
  */
 protected function _init()
 {
     parent::_init();
     if (!$this->_config['name']) {
         $this->_config['name'] = Inflector::slug(basename(LITHIUM_APP_PATH)) . 'cookie';
     }
 }
开发者ID:EHER,项目名称:monopolis,代码行数:12,代码来源:Cookie.php

示例6: run

 /**
  * Auto run the help command
  *
  * @param string $name COMMAND to get help
  * @return void
  */
 public function run($name = null)
 {
     if (!$name) {
         $this->out('COMMANDS', 'heading1', 2);
         $commands = Libraries::locate('command', null, array('recursive' => false));
         foreach ($commands as $command) {
             $info = Inspector::info($command);
             $name = strtolower(Inflector::slug($info['shortName']));
             $this->out($this->_pad($name), 'heading2');
             $this->out($this->_pad($info['description']), 2);
         }
         $message = 'See `{:command}li3 help COMMAND{:end}`';
         $message .= ' for more information on a specific command.';
         $this->out($message, 2);
         return true;
     }
     $name = Inflector::classify($name);
     if (!($class = Libraries::locate('command', $name))) {
         $this->error("{$name} not found");
         return false;
     }
     if (strpos($name, '\\') !== false) {
         $name = join('', array_slice(explode("\\", $name), -1));
     }
     $name = strtolower(Inflector::slug($name));
     $methods = $this->_methods($class);
     $properties = $this->_properties($class);
     $this->out('USAGE', 'heading1');
     $this->out($this->_pad(sprintf("{:command}li3 %s{:end}{:option}%s{:end} [ARGS]", $name ?: 'COMMAND', array_reduce($properties, function ($a, $b) {
         return "{$a} {$b['usage']}";
     }))));
     $info = Inspector::info($class);
     if (!empty($info['description'])) {
         $this->nl();
         $this->out('DESCRIPTION');
         $this->out($this->_pad(strtok($info['description'], "\n"), 1));
         $this->nl();
     }
     if ($properties || $methods) {
         $this->out('OPTIONS', 'heading2');
     }
     if ($properties) {
         $this->_render($properties);
     }
     if ($methods) {
         $this->_render($methods);
     }
     return true;
 }
开发者ID:EHER,项目名称:chegamos,代码行数:55,代码来源:Help.php

示例7: __init

 /**
  * Initialize location
  * Apply method filters
  */
 public static function __init()
 {
     static::config();
     static::applyFilter('mkdir', function ($self, $params, $chain) {
         $name = explode('/', $params['name']);
         foreach ($name as $i => $s) {
             $name[$i] = Inflector::slug($s);
         }
         $params['name'] = join('/', $name);
         return $chain->next($self, $params, $chain);
     });
     static::applyFilter('upload', function ($self, $params, $chain) {
         $file = explode('.', $params['file']['name']);
         $end = count($file) - 1;
         $extension = $file[$end];
         unset($file[$end]);
         $name = join($file);
         $params['file']['name'] = Inflector::slug($name) . ".{$extension}";
         return $chain->next($self, $params, $chain);
     });
     static::applyFilter('copy', function ($self, $params, $chain) {
         $source = trim($params['source'], '/');
         $dest = trim($params['dest'], '/');
         if (substr($dest, 0, strlen($source)) === $source) {
             return false;
         }
         return $chain->next($self, $params, $chain);
     });
     static::applyFilter('move', function ($self, $params, $chain) {
         $source = trim($params['oldname'], '/');
         $dest = trim($params['newname'], '/');
         if (substr($dest, 0, strlen($source)) === $source) {
             return false;
         }
         return $chain->next($self, $params, $chain);
     });
 }
开发者ID:djordje,项目名称:li3_filemanager,代码行数:41,代码来源:Location.php

示例8: testDefaultCookieName

 public function testDefaultCookieName()
 {
     $cookie = new Cookie();
     $expected = Inflector::slug(basename(Libraries::get(true, 'path'))) . 'cookie';
     $this->assertEqual($expected, $cookie->key());
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:6,代码来源:CookieTest.php

示例9: bind

 /**
  * Connect a resource to the `Router`.
  *
  * @param string $resource The name of the resource
  * @param array $options
  */
 public static function bind($resource, $options = array())
 {
     $resources = explode('/', $resource);
     $splitCount = count($resources);
     $class = static::$_classes['route'];
     $scope = isset($options['scope']) ? '(/{:scope:' . strtolower($options['scope']) . '})' : '';
     if ($splitCount > 1) {
         $controller = $resources[$splitCount - 1];
         $resource = Inflector::underscore($controller);
         for ($i = $splitCount - 2; $i >= 0; $i--) {
             $resource = Inflector::underscore($resources[$i]) . '/{:' . Inflector::underscore($resources[$i]) . '_id:[0-9a-f]{24}|[0-9]+}/' . $resource;
         }
     } else {
         $resource = Inflector::pluralize(strtolower(Inflector::slug($resource)));
         $controller = $resource;
         $resource = Inflector::underscore($resource);
     }
     $types = static::$_types;
     if (isset($options['types'])) {
         $types = $options['types'] + $types;
     }
     if (isset($options['except'])) {
         foreach (array_intersect((array) $options['except'], array_keys($types)) as $k) {
             unset($types[$k]);
         }
     }
     if (isset($options['only'])) {
         foreach (array_keys($types) as $k) {
             if (!in_array($k, (array) $options['only'])) {
                 unset($types[$k]);
             }
         }
     }
     $configs = array();
     foreach ($types as $action => $params) {
         $config = array('template' => $scope . String::insert($params['template'], array('resource' => $resource)), 'params' => $params['params'] + array('controller' => $controller, 'action' => isset($params['action']) ? $params['action'] : $action));
         $configs[] = $config;
         if (@$options['type_support'] != false) {
             if (isset($params['type_support']) && $params['type_support'] || @$options['type_support']) {
                 $config = array('template' => $scope . String::insert($params['template'] . '(.{:type:\\w+})?', array('resource' => $resource)), 'params' => $params['params'] + array('controller' => $controller, 'action' => isset($params['action']) ? $params['action'] : $action));
                 $configs[] = $config;
             }
         }
     }
     return $configs;
 }
开发者ID:johnny13,项目名称:li3_rest,代码行数:52,代码来源:Resource.php

示例10: __construct

 public function __construct(array $config = array())
 {
     $self =& $this;
     $defaults = array('base' => array(), 'text' => array(), 'textarea' => array(), 'select' => array('multiple' => false), 'attributes' => array('id' => function ($method, $name, $options) use(&$self) {
         if (in_array($method, array('create', 'end', 'label', 'error'))) {
             return;
         }
         if (!$name || $method == 'hidden' && $name == '_method') {
             return;
         }
         $id = Inflector::camelize(Inflector::slug($name));
         $model = ($binding = $self->binding()) ? $binding->model() : null;
         return $model ? basename(str_replace('\\', '/', $model)) . $id : $id;
     }, 'name' => function ($method, $name, $options) {
         if (!strpos($name, '.')) {
             return $name;
         }
         $name = explode('.', $name);
         $first = array_shift($name);
         return $first . '[' . join('][', $name) . ']';
     }));
     parent::__construct(Set::merge($defaults, $config));
 }
开发者ID:ncud,项目名称:sagalaya,代码行数:23,代码来源:Form.php

示例11: foreach

<?php

$nav = $panels = '';
foreach ($tabs as $tab => $fields) {
    $slug = strtolower(\lithium\util\Inflector::slug($tab));
    $active = $nav ? '' : ' active';
    $nav .= sprintf('<li class="%s"><a href="#%s" data-toggle="tab">%s</a></li>', $active, $slug, $tab);
    $panels .= sprintf('<div class="tab-pane%s" id="%s">', $active, $slug);
    $panels .= $this->scaffold->render('form.fields', compact('fields', 'skip', 'readonly'));
    $panels .= '</div>';
}
?>
<div class="row">

	<div class="col-md-4">
		<h3><?php 
echo $this->scaffold->human;
?>
 meta</h3>
		<div class="well">
			<div class="form-group">
				<?php 
echo $this->scaffold->render('form.meta', compact('skip', 'readonly'));
?>
			</div>
		</div>
	</div>

	<div class="col-md-8">
		<h3><?php 
echo $this->scaffold->human;
开发者ID:bruensicke,项目名称:radium,代码行数:31,代码来源:form.tabs.html.php

示例12: testDefaultCookieName

 public function testDefaultCookieName()
 {
     $cookie = new Cookie();
     $expected = Inflector::slug(basename(LITHIUM_APP_PATH)) . 'cookie';
     $this->assertEqual($expected, $cookie->key());
 }
开发者ID:davidpersson,项目名称:FrameworkBenchmarks,代码行数:6,代码来源:CookieTest.php

示例13: _renderCommands

 /**
  * Output the formatted available commands.
  *
  * @return void
  */
 protected function _renderCommands()
 {
     $commands = Libraries::locate('command', null, array('recursive' => false));
     foreach ($commands as $key => $command) {
         $library = strtok($command, '\\');
         if (!$key || strtok($commands[$key - 1], '\\') != $library) {
             $this->out("{:heading}COMMANDS{:end} {:blue}via {$library}{:end}");
         }
         $info = Inspector::info($command);
         $name = strtolower(Inflector::slug($info['shortName']));
         $this->out($this->_pad($name), 'heading');
         $this->out($this->_pad($info['description']), 2);
     }
     $message = 'See `{:command}li3 help COMMAND{:end}`';
     $message .= ' for more information on a specific command.';
     $this->out($message, 2);
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:22,代码来源:Help.php

示例14: getPlaceUrl

 public function getPlaceUrl()
 {
     return ROOT_URL . \strtolower(Inflector::slug($this->getAddress()->getCity()->getState())) . '/' . \strtolower(Inflector::slug($this->getAddress()->getCity()->getName())) . '/' . \strtolower(Inflector::slug($this->getCategory())) . '/' . \strtolower(Inflector::slug($this->getName())) . '/' . $this->getId() . '.html';
 }
开发者ID:EHER,项目名称:chegamos,代码行数:4,代码来源:Place.php

示例15: __construct

 public function __construct(array $config = array())
 {
     $self =& $this;
     $defaults = array('base' => array(), 'text' => array(), 'textarea' => array(), 'select' => array('multiple' => false), 'attributes' => array('id' => function ($method, $name, $options) use(&$self) {
         if (in_array($method, array('create', 'end', 'label', 'error'))) {
             return;
         }
         if (!$name || $method === 'hidden' && $name === '_method') {
             return;
         }
         $info = $self->binding($name);
         $model = $info->class;
         $id = Inflector::camelize(Inflector::slug($info->name));
         return $model ? basename(str_replace('\\', '/', $model)) . $id : $id;
     }, 'name' => function ($method, $name, $options) {
         if (!strpos($name, '.')) {
             return $name;
         }
         $name = explode('.', $name);
         $first = array_shift($name);
         return $first . '[' . join('][', $name) . ']';
     }), 'binding' => function ($object, $name = null) {
         $result = compact('name') + array('data' => null, 'errors' => null, 'class' => null);
         if (is_object($object)) {
             $result = compact('name') + array('data' => $object->data($name), 'errors' => $object->errors($name), 'class' => $object->model());
         }
         return (object) $result;
     });
     parent::__construct(Set::merge($defaults, $config));
 }
开发者ID:davidpersson,项目名称:FrameworkBenchmarks,代码行数:30,代码来源:Form.php


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