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


PHP Doctrine_Inflector类代码示例

本文整理汇总了PHP中Doctrine_Inflector的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Inflector类的具体用法?PHP Doctrine_Inflector怎么用?PHP Doctrine_Inflector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testClassifyTableize

 public function testClassifyTableize() {
     $name = "Forum_Category";
     $this->assertEqual(Doctrine_Inflector::tableize($name), "forum__category");
     $this->assertEqual(Doctrine_Inflector::classify(Doctrine_Inflector::tableize($name)), $name);
     
     
 }
开发者ID:prismhdd,项目名称:victorioussecret,代码行数:7,代码来源:ManagerTestCase.php

示例2: analyze

 public function analyze($text, $encoding = null)
 {
     static $stopwords;
     if (!isset($stopwords)) {
         $stopwords = array_flip(self::$_stopwords);
     }
     $text = preg_replace('/[\'`´"]/', '', $text);
     $text = Doctrine_Inflector::unaccent($text);
     $text = preg_replace('/[^A-Za-z0-9]/', ' ', $text);
     $text = str_replace('  ', ' ', $text);
     $terms = explode(' ', $text);
     $ret = array();
     if (!empty($terms)) {
         foreach ($terms as $i => $term) {
             if (empty($term)) {
                 continue;
             }
             $lower = strtolower(trim($term));
             if (isset($stopwords[$lower])) {
                 continue;
             }
             $ret[$i] = $lower;
         }
     }
     return $ret;
 }
开发者ID:sabaki-dev,项目名称:doctrine1,代码行数:26,代码来源:Standard.php

示例3: 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

示例4: slugify

 public static function slugify($text)
 {
     $text = Doctrine_Inflector::unaccent($text);
     // replace all non letters or digits by -
     $text = preg_replace('/\\W+/', '-', $text);
     // trim and lowercase
     $text = strtolower(trim($text, '-'));
     return $text;
     /**********************
     
         // Remove all non url friendly characters with the unaccent function
         $text = Doctrine_Inflector::unaccent($this->get('title'));
     
         if (function_exists('mb_strtolower')) {
           $text = mb_strtolower($text);
         } else {
           $text = strtolower($text);
         }
     
         // Remove all none word characters
         $text = preg_replace('/\W/', ' ', $text);
     
         // More stripping. Get rid of all non-alphanumeric.
         $text = strtolower(preg_replace('/[^A-Z^a-z^0-9^\/]+/', '', $text));
     
         return trim($text, '-');
     */
 }
开发者ID:Gula,项目名称:magic,代码行数:28,代码来源:magic.class.php

示例5: getPopularTagsQuery

 public function getPopularTagsQuery($relations = null, $limit = null, dmDoctrineQuery $q = null)
 {
     if (empty($relations)) {
         $this->loadTaggableModels();
         $relations = array_keys($this->getRelationHolder()->getAssociations());
         if (empty($relations)) {
             throw new dmException('There is no taggable model');
         }
     } else {
         $relations = (array) $relations;
     }
     $q = $q ? $q : $this->createQuery('t')->select('t.*');
     $rootAlias = $q->getRootAlias();
     $counts = array();
     foreach ($relations as $relation) {
         $countAlias = 'num_' . Doctrine_Inflector::tableize($relation);
         $q->leftJoin($rootAlias . '.' . $relation . ' ' . $relation);
         $q->addSelect('COUNT(DISTINCT ' . $relation . '.id) AS ' . $countAlias);
         $counts[] = 'COUNT(DISTINCT ' . $relation . '.id)';
     }
     $q->addSelect('(' . implode(' + ', $counts) . ') as total_num');
     //$q->orderBy('total_num DESC');
     $q->groupBy($rootAlias . '.id');
     $q->addHaving('total_num > 0');
     if (null !== $limit) {
         $q->limit($limit);
     }
     return $q;
 }
开发者ID:rafix,项目名称:bibliocnic,代码行数:29,代码来源:PluginDmTagTable.class.php

