本文整理匯總了PHP中dmString::slugify方法的典型用法代碼示例。如果您正苦於以下問題:PHP dmString::slugify方法的具體用法?PHP dmString::slugify怎麽用?PHP dmString::slugify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dmString
的用法示例。
在下文中一共展示了dmString::slugify方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getDmConfiguration
public static function getDmConfiguration()
{
$moduleManager = dmContext::getInstance()->getModuleManager();
// homepage first
$config = array('homepage' => array('class' => 'sfRoute', 'url' => '/', 'params' => array('module' => 'dmAdmin', 'action' => 'index')));
// media library special route
if ($dmMediaLibraryModule = $moduleManager->getModuleOrNull('dmMediaLibrary')) {
$baseUrl = implode('/', array(dmString::slugify($dmMediaLibraryModule->getSpace()->getType()->getPublicName()), dmString::slugify($dmMediaLibraryModule->getSpace()->getPublicName()), dmString::slugify($dmMediaLibraryModule->getPlural())));
$config['dm_media_library_path'] = array('class' => 'sfRoute', 'url' => $baseUrl . '/path/:path', 'params' => array('module' => 'dmMediaLibrary', 'action' => 'path', 'path' => ''), 'requirements' => array('path' => '.*'));
}
// module routes
foreach ($moduleManager->getModules() as $module) {
if (!$module->hasAdmin()) {
continue;
}
$baseUrl = implode('/', array(dmString::slugify($module->getSpace()->getType()->getPublicName()), dmString::slugify($module->getSpace()->getPublicName()), dmString::slugify($module->getPlural())));
$config[$module->getUnderscore()] = array('class' => 'sfRoute', 'url' => $baseUrl . '/:action/*', 'params' => array('module' => $module->getSfName(), 'action' => 'index'));
}
// static routes
$config['default'] = array('class' => 'sfRoute', 'url' => '/+/:module/:action/*');
$config['signin'] = array('class' => 'sfRoute', 'url' => '/security/signin', 'params' => array('module' => 'dmUserAdmin', 'action' => 'signin'));
$config['signout'] = array('class' => 'sfRoute', 'url' => '/security/signout', 'params' => array('module' => 'dmUserAdmin', 'action' => 'signout'));
$config['dm_module_type'] = array('class' => 'sfRoute', 'url' => '/:moduleTypeName', 'params' => array('module' => 'dmAdmin', 'action' => 'moduleType'));
$config['dm_module_space'] = array('class' => 'sfRoute', 'url' => '/:moduleTypeName/:moduleSpaceName', 'params' => array('module' => 'dmAdmin', 'action' => 'moduleSpace'));
return $config;
}
示例2: filterViewVars
protected function filterViewVars(array $vars = array())
{
$vars = parent::filterViewVars($vars);
$menuClass = dmArray::get($vars, 'menuClass');
$vars['menu'] = $this->getService('menu', $menuClass ? $menuClass : null)
->ulClass($vars['ulClass']);
foreach($vars['items'] as $index => $item)
{
$menuItem = $vars['menu']
->addChild($index.'-'.dmString::slugify($item['text']), $item['link'])
->label($item['text'])
->secure(!empty($item['secure']))
->liClass($vars['liClass'])
->addRecursiveChildren(dmArray::get($item, 'depth', 0));
if(!empty($item['nofollow']) && $menuItem->getLink())
{
$menuItem->getLink()->set('rel', 'nofollow');
}
}
unset($vars['items'], $vars['ulClass'], $vars['liClass']);
return $vars;
}
示例3: loadTemplate
protected function loadTemplate(DmMailTemplate $template, array $vars)
{
$culture = $this->serviceContainer->getService('user')->getCulture();
$fileName = dmOs::join(sfConfig::get('sf_cache_dir'), 'mail_templates', sprintf('%s-%s-%s.php', dmString::slugify($template->get('name')), $culture, dmString::slugify($template->get('updated_at'))));
if (!file_exists($fileName)) {
$this->buildTemplate($template, $fileName, $vars);
}
return $fileName;
}
示例4: getModuleTypeBySlug
protected function getModuleTypeBySlug($slug)
{
foreach ($this->context->getModuleManager()->getTypes() as $type) {
if (dmString::slugify($type->getPublicName()) == $slug) {
return $type;
}
}
return null;
}
示例5: configureFromData
protected function configureFromData($data)
{
if (!$this->getOption('file_name')) {
$this->setOption('file_name', dmString::slugify(dmConfig::get('site_name')) . '-' . dmString::random(8));
}
if (!$this->getOption('file_size')) {
$this->setOption('file_size', strlen($data));
}
}
示例6: checkSlug
public function checkSlug($validator, $values)
{
if (!empty($values['slug'])) {
$values['slug'] = dmString::slugify($values['slug'], true);
$existingPageName = dmDb::query('DmPageTranslation t')->where('t.lang = ? AND t.slug = ?', array($this->object->lang, $values['slug']))->select('t.name')->fetchValue();
if ($existingPageName) {
$error = new sfValidatorError($validator, dm::getI18n()->__('The page "%1%" uses this slug', array('%1%' => $existingPageName)));
// throw an error bound to the password field
throw new sfValidatorErrorSchema($validator, array('slug' => $error));
}
}
return $values;
}
示例7: checkModuleAction
public function checkModuleAction($validator, $values)
{
if (!empty($values['module']) && !empty($values['action'])) {
foreach (array('module', 'action') as $key) {
$values[$key] = dmString::modulize(str_replace('-', '_', dmString::slugify(dmString::underscore($values[$key]))));
}
$existingPage = dmDb::query('DmPage p')->where('p.module = ? AND p.action = ? and p.record_id = ? AND p.id != ?', array($values['module'], $values['action'], $this->object->record_id, $this->object->id))->fetchRecord();
if ($existingPage) {
$error = new sfValidatorError($validator, $this->getI18n()->__('The page "%1%" uses this module.action', array('%1%' => $existingPage->name)));
// throw an error bound to the password field
throw new sfValidatorErrorSchema($validator, array('action' => $error));
}
}
return $values;
}
示例8: _doHeaders_callback_atx
public function _doHeaders_callback_atx($matches)
{
$level = strlen($matches[1]);
$attr = $this->_doHeaders_attr($id =& $matches[3]);
$text = $this->runSpanGamut($matches[2]);
if ($this->options['auto_header_id'] && false === strpos($attr, 'id="')) {
$id = '';
if (1 !== $level && !empty($this->headerIdStack[$level - 1])) {
$id = $this->headerIdStack[$level - 1] . ':';
}
$id .= dmString::slugify($text);
if (!empty($id)) {
$attr = ' id="' . $id . '"';
if ($level < 6) {
$this->headerIdStack[$level] = $id;
}
}
}
$block = "<h{$level}{$attr}>" . $text . "</h{$level}>";
return "\n" . $this->hashBlock($block) . "\n\n";
}
示例9: execute
public function execute($configFiles)
{
$config = array();
$behaviors = array();
foreach ($configFiles as $file) {
$tmp = $this->parseYaml($file);
if (!isset($tmp['dmBehaviors'])) {
continue;
}
foreach ($tmp['dmBehaviors'] as $key => $value) {
$sectionKey = dmString::slugify($value['section']);
if (!isset($config[$sectionKey])) {
$config[$sectionKey] = array('section_name' => $value['section'], 'behaviors' => array());
}
$config[$sectionKey]['behaviors'][$key] = array('name' => isset($value['name']) ? $value['name'] : dmString::humanize($key), 'icon' => isset($value['icon']) ? $value['icon'] : '/dmCorePlugin/images/16/gear.png', 'form' => isset($value['form']) ? $value['form'] : 'dm' . dmString::camelize($key) . 'BehaviorForm', 'view' => isset($value['view']) ? $value['view'] : 'dm' . dmString::camelize($key) . 'BehaviorView', 'cache' => isset($value['cache']) ? (bool) $value['cache'] : true);
$behaviors[$key] = $config[$sectionKey]['behaviors'][$key];
}
}
$retval = sprintf("<?php\n" . "// auto-generated by %s\n" . "// date: %s\nsfConfig::set('dm_behaviors_menu_items', \n%s\n);\n sfConfig::set('dm_behaviors', \n%s\n); \n ?>", __CLASS__, date('Y/m/d H:i:s'), var_export($config, true), var_export($behaviors, true));
return $retval;
}
示例10: doUpdateObject
protected function doUpdateObject($values)
{
$parent = dmDb::table('DmPage')->find($values['parent_id']);
if (!$parent instanceof DmPage) {
throw new dmException('Create page with unknown parent ' . $values['parent_id']);
}
parent::doUpdateObject($values);
$this->object->module = $parent->module;
$action = dmString::modulize(str_replace('-', '_', dmString::slugify($values['name'])));
if (dmDb::query('DmPage p')->where('p.module = ? AND p.action = ?', array($this->object->module, $action))->exists()) {
$iterator = 2;
while (dmDb::query('DmPage p')->where('p.module = ? AND p.action = ?', array($this->object->module, $action . $iterator))->exists()) {
$iterator++;
}
$action .= $iterator;
}
$this->object->action = $action;
$this->object->title = $this->object->name;
$this->object->Node->insertAsLastChildOf($parent);
$this->object->PageView->Layout = dmDb::table('DmLayout')->find($values['dm_layout_id']);
$this->object->PageView->save();
$this->object->save();
}
示例11: compilePatterns
public function compilePatterns(array $patterns, array $replacements, $parentSlug)
{
$values = array();
foreach ($patterns as $field => $pattern) {
if ($field === 'slug') {
$slugReplacements = array();
foreach ($replacements as $key => $replacement) {
$slugReplacements[$key] = dmString::slugify($replacement);
}
$value = strtr($pattern, $slugReplacements);
// add parent slug
if ($pattern[0] !== '/') {
$value = $parentSlug . '/' . $value;
}
$value = trim($value, '/');
if (false !== strpos($value, '//')) {
$value = preg_replace('|(/{2,})|', '/', $value);
}
} elseif ($field === 'title') {
$value = ucfirst(strtr($pattern, $replacements));
} else {
$value = strtr($pattern, $replacements);
$value = strip_tags($value);
}
$values[$field] = $this->truncateValueForField(trim($value), $field);
}
return $values;
}
示例12: renderLiOpenTag
protected function renderLiOpenTag()
{
$classes = array();
$id = $this->getOption('show_id') ? dmString::slugify($this->getRoot()->getName() . '-' . $this->getName()) : null;
$link = $this->getLink();
if ($this->isFirst()) {
$classes[] = 'first';
}
if ($this->isLast()) {
$classes[] = 'last';
}
if ($this->getOption('li_class')) {
$classes[] = $this->getOption('li_class');
}
if ($link && $link->isCurrent()) {
$classes[] = $link->getOption('current_class');
} elseif ($link && $link->isParent()) {
$classes[] = $link->getOption('parent_class');
}
return '<li' . ($id ? ' id="' . $id . '"' : '') . (!empty($classes) ? ' class="' . implode(' ', $classes) . '"' : '') . '>';
}
示例13: dirname
<?php
require_once dirname(__FILE__) . '/helper/dmUnitTestHelper.php';
$helper = new dmUnitTestHelper();
$helper->boot();
$t = new lime_test(53);
$t->comment('iconv available : ' . function_exists('iconv'));
$t->is(dmString::slugify(" phrâse avèc dés accënts "), $expected = "phrase-avec-des-accents", $expected);
$t->is(dmString::slugify("fonctionnalité"), $expected = "fonctionnalite", $expected);
$hexTests = array(array('ffffff', 'FFFFFF'), array('#ffffff', 'FFFFFF'), array('#0Cd4fe', '0CD4FE'), array('aaa', null), array('fffff', null), array('fffxff', null));
foreach ($hexTests as $hexTest) {
$t->is(dmString::hexColor($hexTest[0]), $hexTest[1], 'dmString::hexColor(' . $hexTest[0] . ') = ' . (null === $hexTest[1] ? 'NULL' : $hexTest[1]));
}
$t->is(dmString::lcfirst('TEST'), 'tEST', 'lcfirst test');
$t->is(dmString::lcfirst('another test'), 'another test', 'lcfirst test');
// ::retrieveOptFromString()
$t->diag('::retrieveOptFromString()');
// Empty string
$t->diag(' ::retrieveOptFromString() empty string');
$string = '';
$opt = array('aa' => 'bb');
$originalOpt = $opt;
$t->is_deeply(dmString::retrieveOptFromString($string, $opt), null, '::retrieveOptFromString() with an empty string returns null');
$t->is_deeply($opt, $originalOpt, '::retrieveOptFromString() with an empty string does not modify opt');
$t->is_deeply($string, '', '::retrieveOptFromString() with an empty string does not modify string');
// Non-empty string
$t->diag(' ::retrieveOptFromString() non-empty string');
$string = 'x=y';
$opt = array('aa' => 'bb');
dmString::retrieveOptFromString($string, $opt);
$t->is_deeply($opt, array('aa' => 'bb', 'x' => 'y'), '::retrieveOptFromString() merges the options');
示例14: create
/**
* Physically creates asset
*
* @param string $asset_path path to the asset original file
* @param bool $move do move or just copy ?
*/
public function create(sfValidatedFile $file)
{
$this->file = $this->getAvailableFileName(dmString::slugify(dmOs::getFileWithoutExtension($file->getOriginalName())) . dmOs::getFileExtension($file->getOriginalName(), true));
$this->clearCache();
$file->save($this->getFullPath());
$this->refreshFromFile();
return $this;
}
示例15: catch
$helper->updatePageTreeWatcher($t);
} catch (Exception $e) {
$t->skip('Not supported on this server: ' . $e->getMessage(), $nbTests);
return;
}
$t->ok(true, sprintf('Seo updated in %01.2f s', $timer->getElapsedTime()));
foreach (dmDb::table('dmTestPost')->findAll() as $post) {
if (!($page = $post->getDmPage())) {
$t->skip('Post ' . $post . ' has no page', 6);
continue;
}
$page->refresh(true);
$categ = $page->getNode()->getParent()->getRecord();
$domain = $page->getNode()->getParent()->getNode()->getParent()->getRecord();
$t->is($post->isActive, $page->isActive, 'is_active field synchronized to ' . ($post->isActive ? 'TRUE' : 'FALSE'));
$slug = 'dm-test-domains/' . $domain->id . '-' . dmString::slugify($domain->title) . '/' . $categ->id . '-' . dmString::slugify($categ->name) . '/' . dmString::slugify($post->title) . '-' . $post->id;
$slug = dmSeoSynchronizer::truncateValueForField($slug, 'slug');
$t->is($page->slug, $slug, 'slug : ' . $slug);
$name = 'Post : ' . trim($post->title);
$name = dmSeoSynchronizer::truncateValueForField($name, 'name');
$t->is($page->name, $name, 'name : ' . $name);
$title = ucfirst(trim($post->title) . ' | ' . trim($categ->name));
$title = dmSeoSynchronizer::truncateValueForField($title, 'title');
$t->is($page->title, $title, 'title : ' . $title);
$h1 = trim($post->title);
$h1 = dmSeoSynchronizer::truncateValueForField($h1, 'h1');
$t->is($page->h1, $h1, 'h1 : ' . $h1);
$description = dmSeoSynchronizer::truncateValueForField(dmMarkdown::brutalToText($post->body), 'description');
$t->is($page->description, $description ? $description : null, 'description : ' . $description);
}
$t->comment('Add inactive domain');