Пример #1
0
 /**
  * 
  * create / update slider from options
  */
 private function createUpdateSliderFromOptions($options, $sliderID = null, $settingsMain, $settingsParams)
 {
     $arrMain = UniteFunctionsRev::getVal($options, "main");
     $params = UniteFunctionsRev::getVal($options, "params");
     $isTemplate = UniteFunctionsRev::getVal($options, "template");
     if ($isTemplate == "true") {
         $params['template'] = "true";
     } else {
         $params['template'] = "false";
     }
     //trim all input data
     $arrMain = UniteFunctionsRev::trimArrayItems($arrMain);
     //modify the data
     $arrMain = $settingsMain->setStoredValues($arrMain);
     $params = UniteFunctionsRev::trimArrayItems($params);
     $params = $settingsParams->setStoredValues($params);
     $params = array_merge($arrMain, $params);
     $title = UniteFunctionsRev::getVal($arrMain, "title");
     $alias = UniteFunctionsRev::getVal($arrMain, "alias");
     if (!empty($sliderID)) {
         $this->initByID($sliderID);
     }
     $this->validateInputSettings($title, $alias, $params);
     $jsonParams = json_encode($params);
     //insert slider to database
     $arrData = array();
     $arrData["title"] = $title;
     $arrData["alias"] = $alias;
     $arrData["params"] = $jsonParams;
     if (empty($sliderID)) {
         //create slider
         $sliderID = $this->db->insert(GlobalsRevSlider::$table_sliders, $arrData);
         return $sliderID;
     } else {
         //update slider
         $this->initByID($sliderID);
         $sliderID = $this->db->update(GlobalsRevSlider::$table_sliders, $arrData, array("id" => $sliderID));
     }
 }