Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #105 from CakeDC/develop
Browse files Browse the repository at this point in the history
Merge develop
  • Loading branch information
steinkel committed Oct 22, 2015
2 parents 39ea32b + 4517d11 commit 292347f
Show file tree
Hide file tree
Showing 24 changed files with 546 additions and 307 deletions.
19 changes: 14 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,31 @@ env:
- REQUIRE="phpunit/phpunit:3.7.31"

matrix:
- DB=mysql CAKE_VERSION=master
- DB=mysql CAKE_VERSION=2.7

matrix:
include:
- php: 5.3
env:
- CAKE_VERSION=master
- CAKE_VERSION=2.7
- php: 5.4
env:
- CAKE_VERSION=master
- CAKE_VERSION=2.7
- php: 5.5
env:
- CAKE_VERSION=master
- CAKE_VERSION=2.7
- php: 5.3
env:
- CAKE_VERSION=2.6
- php: 5.4
env:
- CAKE_VERSION=2.6
- php: 5.5
env:
- CAKE_VERSION=2.6

before_script:
- git clone https://github.com/burzum/travis.git --depth 1 ../travis
- git clone https://github.com/steinkel/travis.git --depth 1 ../travis
- ../travis/before_script.sh
- if [ "$PHPCS" != 1 ]; then
echo "
Expand Down
49 changes: 13 additions & 36 deletions Config/Migration/001_initialize_tags_schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ class M49ac311a54844a9d87o822502jedc423 extends CakeMigration {
'up' => array(
'create_table' => array(
'tagged' => array(
'id' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 36, 'key' => 'primary'),
'foreign_key' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 36),
'tag_id' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 36),
'model' => array('type' => 'string', 'null' => false, 'default' => NULL, 'key' => 'index'),
'language' => array('type' => 'string', 'null' => true, 'default' => NULL, 'length' => 6),
'created' => array('type' => 'datetime', 'null' => true, 'default' => NULL),
'modified' => array('type' => 'datetime', 'null' => true, 'default' => NULL),
'id' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 36, 'key' => 'primary'),
'foreign_key' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 36),
'tag_id' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 36),
'model' => array('type' => 'string', 'null' => false, 'default' => null, 'key' => 'index'),
'language' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 6),
'created' => array('type' => 'datetime', 'null' => true, 'default' => null),
'modified' => array('type' => 'datetime', 'null' => true, 'default' => null),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => 1),
'UNIQUE_TAGGING' => array('column' => array('model', 'foreign_key', 'tag_id', 'language'), 'unique' => 1),
Expand All @@ -57,13 +57,13 @@ class M49ac311a54844a9d87o822502jedc423 extends CakeMigration {
)
),
'tags' => array(
'id' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 36, 'key' => 'primary'),
'identifier' => array('type' => 'string', 'null' => true, 'default' => NULL, 'length' => 30, 'key' => 'index'),
'name' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 30),
'keyname' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 30),
'id' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 36, 'key' => 'primary'),
'identifier' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 30, 'key' => 'index'),
'name' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 30),
'keyname' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 30),
'weight' => array('type' => 'integer', 'null' => false, 'default' => 0, 'length' => 2),
'created' => array('type' => 'datetime', 'null' => true, 'default' => NULL),
'modified' => array('type' => 'datetime', 'null' => true, 'default' => NULL),
'created' => array('type' => 'datetime', 'null' => true, 'default' => null),
'modified' => array('type' => 'datetime', 'null' => true, 'default' => null),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => 1),
'UNIQUE_TAG' => array('column' => array('identifier', 'keyname'), 'unique' => 1)
Expand All @@ -76,27 +76,4 @@ class M49ac311a54844a9d87o822502jedc423 extends CakeMigration {
)
);

/**
* Before migration callback
*
* @param string $direction, up or down direction of migration process
* @return boolean Should process continue
* @access public
*/
public function before($direction) {
return true;
}

