MDL-34441 cleanup dtl related phpdocs and minor style improvements

This commit is contained in:
Petr Škoda 2012-07-22 10:37:11 +02:00
parent e9324a2274
commit 5a773597de
17 changed files with 90 additions and 102 deletions

View File

@ -17,9 +17,8 @@
/**
* Transfer form
*
* @package tool
* @subpackage dbtransfer
* @copyright 2008 Petr Skoda
* @package tool_dbtransfer
* @copyright 2008 Petr Skoda {@link http://skodak.org/}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -27,6 +26,10 @@ defined('MOODLE_INTERNAL') || die;
require_once $CFG->libdir.'/formslib.php';
/**
* Definition of db export settings form.
*/
class database_export_form extends moodleform {
function definition() {

View File

@ -17,9 +17,8 @@
/**
* Transfer form
*
* @package tool
* @subpackage dbtransfer
* @copyright 2008 Petr Skoda
* @package tool_dbtransfer
* @copyright 2008 Petr Skoda {@link http://skodak.org/}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -27,6 +26,10 @@ defined('MOODLE_INTERNAL') || die;
require_once $CFG->libdir.'/formslib.php';
/**
* Definition of db transfer settings form.
*/
class database_transfer_form extends moodleform {
function definition() {

View File

@ -17,9 +17,8 @@
/**
* Export
*
* @package tool
* @subpackage dbtransfer
* @copyright 2008 Petr Skoda
* @package tool_dbtransfer
* @copyright 2008 Petr Skoda {@link http://skodak.org/}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -32,11 +31,11 @@ require_once('database_export_form.php');
require_login();
admin_externalpage_setup('tooldbexport');
//create form
// Create form.
$form = new database_export_form();
if ($data = $form->get_data()) {
dbtransfer_export_xml_database($data->description, $DB);
tool_dbtransfer_export_xml_database($data->description, $DB);
die;
}

View File

@ -17,9 +17,8 @@
/**
* Transfer tool
*
* @package tool
* @subpackage dbtransfer
* @copyright 2008 Petr Skoda
* @package tool_dbtransfer
* @copyright 2008 Petr Skoda {@link http://skodak.org/}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -32,7 +31,7 @@ require_once('database_transfer_form.php');
require_login();
admin_externalpage_setup('tooldbtransfer');
// Create the form
// Create the form.
$form = new database_transfer_form();
// If we have valid input.
@ -61,7 +60,7 @@ if ($data = $form->get_data()) {
// Do the transfer.
$feedback = new html_list_progress_trace();
dbtransfer_transfer_database($DB, $targetdb, $feedback);
tool_dbtransfer_transfer_database($DB, $targetdb, $feedback);
$feedback->finished();
// Finish up.

View File

@ -17,9 +17,8 @@
/**
* Strings for component 'tool_generator', language 'en', branch 'MOODLE_22_STABLE'
*
* @package tool
* @subpackage dbtransfer
* @copyright 2011 Petr Skoda
* @package tool_dbtransfer
* @copyright 2011 Petr Skoda {@link http://skodak.org/}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

View File

@ -17,9 +17,8 @@
/**
* Export db content to file.
*
* @package tool
* @subpackage dbtransfer
* @copyright 2008 Petr Skoda {@link http://skodak.org}
* @package tool_dbtransfer
* @copyright 2008 Petr Skoda {@link http://skodak.org/}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -44,8 +43,13 @@ TODO:
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/dtllib.php');
function dbtransfer_export_xml_database($description, $mdb) {
/**
* Initiate database export.
* @param string $description
* @param moodle_database $mdb
* @return does not return, calls die()
*/
function tool_dbtransfer_export_xml_database($description, $mdb) {
@set_time_limit(0);
session_get_instance()->write_close(); // release session
@ -65,8 +69,14 @@ function dbtransfer_export_xml_database($description, $mdb) {
die;
}
function dbtransfer_transfer_database($sourcedb, $targetdb, $feedback = null) {
/**
* Initiate database transfer.
* @param moodle_database $sourcedb
* @param moodle_database $targetdb
* @param progress_trace $feedback
* @return void
*/
function tool_dbtransfer_transfer_database(moodle_database $sourcedb, moodle_database $targetdb, progress_trace $feedback = null) {
@set_time_limit(0);
session_get_instance()->write_close(); // release session

View File

@ -15,11 +15,10 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Link to InnoDB conversion tool
* Add hidden links db transfer tool
*
* @package tool
* @subpackage dbtransfer
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @package tool_dbtransfer
* @copyright 2011 Petr Skoda {@link http://skodak.org/}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -29,4 +28,4 @@ if ($hassiteconfig) {
// DB transfer related pages
$ADMIN->add('experimental', new admin_externalpage('tooldbtransfer', get_string('dbtransfer', 'tool_dbtransfer'), $CFG->wwwroot.'/'.$CFG->admin.'/tool/dbtransfer/index.php', 'moodle/site:config', true));
$ADMIN->add('experimental', new admin_externalpage('tooldbexport', get_string('dbexport', 'tool_dbtransfer'), $CFG->wwwroot.'/'.$CFG->admin.'/tool/dbtransfer/dbexport.php', 'moodle/site:config', true));
}
}

View File

@ -17,9 +17,8 @@
/**
* Version details.
*
* @package tool
* @subpackage dbtransfer
* @copyright 2008 Petr Skoda
* @package tool_dbtransfer
* @copyright 2008 Petr Skoda {@link http://skodak.org/}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,12 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* General database export class
*
* @package core
* @subpackage dtl
* @package core_dtl
* @copyright 2008 Andrei Bautu
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -41,16 +38,17 @@ defined('MOODLE_INTERNAL') || die();
* @see export_table_data for the same table.
*/
abstract class database_exporter {
/** Connection to the source database (a @see moodle_database object). */
/** @var moodle_database Connection to the source database (a @see moodle_database object). */
protected $mdb;
/** Database manager of the source database (a @see database_manager object). */
/** @var database_manager Database manager of the source database (a @see database_manager object). */
protected $manager;
/** Source database schema in XMLDB format (a @see xmldb_structure object). */
/** @var xmldb_structure Source database schema in XMLDB format (a @see xmldb_structure object). */
protected $schema;
/**
* Boolean flag - whether or not to check that XML database schema matches
* the RDBMS database schema before exporting (used by
* @see export_database).
* @var bool
*/
protected $check_schema;
@ -158,5 +156,4 @@ abstract class database_exporter {
}
$this->finish_database_export();
}
}

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,12 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* General database importer class
*
* @package core
* @subpackage dtl
* @package core_dtl
* @copyright 2008 Andrei Bautu
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -43,23 +40,22 @@ defined('MOODLE_INTERNAL') || die();
* is respected.
*/
class database_importer {
/** Connection to the target database (a @see moodle_database object). */
/** @var moodle_database Connection to the target database (a @see moodle_database object). */
protected $mdb;
/** Database manager of the target database (a @see database_manager object). */
/** @var database_manager Database manager of the target database (a @see database_manager object). */
protected $manager;
/** Target database schema in XMLDB format (a @see xmldb_structure object). */
/** @var xmldb_structure Target database schema in XMLDB format (a @see xmldb_structure object). */
protected $schema;
/**
* Boolean flag - whether or not to check that XML database schema matches
* the RDBMS database schema before importing (used by
* @see begin_database_import).
* @var bool
*/
protected $check_schema;
/**
* How to use transactions.
*/
/** @var string How to use transactions. */
protected $transactionmode = 'allinone';
/** Transaction object */
/** @var moodle_transaction Transaction object */
protected $transaction;
/**
@ -105,7 +101,7 @@ class database_importer {
global $CFG;
if (!$this->mdb->get_tables()) {
// not tables yet, time to create all tables
// No tables present yet, time to create all tables.
$this->manager->install_from_xmldb_structure($this->schema);
}

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,12 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* General database mover class
*
* @package core
* @subpackage dtl
* @package core_dtl
* @copyright 2008 Andrei Bautu
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -28,33 +25,35 @@
defined('MOODLE_INTERNAL') || die();
class database_mover extends database_exporter {
/** Importer object used to transfer data. */
/** @var database_importer Importer object used to transfer data. */
protected $importer;
protected $feeback;
/** @var progress_trace Progress tracing object */
protected $feedback;
/**
* Object constructor.
*
* @param moodle_database $mdb Connection to the source database (a
* @param moodle_database $mdb_source Connection to the source database (a
* @see moodle_database object).
* @param moodle_database $mdb_target Connection to the target database (a
* @see moodle_database object).
* @param boolean $check_schema - whether or not to check that XML database
* schema matches the RDBMS database schema before exporting (used by
* @param progress_trace $feedback Progress tracing object
* @see export_database).
*/
public function __construct(moodle_database $mdb_source, moodle_database $mdb_target,
$check_schema = true, progress_trace $feeback = null) {
if (empty($feeback)) {
$this->feeback = new null_progress_trace();
$check_schema = true, progress_trace $feedback = null) {
if (empty($feedback)) {
$this->feedback = new null_progress_trace();
} else {
$this->feeback = $feeback;
$this->feedback = $feedback;
}
if ($check_schema) {
$this->feeback->output(get_string('checkingsourcetables', 'core_dbtransfer'));
$this->feedback->output(get_string('checkingsourcetables', 'core_dbtransfer'));
}
parent::__construct($mdb_source, $check_schema);
$this->feeback->output(get_string('creatingtargettables', 'core_dbtransfer'));
$this->feedback->output(get_string('creatingtargettables', 'core_dbtransfer'));
$this->importer = new database_importer($mdb_target, $check_schema);
}
@ -70,12 +69,13 @@ class database_mover extends database_exporter {
* Callback function. Calls importer's begin_database_import callback method.
*
* @param float $version the version of the system which generating the data
* @param string $release moodle release info
* @param string $timestamp the timestamp of the data (in ISO 8601) format.
* @param string $description a user description of the data.
* @return void
*/
public function begin_database_export($version, $release, $timestamp, $description) {
$this->feeback->output(get_string('copyingtables', 'core_dbtransfer'));
$this->feedback->output(get_string('copyingtables', 'core_dbtransfer'));
$this->importer->begin_database_import($version, $timestamp, $description);
}
@ -86,7 +86,7 @@ class database_mover extends database_exporter {
* @return void
*/
public function begin_table_export(xmldb_table $table) {
$this->feeback->output(get_string('copyingtable', 'core_dbtransfer', $table->getName()), 1);
$this->feedback->output(get_string('copyingtable', 'core_dbtransfer', $table->getName()), 1);
$this->importer->begin_table_import($table->getName(), $table->getHash());
}
@ -108,7 +108,7 @@ class database_mover extends database_exporter {
* @return void
*/
public function finish_table_export(xmldb_table $table) {
$this->feeback->output(get_string('done', 'core_dbtransfer', $table->getName()), 2);
$this->feedback->output(get_string('done', 'core_dbtransfer', $table->getName()), 2);
$this->importer->finish_table_import($table->getName());
}

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,12 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* XML format exporter class to file storage
*
* @package core
* @subpackage dtl
* @package core_dtl
* @copyright 2008 Andrei Bautu
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -31,9 +28,9 @@ defined('MOODLE_INTERNAL') || die();
* XML format exporter class to file storage.
*/
class file_xml_database_exporter extends xml_database_exporter {
/** Path to the XML data file. */
/** @var string Path to the XML data file. */
protected $filepath;
/** File descriptor for the output file. */
/** @var resource File descriptor for the output file. */
protected $file;
/**
@ -53,6 +50,7 @@ class file_xml_database_exporter extends xml_database_exporter {
/**
* Specific output method for the file XML sink.
* @param string $text
*/
protected function output($text) {
fwrite($this->file, $text);

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,12 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* XML format importer class from file storage
*
* @package core
* @subpackage dtl
* @package core_dtl
* @copyright 2008 Andrei Bautu
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -31,7 +28,7 @@ defined('MOODLE_INTERNAL') || die();
* XML format importer class from file storage.
*/
class file_xml_database_importer extends xml_database_importer {
/** Path to the XML data file. */
/** @var string Path to the XML data file. */
protected $filepath;
/**

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,12 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* XML format exporter class to memory storage
*
* @package core
* @subpackage dtl
* @package core_dtl
* @copyright 2008 Andrei Bautu
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -31,11 +28,12 @@ defined('MOODLE_INTERNAL') || die();
* XML format exporter class to memory storage (i.e. a string).
*/
class string_xml_database_exporter extends xml_database_exporter {
/** String with XML data. */
/** @var string String with XML data. */
protected $data;
/**
* Specific output method for the memory XML sink.
* @param string $text
*/
protected function output($text) {
$this->data .= $text;

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,12 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* XML format importer class from memory storage
*
* @package core
* @subpackage dtl
* @package core_dtl
* @copyright 2008 Andrei Bautu
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -31,13 +28,13 @@ defined('MOODLE_INTERNAL') || die();
* XML format importer class from memory storage (i.e. string).
*/
class string_xml_database_importer extends xml_database_importer {
/** String with XML data. */
/** @var string String with XML data. */
protected $data;
/**
* Object constructor.
*
* @param string data - string with XML data
* @param string $data - string with XML data
* @param moodle_database $mdb Connection to the target database
* @see xml_database_importer::__construct()
* @param boolean $check_schema - whether or not to check that XML database

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,12 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* XML format exporter class
*
* @package core
* @subpackage dtl
* @package core_dtl
* @copyright 2008 Andrei Bautu
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,12 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* XML format importer class
*
* @package core
* @subpackage dtl
* @package core_dtl
* @copyright 2008 Andrei Bautu
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -150,9 +147,9 @@ abstract class xml_database_importer extends database_importer {
* @param string $data character data to be processed
* @return void
*/
protected function cdata($parser, $cdata) {
protected function cdata($parser, $data) {
if (isset($this->current_field)) {
$this->current_data .= $cdata;
$this->current_data .= $data;
}
}
}