예제 #1
0
 public static function loadWidgetSpace($userId, $widgetSpaceFile)
 {
     $pathToWidgetSpace = WIDGET_SPACE_PATH . $widgetSpaceFile;
     if (file_exists($pathToWidgetSpace)) {
         # Try to load the widget space
         $doc = new DOMDocument('1.0', 'utf-8');
         $doc->formatOutput = true;
         $doc->preserveWhiteSpace = false;
         # Get all tabs
         $doc->load($pathToWidgetSpace);
         $xmlTabs = $doc->getElementsByTagName('tabs');
         foreach ($xmlTabs as $tabs) {
             $tabTitle = $tabs->getAttribute('title');
             # Maybe this tab name already exist
             $tabTitle = Tabs::getNewTabName($userId, $tabTitle);
             # Import the tab
             Tabs::addTab($userId, $tabTitle);
             # Get the tab layout type
             $xmlLayout = $tabs->getElementsByTagName('layout');
             if ($xmlLayout->length > 0) {
                 $layoutType = $xmlLayout->item(0)->getAttribute('type');
                 switch ($layoutType) {
                     case 'three_col_layout':
                         self::loadThreeColLayout($userId, $tabTitle, $xmlLayout->item(0));
                         break;
                     default:
                         throw new MwwException(MwwException::MODEL, 'WidgetSapce::loadWidgetSpace / The layout ' . $layoutType . ' is not supported');
                 }
             } else {
                 continue;
             }
         }
     } else {
         throw new MwwException(MwwException::MODEL, 'WidgetSapce::loadWidgetSpace / The file ' . $widgetSpaceFile . ' doesn\'t exists');
     }
 }