diff options
-rw-r--r-- | engine/classes/ElggPlugin.php | 10 | ||||
-rw-r--r-- | mod/developers/actions/developers/settings.php | 3 | ||||
-rw-r--r-- | mod/developers/classes/ElggLogCache.php | 43 | ||||
-rw-r--r-- | mod/developers/languages/en.php | 5 | ||||
-rw-r--r-- | mod/developers/start.php | 8 | ||||
-rw-r--r-- | mod/developers/views/default/admin/developers/settings.php | 7 | ||||
-rw-r--r-- | mod/developers/views/default/developers/css.php | 6 | ||||
-rw-r--r-- | mod/developers/views/default/developers/log.php | 16 |
8 files changed, 93 insertions, 5 deletions
diff --git a/engine/classes/ElggPlugin.php b/engine/classes/ElggPlugin.php index 95a7362e2..e46ac4273 100644 --- a/engine/classes/ElggPlugin.php +++ b/engine/classes/ElggPlugin.php @@ -700,6 +700,11 @@ class ElggPlugin extends ElggObject { // return false; // } + // include classes + if ($flags & ELGG_PLUGIN_REGISTER_CLASSES) { + $this->registerClasses(); + } + // include start file if ($flags & ELGG_PLUGIN_INCLUDE_START) { $this->includeFile('start.php'); @@ -715,11 +720,6 @@ class ElggPlugin extends ElggObject { $this->registerLanguages(); } - // include classes - if ($flags & ELGG_PLUGIN_REGISTER_CLASSES) { - $this->registerClasses(); - } - return true; } diff --git a/mod/developers/actions/developers/settings.php b/mod/developers/actions/developers/settings.php index d8be34866..9fa96fa91 100644 --- a/mod/developers/actions/developers/settings.php +++ b/mod/developers/actions/developers/settings.php @@ -18,6 +18,7 @@ if (get_input('view_path_cache')) { } elgg_set_plugin_setting('display_errors', get_input('display_errors'), 'developers'); +elgg_set_plugin_setting('screen_log', get_input('screen_log'), 'developers'); $debug = get_input('debug_level'); if ($debug) { @@ -26,4 +27,6 @@ if ($debug) { unset_config('debug', $site->getGUID()); } +system_message(elgg_echo('developers:settings:success')); + forward(REFERER); diff --git a/mod/developers/classes/ElggLogCache.php b/mod/developers/classes/ElggLogCache.php new file mode 100644 index 000000000..19df598d7 --- /dev/null +++ b/mod/developers/classes/ElggLogCache.php @@ -0,0 +1,43 @@ +<?php +/** + * Cache logging information for later display + * + */ + +class ElggLogCache { + protected $cache; + + public function __construct() { + $this->cache = array(); + } + + /** + * Insert into cache + * + * @param mixed $data The log data to cache + */ + public function insert($data) { + $this->cache[] = $data; + } + + /** + * Insert into cache from plugin hook + * + * @param string $hook + * @param string $type + * @param bool $result + * @param array $params Must have the data at $params['msg'] + */ + public function insertDump($hook, $type, $result, $params) { + $this->insert($params['msg']); + } + + /** + * Get the cache + * + * @return array + */ + public function get() { + return $this->cache; + } +} diff --git a/mod/developers/languages/en.php b/mod/developers/languages/en.php index dc763765c..053eed04f 100644 --- a/mod/developers/languages/en.php +++ b/mod/developers/languages/en.php @@ -21,6 +21,8 @@ $english = array( 'developers:help:debug_level' => "This controls the amount of information logged. See elgg_log() for more information.", 'developers:label:display_errors' => 'Display fatal PHP errors', 'developers:help:display_errors' => "By default, Elgg's .htaccess file supresses the display of fatal errors.", + 'developers:label:screen_log' => "Log to the screen", + 'developers:help:screen_log' => "This displays elgg_log() and elgg_dump() output on the web page.", 'developers:debug:off' => 'Off', 'developers:debug:error' => 'Error', @@ -41,6 +43,9 @@ $english = array( 'theme_preview:modules' => 'Modules', 'theme_preview:navigation' => 'Navigation', 'theme_preview:typography' => 'Typography', + + // status messages + 'developers:settings:success' => 'Settings saved', ); add_translation('en', $english); diff --git a/mod/developers/start.php b/mod/developers/start.php index a53b7eec4..23b82d9db 100644 --- a/mod/developers/start.php +++ b/mod/developers/start.php @@ -12,6 +12,7 @@ function developers_init() { elgg_register_event_handler('pagesetup', 'system', 'developers_setup_menu'); elgg_extend_view('css/admin', 'developers/css'); + elgg_extend_view('css/elgg', 'developers/css'); elgg_register_page_handler('theme_preview', 'developers_theme_preview_controller'); @@ -32,6 +33,13 @@ function developers_process_settings() { } else { ini_set('display_errors', 0); } + + if (elgg_get_plugin_setting('screen_log', 'developers') == 1) { + $cache = new ElggLogCache(); + elgg_set_config('log_cache', $cache); + elgg_register_plugin_hook_handler('debug', 'log', array($cache, 'insertDump')); + elgg_extend_view('page/elements/foot', 'developers/log'); + } } function developers_setup_menu() { diff --git a/mod/developers/views/default/admin/developers/settings.php b/mod/developers/views/default/admin/developers/settings.php index 705ad00c6..3843c2c30 100644 --- a/mod/developers/views/default/admin/developers/settings.php +++ b/mod/developers/views/default/admin/developers/settings.php @@ -8,6 +8,7 @@ $sections = array( 'view_path_cache' => 'checkbox', 'display_errors' => 'checkbox', 'debug_level' => 'pulldown', + 'screen_log' => 'checkbox', ); $data = array( @@ -39,6 +40,12 @@ $data = array( 'NOTICE' => elgg_echo('developers:debug:notice'), ), ), + + 'screen_log' => array( + 'type' => 'checkbox', + 'value' => 1, + 'checked' => elgg_get_plugin_setting('screen_log', 'developers') == 1, + ), ); $form_vars = array('id' => 'developer-settings-form'); diff --git a/mod/developers/views/default/developers/css.php b/mod/developers/views/default/developers/css.php index 3aa226d0a..4690945a9 100644 --- a/mod/developers/views/default/developers/css.php +++ b/mod/developers/views/default/developers/css.php @@ -15,3 +15,9 @@ .elgg-page .jstree-default.jstree-focused { background-color: transparent; } +.developers-log { + background-color: #EBF5FF; + border: 1px solid #999; + color: #666; + padding: 20px; +} diff --git a/mod/developers/views/default/developers/log.php b/mod/developers/views/default/developers/log.php new file mode 100644 index 000000000..eca2b4b67 --- /dev/null +++ b/mod/developers/views/default/developers/log.php @@ -0,0 +1,16 @@ +<?php +/** + * Logging information + */ + +$cache = elgg_get_config('log_cache'); +$items = $cache->get(); + +echo '<div class="developers-log">'; +foreach ($items as $item) { + echo '<pre>'; + print_r($item); + echo '</pre>'; +} + +echo '</div>';
\ No newline at end of file |