/**
* After migration callback
*
* @param string $direction, up or down direction of migration process
* @return boolean Should process continue
* @access public
*/
public function after($direction) {
return true;
}

}
?>
24 changes: 1 addition & 23 deletions Config/Migration/002_create_times_tagged_field.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class M4c0d42bcd12c4db099c105f40e8f3d6d extends CakeMigration {
'create_field' => array(
'tagged' => array(
'times_tagged' => array('type' => 'integer', 'null' => false, 'default' => 1),
)
),
),
),
'down' => array(
'drop_field' => array(
Expand All @@ -52,26 +52,4 @@ class M4c0d42bcd12c4db099c105f40e8f3d6d extends CakeMigration {
),
);

/**
* Before migration callback
*
* @param string $direction, up or down direction of migration process
* @return boolean Should process continue
* @access public
*/
public function before($direction) {
return true;
}

/**
* After migration callback
*
* @param string $direction, up or down direction of migration process
* @return boolean Should process continue
* @access public
*/
public function after($direction) {
return true;
}
}
?>
24 changes: 1 addition & 23 deletions Config/Migration/003_occurrence_fields_for_tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class M8d01880f01c11e0be500800200c9a66 extends CakeMigration {
'create_field' => array(
'tags' => array(
'occurrence' => array('type' => 'integer', 'null' => false, 'default' => 0, 'length' => 8),
)
),
),
'drop_field' => array(
'tags' => array('weight')
),
Expand All @@ -60,26 +60,4 @@ class M8d01880f01c11e0be500800200c9a66 extends CakeMigration {
),
);

/**
* Before migration callback
*
* @param string $direction, up or down direction of migration process
* @return boolean Should process continue
* @access public
*/
public function before($direction) {
return true;
}

/**
* After migration callback
*
* @param string $direction, up or down direction of migration process
* @return boolean Should process continue
* @access public
*/
public function after($direction) {
return true;
}
}
?>
10 changes: 6 additions & 4 deletions Config/Migration/map.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@

$map = array(
1 => array(
'001_initialize_tags_schema' => 'M49ac311a54844a9d87o822502jedc423'),
'001_initialize_tags_schema' => 'M49ac311a54844a9d87o822502jedc423',
),
2 => array(
'002_create_times_tagged_field' => 'M4c0d42bcd12c4db099c105f40e8f3d6d'),
'002_create_times_tagged_field' => 'M4c0d42bcd12c4db099c105f40e8f3d6d',
),
3 => array(
'003_occurrence_fields_for_tags' => 'M8d01880f01c11e0be500800200c9a66'),
'003_occurrence_fields_for_tags' => 'M8d01880f01c11e0be500800200c9a66',
),
);
?>
20 changes: 0 additions & 20 deletions Config/Schema/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,6 @@

