/** * Gets all modules in a bundle * @param string $bundleName * @param ModuleLocation $location Backend or frontend * @return string[] Returns the module names */ static function Modules($bundleName, ModuleLocation $location) { $result = array(); $modulesFolder = Path::Combine(self::BundleFolder($bundleName), 'Modules'); $folder = Path::Combine($modulesFolder, (string) $location); $files = Folder::GetFiles($folder); foreach ($files as $file) { $result[] = Path::RemoveExtension($file); } return $result; }
/** * Gets the module templates * @param FrontendModule $module The frontend module * @return string[] Returns the template files */ protected function ModuleTemplates($module) { $folder = PathUtil::ModuleCustomTemplatesFolder($module); if (!Folder::Exists($folder)) { return array(); } $templates = Folder::GetFiles($folder); $result = array(); foreach ($templates as $template) { if (Path::Extension($template) == 'phtml') { $result[] = Path::RemoveExtension($template); } } return $result; }
/** * Checks if the file given in the value doesn't exist yet * @param string $value The value to check * @return boolean True id check passed */ public function Check($value) { $this->error = ''; if ($this->currentFile && $value == $this->currentFile) { return true; } if (!Folder::Exists($this->folder)) { return true; } $files = Folder::GetFiles($this->folder); if ($this->fileExtension) { $value = Path::AddExtension($value, $this->fileExtension); } if (in_array($value, $files)) { $this->error = self::ExistsInFolder; } return $this->error == ''; }
/** * Executes all necessary scripts in the engine folder * @param string $engineFolder The folder * @throws \Exception Raises error if any of the scripts fail */ private function ExecuteScripts($engineFolder) { $files = $this->SortFilesByVersion(Folder::GetFiles($engineFolder)); $completeSql = ''; foreach ($files as $file) { $sqlFile = Path::Combine($engineFolder, $file); $completeSql .= "\r\n" . File::GetContents($sqlFile); } try { $this->CleanAllForeignKeys(); //$this->connection->StartTransaction(); $this->connection->ExecuteMultiQuery($completeSql); } catch (\Exception $exc) { //$this->connection->RollBack(); throw $exc; //throw new \Exception("Error executing SQL in folder $engineFolder: " . $completeSql, null, $exc); } //$this->connection->Commit(); }
/** * Adds the template select field * @param FrontendModule $module The module for template selection */ protected final function AddTemplateField() { $name = 'Template'; $field = new Select($name, (string) $this->Content()->GetTemplate()); $field->AddOption('', Trans("Core.ContentForm.{$name}.Default")); $folder = PathUtil::ModuleCustomTemplatesFolder($this->FrontendModule()); if (Folder::Exists($folder)) { $files = Folder::GetFiles($folder); foreach ($files as $file) { $value = Path::FilenameNoExtension($file); $field->AddOption($value, $value); } } $this->AddField($field, false, Trans("Core.ContentForm.{$name}")); }