Proyectos de Subversion Moodle

Rev

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

Rev 286 Rev 287
Línea 53... Línea 53...
53
        if (!in_array($region, $existingRegions)) {
53
        if (!in_array($region, $existingRegions)) {
54
            $this->blockManager->add_region($region);
54
            $this->blockManager->add_region($region);
55
        }
55
        }
56
    }
56
    }
Línea 57... Línea -...
57
 
-
 
58
    public function validateIfExistBlocks($region)
-
 
59
    {
-
 
60
        // Obtener los bloques de la región actual.
-
 
61
        $blocks = $this->blockManager->get_blocks_for_region($region);
-
 
62
 
-
 
63
        // Validar si todos los bloques especificados existen en esta región.
-
 
64
        foreach ($this->blockNames as $blockName) {
-
 
65
            $blockFound = false;
-
 
66
            foreach ($blocks as $block) {
-
 
67
                if (get_class($block) == 'block_' . $blockName) {
-
 
68
                    $blockFound = true;
-
 
69
                    break;
-
 
70
                }
-
 
71
            }
-
 
72
            // Si algún bloque no se encuentra, devolvemos false.
-
 
73
            if (!$blockFound) {
-
 
74
                return false;
-
 
75
            }
-
 
76
        }
-
 
77
 
-
 
78
        // Si todos los bloques existen, devolvemos true.
-
 
79
        return true;
-
 
80
    }
-
 
81
 
-
 
82
    public function addBlocksIfNotExist($region)
-
 
83
    {
-
 
84
        // Si la variable blockExists es false, intentamos agregar los bloques.
-
 
85
        if (!$this->blockExists) {
-
 
86
            // Obtener los bloques de la región actual.
-
 
87
            $blocks = $this->blockManager->get_blocks_for_region($region);
-
 
88
 
-
 
89
            // Solo añadimos bloques si no existe ninguno de los especificados en blockNames.
-
 
90
            foreach ($this->blockNames as $blockName) {
-
 
91
                $blockFound = false;
-
 
92
 
-
 
93
                // Buscar si el bloque ya está presente en la región.
-
 
94
                foreach ($blocks as $block) {
-
 
95
                    if (get_class($block) == 'block_' . $blockName) {
-
 
96
                        $blockFound = true;
-
 
97
                        break;
-
 
98
                    }
-
 
99
                }
-
 
100
 
-
 
101
                // Si el bloque no está presente, lo añadimos en la región actual.
-
 
102
                if (!$blockFound) {
-
 
103
                    $this->blockManager->add_block($blockName, $region, 1, true);
-
 
104
                }
-
 
105
            }
-
 
106
        }
-
 
107
    }
-
 
Línea 108... Línea 57...
108
 
57
 
109
 
58
 
110
 
59