class TagSchema extends CakeSchema {

/**
* Before callback
*
* @param array Event
* @return boolean
*/
public function before($event = array()) {
return true;
}

/**
* After callback
*
* @param array Event
* @return boolean
*/
public function after($event = array()) {
return true;
}

/**
* Schema for taggeds table
*
Expand Down
14 changes: 7 additions & 7 deletions Controller/TagsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function index() {
/**
* View
*
* @param string
* @param string $keyName Tag key name
* @return void
*/
public function view($keyName = null) {
Expand All @@ -77,14 +77,14 @@ public function view($keyName = null) {
* @return void
*/
public function admin_index() {
$this->{$this->modelClass}->recursive = 0;
$this->{$this->modelClass}->recursive = 0;
$this->set('tags', $this->Paginator->paginate());
}

/**
* Views a single tag
*
* @param string tag UUID
* @param string $keyName Tag key name
* @return void
*/
public function admin_view($keyName) {
Expand Down Expand Up @@ -113,7 +113,7 @@ public function admin_add() {
/**
* Edits a tag
*
* @param string tag UUID
* @param string $tagId Tag UUID
* @return void
*/
public function admin_edit($tagId = null) {
Expand All @@ -138,11 +138,11 @@ public function admin_edit($tagId = null) {
/**
* Deletes a tag
*
* @param string tag UUID
* @param string $tagId Tag UUID
* @return void
*/
public function admin_delete($id = null) {
if ($this->{$this->modelClass}->delete($id)) {
public function admin_delete($tagId = null) {
if ($this->{$this->modelClass}->delete($tagId)) {
$this->Session->setFlash(__d('tags', 'Tag deleted.'));
} else {
$this->Session->setFlash(__d('tags', 'Invalid Tag.'));
Expand Down
14 changes: 11 additions & 3 deletions Docs/Documentation/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,39 @@ After adding the TaggableBehavior to your model, you will need to update your vi
```php
public $actsAs = array(
'Tags.Taggable' => array(
'separator' => '',
'field' => 'tags',
'separator' => ',',
'tagAlias' => 'Tag',
'tagClass' => 'Tags.Tag',
'taggedAlias' => 'Tagged',
'taggedClass' => 'Tags.Tagged',
'field' => 'tags',
'foreignKey' => 'foreign_key',
'associationForeignKey' => 'tag_id',
'cacheOccurrence' => true,
'automaticTagging' => true,
'taggedCounter' => false,
'unsetInAfterFind' => false,
'resetBinding' => false,
'deleteTagsOnEmptyField' => false,
)
);
```

The configuration above contains the default values for each setting. Here are some explanations:

* **separator:** String used to separate tags in the Model.tags value. (Default: ```,```)
* **field:** Name of the Model field containing the tag list. (Default: ```tags```)
* **tagAlias:** Alias for the HABTM relationship between your Model and Tag. (Default: ```Tag```)
* **tagClass**: Name of the model representing Tags. (Default: ```Tags.Tag```)
* **taggedAlias:** Alias for the HABTM join model. (Default: ```Tagged```)
* **taggedClass:** Name of the HABTM join model. (Default: ```Tags.Tagged```)
* **field:** Name of the Model field containing the tag list. (Default: ```tags```)
* **foreignKey:** Name of the HABTM join model field containing the foreign key to the Tagable model. (Default: ```foreign_key```)
* **associationForeignKey:** Name of the HABTM join model field containing the foreign key to the Tag model. (Default: ```tag_id```)
* **cacheOccurrence:** Name of the HABTM join model field containing the foreign key to the Tag model. (Default: ```true```)
* **automaticTagging:** Whether or not the behavior will automatically call saveTags() after each save. (Default: ```true```)
* **taggedCounter:** True to update the number of times a particular tag was used for a specific record.
* **unsetInAfterFind:** Whether or not the related Tag entries have to be unset after a find. If this value is true, the ```$data['Tag']``` array will be unset and tags will only be available using the ```$data['Model']['tags']``` value. (Default: false)
* **resetBinding:** Value passed as the second param of to the ```bindModel()``` call when creating the HABTM association. If set to true, the binding will last only one query. (Default: false)
* **deleteTagsOnEmptyField:** Delete associated Tags if field is empty or empty string.

Note that the ```tagClass```, ```taggedClass```, ```foreignKey``` and ```associationForeignKey``` values must not be changed if you use the plugin as it is shipped. Use these settings when you want to use your own models / tables structure.
6 changes: 6 additions & 0 deletions Docs/Documentation/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Installation

To install the plugin, place the files in a directory labelled "Tags/" in your "app/Plugin/" directory.

Then, include the following line in your `app/Config/bootstrap.php` to load the plugin in your application.

```
CakePlugin::load('Tags');
```

Git Submodule
-------------

Expand Down
5 changes: 3 additions & 2 deletions Docs/Documentation/The-Tag-Cloud-Helper.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ The second param for the ```display()``` method is an array of options. The avai
* **after:** string to be displayed after each generated link. %size% will be replaced with tag size calculated from the weight. (Default: ```empty```)
* **maxSize:** size of the heaviest tag. (Default: ```160```)
* **minSize:** size of the lightest tag. (Default: ```80```)
* **url:** an array containing the default url. (Default: ```array('controller' => 'search'```))
* **named**: the named parameter used to send the tag keyname. (Default: ```by```)
* **url:** an array containing the default URL. (Default: ```array('controller' => 'search'```))
* **named**: the named parameter used to send the tag keyname. (Default: ```by```)
* **paramType**: the type of URL parameters used (```named``` or ```querystring```). (Default: ```named```)
Loading

0 comments on commit 292347f

Please sign in to comment.