Changeset 1984:0b0cb9cd7da7
- Timestamp:
- 09/21/13 23:52:08 (12 years ago)
- Branch:
- default
- Files:
-
- 1 added
- 1 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
locales/en/plugins.po
r1955 r1984 980 980 msgstr "" 981 981 982 msgid "One task to execute" 983 msgstr "" 984 985 #, php-format 986 msgid "%s tasks to execute" 987 msgstr "" 988 989 msgid "There is a task to execute." 990 msgstr "" 991 992 #, php-format 993 msgid_plural "There are %s tasks to execute." 994 msgstr "" 995 996 msgid "This task has never been executed." 997 msgstr "" 998 999 msgid "Last execution of this task was on %s." 1000 msgstr "" 1001 1002 msgid "Manage tasks" 1003 msgstr "" 1004 1005 msgid "Display count of expired tasks on maintenance dashboard icon" 1006 msgstr "" 1007 1008 msgid "Display list of expired tasks on dashboard items" 1009 msgstr "" 1010 1011 msgid "Failed to execute task." 1012 msgstr "" 1013 1014 msgid "Task successfully executed." 1015 msgstr "" 1016 1017 msgid "Empty templates cache directory" 1018 msgstr "" 1019 1020 msgid "Templates cache directory emptied." 1021 msgstr "" 1022 1023 msgid "Failed to empty templates cache directory." 1024 msgstr "" 1025 1026 msgid "Count again comments and trackbacks" 1027 msgstr "" 1028 1029 msgid "Comments and trackback counted." 1030 msgstr "" 1031 1032 msgid "Failed to count comments and trackbacks." 1033 msgstr "" 1034 1035 msgid "Search engine index" 1036 msgstr "" 1037 1038 msgid "Index all comments" 1039 msgstr "" 1040 1041 msgid "Next" 1042 msgstr "" 1043 1044 #, php-format 1045 msgid "Indexing comment %d to %d." 1046 msgstr "" 1047 1048 msgid "Comments index done." 1049 msgstr "" 1050 1051 msgid "Failed to index comments." 1052 msgstr "" 1053 1054 msgid "Index all posts" 1055 msgstr "" 1056 1057 msgid "Indexing entry %d to %d." 1058 msgstr "" 1059 1060 msgid "Entries index done." 1061 msgstr "" 1062 1063 msgid "Failed to index entries." 1064 msgstr "" 1065 1066 msgid "Delete all logs" 1067 msgstr "" 1068 1069 msgid "Logs deleted." 1070 msgstr "" 1071 1072 msgid "Failed to delete logs." 1073 msgstr "" 1074 1075 msgid "optimize tables" 1076 msgstr "" 1077 1078 msgid "Optimization successful." 1079 msgstr "" 1080 1081 msgid "Failed to optimize tables." 1082 msgstr "" 1083 1084 msgid "Download media folder of current blog" 1085 msgstr "" 1086 1087 msgid "Download active theme of current blog" 1088 msgstr "" 1089 1090 msgid "Every week" 1091 msgstr "" 1092 1093 msgid "Every two weeks" 1094 msgstr "" 1095 1096 msgid "Every month" 1097 msgstr "" 1098 1099 msgid "Every two months" 1100 msgstr "" 1101 1102 msgid "Use different periods for each task" 1103 msgstr "" 1104 1105 msgid "Never" 1106 msgstr "" 1107 1108 msgid "Settings successfully updated" 1109 msgstr "" 1110 1111 msgid "You should execute it now." 1112 msgstr "" 1113 982 1114 msgid "Execute task" 983 1115 msgstr "" 984 1116 985 msgid "Task successfully executed." 986 msgstr "" 987 988 msgid "Failed to execute task." 989 msgstr "" 990 991 msgid "one task to update" 992 msgstr "" 993 994 #, php-format 995 msgid "%s tasks to update" 996 msgstr "" 997 998 msgid "Show maintenance tasks to update." 999 msgstr "" 1000 1001 #, php-format 1002 msgid "Last execution of this task was on %s. You should execute it again." 1003 msgstr "" 1004 1005 msgid "Failed to empty templates cache directory." 1006 msgstr "" 1007 1008 msgid "Failed to reset comments and ping counters." 1009 msgstr "" 1010 1011 msgid "Failed to index comments." 1012 msgstr "" 1013 1014 msgid "Failed to index entries." 1015 msgstr "" 1016 1017 msgid "Failed to delete logs." 1018 msgstr "" 1019 1020 msgid "Failed to vacuum tables." 1021 msgstr "" 1022 1023 msgid "Optimization successful." 1024 msgstr "" 1025 1026 msgid "Comments and trackback counted." 1027 msgstr "" 1028 1029 msgid "Templates cache directory emptied." 1030 msgstr "" 1031 1032 msgid "Logs deleted." 1033 msgstr "" 1034 1035 #, php-format 1036 msgid "Indexing entry %d to %d." 1037 msgstr "" 1038 1039 msgid "next" 1040 msgstr "" 1041 1042 msgid "Entries index done." 1043 msgstr "" 1044 1045 msgid "Back" 1046 msgstr "" 1047 1048 #, php-format 1049 msgid "Indexing comment %d to %d." 1050 msgstr "" 1051 1052 msgid "Comments index done." 1053 msgstr "" 1054 1055 msgid "Optimize database room" 1056 msgstr "" 1057 1058 msgid "Vacuum tables" 1059 msgstr "" 1060 1061 msgid "Counters" 1062 msgstr "" 1063 1064 msgid "Reset comments and ping counters" 1065 msgstr "" 1066 1067 msgid "Search engine index" 1068 msgstr "" 1069 1070 msgid "This may take a very long time" 1071 msgstr "" 1072 1073 msgid "Index all posts" 1074 msgstr "" 1075 1076 msgid "Index all comments" 1077 msgstr "" 1078 1079 msgid "Vacuum logs" 1080 msgstr "" 1081 1082 msgid "Delete all logs" 1083 msgstr "" 1084 1085 msgid "Empty templates cache directory" 1086 msgstr "" 1087 1088 msgid "Empty directory" 1089 msgstr "" 1090 1091 msgid "Download media folder of current blog" 1092 msgstr "" 1093 1094 msgid "Download active theme of current blog" 1117 msgid "This may take a very long time." 1118 msgstr "" 1119 1120 msgid "Settings" 1121 msgstr "" 1122 1123 msgid "Display alert messages on expired tasks" 1124 msgstr "" 1125 1126 msgid "Recall time for all tasks:" 1127 msgstr "" 1128 1129 msgid "Recall time per task:" 1130 msgstr "" 1131 1132 msgid "You can place list of expired tasks on your %s." 1095 1133 msgstr "" 1096 1134 -
locales/fr/plugins.po
r1977 r1984 1200 1200 1201 1201 #, php-format 1202 msgid "One task to update" 1203 msgid_plural "%s tasks to update" 1204 msgstr[0] "Une tâche à mettre à jour" 1205 msgstr[1] "%s tâches à mettre à jour" 1206 1207 #, php-format 1208 msgid "Last updated on %s" 1209 msgstr "" 1210 1211 msgid "There is a task to update." 1212 msgid_plural "There are %s tasks to update." 1213 msgstr[0] "Une tâche à mettre à jour" 1214 msgstr[1] "%s tâches à mettre à jour" 1215 1216 msgid "Manage task" 1217 msgstr "gestion des tâches" 1218 1219 msgid "Use different periods for each task" 1220 msgstr "" 1221 1222 msgid "Never" 1223 msgstr "" 1202 msgid "One task to execute" 1203 msgid_plural "%s tasks to execute" 1204 msgstr[0] "Une tâche à exécuter" 1205 msgstr[1] "%s tâches à exécuter" 1206 1207 msgid "There is a task to execute." 1208 msgid_plural "There are %s tasks to execute." 1209 msgstr[0] "Il y a une tâche à exécuter." 1210 msgstr[1] "Il y a %s tâches à exécuter." 1211 1212 msgid "This task has never been executed." 1213 msgstr "Cette tâches n'a jamais été exécuté." 1214 1215 msgid "Last execution of this task was on %s." 1216 msgstr "La dernière exécution de cette tâches était le %s." 1217 1218 msgid "Manage tasks" 1219 msgstr "Gérer les tâches" 1224 1220 1225 1221 msgid "Display count of expired tasks on maintenance dashboard icon" 1226 msgstr "" 1227 1228 msgid "Display list of expired tasks on dashboard contents" 1229 msgstr "" 1230 1231 msgid "Display alert message of expired tasks on plugin page" 1232 msgstr "" 1233 1234 msgid "Recall time for all tasks" 1235 msgstr "" 1236 1237 msgid "Recall time per task" 1238 msgstr "" 1239 1240 msgid "Every week" 1241 msgstr "" 1242 1243 msgid "Every two weeks" 1244 msgstr "" 1245 1246 msgid "Every month" 1247 msgstr "" 1248 1249 msgid "Every two months" 1250 msgstr "" 1222 msgstr "Afficher le nombre de tâches expirées sur l'icône maintenance du tableau de bord" 1223 1224 msgid "Display list of expired tasks on dashboard items" 1225 msgstr "Afficher la liste des tâches expirées dans les éléments du tableau de bord" 1251 1226 1252 1227 msgid "Failed to execute task." … … 1265 1240 msgstr "Impossible de vider le répertoire de cache des « templates »." 1266 1241 1267 msgid " Reset comments and ping counters"1268 msgstr "Re met à zéro les compteurs de commentaires et de signalements"1242 msgid "Count again comments and trackbacks" 1243 msgstr "Recompter les commentaires et rétroliens" 1269 1244 1270 1245 msgid "Comments and trackback counted." 1271 1246 msgstr "Commentaires et rétroliens comptés." 1272 1247 1273 msgid "Failed to reset comments and ping counters."1274 msgstr "Impossible de re mettre à zéro les compteurs de commentaires et de signalements."1248 msgid "Failed to count comments and trackbacks." 1249 msgstr "Impossible de recompter les commentaires et rétroliens." 1275 1250 1276 1251 msgid "Search engine index" … … 1280 1255 msgstr "Indexation de tous les commentaires" 1281 1256 1282 msgid "next" 1283 msgstr "suivant" 1284 1285 #, php-format 1257 msgid "Next" 1258 msgstr "Suivant" 1259 1286 1260 msgid "Indexing comment %d to %d." 1287 1261 msgstr "Indexation des commentaires %d à %d." … … 1296 1270 msgstr "Indexation de tous les billets" 1297 1271 1298 #, php-format1299 1272 msgid "Indexing entry %d to %d." 1300 1273 msgstr "Indexation des billets %d à %d." … … 1315 1288 msgstr "Impossible de supprimer les journaux." 1316 1289 1317 msgid " Vacuumtables"1318 msgstr " Vidage des tables"1290 msgid "optimize tables" 1291 msgstr "Optimiser les tables" 1319 1292 1320 1293 msgid "Optimization successful." 1321 1294 msgstr "Optimisation terminée avec succès." 1322 1295 1323 msgid "Failed to vacuumtables."1324 msgstr "Impossible d e vider les tables."1296 msgid "Failed to optimize tables." 1297 msgstr "Impossible d'optimiser les tables." 1325 1298 1326 1299 msgid "Download media folder of current blog" … … 1330 1303 msgstr "Télécharger le theme actif du blog courant" 1331 1304 1332 msgid "Back" 1333 msgstr "Retour" 1334 1335 #, php-format 1336 msgid "Last execution of this task was on %s." 1337 msgstr "La dernière exécution de cette tâches était le %s." 1305 msgid "Every week" 1306 msgstr "Chaque semaine" 1307 1308 msgid "Every two weeks" 1309 msgstr "Toutes les deux semaines" 1310 1311 msgid "Every month" 1312 msgstr "Chaque mois" 1313 1314 msgid "Every two months" 1315 msgstr "Tous les deux mois" 1316 1317 msgid "Use different periods for each task" 1318 msgstr "Utiliser une période diffèrente pour chaque tâche" 1319 1320 msgid "Never" 1321 msgstr "Jamais" 1322 1323 msgid "Settings successfully updated" 1324 msgstr "Paramètres mis à jour avec succès" 1338 1325 1339 1326 msgid "You should execute it now." 1340 1327 msgstr "Vous devriez l'exécuter à nouveau." 1341 1328 1342 msgid "This task has never been executed."1343 msgstr ""1344 1345 1329 msgid "Execute task" 1346 1330 msgstr "Exécuter la tâche" 1347 1331 1348 msgid "This may take a very long time" 1349 msgstr "Cela peut prendre un certain temps" 1332 msgid "This may take a very long time." 1333 msgstr "Cela peut prendre un certain temps." 1334 1335 msgid "Settings" 1336 msgstr "Paramètres" 1337 1338 msgid "Display alert messages on expired tasks" 1339 msgstr "Afficher les messages d'alert sur les tâches expirées." 1340 1341 msgid "Recall time for all tasks:" 1342 msgstr "Délai de rappel pour toutes les tâches :" 1343 1344 msgid "Recall time per task:" 1345 msgstr "Délai de rappel par tâche :" 1346 1347 msgid "You can place list of expired tasks on your %s." 1348 msgstr "Vous pouvez placer la liste des tâches expirées sur votre %s." 1350 1349 1351 1350 #, php-format -
plugins/maintenance/_admin.php
r1969 r1984 23 23 // Admin behaviors 24 24 $core->addBehavior('dcMaintenanceRegister', array('dcMaintenanceAdmin', 'dcMaintenanceRegister')); 25 $core->addBehavior('adminPreferencesHeaders', array('dcMaintenanceAdmin', 'adminPreferencesHeaders'));26 25 $core->addBehavior('adminDashboardFavs', array('dcMaintenanceAdmin', 'adminDashboardFavs')); 27 26 $core->addBehavior('adminDashboardFavsIcon', array('dcMaintenanceAdmin', 'adminDashboardFavsIcon')); 28 27 $core->addBehavior('adminDashboardItems', array('dcMaintenanceAdmin', 'adminDashboardItems')); 29 $core->addBehavior('admin PreferencesForm', array('dcMaintenanceAdmin', 'adminPreferencesForm'));30 $core->addBehavior('admin BeforeUserOptionsUpdate', array('dcMaintenanceAdmin', 'adminBeforeUserOptionsUpdate'));28 $core->addBehavior('adminDashboardOptionsForm', array('dcMaintenanceAdmin', 'adminDashboardOptionsForm')); 29 $core->addBehavior('adminAfterDashboardOptionsUpdate', array('dcMaintenanceAdmin', 'adminAfterDashboardOptionsUpdate')); 31 30 32 31 /** … … 60 59 61 60 $tasks[] = 'dcMaintenanceCache'; 61 $tasks[] = 'dcMaintenanceIndexposts'; 62 $tasks[] = 'dcMaintenanceIndexcomments'; 62 63 $tasks[] = 'dcMaintenanceCountcomments'; 63 $tasks[] = 'dcMaintenanceIndexcomments';64 $tasks[] = 'dcMaintenanceIndexposts';65 64 $tasks[] = 'dcMaintenanceLogs'; 66 65 $tasks[] = 'dcMaintenanceVacuum'; 67 66 $tasks[] = 'dcMaintenanceZipmedia'; 68 67 $tasks[] = 'dcMaintenanceZiptheme'; 69 }70 71 /**72 * Dashboard headers.73 *74 * Add ajavascript to toggle tasks list.75 */76 public static function adminPreferencesHeaders()77 {78 return dcPage::jsLoad('index.php?pf=maintenance/js/preferences.js');79 68 } 80 69 … … 122 111 // Check expired tasks 123 112 $maintenance = new dcMaintenance($core); 124 $expired = $maintenance->getExpired(); 125 $expired = count($expired); 126 if (!$expired) { 127 return null; 128 } 129 130 $icon[0] .= '<br />'.sprintf(__('One task to update', '%s tasks to update', $expired), $expired); 113 $count = 0; 114 foreach($maintenance->getTasks() as $t) 115 { 116 if ($t->expired() !== false){ 117 $count++; 118 } 119 } 120 121 if (!$count) { 122 return null; 123 } 124 125 $icon[0] .= '<br />'.sprintf(__('One task to execute', '%s tasks to execute', $count), $count); 131 126 } 132 127 … … 145 140 146 141 $maintenance = new dcMaintenance($core); 147 $tasks = $maintenance->getExpired();148 if (empty($tasks)) {149 return null;150 }151 142 152 143 $lines = array(); 153 foreach($tasks as $id => $ts) { 154 $lines[$ts] = 155 '<li title="'.sprintf(__('Last updated on %s'), 156 dt::dt2str($core->blog->settings->system->date_format, $ts).' '. 157 dt::dt2str($core->blog->settings->system->time_format, $ts) 158 ).'">'.$maintenance->getTask($id)->task().'</li>'; 159 } 160 ksort($lines); 144 foreach($maintenance->getTasks() as $t) 145 { 146 $ts = $t->expired(); 147 if ($ts === false){ 148 continue; 149 } 150 151 $lines[] = 152 '<li title="'.($ts === null ? 153 __('This task has never been executed.') 154 : 155 sprintf(__('Last execution of this task was on %s.'), 156 dt::dt2str($core->blog->settings->system->date_format, $ts).' '. 157 dt::dt2str($core->blog->settings->system->time_format, $ts) 158 ) 159 ).'">'.$t->task().'</li>'; 160 } 161 162 if (empty($lines)) { 163 return null; 164 } 161 165 162 166 $items[] = new ArrayObject(array( 163 167 '<div id="maintenance-expired">'. 164 168 '<h3><img src="index.php?pf=maintenance/icon.png" alt="" /> '.__('Maintenance').'</h3>'. 165 '<p >'.sprintf(__('There is a task to update.', 'There are %s tasks to update.', count($tasks)), count($tasks)).'</p>'.169 '<p class="warn">'.sprintf(__('There is a task to execute.', 'There are %s tasks to execute.', count($lines)), count($lines)).'</p>'. 166 170 '<ul>'.implode('',$lines).'</ul>'. 167 '<p><a href="plugin.php?p=maintenance">'.__('Manage task ').'</a></p>'.171 '<p><a href="plugin.php?p=maintenance">'.__('Manage tasks').'</a></p>'. 168 172 '</div>' 169 173 )); … … 178 182 * @param $args <b>object</b> dcCore instance or record 179 183 */ 180 public static function adminPreferencesForm($core) 181 { 182 $core->auth->user_prefs->addWorkspace('maintenance'); 183 $maintenance = new dcMaintenance($core); 184 185 $tasks = $maintenance->getTasks(); 186 if (empty($tasks)) { 187 return null; 188 } 189 190 $full_combo_ts = array_merge(array( 191 __('Use different periods for each task') => 'seperate'), 192 self::comboTs() 193 ); 194 195 $task_combo_ts = array_merge(array( 196 __('Never') => 0), 197 self::comboTs() 198 ); 184 public static function adminDashboardOptionsForm($core) 185 { 186 $core->auth->user_prefs->addWorkspace('maintenance'); 199 187 200 188 echo … … 202 190 '<h4>'.__('Maintenance').'</h4>'. 203 191 204 '<div class="two-boxes">'.205 206 192 '<p><label for="maintenance_dashboard_icon" class="classic">'. 207 193 form::checkbox('maintenance_dashboard_icon', 1, $core->auth->user_prefs->maintenance->dashboard_icon). … … 210 196 '<p><label for="maintenance_dashboard_item" class="classic">'. 211 197 form::checkbox('maintenance_dashboard_item', 1, $core->auth->user_prefs->maintenance->dashboard_item). 212 __('Display list of expired tasks on dashboard contents').'</label></p>'. 213 214 '<p><label for="maintenance_plugin_message" class="classic">'. 215 form::checkbox('maintenance_plugin_message', 1, $core->auth->user_prefs->maintenance->plugin_message). 216 __('Display alert message of expired tasks on plugin page').'</label></p>'. 217 218 '</div>'. 219 220 '<div class="two-boxes">'. 221 222 '<p><label for="maintenance_recall_time">'.__('Recall time for all tasks').'</label>'. 223 form::combo('maintenance_recall_time', $full_combo_ts, 'seperate', 'recall-for-all'). 224 '</p>'. 225 226 '</div>'. 227 228 '<div id="maintenance-recall-time">'. 229 '<h5>'.__('Recall time per task').'</h5>'; 230 231 foreach($tasks as $task) { 232 echo 233 '<div class="two-boxes">'. 234 235 '<p><label for="maintenance_ts_'.$task->id().'">'.$task->task().'</label>'. 236 form::combo('maintenance_ts_'.$task->id(), $task_combo_ts, $task->ts(), 'recall-per-task'). 237 '</p>'. 238 239 '</div>'; 240 } 241 242 echo 243 '</div>'. 198 __('Display list of expired tasks on dashboard items').'</label></p>'. 199 244 200 '</div>'; 245 201 } … … 248 204 * User preferences update. 249 205 * 250 * @param $cur <b>cursor</b> Cursor of user options251 206 * @param $user_id <b>string</b> User ID 252 207 */ 253 public static function admin BeforeUserOptionsUpdate($cur,$user_id=null)208 public static function adminAfterDashboardOptionsUpdate($user_id=null) 254 209 { 255 210 global $core; 256 211 257 212 if (is_null($user_id)) { 258 return null;259 }260 261 $maintenance = new dcMaintenance($core);262 $tasks = $maintenance->getTasks();263 if (empty($tasks)) {264 213 return null; 265 214 } … … 268 217 $core->auth->user_prefs->maintenance->put('dashboard_icon', !empty($_POST['maintenance_dashboard_icon']), 'boolean'); 269 218 $core->auth->user_prefs->maintenance->put('dashboard_item', !empty($_POST['maintenance_dashboard_item']), 'boolean'); 270 $core->auth->user_prefs->maintenance->put('plugin_message', !empty($_POST['maintenance_plugin_message']), 'boolean');271 272 foreach($tasks as $task) {273 if ($_POST['maintenance_recall_time'] == 'seperate') {274 $ts = empty($_POST['maintenance_ts_'.$task->id()]) ? 0 : $_POST['maintenance_ts_'.$task->id()];275 }276 else {277 $ts = $_POST['maintenance_recall_time'];278 }279 $core->auth->user_prefs->maintenance->put('ts_'.$task->id(), abs((integer) $ts), 'integer');280 }281 }282 283 /* @ignore */284 public static function comboTs()285 {286 return array(287 __('Every week') => 604800,288 __('Every two weeks') => 1209600,289 __('Every month') => 2592000,290 __('Every two months') => 5184000291 );292 219 } 293 220 } -
plugins/maintenance/inc/class.dc.maintenance.php
r1969 r1984 25 25 class dcMaintenance 26 26 { 27 p rivate$core;27 public $core; 28 28 private $tasks = array(); 29 29 private $tabs = array(); 30 30 private $groups = array(); 31 private $logs = null; 31 32 32 33 /** … … 44 45 $tabs = new ArrayObject(); 45 46 $groups = new ArrayObject(); 47 $logs = $this->getLogs(); 46 48 47 49 # --BEHAVIOR-- dcMaintenanceRegister … … 75 77 } 76 78 77 $this->tasks[$task] = new $task($this ->core, 'plugin.php?p=maintenance');79 $this->tasks[$task] = new $task($this, 'plugin.php?p=maintenance'); 78 80 } 79 81 … … 230 232 231 233 /** 232 * Get expired tasks. 233 * 234 * @return <b>array</b> Array of expired Task ID / date 235 */ 236 public function getExpired() 237 { 238 // Retrieve logs from this task 239 $rs = $this->core->log->getLogs(array( 240 'log_table' => 'maintenance', 241 'blog_id' => 'all' 242 )); 243 244 $logs = array(); 245 while ($rs->fetch()) { 246 // Check if task exists 247 if (($task = $this->getTask($rs->log_msg)) !== null) { 248 // Check if remider is used and tasks expired 249 if ($task->ts() && strtotime($rs->log_dt) + $task->ts() < time()) { 250 $logs[$rs->log_msg] = $rs->log_dt; 251 } 234 * Get logs 235 * 236 * Return array( 237 * task id => array( 238 * timestamp of last execution, 239 * logged on current blog or not 240 * ) 241 * ) 242 * 243 * @return <b>array</b> List of logged tasks 244 */ 245 public function getLogs() 246 { 247 if ($this->logs === null) { 248 $rs = $this->core->log->getLogs(array( 249 'log_table' => 'maintenance', 250 'blog_id' => 'all' 251 )); 252 253 $this->logs = array(); 254 while ($rs->fetch()) { 255 $this->logs[$rs->log_msg] = array( 256 'ts' => strtotime($rs->log_dt), 257 'blog' => $rs->blog_id == $this->core->blog->id 258 ); 252 259 } 253 260 } 254 return $logs; 261 262 return $this->logs; 255 263 } 256 264 } -
plugins/maintenance/inc/class.dc.maintenance.task.php
r1969 r1984 21 21 class dcMaintenanceTask 22 22 { 23 protected $maintenance; 23 24 protected $core; 24 25 protected $p_url; 25 26 protected $code; 26 protected $ts = 604800; // one week 27 protected $ts = 0; 28 protected $expired = 0; 27 29 protected $ajax = false; 30 protected $blog = false; 28 31 29 32 protected $id; … … 43 46 * use method init() to do it. 44 47 * 45 * @param core <b>dcCore</b> dcCore instance48 * @param maintenance <b>dcMaintenance</b> dcMaintenance instance 46 49 * @param p_url <b>string</b> Maintenance plugin url 47 50 */ 48 public function __construct($core, $p_url) 49 { 50 $this->core =& $core; 51 public function __construct($maintenance, $p_url) 52 { 53 $this->maintenance = $maintenance; 54 $this->core = $maintenance->core; 51 55 $this->init(); 52 56 … … 64 68 } 65 69 66 $ core->auth->user_prefs->addWorkspace('maintenance');67 $ts = $ core->auth->user_prefs->maintenance->get('ts_'.$this->id);68 70 $this->core->blog->settings->addNamespace('maintenance'); 71 $ts = $this->core->blog->settings->maintenance->get('ts_'.$this->id); 72 69 73 $this->ts = abs((integer) $ts); 70 74 } … … 99 103 { 100 104 return $this->ts === false ? false : abs((integer) $this->ts); 105 } 106 107 /** 108 * Get task expired. 109 * 110 * This return: 111 * - Timstamp of last update if it expired 112 * - False if it not expired or has no recall time 113 * - Null if it has never been executed 114 * 115 * @return <b>mixed</b> Last update 116 */ 117 public function expired() 118 { 119 if ($this->expired === 0) { 120 if (!$this->ts()) { 121 $this->expired = false; 122 } 123 else { 124 $this->expired = null; 125 $logs = array(); 126 foreach($this->maintenance->getLogs() as $id => $log) 127 { 128 if ($id != $this->id() || $this->blog && !$log['blog']) { 129 continue; 130 } 131 132 $this->expired = $log['ts'] + $this->ts() < time() ? $log['ts'] : false; 133 } 134 } 135 } 136 return $this->expired; 101 137 } 102 138 … … 251 287 protected function log() 252 288 { 253 $maintenance = new dcMaintenance($this->core); 254 $maintenance->setLog($this->id); 289 $this->maintenance->setLog($this->id); 255 290 } 256 291 } -
plugins/maintenance/inc/tasks/class.dc.maintenance.countcomments.php
r1925 r1984 18 18 protected function init() 19 19 { 20 $this->task = __(' Reset comments and ping counters');20 $this->task = __('Count again comments and trackbacks'); 21 21 $this->success = __('Comments and trackback counted.'); 22 $this->error = __('Failed to reset comments and ping counters.');22 $this->error = __('Failed to count comments and trackbacks.'); 23 23 } 24 24 -
plugins/maintenance/inc/tasks/class.dc.maintenance.indexcomments.php
r1959 r1984 23 23 $this->name = __('Search engine index'); 24 24 $this->task = __('Index all comments'); 25 $this->step_task = __(' next');25 $this->step_task = __('Next'); 26 26 $this->step = __('Indexing comment %d to %d.'); 27 27 $this->success = __('Comments index done.'); -
plugins/maintenance/inc/tasks/class.dc.maintenance.indexposts.php
r1959 r1984 23 23 $this->name = __('Search engine index'); 24 24 $this->task = __('Index all posts'); 25 $this->step_task = __(' next');25 $this->step_task = __('Next'); 26 26 $this->step = __('Indexing entry %d to %d.'); 27 27 $this->success = __('Entries index done.'); -
plugins/maintenance/inc/tasks/class.dc.maintenance.vacuum.php
r1925 r1984 18 18 protected function init() 19 19 { 20 $this->task = __(' Vacuumtables');20 $this->task = __('optimize tables'); 21 21 $this->success = __('Optimization successful.'); 22 $this->error = __('Failed to vacuumtables.');22 $this->error = __('Failed to optimize tables.'); 23 23 } 24 24 -
plugins/maintenance/inc/tasks/class.dc.maintenance.zipmedia.php
r1955 r1984 14 14 class dcMaintenanceZipmedia extends dcMaintenanceTask 15 15 { 16 protected $blog = true; 16 17 protected $tab = 'backup'; 17 18 protected $group = 'zipblog'; -
plugins/maintenance/inc/tasks/class.dc.maintenance.ziptheme.php
r1955 r1984 14 14 class dcMaintenanceZiptheme extends dcMaintenanceTask 15 15 { 16 protected $blog = true; 16 17 protected $tab = 'backup'; 17 18 protected $group = 'zipblog'; -
plugins/maintenance/index.php
r1969 r1984 17 17 18 18 $maintenance = new dcMaintenance($core); 19 $core->blog->settings->addNamespace('maintenance'); 19 20 20 21 // Set var 21 22 23 $msg = ''; 22 24 $headers = ''; 23 25 $p_url = 'plugin.php?p=maintenance'; … … 27 29 $code = empty($_POST['code']) ? null : (integer) $_POST['code']; 28 30 $tab = empty($_REQUEST['tab']) ? 'maintenance' : $_REQUEST['tab']; 31 32 // Save settings 33 34 if (!empty($_POST['settings'])) { 35 36 try { 37 $core->blog->settings->maintenance->put( 38 'plugin_message', 39 !empty($_POST['settings_plugin_message']), 40 'boolean', 41 'Display alert message of expired tasks on plugin page', 42 true, 43 true 44 ); 45 46 foreach($maintenance->getTasks() as $t) { 47 if (!empty($_POST['settings_recall_time']) && $_POST['settings_recall_time'] == 'seperate') { 48 $ts = empty($_POST['settings_ts_'.$t->id()]) ? 0 : $_POST['settings_ts_'.$t->id()]; 49 } 50 else { 51 $ts = $_POST['settings_recall_time']; 52 } 53 $core->blog->settings->maintenance->put( 54 'ts_'.$t->id(), 55 abs((integer) $ts), 56 'integer', 57 sprintf('Recall time for task %s', $t->id()), 58 true, 59 true 60 ); 61 } 62 63 http::redirect($p_url.'&done=1&tab='.$tab); 64 } 65 catch(Exception $e) { 66 $core->error->add($e->getMessage()); 67 } 68 } 29 69 30 70 // Get task object … … 58 98 } 59 99 60 // Get expired tasks 61 $core->auth->user_prefs->addWorkspace('maintenance'); 62 if ($core->auth->user_prefs->maintenance->plugin_message) { 63 $expired = $maintenance->getExpired(); 64 } 100 // Combos 101 102 $combo_ts = array( 103 __('Every week') => 1,//604800, 104 __('Every two weeks') => 1209600, 105 __('Every month') => 2592000, 106 __('Every two months') => 5184000 107 ); 108 109 $full_combo_ts = array_merge(array( 110 __('Use different periods for each task') => 'seperate'), 111 $combo_ts 112 ); 113 114 $task_combo_ts = array_merge(array( 115 __('Never') => 0), 116 $combo_ts 117 ); 65 118 66 119 // Display page … … 68 121 echo '<html><head> 69 122 <title>'.__('Maintenance').'</title>'. 70 dcPage::jsPageTabs($tab); 123 dcPage::jsPageTabs($tab). 124 dcPage::jsLoad('index.php?pf=maintenance/js/settings.js');; 71 125 72 126 if ($task && $task->ajax()) { … … 87 141 // Success message 88 142 89 $msg = $task && !empty($_GET['done']) ? dcPage::success($task->success(),true,true,false) : ''; 143 if (!empty($_GET['done']) && $tab == 'settings') { 144 $msg = dcPage::success(__('Settings successfully updated'), true, true, false); 145 } 146 elseif (!empty($_GET['done']) && $task) { 147 $msg = dcPage::success($task->success(), true, true, false); 148 } 90 149 91 150 if ($task && ($res = $task->step()) !== null) { … … 120 179 '</form>'. 121 180 '<p class="step-back">'. 122 '<a class="back" href="'.$p_url.' ">'.__('Back').'</a>'.181 '<a class="back" href="'.$p_url.'&tab='.$task->tab().'">'.__('Back').'</a>'. 123 182 '</p>'. 124 183 '</div>'; … … 156 215 html::escapeHTML($t->task()).'</label>'; 157 216 158 if (array_key_exists($t->id(), $expired)) { 159 $res_task .= 160 '<br /> <span class="warn">'.sprintf( 161 __('Last execution of this task was on %s.'), 162 dt::dt2str(__('%Y-%m-%d %H:%M'), $expired[$t->id()]) 163 ).' '. 164 __('You should execute it now.').'</span>'; 165 } 166 elseif ($t->ts()) { 167 $res_task .= 168 '<br /> <span class="warn">'. 169 __('This task has never been executed.').' '. 170 __('You should execute it now.').'</span>'; 217 // Expired task alert message 218 $ts = $t->expired(); 219 if ($core->blog->settings->maintenance->plugin_message && $ts !== false) { 220 if ($ts === null) { 221 $res_task .= 222 '<br /> <span class="warn">'. 223 __('This task has never been executed.').' '. 224 __('You should execute it now.').'</span>'; 225 } 226 else { 227 $res_task .= 228 '<br /> <span class="warn">'.sprintf( 229 __('Last execution of this task was on %s.'), 230 dt::str($core->blog->settings->system->date_format, $ts).' '. 231 dt::str($core->blog->settings->system->time_format, $ts) 232 ).' '. 233 __('You should execute it now.').'</span>'; 234 } 171 235 } 172 236 … … 192 256 form::hidden(array('tab'), $tab_id). 193 257 $core->formNonce().'</p>'. 194 '<p class="form-note info">'.__('This may take a very long time ').'.</p>'.258 '<p class="form-note info">'.__('This may take a very long time.').'.</p>'. 195 259 '</form>'. 196 260 '</div>'; … … 218 282 '</div>'; 219 283 } 284 285 // Settings 286 287 echo 288 '<div id="settings" class="multi-part" title="'.__('Settings').'">'. 289 '<h3>'.__('Settings').'</h3>'. 290 '<form action="'.$p_url.'" method="post">'. 291 292 '<p><label for="settings_plugin_message" class="classic">'. 293 form::checkbox('settings_plugin_message', 1, $core->blog->settings->maintenance->plugin_message). 294 __('Display alert messages on expired tasks').'</label></p>'. 295 296 '<p><label for="settings_recall_time">'.__('Recall time for all tasks:').'</label>'. 297 form::combo('settings_recall_time', $full_combo_ts, 'seperate', 'recall-for-all'). 298 '</p>'. 299 300 '<p>'.__('Recall time per task:').'</p>'; 301 302 foreach($maintenance->getTasks($core) as $t) 303 { 304 echo 305 '<div class="two-boxes">'. 306 307 '<p><label for="settings_ts_'.$t->id().'">'.$t->task().'</label>'. 308 form::combo('settings_ts_'.$t->id(), $task_combo_ts, $t->ts(), 'recall-per-task'). 309 '</p>'. 310 311 '</div>'; 312 } 313 314 echo 315 '<p><input type="submit" value="'.__('Save').'" /> '. 316 form::hidden(array('tab'), 'settings'). 317 form::hidden(array('settings'), 1). 318 $core->formNonce().'</p>'. 319 '</form>'. 320 '<p class="info">'.sprintf( 321 __('You can place list of expired tasks on your %s.'), 322 '<a href="preferences.php#user-favorites">'.__('Dashboard').'</a>' 323 ).'</a></p>'. 324 '</div>'; 220 325 } 221 326
Note: See TracChangeset
for help on using the changeset viewer.