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


PHP Doctrine_Inflector::urlize方法代碼示例

本文整理匯總了PHP中Doctrine_Inflector::urlize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Doctrine_Inflector::urlize方法的具體用法?PHP Doctrine_Inflector::urlize怎麽用?PHP Doctrine_Inflector::urlize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine_Inflector的用法示例。


在下文中一共展示了Doctrine_Inflector::urlize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: doctrine_urlize

 /**
  * Convert any passed string to a url friendly string. Converts 'My first blog post' to 'my-first-blog-post'
  *
  * @param  string $text  Text to urlize
  * @return string $text  Urlized text
  */
 public static function doctrine_urlize($text)
 {
     // Transliteration
     $text = self::transliterate($text);
     // Urlize
     return Doctrine_Inflector::urlize($text);
 }
開發者ID:everzet,項目名稱:sfDoctrineObjectGuardPlugin,代碼行數:13,代碼來源:sfObjectGuardTranslit.class.php

示例2: executeAddDocument

 public function executeAddDocument(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod(sfRequest::PUT));
     $document = $request->getParameter('document');
     $this->transaction = TransactionTable::getInstance()->find($document['transaction_id']);
     $asso = AssoTable::getInstance()->find($document['asso_id']);
     $this->checkAuthorisation($asso);
     $form = new DocumentForm();
     $files = $request->getFiles($form->getName());
     $form->bind($request->getParameter($form->getName()), $files);
     $infos = new finfo(FILEINFO_MIME_TYPE);
     if ($form->isValid() and $infos->file($files['fichier']['tmp_name']) == 'application/pdf') {
         $fichier = $this->transaction->getPrimaryKey() . '-' . date('Y-m-d-H-i-s') . '-' . Doctrine_Inflector::urlize($files['fichier']['name']);
         if (substr($fichier, -4) == '-pdf') {
             $fichier = substr($fichier, 0, -4);
         }
         $fichier .= '.pdf';
         $form->setValue('fichier', $fichier);
         $form->setValue('auteur', $this->getUser()->getGuardUser()->getPrimaryKey());
         $doc = $form->save();
         $path = $doc->getPath();
         $dir = substr($path, 0, -strlen($fichier));
         if (!is_dir($dir)) {
             mkdir($dir);
         }
         move_uploaded_file($files['fichier']['tmp_name'], $path);
         $this->redirect('transaction_show', $this->transaction);
     } else {
         $this->form = $form;
         $this->setTemplate('show', $this->transaction);
         $this->getResponse()->setSlot('current_asso', $asso);
     }
 }
開發者ID:TheoJD,項目名稱:portail,代碼行數:33,代碼來源:actions.class.php

示例3: sortString

 public static function sortString($a, $b)
 {
     if ($a[0] == $b[0]) {
         return 0;
     }
     return Doctrine_Inflector::urlize($a[0]) < Doctrine_Inflector::urlize($b[0]) ? -1 : 1;
 }
開發者ID:kidh0,項目名稱:swbrasil,代碼行數:7,代碼來源:components.class.php

示例4: postUp

 public function postUp()
 {
     $records = Projects_Model_ProjectTable::getInstance()->findAll();
     foreach ($records as $record) {
         if (empty($record->name_slug)) {
             $record->name_slug = Doctrine_Inflector::urlize($record->name);
             $record->save();
         }
     }
 }
開發者ID:KasaiDot,項目名稱:FansubCMS,代碼行數:10,代碼來源:1303408421_version4.php

示例5: testGermanCharactersAreConvertedCorrectly

 public function testGermanCharactersAreConvertedCorrectly()
 {
     $this->assertEqual(Doctrine_Inflector::urlize('Ästhetik'), 'aesthetik');
     $this->assertEqual(Doctrine_Inflector::urlize('ästhetisch'), 'aesthetisch');
     $this->assertEqual(Doctrine_Inflector::urlize('Übung'), 'uebung');
     $this->assertEqual(Doctrine_Inflector::urlize('über'), 'ueber');
     $this->assertEqual(Doctrine_Inflector::urlize('Öl'), 'oel');
     $this->assertEqual(Doctrine_Inflector::urlize('ölig'), 'oelig');
     $this->assertEqual(Doctrine_Inflector::urlize('Fuß'), 'fuss');
 }
