Permalink
Browse files

feature(routing): Move all core pages to resource views

Conflicts:
	engine/lib/admin.php
	views/default/core/friends/collection.php
	views/default/core/friends/collectiontabs.php
	views/default/resources/friends/collections/pickercallback.php
  • Loading branch information...
ewinslow committed Dec 5, 2014
1 parent 0142a5f commit 2761e8740ea8420e3d3c885081f3814f1049d425
Showing with 336 additions and 322 deletions.
  1. +11 −162 engine/lib/admin.php
  2. +1 −37 engine/lib/comments.php
  3. +1 −24 engine/lib/cron.php
  4. +1 −14 engine/lib/elgglib.php
  5. +7 −5 engine/lib/friends.php
  6. +4 −32 engine/lib/pagehandler.php
  7. +1 −1 engine/lib/river.php
  8. +6 −9 engine/lib/user_settings.php
  9. +8 −8 engine/lib/users.php
  10. +1 −2 views/default/core/friends/collection.php
  11. +22 −25 views/default/core/friends/collectiontabs.php
  12. 0 {pages → views/default/resources}/account/change_password.php
  13. 0 {pages → views/default/resources}/account/forgotten_password.php
  14. 0 {pages → views/default/resources}/account/login.php
  15. 0 {pages → views/default/resources}/account/register.php
  16. +53 −0 views/default/resources/admin.php
  17. +39 −0 views/default/resources/admin/plugin_screenshot.img.php
  18. +55 −0 views/default/resources/admin/plugin_text_file.php
  19. 0 {pages → views/default/resources}/avatar/edit.php
  20. 0 {pages → views/default/resources}/avatar/view.php
  21. +39 −0 views/default/resources/comments/edit.php
  22. +27 −0 views/default/resources/cron.php
  23. +36 −0 views/default/resources/error.php
  24. 0 {pages → views/default/resources}/friends/collections/add.php
  25. +0 −3 {pages → views/default/resources}/friends/collections/pickercallback.php
  26. 0 {pages → views/default/resources}/friends/collections/view.php
  27. 0 {pages → views/default/resources}/friends/index.php
  28. 0 {pages → views/default/resources}/friends/of.php
  29. 0 {pages → views/default/resources}/profile/edit.php
  30. 0 {pages → views/default/resources}/river.php
  31. +11 −0 views/default/resources/robots.txt.php
  32. 0 {pages → views/default/resources}/settings/account.php
  33. 0 {pages → views/default/resources}/settings/statistics.php
  34. 0 {pages → views/default/resources}/settings/tools.php
  35. +13 −0 views/default/resources/walled_garden.php
