function execute()
 {
     $slideID = (int) Request::post('id');
     if ($slideID > 0) {
         connectionSliderModel::create()->where(array('id' => $slideID))->delete();
     }
 }
 function execute()
 {
     $locale = new Locales('connection');
     $list = $locale->getList();
     $this->smarty->assign('lang', $list);
     $this->smarty->assign('slide', connectionSliderModel::create()->where(array('id' => (int) Request::post('id')))->fetchOne());
 }
 function execute()
 {
     $model = connectionSliderModel::create();
     $locale = new Locales('connection');
     $list = $locale->getList();
     $this->smarty->assign('slides', $model->sort('sort', -1)->fetchAll());
     $this->smarty->assign('lang', $list);
 }
 static function getSlides()
 {
     $lang = Language::getActiveLanguageISO();
     $slides = array_map(function ($a) use($lang) {
         return array_merge($a, $a[$lang]);
     }, connectionSliderModel::create()->sort('sort', -1)->fetchAll());
     return $slides;
 }
 function execute()
 {
     $status = 'success';
     $model = connectionSliderModel::create();
     $locale = new Locales('connection');
     $list = $locale->getList();
     $data = Request::post('slide');
     if (!isset($data['link']) || empty($data['link'])) {
         $status = 'error';
     } else {
         if (isset($data['id'])) {
             $slide = $model->where(array('id' => (int) $data['id']))->fetchOne();
         }
         $dir = UPLOAD_DIR . DS . 'slider' . DS;
         File::mkdir($dir);
         foreach ($list as $lang) {
             $file = Request::files('slide_' . $lang['iso']);
             if (!$file || empty($file[0]['name'])) {
                 if (isset($data['id'])) {
                     $data[$lang['iso']]['image'] = isset($slide[$lang['iso']]['image']) ? $slide[$lang['iso']]['image'] : '';
                 }
                 continue;
             }
             $file = $file[0];
             $info = pathinfo($file['name']);
             $name = strtotime('now') . md5($file['name']) . uniqid() . '.' . $info['extension'];
             File::upload($file, $dir, $name);
             $data[$lang['iso']]['image'] = $name;
         }
         if (isset($data['id'])) {
             $id = $data['id'];
             unset($data['id']);
             $model->where(array('id' => (int) $id))->update($data);
         } else {
             $data['sort'] = 0;
             $model->insert($data);
         }
     }
     return array('status' => $status);
 }