public function IsExist($name, $mode) { $path = $this->rootPath; switch ($mode) { case "Widgets": $path .= "Scripts/Components/" . $name; break; case "Components": $path .= "Scripts/Derictives/" . $name; break; case "Modules": $path .= "Scripts/Modules/" . $name; break; } return array('exist' => JwtUtil::folderExists($path)); }
public static function rename($pathx, $newName, $oldName) { $path = $pathx . $oldName; if (!JwtUtil::folderExists($path)) { return; } if (JwtUtil::fileExists($path . "/" . $oldName . ".html")) { rename($path . "/" . $oldName . ".html", $path . "/" . $newName . ".html"); //unlink($path ."/". $oldName . ".html"); } if (JwtUtil::fileExists($path . "/" . $oldName . "Ctrl.js")) { rename($path . "/" . $oldName . "Ctrl.js", $path . "/" . $newName . "Ctrl.js"); //unlink($path ."/". $oldName . "Ctrl.js"); } if (JwtUtil::fileExists($path . "/" . $oldName . "Svc.js")) { rename($path . "/" . $oldName . "Svc.js", $path . "/" . $newName . "Svc.js"); //unlink($path ."/". $oldName . "Svc.js"); } if (JwtUtil::fileExists($path . "/" . $oldName . ".css")) { rename($path . "/" . $oldName . ".css", $path . "/" . $newName . ".css"); //unlink($path ."/". $oldName . ".css"); } rename($path, $pathx . $newName); }
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("});"); } }