From aefce16b306505c6cfed8d87e975b2c9680559b4 Mon Sep 17 00:00:00 2001 From: cash Date: Mon, 29 Nov 2010 02:53:32 +0000 Subject: cleaned up some of the other smaller plugins git-svn-id: http://code.elgg.org/elgg/trunk@7468 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/crontrigger/start.php | 169 +++++++++++---------- mod/garbagecollector/languages/en.php | 53 +++---- mod/garbagecollector/start.php | 101 ++++++------ .../default/settings/garbagecollector/edit.php | 12 +- mod/logrotate/languages/en.php | 35 +++-- mod/logrotate/start.php | 101 ++++++------ .../views/default/settings/logrotate/edit.php | 12 +- mod/tinymce/languages/en.php | 8 +- mod/tinymce/start.php | 6 +- 9 files changed, 253 insertions(+), 244 deletions(-) diff --git a/mod/crontrigger/start.php b/mod/crontrigger/start.php index 379fe1978..24f50f33b 100644 --- a/mod/crontrigger/start.php +++ b/mod/crontrigger/start.php @@ -1,80 +1,91 @@ \ No newline at end of file +/** + * Elgg Cron trigger. + * When enabled this plugin provides "poor man's cron" functionality to trigger + * elgg cron scripts without the need to install the cron script. + * + * Note, this is a substitute and not a replacement for the cron script. + * It is recommended that you use the cron script where possible. + * + * @package ElggCronTrigger + */ + +elgg_register_event_handler('init', 'system', 'crontrigger_init'); + +function crontrigger_init() { + elgg_register_event_handler('shutdown', 'system', 'crontrigger_shutdownhook'); +} + +function crontrigger_trigger($period) { + elgg_trigger_plugin_hook('cron', $period); +} + +function crontrigger_minute() { + crontrigger_trigger('minute'); +} + +function crontrigger_fiveminute() { + crontrigger_trigger('fiveminute'); +} + +function crontrigger_fifteenmin() { + crontrigger_trigger('fifteenmin'); +} + +function crontrigger_halfhour() { + crontrigger_trigger('halfhour'); +} + +function crontrigger_hourly() { + crontrigger_trigger('hourly'); +} + +function crontrigger_daily() { + crontrigger_trigger('daily'); +} + +function crontrigger_weekly() { + crontrigger_trigger('weekly'); +} + +function crontrigger_monthly() { + crontrigger_trigger('monthly'); +} + +function crontrigger_yearly() { + crontrigger_trigger('yearly'); +} + +/** + * Call cron hooks after a page has been displayed (so user won't notice any slowdown). + * + * If people are not viewing pages quickly enough, the scheduled triggers will + * not occur. + */ +function crontrigger_shutdownhook() { + global $CONFIG; + + $minute = 60; + $fiveminute = $minute * 5; + $fifteenmin = $minute * 15; + $halfhour = $minute * 30; + $hour = 3600; + $day = $hour * 24; + $week = $day * 7; + $month = $week * 4; + $year = $month * 12; + + $now = time(); + + ob_start(); + run_function_once('crontrigger_minute', $now - $minute); + run_function_once('crontrigger_fiveminute', $now - $fiveminute); + run_function_once('crontrigger_fifteenmin', $now - $fifteenmin); + run_function_once('crontrigger_halfhour', $now - $halfhour); + run_function_once('crontrigger_hourly', $now - $hour); + run_function_once('crontrigger_daily', $now - $day); + run_function_once('crontrigger_weekly', $now - $week); + run_function_once('crontrigger_monthly', $now - $month); + run_function_once('crontrigger_yearly', $now - $year); + ob_clean(); +} diff --git a/mod/garbagecollector/languages/en.php b/mod/garbagecollector/languages/en.php index fbebf54b4..b32670a0c 100644 --- a/mod/garbagecollector/languages/en.php +++ b/mod/garbagecollector/languages/en.php @@ -1,32 +1,25 @@ 'How often should the Elgg garbage collector run?', - - 'garbagecollector:weekly' => 'Once a week', - 'garbagecollector:monthly' => 'Once a month', - 'garbagecollector:yearly' => 'Once a year', - - 'garbagecollector' => "GARBAGE COLLECTOR\n", - 'garbagecollector:done' => "DONE\n", - 'garbagecollector:optimize' => "Optimizing %s ", - - 'garbagecollector:error' => "ERROR", - 'garbagecollector:ok' => "OK", - - 'garbagecollector:gc:metastrings' => 'Cleaning up unlinked metastrings: ', - - ); - - add_translation("en",$english); -?> \ No newline at end of file +$english = array( + 'garbagecollector:period' => 'How often should the Elgg garbage collector run?', + + 'garbagecollector:weekly' => 'Once a week', + 'garbagecollector:monthly' => 'Once a month', + 'garbagecollector:yearly' => 'Once a year', + + 'garbagecollector' => "GARBAGE COLLECTOR\n", + 'garbagecollector:done' => "DONE\n", + 'garbagecollector:optimize' => "Optimizing %s ", + + 'garbagecollector:error' => "ERROR", + 'garbagecollector:ok' => "OK", + + 'garbagecollector:gc:metastrings' => 'Cleaning up unlinked metastrings: ', +); + +add_translation("en", $english); \ No newline at end of file diff --git a/mod/garbagecollector/start.php b/mod/garbagecollector/start.php index 26a462207..6267ab1ba 100644 --- a/mod/garbagecollector/start.php +++ b/mod/garbagecollector/start.php @@ -1,71 +1,64 @@ $period)); + echo "\n"; - // Now we optimize all tables - $tables = get_db_tables(); - foreach ($tables as $table) { - echo elgg_echo('garbagecollector:optimize', array($table)); + // Now, because we are nice, trigger a plugin hook to let other plugins do some GC + $rv = true; + $period = get_plugin_setting('period','garbagecollector'); + elgg_trigger_plugin_hook('gc', 'system', array('period' => $period)); - if (optimize_table($table)!==false) - echo elgg_echo('garbagecollector:ok'); - else - echo elgg_echo('garbagecollector:error'); + // Now we optimize all tables + $tables = get_db_tables(); + foreach ($tables as $table) { + echo elgg_echo('garbagecollector:optimize', array($table)); - echo "\n"; + if (optimize_table($table) !== false) { + echo elgg_echo('garbagecollector:ok'); + } else { + echo elgg_echo('garbagecollector:error'); } - echo elgg_echo('garbagecollector:done'); + echo "\n"; } - // Initialise plugin - elgg_register_event_handler('init','system','garbagecollector_init'); -?> \ No newline at end of file + echo elgg_echo('garbagecollector:done'); +} diff --git a/mod/garbagecollector/views/default/settings/garbagecollector/edit.php b/mod/garbagecollector/views/default/settings/garbagecollector/edit.php index 19ae3d245..e05b5d778 100644 --- a/mod/garbagecollector/views/default/settings/garbagecollector/edit.php +++ b/mod/garbagecollector/views/default/settings/garbagecollector/edit.php @@ -1,6 +1,14 @@ period; - if (!$period) $period = 'monthly'; +/** + * Elgg garbage collector plugin settings. + * + * @package ElggGarbageCollector + */ + +$period = $vars['entity']->period; +if (!$period) { + $period = 'monthly'; +} ?>

