public function execute(HTTPRequestCustom $request)
 {
     $id = $request->get_getint('id', 0);
     PersistenceContext::get_querier()->delete(DB_TABLE_SMILEYS, 'WHERE idsmiley = :id', array('id' => $id));
     ###### Régénération du cache des smileys #######
     SmileysCache::invalidate();
     AppContext::get_response()->redirect(AdminSmileysUrlBuilder::management());
 }
 public function __construct($view, $title_page)
 {
     parent::__construct($view);
     $lang = LangLoader::get('admin');
     $this->set_title($lang['smiley_management']);
     $this->add_link($lang['smiley_management'], AdminSmileysUrlBuilder::management());
     $this->add_link($lang['add_smiley'], AdminSmileysUrlBuilder::add());
     $env = $this->get_graphical_environment();
     $env->set_page_title($title_page);
 }
 private function build_table()
 {
     $table_model = new HTMLTableModel('table', array(new HTMLTableColumn($this->lang['smiley']), new HTMLTableColumn(LangLoader::get_message('code', 'main')), new HTMLTableColumn('')), new HTMLTableSortingRule(''), HTMLTableModel::NO_PAGINATION);
     $table = new HTMLTable($table_model);
     $table_model->set_caption($this->lang['smiley_management']);
     $results = array();
     foreach (SmileysCache::load()->get_smileys() as $code => $row) {
         $edit_link = new LinkHTMLElement(AdminSmileysUrlBuilder::edit($row['idsmiley']), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit');
         $delete_link = new LinkHTMLElement(AdminSmileysUrlBuilder::delete($row['idsmiley']), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => 'delete-element'), 'fa fa-delete');
         $results[] = new HTMLTableRow(array(new HTMLTableRowCell(new ImgHTMLElement(Url::to_rel('/images/smileys/') . $row['url_smiley'], array('id' => 'smiley-' . $row['idsmiley'] . '-img', 'alt' => ''))), new HTMLTableRowCell($code), new HTMLTableRowCell($edit_link->display() . $delete_link->display())));
     }
     $table->set_rows(count($results), $results);
     $this->view->put('table', $table->display());
 }
 private function save_smiley()
 {
     $code_smiley = $this->smiley_form->get_value('code_smiley');
     $url_smiley = $this->smiley_form->get_value('url_smiley')->get_raw_value();
     if (!empty($code_smiley) && !empty($url_smiley)) {
         if (!$this->smiley['idsmiley']) {
             $check_smiley = PersistenceContext::get_querier()->count(DB_TABLE_SMILEYS, 'WHERE code_smiley=:code_smiley', array('code_smiley' => $code_smiley));
             if (empty($check_smiley)) {
                 PersistenceContext::get_querier()->insert(DB_TABLE_SMILEYS, array('code_smiley' => $code_smiley, 'url_smiley' => $url_smiley));
                 ###### Régénération du cache des smileys #######
                 SmileysCache::invalidate();
                 $this->view->put('MSG', MessageHelper::display($this->lang['smiley_add_success'], MessageHelper::SUCCESS));
             } else {
                 $this->view->put('MSG', MessageHelper::display(LangLoader::get_message('element.already_exists', 'status-messages-common'), MessageHelper::ERROR));
             }
         } else {
             PersistenceContext::get_querier()->update(DB_TABLE_SMILEYS, array('url_smiley' => $url_smiley, 'code_smiley' => $code_smiley), 'WHERE idsmiley = :id', array('id' => $this->smiley['idsmiley']));
             ###### Régénération du cache des smileys #######
             SmileysCache::invalidate();
             AppContext::get_response()->redirect(AdminSmileysUrlBuilder::management());
         }
     }
 }