1 | <?php |
||||||||
2 | /** |
||||||||
3 | * Plugin for creating web pages for your site |
||||||||
4 | */ |
||||||||
5 | |||||||||
6 | /** |
||||||||
7 | * External pages init |
||||||||
8 | * |
||||||||
9 | * @return void |
||||||||
10 | */ |
||||||||
11 | function expages_init() { |
||||||||
12 | |||||||||
13 | // Register a page handler, so we can have nice URLs |
||||||||
14 | 31 | elgg_register_page_handler('about', 'expages_page_handler'); |
|||||||
0 ignored issues
–
show
|
|||||||||
15 | 31 | elgg_register_page_handler('terms', 'expages_page_handler'); |
|||||||
0 ignored issues
–
show
The function
elgg_register_page_handler() has been deprecated: 3.0
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.
Loading history...
|
|||||||||
16 | 31 | elgg_register_page_handler('privacy', 'expages_page_handler'); |
|||||||
0 ignored issues
–
show
The function
elgg_register_page_handler() has been deprecated: 3.0
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.
Loading history...
|
|||||||||
17 | 31 | elgg_register_page_handler('expages', 'expages_page_handler'); |
|||||||
0 ignored issues
–
show
The function
elgg_register_page_handler() has been deprecated: 3.0
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.
Loading history...
|
|||||||||
18 | |||||||||
19 | // Register public external pages |
||||||||
20 | 31 | elgg_register_plugin_hook_handler('public_pages', 'walled_garden', 'expages_public'); |
|||||||
21 | |||||||||
22 | 31 | elgg_register_plugin_hook_handler('register', 'menu:expages', 'expages_menu_register_hook'); |
|||||||
23 | |||||||||
24 | // add a menu item for the admin edit page |
||||||||
25 | 31 | elgg_register_menu_item('page', [ |
|||||||
26 | 31 | 'name' => 'configure_utilities:expages', |
|||||||
27 | 31 | 'text' => elgg_echo('admin:configure_utilities:expages'), |
|||||||
28 | 31 | 'href' => 'admin/configure_utilities/expages', |
|||||||
29 | 31 | 'section' => 'configure', |
|||||||
30 | 31 | 'parent_name' => 'configure_utilities', |
|||||||
31 | 31 | 'context' => 'admin', |
|||||||
32 | ]); |
||||||||
33 | |||||||||
34 | // add footer links |
||||||||
35 | 31 | expages_setup_footer_menu(); |
|||||||
36 | 31 | } |
|||||||
37 | |||||||||
38 | /** |
||||||||
39 | * Extend the public pages range |
||||||||
40 | * |
||||||||
41 | * @param string $hook 'public_pages' |
||||||||
42 | * @param string $handler 'walled_garden' |
||||||||
43 | * @param array $return current return value |
||||||||
44 | * @param mixed $params supplied params |
||||||||
45 | * |
||||||||
46 | * @return array |
||||||||
47 | */ |
||||||||
48 | function expages_public($hook, $handler, $return, $params) { |
||||||||
2 ignored issues
–
show
The parameter
$handler is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
Loading history...
The parameter
$params is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
Loading history...
The parameter
$hook is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
Loading history...
|
|||||||||
49 | $pages = ['about', 'terms', 'privacy']; |
||||||||
50 | return array_merge($pages, $return); |
||||||||
51 | } |
||||||||
52 | |||||||||
53 | /** |
||||||||
54 | * Setup the links to site pages |
||||||||
55 | * |
||||||||
56 | * @return void |
||||||||
57 | */ |
||||||||
58 | function expages_setup_footer_menu() { |
||||||||
59 | 31 | $pages = ['about', 'terms', 'privacy']; |
|||||||
60 | 31 | foreach ($pages as $page) { |
|||||||
61 | 31 | elgg_register_menu_item('walled_garden', [ |
|||||||
62 | 31 | 'name' => $page, |
|||||||
63 | 31 | 'text' => elgg_echo("expages:$page"), |
|||||||
64 | 31 | 'href' => $page, |
|||||||
65 | ]); |
||||||||
66 | |||||||||
67 | 31 | elgg_register_menu_item('footer', [ |
|||||||
68 | 31 | 'name' => $page, |
|||||||
69 | 31 | 'text' => elgg_echo("expages:$page"), |
|||||||
70 | 31 | 'href' => $page, |
|||||||
71 | 31 | 'section' => 'meta', |
|||||||
72 | ]); |
||||||||
73 | } |
||||||||
74 | 31 | } |
|||||||
75 | |||||||||
76 | /** |
||||||||
77 | * External pages page handler |
||||||||
78 | * |
||||||||
79 | * @param array $page URL segements |
||||||||
80 | * @param string $handler Handler identifier |
||||||||
81 | * @return bool |
||||||||
82 | */ |
||||||||
83 | function expages_page_handler($page, $handler) { |
||||||||
84 | if ($handler == 'expages') { |
||||||||
85 | forward($page[1]); |
||||||||
86 | } |
||||||||
87 | $type = strtolower($handler); |
||||||||
88 | |||||||||
89 | $title = elgg_echo("expages:$type"); |
||||||||
90 | |||||||||
91 | $object = elgg_get_entities([ |
||||||||
92 | 'type' => 'object', |
||||||||
93 | 'subtype' => $type, |
||||||||
94 | 'limit' => 1, |
||||||||
95 | ]); |
||||||||
96 | |||||||||
97 | $description = $object ? $object[0]->description : elgg_echo('expages:notset'); |
||||||||
98 | $description = elgg_view('output/longtext', ['value' => $description]); |
||||||||
99 | |||||||||
100 | $content = elgg_view('expages/wrapper', [ |
||||||||
101 | 'content' => $description, |
||||||||
102 | ]); |
||||||||
103 | |||||||||
104 | if (elgg_is_admin_logged_in()) { |
||||||||
105 | elgg_register_menu_item('title', [ |
||||||||
106 | 'name' => 'edit', |
||||||||
107 | 'text' => elgg_echo('edit'), |
||||||||
108 | 'href' => "admin/configure_utilities/expages?type=$type", |
||||||||
109 | 'link_class' => 'elgg-button elgg-button-action', |
||||||||
110 | ]); |
||||||||
111 | } |
||||||||
112 | |||||||||
113 | $shell = 'default'; |
||||||||
114 | if (elgg_get_config('walled_garden') && !elgg_is_logged_in()) { |
||||||||
115 | $shell = 'walled_garden'; |
||||||||
116 | } |
||||||||
117 | $body = elgg_view_layout('default', [ |
||||||||
118 | 'content' => $content, |
||||||||
119 | 'title' => $title, |
||||||||
120 | 'sidebar' => false, |
||||||||
121 | ]); |
||||||||
122 | echo elgg_view_page($title, $body, $shell); |
||||||||
123 | |||||||||
124 | return true; |
||||||||
125 | } |
||||||||
126 | |||||||||
127 | /** |
||||||||
128 | * Adds menu items to the expages edit form |
||||||||
129 | * |
||||||||
130 | * @param string $hook 'register' |
||||||||
131 | * @param string $type 'menu:expages' |
||||||||
132 | * @param array $return current menu items |
||||||||
133 | * @param array $params parameters |
||||||||
134 | * |
||||||||
135 | * @return array |
||||||||
136 | */ |
||||||||
137 | function expages_menu_register_hook($hook, $type, $return, $params) { |
||||||||
2 ignored issues
–
show
The parameter
$type is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
Loading history...
The parameter
$hook is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
Loading history...
|
|||||||||
138 | $type = elgg_extract('type', $params); |
||||||||
139 | |||||||||
140 | $pages = ['about', 'terms', 'privacy']; |
||||||||
141 | foreach ($pages as $page) { |
||||||||
142 | $return[] = ElggMenuItem::factory([ |
||||||||
143 | 'name' => $page, |
||||||||
144 | 'text' => elgg_echo("expages:$page"), |
||||||||
145 | 'href' => "admin/configure_utilities/expages?type=$page", |
||||||||
146 | 'selected' => $page === $type, |
||||||||
147 | ]); |
||||||||
148 | } |
||||||||
149 | return $return; |
||||||||
150 | } |
||||||||
151 | |||||||||
152 | return function() { |
||||||||
153 | 18 | elgg_register_event_handler('init', 'system', 'expages_init'); |
|||||||
154 | }; |
||||||||
155 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.