開發者ID:kaakshay,項目名稱:audience-insight-repository,代碼行數:10,代碼來源:2160TestCase.php

示例6: postUp

 public function postUp()
 {
     $table = Doctrine::getTable('News_Model_News');
     $records = $table->findAll();
     foreach ($records as $record) {
         if (empty($record->title_slug)) {
             $record->title_slug = Doctrine_Inflector::urlize($record->title);
             $record->save();
         }
     }
 }
開發者ID:KasaiDot,項目名稱:FansubCMS,代碼行數:11,代碼來源:1298899838_version2.php

示例7: generateFilename

 /**
  * Generates a non-random-filename
  *
  * @return string A non-random name to represent the current file
  */
 public function generateFilename()
 {
     $filename = $this->getOriginalName();
     $ext = filter_var($this->getExtension($this->getOriginalExtension()), FILTER_SANITIZE_URL);
     $name = substr($this->getOriginalName(), 0, -strlen($ext));
     $i = 1;
     while (file_exists($this->getPath() . '/' . $filename)) {
         $filename = Doctrine_Inflector::urlize($name) . '-' . $i . $ext;
         $i++;
     }
     return $filename;
 }
開發者ID:ndachez,項目名稱:dachez,代碼行數:17,代碼來源:peanutValidatedFile.class.php

示例8: buildSlug

 protected function buildSlug($record)
 {
     if (empty($this->_options['fields'])) {
         $value = (string) $record;
     } else {
         $value = '';
         foreach ($this->_options['fields'] as $field) {
             $value = $record->{$field} . ' ';
         }
     }
     return Doctrine_Inflector::urlize($value);
 }
開發者ID:kirvin,項目名稱:the-nerdery,代碼行數:12,代碼來源:Sluggable.php

示例9: executeExport

 public function executeExport(sfWebRequest $request)
 {
     $budget = $this->getRoute()->getObject();
     $asso = $budget->getAsso();
     $this->checkAuthorisation($budget->getAsso());
     $categories = $budget->getCategoriesWithEntry()->execute();
     $nom = $budget->getPrimaryKey() . '-' . date('Y-m-d-H-i-s') . '-' . Doctrine_Inflector::urlize($budget->getNom());
     $html = $this->getPartial('budget/pdf', compact(array('categories', 'asso', 'budget', 'transactions')));
     $doc = new Document();
     $doc->setNom('Export du budget prévisionnel');
     $doc->setAsso($asso);
     $doc->setUser($this->getUser()->getGuardUser());
     $doc->setTypeFromSlug('budgets');
     $path = $doc->generatePDF('Budget Prévisionnel', $nom, $html);
     header('Content-type: application/pdf');
     readfile($path);
     return sfView::NONE;
 }
開發者ID:TheoJD,項目名稱:portail,代碼行數:18,代碼來源:actions.class.php

示例10: beforeSave

 public function beforeSave($event)
 {
     if (true !== $this->update && $this->owner->slug) {
         return parent::beforeSave($event);
     }
     if (!is_array($this->columns)) {
         throw new CException('Columns have to be in array format.');
     }
     $availableColumns = array_keys($this->owner->tableSchema->columns);
     // Try to guess the right columns
     if (0 === count($this->columns)) {
         $this->columns = array_intersect($this->_defaultColumnsToCheck, $availableColumns);
     } else {
         // Unknown columns on board?
         foreach ($this->columns as $col) {
             if (!in_array($col, $availableColumns)) {
                 throw new CException('Unable to build slug, column ' . $col . ' not found.');
             }
         }
     }
     // No columns to build a slug?
     if (0 === count($this->columns)) {
         throw new CException('You must define "columns" to your sluggable behavior.');
     }
     // Fetch values
     $values = array();
     foreach ($this->columns as $col) {
         $values[] = $this->owner->{$col};
     }
     // First version of slug
     $slug = $checkslug = Doctrine_Inflector::urlize(implode('-', $values));
     // Check if slug has to be unique
     if (false === $this->unique) {
         $this->owner->slug = $slug;
     } else {
         $counter = 0;
         while ($this->owner->findByAttributes(array('slug' => $checkslug))) {
             $checkslug = sprintf('%s-%d', $slug, ++$counter);
         }
         $this->owner->slug = $counter > 0 ? $checkslug : $slug;
     }
     return parent::beforeSave($event);
 }
