private function handleCategory($category = '')
{
// Does a category with this name exist?
/* @var \SpoonDatabase $db */
$db = BackendModel::getContainer()->get('database');
$id = (int) $db->getVar('SELECT id FROM blog_categories WHERE title=? AND language=?', array($category, BL::getWorkingLanguage()));
// We found an id!
if ($id > 0) {
return $id;
}
// Return default if we got an empty string
if (trim($category) == '') {
return 2;
}
// We should create a new category
$cat = array();
$cat['language'] = BL::getWorkingLanguage();
$cat['title'] = $category;
$meta = array();
$meta['keywords'] = $category;
$meta['description'] = $category;
$meta['title'] = $category;
$meta['url'] = $category;
return Model::insertCategory($cat, $meta);
}