|
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 00031 abstract class backup_subplugin { 00032 00033 protected $subplugintype; 00034 protected $subpluginname; 00035 protected $connectionpoint; 00036 protected $optigroup; // Optigroup, parent of all optigroup elements 00037 protected $step; 00038 protected $task; 00039 00040 public function __construct($subplugintype, $subpluginname, $optigroup, $step) { 00041 $this->subplugintype = $subplugintype; 00042 $this->subpluginname = $subpluginname; 00043 $this->optigroup = $optigroup; 00044 $this->connectionpoint = ''; 00045 $this->step = $step; 00046 $this->task = $step->get_task(); 00047 } 00048 00049 public function define_subplugin_structure($connectionpoint) { 00050 00051 $this->connectionpoint = $connectionpoint; 00052 00053 $methodname = 'define_' . $connectionpoint . '_subplugin_structure'; 00054 00055 if (method_exists($this, $methodname)) { 00056 $this->$methodname(); 00057 } 00058 } 00059 00060 // Protected API starts here 00061 00062 // backup_step/structure_step/task wrappers 00063 00067 protected function get_setting_value($name) { 00068 if (is_null($this->task)) { 00069 throw new backup_step_exception('not_specified_backup_task'); 00070 } 00071 return $this->task->get_setting_value($name); 00072 } 00073 00074 // end of backup_step/structure_step/task wrappers 00075 00080 protected function get_subplugin_element($final_elements = null, $conditionparam = null, $conditionvalue = null) { 00081 // Something exclusive for this backup_subplugin_element (backup_optigroup_element) 00082 // because it hasn't XML representation 00083 $name = 'optigroup_' . $this->subplugintype . '_' . $this->subpluginname . '_' . $this->connectionpoint; 00084 $optigroup_element = new backup_subplugin_element($name, $final_elements, $conditionparam, $conditionvalue); 00085 $this->optigroup->add_child($optigroup_element); // Add optigroup_element to stay connected since beginning 00086 return $optigroup_element; 00087 } 00088 00093 protected function get_recommended_name() { 00094 return 'subplugin_' . $this->subplugintype . '_' . $this->subpluginname . '_' . $this->connectionpoint; 00095 } 00096 00097 }