public function __construct($view, $title_page) { parent::__construct($view); $lang = LangLoader::get('common', 'download'); $this->set_title($lang['module_title']); $this->add_link(LangLoader::get_message('categories.management', 'categories-common'), DownloadUrlBuilder::manage_categories()); $this->add_link(LangLoader::get_message('category.add', 'categories-common'), DownloadUrlBuilder::add_category()); $this->add_link($lang['download.management'], DownloadUrlBuilder::manage()); $this->add_link($lang['download.actions.add'], DownloadUrlBuilder::add()); $this->add_link(LangLoader::get_message('configuration', 'admin-common'), DownloadUrlBuilder::configuration()); $env = $this->get_graphical_environment(); $env->set_page_title($title_page, $lang['module_title']); }
public function get_actions_tree_links() { $lang = LangLoader::get('common', 'download'); $tree = new ModuleTreeLinks(); $manage_categories_link = new AdminModuleLink(LangLoader::get_message('categories.manage', 'categories-common'), DownloadUrlBuilder::manage_categories()); $manage_categories_link->add_sub_link(new AdminModuleLink(LangLoader::get_message('categories.manage', 'categories-common'), DownloadUrlBuilder::manage_categories())); $manage_categories_link->add_sub_link(new AdminModuleLink(LangLoader::get_message('category.add', 'categories-common'), DownloadUrlBuilder::add_category())); $tree->add_link($manage_categories_link); $manage_link = new AdminModuleLink($lang['download.manage'], DownloadUrlBuilder::manage()); $manage_link->add_sub_link(new AdminModuleLink($lang['download.manage'], DownloadUrlBuilder::manage())); $manage_link->add_sub_link(new AdminModuleLink($lang['download.actions.add'], DownloadUrlBuilder::add(AppContext::get_request()->get_getint('id_category', Category::ROOT_CATEGORY)))); $tree->add_link($manage_link); $tree->add_link(new AdminModuleLink(LangLoader::get_message('configuration', 'admin-common'), DownloadUrlBuilder::configuration())); if (!AppContext::get_current_user()->check_level(User::ADMIN_LEVEL)) { $tree->add_link(new ModuleLink($lang['download.actions.add'], DownloadUrlBuilder::add(AppContext::get_request()->get_getint('id_category', Category::ROOT_CATEGORY)), DownloadAuthorizationsService::check_authorizations()->write() || DownloadAuthorizationsService::check_authorizations()->contribution())); } $tree->add_link(new ModuleLink($lang['download.pending'], DownloadUrlBuilder::display_pending(), DownloadAuthorizationsService::check_authorizations()->write() || DownloadAuthorizationsService::check_authorizations()->contribution() || DownloadAuthorizationsService::check_authorizations()->moderation())); return $tree; }
public function get_array_tpl_vars() { $category = $this->get_category(); $contents = FormatingHelper::second_parse($this->contents); $description = $this->get_real_short_contents(); $user = $this->get_author_user(); $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true); $number_comments = CommentsService::get_number_comments('download', $this->id); return array('C_VISIBLE' => $this->is_visible(), 'C_EDIT' => $this->is_authorized_to_edit(), 'C_DELETE' => $this->is_authorized_to_delete(), 'C_READ_MORE' => !$this->is_short_contents_enabled() && $description != $contents && strlen($description) >= DownloadConfig::NUMBER_CARACTERS_BEFORE_CUT, 'C_SIZE' => !empty($this->size), 'C_PICTURE' => $this->has_picture(), 'C_CUSTOM_AUTHOR_DISPLAY_NAME' => $this->is_author_display_name_enabled(), 'C_USER_GROUP_COLOR' => !empty($user_group_color), 'C_UPDATED_DATE' => $this->has_updated_date(), 'ID' => $this->id, 'NAME' => $this->name, 'SIZE' => $this->formated_size, 'CONTENTS' => $contents, 'DESCRIPTION' => $description, 'DATE' => $this->creation_date->format(Date::FORMAT_DAY_MONTH_YEAR), 'DATE_DAY' => $this->creation_date->get_day(), 'DATE_MONTH' => $this->creation_date->get_month(), 'DATE_YEAR' => $this->creation_date->get_year(), 'DATE_DAY_MONTH' => $this->creation_date->format(Date::FORMAT_DAY_MONTH), 'DATE_ISO8601' => $this->creation_date->format(Date::FORMAT_ISO8601), 'UPDATED_DATE' => $this->updated_date !== null ? $this->updated_date->format(Date::FORMAT_DAY_MONTH_YEAR) : '', 'UPDATED_DATE_ISO8601' => $this->updated_date !== null ? $this->updated_date->format(Date::FORMAT_ISO8601) : '', 'STATUS' => $this->get_status(), 'CUSTOM_AUTHOR_DISPLAY_NAME' => $this->author_display_name, 'C_AUTHOR_EXIST' => $user->get_id() !== User::VISITOR_LEVEL, 'PSEUDO' => $user->get_display_name(), 'USER_LEVEL_CLASS' => UserService::get_level_class($user->get_level()), 'USER_GROUP_COLOR' => $user_group_color, 'NUMBER_DOWNLOADS' => $this->number_downloads, 'L_DOWNLOADED_TIMES' => StringVars::replace_vars(LangLoader::get_message('downloaded_times', 'common', 'download'), array('number_downloads' => $this->number_downloads)), 'STATIC_NOTATION' => NotationService::display_static_image($this->get_notation()), 'NOTATION' => NotationService::display_active_image($this->get_notation()), 'C_COMMENTS' => !empty($number_comments), 'L_COMMENTS' => CommentsService::get_lang_comments('download', $this->id), 'NUMBER_COMMENTS' => CommentsService::get_number_comments('download', $this->id), 'C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'CATEGORY_ID' => $category->get_id(), 'CATEGORY_NAME' => $category->get_name(), 'CATEGORY_DESCRIPTION' => $category->get_description(), 'CATEGORY_IMAGE' => $category->get_image()->rel(), 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? DownloadUrlBuilder::configuration()->rel() : DownloadUrlBuilder::edit_category($category->get_id())->rel(), 'U_SYNDICATION' => SyndicationUrlBuilder::rss('download', $this->id_category)->rel(), 'U_AUTHOR_PROFILE' => UserUrlBuilder::profile($this->get_author_user()->get_id())->rel(), 'U_LINK' => DownloadUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $this->id, $this->rewrited_name)->rel(), 'U_DOWNLOAD' => DownloadUrlBuilder::download($this->id)->rel(), 'U_DEADLINK' => DownloadUrlBuilder::dead_link($this->id)->rel(), 'U_CATEGORY' => DownloadUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name())->rel(), 'U_EDIT' => DownloadUrlBuilder::edit($this->id)->rel(), 'U_DELETE' => DownloadUrlBuilder::delete($this->id)->rel(), 'U_PICTURE' => $this->get_picture()->rel(), 'U_COMMENTS' => DownloadUrlBuilder::display_comments($category->get_id(), $category->get_rewrited_name(), $this->id, $this->rewrited_name)->rel()); }
* ################################################### * * This program is a free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ #################################################### # English # #################################################### $lang['root_category_description'] = 'Welcome to the downloads section of the website! <br /><br /> One category and one file were created to show you how this module works. Here are some tips to get started on this module. <br /><br /> <ul class="formatter-ul"> <li class="formatter-li"> To configure or customize the module homepage your module, go into the <a href="' . DownloadUrlBuilder::configuration()->relative() . '">module administration</a></li> <li class="formatter-li"> To create categories, <a href="' . DownloadUrlBuilder::add_category()->relative() . '">clic here</a></li> <li class="formatter-li"> To create download files, <a href="' . DownloadUrlBuilder::add()->relative() . '">clic here</a></li> </ul> <br />To learn more, don \'t hesitate to consult the documentation for the module on <a href="http://www.phpboost.com">PHPBoost</a> website.';
private function build_view(HTTPRequestCustom $request) { $now = new Date(); $authorized_categories = DownloadService::get_authorized_categories($this->get_category()->get_id()); $mode = $request->get_getstring('sort', DownloadUrlBuilder::DEFAULT_SORT_MODE); $field = $request->get_getstring('field', DownloadUrlBuilder::DEFAULT_SORT_FIELD); $page = AppContext::get_request()->get_getint('page', 1); $subcategories_page = AppContext::get_request()->get_getint('subcategories_page', 1); $subcategories_number = count(DownloadService::get_categories_manager()->get_categories_cache()->get_childrens($this->get_category()->get_id())); $subcategories_pagination = $this->get_subcategories_pagination($subcategories_number, $this->config->get_categories_number_per_page(), $field, $mode, $page, $subcategories_page); //Children categories $result = PersistenceContext::get_querier()->select('SELECT @id_cat:= download_cats.id, download_cats.*, (SELECT COUNT(*) FROM ' . DownloadSetup::$download_table . ' WHERE id_category IN ( @id_cat, (SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . DownloadSetup::$download_cats_table . ' WHERE id_parent = @id_cat), (SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . DownloadSetup::$download_cats_table . ' parents INNER JOIN ' . DownloadSetup::$download_cats_table . ' childs ON parents.id = childs.id_parent WHERE parents.id_parent = @id_cat) ) AND (approbation_type = 1 OR (approbation_type = 2 AND start_date < :timestamp_now AND (end_date > :timestamp_now OR end_date = 0))) ) AS downloadfiles_number FROM ' . DownloadSetup::$download_cats_table . ' download_cats WHERE id_parent = :id_category AND id IN :authorized_categories ORDER BY id_parent, c_order LIMIT :number_items_per_page OFFSET :display_from', array('timestamp_now' => $now->get_timestamp(), 'id_category' => $this->category->get_id(), 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $subcategories_pagination->get_number_items_per_page(), 'display_from' => $subcategories_pagination->get_display_from())); $nbr_cat_displayed = 0; while ($row = $result->fetch()) { $category_image = new Url($row['image']); $this->tpl->assign_block_vars('sub_categories_list', array('C_CATEGORY_IMAGE' => !empty($row['image']), 'C_MORE_THAN_ONE_DOWNLOADFILE' => $row['downloadfiles_number'] > 1, 'CATEGORY_NAME' => $row['name'], 'CATEGORY_IMAGE' => $category_image->rel(), 'DOWNLOADFILES_NUMBER' => $row['downloadfiles_number'], 'U_CATEGORY' => DownloadUrlBuilder::display_category($row['id'], $row['rewrited_name'])->rel())); $nbr_cat_displayed++; } $result->dispose(); $nbr_column_cats = $nbr_cat_displayed > $this->config->get_columns_number_per_line() ? $this->config->get_columns_number_per_line() : $nbr_cat_displayed; $nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1; $cats_columns_width = floor(100 / $nbr_column_cats); $condition = 'WHERE id_category = :id_category AND (approbation_type = 1 OR (approbation_type = 2 AND start_date < :timestamp_now AND (end_date > :timestamp_now OR end_date = 0)))'; $parameters = array('id_category' => $this->get_category()->get_id(), 'timestamp_now' => $now->get_timestamp()); $pagination = $this->get_pagination($condition, $parameters, $field, $mode, $page, $subcategories_page); $sort_mode = $mode == 'asc' ? 'ASC' : 'DESC'; switch ($field) { case 'name': $sort_field = DownloadFile::SORT_ALPHABETIC; break; case 'download': $sort_field = DownloadFile::SORT_NUMBER_DOWNLOADS; break; case 'com': $sort_field = DownloadFile::SORT_NUMBER_COMMENTS; break; case 'note': $sort_field = DownloadFile::SORT_NOTATION; break; case 'author': $sort_field = DownloadFile::SORT_AUTHOR; break; case 'date': $sort_field = DownloadFile::SORT_DATE; break; default: $sort_field = DownloadFile::SORT_UPDATED_DATE; break; } $result = PersistenceContext::get_querier()->select('SELECT download.*, member.*, com.number_comments, notes.average_notes, notes.number_notes, note.note FROM ' . DownloadSetup::$download_table . ' download LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = download.author_user_id 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 = :user_id ' . $condition . ' ORDER BY ' . $sort_field . ' ' . $sort_mode . ' LIMIT :number_items_per_page OFFSET :display_from', array_merge($parameters, array('user_id' => AppContext::get_current_user()->get_id(), 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()))); $category_description = FormatingHelper::second_parse($this->get_category()->get_description()); $this->tpl->put_all(array('C_FILES' => $result->get_rows_count() > 0, 'C_MORE_THAN_ONE_FILE' => $result->get_rows_count() > 1, 'C_CATEGORY_DISPLAYED_SUMMARY' => $this->config->is_category_displayed_summary(), 'C_CATEGORY_DISPLAYED_TABLE' => $this->config->is_category_displayed_table(), 'C_CATEGORY_DESCRIPTION' => !empty($category_description), 'C_AUTHOR_DISPLAYED' => $this->config->is_author_displayed(), 'C_COMMENTS_ENABLED' => $this->config->are_comments_enabled(), 'C_NOTATION_ENABLED' => $this->config->is_notation_enabled(), 'C_MODERATION' => DownloadAuthorizationsService::check_authorizations($this->get_category()->get_id())->moderation(), 'C_PAGINATION' => $pagination->has_several_pages(), 'C_CATEGORY' => true, 'C_ROOT_CATEGORY' => $this->get_category()->get_id() == Category::ROOT_CATEGORY, 'C_HIDE_NO_ITEM_MESSAGE' => $this->get_category()->get_id() == Category::ROOT_CATEGORY && ($nbr_cat_displayed != 0 || !empty($category_description)), 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_SUBCATEGORIES_PAGINATION' => $subcategories_pagination->has_several_pages(), 'SUBCATEGORIES_PAGINATION' => $subcategories_pagination->display(), 'CATS_COLUMNS_WIDTH' => $cats_columns_width, 'PAGINATION' => $pagination->display(), 'TABLE_COLSPAN' => 4 + (int) $this->config->are_comments_enabled() + (int) $this->config->is_notation_enabled(), 'ID_CAT' => $this->get_category()->get_id(), 'CATEGORY_NAME' => $this->get_category()->get_name(), 'CATEGORY_IMAGE' => $this->get_category()->get_image()->rel(), 'CATEGORY_DESCRIPTION' => $category_description, 'U_EDIT_CATEGORY' => $this->get_category()->get_id() == Category::ROOT_CATEGORY ? DownloadUrlBuilder::configuration()->rel() : DownloadUrlBuilder::edit_category($this->get_category()->get_id())->rel())); while ($row = $result->fetch()) { $downloadfile = new DownloadFile(); $downloadfile->set_properties($row); $keywords = $downloadfile->get_keywords(); $has_keywords = count($keywords) > 0; $this->tpl->assign_block_vars('downloadfiles', array_merge($downloadfile->get_array_tpl_vars(), array('C_KEYWORDS' => $has_keywords))); if ($has_keywords) { $this->build_keywords_view($keywords); } } $result->dispose(); $this->build_sorting_form($field, $mode); }
* ################################################### * * This program is a free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ #################################################### # French # #################################################### $lang['root_category_description'] = 'Bienvenue dans l\'espace de téléchargement du site ! <br /><br /> Une catégorie et un fichier ont été créés pour vous montrer comment fonctionne ce module. Voici quelques conseils pour bien débuter sur ce module. <br /><br /> <ul class="formatter-ul"> <li class="formatter-li"> Pour configurer ou personnaliser l\'accueil de votre module, rendez vous dans l\'<a href="' . DownloadUrlBuilder::configuration()->relative() . '">administration du module</a></li> <li class="formatter-li"> Pour créer des catégories, <a href="' . DownloadUrlBuilder::add_category()->relative() . '">cliquez ici</a> </li> <li class="formatter-li"> Pour ajouter des fichiers en téléchargement, <a href="' . DownloadUrlBuilder::add()->relative() . '">cliquez ici</a></li> </ul> <br />Pour en savoir plus, n\'hésitez pas à consulter la documentation du module sur le site de <a href="http://www.phpboost.com">PHPBoost</a>.';