Exemplo n.º 1
0
 private function setNavigation($sb)
 {
     $sb->appendLine();
     if (!isset($this->app->Navigations)) {
         return;
     }
     foreach ($this->app->Navigations as $item) {
         $createNew = false;
         if (!JwtUtil::folderExists($this->root . "Scripts/Components/" . $item['WidgetName'])) {
             $createNew = true;
         }
         JwtUtil::makeDirectory($this->root . "Scripts/Components/" . $item['WidgetName']);
         $sb->appendLine()->appendTab();
         $sb->appendFormat("stateprovider.state('%s'", $this->getNavigationStateName($item));
         $sb->append(",{");
         $sb->appendFormat("url:'/%s%s'", $item['NavigationName'], JwtUtil::IsNullOrEmptyString($item['ParamName']) ? "" : $this->getParamName($item['ParamName']));
         $view = $item['Views'];
         if (isset($view) && count($view) > 0) {
             $sb->append(",views:{");
             $isFirst = true;
             foreach ($view as $item2) {
                 if ($isFirst) {
                     $sb->append("'" . $item2['ViewName'] . "':{");
                 } else {
                     $sb->append(",'" . $item2['ViewName'] . "':{");
                 }
                 if (!JwtUtil::IsNullOrEmptyString($item2['WidgetName'])) {
                     $PathString = $this->root . sprintf("Scripts/Components/%s/%s.html", $item2['WidgetName'], $item2['WidgetName']);
                     if (!JwtUtil::fileExists($PathString)) {
                         JwtUtil::putContent($PathString, "<h3>widget Name : {{vm.title}}</h3>");
                     }
                     $sb->append("templateUrl:" . $this->getTemplatePath(sprintf("'Scripts/Components/%s/%s.html'", $item2['WidgetName'], $item2['WidgetName']), $item2['WidgetName']));
                     $this->mControllers[] = $item2['WidgetName'];
                     $PathString = $this->root . sprintf("Scripts/Components/%s/%sCtrl.js", $item2['WidgetName'], $item2['WidgetName']);
                     if (JwtUtil::fileExists($PathString)) {
                         $sb->appendFormat(",controller:'%sCtrl as vm'", $item2['WidgetName']);
                     }
                 }
                 $sb->append("}");
                 $isFirst = false;
             }
             $sb->append("}");
         }
         if (!JwtUtil::IsNullOrEmptyString($item['WidgetName'])) {
             if ($createNew) {
                 $PathString = $this->root . sprintf("Scripts/Components/%s/%s.html", $item['WidgetName'], $item['WidgetName']);
                 JwtUtil::putContent($PathString, "<h3>widget Name : {{vm.title}}</h3>");
                 $PathString = $this->root . sprintf("Scripts/Components/%s/%sCtrl.js", $item['WidgetName'], $item['WidgetName']);
                 JwtUtil::putContent($PathString, $this->getEmptyController($item['WidgetName']));
                 $PathString = $this->root . sprintf("Scripts/Components/%s/%sSvc.js", $item['WidgetName'], $item['WidgetName']);
                 JwtUtil::putContent($PathString, $this->getEmptyService($item['WidgetName']));
             }
             $PathString = $this->root . sprintf("Scripts/Components/%s/%s.html", $item['WidgetName'], $item['WidgetName']);
             if (JwtUtil::fileExists($PathString)) {
                 $sb->append(",templateUrl:" . $this->getTemplatePath(sprintf("'Scripts/Components/%s/%s.html'", $item['WidgetName'], $item['WidgetName']), $item['WidgetName']));
             }
             $PathString = $this->root . sprintf("Scripts/Components/%s/%sCtrl.js", $item['WidgetName'], $item['WidgetName']);
             if (JwtUtil::fileExists($PathString)) {
                 $sb->appendFormat(",controller:'%sCtrl as vm'", $item['WidgetName']);
             }
             $this->mControllers[] = $item['WidgetName'];
         }
         $sb->Append("});");
     }
 }