Rev 270 | Rev 279 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
<?phprequire_once(__DIR__ . '/cesa.php');class StaticsBlocks extends Cesa{public function __construct($title){global $USER, $PAGE, $SITE;require_login(null, false);if (isguestuser()) {throw new require_login_exception('Guests are not allowed here.');}$this->userID = optional_param('userid', $USER->id, PARAM_INT);$this->currentUser = $this->userID == $USER->id;$this->user = core_user::get_user($this->userID);$this->title = get_string($title);$this->blockManager = $PAGE->blocks;// Definimos varias regiones$this->regions = ['side-post'];$this->blockNames = ['cesa_course_rating', 'comments', 'messageteacher', 'mynotes'];$this->blockExists = true;if (!$this->user || !core_user::is_real_user($this->userID)) {throw new moodle_exception('invaliduser', 'error');}// Asignar y validar los bloques en todas las regionesforeach ($this->regions as $region) {$this->regionName = $region;$this->addRegion(); // Añadir la región si no existe$this->validateIfExistBlocks(); // Validar si los bloques existen$this->addBlocksIfNotExist(); // Añadir bloques si no existen}}public function renderBlocks(){global $OUTPUT;$blocksView = '';// Renderizar bloques para cada regiónforeach ($this->regions as $region) {$this->regionName = $region;$this->blockManager->load_blocks(true); // Cargar bloques en la región$blocksView .= $OUTPUT->blocks_for_region($this->regionName); // Renderizar bloques}return $blocksView; // Devolver bloques renderizados}}/* // Instanciamos y renderizamos la página con los bloques estáticos$statics_blocks = new StaticsBlocks();echo $statics_blocks->renderBlocks(); */