示例6: preSave

 /**
  * Throws an exception if the record is modified while it is 
  * locked. 
  * 
  * @param Doctrine_Event $event 
  * @return void
  */
 public function preSave(Doctrine_Event $event)
 {
     $modelName = Doctrine_Inflector::tableize(get_class($event->getInvoker()));
     $modifiedFields = $event->getInvoker()->getModified();
     $locked = $event->getInvoker()->isLocked;
     $lockModified = array_key_exists('isLocked', $modifiedFields);
     $numModified = count($modifiedFields);
     /**
      * Record fields haven't been modified, nothing to do here. 
      */
     if (!$event->getInvoker()->isModified()) {
         return;
     }
     /**
      * The record is not locked, and the lock isn't being changed, nothing to do here. 
      */
     if (!$locked && !$lockModified) {
         return;
     }
     /**
      * Only the lock is being modified so there's nothing to
      * do here. 
      */
     if ($lockModified && $numModified == 1) {
         return;
     }
     /**
      * The record is locked, throw an exception. 
      */
     if ($locked) {
         throw new Behavior_Lockable_Exception('The record must be unlocked before it can be modified.');
     }
 }
开发者ID:boydjd,项目名称:doctrine-addons,代码行数:40,代码来源:Listener.php

示例7: executeCreate

 /**
  * Display comment form incase of validation issues
  *  
  * @param sfWebRequest $request
  */
 public function executeCreate(sfWebRequest $request)
 {
     $this->rating_enabled = $request->hasParameter('rating_enabled') ? $request->getParameter('rating_enabled') : false;
     $form = $this->getForm($this->rating_enabled);
     if ($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT)) {
         $form->bind($request->getParameter($form->getName()));
         if ($form->isValid()) {
             if (sfConfig::get('app_rt_comment_moderation', false)) {
                 $form->save();
                 $this->notifyAdministrator($form->getObject());
             } else {
                 $form->getObject()->setIsActive(true);
                 $form->save();
                 $routes = $this->getContext()->getRouting()->getRoutes();
                 $route_name = Doctrine_Inflector::tableize($form->getObject()->getModel()) . '_show';
                 if (isset($routes[$route_name])) {
                     $target_object = $form->getObject()->getObject();
                     $cache_class = $form->getObject()->getModel() . 'CacheToolkit';
                     if (class_exists($cache_class)) {
                         call_user_func($cache_class . '::clearCache', $target_object);
                     }
                     $this->redirect($this->getContext()->getRouting()->generate($route_name, $target_object));
                 }
             }
             $this->redirect(sprintf('rtComment/saved?model=%s&model_id=%s', $form->getObject()->getModel(), $form->getObject()->getModelId()));
         } else {
             $this->getUser()->setFlash('default_error', true, false);
         }
     }
     $this->form = $form;
 }
开发者ID:pierswarmers,项目名称:rtCorePlugin,代码行数:36,代码来源:BasertCommentActions.class.php

示例8: executeAjaxSearch

 public function executeAjaxSearch(sfWebRequest $request)
 {
     if ($request->hasParameter('models')) {
         $query = Doctrine::getTable('rtIndex')->getStandardSearchComponentInQuery($request->getParameter('q', ''), $this->getUser()->getCulture(), Doctrine::getTable('rtIndex')->getModelTypeRestrictionQuery(explode(',', $request->getParameter('models'))));
     } else {
         $query = Doctrine::getTable('rtIndex')->getBasePublicSearchQuery($request->getParameter('q'), $this->getUser()->getCulture());
     }
     $this->logMessage('{testing}' . $request->getParameter('q', ''), 'notice');
     $query->limit(100);
     $rt_indexes = $query->execute();
     $routes = $this->getContext()->getRouting()->getRoutes();
     $items = array();
     foreach ($rt_indexes as $rt_index) {
         $route = Doctrine_Inflector::tableize($rt_index->getCleanModel()) . '_show';
         $url = '';
         if (isset($routes[Doctrine_Inflector::tableize($rt_index->getCleanModel()) . '_show'])) {
             $url = sfContext::getInstance()->getController()->genUrl(array('sf_route' => $route, 'sf_subject' => $rt_index->getObject()));
             $url = str_replace('/frontend_dev.php', '', $url);
         }
         $object = $rt_index->getObject();
         $item = array('title' => $object->getTitle(), 'link' => $url);
         $item['placeholder'] = $object instanceof rtSnippet ? '![' . $object->getTitle() . '](snippet:' . $object->getCollection() . ')' : '';
         $items[] = $item;
     }
     return $this->returnJSONResponse(array('status' => 'success', 'items' => $items), $request);
 }
