25 public static function GetWizardList($filterNamespace =
false, $bLoadFromModules =
false)
28 $arLoadedWizards =
array();
30 $wizardPath =
$_SERVER[
"DOCUMENT_ROOT"].CWizardUtil::GetRepositoryPath();
32 if (
$handle = @opendir($wizardPath))
34 while (($dirName = readdir(
$handle)) !==
false)
36 if ($dirName ==
"." || $dirName ==
".." || !is_dir($wizardPath.
"/".$dirName))
39 if (file_exists($wizardPath.
"/".$dirName.
"/.description.php"))
42 if ($filterNamespace !==
false && $filterNamespace <>
'')
45 if (LANGUAGE_ID !=
"en" && LANGUAGE_ID !=
"ru")
50 __IncludeLang($wizardPath.
"/".$dirName.
"/lang/".LANGUAGE_ID.
"/.description.php",
false);
52 $arWizardDescription =
array();
53 include($wizardPath.
"/".$dirName.
"/.description.php");
54 $arWizards[] =
array(
"ID" => $dirName) + $arWizardDescription;
55 $arLoadedWizards[] = $dirName;
59 if ($filterNamespace !==
false && ($filterNamespace ==
'' || $filterNamespace != $dirName))
62 if ($nspaceHandle = @opendir($wizardPath.
"/".$dirName))
64 while (($file = readdir($nspaceHandle)) !==
false)
66 $pathToWizard = $wizardPath.
"/".$dirName.
"/".$file;
68 if ($file ==
"." || $file ==
".." || !is_dir($pathToWizard))
71 if (file_exists($pathToWizard.
"/.description.php"))
73 if (LANGUAGE_ID !=
"en" && LANGUAGE_ID !=
"ru")
78 __IncludeLang($pathToWizard.
"/lang/".LANGUAGE_ID.
"/.description.php",
false);
80 $arWizardDescription =
array();
81 include($pathToWizard.
"/.description.php");
82 $arWizards[] =
array(
"ID" => $dirName.
":".$file) + $arWizardDescription;
83 $arLoadedWizards[] = $dirName.
":".$file;
87 @closedir($nspaceHandle);
94 if ($bLoadFromModules)
96 $modulesPath =
$_SERVER[
"DOCUMENT_ROOT"].
"/bitrix/modules";
98 if (
$handle = @opendir($modulesPath))
100 while (($moduleName = readdir(
$handle)) !==
false)
102 if ($moduleName ==
"." || $moduleName ==
".." || !is_dir($modulesPath.
"/".$moduleName))
105 if (!file_exists($modulesPath.
"/".$moduleName.
"/install/wizards"))
108 if ($handle1 = @opendir($modulesPath.
"/".$moduleName.
"/install/wizards"))
110 while (($dirName = readdir($handle1)) !==
false)
112 if ($dirName ==
"." || $dirName ==
".." || !is_dir($modulesPath.
"/".$moduleName.
"/install/wizards/".$dirName))
115 if ($filterNamespace !==
false && ($filterNamespace ==
'' || $filterNamespace != $dirName))
118 if ($handle2 = @opendir($modulesPath.
"/".$moduleName.
"/install/wizards/".$dirName))
120 while (($file = readdir($handle2)) !==
false)
122 $pathToWizard = $modulesPath.
"/".$moduleName.
"/install/wizards/".$dirName.
"/".$file;
124 if ($file ==
"." || $file ==
".." || !is_dir($pathToWizard))
127 if (in_array($dirName.
":".$file, $arLoadedWizards))
130 if (file_exists($pathToWizard.
"/.description.php"))
132 if (LANGUAGE_ID !=
"en" && LANGUAGE_ID !=
"ru")
137 __IncludeLang($pathToWizard.
"/lang/".LANGUAGE_ID.
"/.description.php",
false);
139 $arWizardDescription =
array();
140 include($pathToWizard.
"/.description.php");
141 $arWizards[] =
array(
"ID" => $moduleName.
":".$dirName.
":".$file) + $arWizardDescription;
142 $arLoadedWizards[] = $dirName.
":".$file;
216 public static function ReplaceMacros($filePath, $arReplace, $skipSharp =
false)
220 if (!is_file($filePath) || !is_writable($filePath) || !is_array($arReplace))
223 @chmod($filePath, BX_FILE_PERMISSIONS);
225 if (!
$handle = @fopen($filePath,
"rb"))
231 if (!(
$handle = @fopen($filePath,
"wb")))
239 foreach ($arReplace as $search => $replace)
242 $arSearch[] = $search;
244 $arSearch[] =
"#".$search.
"#";
246 $arValue[] = $replace;
260 if ((!is_dir($filePath) && !is_file($filePath)) || !is_array($arReplace))
263 $root = (defined(
"WIZARD_SITE_ROOT_PATH")? WIZARD_SITE_ROOT_PATH :
$_SERVER[
"DOCUMENT_ROOT"]);
264 $root = trim($root,
"/");
266 if (
$handle = @opendir($filePath))
268 while (($file = readdir(
$handle)) !==
false)
270 if ($file ==
"." || $file ==
".." || (trim($filePath,
"/") == $root && ($file ==
"bitrix" || $file ==
"upload")))
273 if (is_dir($filePath.
"/".$file))
277 elseif (is_file($filePath.
"/".$file))
282 if (!is_writable($filePath.
"/".$file))
285 $size = filesize($filePath.
"/".$file);
292 @chmod($filePath.
"/".$file, BX_FILE_PERMISSIONS);
294 if (!$handleFile = @fopen($filePath.
"/".$file,
"rb"))
297 $content = @fread($handleFile, $size);
298 @fclose($handleFile);
300 if (!($handleFile = @fopen($filePath.
"/".$file,
"wb")))
303 if (flock($handleFile, LOCK_EX))
308 foreach ($arReplace as $search => $replace)
310 $arSearch[] =
"#".$search.
"#";
311 $arValue[] = $replace;
316 @flock($handleFile, LOCK_UN);
318 @fclose($handleFile);
384 public static function CreateThumbnail($sourcePath, $previewPath, $maxWidth, $maxHeight)
386 if (!is_file($sourcePath))
389 $maxWidth = intval($maxWidth);
390 $maxHeight = intval($maxHeight);
392 if ($maxWidth <= 0 || $maxHeight <= 0)
395 list($sourceWidth, $sourceHeight,
$type) = @getimagesize($sourcePath);
407 $imageFunction =
"imagecreatefrom".$imageType;
408 $sourceImage = @$imageFunction($sourcePath);
413 $ratioWidth = $sourceWidth / $maxWidth;
414 $ratioHeight = $sourceHeight / $maxHeight;
415 $ratio = ($ratioWidth > $ratioHeight) ? $ratioWidth : $ratioHeight;
420 $previewWidth = $sourceWidth / $ratio;
421 $previewHeight = $sourceHeight / $ratio;
425 $previewWidth = $maxWidth;
426 $previewHeight = $maxHeight;
431 if (function_exists(
"gd_info"))
433 $arGDInfo = gd_info();
434 $bGD2 = str_contains($arGDInfo[
'GD Version'],
"2.");
440 $previewImage = imagecreatetruecolor($previewWidth, $previewHeight);
441 imagecopyresampled($previewImage, $sourceImage, 0, 0, 0, 0, $previewWidth, $previewHeight, $sourceWidth, $sourceHeight);
445 $previewImage = imagecreate($previewWidth, $previewHeight);
446 imagecopyresized($previewImage, $sourceImage, 0, 0, 0, 0, $previewWidth, $previewHeight, $sourceWidth, $sourceHeight);
450 $imageFunction =
"image".$imageType;
452 if ($imageType ==
"jpeg")
453 $success = @$imageFunction($previewImage, $previewPath, 95);
455 $success = @$imageFunction($previewImage, $previewPath);
457 @imagedestroy($previewImage);
458 @imagedestroy($sourceImage);