public function save_action() { if ($this->_validate()) { require_once UNOSLIDER_BASE . '/application/models/unoslider.php'; $model = new Unoslider_Model(); $layers = array(); if (isset($_POST['layers'])) { foreach ($_POST['layers'] as $layer) { $layers[] = json_decode(stripslashes($layer), true); } } $presets = null; if (isset($_POST['undr_presets'])) { foreach ($_POST['undr_presets'] as $preset) { $presets[] = json_decode(stripslashes($preset), true); } $presets = serialize($presets); } $data = array('title' => empty($_POST['undr_title']) ? 'Unnamed Slider' : $_POST['undr_title'], 'size' => serialize(array('width' => $_POST['width'], 'height' => $_POST['height'])), 'theme' => $_POST['undr_theme'], 'slides' => serialize($_POST['slide_data']), 'links' => serialize(array('href' => $_POST['imglink'], 'target' => $_POST['linktarget'])), 'tooltip' => serialize($_POST['tooltip']), 'layers' => serialize($layers), 'presets' => $presets, 'options' => serialize(array('scale' => isset($_POST['undr_scale']) ? true : false, 'responsive' => isset($_POST['undr_responsive']) ? true : false, 'responsive_layers' => isset($_POST['undr_responsive_layers']) ? true : false, 'mobile' => isset($_POST['undr_mobile']) ? true : false, 'touch' => isset($_POST['undr_touch']) ? true : false, 'indicator' => !isset($_POST['undr_indicator']) ? false : array('autohide' => isset($_POST['undr_indicator_autohide']) ? true : false), 'navigation' => !isset($_POST['undr_navigation']) ? false : array('autohide' => !isset($_POST['undr_navigation_autohide']) ? false : implode(',', $_POST['undr_navigation_autohide']), 'play' => $_POST['undr_play'], 'stop' => $_POST['undr_pause'], 'next' => $_POST['undr_next'], 'prev' => $_POST['undr_prev']), 'slideshow' => !isset($_POST['undr_slideshow']) ? false : array('speed' => $_POST['undr_slideshow_speed'], 'autostart' => isset($_POST['undr_slideshow_autostart']) ? true : false, 'timer' => isset($_POST['undr_slideshow_timer']) ? true : false, 'hoverPause' => isset($_POST['undr_slideshow_hoverPause']) ? true : false, 'continuous' => isset($_POST['undr_slideshow_continuous']) ? true : false, 'infinite' => isset($_POST['undr_slideshow_infinite']) ? true : false), 'block' => array('vertical' => $_POST['undr_block_vertical'], 'horizontal' => $_POST['undr_block_horizontal']), 'animation' => array('speed' => $_POST['undr_animation_speed'], 'delay' => $_POST['undr_animation_delay'], 'transition' => $_POST['undr_transition'], 'variation' => isset($_POST['undr_variation']) ? $_POST['undr_variation'] : '', 'pattern' => $_POST['undr_pattern'], 'direction' => isset($_POST['undr_direction']) ? $_POST['undr_direction'] : ''), 'presets_order' => isset($_POST['undr_presets_order']) ? true : false))); if (empty($_POST['id'])) { // Create $id = $model->insert($data); $success = $id === 0 ? false : true; $response = json_encode(array('success' => $success, 'last_id' => $id)); } else { // Edit $result = $model->update($_POST['id'], $data); $success = $result === false ? false : true; $response = json_encode(array('success' => $success)); } // response output if (!$success) { header('HTTP/1.1 403 Forbidden'); } header("Content-Type: application/json"); echo $response; } exit; }