public function set_properties(array $properties) { $this->id = $properties['id']; $this->id_category = $properties['id_category']; $this->name = $properties['name']; $this->rewrited_name = $properties['rewrited_name']; $this->url = new Url($properties['url']); $this->size = $properties['size']; $this->contents = $properties['contents']; $this->short_contents = $properties['short_contents']; $this->approbation_type = $properties['approbation_type']; $this->start_date = !empty($properties['start_date']) ? new Date($properties['start_date'], Timezone::SERVER_TIMEZONE) : null; $this->end_date = !empty($properties['end_date']) ? new Date($properties['end_date'], Timezone::SERVER_TIMEZONE) : null; $this->end_date_enabled = !empty($properties['end_date']); $this->creation_date = new Date($properties['creation_date'], Timezone::SERVER_TIMEZONE); $this->updated_date = !empty($properties['updated_date']) ? new Date($properties['updated_date'], Timezone::SERVER_TIMEZONE) : null; $this->number_downloads = $properties['number_downloads']; $this->picture_url = new Url($properties['picture_url']); $user = new User(); if (!empty($properties['user_id'])) { $user->set_properties($properties); } else { $user->init_visitor_user(); } $this->set_author_user($user); $notation = new Notation(); $notation->set_module_name('download'); $notation->set_notation_scale(DownloadConfig::load()->get_notation_scale()); $notation->set_id_in_module($properties['id']); $notation->set_number_notes($properties['number_notes']); $notation->set_average_notes($properties['average_notes']); $notation->set_user_already_noted(!empty($properties['note'])); $this->notation = $notation; $this->author_display_name = !empty($properties['author_display_name']) ? $properties['author_display_name'] : $this->author_user->get_display_name(); $this->author_display_name_enabled = !empty($properties['author_display_name']); $units = array(LangLoader::get_message('unit.bytes', 'common'), LangLoader::get_message('unit.kilobytes', 'common'), LangLoader::get_message('unit.megabytes', 'common'), LangLoader::get_message('unit.gigabytes', 'common')); $power = $this->size > 0 ? floor(log($this->size, 1024)) : 0; $this->formated_size = (double) number_format($this->size / pow(1024, $power), 2, '.', ',') . ' ' . $units[$power]; }
private function build_view() { global $LANG, $Bread_crumb; load_module_lang('gallery'); $g_idpics = retrieve(GET, 'id', 0); $g_views = retrieve(GET, 'views', false); $g_notes = retrieve(GET, 'notes', false); $g_sort = retrieve(GET, 'sort', ''); $g_sort = !empty($g_sort) ? 'sort=' . $g_sort : ''; //Récupération du mode d'ordonnement. if (preg_match('`([a-z]+)_([a-z]+)`', $g_sort, $array_match)) { $g_type = $array_match[1]; $g_mode = $array_match[2]; } else { list($g_type, $g_mode) = array('date', 'desc'); } $comments_topic = new GalleryCommentsTopic(); $config = GalleryConfig::load(); $category = $this->get_category(); $categories = GalleryService::get_categories_manager()->get_categories_cache()->get_childrens($category->get_id()); $authorized_categories = GalleryService::get_authorized_categories($category->get_id()); $Gallery = new Gallery(); $nbr_pics = $this->db_querier->count(GallerySetup::$gallery_table, 'WHERE idcat=:idcat AND aprob = 1', array('idcat' => $category->get_id())); $total_cat = count($categories); //On crée une pagination si le nombre de catégories est trop important. $page = AppContext::get_request()->get_getint('p', 1); $pagination = new ModulePagination($page, $total_cat, $config->get_categories_number_per_page()); $pagination->set_url(new Url('/gallery/gallery.php?p=%d&cat=' . $category->get_id() . '&id=' . $g_idpics . '&' . $g_sort)); if ($pagination->current_page_is_empty() && $page > 1) { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } //Colonnes des catégories. $nbr_column_cats = $total_cat > $config->get_columns_number() ? $config->get_columns_number() : $total_cat; $nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1; $column_width_cats = floor(100 / $nbr_column_cats); //Colonnes des images. $nbr_column_pics = $nbr_pics > $config->get_columns_number() ? $config->get_columns_number() : $nbr_pics; $nbr_column_pics = !empty($nbr_column_pics) ? $nbr_column_pics : 1; $column_width_pics = floor(100 / $nbr_column_pics); $is_admin = AppContext::get_current_user()->check_level(User::ADMIN_LEVEL); $is_modo = GalleryAuthorizationsService::check_authorizations($category->get_id())->moderation(); $module_data_path = $this->tpl->get_pictures_data_path(); $rewrite_title = Url::encode_rewrite($category->get_name()); ##### Catégorie disponibles ##### $nbr_cat_displayed = 0; if ($total_cat > 0 && empty($g_idpics)) { $this->tpl->put('C_GALLERY_CATS', true); $j = 0; $result = $this->db_querier->select('SELECT @id_cat:= gallery_cats.id, gallery_cats.*, (SELECT COUNT(*) FROM ' . GallerySetup::$gallery_table . ' WHERE idcat IN ( @id_cat, (SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . GallerySetup::$gallery_cats_table . ' WHERE id_parent = @id_cat), (SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . GallerySetup::$gallery_cats_table . ' parents INNER JOIN ' . GallerySetup::$gallery_cats_table . ' childs ON parents.id = childs.id_parent WHERE parents.id_parent = @id_cat) ) AND aprob = 1 ) AS nbr_pics FROM ' . GallerySetup::$gallery_cats_table . ' gallery_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(), 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())); 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(), 'PICTURES_NUMBER' => sprintf($LANG['nbr_pics_info'], $row['nbr_pics']), 'U_CATEGORY' => GalleryUrlBuilder::get_link_cat($row['id'], $row['name']))); $nbr_cat_displayed++; } $result->dispose(); } $category_description = FormatingHelper::second_parse($category->get_description()); $this->tpl->put_all(array('C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'C_CATEGORY_DESCRIPTION' => $category_description, 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_SUBCATEGORIES_PAGINATION' => $pagination->has_several_pages(), 'SUBCATEGORIES_PAGINATION' => $pagination->display(), 'ARRAY_JS' => '', 'NBR_PICS' => 0, 'MAX_START' => 0, 'START_THUMB' => 0, 'END_THUMB' => 0, 'COLUMNS_NUMBER' => $nbr_column_pics, 'CATS_COLUMNS_WIDTH' => $column_width_cats, 'COLUMN_WIDTH_PICS' => $column_width_pics, 'CATEGORY_DESCRIPTION' => $category_description, 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? GalleryUrlBuilder::configuration()->rel() : GalleryUrlBuilder::edit_category($category->get_id())->rel(), 'CAT_ID' => $category->get_id(), 'DISPLAY_MODE' => $config->get_pics_enlargement_mode(), 'GALLERY' => $category->get_id() != Category::ROOT_CATEGORY ? $this->lang['module_title'] . ' - ' . $category->get_name() : $this->lang['module_title'], 'HEIGHT_MAX' => $config->get_mini_max_height(), 'WIDTH_MAX' => $column_width_pics, 'MODULE_DATA_PATH' => $module_data_path, 'L_APROB' => $LANG['aprob'], 'L_UNAPROB' => $LANG['unaprob'], 'L_FILE_FORBIDDEN_CHARS' => $LANG['file_forbidden_chars'], 'L_TOTAL_IMG' => $category->get_id() != Category::ROOT_CATEGORY ? sprintf($LANG['total_img_cat'], $nbr_pics) : '', 'L_ADD_IMG' => $LANG['add_pic'], 'L_GALLERY' => $this->lang['module_title'], 'L_CATEGORIES' => $category->get_id_parent() >= 0 ? $LANG['sub_album'] : $LANG['album'], 'L_NAME' => $LANG['name'], 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_MOVETO' => $LANG['moveto'], 'L_DELETE' => LangLoader::get_message('delete', 'common'), 'L_SUBMIT' => $LANG['submit'], 'L_ALREADY_VOTED' => $LANG['already_vote'], 'L_ORDER_BY' => LangLoader::get_message('sort_by', 'common') . (isset($LANG[$g_type]) ? ' ' . strtolower($LANG[$g_type]) : ''), 'L_DIRECTION' => $LANG['direction'], 'L_DISPLAY' => LangLoader::get_message('display', 'common'), 'U_INDEX' => url('.php'), 'U_BEST_VIEWS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?views=1&cat=' . $category->get_id(), '-' . $category->get_id() . '.php?views=1'), 'U_BEST_NOTES' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?notes=1&cat=' . $category->get_id(), '-' . $category->get_id() . '.php?notes=1'), 'U_ASC' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $category->get_id() . '&sort=' . $g_type . '_' . 'asc', '-' . $category->get_id() . '.php?sort=' . $g_type . '_' . 'asc'), 'U_DESC' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $category->get_id() . '&sort=' . $g_type . '_' . 'desc', '-' . $category->get_id() . '.php?sort=' . $g_type . '_' . 'desc'), 'U_ORDER_BY_NAME' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=name_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=name_desc'), 'U_ORDER_BY_DATE' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=date_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=date_desc'), 'U_ORDER_BY_VIEWS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=views_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=views_desc'), 'U_ORDER_BY_NOTES' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=notes_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=notes_desc'), 'U_ORDER_BY_COM' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=com_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=com_desc'), 'L_BEST_VIEWS' => $LANG['best_views'], 'L_BEST_NOTES' => $LANG['best_notes'], 'L_ASC' => $LANG['asc'], 'L_DESC' => $LANG['desc'], 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_VIEWS' => $LANG['views'], 'L_NOTES' => LangLoader::get_message('notes', 'common'), 'L_COM' => $LANG['com_s'])); ##### Affichage des photos ##### if ($nbr_pics > 0) { switch ($g_type) { case 'name': $sort_type = 'g.name'; break; case 'date': $sort_type = 'g.timestamp'; break; case 'views': $sort_type = 'g.views'; break; case 'notes': $sort_type = 'notes.average_notes'; break; case 'com': $sort_type = 'com.number_comments'; break; default: $sort_type = 'g.timestamp'; } switch ($g_mode) { case 'desc': $sort_mode = 'DESC'; break; case 'asc': $sort_mode = 'ASC'; break; default: $sort_mode = 'DESC'; } $g_sql_sort = ' ORDER BY ' . $sort_type . ' ' . $sort_mode; if ($g_views) { $g_sql_sort = ' ORDER BY g.views DESC'; } elseif ($g_notes) { $g_sql_sort = ' ORDER BY notes.average_notes DESC'; } $this->tpl->put('C_GALLERY_PICS', true); //Affichage d'une photo demandée. if (!empty($g_idpics)) { $info_pics = $this->db_querier->select_single_row_query("SELECT g.*, m.display_name, m.groups, m.level, notes.average_notes, notes.number_notes, note.note\n\t\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = g.user_id\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com ON com.id_in_module = g.id AND com.module_id = 'gallery'\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_AVERAGE_NOTES . " notes ON notes.id_in_module = g.id AND notes.module_name = 'gallery'\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_NOTE . " note ON note.id_in_module = g.id AND note.module_name = 'gallery' AND note.user_id = :user_id\n\t\t\t\t\tWHERE g.idcat = :idcat AND g.id = :id AND g.aprob = 1\n\t\t\t\t\t" . $g_sql_sort, array('user_id' => AppContext::get_current_user()->get_id(), 'idcat' => $category->get_id(), 'id' => $g_idpics)); if (!empty($info_pics['id'])) { $Bread_crumb->add(stripslashes($info_pics['name']), PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $info_pics['idcat'] . '&id=' . $info_pics['id'], '-' . $info_pics['idcat'] . '-' . $info_pics['id'] . '.php')); //Affichage miniatures. $id_previous = 0; $id_next = 0; $nbr_pics_display_before = floor(($nbr_column_pics - 1) / 2); //Nombres de photos de chaque côté de la miniature de la photo affichée. $nbr_pics_display_after = $nbr_column_pics - 1 - floor($nbr_pics_display_before); list($i, $reach_pics_pos, $pos_pics, $thumbnails_before, $thumbnails_after, $start_thumbnails, $end_thumbnails) = array(0, false, 0, 0, 0, $nbr_pics_display_before, $nbr_pics_display_after); $array_pics = array(); $array_js = 'var array_pics = new Array();'; $result = $this->db_querier->select("SELECT g.id, g.idcat, g.path\n\t\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\t\tWHERE g.idcat = :idcat AND g.aprob = 1\n\t\t\t\t\t" . $g_sql_sort, array('idcat' => $category->get_id())); while ($row = $result->fetch()) { //Si la miniature n'existe pas (cache vidé) on regénère la miniature à partir de l'image en taille réelle. if (!file_exists(PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'])) { $Gallery->Resize_pics(PATH_TO_ROOT . '/gallery/pics/' . $row['path']); } //Redimensionnement + création miniature //Affichage de la liste des miniatures sous l'image. $array_pics[] = '<td class="center" style="height:' . ($config->get_mini_max_height() + 16) . 'px"><span id="thumb' . $i . '"><a href="gallery' . url('.php?cat=' . $row['idcat'] . '&id=' . $row['id'] . '&sort=' . $g_sort, '-' . $row['idcat'] . '-' . $row['id'] . '.php?sort=' . $g_sort) . '#pics_max' . '"><img src="pics/thumbnails/' . $row['path'] . '" alt="' . $row['path'] . '" /></a></span></td>'; if ($row['id'] == $g_idpics) { $reach_pics_pos = true; $pos_pics = $i; } else { if (!$reach_pics_pos) { $thumbnails_before++; $id_previous = $row['id']; } else { $thumbnails_after++; if (empty($id_next)) { $id_next = $row['id']; } } } $array_js .= 'array_pics[' . $i . '] = new Array();' . "\n"; $array_js .= 'array_pics[' . $i . '][\'link\'] = \'' . GalleryUrlBuilder::get_link_item($row['idcat'], $row['id']) . '#pics_max' . "';\n"; $array_js .= 'array_pics[' . $i . '][\'path\'] = \'' . $row['path'] . "';\n"; $i++; } $result->dispose(); $activ_note = $config->is_notation_enabled() && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL); if ($activ_note) { //Affichage notation. $notation = new Notation(); $notation->set_module_name('gallery'); $notation->set_id_in_module($info_pics['id']); $notation->set_notation_scale($config->get_notation_scale()); $notation->set_number_notes($info_pics['number_notes']); $notation->set_average_notes($info_pics['average_notes']); $notation->set_user_already_noted(!empty($info_pics['note'])); } if ($thumbnails_before < $nbr_pics_display_before) { $end_thumbnails += $nbr_pics_display_before - $thumbnails_before; } if ($thumbnails_after < $nbr_pics_display_after) { $start_thumbnails += $nbr_pics_display_after - $thumbnails_after; } $html_protected_name = $info_pics['name']; $comments_topic->set_id_in_module($info_pics['id']); $comments_topic->set_url(new Url('/gallery/gallery.php?cat=' . $category->get_id() . '&id=' . $g_idpics . '&com=0')); //Liste des catégories. $search_category_children_options = new SearchCategoryChildrensOptions(); $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS); $search_category_children_options->add_authorizations_bits(Category::WRITE_AUTHORIZATIONS); $categories_tree = GalleryService::get_categories_manager()->get_select_categories_form_field($info_pics['id'] . 'cat', '', $info_pics['idcat'], $search_category_children_options); $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options'); $method->setAccessible(true); $categories_tree_options = $method->invoke($categories_tree); $cat_list = ''; foreach ($categories_tree_options as $option) { $cat_list .= $option->display()->render(); } $group_color = User::get_group_color($info_pics['groups'], $info_pics['level']); //Affichage de l'image et de ses informations. $this->tpl->put_all(array('C_GALLERY_PICS_MAX' => true, 'C_GALLERY_PICS_MODO' => $is_modo, 'C_AUTHOR_DISPLAYED' => $config->is_author_displayed(), 'C_VIEWS_COUNTER_ENABLED' => $config->is_views_counter_enabled(), 'C_TITLE_ENABLED' => $config->is_title_enabled(), 'C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_NOTATION_ENABLED' => $config->is_notation_enabled(), 'ID' => $info_pics['id'], 'NAME' => '<span id="fi_' . $info_pics['id'] . '">' . stripslashes($info_pics['name']) . '</span> <span id="fi' . $info_pics['id'] . '"></span>', 'POSTOR' => '<a class="small ' . UserService::get_level_class($info_pics['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . ' href="' . UserUrlBuilder::profile($info_pics['user_id'])->rel() . '">' . $info_pics['display_name'] . '</a>', 'DATE' => Date::to_format($info_pics['timestamp'], Date::FORMAT_DAY_MONTH_YEAR), 'VIEWS' => $info_pics['views'] + 1, 'DIMENSION' => $info_pics['width'] . ' x ' . $info_pics['height'], 'SIZE' => NumberHelper::round($info_pics['weight'] / 1024, 1), 'L_COMMENTS' => CommentsService::get_number_and_lang_comments('gallery', $info_pics['id']), 'KERNEL_NOTATION' => $activ_note ? NotationService::display_active_image($notation) : '', 'COLSPAN' => $config->get_columns_number() + 2, 'CAT' => $cat_list, 'RENAME' => $html_protected_name, 'RENAME_CUT' => $html_protected_name, 'IMG_APROB' => $info_pics['aprob'] == 1 ? 'fa fa-eye-slash' : 'fa fa-eye', 'ARRAY_JS' => $array_js, 'NBR_PICS' => $i - 1, 'MAX_START' => $i - 1 - $nbr_column_pics, 'START_THUMB' => $pos_pics - $start_thumbnails > 0 ? $pos_pics - $start_thumbnails : 0, 'END_THUMB' => $pos_pics + $end_thumbnails, 'L_KB' => LangLoader::get_message('unit.kilobytes', 'common'), 'L_INFORMATIONS' => $LANG['informations'], 'L_NAME' => $LANG['name'], 'L_POSTOR' => $LANG['postor'], 'L_VIEWS' => $LANG['views'], 'L_ADD_ON' => $LANG['add_on'], 'L_DIMENSION' => $LANG['dimension'], 'L_SIZE' => $LANG['size'], 'L_NOTE' => LangLoader::get_message('note', 'common'), 'L_COM' => $LANG['com'], 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_APROB_IMG' => $info_pics['aprob'] == 1 ? $LANG['unaprob'] : $LANG['aprob'], 'L_THUMBNAILS' => $LANG['thumbnails'], 'U_DEL' => url('gallery.php?del=' . $info_pics['id'] . '&token=' . AppContext::get_session()->get_token() . '&cat=' . $category->get_id()), 'U_MOVE' => url('gallery.php?id=' . $info_pics['id'] . '&token=' . AppContext::get_session()->get_token() . '&move=\' + this.options[this.selectedIndex].value'), 'U_PREVIOUS' => $pos_pics > 0 ? '<a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_previous) . '#pics_max"><i class="fa fa-arrow-left fa-2x"></i></a> <a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_previous) . '#pics_max">' . $LANG['previous'] . '</a>' : '', 'U_NEXT' => $pos_pics < $i - 1 ? '<a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_next) . '#pics_max">' . $LANG['next'] . '</a> <a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_next) . '#pics_max"><i class="fa fa-arrow-right fa-2x"></i></a>' : '', 'U_LEFT_THUMBNAILS' => $pos_pics - $start_thumbnails > 0 ? '<span id="display_left"><a href="javascript:display_thumbnails(\'left\')"><i class="fa fa-arrow-left fa-2x"></i></a></span>' : '<span id="display_left"></span>', 'U_RIGHT_THUMBNAILS' => $pos_pics - $start_thumbnails <= $i - 1 - $nbr_column_pics ? '<span id="display_right"><a href="javascript:display_thumbnails(\'right\')"><i class="fa fa-arrow-right fa-2x"></i></a></span>' : '<span id="display_right"></span>', 'U_COMMENTS' => GalleryUrlBuilder::get_link_item($info_pics['idcat'], $info_pics['id'], 0, $g_sort) . '#comments-list', 'U_IMG_MAX' => 'show_pics.php?id=' . $info_pics['id'] . '&cat=' . $info_pics['idcat'])); //Affichage de la liste des miniatures sous l'image. $i = 0; foreach ($array_pics as $pics) { if ($i >= $pos_pics - $start_thumbnails && $i <= $pos_pics + $end_thumbnails) { $this->tpl->assign_block_vars('list_preview_pics', array('PICS' => $pics)); } $i++; } //Commentaires if (AppContext::get_request()->get_getint('com', 0) == 0 && $config->are_comments_enabled()) { $this->tpl->put_all(array('COMMENTS' => CommentsService::display($comments_topic)->render())); } } } else { $sort = retrieve(GET, 'sort', ''); //On crée une pagination si le nombre de photos est trop important. $page = AppContext::get_request()->get_getint('pp', 1); $pagination = new ModulePagination($page, $nbr_pics, $config->get_pics_number_per_page()); $pagination->set_url(new Url('/gallery/gallery.php?pp=%d' . (!empty($sort) ? '&sort=' . $sort : '') . '&cat=' . $category->get_id())); if ($pagination->current_page_is_empty() && $page > 1) { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } $this->tpl->put_all(array('C_GALLERY_MODO' => $is_modo, 'C_PICTURE_NAME_DISPLAYED' => $config->is_title_enabled(), 'C_AUTHOR_DISPLAYED' => $config->is_author_displayed(), 'C_VIEWS_COUNTER_ENABLED' => $config->is_views_counter_enabled(), 'C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_VIEW' => $LANG['view'], 'L_VIEWS' => $LANG['views'])); $is_connected = AppContext::get_current_user()->check_level(User::MEMBER_LEVEL); $j = 0; $result = $this->db_querier->select("SELECT g.id, g.idcat, g.name, g.path, g.timestamp, g.aprob, g.width, g.height, g.user_id, g.views, g.aprob, m.display_name, m.groups, m.level, notes.average_notes, notes.number_notes, note.note\n\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = g.user_id\n\t\t\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com ON com.id_in_module = g.id AND com.module_id = 'gallery'\n\t\t\t\tLEFT JOIN " . DB_TABLE_AVERAGE_NOTES . " notes ON notes.id_in_module = g.id AND notes.module_name = 'gallery'\n\t\t\t\tLEFT JOIN " . DB_TABLE_NOTE . " note ON note.id_in_module = g.id AND note.module_name = 'gallery' AND note.user_id = :user_id\n\t\t\t\tWHERE g.idcat = :idcat AND g.aprob = 1\n\t\t\t\t" . $g_sql_sort . "\n\t\t\t\tLIMIT :number_items_per_page OFFSET :display_from", array('user_id' => AppContext::get_current_user()->get_id(), 'idcat' => $category->get_id(), 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())); while ($row = $result->fetch()) { //Si la miniature n'existe pas (cache vidé) on regénère la miniature à partir de l'image en taille réelle. if (!file_exists(PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'])) { $Gallery->Resize_pics(PATH_TO_ROOT . '/gallery/pics/' . $row['path']); } //Redimensionnement + création miniature $onclick = ''; //Affichage de l'image en grand. if ($config->get_pics_enlargement_mode() == GalleryConfig::FULL_SCREEN) { $display_link = PATH_TO_ROOT . '/gallery/pics/' . $row['path'] . '" onmousedown="increment_view(' . $row['id'] . ');" title="' . str_replace('"', '', stripslashes($row['name'])); } elseif ($config->get_pics_enlargement_mode() == GalleryConfig::POPUP) { $onclick = 'increment_view(' . $row['id'] . ');display_pics_popup(\'' . PATH_TO_ROOT . '/gallery/show_pics' . url('.php?id=' . $row['id'] . '&cat=' . $row['idcat']) . '\', \'' . $row['width'] . '\', \'' . $row['height'] . '\');return false;'; $display_link = ''; } elseif ($config->get_pics_enlargement_mode() == GalleryConfig::RESIZE) { $onclick = 'increment_view(' . $row['id'] . ');display_pics(' . $row['id'] . ', \'' . PATH_TO_ROOT . '/gallery/show_pics' . url('.php?id=' . $row['id'] . '&cat=' . $row['idcat']) . '\');return false;'; $display_link = ''; } else { $onclick = true; $display_link = url('gallery.php?cat=' . $row['idcat'] . '&id=' . $row['id'], 'gallery-' . $row['idcat'] . '-' . $row['id'] . '.php') . '#pics_max'; } //Liste des catégories. $search_category_children_options = new SearchCategoryChildrensOptions(); $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS); $search_category_children_options->add_authorizations_bits(Category::WRITE_AUTHORIZATIONS); $categories_tree = GalleryService::get_categories_manager()->get_select_categories_form_field($row['id'] . 'cat', '', $row['idcat'], $search_category_children_options); $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options'); $method->setAccessible(true); $categories_tree_options = $method->invoke($categories_tree); $cat_list = ''; foreach ($categories_tree_options as $option) { $cat_list .= $option->display()->render(); } $notation = new Notation(); $notation->set_module_name('gallery'); $notation->set_notation_scale($config->get_notation_scale()); $notation->set_id_in_module($row['id']); $notation->set_number_notes($row['number_notes']); $notation->set_average_notes($row['average_notes']); $notation->set_user_already_noted(!empty($row['note'])); $group_color = User::get_group_color($row['groups'], $row['level']); $comments_topic->set_id_in_module($row['id']); $html_protected_name = $row['name']; $this->tpl->assign_block_vars('pics_list', array('C_IMG_APROB' => $row['aprob'] == 1, 'C_OPEN_TR' => is_int($j++ / $nbr_column_pics), 'C_CLOSE_TR' => is_int($j / $nbr_column_pics), 'ID' => $row['id'], 'APROB' => $row['aprob'], 'PATH' => $row['path'], 'NAME' => stripslashes($row['name']), 'SHORT_NAME' => TextHelper::wordwrap_html(stripslashes($row['name']), 22, ' '), 'POSTOR' => $LANG['by'] . (!empty($row['display_name']) ? ' <a class="small ' . UserService::get_level_class($row['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . ' href="' . UserUrlBuilder::profile($row['user_id'])->rel() . '">' . $row['display_name'] . '</a>' : ' ' . $LANG['guest']), 'VIEWS' => $row['views'], 'L_VIEWS' => $row['views'] > 1 ? $LANG['views'] : $LANG['view'], 'L_COMMENTS' => CommentsService::get_number_and_lang_comments('gallery', $row['id']), 'KERNEL_NOTATION' => $config->is_notation_enabled() && $is_connected ? NotationService::display_active_image($notation) : NotationService::display_static_image($notation), 'CAT' => $cat_list, 'ONCLICK' => $onclick, 'RENAME' => $html_protected_name, 'RENAME_CUT' => $html_protected_name, 'L_APROB_IMG' => $row['aprob'] == 1 ? $LANG['unaprob'] : $LANG['aprob'], 'U_PICTURE_LINK' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $row['idcat'] . '&id=' . $row['id'], '-' . $row['idcat'] . '-' . $row['id'] . '.php'), 'U_PICTURE' => PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'], 'U_DEL' => url('gallery.php?del=' . $row['id'] . '&token=' . AppContext::get_session()->get_token() . '&cat=' . $category->get_id()), 'U_MOVE' => url('gallery.php?id=' . $row['id'] . '&token=' . AppContext::get_session()->get_token() . '&move=\' + this.options[this.selectedIndex].value'), 'U_DISPLAY' => $display_link, 'U_COMMENTS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $row['idcat'] . '&id=' . $row['id'] . '&com=0', '-' . $row['idcat'] . '-' . $row['id'] . '.php?com=0') . '#comments-list')); } $result->dispose(); //Création des cellules du tableau si besoin est. while (!is_int($j / $nbr_column_pics)) { $this->tpl->assign_block_vars('end_table', array('TD_END' => '<td class="td-end" style="width:' . $column_width_pics . '%"> </td>', 'TR_END' => is_int(++$j / $nbr_column_pics) ? '</tr>' : '')); } } } }
/** * @desc This function required object Notation containing the module_name, id_in_module, user_id, note and notation_scale. * @param object $notation Notation */ public static function display_active_image(Notation $notation) { $note_post = AppContext::get_request()->get_int('note', 0); $id_post = AppContext::get_request()->get_int('id', 0); if (!empty($note_post) && !empty($id_post)) { $notation->set_id_in_module($id_post); $notation->set_note($note_post); self::register_notation($notation); } else { $template = new FileTemplate('framework/content/notation/notation.tpl'); $average_notes = $notation->get_average_notes(); $int = intval($average_notes); $decimal = floatval('0.' . substr($average_notes, strpos($average_notes, '.') + 1)); for ($i = 1; $i <= $notation->get_notation_scale(); $i++) { $star_full = false; $star_half = false; $star_empty = false; if ($int >= $i || $int + 1 == $i && $decimal >= 0.75) { $star_full = true; } else { if ($int + 1 == $i && $decimal > 0.25 && $decimal < 0.75) { $star_half = true; } else { $star_empty = true; } } $template->assign_block_vars('star', array('I' => $i, 'STAR_EMPTY' => $star_empty, 'STAR_HALF' => $star_half, 'STAR_FULL' => $star_full)); } $count_notes = $notation->get_number_notes(); $template->put_all(array('C_JS_NOT_ALREADY_INCLUDED' => !self::$js_already_included, 'C_NOTES' => $count_notes > 0 ? true : false, 'C_MORE_1_NOTES' => $count_notes > 1 ? true : false, 'CURRENT_URL' => REWRITED_SCRIPT, 'ID_IN_MODULE' => $notation->get_id_in_module(), 'NOTATION_SCALE' => $notation->get_notation_scale(), 'NUMBER_NOTES' => $count_notes, 'AVERAGE_NOTES' => $average_notes, 'ALREADY_NOTE' => $notation->user_already_noted(), 'L_NO_NOTE' => LangLoader::get_message('no_note', 'common'), 'L_AUTH_ERROR' => LangLoader::get_message('error.auth', 'status-messages-common'), 'L_ALREADY_NOTE' => self::$lang['already_vote'], 'L_NOTES' => LangLoader::get_message('notes', 'common'), 'L_NOTE' => LangLoader::get_message('note', 'common'), 'L_VALID_NOTE' => LangLoader::get_message('add_note', 'common'))); self::$js_already_included = true; return $template->render(); } }
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(); }
public function set_properties(array $properties) { $this->id = $properties['id']; $this->id_category = $properties['id_category']; $this->name = $properties['name']; $this->rewrited_name = $properties['rewrited_name']; $this->url = new Url($properties['url']); $this->contents = $properties['contents']; $this->short_contents = $properties['short_contents']; $this->approbation_type = $properties['approbation_type']; $this->start_date = !empty($properties['start_date']) ? new Date($properties['start_date'], Timezone::SERVER_TIMEZONE) : null; $this->end_date = !empty($properties['end_date']) ? new Date($properties['end_date'], Timezone::SERVER_TIMEZONE) : null; $this->end_date_enabled = !empty($properties['end_date']); $this->creation_date = new Date($properties['creation_date'], Timezone::SERVER_TIMEZONE); $this->number_views = $properties['number_views']; $this->partner = (bool) $properties['partner']; $this->partner_picture = new Url($properties['partner_picture']); $this->privileged_partner = (bool) $properties['privileged_partner']; $user = new User(); if (!empty($properties['user_id'])) { $user->set_properties($properties); } else { $user->init_visitor_user(); } $this->set_author_user($user); $notation = new Notation(); $notation->set_module_name('web'); $notation->set_notation_scale(WebConfig::load()->get_notation_scale()); $notation->set_id_in_module($properties['id']); $notation->set_number_notes($properties['number_notes']); $notation->set_average_notes($properties['average_notes']); $notation->set_user_already_noted(!empty($properties['note'])); $this->notation = $notation; }
$controller = new UserErrorController(LangLoader::get_message('error', 'status-messages-common'), $LANG['e_unexist_media']); DispatchManager::redirect($controller); } elseif (!MediaAuthorizationsService::check_authorizations($media['idcat'])->read()) { $error_controller = PHPBoostErrors::user_not_authorized(); DispatchManager::redirect($error_controller); } 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) {
public function set_properties(array $properties) { $this->set_id($properties['id']); $this->set_id_category($properties['id_category']); $this->set_title($properties['title']); $this->set_rewrited_title($properties['rewrited_title']); $this->set_description($properties['description']); $this->set_contents($properties['contents']); $this->set_picture(new Url($properties['picture_url'])); $this->set_number_view($properties['number_view']); $this->set_author_name_displayed($properties['author_name_displayed']); $this->set_publishing_state($properties['published']); $this->publishing_start_date = !empty($properties['publishing_start_date']) ? new Date($properties['publishing_start_date'], Timezone::SERVER_TIMEZONE) : null; $this->publishing_end_date = !empty($properties['publishing_end_date']) ? new Date($properties['publishing_end_date'], Timezone::SERVER_TIMEZONE) : null; $this->end_date_enabled = !empty($properties['publishing_end_date']); $this->set_date_created(new Date($properties['date_created'], Timezone::SERVER_TIMEZONE)); $this->date_updated = !empty($properties['date_updated']) ? new Date($properties['date_updated'], Timezone::SERVER_TIMEZONE) : null; $this->set_notation_enabled($properties['notation_enabled']); $this->set_sources(!empty($properties['sources']) ? unserialize($properties['sources']) : array()); $user = new User(); if (!empty($properties['user_id'])) { $user->set_properties($properties); } else { $user->init_visitor_user(); } $this->set_author_user($user); $notation = new Notation(); $notation->set_module_name('articles'); $notation->set_notation_scale(ArticlesConfig::load()->get_notation_scale()); $notation->set_id_in_module($properties['id']); $notation->set_number_notes($properties['number_notes']); $notation->set_average_notes($properties['average_notes']); $notation->set_user_already_noted(!empty($properties['note'])); $this->notation = $notation; }