'', 'slider_title' => '', 'slider_description' => '', 'slider_link' => '', 'slider_order' => '', 'slider_caption_offset' => 100, 'slider_caption_align' => 'left', 'slider_title_size' => 30, 'slider_desc_size' => 15, 'slider_btn_size' => 'normal', ]; private static $default_slider_settings = [ 'slider_id' => '', 'slider_path' => 0, 'slider_height' => '300', 'slider_navigation' => TRUE, 'slider_interval' => 200, 'slider_indicator' => TRUE, ]; private static $widget_instance = NULL; public static function widgetInstance() { if (self::$widget_instance === NULL) { self::$widget_instance = new static(); $lang = file_exists(WIDGETS."slider/locale/".LANGUAGE.".php") ? WIDGETS."slider/locale/".LANGUAGE.".php" : WIDGETS."slider/locale/English.php"; self::$slider_locale = fusion_get_locale('', $lang); if (!empty(self::$colData['page_content'])) { self::$slider_content = \defender::unserialize(self::$colData['page_content']); // Delete if (isset($_GET['widgetAction']) && isset($_GET['widgetKey']) && isnum($_GET['widgetKey'])) { if (isset(self::$slider_content[$_GET['widgetKey']])) { switch ($_GET['widgetAction']) { case 'del': if (isset(self::$slider_content[$_GET['widgetKey']])) { unset(self::$slider_content[$_GET['widgetKey']]); if (!empty(self::$slider_content)) { $slider_arr = array_combine(range(1, count(self::$slider_content)), array_values(self::$slider_content)); } else { $slider_arr = array_values(self::$slider_content); } if (!empty($slider_arr)) { $tmp_slider_arr = $slider_arr; foreach ($tmp_slider_arr as $key => $newData) { $newData['slider_order'] = $key; $slider_arr[$key] = $newData; } } self::$colData['page_content'] = \defender::serialize($slider_arr); dbquery_insert(DB_CUSTOM_PAGES_CONTENT, self::$colData, 'update'); addNotice('success', self::$slider_locale['SLDW_0200']); redirect(clean_request('slider=cur_slider', ['widgetAction', 'widgetKey'], FALSE)); } break; case 'edit': self::$slider_content = self::$slider_content[$_GET['widgetKey']]; break; } } else { redirect(clean_request('slider=cur_slider', ['widgetAction', 'widgetKey'], FALSE)); } } } self::$slider_content += self::$default_slider_data; // Parse Slider Settings if (!empty(self::$colData['page_options'])) { self::$slider_settings = \defender::unserialize(self::$colData['page_options']); } self::$slider_settings += self::$default_slider_settings; // Tab Interface if (empty(self::$colData['page_options'])) { self::$new_slider = TRUE; self::$slider_tab['title'][2] = self::$slider_locale['SLDW_0406']; self::$slider_tab['id'][2] = "slider_settings"; self::$tab_active = self::$slider_tab['id'][2]; } else { self::$slider_tab['title'][0] = ((isset($_GET['widgetAction']) && $_GET['widgetAction'] == 'edit') ? self::$slider_locale['back'] : self::$slider_locale['SLDW_0300']); self::$slider_tab['id'][0] = "cur_slider"; self::$slider_tab['title'][1] = ((isset($_GET['widgetAction']) && $_GET['widgetAction'] == 'edit') ? self::$slider_locale['SLDW_0301'] : self::$slider_locale['SLDW_0302']); self::$slider_tab['id'][1] = "slider_frm"; self::$slider_tab['title'][2] = self::$slider_locale['SLDW_0303']; self::$slider_tab['id'][2] = "slider_settings"; self::$tab_active = isset($_GET['slider']) && in_array($_GET['slider'], self::$slider_tab['id']) ? $_GET['slider'] : self::$slider_tab['id'][0]; } } return self::$widget_instance; } public function exclude_return() { return self::$exclude_return; } public function validate_input() { $widget_data = []; if (!empty(self::$colData['page_content'])) { $widget_data = \defender::unserialize(self::$colData['page_content']); } $data = [ 'slider_title' => form_sanitizer($_POST['slider_title'], '', 'slider_title'), 'slider_description' => form_sanitizer($_POST['slider_description'], '', 'slider_description'), 'slider_link' => form_sanitizer($_POST['slider_link'], '', 'slider_link'), 'slider_order' => form_sanitizer($_POST['slider_order'], 0, 'slider_order'), 'slider_caption_offset' => form_sanitizer($_POST['slider_caption_offset'], 0, 'slider_caption_offset'), 'slider_caption_align' => form_sanitizer($_POST['slider_caption_align'], '', 'slider_caption_align'), 'slider_title_size' => form_sanitizer($_POST['slider_title_size'], '', 'slider_title_size'), 'slider_desc_size' => form_sanitizer($_POST['slider_desc_size'], '', 'slider_desc_size'), 'slider_btn_size' => form_sanitizer($_POST['slider_btn_size'], '', 'slider_btn_size') ]; if ($data['slider_order'] == 0) { $data['slider_order'] = count($widget_data) + 1; } if (\defender::safe()) { if (!empty($_FILES['slider_image_src']['tmp_name'])) { $upload = form_sanitizer($_FILES['slider_image_src'], '', 'slider_image_src'); if (empty($upload['error'])) { $data['slider_image_src'] = $upload['image_name']; } } else { $data['slider_image_src'] = form_sanitizer($_POST['slider_image_src-mediaSelector'], '', 'slider_image_src-mediaSelector'); } } // The new is always the last one if (!empty($widget_data)) { reset($widget_data); $count = 1; foreach ($widget_data as $key => $arrayOrder) { $widget_data[$key]['slider_order'] = $count; $count++; } } // Now merge if (isset($_GET['widgetAction']) && $_GET['widgetAction'] == 'edit' && isset($_GET['widgetKey']) && isset($widget_data[$_GET['widgetKey']])) { $widget_data[$_GET['widgetKey']] = $data; } else { $new_widget_data[] = $data; $widget_data = array_merge_recursive($widget_data, $new_widget_data); } $widget_data = sorter($widget_data, 'slider_order'); $widget_data = array_values($widget_data); $count = 1; foreach ($widget_data as $key => $arrayOrder) { $widget_data[$key]['slider_order'] = $count; $count++; } if (\defender::safe() && !empty($widget_data)) { $widget_data = \defender::serialize($widget_data); return $widget_data; } } public function validate_settings() { $widget_settings = [ 'slider_id' => form_sanitizer($_POST['slider_id'], '', 'slider_id'), 'slider_path' => form_sanitizer($_POST['slider_path'], '', 'slider_path'), 'slider_height' => form_sanitizer($_POST['slider_height'], '', 'slider_height'), 'slider_navigation' => form_sanitizer($_POST['slider_navigation'], 0, 'slider_navigation'), 'slider_indicator' => form_sanitizer($_POST['slider_indicator'], 0, 'slider_indicator'), 'slider_interval' => form_sanitizer($_POST['slider_interval'], 0, 'slider_interval') ]; if (defender::safe() && !empty($widget_settings)) { return \defender::serialize($widget_settings); } } public function validate_delete() { } /* * Slider Interface */ public function display_form_input() { echo opentab(self::$slider_tab, self::$tab_active, 'slider_tabs', TRUE, 'm-t-20 nav-tabs', 'slider', ['widgetAction', 'widgetKey']); switch (self::$tab_active) { //default: case 'cur_slider': self::slider_content(); break; case 'slider_settings': self::slider_options_form(); break; default: //case 'slider_frm': self::slider_form(); } echo closetab(); } private function slider_content() { if (!empty(self::$colData['page_content'])) { self::$widget_data = \defender::unserialize(self::$colData['page_content']); if (!empty(self::$widget_data)) { ?>
- |