private function create_navigation_cats($cats_uri_rows, $base_url, $type) { if (empty($cats_uri_rows)) { $sub_cats = $this->browse_model->get_sub_categories(NULL, $type); $cats = create_hierarchical_sub_cats($base_url, $sub_cats); return $this->generate_nav_list($cats, $base_url); } else { $last_row = end($cats_uri_rows); $last_but_one_row = prev($cats_uri_rows); // czy ostatni segment sciezki jest rodzicem dla innych kategorii if ($this->browse_model->sub_cats_exist($last_row['id'], $type)) { //potomkowie ostatniego segmentu występują... //pobierz potomkow ostatniego segmentu sciezki $sub_cats = $this->browse_model->get_sub_categories($last_row['id'], $type); $path = create_hierarchical_path($base_url, $cats_uri_rows); $cats = create_hierarchical_sub_cats($base_url, $sub_cats, NULL, $cats_uri_rows); return $this->generate_nav_list($cats, $base_url, $path, true); } else { //potomkowie ostatniego segmentu nie występują... if (count($cats_uri_rows) == 1) { //pobierz główne kategorie id rodzica == NULL $sub_cats = $this->browse_model->get_sub_categories(NULL, $type); $cats = create_hierarchical_sub_cats($base_url, $sub_cats, $last_row['id']); return $this->generate_nav_list($cats, $base_url, array(), true); } else { //pobierz potomkow przedostatniego segmentu sciezki kategorii $sub_cats = $this->browse_model->get_sub_categories($last_but_one_row['id'], $type); // usun ostatni element w sciezce kategorii - wymagane by zbudowac prawidlowa sciezke array_pop($cats_uri_rows); $path = create_hierarchical_path($base_url, $cats_uri_rows); $cats = create_hierarchical_sub_cats($base_url, $sub_cats, $last_row['id'], $cats_uri_rows); return $this->generate_nav_list($cats, $base_url, $path, true); } } } }
public function view($gallery_id = 0, $current_image_index = 1, $name = '') { $this->load->model('browse_model'); $this->load->model('comments_model'); $this->load->model('evaluations_model'); $this->load->library('typography'); $this->load->helper(array('urllinker', 'urlslug', 'browse')); if (($gallery = $this->browse_model->get_gallery(intval($gallery_id))) === FALSE) { show_error("Galeria nie występuje...", 404, 'Błąd!'); } if (($current_page = $this->current_page(5)) === FALSE) { show_error("Strona nie występuje...", 404, 'Błąd!'); } $current_image_index = intval($current_image_index); $gallery_images = $this->browse_model->get_gallery_images($gallery_id); if ($current_image_index < 1 || $current_image_index > count($gallery_images)) { show_error("Brak pracy w galerii...", 404, 'Błąd!'); } $this->data['adult_user'] = $this->adult_user; $all_gallery_comments = $this->comments_model->counts_gallery_comments($gallery_id); if ($all_gallery_comments > 0) { $last_page = ceil($all_gallery_comments / $this->gallery_comments_config['page_size']); if ($current_page > $last_page) { $current_page = $last_page; } $gallery_comments = $this->comments_model->get_gallery_comments($gallery_id, $this->gallery_comments_config['page_size'], $current_page); foreach ($gallery_comments as &$gallery_comment) { $gallery_comment->comment = $this->typography->auto_typography(htmlEscapeAndLinkUrls($gallery_comment->comment), TRUE); $gallery_comment->signature = $this->typography->auto_typography(htmlEscapeAndLinkUrls($gallery_comment->signature), TRUE); } $this->data['object_comments'] = $gallery_comments; $this->data['pagination_links'] = $this->pagination_links("/gallery/view/{$gallery_id}/" . $current_image_index, $this->gallery_comments_config['page_size'], $all_gallery_comments, 5); } else { $this->data['object_comments'] = array(); } $this->data['can_comment'] = $gallery->can_comment; $this->data['comment_object_owner'] = $gallery->user_id; $this->data['can_evaluate'] = $gallery->can_evaluate; $this->data['gallery_images'] = $gallery_images; $this->data['current_image_index'] = $current_image_index; $this->data['preview_image'] = $gallery_images[$current_image_index - 1]; if ($current_image_index - 1 > 0) { $this->data['previous_image_index'] = $current_image_index - 1; } if ($current_image_index + 1 <= count($this->data['gallery_images'])) { $this->data['next_image_index'] = $current_image_index + 1; } $cats_uri_rows = $this->browse_model->get_cats_uri_rows($this->browse_model->build_path_cats($gallery->category_id, 'galleries'), 'galleries'); $this->data['gallery_cats_path'] = create_hierarchical_path(base_url() . 'browse/galleries/', $cats_uri_rows); $cats_uri_rows = $this->browse_model->get_cats_uri_rows($this->browse_model->build_path_cats($gallery_images[$current_image_index - 1]->category_id, 'images'), 'images'); $this->data['current_image_cats_path'] = create_hierarchical_path(base_url() . 'browse/images/', $cats_uri_rows); $this->data['user_gallery'] = $this->browse_model->get_user($gallery->user_id); $this->data['gallery'] = $gallery; if ($this->ion_auth->logged_in()) { $logged_in_user = $this->ion_auth->user()->row(); $this->data['logged_in_user'] = $logged_in_user; $this->data['object_rated'] = $this->evaluations_model->rated_gallery($gallery->id, $logged_in_user->id); } $this->data['thumb_mini_config'] = $this->config->item('thumb_mini', 'digallery'); $this->data['thumb_preview_config'] = $this->config->item('thumb_preview', 'digallery'); $this->data['avatars_config'] = $this->config->item('avatar', 'digallery'); $this->data['name_of_ratings'] = $this->config->item('name_of_ratings', 'digallery'); $this->data['js'][] = 'comments.js'; $this->data['js'][] = 'jquery.jcarousel.min.0.2.8.js'; //$this->data['js'][] = 'jquery.jcarousel.min.0.3.0.js'; $this->data['js'][] = 'gallery_view.js'; $this->render(); }
public function preview($image_id = 0, $name = '') { $this->load->model('browse_model'); $this->load->model('comments_model'); $this->load->model('evaluations_model'); $this->load->library('typography'); $this->load->helper(array('browse', 'urllinker', 'urlslug')); if (($image = $this->browse_model->get_image(intval($image_id))) === FALSE) { show_error("Praca nie występuje...", 404, 'Błąd!'); } if (($current_page = $this->current_page(4)) === FALSE) { show_error("Strona nie występuje...", 404, 'Błąd!'); } $this->data['adult_user'] = $this->adult_user; $this->data['previous_image_id_name'] = $this->browse_model->get_user_prev_image_id_name($image->user_id, $image->id); $this->data['next_image_id_name'] = $this->browse_model->get_user_next_image_id_name($image->user_id, $image->id); $all_image_comments = $this->comments_model->counts_image_comments($image_id); if ($all_image_comments > 0) { $last_page = ceil($all_image_comments / $this->image_comments_config['page_size']); if ($current_page > $last_page) { $current_page = $last_page; } $image_comments = $this->comments_model->get_image_comments($image_id, $this->image_comments_config['page_size'], $current_page); foreach ($image_comments as &$image_comment) { $image_comment->comment = $this->typography->auto_typography(htmlEscapeAndLinkUrls($image_comment->comment), TRUE); $image_comment->signature = $this->typography->auto_typography(htmlEscapeAndLinkUrls($image_comment->signature), TRUE); } $this->data['object_comments'] = $image_comments; $this->data['pagination_links'] = $this->pagination_links("/image/preview/{$image_id}/", $this->image_comments_config['page_size'], $all_image_comments, 4); } else { $this->data['object_comments'] = array(); } $this->data['can_comment'] = $image->can_comment; $this->data['comment_object_owner'] = $image->user_id; $this->data['can_evaluate'] = $image->can_evaluated; $cats_uri_rows = $this->browse_model->get_cats_uri_rows($this->browse_model->build_path_cats($image->category_id, 'images'), 'images'); $cats_path = create_hierarchical_path(base_url() . 'browse/images/', $cats_uri_rows); $user_image = $this->browse_model->get_user($image->user_id); $this->data['number_views'] = $this->browse_model->counts_views($image->id); $this->data['number_views_today'] = $this->browse_model->counts_views_today($image->id); $this->increment_views($image->id); $this->data['number_downloads'] = $this->browse_model->counts_downloads($image->id); $this->data['number_downloads_today'] = $this->browse_model->counts_downloads_today($image->id); //$this->browse_model->increment_downloads($image->id); $this->data['user_image'] = $user_image; $this->data['thumbs_mini'] = $this->browse_model->get_thumb_images(0, 0, 'dd', $image->user_id, 1, 8); $this->data['preview_image'] = $image; $this->data['cats_path'] = $cats_path; $this->data['number_favs'] = $this->browse_model->counts_favorites($image->id); $this->data['number_favs_today'] = $this->browse_model->counts_favorites_today($image->id); if ($this->ion_auth->logged_in()) { $logged_in_user = $this->ion_auth->user()->row(); $this->data['logged_in_user'] = $logged_in_user; $this->data['image_added_to_favs'] = $this->browse_model->added_to_favorites($image_id, $logged_in_user->id); $this->data['object_rated'] = $this->evaluations_model->rated_image($image->id, $logged_in_user->id); } $this->data['thumb_mini_config'] = $this->config->item('thumb_mini', 'digallery'); $this->data['thumb_preview_config'] = $this->config->item('thumb_preview', 'digallery'); $this->data['avatars_config'] = $this->config->item('avatar', 'digallery'); if ($image->plus_18 && !$this->adult_user && !(isset($logged_in_user) && $logged_in_user->id === $image->user_id)) { $this->data['adult_filter'] = TRUE; } else { $this->data['adult_filter'] = FALSE; } $this->data['js'][] = 'comments.js'; $this->data['js'][] = 'preview.js'; $this->data['name_of_ratings'] = $this->config->item('name_of_ratings', 'digallery'); $this->render(); }