Exemplo n.º 1
0
		public static function copyContent($source, $destination)
		{
			if (is_dir($source) && $dh = opendir($source)) {
				if (!is_dir($destination))
					mkdir($destination, 0777);
					
				while (($file = readdir($dh)) !== false) {
					if ($file == '.' || $file == '..') {
						continue;
					} elseif (is_dir($source . DIRECTORY_SEPARATOR . $file)) {
						self::copy(
							$source . DIRECTORY_SEPARATOR . $file,
							$destination . DIRECTORY_SEPARATOR . $file
						);
					} else {
						FileUtils::copy(
							$source . DIRECTORY_SEPARATOR . $file,
							$destination . DIRECTORY_SEPARATOR . $file
						);
					}
				}
			}
		}
Exemplo n.º 2
0
		public function run()
		{
			$pool = get_object_vars($this->getXmlElement());
			if (!is_array($pool['file'])) $pool['file'] = array($pool['file']);
			
			foreach ($pool['file'] as $fileElement) {
				$from 	= (string)$fileElement->attributes()->from;
				$to		= (string)$fileElement->attributes()->to;

				if (!$from || !$to) continue;
				
				if (strpos($to ,'language/')!==false) {
					$dirs = 
						DirUtils::getDirs(
							$this->getParentAction()->getBuild()->getPath()
							. DIRECTORY_SEPARATOR . 'language'
							,
							false
						);
					foreach ($dirs as $dir) {
						FileUtils::copy(
							$this->
							getParentAction()->
							getCurrentMod()->
							getPath() . DIRECTORY_SEPARATOR . $from
							,
							$this->
							getParentAction()->
							getBuild()->
							getPath()
							.DIRECTORY_SEPARATOR 
							. preg_replace(
						    	'!language/(\w*)/!iS', 
						    	'language/' . $dir . '/', 
						    	$to
						    )
						);
					}
				} elseif (strpos($from, "*") && strpos($to, "*")) {
					$from = dirname(
						$this->
						getParentAction()->
						getCurrentMod()->
						getPath() . DIRECTORY_SEPARATOR .$from
					);
					
					$to = dirname(
						$this->
						getParentAction()->
						getBuild()->
						getPath()
						.DIRECTORY_SEPARATOR . $to
					);
					
					if(is_dir($to)) {
						DirUtils::copyContent($from, $to);
					} else {
						DirUtils::copy($from, $to);
					}					
				} else {
					if (
						!is_dir(
							$this->
							getParentAction()->
							getCurrentMod()->
							getPath() . DIRECTORY_SEPARATOR . $from
						)
					) {
						FileUtils::copy(
							$this->
							getParentAction()->
							getCurrentMod()->
							getPath() . DIRECTORY_SEPARATOR . $from
							,
							$this->
							getParentAction()->
							getBuild()->
							getPath() . DIRECTORY_SEPARATOR . $to
						);
					} else {
						DirUtils::copy(
							$this->
							getParentAction()->
							getCurrentMod()->
							getPath() . DIRECTORY_SEPARATOR . $from
							,
							$this->
							getParentAction()->
							getBuild()->
							getPath() . DIRECTORY_SEPARATOR . $to
						);
					}
				}
			}
		}