See Release Notes
Long Term Support Release
1 <?php 2 3 // This file is part of Moodle - http://moodle.org/ 4 // 5 // Moodle is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // Moodle is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 17 18 /** 19 * @package moodlecore 20 * @subpackage backup-xml 21 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 /** 26 * This abstract class implements one progressive_parser_processor 27 * 28 * Processor that will receive chunks of data from the @progressive_parser 29 * and will perform all sort of operations with them (join, split, invoke 30 * other methods, output, whatever... 31 * 32 * You will need to extend this class to get the expected functionality 33 * by implementing the @process_chunk() method to handle different 34 * chunks of information and, optionally, the @process_cdata() to 35 * process each cdata piece individually before being "published" to 36 * the chunk processor. 37 * 38 * The "propietary array format" that the parser publishes to the @progressive_parser_procesor 39 * is this: 40 * array ( 41 * 'path' => path where the tags belong to, 42 * 'level'=> level (1-based) of the tags 43 * 'tags => array ( 44 * 'name' => name of the tag, 45 * 'attrs'=> array( name of the attr => value of the attr), 46 * 'cdata => cdata of the tag 47 * ) 48 * ) 49 * 50 * TODO: Finish phpdocs 51 */ 52 abstract class progressive_parser_processor { 53 54 protected $inittime; // Initial microtime 55 protected $chunks; // Number of chunks processed 56 57 public function __construct() { 58 $this->inittime= microtime(true); 59 $this->chunks = 0; 60 } 61 62 /** 63 * Receive one chunk of information from the parser 64 */ 65 abstract public function process_chunk($data); 66 67 /** 68 * The parser fires this each time one path is going to be parsed 69 */ 70 public function before_path($path) { } 71 72 /** 73 * The parser fires this each time one path has been parsed 74 */ 75 public function after_path($path) { } 76 77 /** 78 * Perform custom transformations in the processed cdata 79 */ 80 public function process_cdata($cdata) { 81 return $cdata; 82 } 83 84 public function debug_info() { 85 return array('memory' => memory_get_peak_usage(true), 86 'time' => microtime(true) - $this->inittime, 87 'chunks' => $this->chunks); 88 } 89 90 public function receive_chunk($data) { 91 $this->chunks++; 92 $this->process_chunk($data); 93 } 94 95 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body