示例#1
0
	public static function InspectDir(&$arSnGroups, $path, $template, $level = 0, $parent = '')
	{
		$basePath = $_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/templates/".$template."/snippets";
		if (!file_exists($basePath))
			return;

		$bpPath = $basePath.($path == "" ? "" : "/").$path;
		$handle  = @opendir($bpPath);
		if (!$level)
			$level = 0;

		if (!$parent)
			$parent = "";

		while(false !== ($file = @readdir($handle)))
		{
			if($file == "." || $file == ".." || $file == ".htaccess" || $file == ".content.php" || ($level == 0 && $file == "images"))
				continue;

			$fullPath = $bpPath."/".$file;
			if (!is_dir($fullPath))
				continue;

			$arSnGroups[] = Array
			(
				'path' => $path,
				'name' => $file,
				'level' => $level,
				'default_name' => CSnippets::GetDefaultFileName($fullPath)
			);

			$new_path = "".$path.($path == "" ? "" : "/").$file;
			CSnippets::InspectDir($arSnGroups, $new_path, $template, $level + 1,$parent);
		}
	}
示例#2
0
 function InspectDir(&$arSnGroups, $path, $template, $level = 0, $parent = '')
 {
     $io = CBXVirtualIo::GetInstance();
     $basePath = $_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/" . $template . "/snippets";
     if (!$io->DirectoryExists($basePath)) {
         return;
     }
     $bpPath = $basePath . ($path == "" ? "" : "/") . $path;
     if (!$level) {
         $level = 0;
     }
     $d = $io->GetDirectory($bpPath);
     $arChildren = $d->GetChildren();
     foreach ($arChildren as $child) {
         $file = $child->GetName();
         if ($file == ".htaccess" || $file == ".content.php" || $level == 0 && $file == "images" || !$child->IsDirectory()) {
             continue;
         }
         $filePath = $child->GetPathWithName();
         $arSnGroups[] = array('path' => $path, 'name' => $file, 'level' => $level, 'default_name' => CSnippets::GetDefaultFileName($filePath));
         $new_path = "" . $path . ($path == "" ? "" : "/") . $file;
         CSnippets::InspectDir($arSnGroups, $new_path, $template, $level + 1, $parent);
     }
 }