private function build_table() { $table_model = new SQLHTMLTableModel(DownloadSetup::$download_table, 'table', array(new HTMLTableColumn(LangLoader::get_message('form.name', 'common'), 'name'), new HTMLTableColumn(LangLoader::get_message('category', 'categories-common'), 'id_category'), new HTMLTableColumn(LangLoader::get_message('author', 'common'), 'display_name'), new HTMLTableColumn(LangLoader::get_message('form.date.creation', 'common'), 'creation_date'), new HTMLTableColumn(LangLoader::get_message('status', 'common'), 'approbation_type'), new HTMLTableColumn('')), new HTMLTableSortingRule('creation_date', HTMLTableSortingRule::DESC)); $table = new HTMLTable($table_model); $table_model->set_caption($this->lang['download.management']); $results = array(); $result = $table_model->get_sql_results('download LEFT JOIN ' . DB_TABLE_COMMENTS_TOPIC . ' com ON com.id_in_module = download.id AND com.module_id = \'download\' LEFT JOIN ' . DB_TABLE_AVERAGE_NOTES . ' notes ON notes.id_in_module = download.id AND notes.module_name = \'download\' LEFT JOIN ' . DB_TABLE_NOTE . ' note ON note.id_in_module = download.id AND note.module_name = \'download\' AND note.user_id = ' . AppContext::get_current_user()->get_id() . ' LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = download.author_user_id', array('*', 'download.id')); foreach ($result as $row) { $downloadfile = new DownloadFile(); $downloadfile->set_properties($row); $category = $downloadfile->get_category(); $user = $downloadfile->get_author_user(); $edit_link = new LinkHTMLElement(DownloadUrlBuilder::edit($downloadfile->get_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit'); $delete_link = new LinkHTMLElement(DownloadUrlBuilder::delete($downloadfile->get_id()), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => 'delete-element'), 'fa fa-delete'); $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true); $author = $user->get_id() !== User::VISITOR_LEVEL ? new LinkHTMLElement(UserUrlBuilder::profile($user->get_id()), $user->get_display_name(), !empty($user_group_color) ? array('style' => 'color: ' . $user_group_color) : array(), UserService::get_level_class($user->get_level())) : $user->get_display_name(); $results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement(DownloadUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $downloadfile->get_id(), $downloadfile->get_rewrited_name()), $downloadfile->get_name()), 'left'), new HTMLTableRowCell(new LinkHTMLElement(DownloadUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name()), $category->get_name())), new HTMLTableRowCell($author), new HTMLTableRowCell($downloadfile->get_creation_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), new HTMLTableRowCell($downloadfile->get_status()), new HTMLTableRowCell($edit_link->display() . $delete_link->display()))); } $table->set_rows($table_model->get_number_of_matching_rows(), $results); $this->view->put('table', $table->display()); }
private function build_table() { $table_model = new SQLHTMLTableModel(CalendarSetup::$calendar_events_table, 'table', array(new HTMLTableColumn(LangLoader::get_message('form.title', 'common'), 'title'), new HTMLTableColumn(LangLoader::get_message('category', 'categories-common'), 'id_category'), new HTMLTableColumn(LangLoader::get_message('author', 'common'), 'display_name'), new HTMLTableColumn(LangLoader::get_message('date', 'date-common'), 'start_date'), new HTMLTableColumn($this->lang['calendar.titles.repetition']), new HTMLTableColumn(LangLoader::get_message('status.approved', 'common'), 'approved'), new HTMLTableColumn('')), new HTMLTableSortingRule('start_date', HTMLTableSortingRule::DESC)); $table = new HTMLTable($table_model); $table_model->set_caption($this->lang['calendar.config.events.management']); $table_model->add_permanent_filter('parent_id = 0'); $results = array(); $result = $table_model->get_sql_results('event LEFT JOIN ' . CalendarSetup::$calendar_events_content_table . ' event_content ON event_content.id = event.content_id LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = event_content.author_id'); foreach ($result as $row) { $event = new CalendarEvent(); $event->set_properties($row); $category = $event->get_content()->get_category(); $user = $event->get_content()->get_author_user(); $edit_link = new LinkHTMLElement(CalendarUrlBuilder::edit_event(!$event->get_parent_id() ? $event->get_id() : $event->get_parent_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit'); $delete_link = new LinkHTMLElement(CalendarUrlBuilder::delete_event($event->get_id()), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => !$event->belongs_to_a_serie() ? 'delete-element' : ''), 'fa fa-delete'); $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true); $author = $user->get_id() !== User::VISITOR_LEVEL ? new LinkHTMLElement(UserUrlBuilder::profile($user->get_id()), $user->get_display_name(), !empty($user_group_color) ? array('style' => 'color: ' . $user_group_color) : array(), UserService::get_level_class($user->get_level())) : $user->get_display_name(); $br = new BrHTMLElement(); $results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement(CalendarUrlBuilder::display_event($category->get_id(), $category->get_rewrited_name(), $event->get_id(), $event->get_content()->get_rewrited_title()), $event->get_content()->get_title()), 'left'), new HTMLTableRowCell(new SpanHTMLElement($category->get_name(), array('style' => $category->get_id() != Category::ROOT_CATEGORY && $category->get_color() ? 'color:' . $category->get_color() : ''))), new HTMLTableRowCell($author), new HTMLTableRowCell(LangLoader::get_message('from_date', 'main') . ' ' . $event->get_start_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) . $br->display() . LangLoader::get_message('to_date', 'main') . ' ' . $event->get_end_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), new HTMLTableRowCell($event->belongs_to_a_serie() ? $this->lang['calendar.labels.repeat.' . $event->get_content()->get_repeat_type()] . ' - ' . $event->get_content()->get_repeat_number() . ' ' . $this->lang['calendar.labels.repeat_times'] : LangLoader::get_message('no', 'common')), new HTMLTableRowCell($event->get_content()->is_approved() ? LangLoader::get_message('yes', 'common') : LangLoader::get_message('no', 'common')), new HTMLTableRowCell($edit_link->display() . $delete_link->display()))); } $table->set_rows($table_model->get_number_of_matching_rows(), $results); $this->view->put('table', $table->display()); }
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 build_table() { $table_model = new SQLHTMLTableModel(DB_TABLE_MEMBER, 'table', array(new HTMLTableColumn($this->lang['display_name'], 'display_name'), new HTMLTableColumn($this->lang['email']), new HTMLTableColumn($this->lang['registration_date'], 'registration_date'), new HTMLTableColumn($this->lang['messages'], 'posted_msg'), new HTMLTableColumn($this->lang['last_connection'], 'last_connection_date'), new HTMLTableColumn($this->lang['private_message'])), new HTMLTableSortingRule('display_name', HTMLTableSortingRule::ASC)); $table = new HTMLTable($table_model); $results = array(); $result = $table_model->get_sql_results('m LEFT JOIN ' . DB_TABLE_INTERNAL_AUTHENTICATION . ' ia ON ia.user_id = m.user_id'); foreach ($result as $row) { $posted_msg = !empty($row['posted_msg']) ? $row['posted_msg'] : '0'; $group_color = User::get_group_color($row['groups'], $row['level']); $author = new LinkHTMLElement(UserUrlBuilder::profile($row['user_id']), $row['display_name'], !empty($group_color) ? array('style' => 'color: ' . $group_color) : array(), UserService::get_level_class($row['level'])); $results[] = new HTMLTableRow(array(new HTMLTableRowCell($author), new HTMLTableRowCell($row['show_email'] == 1 ? new LinkHTMLElement('mailto:' . $row['email'], $this->lang['email'], array(), 'basic-button smaller') : ''), new HTMLTableRowCell(Date::to_format($row['registration_date'], Date::FORMAT_DAY_MONTH_YEAR)), new HTMLTableRowCell($posted_msg), new HTMLTableRowCell(!empty($row['last_connection_date']) ? Date::to_format($row['last_connection_date'], Date::FORMAT_DAY_MONTH_YEAR) : LangLoader::get_message('never', 'main')), new HTMLTableRowCell(new LinkHTMLElement(UserUrlBuilder::personnal_message($row['user_id']), 'PM', array(), 'basic-button smaller')))); } $table->set_rows($table_model->get_number_of_matching_rows(), $results); $this->view->put('table', $table->display()); }
private function build_table() { $table_model = new SQLHTMLTableModel(PREFIX . 'errors_404', 'table', array(new HTMLTableColumn($this->lang['404_error_requested_url']), new HTMLTableColumn($this->lang['404_error_from_url']), new HTMLTableColumn($this->lang['404_error_times'], 'times', 'col-small'), new HTMLTableColumn(LangLoader::get_message('delete', 'common'), '', 'col-small')), new HTMLTableSortingRule('times', HTMLTableSortingRule::DESC)); $table = new HTMLTable($table_model, 'table-fixed error-list404'); $table_model->set_caption($this->lang['404_list']); $results = array(); $result = $table_model->get_sql_results(); foreach ($result as $row) { $delete_link = new LinkHTMLElement(AdminErrorsUrlBuilder::delete_404_error($row['id']), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => 'delete-element'), 'fa fa-delete'); $results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement($row['requested_url'], $row['requested_url'], array('title' => $this->lang['404_error_requested_url']))), new HTMLTableRowCell(new LinkHTMLElement($row['from_url'], $row['from_url'], array('title' => $this->lang['404_error_from_url']))), new HTMLTableRowCell($row['times']), new HTMLTableRowCell($delete_link->display()))); } $table->set_rows($table_model->get_number_of_matching_rows(), $results); if ($table_model->get_number_of_matching_rows()) { $this->build_form(); $this->view->put('FORM', $this->form->display()); $this->view->put('table', $table->display()); } else { $this->view->put('MSG', MessageHelper::display(LangLoader::get_message('no_item_now', 'common'), MessageHelper::SUCCESS, 0, true)); } }
private function build_table() { $table_model = new SQLHTMLTableModel(FaqSetup::$faq_table, 'table', array(new HTMLTableColumn($this->lang['faq.form.question'], 'question'), new HTMLTableColumn(LangLoader::get_message('category', 'categories-common'), 'id_category'), new HTMLTableColumn(LangLoader::get_message('author', 'common'), 'display_name'), new HTMLTableColumn(LangLoader::get_message('form.date.creation', 'common'), 'creation_date'), new HTMLTableColumn(LangLoader::get_message('status.approved', 'common'), 'approved'), new HTMLTableColumn('')), new HTMLTableSortingRule('creation_date', HTMLTableSortingRule::DESC)); $table = new HTMLTable($table_model); $table_model->set_caption($this->lang['faq.management']); $results = array(); $result = $table_model->get_sql_results('faq LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = faq.author_user_id'); foreach ($result as $row) { $faq_question = new FaqQuestion(); $faq_question->set_properties($row); $category = $faq_question->get_category(); $user = $faq_question->get_author_user(); $edit_link = new LinkHTMLElement(FaqUrlBuilder::edit($faq_question->get_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit'); $delete_link = new LinkHTMLElement(FaqUrlBuilder::delete($faq_question->get_id()), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => 'delete-element'), 'fa fa-delete'); $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true); $author = $user->get_id() !== User::VISITOR_LEVEL ? new LinkHTMLElement(UserUrlBuilder::profile($user->get_id()), $user->get_display_name(), !empty($user_group_color) ? array('style' => 'color: ' . $user_group_color) : array(), UserService::get_level_class($user->get_level())) : $user->get_display_name(); $results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement(FaqUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $faq_question->get_id()), $faq_question->get_question()), 'left'), new HTMLTableRowCell(new LinkHTMLElement(FaqUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name()), $category->get_name())), new HTMLTableRowCell($author), new HTMLTableRowCell($faq_question->get_creation_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), new HTMLTableRowCell($faq_question->is_approved() ? LangLoader::get_message('yes', 'common') : LangLoader::get_message('no', 'common')), new HTMLTableRowCell($edit_link->display() . $delete_link->display()))); } $table->set_rows($table_model->get_number_of_matching_rows(), $results); $this->view->put('table', $table->display()); }
private function build_table() { $table_model = new SQLHTMLTableModel(ArticlesSetup::$articles_table, 'table', array(new HTMLTableColumn(LangLoader::get_message('form.title', 'common'), 'title'), new HTMLTableColumn(LangLoader::get_message('category', 'categories-common'), 'id_category'), new HTMLTableColumn(LangLoader::get_message('author', 'common'), 'display_name'), new HTMLTableColumn(LangLoader::get_message('form.date.creation', 'common'), 'date_created'), new HTMLTableColumn(LangLoader::get_message('status', 'common'), 'published'), new HTMLTableColumn('')), new HTMLTableSortingRule('date_created', HTMLTableSortingRule::DESC)); $table = new HTMLTable($table_model); $table_model->set_caption($this->lang['articles_management']); $results = array(); $result = $table_model->get_sql_results('articles LEFT JOIN ' . DB_TABLE_AVERAGE_NOTES . ' notes ON notes.id_in_module = articles.id AND notes.module_name = \'articles\' LEFT JOIN ' . DB_TABLE_NOTE . ' note ON note.id_in_module = articles.id AND note.module_name = \'articles\' AND note.user_id = ' . AppContext::get_current_user()->get_id() . ' LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = articles.author_user_id', array('*', 'articles.id')); foreach ($result as $row) { $article = new Article(); $article->set_properties($row); $category = $article->get_category(); $user = $article->get_author_user(); $edit_link = new LinkHTMLElement(ArticlesUrlBuilder::edit_article($article->get_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit'); $delete_link = new LinkHTMLElement(ArticlesUrlBuilder::delete_article($article->get_id()), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => 'delete-element'), 'fa fa-delete'); $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true); $author = $user->get_id() !== User::VISITOR_LEVEL ? new LinkHTMLElement(UserUrlBuilder::profile($user->get_id()), $user->get_display_name(), !empty($user_group_color) ? array('style' => 'color: ' . $user_group_color) : array(), UserService::get_level_class($user->get_level())) : $user->get_display_name(); $br = new BrHTMLElement(); $dates = ''; if ($article->get_publishing_start_date() != null && $article->get_publishing_end_date() != null) { $dates = LangLoader::get_message('form.date.start', 'common') . ' ' . $article->get_publishing_start_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) . $br->display() . LangLoader::get_message('form.date.end', 'common') . ' ' . $article->get_publishing_end_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE); } else { if ($article->get_publishing_start_date() != null) { $dates = $article->get_publishing_start_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE); } else { if ($article->get_publishing_end_date() != null) { $dates = LangLoader::get_message('until', 'main') . ' ' . $article->get_publishing_end_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE); } } } $start_and_end_dates = new SpanHTMLElement($dates, array(), 'smaller'); $results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement(ArticlesUrlBuilder::display_article($category->get_id(), $category->get_rewrited_name(), $article->get_id(), $article->get_rewrited_title()), $article->get_title()), 'left'), new HTMLTableRowCell(new LinkHTMLElement(ArticlesUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name()), $category->get_name())), new HTMLTableRowCell($author), new HTMLTableRowCell($article->get_date_created()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), new HTMLTableRowCell($article->get_status() . $br->display() . ($dates ? $start_and_end_dates->display() : '')), new HTMLTableRowCell($edit_link->display() . $delete_link->display()))); } $table->set_rows($table_model->get_number_of_matching_rows(), $results); $this->view->put('table', $table->display()); }
private function build_table() { $number_admins = UserService::count_admin_members(); $table_model = new SQLHTMLTableModel(DB_TABLE_MEMBER, 'table', array(new HTMLTableColumn($this->lang['display_name'], 'display_name'), new HTMLTableColumn($this->lang['level'], 'level'), new HTMLTableColumn($this->lang['email']), new HTMLTableColumn($this->lang['registration_date'], 'registration_date'), new HTMLTableColumn($this->lang['last_connection'], 'last_connection_date'), new HTMLTableColumn($this->lang['approbation'], 'approved'), new HTMLTableColumn('')), new HTMLTableSortingRule('display_name', HTMLTableSortingRule::ASC)); $table = new HTMLTable($table_model); $table_model->set_caption(LangLoader::get_message('members.members-management', 'admin-user-common')); $results = array(); $result = $table_model->get_sql_results('m LEFT JOIN ' . DB_TABLE_INTERNAL_AUTHENTICATION . ' ia ON ia.user_id = m.user_id'); foreach ($result as $row) { $user = new User(); $user->set_properties($row); $edit_link = new LinkHTMLElement(UserUrlBuilder::edit_profile($user->get_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit'); if ($user->get_level() != User::ADMIN_LEVEL || $user->get_level() == User::ADMIN_LEVEL && $number_admins > 1) { $delete_link = new LinkHTMLElement(AdminMembersUrlBuilder::delete($user->get_id()), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => 'delete-element'), 'fa fa-delete'); } else { $delete_link = new LinkHTMLElement('', '', array('title' => LangLoader::get_message('delete', 'common'), 'onclick' => 'return false;'), 'fa fa-delete icon-disabled'); } $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true); $results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement(UserUrlBuilder::profile($user->get_id()), $user->get_display_name(), !empty($user_group_color) ? array('style' => 'color: ' . $user_group_color) : array(), UserService::get_level_class($user->get_level()))), new HTMLTableRowCell(UserService::get_level_lang($user->get_level())), new HTMLTableRowCell(new LinkHTMLElement('mailto:' . $user->get_email(), $this->lang['email'], array(), 'basic-button smaller')), new HTMLTableRowCell(Date::to_format($row['registration_date'], Date::FORMAT_DAY_MONTH_YEAR)), new HTMLTableRowCell(!empty($row['last_connection_date']) ? Date::to_format($row['last_connection_date'], Date::FORMAT_DAY_MONTH_YEAR) : LangLoader::get_message('never', 'main')), new HTMLTableRowCell($row['approved'] ? LangLoader::get_message('yes', 'common') : LangLoader::get_message('no', 'common')), new HTMLTableRowCell($edit_link->display() . $delete_link->display()))); } $table->set_rows($table_model->get_number_of_matching_rows(), $results); $this->view->put_all(array('FORM' => $this->build_form()->display(), 'table' => $table->display())); }
private function build_table() { $errors = $this->get_errors_list(); $types = array('question' => 'error.unknow', 'notice' => 'error.notice', 'warning' => 'error.warning', 'error' => 'error.fatal'); $table_model = new HTMLTableModel('table', array(new HTMLTableColumn(LangLoader::get_message('date', 'date-common'), '', 'col-large'), new HTMLTableColumn(LangLoader::get_message('description', 'main'))), new HTMLTableSortingRule(''), self::NUMBER_ITEMS_PER_PAGE); $table = new HTMLTable($table_model, 'table-fixed error-list'); $table_model->set_caption($this->lang['logged_errors_list']); $br = new BrHTMLElement(); $results = array(); foreach ($errors as $error) { $error_class = new SpanHTMLElement(LangLoader::get_message($types[$error['errclass']], 'status-messages-common') . ' : ', array(), 'text-strong'); $error_stacktrace = new SpanHTMLElement(strip_tags($error['errstacktrace'], '<br>'), array(), 'text-italic'); $error_message = $error_class->display() . strip_tags($error['errmsg'], '<br>') . $br->display() . $br->display() . $br->display() . $error_stacktrace->display(); $results[] = new HTMLTableRow(array(new HTMLTableRowCell($error['errdate']), new HTMLTableRowCell(new DivHTMLElement($error_message, array(), $error['errclass'])))); } $results_number = count($results); $table->set_rows($results_number, $results); if ($results_number) { $this->view->put_all(array('FORM' => $this->build_form()->display(), 'table' => $table->display())); } else { $this->view->put('MSG', MessageHelper::display(LangLoader::get_message('no_item_now', 'common'), MessageHelper::SUCCESS, 0, true)); } }