Changeset 18417
- Timestamp:
- 05/18/09 21:55:15 (4 years ago)
- Files:
-
- plugins/sfDoctrineActAsRattablePlugin/trunk (modified) (1 prop)
- plugins/sfDoctrineActAsRattablePlugin/trunk/README (modified) (6 diffs)
- plugins/sfDoctrineActAsRattablePlugin/trunk/lib/Rattable.class.php (added)
- plugins/sfDoctrineActAsRattablePlugin/trunk/lib/RattableListener.class.php (added)
- plugins/sfDoctrineActAsRattablePlugin/trunk/lib/RattableTemplate.class.php (modified) (1 diff)
- plugins/sfDoctrineActAsRattablePlugin/trunk/lib/task (deleted)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfDoctrineActAsRattablePlugin/trunk
- Property svn:ignore set to
nbproject
- Property svn:ignore set to
plugins/sfDoctrineActAsRattablePlugin/trunk/README
r18390 r18417 1 {{{2 #!WikiMarkdown3 4 1 # sfDoctrineActAsRattablePlugin # 5 2 … … 12 9 13 10 ### Features ### 14 * add remove ratings 11 12 * add/remove ratings 15 13 * manage multiple ratings 16 14 * get average rating 17 * get user rating (base on the object they are associated to)18 15 * get commented ratings 16 * be notified when an object is rated 19 17 20 18 ### How it works ### 21 19 22 Giving Rattable behavior to an object do quitethe same as [Doctrine I18n](http://www.doctrine-project.org/documentation/manual/1_1/en/behaviors#core-behaviors:i18n)20 Giving Rattable behavior to an object the same as [Doctrine I18n](http://www.doctrine-project.org/documentation/manual/1_1/en/behaviors#core-behaviors:i18n) 23 21 24 22 It create an object_rate table with how many column as criterias OR default one : rate 23 24 Example : 25 26 hotel_room: 27 actAs: 28 Rattable: 29 criterias: [clean_state, receptionist, equipment] 30 max_rate: 5 31 rounding_rate: 1 32 33 Will create 2 tables: 34 35 1 hotel_room 36 1 hotel_room_rate, with columns: 37 clean_state 38 reception 39 equipment 40 comment 41 user_id # foreignKey to sfGuardUser if exists 25 42 26 43 ## Installation ## … … 32 49 33 50 ./symfony plugin-install http://svn.symfony-project.com/plugins/sfDoctrineActAsRattblePlugin/branches/1.2 34 35 * edit your schema.yml and add36 37 actAs: [Rattable] to model you want to be rattable38 39 * rebuild the model:40 41 ./symfony doctrine-build-all42 43 * clear cache:44 45 ./symfony cc46 51 47 52 ### SVN way ### 48 53 49 * go to your plugin directory: 54 * from the terminal, go to your plugin directory: 55 * enter 56 57 svn pe svn:externals . 58 59 * write add a line 60 61 sfDoctrineActAsRattblePlugin http://svn.symfony-project.com/plugins/sfDoctrineActAsRattblePlugin/branches/1.2 62 63 * close the editor 64 * do a ``svn update`` an that's all 50 65 51 66 ## Configuration ## 52 67 53 my_object: 54 actAs: 55 Rattable: 56 criterias: [clean_state, receptionist, equipment] # optional, only if you wanna rate specifics parts 57 max_rate: 5 # 2,10 etc. any integer number you want (more than 100 is a bad idea, work with rounding) 58 rounding_rate: 1 # default is 1, but you cant set 0.1, 0.2 etc. 68 * configure your object : 69 70 my_object: 71 actAs: 72 Rattable: 73 criterias: rate # or [clean_state, receptionist, equipment] only if you wanna rate specifics parts 74 max_rate: 5 # 2,10 etc. any integer number you want (more than 20 is a bad idea, work with rounding instead) 75 rounding_rate: 1 # or 0.1, 0.2 etc. 76 with_comment: true # false 77 78 * rebuild the model: 79 80 ./symfony doctrine-build-all 81 82 * clear cache: 83 84 ./symfony cc 59 85 60 86 ## API ## 87 61 88 The plugin implements the following methods to the object: 62 89 63 * 90 * getRatingsDetails() 91 * getAvgRatings() 92 * addRate(RategObject $rateObject) 93 * removeRatings() 94 95 ## Events notifications types ## 96 97 * rate.add notify 98 * rate.remove notify 64 99 65 100 ## Helpers ## … … 68 103 69 104 ## Todo ## 70 * add comment to rates 105 * notification management 106 * give examples 107 * create helpers 108 * create components to show ratings 109 * add icons possibility for ratings types 71 110 72 111 ## Unit testing ## 73 The plugin has been unit-tested, if not fully. The tests are located in http://svn.symfony-project.com/plugins/sfDoctrineActAsRattablePlugin/branches/developpment_env/test/unit/sfDoctrineActAsRattableTest.php.112 The plugin has been unit-tested, perhaps not fully (I'm a newbie in unit tests). The tests are located in [developpment branch](http://svn.symfony-project.com/plugins/sfDoctrineActAsRattablePlugin/branches/developpment_env/test/unit/sfDoctrineActAsRattableTest.php). 74 113 75 114 ## Side notes ## … … 78 117 ## License and credits ## 79 118 This plugin has been created by [Mickael Kurmann](http://www.vieuxsteak.ch/) and is licensed under the MIT license. 119 80 120 I took my inspiration from : 81 121 … … 83 123 * [Unobtrusive AJAX Star Rating bar from Masuga](http://www.masugadesign.com/the-lab/scripts/unobtrusive-ajax-star-rating-bar/) 84 124 * [jQuery Star Rating plugin](http://www.fyneworks.com/jquery/star-rating/#tab-Overview) 85 86 }}}plugins/sfDoctrineActAsRattablePlugin/trunk/lib/RattableTemplate.class.php
r18389 r18417 1 1 <?php 2 2 3 class RattableListener extends Doctrine_Record_Listener4 {5 }6 7 3 class Rattable extends Doctrine_Template 8 4 { 5 /** 6 * __construct 7 * 8 * @param string $array 9 * @return void 10 */ 11 public function __construct(array $options = array()) 12 { 13 parent::__construct($options); 14 $this->_plugin = new Doctrine_Rattable($this->_options); 15 } 16 17 /** 18 * Initialize the Rattable plugin for the template 19 * 20 * @return void 21 */ 22 public function setUp() 23 { 24 $this->_plugin->initialize($this->_table); 25 } 26 27 /** 28 * Get the plugin instance for the Rattable template 29 * 30 * @return void 31 */ 32 public function getRattable() 33 { 34 return $this->_plugin; 35 } 9 36 }