public function __construct($view, $title_page) { parent::__construct($view); $lang = LangLoader::get('common', 'media'); $this->set_title($lang['module_title']); $this->add_link(LangLoader::get_message('categories.management', 'categories-common'), MediaUrlBuilder::manage_categories()); $this->add_link(LangLoader::get_message('category.add', 'categories-common'), MediaUrlBuilder::add_category()); $this->add_link($lang['media.management'], MediaUrlBuilder::manage()); $this->add_link($lang['media.actions.add'], MediaUrlBuilder::add()); $this->add_link(LangLoader::get_message('configuration', 'admin-common'), MediaUrlBuilder::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', 'media'); $tree = new ModuleTreeLinks(); $manage_categories_link = new AdminModuleLink(LangLoader::get_message('categories.manage', 'categories-common'), MediaUrlBuilder::manage_categories()); $manage_categories_link->add_sub_link(new AdminModuleLink(LangLoader::get_message('categories.manage', 'categories-common'), MediaUrlBuilder::manage_categories())); $manage_categories_link->add_sub_link(new AdminModuleLink(LangLoader::get_message('category.add', 'categories-common'), MediaUrlBuilder::add_category())); $tree->add_link($manage_categories_link); $manage_media_link = new AdminModuleLink($lang['media.manage'], MediaUrlBuilder::manage()); $manage_media_link->add_sub_link(new AdminModuleLink($lang['media.manage'], MediaUrlBuilder::manage())); $manage_media_link->add_sub_link(new AdminModuleLink($lang['media.actions.add'], MediaUrlBuilder::add())); $tree->add_link($manage_media_link); $tree->add_link(new AdminModuleLink(LangLoader::get_message('configuration', 'admin-common'), MediaUrlBuilder::configuration())); if (!AppContext::get_current_user()->check_level(User::ADMIN_LEVEL)) { $tree->add_link(new ModuleLink($lang['media.actions.add'], MediaUrlBuilder::add(), MediaAuthorizationsService::check_authorizations()->write() || MediaAuthorizationsService::check_authorizations()->contribution())); } return $tree; }
* ################################################### * * 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 multimedia 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="' . MediaUrlBuilder::configuration()->relative() . '">module administration</a></li> <li class="formatter-li"> To create categories, <a href="' . MediaUrlBuilder::add_category()->relative() . '">clic here</a></li> <li class="formatter-li"> To create multimedia files, <a href="' . MediaUrlBuilder::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() { global $LANG, $MEDIA_LANG; require_once PATH_TO_ROOT . '/media/media_constant.php'; load_module_lang('media'); $config = MediaConfig::load(); $category = $this->get_category(); $authorized_categories = MediaService::get_authorized_categories($category->get_id()); //Contenu de la catégorie $page = AppContext::get_request()->get_getint('p', 1); $subcategories_page = AppContext::get_request()->get_getint('subcategories_page', 1); $get_sort = retrieve(GET, 'sort', ''); $get_mode = retrieve(GET, 'mode', ''); $mode = $get_mode == 'asc' ? 'ASC' : 'DESC'; $unget = !empty($get_sort) && !empty($mode) ? '?sort=' . $get_sort . '&mode=' . $get_mode : ''; //On crée une pagination si le nombre de sous-catégories est trop important. $subcategories_number = count(MediaService::get_categories_manager()->get_categories_cache()->get_childrens($category->get_id())); $pagination = new ModulePagination($subcategories_page, $subcategories_number, $config->get_categories_number_per_page()); $pagination->set_url(new Url('/media/media.php' . (!empty($unget) ? $unget . '&' : '?') . 'cat=' . $category->get_id() . '&p=' . $page . '&subcategories_page=%d')); if ($pagination->current_page_is_empty() && $subcategories_page > 1) { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } //Children categories $result = PersistenceContext::get_querier()->select('SELECT @id_cat:= media_cats.id, media_cats.*, (SELECT COUNT(*) FROM ' . MediaSetup::$media_table . ' WHERE idcat IN ( @id_cat, (SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . MediaSetup::$media_cats_table . ' WHERE id_parent = @id_cat), (SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . MediaSetup::$media_cats_table . ' parents INNER JOIN ' . MediaSetup::$media_cats_table . ' childs ON parents.id = childs.id_parent WHERE parents.id_parent = @id_cat) ) AND infos = :status ) AS mediafiles_number FROM ' . MediaSetup::$media_cats_table . ' media_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('id_category' => $category->get_id(), 'status' => MEDIA_STATUS_APROBED, 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $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']), 'CATEGORY_NAME' => $row['name'], 'CATEGORY_IMAGE' => $category_image->rel(), 'MEDIAFILES_NUMBER' => sprintf($row['mediafiles_number'] > 1 ? $MEDIA_LANG['num_medias'] : $MEDIA_LANG['num_media'], $row['mediafiles_number']), 'U_CATEGORY' => MediaUrlBuilder::display_category($row['id'], $row['rewrited_name'])->rel())); $nbr_cat_displayed++; } $result->dispose(); $nbr_column_cats = $nbr_cat_displayed > $config->get_columns_number_per_line() ? $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); $category_description = FormatingHelper::second_parse($category->get_description()); $this->tpl->put_all(array('C_CATEGORIES' => true, 'C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'C_CATEGORY_DESCRIPTION' => $category_description, 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_MODO' => MediaAuthorizationsService::check_authorizations($category->get_id())->moderation(), 'C_SUBCATEGORIES_PAGINATION' => $pagination->has_several_pages(), 'SUBCATEGORIES_PAGINATION' => $pagination->display(), 'L_UNAPROBED' => $MEDIA_LANG['unaprobed_media_short'], 'L_BY' => $MEDIA_LANG['media_added_by'], 'CATS_COLUMNS_WIDTH' => $cats_columns_width, 'CATEGORY_NAME' => $category->get_id() == Category::ROOT_CATEGORY ? LangLoader::get_message('module_title', 'common', 'media') : $category->get_name(), 'CATEGORY_DESCRIPTION' => $category_description, 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? MediaUrlBuilder::configuration()->rel() : MediaUrlBuilder::edit_category($category->get_id())->rel(), 'ID_CAT' => $category->get_id())); $selected_fields = array('alpha' => '', 'date' => '', 'nbr' => '', 'note' => '', 'com' => '', 'asc' => '', 'desc' => ''); switch ($get_sort) { case 'alpha': $sort = 'name'; $selected_fields['alpha'] = ' selected="selected"'; break; default: case 'date': $sort = 'timestamp'; $selected_fields['date'] = ' selected="selected"'; break; case 'nbr': $sort = 'counter'; $selected_fields['nbr'] = ' selected="selected"'; break; case 'note': $sort = 'average_notes'; $selected_fields['note'] = ' selected="selected"'; break; case 'com': $sort = 'com.number_comments'; $selected_fields['com'] = ' selected="selected"'; break; } if ($mode == 'ASC') { $selected_fields['asc'] = ' selected="selected"'; } else { $selected_fields['desc'] = ' selected="selected"'; } $this->tpl->put_all(array('C_DISPLAY_NOTATION' => $config->is_notation_enabled(), 'C_DISPLAY_COMMENTS' => $config->are_comments_enabled(), 'L_ALPHA' => $MEDIA_LANG['sort_title'], 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_NBR' => $MEDIA_LANG['sort_popularity'], 'L_NOTE' => LangLoader::get_message('note', 'common'), 'L_COM' => $LANG['com'], 'L_DESC' => $LANG['desc'], 'L_ASC' => $LANG['asc'], 'L_ORDER_BY' => LangLoader::get_message('sort_by', 'common'), 'SELECTED_ALPHA' => $selected_fields['alpha'], 'SELECTED_DATE' => $selected_fields['date'], 'SELECTED_NBR' => $selected_fields['nbr'], 'SELECTED_NOTE' => $selected_fields['note'], 'SELECTED_COM' => $selected_fields['com'], 'SELECTED_ASC' => $selected_fields['asc'], 'SELECTED_DESC' => $selected_fields['desc'])); $condition = 'WHERE idcat = :idcat AND infos = :status'; $parameters = array('idcat' => $category->get_id(), 'status' => MEDIA_STATUS_APROBED); //On crée une pagination si le nombre de fichiers est trop important. $mediafiles_number = MediaService::count($condition, $parameters); $pagination = new ModulePagination($page, $mediafiles_number, $config->get_items_number_per_page()); $pagination->set_url(new Url('/media/media.php' . (!empty($unget) ? $unget . '&' : '?') . 'cat=' . $category->get_id() . '&p=%d&subcategories_page=' . $subcategories_page)); if ($pagination->current_page_is_empty() && $page > 1) { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } $notation = new Notation(); $notation->set_module_name('media'); $notation->set_notation_scale($config->get_notation_scale()); $result = PersistenceContext::get_querier()->select("SELECT v.id, v.iduser, v.name, v.timestamp, v.counter, v.infos, v.contents, mb.display_name, mb.groups, mb.level, notes.average_notes, com.number_comments\n\t\t\tFROM " . PREFIX . "media AS v\n\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " AS mb ON v.iduser = mb.user_id\n\t\t\tLEFT JOIN " . DB_TABLE_AVERAGE_NOTES . " notes ON v.id = notes.id_in_module AND notes.module_name = 'media'\n\t\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com ON v.id = com.id_in_module AND com.module_id = 'media'\n\t\t\t" . $condition . "\n\t\t\tORDER BY " . $sort . " " . $mode . "\n\t\t\tLIMIT :number_items_per_page OFFSET :display_from", array_merge($parameters, array('number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()))); $this->tpl->put_all(array('C_FILES' => $result->get_rows_count() > 0, 'C_DISPLAY_NO_FILE_MSG' => $result->get_rows_count() == 0 && $category->get_id() != Category::ROOT_CATEGORY, 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'TARGET_ON_CHANGE_ORDER' => ServerEnvironmentConfig::load()->is_url_rewriting_enabled() ? 'media-0-' . $category->get_id() . '.php?' : 'media.php?cat=' . $category->get_id() . '&')); while ($row = $result->fetch()) { $notation->set_id_in_module($row['id']); $group_color = User::get_group_color($row['groups'], $row['level']); $this->tpl->assign_block_vars('file', array('ID' => $row['id'], 'NAME' => $row['name'], 'IMG_NAME' => str_replace('"', '\\"', $row['name']), 'C_DESCRIPTION' => !empty($row['contents']), 'DESCRIPTION' => stripslashes(FormatingHelper::second_parse($row['contents'])), 'POSTER' => $MEDIA_LANG['media_added_by'] . ' : ' . !empty($row['display_name']) ? '<a href="' . UserUrlBuilder::profile($row['iduser'])->rel() . '" class="' . UserService::get_level_class($row['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . $row['display_name'] . '</a>' : $LANG['guest'], 'DATE' => sprintf($MEDIA_LANG['add_on_date'], Date::to_format($row['timestamp'], Date::FORMAT_DAY_MONTH_YEAR)), 'COUNT' => sprintf($MEDIA_LANG['view_n_times'], $row['counter']), 'NOTE' => NotationService::display_static_image($notation), 'U_MEDIA_LINK' => PATH_TO_ROOT . '/media/' . url('media.php?id=' . $row['id'], 'media-' . $row['id'] . '-' . $category->get_id() . '+' . Url::encode_rewrite($row['name']) . '.php'), 'U_ADMIN_UNVISIBLE_MEDIA' => PATH_TO_ROOT . url('/media/media_action.php?unvisible=' . $row['id'] . '&token=' . AppContext::get_session()->get_token()), 'U_ADMIN_EDIT_MEDIA' => PATH_TO_ROOT . url('/media/media_action.php?edit=' . $row['id']), 'U_ADMIN_DELETE_MEDIA' => PATH_TO_ROOT . url('/media/media_action.php?del=' . $row['id'] . '&token=' . AppContext::get_session()->get_token()), 'U_COM_LINK' => '<a href="' . PATH_TO_ROOT . '/media/media' . url('.php?id=' . $row['id'] . '&com=0', '-' . $row['id'] . '-' . $category->get_id() . '+' . Url::encode_rewrite($row['name']) . '.php?com=0') . '">' . CommentsService::get_number_and_lang_comments('media', $row['id']) . '</a>')); } $result->dispose(); }
bread_crumb($media['idcat']); $Bread_crumb->add($media['name'], url('media.php?id=' . $id_media, 'media-' . $id_media . '-' . $media['idcat'] . '+' . Url::encode_rewrite($media['name']) . '.php')); define('TITLE', $media['name']); require_once '../kernel/header.php'; //MAJ du compteur. PersistenceContext::get_querier()->inject("UPDATE " . PREFIX . "media SET counter = counter + 1 WHERE id = :id", array('id' => $id_media)); $notation = new Notation(); $notation->set_module_name('media'); $notation->set_notation_scale($config->get_notation_scale()); $notation->set_id_in_module($id_media); $notation->set_number_notes($media['number_notes']); $notation->set_average_notes($media['average_notes']); $notation->set_user_already_noted(!empty($media['note'])); $nbr_notes = $media['number_notes']; $group_color = User::get_group_color($media['groups'], $media['level']); $tpl->put_all(array('ID' => $id_media, 'C_DISPLAY_MEDIA' => true, 'C_ROOT_CATEGORY' => $media['idcat'] == Category::ROOT_CATEGORY, 'C_MODO' => MediaAuthorizationsService::check_authorizations($media['idcat'])->moderation(), 'C_DISPLAY_NOTATION' => $config->is_notation_enabled(), 'C_DISPLAY_COMMENTS' => $config->are_comments_enabled(), 'ID_MEDIA' => $id_media, 'NAME' => $media['name'], 'CONTENTS' => stripslashes(FormatingHelper::second_parse($media['contents'])), 'COUNT' => $media['counter'], 'KERNEL_NOTATION' => NotationService::display_active_image($notation), 'HITS' => (int) $media['counter'] + 1 > 1 ? sprintf($MEDIA_LANG['n_times'], (int) $media['counter'] + 1) : sprintf($MEDIA_LANG['n_time'], (int) $media['counter'] + 1), 'U_COM' => PATH_TO_ROOT . '/media/media' . url('.php?id=' . $id_media . '&com=0', '-' . $id_media . '-' . $media['idcat'] . '+' . Url::encode_rewrite($media['name']) . '.php?com=0') . '#comments-list', 'L_COM' => CommentsService::get_number_and_lang_comments('media', $id_media), 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_SIZE' => $LANG['size'], 'L_MEDIA_INFOS' => $MEDIA_LANG['media_infos'], 'DATE' => Date::to_format($media['timestamp'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'L_MODO_PANEL' => $LANG['modo_panel'], 'L_UNAPROBED' => $MEDIA_LANG['unaprobed_media_short'], 'HEIGHT_P' => $media['height'] + 50, 'L_VIEWED' => $LANG['view'], 'L_BY' => $LANG['by'], 'BY' => !empty($media['display_name']) ? '<a href="' . UserUrlBuilder::profile($media['iduser'])->rel() . '" class="' . UserService::get_level_class($media['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . $media['display_name'] . '</a>' : $LANG['guest'], 'U_UNVISIBLE_MEDIA' => url('media_action.php?unvisible=' . $id_media . '&token=' . AppContext::get_session()->get_token()), 'U_EDIT_MEDIA' => url('media_action.php?edit=' . $id_media), 'U_DELETE_MEDIA' => url('media_action.php?del=' . $id_media . '&token=' . AppContext::get_session()->get_token()), 'U_POPUP_MEDIA' => url('media_popup.php?id=' . $id_media), 'CATEGORY_NAME' => $media['idcat'] == Category::ROOT_CATEGORY ? LangLoader::get_message('module_title', 'common', 'media') : MediaService::get_categories_manager()->get_categories_cache()->get_category($media['idcat'])->get_name(), 'U_EDIT_CATEGORY' => $media['idcat'] == Category::ROOT_CATEGORY ? MediaUrlBuilder::configuration()->rel() : MediaUrlBuilder::edit_category($media['idcat'])->rel())); if (empty($mime_type_tpl[$media['mime_type']])) { $media_tpl = new FileTemplate('media/format/media_other.tpl'); } else { $media_tpl = new FileTemplate('media/' . $mime_type_tpl[$media['mime_type']]); } $media_tpl->put_all(array('URL' => $media['url'], 'MIME' => $media['mime_type'], 'WIDTH' => $media['width'], 'HEIGHT' => $media['height'])); $tpl->put('media_format', $media_tpl); //Affichage commentaires. if (AppContext::get_request()->get_getint('com', 0) == 0) { $comments_topic = new MediaCommentsTopic(); $comments_topic->set_id_in_module($id_media); $comments_topic->set_url(new Url('/media/media.php?id=' . $id_media . '&com=0')); $tpl->put_all(array('COMMENTS' => CommentsService::display($comments_topic)->render())); } $tpl->display();
* ################################################### * * 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 multimédia 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="' . MediaUrlBuilder::configuration()->relative() . '">administration du module</a></li> <li class="formatter-li"> Pour créer des catégories, <a href="' . MediaUrlBuilder::add_category()->relative() . '">cliquez ici</a> </li> <li class="formatter-li"> Pour créer des fichiers multimédias, <a href="' . MediaUrlBuilder::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>.';