Changeset 2044:4a3330bc8bd5 for plugins/maintenance/inc
- Timestamp:
- 09/23/13 20:34:42 (12 years ago)
- Branch:
- default
- Location:
- plugins/maintenance/inc
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/maintenance/inc/class.dc.maintenance.php
r1989 r2044 26 26 { 27 27 public $core; 28 public $p_url = 'plugin.php?p=maintenance'; 29 28 30 private $tasks = array(); 29 31 private $tabs = array(); … … 34 36 * Constructor. 35 37 * 36 * Here you register tasks and groups for tasks.37 *38 38 * @param core <b>dcCore</b> dcCore instance 39 39 */ … … 41 41 { 42 42 $this->core = $core; 43 44 $tasks = new ArrayObject();45 $tabs = new ArrayObject();46 $groups = new ArrayObject();47 43 $logs = $this->getLogs(); 48 49 # --BEHAVIOR-- dcMaintenanceRegister 50 $core->callBehavior('dcMaintenanceRegister', $core, $tasks, $groups, $tabs); 51 52 $this->init($tasks, $groups, $tabs); 53 } 54 55 /** 56 * Initialize list of groups and tasks. 57 * 58 * @param tasks <b>arrayObject</b> Array of task to register 59 * @param groups <b>arrayObject</b> Array of groups to add 60 * @param tabs <b>arrayObject</b> Array of tabs to add 61 */ 62 public function init($tasks, $groups, $tabs) 63 { 64 $this->tasks = $this->groups = array(); 65 66 foreach($tasks as $task) 67 { 68 if (!class_exists($task)) { 69 continue; 70 } 71 72 $r = new ReflectionClass($task); 73 $p = $r->getParentClass(); 74 75 if (!$p || $p->name != 'dcMaintenanceTask') { 76 continue; 77 } 78 79 if (($t = new $task($this, 'plugin.php?p=maintenance')) === null 80 || $t->perm() === null && !$this->core->auth->isSuperAdmin() 81 || !$this->core->auth->check($t->perm(), $this->core->blog->id)) { 82 continue; 83 } 84 85 $this->tasks[$task] = $t; 86 } 87 88 foreach($groups as $id => $name) 89 { 90 $this->groups[(string) $id] = (string) $name; 91 } 92 93 foreach($tabs as $id => $name) 94 { 95 $this->tabs[(string) $id] = (string) $name; 96 } 97 } 98 99 /** 100 * Get a tab name. 44 $this->init(); 45 } 46 47 /** 48 * Initialize list of tabs and groups and tasks. 49 * 50 * To register a tab or group or task, 51 * use behavior dcMaintenanceInit then a method of 52 * dcMaintenance like addTab('myTab', ...). 53 */ 54 protected function init() 55 { 56 # --BEHAVIOR-- dcMaintenanceInit 57 $this->core->callBehavior('dcMaintenanceInit', $this); 58 } 59 60 /// @name Tab methods 61 //@{ 62 /** 63 * Add a tab. 64 * 65 * @param id <b>string<b> Tab ID 66 * @param name <b>string<b> Tab name 67 * @param options <b>string<b> Options 68 * @return <b>dcMaintenance</b> Self 69 */ 70 public function addTab($id, $name, $options=array()) 71 { 72 $this->tabs[$id] = new dcMaintenanceDescriptor($id, $name, $options); 73 74 return $this; 75 } 76 77 /** 78 * Get a tab. 101 79 * 102 80 * @param id <b>string</b> Tab ID 103 * @return <b> mixed</b> tab name or null if not exists81 * @return <b>object</b> dcMaintenanceDescriptor of a tab 104 82 */ 105 83 public function getTab($id) … … 117 95 return $this->tabs; 118 96 } 119 120 /** 121 * Get a group name. 97 //@} 98 99 100 /// @name Group methods 101 //@{ 102 /** 103 * Add a group. 104 * 105 * @param id <b>string<b> Group ID 106 * @param name <b>string<b> Group name 107 * @param options <b>string<b> Options 108 * @return <b>dcMaintenance</b> Self 109 */ 110 public function addGroup($id, $name, $options=array()) 111 { 112 $this->groups[$id] = new dcMaintenanceDescriptor($id, $name, $options); 113 114 return $this; 115 } 116 117 /** 118 * Get a group. 122 119 * 123 120 * @param id <b>string</b> Group ID 124 * @return <b> mixed</b> Group name or null if not exists121 * @return <b>object</b> dcMaintenanceDescriptor of a group 125 122 */ 126 123 public function getGroup($id) … … 132 129 * Get groups. 133 130 * 134 * @return <b>array</b> Array of groups ID and name131 * @return <b>array</b> Array of groups ID and descriptor 135 132 */ 136 133 public function getGroups() 137 134 { 138 135 return $this->groups; 136 } 137 //@} 138 139 140 /// @name Task methods 141 //@{ 142 /** 143 * Add a task. 144 * 145 * @param task <b>mixed<b> Class name or object 146 * @return <b>boolean</b> True if it is added 147 * @return <b>dcMaintenance</b> Self 148 */ 149 public function addTask($task) 150 { 151 if (class_exists($task) && is_subclass_of($task, 'dcMaintenanceTask')) { 152 $this->tasks[$task] = new $task($this); 153 } 154 155 return $this; 139 156 } 140 157 … … 174 191 return $res; 175 192 } 176 193 //@} 194 195 196 /// @name Log methods 197 //@{ 177 198 /** 178 199 * Set log for a task. … … 268 289 return $this->logs; 269 290 } 291 //@} 270 292 } -
plugins/maintenance/inc/class.dc.maintenance.task.php
r1989 r2044 33 33 protected $id; 34 34 protected $name; 35 protected $description; 35 36 protected $tab = 'maintenance'; 36 37 protected $group = 'other'; … … 50 51 * @param p_url <b>string</b> Maintenance plugin url 51 52 */ 52 public function __construct($maintenance , $p_url)53 public function __construct($maintenance) 53 54 { 54 55 $this->maintenance = $maintenance; … … 61 62 } 62 63 63 $this->p_url = $ p_url;64 $this->p_url = $maintenance->p_url; 64 65 $this->id = get_class($this); 65 66 … … 191 192 192 193 /** 194 * Get task description. 195 * 196 * @return <b>string</b> Description 197 */ 198 public function description() 199 { 200 return $this->description; 201 } 202 203 /** 193 204 * Get task tab. 194 205 * … … 322 333 $this->maintenance->setLog($this->id); 323 334 } 335 336 public function help() 337 { 338 return null; 339 } 324 340 } -
plugins/maintenance/inc/tasks/class.dc.maintenance.cache.php
r1925 r2044 21 21 $this->success = __('Templates cache directory emptied.'); 22 22 $this->error = __('Failed to empty templates cache directory.'); 23 24 $this->description = __("It may be useful to empty this cache when modifying a theme's .html or .css files (or when updating a theme or plugin). Notice : with some hosters, the templates cache cannot be emptied with this plugin. You may then have to delete the directory <strong>/cbtpl/</strong> directly on the server with your FTP software."); 23 25 } 24 26 -
plugins/maintenance/inc/tasks/class.dc.maintenance.countcomments.php
r1984 r2044 21 21 $this->success = __('Comments and trackback counted.'); 22 22 $this->error = __('Failed to count comments and trackbacks.'); 23 24 $this->description = __('Count again comments and trackbacks allows to check their exact numbers. This operation can be useful when importing from another blog platform (or when migrating from dotclear 1 to dotclear 2).'); 23 25 } 24 26 -
plugins/maintenance/inc/tasks/class.dc.maintenance.indexcomments.php
r1989 r2044 27 27 $this->success = __('Comments index done.'); 28 28 $this->error = __('Failed to index comments.'); 29 30 $this->description = __('Index all comments and trackbacks in search engine index. This operation is necessary, after importing content in your blog, to use internal search engine, on public and private pages.'); 29 31 } 30 32 -
plugins/maintenance/inc/tasks/class.dc.maintenance.indexposts.php
r1989 r2044 27 27 $this->success = __('Entries index done.'); 28 28 $this->error = __('Failed to index entries.'); 29 30 $this->description = __('Index all entries in search engine index. This operation is necessary, after importing content in your blog, to use internal search engine, on public and private pages.'); 29 31 } 30 32 -
plugins/maintenance/inc/tasks/class.dc.maintenance.logs.php
r1925 r2044 21 21 $this->success = __('Logs deleted.'); 22 22 $this->error = __('Failed to delete logs.'); 23 24 $this->description = __('Logs record all activity and connection to your blog history. Unless you need to keep this history, consider deleting these logs from time to time.'); 23 25 } 24 26 -
plugins/maintenance/inc/tasks/class.dc.maintenance.vacuum.php
r1984 r2044 18 18 protected function init() 19 19 { 20 $this->name = __('Optimise database'); 20 21 $this->task = __('optimize tables'); 21 22 $this->success = __('Optimization successful.'); 22 23 $this->error = __('Failed to optimize tables.'); 24 25 $this->description = __("After numerous delete or update operations on Dotclear's database, it gets fragmented. Optimizing will allow to defragment it. It has no incidence on your data's integrity. It is recommended to optimize before any blog export."); 23 26 } 24 27 -
plugins/maintenance/inc/tasks/class.dc.maintenance.zipmedia.php
r1989 r2044 22 22 { 23 23 $this->task = __('Download media folder of current blog'); 24 25 $this->description = __('It may be useful to backup your media folder. This compress all content of media folder into a single zip file. Notice : with some hosters, the media folder cannot be compressed with this plugin if it is too big.'); 24 26 } 25 27 -
plugins/maintenance/inc/tasks/class.dc.maintenance.ziptheme.php
r1989 r2044 22 22 { 23 23 $this->task = __('Download active theme of current blog'); 24 25 $this->description = __('It may be useful to backup the active theme before any change or update. This compress theme folder into a single zip file.'); 24 26 } 25 27
Note: See TracChangeset
for help on using the changeset viewer.