Ejemplo n.º 1
0
 public static function scanBlocks()
 {
     $modules = invokable_modules("block_info");
     $real_blocks = array();
     foreach ($modules as $module) {
         $tmp = method_invoke($module, "block_info");
         foreach ($tmp as $k => $v) {
             $tmp[$k]["module"] = $module;
             $tmp[$k]["block"] = $k;
         }
         $real_blocks = array_merge($real_blocks, $tmp);
     }
     $saved_blocks = self::get_all_blocks();
     foreach ($real_blocks as $blockName => $blockData) {
         $exist = false;
         foreach ($saved_blocks as $key => $sb) {
             if ($blockName == $sb) {
                 $exist = true;
                 unset($saved_blocks[$key]);
                 // self::update_block($blockName, $blockData);
                 break;
             }
         }
         if (!$exist) {
             self::insert_block($blockData);
         }
     }
     foreach ($saved_blocks as $b) {
         self::delete_block($b);
     }
     page::redirect("/admin/blocks");
 }
Ejemplo n.º 2
0
 public static function theme_menu()
 {
     self::include_theme();
     $modules = invokable_modules("menu_ui");
     $a = array();
     foreach ($modules as $module) {
         $b = method_invoke($module, "menu_ui");
         foreach ($b as $k => $element) {
             $s = true;
             if (count($a) > 0) {
                 foreach ($a as $l => $currents) {
                     if ($currents['name'] == $element['name']) {
                         $s = false;
                         if (!isset($currents['url'])) {
                             $a[$l]['url'] = $currents['url'];
                         }
                         if (isset($element['submenu'])) {
                             $a[$l]['submenu'] = array_merge($a[$l]['submenu'], $element['submenu']);
                         }
                     }
                 }
                 if ($s) {
                     $a[] = $element;
                 }
             } else {
                 $a[] = $element;
             }
         }
     }
     /*         * */
     foreach ($a as $key => $link) {
         if (!page::access_check_by_url($link['url'])) {
             unset($a[$key]);
         } else {
             if (isset($link['submenu'])) {
                 foreach ($link['submenu'] as $subkey => $sublink) {
                     if (!page::access_check_by_url($sublink['url'])) {
                         unset($a[$key]['submenu'][$subkey]);
                     }
                 }
             }
         }
     }
     /*         * */
     return theme_ui::header_menu($a);
 }