當前位置: 首頁>>代碼示例>>PHP>>正文


PHP dmString::slugify方法代碼示例

本文整理匯總了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;
 }
開發者ID:jaimesuez,項目名稱:diem,代碼行數:26,代碼來源:dmAdminRoutingConfigHandler.php

示例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;
  }
開發者ID:Regmaya,項目名稱:diem,代碼行數:28,代碼來源:dmWidgetNavigationMenuView.php

示例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;
 }
開發者ID:runopencode,項目名稱:diem-extended,代碼行數:9,代碼來源:dmMailTemplateRenderer.php

示例4: getModuleTypeBySlug

 protected function getModuleTypeBySlug($slug)
 {
     foreach ($this->context->getModuleManager()->getTypes() as $type) {
         if (dmString::slugify($type->getPublicName()) == $slug) {
             return $type;
         }
     }
     return null;
 }
開發者ID:theolymp,項目名稱:diem,代碼行數:9,代碼來源:BasedmAdminActions.class.php

示例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));
     }
 }
開發者ID:theolymp,項目名稱:diem,代碼行數:9,代碼來源:dmDownloadResponse.php

示例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;
 }
開發者ID:jdart,項目名稱:diem,代碼行數:13,代碼來源:DmPageFrontNewForm.php

示例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;
 }
開發者ID:theolymp,項目名稱:diem,代碼行數:15,代碼來源:DmPageFrontEditForm.php

示例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";
 }
開發者ID:theolymp,項目名稱:diem,代碼行數:21,代碼來源:dmMarkdown.php

示例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;
 }
開發者ID:runopencode,項目名稱:diem-extended,代碼行數:21,代碼來源:dmBehaviorsConfigHandler.class.php

示例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();
 }
開發者ID:theolymp,項目名稱:diem,代碼行數:23,代碼來源:DmPageFrontNewForm.php

示例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;
 }
開發者ID:eXtreme,項目名稱:diem,代碼行數:28,代碼來源:dmSeoSynchronizer.php

示例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) . '"' : '') . '>';
 }
開發者ID:jdart,項目名稱:diem,代碼行數:21,代碼來源:dmMenu.php

示例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');
開發者ID:jdart,項目名稱:diem,代碼行數:31,代碼來源:dmStringTest.php

示例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;
 }
開發者ID:theolymp,項目名稱:diem,代碼行數:14,代碼來源:PluginDmMedia.class.php

示例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');
開發者ID:vjousse,項目名稱:diem,代碼行數:31,代碼來源:dmSeoSyncTest.php


注:本文中的dmString::slugify方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。