public function RightColumnContent() { switch ($this->Action) { case 'view': $this->CheckIdExist(); $Object = Db_Brand::getObjectById($this->Id); $this->TPL->assign('Object', $Object); $ObjectTrans = Db_BrandTrans::getTransByObjectId($this->Id); $this->TPL->assign('ObjectTrans', $ObjectTrans); $LanguageModel = Db_Language::getLanguageWithKey(); $this->TPL->assign('LanguageModel', $LanguageModel); break; case 'edit': $this->CheckIdExist(); $Object = Db_Brand::getObjectById($this->Id); $this->TPL->assign('Object', $Object); $ObjectTrans = Db_BrandTrans::getTransByObjectId($this->Id); $this->TPL->assign('ObjectTrans', $ObjectTrans); $LanguageModel = Db_Language::getLanguageWithKey(); $this->TPL->assign('LanguageModel', $LanguageModel); break; case 'delete': if ($this->Id != 0) { Db_Brand::deleteByField('id', $this->Id); Db_BrandTrans::deleteByField('bt_brand_id', $this->Id, 0); if (is_dir(BASE_PATH . 'files/' . $this->object_path . $this->Id)) { removeDir(BASE_PATH . 'files/' . $this->object_path . $this->Id); } $this->Msg->SetMsg($this->_T('success_item_deleted')); $this->Redirect($this->PageUrl); } break; case 'add': $LanguageModel = Db_Language::getLanguageWithKey(); $this->TPL->assign('LanguageModel', $LanguageModel); break; case 'save': if ($this->Id != 0) { $this->CheckIdExist(); } $b_url = getPost('b_url'); $b_priority = getPost('b_priority'); $b_published = isset($_POST['b_published']) ? 1 : 0; $bt_title = getPost('bt_title'); $bt_description = getPost('bt_description'); // Save data into OBJECT $Object = new Db_Brand($this->DB, $this->Id, 'id'); $Object->b_url = $b_url; $Object->b_priority = $b_priority; $Object->b_published = $b_published; $Object->save(); // Take id of $Object $id = $Object->id; // Save trans values into $ObjectTrans foreach ($bt_title as $lang => $title) { $ObjectTrans = new Db_BrandTrans(); $ObjectTrans->findByFields(array('bt_brand_id' => $id, 'bt_lang_id' => $lang)); $ObjectTrans->bt_title = $bt_title[$lang]; $ObjectTrans->bt_description = $bt_description[$lang]; $ObjectTrans->bt_lang_id = $lang; $ObjectTrans->bt_brand_id = $id; $ObjectTrans->save(); } if (!empty($_FILES['b_image']) && $_FILES['b_image']['error'] == 0) { $image = Db_Brand::getObjectById($id); if (!empty($image['b_image']) && is_dir(BASE_PATH . 'files/' . $this->object_path . $this->Id)) { removeDir(BASE_PATH . 'files/' . $this->object_path . $this->Id); } $path = BASE_PATH . 'files/' . $this->object_path . '/' . $id . '/'; if ($filename = Upload::uploadImage($path, $_FILES['b_image'], 'main', $this->imageSizes, 'auto')) { $Object = new Db_Brand($this->DB, $id, 'id'); $Object->b_image = $filename; $Object->save(); } } $this->Msg->SetMsg($this->_T('success_item_saved')); $this->Redirect($this->PageUrl . '?action=view&id=' . $id); break; default: $Objects = Db_Brand::getObjects(); $ObjectsTrans = Db_BrandTrans::getTransByLang($this->LangId); $ListGrid = false; if ($Objects) { $ListGrid = new TGrid(); $ListGrid->Spacing = 0; $ListGrid->Width = '100%'; $ListGrid->SetClass('table table-bordered table-highlight-head'); $ListGrid->AddHeaderRow($this->_T('id'), $this->_T('Title'), $this->_T('Published'), $this->_T('Priority'), $this->_T('actions')); $ListGrid->BeginBody(); foreach ($Objects as $Object) { $Grid_TR = new TGrid_TTR(); $Grid_TD = new TGrid_TTD($Object['id'] . ' ( <a href="' . $this->PageUrl . '?action=view&id=' . $Object['id'] . '">' . $this->_T('see') . '</a> )'); $Grid_TR->Add($Grid_TD); $Grid_TD = new TGrid_TTD($ObjectsTrans[$Object['id']]['bt_title']); $Grid_TR->Add($Grid_TD); $Grid_TD = new TGrid_TTD($Object['b_published'] == 1 ? $this->_T('yes') : $this->_T('no')); $Grid_TR->Add($Grid_TD); $Grid_TD = new TGrid_TTD($Object['b_priority']); $Grid_TR->Add($Grid_TD); $Grid_TD = new TGrid_TTD(' <a class="bs-tooltip" title="" href="' . $this->PageUrl . '?action=edit&id=' . $Object['id'] . '" data-original-title="' . $this->_T('edit') . '"><i class="icon-pencil"></i></a> <a class="bs-tooltip confirm-dialog" data-text="' . _T('sure_you_want_to_delete') . '" title="" href="' . $this->PageUrl . '?action=delete&id=' . $Object['id'] . '" data-original-title="' . $this->_T('delete') . '"><i class="icon-trash"></i></a> '); $Grid_TD->AddAttr(new TAttr('class', 'align-center')); $Grid_TR->Add($Grid_TD); $ListGrid->AddTR($Grid_TR); } $ListGrid->EndBody(); $ListGrid = $ListGrid->Html(); } $this->TPL->assign('ListGrid', $ListGrid); break; } $msg = $this->Msg->Html(); $this->TPL->assign('msg', $msg); $this->TPL->assign('Action', $this->Action); $result = $this->TPL->display(null, true); $this->Msg->Clear(); return $result; }