示例#1
0
 /**
  * Index a string with the moduleId and the itemId.
  *
  * The function get a string and separate into many words and store each of them.
  *
  * @param integer $moduleId The module ID to store.
  * @param integer $itemId   The item ID.
  * @param string  $data     String to save.
  *
  * @return void
  */
 private function _index($moduleId, $itemId, $data)
 {
     $array = $this->_stringToArray($data);
     // Found all the relations moduleId-itemId <-> userId-tagId
     $oldTagUserRelations = $this->getRelationIdByModule($moduleId, $itemId);
     // Delete the entries for the moduleId-itemId <-> userId
     $this->_tagsModules->deleteRelations($moduleId, $itemId, $oldTagUserRelations);
     foreach ($array as $word) {
         $crc32 = crc32($word);
         // Save the tag
         $tagId = $this->_tags->saveTags($crc32, $word);
         // Save the tag-user relation
         $tagUserId = $this->_tagsUsers->saveTags($tagId);
         // Save the tag-user-moduleId relation
         $this->_tagsModules->saveTags($moduleId, $itemId, $tagUserId);
     }
 }