當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。