ossn.lib.page.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 /**
13  * Register a page handler;
14  * @params: $handler = page;
15  * @params: $function = function which handles page;
16  * @param string $handler
17  * @param string $function
18  *
19  * @last edit: $arsalanshah
20  * @Reason: Initial;
21  */
22 function ossn_register_page($handler, $function) {
23  global $Ossn;
24  $pages = $Ossn->page[$handler] = $function;
25  return $pages;
26 }
27 /**
28  * Unregister a page from syste,
29  * @param (string) $handler Page handler name;
30  *
31  * @last edit: $arsalanshah
32  * @return void;
33  */
35  global $Ossn;
36  unset($Ossn->page[$handler]);
37 }
38 
39 /**
40  * Output a page.
41  *
42  * If page is not registered then user will see a 404 page;
43  *
44  * @param (string) $handler Page handler name;
45  * @param (string) $page handler/page;
46  * @last edit: $arsalanshah
47  * @Reason: Initial;
48  *
49  * @return mix|null data
50  * @access private
51  */
52 
54  global $Ossn;
55  $context = $handler;
56  if(isset($page) && !empty($page)){
57  $context = "$handler/$page";
58  }
59  //set context
60  ossn_add_context($context);
61 
62  $page = explode('/', $page);
63  if(isset($Ossn->page) && isset($Ossn->page[$handler]) && !empty($handler) && is_callable($Ossn->page[$handler])){
64 
65  //get page contents
66  ob_start();
67  call_user_func($Ossn->page[$handler], $page, $handler);
68  $contents = ob_get_clean();
69 
70  //supply params to hook
71  $params['page'] = $page;
72  $params['handler'] = $handler;
73 
74  return ossn_call_hook('page', 'load', $params, $contents);
75  } else {
76  return ossn_error_page();
77  }
78 
79 }
80 
81 /**
82  * Set page owner guid, this is very useful
83  *
84  * @param (int) $guid Guid of owner
85  *
86  * @return void
87  */
88 
89 function ossn_set_page_owner_guid($guid) {
90  global $Ossn;
91  $Ossn->pageOwnerGuid = $guid;
92 }
93 
94 /**
95  * Get page owner guid
96  *
97  * @return (int)
98  */
99 
101  global $Ossn;
102  return $Ossn->pageOwnerGuid;
103 }