Proyectos de Subversion Moodle

Rev

Rev 269 | Rev 271 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 269 Rev 270
Línea 35... Línea 35...
35
            $this->validateIfExistBlocks(); // Validar si los bloques existen
35
            $this->validateIfExistBlocks(); // Validar si los bloques existen
36
            $this->addBlocksIfNotExist(); // Añadir bloques si no existen
36
            $this->addBlocksIfNotExist(); // Añadir bloques si no existen
37
        }
37
        }
38
    }
38
    }
Línea 39... Línea -...
39
 
-
 
40
    public function addRegion()
-
 
41
    {
-
 
42
        // Añadir la región si no existe en blockManager
-
 
43
        if (!in_array($this->regionName, $this->blockManager->get_regions())) {
-
 
44
            $this->blockManager->add_region($this->regionName);
-
 
45
        }
-
 
46
    }
-
 
47
 
-
 
48
    public function validateIfExistBlocks()
-
 
49
    {
-
 
50
        $this->blockExists = true;
-
 
51
        $this->blocks = $this->blockManager->get_blocks_for_region($this->regionName);
-
 
52
 
-
 
53
        foreach ($this->blockNames as $blockName) {
-
 
54
            $blockFound = false;
-
 
55
            foreach ($this->blocks as $block) {
-
 
56
                $blockclass = get_class($block);
-
 
57
                if ($blockclass == 'block_' . $blockName) {
-
 
58
                    $blockFound = true;
-
 
59
                    break;
-
 
60
                }
-
 
61
            }
-
 
62
            if (!$blockFound) {
-
 
63
                $this->blockExists = false;
-
 
64
                break;
-
 
65
            }
-
 
66
        }
-
 
67
        return $this->blockExists;
-
 
68
    }
-
 
69
 
-
 
70
    public function addBlocksIfNotExist($page = 'courses')
-
 
71
    {
-
 
72
        if (!$this->blockExists) {
-
 
73
            foreach ($this->blockNames as $blockName) {
-
 
74
                $this->blockManager->add_block($blockName, $this->regionName, 1, true);
-
 
75
            }
-
 
76
        }
-
 
77
    }
-
 
78
 
39
 
79
    public function renderBlocks()
40
    public function renderBlocks()
80
    {
41
    {
Línea 81... Línea 42...
81
        global $OUTPUT;
42
        global $OUTPUT;