|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00030 abstract class backup_plugin { 00031 00032 protected $plugintype; 00033 protected $pluginname; 00034 protected $connectionpoint; 00035 protected $optigroup; // Optigroup, parent of all optigroup elements 00036 protected $step; 00037 protected $task; 00038 00039 public function __construct($plugintype, $pluginname, $optigroup, $step) { 00040 $this->plugintype = $plugintype; 00041 $this->pluginname = $pluginname; 00042 $this->optigroup = $optigroup; 00043 $this->connectionpoint = ''; 00044 $this->step = $step; 00045 $this->task = $step->get_task(); 00046 } 00047 00048 public function define_plugin_structure($connectionpoint) { 00049 00050 $this->connectionpoint = $connectionpoint; 00051 00052 $methodname = 'define_' . $connectionpoint . '_plugin_structure'; 00053 00054 if (method_exists($this, $methodname)) { 00055 $this->$methodname(); 00056 } 00057 } 00058 00059 // Protected API starts here 00060 00061 // backup_step/structure_step/task wrappers 00062 00066 protected function get_setting_value($name) { 00067 if (is_null($this->task)) { 00068 throw new backup_step_exception('not_specified_backup_task'); 00069 } 00070 return $this->task->get_setting_value($name); 00071 } 00072 00073 // end of backup_step/structure_step/task wrappers 00074 00079 protected function get_plugin_element($final_elements = null, $conditionparam = null, $conditionvalue = null) { 00080 // Something exclusive for this backup_plugin_element (backup_optigroup_element) 00081 // because it hasn't XML representation 00082 $name = 'optigroup_' . $this->plugintype . '_' . $this->pluginname . '_' . $this->connectionpoint; 00083 $optigroup_element = new backup_plugin_element($name, $final_elements, $conditionparam, $conditionvalue); 00084 $this->optigroup->add_child($optigroup_element); // Add optigroup_element to stay connected since beginning 00085 return $optigroup_element; 00086 } 00087 00092 protected function get_recommended_name() { 00093 return 'plugin_' . $this->plugintype . '_' . $this->pluginname . '_' . $this->connectionpoint; 00094 } 00095 00096 }