Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions ETaggableBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ class ETaggableBehavior extends CActiveRecordBehavior {
*/
private $scopeCriteria = null;

/**
* @var bool different case-variants of the same tag are accepted
*/
public $caseSensitive = false;

/**
* Get DB connection.
* @return CDbConnection
Expand Down Expand Up @@ -146,7 +151,11 @@ public function setTags($tags) {
$this->loadTags();

$tags = $this->toTagsArray($tags);
$this->tags = array_unique($tags);
if($this->caseSensitive) {
$this->tags = array_unique($tags);
} else {
$this->tags = array_intersect_key($tags, array_unique(array_map('strtolower', $tags)));
}

return $this->getOwner();
}
Expand All @@ -159,7 +168,13 @@ public function addTags($tags) {
$this->loadTags();

$tags = $this->toTagsArray($tags);
$this->tags = array_unique(array_merge($this->tags, $tags));
$mergedTags = array_merge($this->tags, $tags);

if($this->caseSensitive) {
$this->tags = array_unique($mergedTags);
} else {
$this->tags = array_intersect_key($mergedTags, array_unique(array_map('strtolower', $mergedTags)));
}

return $this->getOwner();
}
Expand Down Expand Up @@ -702,4 +717,4 @@ protected function updateCount($count) {
)->execute();
}
}
}
}