開發者ID:nassimrehali,項目名稱:yiisite,代碼行數:43,代碼來源:SluggableBehavior.php

示例11: _deleteRelatedData

 private function _deleteRelatedData()
 {
     if (!$this->_contentTypeName) {
         return;
     }
     $this->logSection('sympal', sprintf('...deleting data related to Sympal plugin ContentType "%s"', $this->_contentTypeName), null, 'COMMENT');
     $lowerName = str_replace('-', '_', Doctrine_Inflector::urlize($this->_contentTypeName));
     $slug = 'sample-' . $lowerName;
     $contentType = Doctrine_Core::getTable('sfSympalContentType')->findOneByName($this->_contentTypeName);
     // Find content lists related to this conten type
     $q = Doctrine_Core::getTable('sfSympalContentList')->createQuery('c')->select('c.id, c.content_id')->from('sfSympalContentList c INDEXBY c.content_id')->where('c.content_type_id = ?', $contentType['id']);
     $contentTypes = $q->fetchArray();
     $contentIds = array_keys($contentTypes);
     // Delete content records related to this content type
     Doctrine_Core::getTable('sfSympalContent')->createQuery('c')->delete()->where('c.content_type_id = ?', $contentType['id'])->orWhereIn('c.id', $contentIds)->execute();
     // Delete menu items related to this content type
     Doctrine_Core::getTable('sfSympalMenuItem')->createQuery('m')->delete()->where('m.name = ?', array($this->_contentTypeName))->execute();
     // Delete the content type record
     Doctrine_Core::getTable('sfSympalContentType')->createQuery('t')->delete()->where('t.id = ?', $contentType['id'])->execute();
 }
開發者ID:sympal,項目名稱:sympal,代碼行數:20,代碼來源:sfSympalPluginManagerUninstall.class.php

示例12: executeJustificatif

 public function executeJustificatif(sfWebRequest $request)
 {
     $note_de_frais = $this->getRoute()->getObject();
     $user = $this->getUser();
     $asso = $note_de_frais->getAsso();
     $this->checkAuthorisation($asso);
     $html = $this->getPartial('noteDeFrais/pdf', compact(array('note_de_frais', 'asso', 'user')));
     $nom = $note_de_frais->getPrimaryKey() . '-' . date('Y-m-d-H-i-s') . '-' . Doctrine_Inflector::urlize($note_de_frais->getNom());
     $doc = new Document();
     $doc->setNom('Attestation à signer');
     $doc->setAsso($asso);
     $doc->setUser($this->getUser()->getGuardUser());
     $doc->transaction_id = $note_de_frais->transaction_id;
     $doc->setTypeFromSlug('note_de_frais');
     $path = $doc->generatePDF('Note de frais', $nom, $html);
     $doc->save();
     header('Content-type: application/pdf');
     readfile($path);
     return sfView::NONE;
 }
開發者ID:TheoJD,項目名稱:portail,代碼行數:20,代碼來源:actions.class.php

示例13: _createDefaultContentTypeRecords

 protected function _createDefaultContentTypeRecords(&$installVars)
 {
     $this->logSection('sympal', '...creating default Sympal ContentType records', null, 'COMMENT');
     $lowerName = str_replace('-', '_', Doctrine_Inflector::urlize(str_replace('sfSympal', null, $this->_contentTypeName)));
     $slug = 'sample_' . $lowerName;
     $properties = array();
     $contentType = $this->newContentType($this->_contentTypeName, $properties);
     $installVars['contentType'] = $contentType;
     $properties = array('slug' => $slug);
     $content = $this->newContent($contentType, $properties);
     $installVars['content'] = $content;
     $properties = array('slug' => $lowerName, 'ContentType' => Doctrine_Core::getTable('sfSympalContentType')->findOneByName('ContentList'));
     $contentList = $this->newContent('sfSympalContentList', $properties);
     $contentList->trySettingTitleProperty('Sample ' . $contentType['label'] . ' List');
     $contentList->getRecord()->setContentType($contentType);
     $installVars['contentList'] = $contentList;
     $properties = array('date_published' => new Doctrine_Expression('NOW()'), 'label' => str_replace('sfSympal', null, $this->_contentTypeName), 'RelatedContent' => $contentList);
     $menuItem = $this->newMenuItem($this->_contentTypeName, $properties);
     $installVars['menuItem'] = $menuItem;
     $properties = array('body' => '<?php echo get_sympal_breadcrumbs($menuItem, $content) ?><h2><?php echo get_sympal_content_slot($content, \'title\') ?></h2><p><strong>Posted by <?php echo $content->CreatedBy->username ?> on <?php echo get_sympal_content_slot($content, \'date_published\') ?></strong></p><p><?php echo get_sympal_content_slot($content, \'body\') ?></p>');
 }
