PageRenderTime 49ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/album.php

http://github.com/MightyGorgon/icy_phoenix
PHP | 260 lines | 169 code | 35 blank | 56 comment | 44 complexity | 8ee4ba6f8bc91436220754265c99eaef MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. /**
  3. *
  4. * @package Icy Phoenix
  5. * @version $Id$
  6. * @copyright (c) 2008 Icy Phoenix
  7. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8. *
  9. */
  10. /**
  11. *
  12. * @Extra credits for this file
  13. * Smartor (smartor_xp@hotmail.com)
  14. *
  15. */
  16. define('IN_ICYPHOENIX', true);
  17. if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', './');
  18. if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
  19. include(IP_ROOT_PATH . 'common.' . PHP_EXT);
  20. // Start session management
  21. $user->session_begin();
  22. $auth->acl($user->data);
  23. $user->setup();
  24. // End session management
  25. // Get general album information
  26. include(ALBUM_MOD_PATH . 'album_common.' . PHP_EXT);
  27. // ------------------------------------
  28. // Check $album_user_id
  29. // ------------------------------------
  30. $album_user_id = request_var('user_id', 0);
  31. if (empty($album_user_id))
  32. {
  33. // if no user_id was supplied then we aren't going to show a personal gallery category
  34. $album_user_id = ALBUM_PUBLIC_GALLERY;
  35. }
  36. if ($album_user_id != ALBUM_PUBLIC_GALLERY)
  37. {
  38. $mode = request_var('mode', '', true);
  39. $album_view_mode = strtolower($mode);
  40. // make sure that it only contains some valid value
  41. switch ($album_view_mode)
  42. {
  43. case ALBUM_VIEW_ALL:
  44. $album_view_mode = ALBUM_VIEW_ALL;
  45. break;
  46. case ALBUM_VIEW_LIST:
  47. $album_view_mode = ALBUM_VIEW_LIST;
  48. break;
  49. default:
  50. $album_view_mode = '';
  51. }
  52. $cat_id = request_var('cat_id', 0);
  53. if ($cat_id <= 0)
  54. {
  55. $cat_id = ALBUM_ROOT_CATEGORY;
  56. }
  57. if ($album_user_id < 1)
  58. {
  59. if (!$user->data['session_logged_in'])
  60. {
  61. redirect(append_sid(album_append_uid(CMS_PAGE_LOGIN . '?redirect=album.' . PHP_EXT, true)));
  62. }
  63. else
  64. {
  65. $album_user_id = $user->data['user_id'];
  66. redirect(append_sid(album_append_uid('album.' . PHP_EXT, true)));
  67. }
  68. }
  69. if (($cat_id != ALBUM_ROOT_CATEGORY) && ($cat_id != album_get_personal_root_id($album_user_id)))
  70. {
  71. redirect(append_sid(album_append_uid('album_cat.' . PHP_EXT . album_build_url_parameters($_GET), false)));
  72. }
  73. }
  74. $catrows = array();
  75. $options = ($album_view_mode == ALBUM_VIEW_LIST) ? ALBUM_READ_ALL_CATEGORIES | ALBUM_AUTH_VIEW : ALBUM_AUTH_VIEW;
  76. $catrows = album_read_tree($album_user_id, $options);
  77. // Mighty Gorgon: is this really needed? Maybe not... let's keep it commented until someone complains!!!
  78. //album_read_tree($album_user_id);
  79. $album_nav_cat_desc = album_make_nav_tree($cat_id, 'album_cat.' . PHP_EXT, 'nav' , $album_user_id);
  80. if ($album_nav_cat_desc != '')
  81. {
  82. $nav_server_url = create_server_url();
  83. $album_nav_cat_desc = ALBUM_NAV_ARROW . $album_nav_cat_desc;
  84. $breadcrumbs['address'] = ALBUM_NAV_ARROW . '<a href="' . $nav_server_url . append_sid('album.' . PHP_EXT) . '">' . $lang['Album'] . '</a>' . $album_nav_cat_desc;
  85. }
  86. // --------------------------------
  87. // Build allowed category-list (for recent pics after here)
  88. // $catrows array now stores all categories which this user can view.
  89. // --------------------------------
  90. $allowed_cat = ''; // For Recent Public Pics below
  91. for ($i = 0; $i < sizeof($catrows); $i++)
  92. {
  93. // --------------------------------
  94. // build list of allowd category id's
  95. // --------------------------------
  96. $allowed_cat .= ($allowed_cat == '') ? $catrows[$i]['cat_id'] : ',' . $catrows[$i]['cat_id'];
  97. }
  98. //
  99. // END of Categories Index
  100. //
  101. // ------------------------------------
  102. // Build the sort method and sort order
  103. // information
  104. // ------------------------------------
  105. $start = request_var('start', 0);
  106. $start = ($start < 0) ? 0 : $start;
  107. $sort_method = request_var('sort_method', $album_config['sort_method']);
  108. $sort_method = check_var_value($sort_method, array('pic_time', 'pic_title', 'username', 'pic_view_count', 'rating', 'comments', 'new_comment'));
  109. $sort_order = request_var('sort_order', $album_config['sort_order']);
  110. $sort_order = check_var_value($sort_order, array('DESC', 'ASC'));
  111. $sort_append = '&amp;sort_method=' . $sort_method . '&amp;sort_order=' . $sort_order;
  112. // ------------------------------------
  113. // additional sorting options
  114. // ------------------------------------
  115. if ($album_user_id != ALBUM_PUBLIC_GALLERY)
  116. {
  117. $sort_rating_option = '';
  118. $sort_comments_option = '';
  119. $sort_new_comment_option = '';
  120. if ($album_config['rate'] == 1)
  121. {
  122. $sort_rating_option = '<option value="rating" ';
  123. $sort_rating_option .= ($sort_method == 'rating') ? 'selected="selected"' : '';
  124. $sort_rating_option .= '>' . $lang['Rating'] . '</option>';
  125. }
  126. if ($album_config['comment'] == 1)
  127. {
  128. $sort_comments_option = '<option value="comments" ';
  129. $sort_comments_option .= ($sort_method == 'comments') ? 'selected="selected"' : '';
  130. $sort_comments_option .= '>' . $lang['Comments'] . '</option>';
  131. $sort_new_comment_option = '<option value="new_comment" ';
  132. $sort_new_comment_option .= ($sort_method == 'new_comment') ? 'selected="selected"' : '';
  133. $sort_new_comment_option .= '>' . $lang['New_Comment'] . '</option>';
  134. }
  135. }
  136. /*
  137. +----------------------------------------------------------
  138. | Start output the page
  139. +----------------------------------------------------------
  140. */
  141. $meta_content['page_title'] = $lang['Album'];
  142. $meta_content['description'] = '';
  143. $meta_content['keywords'] = '';
  144. // is it a public gallery ?
  145. if ($album_user_id == ALBUM_PUBLIC_GALLERY)
  146. {
  147. $template_to_parse = 'album_index_body.tpl';
  148. $cols = ($album_config['img_cols'] == 0 ? 4 : $album_config['img_cols']);
  149. $cols_width = (100 / $cols) . '%';
  150. // Last Comments
  151. if ($album_config['show_last_comments'] == 1)
  152. {
  153. album_build_last_comments_info($allowed_cat);
  154. }
  155. // Recent Public Pics
  156. if ($album_config['disp_late'] == 1)
  157. {
  158. album_build_recent_pics($allowed_cat);
  159. }
  160. // Highest Rated Pics
  161. if ($album_config['disp_high'] == 1)
  162. {
  163. album_build_highest_rated_pics($allowed_cat);
  164. }
  165. // Most Viewed Pics
  166. if ($album_config['disp_mostv'] == 1)
  167. {
  168. album_build_most_viewed_pics($allowed_cat);
  169. }
  170. //Random Pics
  171. if ($album_config['disp_rand'] == 1)
  172. {
  173. album_build_random_pics($allowed_cat);
  174. }
  175. $template->assign_vars(array(
  176. 'BREADCRUMBS_ADDRESS' => (empty($breadcrumbs['address']) ? (($meta_content['page_title_clean'] != $config['sitename']) ? ($lang['Nav_Separator'] . '<a href="#" class="nav-current">' . $meta_content['page_title_clean'] . '</a>') : '') : $breadcrumbs['address']),
  177. 'ALBUM_NAV' => $album_nav_cat_desc,
  178. 'S_COLS' => $cols,
  179. 'S_COL_WIDTH' => $cols_width,
  180. 'S_THUMBNAIL_SIZE' => $album_config['thumbnail_size'],
  181. 'TARGET_BLANK' => ($album_config['fullpic_popup']) ? 'target="_blank"' : '',
  182. 'L_RAND_PICS' => $lang['Random_Pictures'],
  183. 'L_HI_RATINGS' => $lang['Highest_Rated_Pictures'],
  184. 'L_RECENT_PUBLIC_PICS' => $lang['Recent_Public_Pics'],
  185. 'L_MOST_VIEWED' => $lang['Most_Viewed_Pictures'],
  186. 'L_NO_PICS' => $lang['No_Pics'],
  187. 'L_PIC_TITLE' => $lang['Pic_Image'],
  188. 'L_PIC_ID' => $lang['Pic_ID'],
  189. 'L_VIEW' => $lang['View'],
  190. 'L_POSTER' => $lang['Pic_Poster'],
  191. 'L_POSTED' => $lang['Posted'],
  192. 'L_ALBUM_ALLPICS' => $lang['All_Picture_List_Of_User'],
  193. 'L_ALBUM_OTF' => $lang['Pic_Gallery'],
  194. 'L_ALBUM_HON' => $lang['Hot_Or_Not'],
  195. 'L_ALBUM_RDF' => $lang['Pic_RDF'],
  196. 'L_ALBUM_RSS' => $lang['Pic_RSS'],
  197. 'U_ALBUM_ALLPICS' => append_sid(album_append_uid('album_allpics.' . PHP_EXT)),
  198. 'U_ALBUM_OTF' => append_sid(album_append_uid('album_otf.' . PHP_EXT)),
  199. 'U_ALBUM_HON' => append_sid(album_append_uid('album_hotornot.' . PHP_EXT)),
  200. 'U_ALBUM_RDF' => append_sid(album_append_uid('album_rdf.' . PHP_EXT)),
  201. 'U_ALBUM_RSS' => append_sid(album_append_uid('album_rss.' . PHP_EXT)),
  202. )
  203. );
  204. }
  205. // it's a personal gallery, and in the root folder
  206. else
  207. {
  208. if ($album_view_mode == ALBUM_VIEW_LIST)
  209. {
  210. include(ALBUM_MOD_PATH . 'album_memberlist.' . PHP_EXT);
  211. }
  212. else
  213. {
  214. // include our special personal gallery files
  215. // this file holds all the code to handle personal galleries
  216. // except moderation and management of personal gallery categories.
  217. include(ALBUM_MOD_PATH . 'album_personal.' . PHP_EXT);
  218. }
  219. }
  220. if (empty($album_view_mode))
  221. {
  222. album_display_index($album_user_id, ALBUM_ROOT_CATEGORY, true, true, true);
  223. }
  224. full_page_generation($template_to_parse, $meta_content['page_title'], $meta_content['description'], $meta_content['keywords']);
  225. ?>