diff --git a/mod/logrotate/languages/en.php b/mod/logrotate/languages/en.php index 5efb51639..e60d1b841 100644 --- a/mod/logrotate/languages/en.php +++ b/mod/logrotate/languages/en.php @@ -1,20 +1,19 @@ 'How often should the system log be archived?', - - 'logrotate:weekly' => 'Once a week', - 'logrotate:monthly' => 'Once a month', - 'logrotate:yearly' => 'Once a year', - - 'logrotate:logrotated' => "Log rotated\n", - 'logrotate:lognotrotated' => "Error rotating log\n", - ); - - add_translation("en",$english); -?> \ No newline at end of file +$english = array( + 'logrotate:period' => 'How often should the system log be archived?', + + 'logrotate:weekly' => 'Once a week', + 'logrotate:monthly' => 'Once a month', + 'logrotate:yearly' => 'Once a year', + + 'logrotate:logrotated' => "Log rotated\n", + 'logrotate:lognotrotated' => "Error rotating log\n", +); + +add_translation("en", $english); \ No newline at end of file diff --git a/mod/logrotate/start.php b/mod/logrotate/start.php index 485f53f49..28c1694eb 100644 --- a/mod/logrotate/start.php +++ b/mod/logrotate/start.php @@ -1,56 +1,53 @@ \ No newline at end of file + + if (!archive_log($offset)) { + $resulttext = elgg_echo("logrotate:lognotrotated"); + } + + return $returnvalue . $resulttext; +} diff --git a/mod/logrotate/views/default/settings/logrotate/edit.php b/mod/logrotate/views/default/settings/logrotate/edit.php index 19b92c320..db439eaa0 100644 --- a/mod/logrotate/views/default/settings/logrotate/edit.php +++ b/mod/logrotate/views/default/settings/logrotate/edit.php @@ -1,6 +1,14 @@ period; - if (!$period) $period = 'monthly'; +/** + * Elgg log rotator plugin settings. + * + * @package ElggLogRotate + */ + +$period = $vars['entity']->period; +if (!$period) { + $period = 'monthly'; +} ?>

diff --git a/mod/tinymce/languages/en.php b/mod/tinymce/languages/en.php index f5d6550dd..811e93492 100644 --- a/mod/tinymce/languages/en.php +++ b/mod/tinymce/languages/en.php @@ -1,9 +1,11 @@ "Remove editor", 'tinymce:add' => "Add editor", 'tinymce:word_count' => 'Word count: ', diff --git a/mod/tinymce/start.php b/mod/tinymce/start.php index b605f92f6..bc54c36a0 100644 --- a/mod/tinymce/start.php +++ b/mod/tinymce/start.php @@ -2,12 +2,10 @@ /** * TinyMCE wysiwyg editor * - * @package TinyMCE - **/ + * @package ElggTinyMCE + */ function tinymce_init() { - global $CONFIG; - elgg_extend_view('css', 'tinymce/css'); elgg_extend_view('embed/custom_insert_js', 'tinymce/embed_custom_insert_js'); } -- cgit v1.2.3