/**
  * check whether a category exists and returns the id
  * else insert new category
  *
  * @return int category id
  * @param string $category the category name
  */
 protected function insertCategory($category)
 {
     // no category handling for uncategorized
     if ($category == -1) {
         return -1;
     }
     // search existing category
     $categoriesModel = new application_models_categories();
     $categories = $categoriesModel->fetchAll($categoriesModel->select()->where($categoriesModel->getAdapter()->quoteInto('name=?', trim($category))));
     // use existing category
     if ($categories->count() > 0) {
         return $categories->current()->id;
     } else {
         return $categoriesModel->insert(array('name' => trim($category), 'position' => $categoriesModel->maxPosition() + 1));
     }
 }