edit_xml_file_save.class.php

来自「很棒的在线教学系统」· PHP 代码 · 共 101 行

PHP
101
字号
<?php // $Id: edit_xml_file_save.class.php,v 1.4 2007/10/10 05:25:24 nicolasconnault Exp $/////////////////////////////////////////////////////////////////////////////                                                                       //// NOTICE OF COPYRIGHT                                                   ////                                                                       //// Moodle - Modular Object-Oriented Dynamic Learning Environment         ////          http://moodle.com                                            ////                                                                       //// Copyright (C) 1999 onwards Martin Dougiamas        http://dougiamas.com  ////           (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com  ////                                                                       //// This program 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 2 of the License, or     //// (at your option) any later version.                                   ////                                                                       //// This program 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:                          ////                                                                       ////          http://www.gnu.org/copyleft/gpl.html                         ////                                                                       //////////////////////////////////////////////////////////////////////////////// This class will save the changes performed to the comment of one fileclass edit_xml_file_save extends XMLDBAction {    /**     * Init method, every subclass will have its own     */    function init() {        parent::init();    /// Set own custom attributes    /// Get needed strings        $this->loadStrings(array(        /// 'key' => 'module',        ));    }    /**     * Invoke method, every class will have its own     * returns true/false on completion, setting both     * errormsg and output as necessary     */    function invoke() {        parent::invoke();        $result = true;    /// Set own core attributes        $this->does_generate = ACTION_NONE;        //$this->does_generate = ACTION_GENERATE_HTML;    /// These are always here        global $CFG, $XMLDB;    /// Do the job, setting result as needed        if (!data_submitted('nomatch')) { ///Basic prevention            error('Wrong action call');        }    /// Get parameters        $dirpath = required_param('dir', PARAM_PATH);        $dirpath = $CFG->dirroot . stripslashes_safe($dirpath);        $comment = required_param('comment', PARAM_CLEAN);        $comment = stripslashes_safe($comment);    /// Set comment and recalculate hash        $editeddir =& $XMLDB->editeddirs[$dirpath];        $structure =& $editeddir->xml_file->getStructure();        $structure->setComment($comment);        $structure->calculateHash(true);    /// If the hash has changed from the original one, change the version    /// and mark the structure as changed        $origdir =& $XMLDB->dbdirs[$dirpath];        $origstructure =& $origdir->xml_file->getStructure();        if ($structure->getHash() != $origstructure->getHash()) {            $structure->setVersion(userdate(time(), '%Y%m%d', 99, false));            $structure->setChanged(true);        }    /// Launch postaction if exists (leave this here!)        if ($this->getPostAction() && $result) {            return $this->launch($this->getPostAction());        }    /// Return ok if arrived here        return $result;    }}?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?