/** * Retrieve the lists of filenames. * Generate the Classes that list the Dal Modules names available in the * solution. * * @param assoc array $data depending on the situation, some data can be passed * on to generate the files desired. */ public function Run($data = null) { $FrameworkDalModules = DirectoryManager::GetFileNames("APP_ROOT_DIR" . \Puzzlout\Framework\Enums\FrameworkFolderName::DalModulesFolderName); $ApplicationDalModules = DirectoryManager::GetFileNames("APP_ROOT_DIR" . \Puzzlout\Framework\Enums\ApplicationFolderName::AppsFolderName . "APP_NAME" . \Puzzlout\Framework\Enums\ApplicationFolderName::DalModulesFolderName); $this->InitGenerateFrameworkFile($FrameworkDalModules); $this->InitGenerateApplicationFile($ApplicationDalModules); }
/** * Retrieve the lists of filenames. * Generate the Classes that list the Dal Modules names available in the * solution. */ public function Run($data = null) { $FrameworkList = DirectoryManager::GetFilesNamesRecursively("APP_ROOT_DIR" . \Puzzlout\Framework\Enums\FrameworkFolderName::ViewsFolderName); $ApplicationList = DirectoryManager::GetFilesNamesRecursively("APP_ROOT_DIR" . \Puzzlout\Framework\Enums\ApplicationFolderName::AppsFolderName . "APP_NAME" . \Puzzlout\Framework\Enums\ApplicationFolderName::ViewsFolderName); $this->InitGenerateFrameworkFile($FrameworkList); $this->InitGenerateApplicationFile($ApplicationList); }
public function UploadFiles() { $this->uploadDirectory = $this->GetUploadDirectory(); $this->resultJson["fileUploadResults"] = array(); foreach ($this->files as $file) { $this->currentFile = new \Puzzlout\Framework\Core\BO\FileUploadResult($file["tmp_name"]); //Init object $document = $this->InitDocumentObject(); //Check if file exist before adding a row in DB $this->currentFile->setFilePath($this->uploadDirectory . "/" . $document->document_value()); \Puzzlout\Framework\Core\DirectoryManager::CreateDirectory($this->uploadDirectory); $fileExists = \Puzzlout\Framework\Core\DirectoryManager::FileExists($this->currentFile->filePath()); $this->currentFile->setDoesExist($fileExists); //Add document to DB if (!$fileExists) { //Don't add the document in DB if already added $this->AddDocumentToDatabase($document); //Add document to uploads directory $uploaded = $this->UploadAFile($this->currentFile->tmpFilePath(), $this->currentFile->filePath()); $this->currentFile->setIsUploaded($uploaded); } else { $this->currentFile->setIsUploaded(false); } array_push($this->resultJson["fileUploadResults"], $this->currentFile); } return $this->resultJson; }
/** * Retrieve the partial view from either the Framework folder or the current Application folder. * * @param string $viewName The name of view to load * @throws \Puzzlout\Framework\Exceptions\ViewNotFoundException Throws an exception if the view is not found * @see \Puzzlout\Framework\Core\ViewLoader::GetFrameworkRootDir() * @see \Puzzlout\Framework\Core\ViewLoader::GetApplicationRootDir() */ public function GetPartialView($viewName) { $ListOfPathToCheck = array(DirectoryManager::GetFrameworkRootDir() . "Modules/", DirectoryManager::GetFrameworkRootDir() . $this->controller->module() . "/Modules/", DirectoryManager::GetApplicationRootDir() . "/Modules/", DirectoryManager::GetApplicationRootDir() . $this->controller->module() . "/Modules/"); foreach ($ListOfPathToCheck as $path) { $fileToCheck = $path . $viewName . self::VIEWFILEEXTENSION; if (file_exists($fileToCheck)) { return $fileToCheck; } } $errMsg = "Partial view \"" . $viewName . "\" not found in list." . var_dump($ListOfPathToCheck); throw new ViewNotFoundException($errMsg, MvcErrors::PARTIAL_VIEW_NOT_FOUND, null); }
function LoadFiles() { $this->uploadDirectory = $this->GetUploadDirectory(); $this->resultJson["fileResults"] = array(); $documents = $this->LoadDocumentObjects(); foreach ($documents as &$document) { $this->currentFile = new \Puzzlout\Framework\BO\FileUploadResult($document->document_value()); $this->currentFile->setFilePath($this->uploadDirectory . "/" . $document->document_value()); $this->currentFile->setWebPath($this->GetWebUploadDirectory() . "/" . $document->document_value()); $fileExists = \Puzzlout\Framework\Core\DirectoryManager::FileExists($this->currentFile->filePath()); if ($fileExists) { $this->currentFile->setDoesExist(true); array_push($this->resultJson["fileResults"], $this->currentFile); } } return $this->resultJson; }
/** * Generate the files for an app. * * @param string $Appname */ function ProcessApplicationData($Appname) { $ApplicationControllers = DirectoryManager::GetFileNames("APP_ROOT_DIR" . \Puzzlout\Framework\Enums\ApplicationFolderName::AppsFolderName . $Appname . \Puzzlout\Framework\Enums\ApplicationFolderName::ControllersFolderName); $this->params = array(BaseClassGenerator::NameSpaceKey => "Applications\\" . $Appname . "\\Generated", BaseClassGenerator::ClassNameKey => $Appname . $this->GeneratedClassPrefix, BaseClassGenerator::DestinationDirKey => \Puzzlout\Framework\Enums\ApplicationFolderName::AppsFolderName . $Appname . \Puzzlout\Framework\Enums\ApplicationFolderName::Generated, BaseClassGenerator::ClassDescriptionKey => "Lists the constants for application controller classes to autocompletion and easy coding.", ConstantsClassGeneratorBase::DoGenerateConstantKeysKey => true, ConstantsClassGeneratorBase::DoGenerateGetListMethodKey => true); $this->GenerateApplicationFile($ApplicationControllers); }
protected function AddFilePathToObjectList($list) { if (is_array($list)) { foreach ($list as &$object) { if ($object instanceof \Puzzlout\Framework\Interfaces\IDocument) { $filePath = $this->GetUploadDirectory($object) . "/" . $object->Filename(); $fileExists = \Puzzlout\Framework\Core\DirectoryManager::FileExists($filePath); if ($fileExists) { $object->setWebPath($this->GetWebUploadDirectory($object) . "/" . $object->Filename()); } } } } return $list; }