This repository has been archived by the owner on Oct 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from burzum/develop
Develop
- Loading branch information
Showing
26 changed files
with
582 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,3 @@ | |
$map = array( | ||
1 => array('001_initialize_ratings_schema' => 'InitializeRatingsSchema') | ||
); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Installation | ||
============ | ||
|
||
To create tables you can use migrations plugin or schema shell. To create the tables via schema shell execute: | ||
|
||
```cake schema create --plugin Ratings --name ratings``` | ||
|
||
To create the tables via the migrations plugin run: | ||
|
||
```cake migrations.migration run all -p ratings``` | ||
|
||
Make sure the plugin is loaded in the application. | ||
|
||
```php | ||
CakePlugin::load('Ratings'); | ||
// or | ||
CakePlugin::loadAll(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
The Ratable Behavior | ||
==================== | ||
|
||
Behavior configuration | ||
---------------------- | ||
|
||
* **modelClass:** Must be set in the case of a plugin model to make the behavior work with plugin models like `Plugin.Model`. Required to define for plugin's models, and for model of app which name does not equal to class name, | ||
* **saveToField:** Boolean, true if the calculated result should be saved in the rated model | ||
* **calculation:** 'average' or 'sum', default is average. | ||
* **update:** Boolean flag, that define permission to rerate(change previous rating) | ||
* **modelValidate:** Validate the model before save, default is false | ||
* **modelCallbacks:** Run model callbacks when the rating is saved to the model, default is false | ||
|
||
The following options provide common defaults that, in most cases, need not be redefined: | ||
|
||
* **rateClass:** Name of the rate class model, by default is 'Ratings.Rating'. | ||
* **foreignKey:** Foreign key field, contains rated model id. | ||
* **field:** Name of the field that is updated with the calculated rating, | ||
* **fieldSummary:** Optional cache field that will store summary of all ratings that allow to implement quick rating calculation, | ||
* **fieldCounter:** Optional cache field that will store count of all ratings that allow to implement quick rating calculation. | ||
|
||
Behavior callbacks | ||
------------------ | ||
|
||
The `beforeRate` and `afterRate` callbacks are currently supported, and are defined in the rated model. These are called before and after the rate operation respectively. | ||
|
||
BeforeRate callback get one $data parameter that is a array containing: | ||
|
||
* **foreignKey:** Rated object id | ||
* **userId:** Rated user id | ||
* **value:** Rating value | ||
* **type:** Rating mode: saveRating or removeRating | ||
|
||
AfterRate callback get one $data parameter that is a array containing: | ||
|
||
* **foreignKey:** Rated object id | ||
* **userId:** Rated user id | ||
* **value:** Rating value | ||
* **type:** Rating mode: saveRating or removeRating | ||
* **result:** New rating value | ||
* **update:** Update mode value based on configuration | ||
* **oldRating:** Previous rating state | ||
|
||
Provided API is: | ||
|
||
* **saveRating($foreignKey, $userId, $value):** Allow to add new rating. | ||
* **removeRating($foreignKey, $userId):** Allow to remove undesired rating. | ||
* **rate($foreignKey, $userId, $rating, $options):** Aallow to rate agains not numeric values like 'up'/'down' that defined in $options array. | ||
* **isRatedBy($foreignKey, $userId):** Acheck method that user already rate defined model object | ||
* **cacheRatingStatistics($data):** Caches the sum of the different ratings for each of them if fields with database structure contain fields rating_{$value}. |
Oops, something went wrong.