View
@@ -504,57 +504,9 @@ function _elgg_admin_sort_page_menu($hook, $type, $return, $params) {
* @access private
*/
function _elgg_admin_page_handler($page) {
elgg_admin_gatekeeper();
_elgg_admin_add_plugin_settings_menu();
elgg_set_context('admin');
elgg_unregister_css('elgg');
elgg_load_js('elgg.admin');
elgg_load_js('jquery.jeditable');
// default to dashboard
if (!isset($page[0]) || empty($page[0])) {
$page = array('dashboard');
}
// was going to fix this in the page_handler() function but
// it's commented to explicitly return a string if there's a trailing /
if (empty($page[count($page) - 1])) {
array_pop($page);
}
$vars = array('page' => $page);
// special page for plugin settings since we create the form for them
if ($page[0] == 'plugin_settings') {
if (isset($page[1]) && (elgg_view_exists("settings/{$page[1]}/edit") ||
elgg_view_exists("plugins/{$page[1]}/settings"))) {
$view = 'admin/plugin_settings';
$plugin = elgg_get_plugin_from_id($page[1]);
$vars['plugin'] = $plugin;
$title = elgg_echo("admin:{$page[0]}");
} else {
forward('', '404');
}
} else {
$view = 'admin/' . implode('/', $page);
$title = elgg_echo("admin:{$page[0]}");
if (count($page) > 1) {
$title .= ' : ' . elgg_echo('admin:' . implode(':', $page));
}
}
// gets content and prevents direct access to 'components' views
if ($page[0] == 'components' || !($content = elgg_view($view, $vars))) {
$title = elgg_echo('admin:unknown_section');
$content = elgg_echo('admin:unknown_section');
}
$body = elgg_view_layout('admin', array('content' => $content, 'title' => $title));
echo elgg_view_page($title, $body, 'admin');
echo elgg_view('resources/admin', [
'segments' => $page,
]);
return true;
}
@@ -567,41 +519,9 @@ function _elgg_admin_page_handler($page) {
* @access private
*/
function _elgg_admin_plugin_screenshot_page_handler($pages) {
// only admins can use this for security
elgg_admin_gatekeeper();
$plugin_id = elgg_extract(0, $pages);
// only thumbnail or full.
$size = elgg_extract(1, $pages, 'thumbnail');
// the rest of the string is the filename
$filename_parts = array_slice($pages, 2);
$filename = implode('/', $filename_parts);
$filename = sanitise_filepath($filename, false);
$plugin = elgg_get_plugin_from_id($plugin_id);
if (!$plugin) {
$file = elgg_get_root_path() . '_graphics/icons/default/medium.png';
} else {
$file = $plugin->getPath() . $filename;
if (!file_exists($file)) {
$file = elgg_get_root_path() . '_graphics/icons/default/medium.png';
}
}
header("Content-type: image/jpeg");
// resize to 100x100 for thumbnails
switch ($size) {
case 'thumbnail':
echo get_resized_image_from_existing_file($file, 100, 100, true);
break;
case 'full':
default:
echo file_get_contents($file);
break;
}
echo elgg_view('resources/admin/plugin_screenshot.img', [
'segments' => $pages,
]);
return true;
}
@@ -622,58 +542,9 @@ function _elgg_admin_plugin_screenshot_page_handler($pages) {
* @access private
*/
function _elgg_admin_markdown_page_handler($pages) {
elgg_admin_gatekeeper();
_elgg_admin_add_plugin_settings_menu();
elgg_set_context('admin');
elgg_unregister_css('elgg');
elgg_load_js('elgg.admin');
elgg_load_js('jquery.jeditable');
elgg_load_library('elgg:markdown');
$plugin_id = elgg_extract(0, $pages);
$plugin = elgg_get_plugin_from_id($plugin_id);
$filename = elgg_extract(1, $pages);
$error = false;
if (!$plugin) {
$error = elgg_echo('admin:plugins:markdown:unknown_plugin');
$body = elgg_view_layout('admin', array('content' => $error, 'title' => $error));
echo elgg_view_page($error, $body, 'admin');
return true;
}
$text_files = $plugin->getAvailableTextFiles();
if (!array_key_exists($filename, $text_files)) {
$error = elgg_echo('admin:plugins:markdown:unknown_file');
}
$file = $text_files[$filename];
$file_contents = file_get_contents($file);
if (!$file_contents) {
$error = elgg_echo('admin:plugins:markdown:unknown_file');
}
if ($error) {
$title = $error;
$body = elgg_view_layout('admin', array('content' => $error, 'title' => $title));
echo elgg_view_page($title, $body, 'admin');
return true;
}
$title = $plugin->getManifest()->getName() . ": $filename";
$text = Markdown($file_contents);
$body = elgg_view_layout('admin', array(
// setting classes here because there's no way to pass classes
// to the layout
'content' => '<div class="elgg-markdown">' . $text . '</div>',
'title' => $title
));
echo elgg_view_page($title, $body, 'admin');
echo elgg_view('resources/admin/plugin_text_file', [
'segments' => $pages,
]);
return true;
}
@@ -683,15 +554,7 @@ function _elgg_admin_markdown_page_handler($pages) {
* @access private
*/
function _elgg_robots_page_handler() {
$site = elgg_get_site_entity();
header("Content-type: text/plain");
$content = $site->getPrivateSetting('robots.txt');
$plugin_content = elgg_trigger_plugin_hook('robots.txt', 'site', array('site' => $site), '');
if ($plugin_content) {
$content = $content . "\n\n" . $plugin_content;
}
echo $content;
echo elgg_view('resources/robots.txt');
return true;
}
@@ -740,21 +603,7 @@ function _elgg_admin_maintenance_handler($hook, $type, $info) {
elgg_unregister_plugin_hook_handler('register', 'menu:login', '_elgg_login_menu_setup');
$site = elgg_get_site_entity();
$message = $site->getPrivateSetting('elgg_maintenance_message');
if (!$message) {
$message = elgg_echo('admin:maintenance_mode:default_message');
}
elgg_load_css('maintenance');
header("HTTP/1.1 503 Service Unavailable");
$body = elgg_view_layout('maintenance', array(
'message' => $message,
'site' => $site,
));
echo elgg_view_page($site->name, $body, 'maintenance');
echo elgg_view('resources/maintenance')
return false;
}
View
@@ -40,43 +40,7 @@ function _elgg_comments_page_handler($page) {
switch ($page[0]) {
case 'edit':
elgg_gatekeeper();
if (empty($page[1])) {
register_error(elgg_echo('generic_comment:notfound'));
forward(REFERER);
}
$comment = get_entity($page[1]);
if (!($comment instanceof \ElggComment) || !$comment->canEdit()) {
register_error(elgg_echo('generic_comment:notfound'));
forward(REFERER);
}
$target = $comment->getContainerEntity();
if (!($target instanceof \ElggEntity)) {
register_error(elgg_echo('generic_comment:notfound'));
forward(REFERER);
}
$title = elgg_echo('generic_comments:edit');
elgg_push_breadcrumb($target->getDisplayName(), $target->getURL());
elgg_push_breadcrumb($title);
$params = array(
'entity' => $target,
'comment' => $comment,
'is_edit_page' => true,
);
$content = elgg_view_form('comment/save', null, $params);
$params = array(
'content' => $content,
'title' => $title,
'filter' => '',
);
$body = elgg_view_layout('content', $params);
echo elgg_view_page($title, $body);
echo elgg_view('resources/comments/edit', ['segments' => $page]);
return true;
break;
View
@@ -44,30 +44,7 @@ function _elgg_cron_init() {
* @access private
*/
function _elgg_cron_page_handler($page) {
if (!isset($page[0])) {
forward();
}
$period = strtolower($page[0]);
$allowed_periods = elgg_get_config('elgg_cron_periods');
if (!in_array($period, $allowed_periods)) {
throw new \CronException("$period is not a recognized cron period.");
}
// Get a list of parameters
$params = array();
$params['time'] = time();
// Data to return to
$old_stdout = "";
ob_start();
$old_stdout = elgg_trigger_plugin_hook('cron', $period, $params, $old_stdout);
$std_out = ob_get_clean();
echo $std_out . $old_stdout;
echo elgg_view('resources/cron', ['segments' => $page]);
return true;
}
View
@@ -1745,20 +1745,7 @@ function _elgg_is_valid_options_for_batch_operation($options, $type) {
* @access private
*/
function _elgg_walled_garden_index() {
elgg_load_css('elgg.walled_garden');
elgg_load_js('elgg.walled_garden');
$content = elgg_view('core/walled_garden/login');
$params = array(
'content' => $content,
'class' => 'elgg-walledgarden-double',
'id' => 'elgg-walledgarden-login',
);
$body = elgg_view_layout('walled_garden', $params);
echo elgg_view_page('', $body, 'walled_garden');
echo elgg_view('resources/walled_garden');
return true;
}
View
@@ -128,10 +128,10 @@ function _elgg_friends_page_handler($segments, $handler) {
switch ($handler) {
case 'friends':
require_once(dirname(dirname(dirname(__FILE__))) . "/pages/friends/index.php");
echo elgg_view("resources/friends/index");
break;
case 'friendsof':
require_once(dirname(dirname(dirname(__FILE__))) . "/pages/friends/of.php");
echo elgg_view("resources/friends/of");
break;
default:
return false;
@@ -155,18 +155,20 @@ function _elgg_collections_page_handler($page_elements) {
case 'add':
elgg_set_page_owner_guid(elgg_get_logged_in_user_guid());
require_once "{$base}pages/friends/collections/add.php";
echo elgg_view("resources/friends/collections/add");
return true;
break;
case 'owner':
$user = get_user_by_username($page_elements[1]);
if ($user) {
elgg_set_page_owner_guid($user->getGUID());
require_once "{$base}pages/friends/collections/view.php";
echo elgg_view("resources/friends/collections/view");
return true;
}
break;
case 'pickercallback':
echo elgg_view('resources/friends/collections/pickercallback');
return true;
}
}
return false;
View
@@ -230,38 +230,10 @@ function elgg_front_page_handler() {
* @return void
*/
function elgg_error_page_handler($hook, $type, $result, $params) {
if (elgg_view_exists("errors/$type")) {
$title = elgg_echo("error:$type:title");
if ($title == "error:$type:title") {
// use default if there is no title for this error type
$title = elgg_echo("error:default:title");
}
$content = elgg_view("errors/$type", $params);
} else {
$title = elgg_echo("error:default:title");
$content = elgg_view("errors/default", $params);
}
$httpCodes = array(
'400' => 'Bad Request',
'401' => 'Unauthorized',
'403' => 'Forbidden',
'404' => 'Not Found',
'407' => 'Proxy Authentication Required',
'500' => 'Internal Server Error',
'503' => 'Service Unavailable',
);
if (isset($httpCodes[$type])) {
header("HTTP/1.1 $type {$httpCodes[$type]}");
}
$body = elgg_view_layout('error', array(
'title' => $title,
'content' => $content,
));
echo elgg_view_page($title, $body, 'error');
echo elgg_view('resources/error', [
'type' => $type,
'params' => $params,
]);
exit;
}
View
@@ -744,7 +744,7 @@ function _elgg_river_page_handler($page) {
}
set_input('page_type', $page_type);
require_once("{$CONFIG->path}pages/river.php");
echo elgg_view("resources/river");
return true;
}
Oops, something went wrong.

0 comments on commit 2761e87

Please sign in to comment.