ÿØÿà 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Á.. namespace core_block\external; use core_external\external_api; use core_external\external_function_parameters; use core_external\external_multiple_structure; use core_external\external_single_structure; use core_external\external_value; /** * This is the external method used for fetching the addable blocks in a given page. * * @package core_block * @since Moodle 3.11 * @copyright 2020 Mihail Geshoski * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class fetch_addable_blocks extends external_api { /** * Describes the parameters for execute. * * @return external_function_parameters */ public static function execute_parameters(): external_function_parameters { return new external_function_parameters( [ 'pagecontextid' => new external_value(PARAM_INT, 'The context ID of the page.'), 'pagetype' => new external_value(PARAM_ALPHANUMEXT, 'The type of the page.'), 'pagelayout' => new external_value(PARAM_ALPHA, 'The layout of the page.'), 'subpage' => new external_value(PARAM_TEXT, 'The subpage identifier', VALUE_DEFAULT, ''), 'pagehash' => new external_value(PARAM_ALPHANUMEXT, 'Page hash', VALUE_DEFAULT, ''), ] ); } /** * Fetch the addable blocks in a given page. * * @param int $pagecontextid The context ID of the page * @param string $pagetype The type of the page * @param string $pagelayout The layout of the page * @param string $subpage The subpage identifier * @param string $pagehash Page hash that can be provided instead of all parameters above * @return array The blocks list */ public static function execute(int $pagecontextid, string $pagetype, string $pagelayout, string $subpage = '', string $pagehash = ''): array { global $PAGE; $params = self::validate_parameters(self::execute_parameters(), [ 'pagecontextid' => $pagecontextid, 'pagetype' => $pagetype, 'pagelayout' => $pagelayout, 'subpage' => $subpage, 'pagehash' => $pagehash, ] ); if ($params['pagehash']) { // If pagehash is specified, all other parameters are ignored, all information // about the page is stored in the session. $page = \moodle_page::retrieve_edited_page($params['pagehash'], MUST_EXIST); self::validate_context($page->context); } else { // For backward-compatibility and Mobile App instead of pagehash // we can specify context, pagelayout, pagetype and subtype. $context = \context::instance_by_id($params['pagecontextid']); // Validate the context. This will also set the context in $PAGE. self::validate_context($context); // We need to manually set the page layout and page type. $PAGE->set_pagelayout($params['pagelayout']); $PAGE->set_pagetype($params['pagetype']); $PAGE->set_subpage($params['subpage']); $page = $PAGE; } // Firstly, we need to load all currently existing page blocks to later determine which blocks are addable. $page->blocks->load_blocks(false); $page->blocks->create_all_block_instances(); $addableblocks = $page->blocks->get_addable_blocks(); return array_map(function($block) use ($page) { $classname = \block_manager::get_block_edit_form_class($block->name); return [ 'name' => $block->name, 'title' => get_string('pluginname', "block_{$block->name}"), 'blockform' => $classname::display_form_when_adding() ? $classname : null, ]; }, $addableblocks); } /** * Describes the execute return value. * * @return external_multiple_structure */ public static function execute_returns(): external_multiple_structure { return new external_multiple_structure( new external_single_structure( [ 'name' => new external_value(PARAM_PLUGIN, 'The name of the block.'), 'title' => new external_value(PARAM_RAW, 'The title of the block.'), 'blockform' => new external_value(PARAM_RAW, 'If this block type has a form when it is being added then the classname of the form') ] ), 'List of addable blocks in a given page.' ); } }