开发者ID:pierswarmers,项目名称:rtCorePlugin,代码行数:26,代码来源:BasertSearchAdminActions.class.php

示例9: 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

示例10: getPopularTagsQueryTableProxy

 public function getPopularTagsQueryTableProxy($relations = null, $limit = 10, $hydrationMode = Doctrine::HYDRATE_RECORD)
 {
     if (!$relations) {
         $relations = array();
         $allRelations = $this->getInvoker()->getTable()->getRelations();
         foreach ($allRelations as $name => $relation) {
             if ($relation['refTable']) {
                 $relations[] = $name;
             }
         }
     }
     $relations = (array) $relations;
     $q = $this->getInvoker()->getTable()->createQuery('t')->select('t.*');
     $counts = array();
     foreach ($relations as $relation) {
         $countAlias = 'num_' . Doctrine_Inflector::tableize($relation);
         $q->leftJoin('t.' . $relation . ' ' . $relation);
         $q->addSelect('COUNT(DISTINCT ' . $relation . '.id) AS ' . $countAlias);
         $counts[] = 'COUNT(DISTINCT ' . $relation . '.id)';
     }
     $q->addSelect('(' . implode(' + ', $counts) . ') as total_num');
     $q->orderBy('total_num DESC');
     $q->groupBy('t.id');
     $q->addHaving('total_num > 0');
     $q->limit($limit);
     return $q;
 }
开发者ID:JoshuaEstes,项目名称:sfDoctrineExtraPlugin,代码行数:27,代码来源:TaggableTag.php

示例11: 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

示例12: set

 /**
  * Set a record attribute. Allows overriding Doctrine record accessors with Propel style functions
  *
  * @param string $name 
  * @param string $value 
  * @param string $load 
  * @return void
  */
 public function set($name, $value, $load = true)
 {
     $setter = 'set' . Doctrine_Inflector::classify($name);
     if (method_exists($this, $setter)) {
         return $this->{$setter}($value, $load);
     }
     return parent::set($name, $value, $load);
 }
开发者ID:amitesh-singh,项目名称:Enlightenment,代码行数:16,代码来源:sfDoctrineRecord.class.php

示例13: setQuery

 /**
  * @param  $_query
  * @return Kebab_Controller_Helper_Search
  */
 public function setQuery($_query)
 {
     $_query = strtolower(Doctrine_Inflector::unaccent($_query));
     if ($_query !== false && is_string($_query)) {
         $this->_query = '*' . $_query . '*';
     }
     return $this;
 }
开发者ID:esironal,项目名称:kebab-project,代码行数:12,代码来源:Search.php

示例14: setTableDefinition

 /**
  * Set table definition for contactable behavior
  * (borrowed from Sluggable in Doctrine core)
  *
  * @return void
  * @author Brent Shaffer
  */
 public function setTableDefinition()
 {
     foreach ($this->_options['fields'] as $field => $unit) {
         $name = Doctrine_Inflector::tableize($field . '_' . strtolower($unit));
         $this->_options['columns'][$field] = $name;
         $this->hasColumn($name, 'float');
     }
     $this->_table->unshiftFilter(new Doctrine_Record_Filter_Localizable($this->_options));
 }
开发者ID:JoshuaEstes,项目名称:sfDoctrineExtraPlugin,代码行数:16,代码来源:Localizable.php

示例15: 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


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