Commit 3325a189 authored by Petr Skoda's avatar Petr Skoda
Browse files

convert html import to new booktool plugin

fixes #5

AMOS BEGIN
 MOV [doimport,mod_book],[doimport,booktool_importhtml]
 MOV [import,mod_book],[import,booktool_importhtml]
 MOV [book:importhtml,mod_book],[importhtml:import,booktool_importhtml]
 MOV [importinfo,mod_book],[importinfo,booktool_importhtml]
 MOV [importing,mod_book],[importing,booktool_importhtml]
 MOV [importingchapters,mod_book],[importingchapters,booktool_importhtml]
 MOV [import_help,mod_book],[import_help,booktool_importhtml]
 MOV [maindirectory,mod_book],[maindirectory,booktool_importhtml]
 MOV [relinking,mod_book],[relinking,booktool_importhtml]
AMOS END
parent 4bc75ecc
......@@ -57,15 +57,4 @@ $capabilities = array(
'manager' => CAP_ALLOW,
)
),
'mod/book:import' => array(
'riskbitmask' => RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
)
),
);
......@@ -50,12 +50,6 @@ class book_chapter_edit_form extends moodleform {
$mform->setType('content_editor', PARAM_RAW);
$mform->addRule('content_editor', get_string('required'), 'required', null, 'client');
if ($chapter->id and has_capability('mod/book:import', $context)) {
//TODO: after files
//$mform->addElement('static', 'doimport', get_string('importingchapters', 'book').':', '<a href="import.php?id='.$chapter->cmid.'">'.get_string('doimport', 'book').'</a>');
}
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
......
......@@ -93,20 +93,8 @@ $string['navprev'] = 'Previous';
$string['navnext'] = 'Next';
$string['navexit'] = 'Exit book';
$string['importingchapters'] = 'Importing chapters into book';
$string['import'] = 'Import';
$string['import_help'] = 'You can import a single HTML file or every HTML file in a direcory. Relative file links are converted to absolute chapter links. Images, flash and Java are relinked too.';
$string['doimport'] = 'Import';
$string['doexport'] = 'Export';
$string['importing'] = 'Importing';
$string['relinking'] = 'Relinking';
$string['importinfo'] = 'Import selected HTML file or directory.<br />Chapters are sorted alphabetically using file names.<br />Files named \'sub_*.*\' are always imported as subchapters.';
$string['maindirectory'] = 'Main directory';
$string['fileordir'] = 'File or directory';
$string['book:read'] = 'Read book';
$string['book:edit'] = 'Edit book chapters';
$string['book:viewhiddenchapters'] = 'View hidden book chapters';
$string['book:import'] = 'Import chapters';
$string['errorchapter'] = 'Error reading book chapter.';
\ No newline at end of file
......@@ -259,11 +259,6 @@ function book_extend_settings_navigation(settings_navigation $settingsnav, navig
}
}
if (has_capability('mod/book:import', $PAGE->cm->context)) {
//TODO
//$doimport = ($allowimport and $edit) ? '<div>(<a href="import.php?id='.$cm->id.'">'.get_string('doimport', 'book').'</a>)</div>' : '';
}
if (has_capability('mod/book:edit', $PAGE->cm->context)) {
if (!empty($USER->editing)) {
$string = get_string("turneditingoff");
......
<?php
// This file is part of Book module for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Book import capability definition
*
* @package booktool
* @subpackage importhtml
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$capabilities = array(
'booktool/importhtml:import' => array(
'riskbitmask' => RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
)
),
);
......@@ -17,12 +17,14 @@
/**
* Book import form
*
* @package mod
* @subpackage book
* @package booktool
* @subpackage importhtml
* @copyright 2004-2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
require_once($CFG->libdir.'/formslib.php');
class book_import_form extends moodleform {
......
......@@ -17,12 +17,14 @@
/**
* Book import
*
* @package mod
* @subpackage book
* @package booktool
* @subpackage importhtml
* @copyright 2004-2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
die('TODO');
require('../../config.php');
require_once($CFG->dirroot.'/mod/book/locallib.php');
require_once('import_form.php');
......@@ -70,7 +72,7 @@ if ($mform->is_cancelled()) {
} else if ($data = $mform->get_data()) {
die('TODO');
/*
$coursebase = $CFG->dataroot.'/'.$book->course;
......
<?php
// This file is part of Book plugin for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Book import language strings
*
* @package booktool
* @subpackage importhtml
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
$string['doimport'] = 'Import';
$string['import'] = 'Import';
$string['importhtml:import'] = 'Import chapters';
$string['importinfo'] = 'Import selected HTML file or directory.<br />Chapters are sorted alphabetically using file names.<br />Files named \'sub_*.*\' are always imported as subchapters.';
$string['importing'] = 'Importing';
$string['importingchapters'] = 'Importing chapters into book';
$string['import_help'] = 'You can import a single HTML file or every HTML file in a direcory. Relative file links are converted to absolute chapter links. Images, flash and Java are relinked too.';
$string['maindirectory'] = 'Main directory';
$string['pluginname'] = 'Book HTML import';
$string['relinking'] = 'Relinking';
<?php
// This file is part of Book plugin for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* HTML import lib
*
* @package booktool
* @subpackage importhtml
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
function booktool_importhtml_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $booknode) {
global $USER, $PAGE, $CFG, $DB, $OUTPUT;
if ($PAGE->cm->modname !== 'book') {
return;
}
if (empty($PAGE->cm->context)) {
$PAGE->cm->context = get_context_instance(CONTEXT_MODULE, $PAGE->cm->instance);
}
$params = $PAGE->url->params();
if (empty($params['id'])) {
return;
}
if (has_capability('booktool/importhtml:import', $PAGE->cm->context)) {
//TODO
//$doimport = ($allowimport and $edit) ? '<div>(<a href="import.php?id='.$cm->id.'">'.get_string('doimport', 'book').'</a>)</div>' : '';
}
}
\ No newline at end of file
<?php
// This file is part of Book plugin for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Book import plugin version info
*
* @package booktool
* @subpackage importhtml
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2011090800; // The current plugin version (Date: YYYYMMDDXX)
$plugin->component = 'booktool_importhtml'; // Full name of the plugin (used for diagnostics)
......@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die;
$module->version = 2011032002; // The current module version (Date: YYYYMMDDXX)
$module->version = 2011032003; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2011070101; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)
$module->component = 'mod_book'; // Full name of the plugin (used for diagnostics)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment