Dotclear

Changeset 1984:0b0cb9cd7da7


Ignore:
Timestamp:
09/21/13 23:52:08 (12 years ago)
Author:
Denis Jean-Chirstian <contact@…>
Branch:
default
Message:

Revamp plugin maintenance, step 4 bis, better place for settings according to boss and some typo, addresses #999

Files:
1 added
1 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • locales/en/plugins.po

    r1955 r1984  
    980980msgstr "" 
    981981 
     982msgid "One task to execute" 
     983msgstr "" 
     984 
     985#, php-format 
     986msgid "%s tasks to execute" 
     987msgstr "" 
     988 
     989msgid "There is a task to execute." 
     990msgstr "" 
     991 
     992#, php-format 
     993msgid_plural "There are %s tasks to execute." 
     994msgstr "" 
     995 
     996msgid "This task has never been executed." 
     997msgstr "" 
     998 
     999msgid "Last execution of this task was on %s." 
     1000msgstr "" 
     1001 
     1002msgid "Manage tasks" 
     1003msgstr "" 
     1004 
     1005msgid "Display count of expired tasks on maintenance dashboard icon" 
     1006msgstr "" 
     1007 
     1008msgid "Display list of expired tasks on dashboard items" 
     1009msgstr "" 
     1010 
     1011msgid "Failed to execute task." 
     1012msgstr "" 
     1013 
     1014msgid "Task successfully executed." 
     1015msgstr "" 
     1016 
     1017msgid "Empty templates cache directory" 
     1018msgstr "" 
     1019 
     1020msgid "Templates cache directory emptied." 
     1021msgstr "" 
     1022 
     1023msgid "Failed to empty templates cache directory." 
     1024msgstr "" 
     1025 
     1026msgid "Count again comments and trackbacks" 
     1027msgstr "" 
     1028 
     1029msgid "Comments and trackback counted." 
     1030msgstr "" 
     1031 
     1032msgid "Failed to count comments and trackbacks." 
     1033msgstr "" 
     1034 
     1035msgid "Search engine index" 
     1036msgstr "" 
     1037 
     1038msgid "Index all comments" 
     1039msgstr "" 
     1040 
     1041msgid "Next" 
     1042msgstr "" 
     1043 
     1044#, php-format 
     1045msgid "Indexing comment %d to %d." 
     1046msgstr "" 
     1047 
     1048msgid "Comments index done." 
     1049msgstr "" 
     1050 
     1051msgid "Failed to index comments." 
     1052msgstr "" 
     1053 
     1054msgid "Index all posts" 
     1055msgstr "" 
     1056 
     1057msgid "Indexing entry %d to %d." 
     1058msgstr "" 
     1059 
     1060msgid "Entries index done." 
     1061msgstr "" 
     1062 
     1063msgid "Failed to index entries." 
     1064msgstr "" 
     1065 
     1066msgid "Delete all logs" 
     1067msgstr "" 
     1068 
     1069msgid "Logs deleted." 
     1070msgstr "" 
     1071 
     1072msgid "Failed to delete logs." 
     1073msgstr "" 
     1074 
     1075msgid "optimize tables" 
     1076msgstr "" 
     1077 
     1078msgid "Optimization successful." 
     1079msgstr "" 
     1080 
     1081msgid "Failed to optimize tables." 
     1082msgstr "" 
     1083 
     1084msgid "Download media folder of current blog" 
     1085msgstr "" 
     1086 
     1087msgid "Download active theme of current blog" 
     1088msgstr "" 
     1089 
     1090msgid "Every week" 
     1091msgstr "" 
     1092 
     1093msgid "Every two weeks" 
     1094msgstr "" 
     1095 
     1096msgid "Every month" 
     1097msgstr "" 
     1098 
     1099msgid "Every two months" 
     1100msgstr "" 
     1101 
     1102msgid "Use different periods for each task" 
     1103msgstr "" 
     1104 
     1105msgid "Never" 
     1106msgstr "" 
     1107 
     1108msgid "Settings successfully updated" 
     1109msgstr "" 
     1110 
     1111msgid "You should execute it now." 
     1112msgstr "" 
     1113 
    9821114msgid "Execute task" 
    9831115msgstr "" 
    9841116 
    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" 
     1117msgid "This may take a very long time." 
     1118msgstr "" 
     1119 
     1120msgid "Settings" 
     1121msgstr "" 
     1122 
     1123msgid "Display alert messages on expired tasks" 
     1124msgstr "" 
     1125 
     1126msgid "Recall time for all tasks:" 
     1127msgstr "" 
     1128 
     1129msgid "Recall time per task:" 
     1130msgstr "" 
     1131 
     1132msgid "You can place list of expired tasks on your %s." 
    10951133msgstr "" 
    10961134 
  • locales/fr/plugins.po

    r1977 r1984  
    12001200 
    12011201#, 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 "" 
     1202msgid "One task to execute" 
     1203msgid_plural "%s tasks to execute" 
     1204msgstr[0] "Une tâche à exécuter" 
     1205msgstr[1] "%s tâches à exécuter" 
     1206 
     1207msgid "There is a task to execute." 
     1208msgid_plural "There are %s tasks to execute." 
     1209msgstr[0] "Il y a une tâche à exécuter." 
     1210msgstr[1] "Il y a %s tâches à exécuter." 
     1211 
     1212msgid "This task has never been executed." 
     1213msgstr "Cette tâches n'a jamais été exécuté." 
     1214 
     1215msgid "Last execution of this task was on %s." 
     1216msgstr "La dernière exécution de cette tâches était le %s." 
     1217 
     1218msgid "Manage tasks" 
     1219msgstr "Gérer les tâches" 
    12241220 
    12251221msgid "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 "" 
     1222msgstr "Afficher le nombre de tâches expirées sur l'icône maintenance du tableau de bord" 
     1223 
     1224msgid "Display list of expired tasks on dashboard items" 
     1225msgstr "Afficher la liste des tâches expirées dans les éléments du tableau de bord" 
    12511226 
    12521227msgid "Failed to execute task." 
     
    12651240msgstr "Impossible de vider le répertoire de cache des « templates »." 
    12661241 
    1267 msgid "Reset comments and ping counters" 
    1268 msgstr "Remet à zéro les compteurs de commentaires et de signalements" 
     1242msgid "Count again comments and trackbacks" 
     1243msgstr "Recompter les commentaires et rétroliens" 
    12691244 
    12701245msgid "Comments and trackback counted." 
    12711246msgstr "Commentaires et rétroliens comptés." 
    12721247 
    1273 msgid "Failed to reset comments and ping counters." 
    1274 msgstr "Impossible de remettre à zéro les compteurs de commentaires et de signalements." 
     1248msgid "Failed to count comments and trackbacks." 
     1249msgstr "Impossible de recompter les commentaires et rétroliens." 
    12751250 
    12761251msgid "Search engine index" 
     
    12801255msgstr "Indexation de tous les commentaires" 
    12811256 
    1282 msgid "next" 
    1283 msgstr "suivant" 
    1284  
    1285 #, php-format 
     1257msgid "Next" 
     1258msgstr "Suivant" 
     1259 
    12861260msgid "Indexing comment %d to %d." 
    12871261msgstr "Indexation des commentaires %d à %d." 
     
    12961270msgstr "Indexation de tous les billets" 
    12971271 
    1298 #, php-format 
    12991272msgid "Indexing entry %d to %d." 
    13001273msgstr "Indexation des billets %d à %d." 
     
    13151288msgstr "Impossible de supprimer les journaux." 
    13161289 
    1317 msgid "Vacuum tables" 
    1318 msgstr "Vidage des tables" 
     1290msgid "optimize tables" 
     1291msgstr "Optimiser les tables" 
    13191292 
    13201293msgid "Optimization successful." 
    13211294msgstr "Optimisation terminée avec succès." 
    13221295 
    1323 msgid "Failed to vacuum tables." 
    1324 msgstr "Impossible de vider les tables." 
     1296msgid "Failed to optimize tables." 
     1297msgstr "Impossible d'optimiser les tables." 
    13251298 
    13261299msgid "Download media folder of current blog" 
     
    13301303msgstr "Télécharger le theme actif du blog courant" 
    13311304 
    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." 
     1305msgid "Every week" 
     1306msgstr "Chaque semaine" 
     1307 
     1308msgid "Every two weeks" 
     1309msgstr "Toutes les deux semaines" 
     1310 
     1311msgid "Every month" 
     1312msgstr "Chaque mois" 
     1313 
     1314msgid "Every two months" 
     1315msgstr "Tous les deux mois" 
     1316 
     1317msgid "Use different periods for each task" 
     1318msgstr "Utiliser une période diffèrente pour chaque tâche" 
     1319 
     1320msgid "Never" 
     1321msgstr "Jamais" 
     1322 
     1323msgid "Settings successfully updated" 
     1324msgstr "Paramètres mis à jour avec succès" 
    13381325 
    13391326msgid "You should execute it now." 
    13401327msgstr "Vous devriez l'exécuter à nouveau." 
    13411328 
    1342 msgid "This task has never been executed." 
    1343 msgstr "" 
    1344  
    13451329msgid "Execute task" 
    13461330msgstr "Exécuter la tâche" 
    13471331 
    1348 msgid "This may take a very long time" 
    1349 msgstr "Cela peut prendre un certain temps" 
     1332msgid "This may take a very long time." 
     1333msgstr "Cela peut prendre un certain temps." 
     1334 
     1335msgid "Settings" 
     1336msgstr "Paramètres" 
     1337 
     1338msgid "Display alert messages on expired tasks" 
     1339msgstr "Afficher les messages d'alert sur les tâches expirées." 
     1340 
     1341msgid "Recall time for all tasks:" 
     1342msgstr "Délai de rappel pour toutes les tâches :" 
     1343 
     1344msgid "Recall time per task:" 
     1345msgstr "Délai de rappel par tâche :" 
     1346 
     1347msgid "You can place list of expired tasks on your %s." 
     1348msgstr "Vous pouvez placer la liste des tâches expirées sur votre %s." 
    13501349 
    13511350#, php-format 
  • plugins/maintenance/_admin.php

    r1969 r1984  
    2323// Admin behaviors 
    2424$core->addBehavior('dcMaintenanceRegister', array('dcMaintenanceAdmin', 'dcMaintenanceRegister')); 
    25 $core->addBehavior('adminPreferencesHeaders', array('dcMaintenanceAdmin', 'adminPreferencesHeaders')); 
    2625$core->addBehavior('adminDashboardFavs', array('dcMaintenanceAdmin', 'adminDashboardFavs')); 
    2726$core->addBehavior('adminDashboardFavsIcon', array('dcMaintenanceAdmin', 'adminDashboardFavsIcon')); 
    2827$core->addBehavior('adminDashboardItems', array('dcMaintenanceAdmin', 'adminDashboardItems')); 
    29 $core->addBehavior('adminPreferencesForm',   array('dcMaintenanceAdmin',   'adminPreferencesForm')); 
    30 $core->addBehavior('adminBeforeUserOptionsUpdate',     array('dcMaintenanceAdmin',   'adminBeforeUserOptionsUpdate')); 
     28$core->addBehavior('adminDashboardOptionsForm',   array('dcMaintenanceAdmin',   'adminDashboardOptionsForm')); 
     29$core->addBehavior('adminAfterDashboardOptionsUpdate', array('dcMaintenanceAdmin',   'adminAfterDashboardOptionsUpdate')); 
    3130 
    3231/** 
     
    6059 
    6160          $tasks[] = 'dcMaintenanceCache'; 
     61          $tasks[] = 'dcMaintenanceIndexposts'; 
     62          $tasks[] = 'dcMaintenanceIndexcomments'; 
    6263          $tasks[] = 'dcMaintenanceCountcomments'; 
    63           $tasks[] = 'dcMaintenanceIndexcomments'; 
    64           $tasks[] = 'dcMaintenanceIndexposts'; 
    6564          $tasks[] = 'dcMaintenanceLogs'; 
    6665          $tasks[] = 'dcMaintenanceVacuum'; 
    6766          $tasks[] = 'dcMaintenanceZipmedia'; 
    6867          $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'); 
    7968     } 
    8069 
     
    122111          // Check expired tasks 
    123112          $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); 
    131126     } 
    132127 
     
    145140 
    146141          $maintenance = new dcMaintenance($core); 
    147           $tasks = $maintenance->getExpired(); 
    148           if (empty($tasks)) { 
    149                return null; 
    150           } 
    151142 
    152143          $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          } 
    161165 
    162166          $items[] = new ArrayObject(array( 
    163167               '<div id="maintenance-expired">'. 
    164168               '<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>'. 
    166170               '<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>'. 
    168172               '</div>' 
    169173               )); 
     
    178182      * @param $args     <b>object</b>  dcCore instance or record 
    179183      */ 
    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'); 
    199187 
    200188          echo 
     
    202190          '<h4>'.__('Maintenance').'</h4>'. 
    203191 
    204           '<div class="two-boxes">'. 
    205  
    206192          '<p><label for="maintenance_dashboard_icon" class="classic">'. 
    207193          form::checkbox('maintenance_dashboard_icon', 1, $core->auth->user_prefs->maintenance->dashboard_icon). 
     
    210196          '<p><label for="maintenance_dashboard_item" class="classic">'. 
    211197          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 
    244200          '</div>'; 
    245201     } 
     
    248204      * User preferences update. 
    249205      * 
    250       * @param $cur <b>cursor</b>  Cursor of user options 
    251206      * @param $user_id  <b>string</b>  User ID 
    252207      */ 
    253      public static function adminBeforeUserOptionsUpdate($cur, $user_id=null) 
     208     public static function adminAfterDashboardOptionsUpdate($user_id=null) 
    254209     { 
    255210          global $core; 
    256211 
    257212          if (is_null($user_id)) { 
    258                return null; 
    259           } 
    260  
    261           $maintenance = new dcMaintenance($core); 
    262           $tasks = $maintenance->getTasks(); 
    263           if (empty($tasks)) { 
    264213               return null; 
    265214          } 
     
    268217          $core->auth->user_prefs->maintenance->put('dashboard_icon', !empty($_POST['maintenance_dashboard_icon']), 'boolean'); 
    269218          $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')   => 5184000 
    291           ); 
    292219     } 
    293220} 
  • plugins/maintenance/inc/class.dc.maintenance.php

    r1969 r1984  
    2525class dcMaintenance 
    2626{ 
    27      private $core; 
     27     public $core; 
    2828     private $tasks = array(); 
    2929     private $tabs = array(); 
    3030     private $groups = array(); 
     31     private $logs = null; 
    3132 
    3233     /** 
     
    4445          $tabs = new ArrayObject(); 
    4546          $groups = new ArrayObject(); 
     47          $logs = $this->getLogs(); 
    4648 
    4749          # --BEHAVIOR-- dcMaintenanceRegister 
     
    7577               } 
    7678 
    77                $this->tasks[$task] = new $task($this->core, 'plugin.php?p=maintenance'); 
     79               $this->tasks[$task] = new $task($this, 'plugin.php?p=maintenance'); 
    7880          } 
    7981 
     
    230232 
    231233     /** 
    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                    ); 
    252259               } 
    253260          } 
    254           return $logs; 
     261 
     262          return $this->logs; 
    255263     } 
    256264} 
  • plugins/maintenance/inc/class.dc.maintenance.task.php

    r1969 r1984  
    2121class dcMaintenanceTask 
    2222{ 
     23     protected $maintenance; 
    2324     protected $core; 
    2425     protected $p_url; 
    2526     protected $code; 
    26      protected $ts = 604800; // one week 
     27     protected $ts = 0; 
     28     protected $expired = 0; 
    2729     protected $ajax = false; 
     30     protected $blog = false; 
    2831 
    2932     protected $id; 
     
    4346      * use method init() to do it. 
    4447      * 
    45       * @param core <b>dcCore</b>  dcCore instance 
     48      * @param maintenance    <b>dcMaintenance</b>     dcMaintenance instance 
    4649      * @param p_url     <b>string</b>  Maintenance plugin url 
    4750      */ 
    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; 
    5155          $this->init(); 
    5256 
     
    6468          } 
    6569 
    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 
    6973          $this->ts = abs((integer) $ts); 
    7074     } 
     
    99103     { 
    100104          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; 
    101137     } 
    102138 
     
    251287     protected function log() 
    252288     { 
    253           $maintenance = new dcMaintenance($this->core); 
    254           $maintenance->setLog($this->id); 
     289          $this->maintenance->setLog($this->id); 
    255290     } 
    256291} 
  • plugins/maintenance/inc/tasks/class.dc.maintenance.countcomments.php

    r1925 r1984  
    1818     protected function init() 
    1919     { 
    20           $this->task         = __('Reset comments and ping counters'); 
     20          $this->task         = __('Count again comments and trackbacks'); 
    2121          $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.'); 
    2323     } 
    2424 
  • plugins/maintenance/inc/tasks/class.dc.maintenance.indexcomments.php

    r1959 r1984  
    2323          $this->name         = __('Search engine index'); 
    2424          $this->task         = __('Index all comments'); 
    25           $this->step_task    = __('next'); 
     25          $this->step_task    = __('Next'); 
    2626          $this->step         = __('Indexing comment %d to %d.'); 
    2727          $this->success           = __('Comments index done.'); 
  • plugins/maintenance/inc/tasks/class.dc.maintenance.indexposts.php

    r1959 r1984  
    2323          $this->name         = __('Search engine index'); 
    2424          $this->task         = __('Index all posts'); 
    25           $this->step_task    = __('next'); 
     25          $this->step_task    = __('Next'); 
    2626          $this->step         = __('Indexing entry %d to %d.'); 
    2727          $this->success           = __('Entries index done.'); 
  • plugins/maintenance/inc/tasks/class.dc.maintenance.vacuum.php

    r1925 r1984  
    1818     protected function init() 
    1919     { 
    20           $this->task         = __('Vacuum tables'); 
     20          $this->task         = __('optimize tables'); 
    2121          $this->success           = __('Optimization successful.'); 
    22           $this->error        = __('Failed to vacuum tables.'); 
     22          $this->error        = __('Failed to optimize tables.'); 
    2323     } 
    2424 
  • plugins/maintenance/inc/tasks/class.dc.maintenance.zipmedia.php

    r1955 r1984  
    1414class dcMaintenanceZipmedia extends dcMaintenanceTask 
    1515{ 
     16     protected $blog = true; 
    1617     protected $tab = 'backup'; 
    1718     protected $group = 'zipblog'; 
  • plugins/maintenance/inc/tasks/class.dc.maintenance.ziptheme.php

    r1955 r1984  
    1414class dcMaintenanceZiptheme extends dcMaintenanceTask 
    1515{ 
     16     protected $blog = true; 
    1617     protected $tab = 'backup'; 
    1718     protected $group = 'zipblog'; 
  • plugins/maintenance/index.php

    r1969 r1984  
    1717 
    1818$maintenance = new dcMaintenance($core); 
     19$core->blog->settings->addNamespace('maintenance'); 
    1920 
    2021// Set var 
    2122 
     23$msg = ''; 
    2224$headers = ''; 
    2325$p_url = 'plugin.php?p=maintenance'; 
     
    2729$code = empty($_POST['code']) ? null : (integer) $_POST['code']; 
    2830$tab = empty($_REQUEST['tab']) ? 'maintenance' : $_REQUEST['tab']; 
     31 
     32// Save settings 
     33 
     34if (!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} 
    2969 
    3070// Get task object 
     
    5898} 
    5999 
    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); 
    65118 
    66119// Display page 
     
    68121echo '<html><head> 
    69122<title>'.__('Maintenance').'</title>'. 
    70 dcPage::jsPageTabs($tab); 
     123dcPage::jsPageTabs($tab). 
     124dcPage::jsLoad('index.php?pf=maintenance/js/settings.js');; 
    71125 
    72126if ($task && $task->ajax()) { 
     
    87141// Success message 
    88142 
    89 $msg = $task && !empty($_GET['done']) ? dcPage::success($task->success(),true,true,false) : ''; 
     143if (!empty($_GET['done']) && $tab == 'settings') { 
     144     $msg = dcPage::success(__('Settings successfully updated'), true, true, false); 
     145} 
     146elseif (!empty($_GET['done']) && $task) { 
     147     $msg = dcPage::success($task->success(), true, true, false); 
     148} 
    90149 
    91150if ($task && ($res = $task->step()) !== null) { 
     
    120179     '</form>'. 
    121180     '<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>'. 
    123182     '</p>'. 
    124183     '</div>'; 
     
    156215                    html::escapeHTML($t->task()).'</label>'; 
    157216 
    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                         } 
    171235                    } 
    172236 
     
    192256               form::hidden(array('tab'), $tab_id). 
    193257               $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>'. 
    195259               '</form>'. 
    196260               '</div>'; 
     
    218282          '</div>'; 
    219283     } 
     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>'; 
    220325} 
    221326 
Note: See TracChangeset for help on using the changeset viewer.

Sites map