開發者ID:sympal,項目名稱:sympal,代碼行數:21,代碼來源:sfSympalPluginManagerInstall.class.php

示例14: urlize

 /**
  * Clean for usage in URLs
  *
  * @param $string
  * @return string
  */
 private function urlize($string)
 {
     return Doctrine_Inflector::urlize($string);
 }
開發者ID:pierswarmers,項目名稱:rtCorePlugin,代碼行數:10,代碼來源:rtViewToolkit.php

示例15: beforeSave

 /**
  * beforeSave
  *
  * @param CModelEvent $event
  *
  * @throws CException
  * @access public
  */
 public function beforeSave($event)
 {
     // Slug already created and no updated needed
     if (true !== $this->update && !empty($this->getOwner()->{$this->slugColumn})) {
         Yii::trace('Slug found - no update needed.', __CLASS__ . '::' . __FUNCTION__);
         return parent::beforeSave($event);
     }
     $availableColumns = array_keys($this->getOwner()->tableSchema->columns);
     // Try to guess the right columns
     if (0 === count($this->columns)) {
         $this->columns = array_intersect($this->_defaultColumnsToCheck, $availableColumns);
     } else {
         // Unknown columns on board?
         foreach ($this->columns as $col) {
             if (!in_array($col, $availableColumns)) {
                 if (false !== strpos($col, '.')) {
                     Yii::trace('Dependencies to related models found', __CLASS__);
                     list($model, $attribute) = explode('.', $col);
                     $externalColumns = array_keys($this->getOwner()->{$model}->tableSchema->columns);
                     if (!in_array($attribute, $externalColumns)) {
                         throw new CException("Model {$model} does not haz {$attribute}");
                     }
                 } else {
                     throw new CException('Unable to build slug, column ' . $col . ' not found.');
                 }
             }
         }
     }
     // No columns to build a slug?
     if (0 === count($this->columns)) {
         throw new CException('You must define "columns" to your sluggable behavior.');
     }
     // Fetch values
     $values = array();
     foreach ($this->columns as $col) {
         if (false === strpos($col, '.')) {
             $values[] = $this->getOwner()->{$col};
         } else {
             list($model, $attribute) = explode('.', $col);
             $values[] = $this->getOwner()->{$model}->{$attribute};
         }
     }
     // First version of slug
     if (true === $this->useInflector) {
         $slug = $checkslug = Doctrine_Inflector::urlize(implode('-', $values));
     } else {
         $slug = $checkslug = $this->simpleSlug(implode('-', $values));
     }
     // Check if slug has to be unique
     if (false === $this->unique || !$this->getOwner()->getIsNewRecord() && $slug === $this->getOwner()->{$this->slugColumn}) {
         Yii::trace('Non unique slug or slug already set', __CLASS__);
         $this->getOwner()->{$this->slugColumn} = $slug;
     } else {
         $counter = 0;
         while ($this->getOwner()->resetScope()->exists($this->slugColumn . '=:sluggable', array(':sluggable' => $checkslug))) {
             Yii::trace("{$checkslug} found, iterating", __CLASS__);
             $checkslug = sprintf('%s-%d', $slug, ++$counter);
         }
         $this->getOwner()->{$this->slugColumn} = $counter > 0 ? $checkslug : $slug;
     }
     return parent::beforeSave($event);
 }
開發者ID:mintao,項目名稱:yii-behavior-sluggable,代碼行數:70,代碼來源:SluggableBehavior.php


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