ossn.lib.initialize.php
Go to the documentation of this file.
1 <?php
2 /**
3  * Open Source Social Network
4  *
5  * @package (Informatikon.com).ossn
6  * @author OSSN Core Team <[email protected]>
7  * @copyright 2014 iNFORMATIKON TECHNOLOGIES
8  * @license General Public Licence http://www.opensource-socialnetwork.org/licence
9  * @link http://www.opensource-socialnetwork.org/licence
10  */
11 
12 //register all available language
14 foreach($available_languages as $language){
15  ossn_register_language($language, ossn_route()->locale . "ossn.{$language}.php");
16 }
18 /**
19  * Initialize the css library
20  *
21  * @return void
22  */
23 function ossn_initialize() {
24  $url = ossn_site_url();
25 
26  $icon = ossn_site_url('components/OssnWall/images/news-feed.png');
27  ossn_register_sections_menu('newsfeed', array(
28  'text' => ossn_print('news:feed'),
29  'url' => "{$url}home",
30  'section' => 'links',
31  'icon' => $icon
32  ));
33  ossn_extend_view('ossn/js/head', 'javascripts/head');
34  ossn_extend_view('ossn/admin/js/head', 'javascripts/head');
35  //actions
36  ossn_register_action('user/login', ossn_route()->actions . 'user/login.php');
37  ossn_register_action('user/register', ossn_route()->actions . 'user/register.php');
38  ossn_register_action('user/logout', ossn_route()->actions . 'user/logout.php');
39 
40  ossn_register_action('friend/add', ossn_route()->actions . 'friend/add.php');
41  ossn_register_action('friend/remove', ossn_route()->actions . 'friend/remove.php');
42  ossn_register_action('resetpassword', ossn_route()->actions . 'user/resetpassword.php');
43  ossn_register_action('resetlogin', ossn_route()->actions . 'user/resetlogin.php');
44 
45 
46  ossn_register_page('index', 'ossn_index_pagehandler');
47  ossn_register_page('home', 'ossn_user_pagehandler');
48  ossn_register_page('login', 'ossn_user_pagehandler');
49  ossn_register_page('registered', 'ossn_user_pagehandler');
50  ossn_register_page('syserror', 'ossn_system_error_pagehandler');
51 
52  ossn_register_page('resetlogin', 'ossn_user_pagehandler');
53 
54  ossn_add_hook('newsfeed', "sidebar:left", 'newfeed_menu_handler');
55 }
56 
57 /**
58  * Add left menu to newsfeed page
59  *
60  * @return menu
61  */
62 function newfeed_menu_handler($hook, $type, $return) {
63  $return[] = ossn_view_sections_menu('newsfeed');
64  return $return;
65 }
66 
67 /**
68  * System Errors
69  * @pages:
70  * unknown,
71  *
72  * @return boolean|null
73  */
75  $page = $pages[0];
76  if (empty($page)) {
77  $page = 'unknown';
78  }
79  switch ($page) {
80  case 'unknown':
81  $error = "<div class='ossn-ajax-error'>" . ossn_print('system:error:text') . "</div>";
82  $params = array(
83  'title' => ossn_print('system:error:title'),
84  'contents' => $error,
85  'callback' => false,
86  );
87  echo ossn_plugin_view('output/ossnbox', $params);
88  break;
89  }
90 }
91 
92 /**
93  * Register basic pages
94  * @pages:
95  * home,
96  * login,
97  * registered
98  *
99  * @return mixed contents
100  */
101 function ossn_user_pagehandler($home, $handler) {
102  switch ($handler) {
103  case 'home':
104  if (!ossn_isLoggedin()) {
105  ossn_error_page();
106  }
107  $title = ossn_print('news:feed');
108  if (com_is_active('OssnWall')) {
109  $contents['content'] = ossn_plugin_view('wall/pages/wall');
110  }
111  $content = ossn_set_page_layout('newsfeed', $contents);
112  echo ossn_view_page($title, $content);
113  break;
114  case 'resetlogin':
115  if (ossn_isLoggedin()) {
116  redirect('home');
117  }
118  $user = input('user');
119  $code = input('c');
120  $contents['content'] = ossn_plugin_view('pages/contents/user/resetlogin');
121 
122  if (!empty($user) && !empty($code)) {
123  $contents['content'] = ossn_plugin_view('pages/contents/user/resetcode');
124  }
125  $title = ossn_print('reset:login');
126  $content = ossn_set_page_layout('startup', $contents);
127  echo ossn_view_page($title, $content);
128  break;
129  case 'login':
130  if (ossn_isLoggedin()) {
131  redirect('home');
132  }
133  $title = ossn_print('site:login');
134  $contents['content'] = ossn_plugin_view('pages/contents/user/login');
135  $content = ossn_set_page_layout('startup', $contents);
136  echo ossn_view_page($title, $content);
137  break;
138 
139  case 'registered':
140  if (ossn_isLoggedin()) {
141  redirect('home');
142  }
143  $title = ossn_print('account:registered');
144  $contents['content'] = ossn_plugin_view('pages/contents/user/registered');
145  $content = ossn_set_page_layout('startup', $contents);
146  echo ossn_view_page($title, $content);
147  break;
148 
149  default:
150  ossn_error_page();
151  break;
152 
153  }
154 }
155 
156 /**
157  * Register site index page
158  * @pages:
159  * index or home,
160  *
161  * @return boolean|null
162  */
163 function ossn_index_pagehandler($index) {
164  if (ossn_isLoggedin()) {
165  redirect('home');
166  }
167  $page = $index[0];
168  if (empty($page)) {
169  $page = 'home';
170  }
171  switch ($page) {
172  case 'home':
173  echo ossn_plugin_view('pages/index');
174  break;
175 
176  default:
177  ossn_error_page();
178  break;
179 
180  }
181 }
182 /**
183  * Loads system plugins before we load components.
184  *
185  * @return void
186  */
188  //load system plugins before components load #451
189  ossn_register_plugins_by_path(ossn_route()->system . 'plugins/');
190 }
191 ossn_register_callback('ossn', 'init', 'ossn_initialize');
192 ossn_register_callback('components', 'before:load', 'ossn_system_plugins_load');