private function renderClientPrivileges($path, $className, $privilegeList) { $lastDot = strrpos($className, '.'); $package = substr($className, 0, $lastDot); $class = substr($className, $lastDot + 1); $imports = ''; if (!strpos($package, 'gpf')) { $imports = ' import com.qualityunit.gpf.client.model.Application; import com.qualityunit.gpf.client.model.Permission; '; } $permissionVariables = ''; foreach ($privilegeList as $object => $privileges) { foreach ($privileges as $privilege) { $permissionVariables .= ' ' . strtoupper($object) . '_' . strtoupper($privilege) . "(\"{$object}|{$privilege}\"),\n"; } } $permissionVariables = rtrim($permissionVariables, " ,'\n") . ';'; $content = "/**\n * Copyright 2007 Quality Unit s.r.o.\n *\n * Licensed under the Quality Unit, s.r.o. Standard End User License Agreement,\n * Version 1.0 (the \"License\"); you may not use this file except in compliance\n * with the License. You may obtain a copy of the License at\n * http://www.qualityunit.com/licenses/license\n *\n */\n\npackage {$package};\n{$imports}\npublic enum {$class} implements Permission {\n{$permissionVariables}\n\n private String permission;\n\n private {$class}(String permission) {\n this.permission = permission;\n }\n\n public boolean isAllowed() {\n return Application.hasPermission(permission);\n }\n}"; $file = new Gpf_Io_File($path . str_replace('.', '/', $className) . '.java'); $file->putContents($content); }
private function replaceTemplatesInDirectory($cacheZipFolderPath, $filetypes, Pap_Common_User $affiliate, Pap_Common_Banner $banner, $channelcode){ $cacheZipFolder = new Gpf_Io_DirectoryIterator($cacheZipFolderPath, '', true); $typesArray = $this->getFileTypesArray($filetypes); foreach ($cacheZipFolder as $fullFileName => $fileName) { $file = new Gpf_Io_File($fullFileName); if ($file->matchPatterns($typesArray)){ $content = $this->replaceVariables($affiliate, $banner, $channelcode, $file->getContents()); $file->putContents($content); } } }