/** * get sliders array - function don't belong to the object! */ public function getArrSliders($orders = false, $templates = 'neither') { $order_fav = false; if ($orders !== false && key($orders) != 'favorite') { $order_direction = reset($orders); $do_order = key($orders); } else { $do_order = 'id'; $order_direction = 'ASC'; if (is_array($orders) && key($orders) == 'favorite') { $order_direction = reset($orders); $order_fav = true; } } $where = "`type` != 'template'"; $response = $this->db->fetch(RevSliderGlobals::$table_sliders, $where, $do_order, '', $order_direction); $arrSliders = array(); foreach ($response as $arrData) { $slider = new RevSlider(); $slider->initByDBData($arrData); /* This part needs to stay for backwards compatibility. It is used in the update process from v4x to v5x */ if ($templates === true) { if ($slider->getParam("template", "false") == "false") { continue; } } elseif ($templates === false) { if ($slider->getParam("template", "false") == "true") { continue; } } $arrSliders[] = $slider; } if ($order_fav === true) { $temp = array(); $temp_not = array(); foreach ($arrSliders as $key => $slider) { if ($slider->isFavorite()) { $temp_not[] = $slider; } else { $temp[] = $slider; } } $arrSliders = array(); $arrSliders = $order_direction == 'ASC' ? array_merge($temp, $temp_not) : array_merge($temp_not, $temp); } return $arrSliders; }