public function save($data_to_save)
{
if (is_admin() == false) {
return false;
}
if (isset($data_to_save['is_element']) and $data_to_save['is_element'] == true) {
exit(__FILE__ . __LINE__ . d($data_to_save));
}
$table = 'elements';
$save = false;
if (!empty($data_to_save)) {
$s = $data_to_save;
if (!isset($s['parent_id'])) {
$s['parent_id'] = 0;
}
if (!isset($s['id']) and isset($s['module'])) {
$s['module'] = $data_to_save['module'];
if (!isset($s['module_id'])) {
$save = $this->get('limit=1&module=' . $s['module']);
if ($save != false and isset($save[0]) and is_array($save[0])) {
$s['id'] = $save[0]['id'];
$save = $this->app->database_manager->save($table, $s);
} else {
$save = $this->app->database_manager->save($table, $s);
}
}
} else {
$save = $this->app->database_manager->save($table, $s);
}
}
if ($save != false) {
$this->app->cache_manager->delete('elements' . DIRECTORY_SEPARATOR . '');
$this->app->cache_manager->delete('elements' . DIRECTORY_SEPARATOR . 'global');
}
return $save;
}