当前位置: 首页>>代码示例>>PHP>>正文


PHP WizardServices::CopyDirFilesEx方法代码示例

本文整理汇总了PHP中WizardServices::CopyDirFilesEx方法的典型用法代码示例。如果您正苦于以下问题:PHP WizardServices::CopyDirFilesEx方法的具体用法?PHP WizardServices::CopyDirFilesEx怎么用?PHP WizardServices::CopyDirFilesEx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WizardServices的用法示例。


在下文中一共展示了WizardServices::CopyDirFilesEx方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: CopyDirFilesEx

	public static function CopyDirFilesEx($startFolderFrom, $startFolderTo, $arTranslateExt=array('php','css','js')) {
		global $APPLICATION;
		
		if (realpath($startFolderFrom) === realpath($startFolderTo)) {
			return false;
		}
		if (!is_dir($startFolderFrom)) {
			return false;
		}
		if (!is_dir($startFolderTo)) {
			mkdir($startFolderTo, BX_DIR_PERMISSIONS, true);
		}
		
		if (!is_array($arTranslateExt))
			$arTranslateExt=array('php','css','js');
		
		if ($dh = @opendir($startFolderFrom)) {
			while (($file = readdir($dh)) !== false) {
				if ($file == '.' || $file == '..') {
					continue;
				}
				$curFile = $startFolderFrom.'/'.$file;
				$toFile = $startFolderTo.'/'.$file;
				if (is_dir($curFile)) {
					WizardServices::CopyDirFilesEx($curFile, $toFile, $arTranslateExt);
				}
				if (is_file($curFile)) {
					$ext = ToLower(end(explode('.', $curFile)));
					if (!in_array($ext, $arTranslateExt)) {
						@copy($curFile, $toFile);
						@chmod($toFile, BX_FILE_PERMISSIONS);
						continue;
					}
					if (($fileContent = @file_get_contents($curFile)) !== false) {
						$fileContent = $APPLICATION->ConvertCharset($fileContent, 'Windows-1251', 'UTF-8');
						$res = @file_put_contents($toFile, $fileContent);
						if ($res) {
							@chmod($toFile, BX_FILE_PERMISSIONS);
						}
					}
				}
			}
		}
		
		return true;
	}
开发者ID:ASDAFF,项目名称:entask.ru,代码行数:46,代码来源:utils.php

示例2: OnPostForm

	function OnPostForm()
	{
		$wizard = &$this->GetWizard();
		
		if ($wizard->IsNextButtonClick())
		{
			$SITES = $wizard->GetVar('sites');
			$arSitesPassed = array();
			$pub_files = $wizard->GetVar('public_files_installed');
			$pub_data = $wizard->GetVar('public_data_installed');
			$pub_updater = $wizard->GetVar('public_data_updater');
			
			$arErrors=array();
			
			if (is_array($SITES) && count($SITES)) {
				$rS = CSite::GetList($ord='id', $dir='asc', array('ACTIVE'=>'Y'));
				$arSites = array();
				while($arr = $rS->Fetch()) {
					$arSites[$arr['LID']] = $arr;
				}
				
				foreach($SITES as $ST) {
					if (! in_array($ST, array_keys($arSites)) || !($arSites[$ST]['DIR'] || $arSites[$ST]['DOC_ROOT'])) {
						$arErrors[] = array('LID'=>$ST, 'MSG'=>GetMessage('WD_SITE_NOT_FOUND'));
						continue;
					}
					if (! empty($arSites[$ST]['DOC_ROOT'])) {
						if (! is_writable($arSites[$ST]['DOC_ROOT']) ) {
							$arErrors[] = array('LID'=>$ST, 'NAME'=>$arSites[$ST]['NAME'], 'PATH'=>$arSites[$ST]['DOC_ROOT'], 'MSG'=>GetMessage('WD_SITE_NOT_WRITABLE'));
							continue;
						}
						else {
							$doc_root = preg_replace('#\/$#', '', $arSites[$ST]['DOC_ROOT']);
						}
					}
					else {
						if (! is_writable($_SERVER['DOCUMENT_ROOT'] . $arSites[$ST]['DIR']) ) {
							$arErrors[] = array('LID'=>$ST, 'NAME'=>$arSites[$ST]['NAME'], 'PATH'=>$_SERVER['DOCUMENT_ROOT'] . $arSites[$ST]['DIR'], 'MSG'=>GetMessage('WD_SITE_NOT_WRITABLE'));
							continue;
						}
						else {
							$doc_root = preg_replace('#\/$#', '', $_SERVER['DOCUMENT_ROOT'] . $arSites[$ST]['DIR']);
						}
					}
					$tmpls = $wizard->GetVar('template_installed');
					$arFields=array();
					$arFields['NAME'] = $arSites[$ST]['NAME'];
					$index=1;
					foreach($tmpls as $tp) {
						$arFields["TEMPLATE"][] = array(
							"TEMPLATE" => $tp,
							"SORT" => $index++,
							"CONDITION" => ''
						);
					}
					
					$bIsUTF = (defined('BX_UTF') && BX_UTF == true);
					
					if (!$bIsUTF) {
						if (CopyDirFiles(str_replace('\\', '/', dirname(__FILE__)) . '/public_files', $doc_root, true, true) !== false) {
							$pub_files[] = '[' . $arSites[$ST]['LID'] . '] ' . $arSites[$ST]['NAME'];
							
							$langs = new CLang;
							if ($langs->Update($ST, $arFields) === false) {
								$arErrors[] = array('LID'=>$ST, 'NAME'=>$arSites[$ST]['NAME'], 'MSG'=>GetMessage('WD_TPL_NOT_ASSIGN'));
							}
							$arSitesPassed[] = $ST;
						}
						else {
							$this->SetError( GetMessage('WD_STEP_2_NOT_INSTALLED') );
						}
					}
					else {
						if (WizardServices::CopyDirFilesEx(str_replace('\\', '/', dirname(__FILE__)) . '/public_files', $doc_root) !== false) {
							
							$pub_files[] = '[' . $arSites[$ST]['LID'] . '] ' . $arSites[$ST]['NAME'];
							
							$langs = new CLang;
							if ($langs->Update($ST, $arFields) === false) {
								$arErrors[] = array('LID'=>$ST, 'NAME'=>$arSites[$ST]['NAME'], 'MSG'=>GetMessage('WD_TPL_NOT_ASSIGN'));
							}
							$arSitesPassed[] = $ST;
						}
						else {
							$this->SetError( GetMessage('WD_STEP_2_NOT_INSTALLED') );
						}
					}
				}
			}
			$wizard->SetVar('errors', $arErrors);
			$wizard->SetVar('public_files_installed', $pub_files);
			//$install_data = $wizard->GetVar('install_data');
			if (count($arSitesPassed) && count($pub_data)) {
				CModule::IncludeModule('iblock');
				// create iblock type
				$arType = array(
					'ID'=>'BT',
					"SECTIONS" => "Y",
					"IN_RSS" => "N",
					"SORT" => 100,
//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:entask.ru,代码行数:101,代码来源:wizard.php


注:本文中的WizardServices::CopyDirFilesEx方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。