ÿØÿà JFIF    ÿÛ „  ( %"1!%)+...383,7(-.+  -+++--++++---+-+-----+---------------+---+-++7-----ÿÀ  ß â" ÿÄ     ÿÄ H    !1AQaq"‘¡2B±ÁÑð#R“Ò Tbr‚²á3csƒ’ÂñDS¢³$CÿÄ   ÿÄ %  !1AQa"23‘ÿÚ   ? ôÿ ¨pŸªáÿ —åYõõ\?àÒü©ŠÄï¨pŸªáÿ —åYõõ\?àÓü©ŠÄá 0Ÿªáÿ Ÿå[úƒ ú®ði~TÁbqÐ8OÕpÿ ƒOò¤Oè`–RÂáœá™êi€ßÉ< FtŸI“öÌ8úDf´°å}“¾œ6  öFá°y¥jñÇh†ˆ¢ã/ÃÐ:ªcÈ "Y¡ðÑl>ÿ ”ÏËte:qž\oäŠe÷󲍷˜HT4&ÿ ÓÐü6ö®¿øþßèô Ÿ•7Ñi’•j|“ñì>b…þS?*Óôÿ ÓÐü*h¥£ír¶ü UãS炟[AÐaè[ûª•õ&õj?†Éö+EzP—WeÒírJFt ‘BŒ†Ï‡%#tE Øz ¥OÛ«!1›üä±Í™%ºÍãö]°î(–:@<‹ŒÊö×òÆt¦ãº+‡¦%ÌÁ²h´OƒJŒtMÜ>ÀÜÊw3Y´•牋4ǍýʏTì>œú=Íwhyë,¾Ôò×õ¿ßÊa»«þˆѪQ|%6ž™A õ%:øj<>É—ÿ Å_ˆCbõ¥š±ý¯Ýƒï…¶|RëócÍf溪“t.СøTÿ *Ä¿-{†çàczůŽ_–^XþŒ±miB[X±d 1,é”zEù»& î9gœf™9Ð'.;—™i}!ôšåîqêÛ٤ёý£½ÆA–àôe"A$˝Úsäÿ ÷Û #°xŸëí(l »ý3—¥5m! rt`†0~'j2(]S¦¦kv,ÚÇ l¦øJA£Šƒ J3E8ÙiŽ:cÉžúeZ°€¯\®kÖ(79«Ž:¯X”¾³Š&¡* ….‰Ž(ÜíŸ2¥ª‡×Hi²TF¤ò[¨íÈRëÉ䢍mgÑ.Ÿ<öäS0í„ǹÁU´f#Vß;Õ–…P@3ío<ä-±»Ž.L|kªÀê›fÂ6@»eu‚|ÓaÞÆŸ…¨ááå>åŠ?cKü6ùTÍÆ”†sĤÚ;H2RÚ†õ\Ö·Ÿn'¾ ñ#ºI¤Å´%çÁ­‚â7›‹qT3Iï¨ÖÚ5I7Ë!ÅOóŸ¶øÝñØôת¦$Tcö‘[«Ö³šÒ';Aþ ¸èíg A2Z"i¸vdÄ÷.iõ®§)¿]¤À†–‡É&ä{V¶iŽ”.Ó×Õÿ û?h¬Mt–íª[ÿ Ñÿ ÌV(í}=ibÔ¡›¥¢±b Lô¥‡piη_Z<‡z§èŒ)iÖwiÇ 2hÙ3·=’d÷8éŽ1¦¸c¤µ€7›7Ø ð\á)} ¹fËí›pAÃL%âc2 í§æQz¿;T8sæ°qø)QFMð‰XŒÂ±N¢aF¨…8¯!U  Z©RÊ ÖPVÄÀÍin™Ì-GˆªÅËŠ›•zË}º±ŽÍFò¹}Uw×#ä5B¤{î}Ð<ÙD é©¤&‡ïDbàÁôMÁ.. /** * Library of functions and constants for module wiki * * It contains the great majority of functions defined by Moodle * that are mandatory to develop a module. * * @package mod_wiki * @copyright 2009 Marc Alier, Jordi Piguillem marc.alier@upc.edu * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu * * @author Jordi Piguillem * @author Marc Alier * @author David Jimenez * @author Josep Arus * @author Kenneth Riba * * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** * Generic parser implementation * * @author Josep Arús * * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package mod_wiki */ class wiki_parser_proxy { /** * @var array $parsers Array of parser instances */ private static $parsers = []; /** * Parse a string using a specific parser * * @param string $string The string to parse * @param string $type The parser type * @param array $options The parser options * @return mixed The parsed string or false if the parser type is not found */ public static function parse(&$string, $type, $options = []) { $type = strtolower($type); self::$parsers[$type] = null; // Reset the current parser because it may have other options. if (self::create_parser_instance($type)) { return self::$parsers[$type]->parse($string, $options); } else { return false; } } public static function get_token($name, $type) { if (self::create_parser_instance($type)) { return self::$parsers[$type]->get_token($name); } else { return false; } } public static function get_section(&$string, $type, $section, $allcontent = false) { if (self::create_parser_instance($type)) { $content = self::$parsers[$type]->get_section($section, $string, true); if ($allcontent) { return $content; } else { return is_array($content) ? $content[1] : null; } } else { return false; } } private static function create_parser_instance($type) { global $CFG; $type = clean_param($type, PARAM_ALPHA); if (empty(self::$parsers[$type])) { $path = "$CFG->dirroot/mod/wiki/parser/markups/$type.php"; if (!file_exists($path)) { throw new moodle_exception("Parser type $type not found"); } include_once($path); $class = strtolower($type) . "_parser"; if (class_exists($class)) { self::$parsers[$type] = new $class; return true; } else { return false; } } else { return true; } } } require_once('utils.php'); abstract class generic_parser { protected $string; protected $blockrules = array(); protected $tagrules = array(); private $rulestack = array(); protected $parserstatus = 'Before'; /** * Dynamic return values */ protected $returnvalues = array(); private $nowikiindex = array(); protected $nowikitoken = "%!"; public function __construct() { } /** * Parse function */ public function parse(&$string, $options = array()) { if (!is_string($string)) { return false; } $this->string =& $string; $this->set_options(is_array($options) ? $options : array()); $this->initialize_nowiki_index(); if (method_exists($this, 'before_parsing')) { $this->before_parsing(); } $this->parserstatus = 'Parsing'; foreach ($this->blockrules as $name => $block) { $this->process_block_rule($name, $block); } $this->commit_nowiki_index(); $this->parserstatus = 'After'; if (method_exists($this, 'after_parsing')) { $this->after_parsing(); } return array('parsed_text' => $this->string) + $this->returnvalues; } /** * Initialize options */ protected function set_options($options) { } /** * Block processing function & callbacks */ protected function process_block_rule($name, $block) { $this->rulestack[] = array('callback' => method_exists($this, $name . "_block_rule") ? $name . "_block_rule" : null, 'rule' => $block); $this->string = preg_replace_callback($block['expression'], array($this, 'block_callback'), $this->string); array_pop($this->rulestack); } private function block_callback($match) { $rule = end($this->rulestack); if (!empty($rule['callback'])) { $stuff = $this->{$rule['callback']}($match); } else { $stuff = $match[1]; } if (is_array($stuff) && $rule['rule']['tag']) { $this->rules($stuff[0], $rule['rule']['tags']); $stuff = "\n" . parser_utils::h($rule['rule']['tag'], $stuff[0], $stuff[1]) . "\n"; } else { if (!isset($rule['rule']['tags'])) { $rule['rule']['tags'] = null; } $this->rules($stuff, $rule['rule']['tags']); if (isset($rule['rule']['tag']) && is_string($rule['rule']['tag'])) { $stuff = "\n" . parser_utils::h($rule['rule']['tag'], $stuff) . "\n"; } } return $stuff; } /** * Rules processing function & callback */ protected final function rules(&$text, $rules = null) { if ($rules === null) { $rules = array('except' => array()); } else if (is_array($rules) && count($rules) > 1) { $rules = array('only' => $rules); } if (isset($rules['only']) && is_array($rules['only'])) { $rules = $rules['only']; foreach ($rules as $r) { if (!empty($this->tagrules[$r])) { $this->process_tag_rule($r, $this->tagrules[$r], $text); } } } else if (isset($rules['except']) && is_array($rules['except'])) { $rules = $rules['except']; foreach ($this->tagrules as $r => $tr) { if (!in_array($r, $rules)) { $this->process_tag_rule($r, $tr, $text); } } } } private function process_tag_rule($name, $rule, &$text) { if (method_exists($this, $name . "_tag_rule")) { $this->rulestack[] = array('callback' => $name . "_tag_rule", 'rule' => $rule); $text = preg_replace_callback($rule['expression'], array($this, 'tag_callback'), $text); array_pop($this->rulestack); } else { if (isset($rule['simple'])) { $replace = "<{$rule['tag']} />"; } else { $replace = parser_utils::h($rule['tag'], "$1"); } $text = preg_replace($rule['expression'], $replace, $text); } } private function tag_callback($match) { $rule = end($this->rulestack); $stuff = $this->{$rule['callback']}($match); if (is_array($stuff)) { return parser_utils::h($rule['rule']['tag'], $stuff[0], $stuff[1]); } else { return $stuff; } } /** * Special nowiki parser index */ private function initialize_nowiki_index() { $token = "\Q" . $this->nowikitoken . "\E"; $this->string = preg_replace_callback("/" . $token . "\d+" . $token . "/", array($this, "initialize_nowiki_index_callback"), $this->string); } private function initialize_nowiki_index_callback($match) { return $this->protect($match[0]); } protected function protect($text) { $this->nowikiindex[] = $text; return $this->nowikitoken . (count($this->nowikiindex) - 1) . $this->nowikitoken; } private function commit_nowiki_index() { $token = "\Q" . $this->nowikitoken . "\E"; $this->string = preg_replace_callback("/" . $token . "(\d+)" . $token . "/", array($this, "commit_nowiki_index_callback"), $this->string); } private function commit_nowiki_index_callback($match) { return $this->nowikiindex[intval($match[1])]; } /** * Get token of the parsable element $name. */ public function get_token($name) { foreach (array_merge($this->blockrules, $this->tagrules) as $n => $v) { if ($name == $n && isset($v['token'])) { return $v['token'] ? $v['token'] : false; } } return false; } }