parser

Написать ответ на текущее сообщение

 

 
   команды управления поиском

Публикую как есть ....

sergei v.2 05.03.2006 15:30

в конфиг фск-едитора пишите строчку
FCKConfig.LinkBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.htm?Connector=connectors/parser/connector.html' ;
И соответст венно привожу код connectors/parser/connector.html
@USE
/classes/_admin/logon_admin.p

@auto[]
# каталог куда фск сможет что либо закачивать
$userFiles[/_user_files]

$filePermission[
	$.Image[
		$.AllowedExtensions[jpg|gif|jpeg|png]
		$.DeniedExtensions[]
	]	
	$.File[
		$.AllowedExtensions[]
		$.DeniedExtensions[phtml|php|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|dll|reg]
	]	
	$.Flash[
		$.AllowedExtensions[swf|fla]
		$.DeniedExtensions[]
	]	
	$.Media[
		$.AllowedExtensions[swf|fla|jpg|gif|jpeg|png|avi|mpg|mpeg]
		$.DeniedExtensions[]
	]
]
$resourcePath[
	$.Image[img]
	$.File[file]
	$.Flash[flash]
	$.Media[]
]


#################################3
@main[]
^connect[$CONNECT_STRING]{
# ---------------------------------------------
# Тут я закоментирал авторизацию и проверку на права!
# Кому надо можно написать свои вызовы авторизации
# ---------------------------------------------
#$ADMIN[^getUserFromCookie[]]
#$su[X]
#^if(def $ADMIN && ^access[$su]){ 

	^fileManager[]

#}{
#	сорри!!!
#}
}

#######################
@fileManager[]
$now[^date::now[]]

$resourceType[$form:Type]
$command[$form:Command]
$currentFolder[$form:CurrentFolder]
#$currentFolder[^currentFolder.trim[both;\/]]

$rp[$resourcePath.$resourceType]
$path[${userFiles}/${rp}$currentFolder]
$fileExt[$filePermission.[$resourceType].AllowedExtensions]
$deny[$filePermission.[$resourceType].DeniedExtensions]



^switch[$command]{
^case[GetFoldersAndFiles]{$xml[^getFoldersAndFiles[]]}
^case[CreateFolder]{$xml[^createFolder[$form:NewFolderName]]}
^case[GetFolders]{$xml[^getFolders[]]}
^case[FileUpload]{$xml[^fileUpload[]]}
^case[DEFAULT]{$xml[^getFoldersAndFiles[]]}
}

$response:Expires[ Mon, 26 Jul 1997 05:00:00 GMT]
$response:Last-Modified[^now.unix-timestamp[]]
$response:Cache-Control[no-store, no-cache, must-revalidate,post-check=0, pre-check=0]
^if($command ne "FileUpload"){$response:Content-Type[text/xml^; charset=windows-1251]}
$response:Pragma[no-cache]
$response:body[$xml]

$result[]


@fileUpload[]
$error[0]
^form:fields.foreach[field;value]{ 
	^if(^field.pos[NewFile]>=0){
		$name[$value.name]
		^try{
			^if(^name.match[^^.*\.($deny)^$] || (!^name.match[^^.*\.($fileExt)^$])){
#неверное расширение файла
			$error[202]	
			}{
			^value.save[binary;${path}$value.name]
			}
		}{
		$error[1000]
		$exception.handled(1)
		
		}
}
}
$result[
<script type="text/javascript">
window.parent.frames["frmUpload"].OnUploadCompleted($error, '$name')^;
</script>]



@listFiles[]
### Выводит список файлов в формате xml

$list[^file:list[$path;\.($fileExt)^$]] 
^if(def $list){
$result[<Files>
	^list.menu{$f[^file::stat[$path/$list.name]]$sz(^math:round($f.size/1024)) ^if($sz==0){$sz(1)}<File name="$list.name" size="$sz"/>}
</Files>]
}{
$result[<Files/>]
}


@listFolders[]
### Выводит список каталогов в формате xml
$list[^file:list[$path]]
^if(def $list){
$result[<Folders>
^list.menu{^if(-d "$path/$list.name"){<Folder name="$list.name"/>
}}
</Folders> ]
}{
$result[<Folders/>] 
}


@getFoldersAndFiles[]
$folders[^listFolders[]]
$files[^listFiles[]]

$result[^createXmlHeader[]
$folders
$files
^createXmlFooter[]]


@getFolders[]
$folders[^listFolders[]]
$result[^createXmlHeader[]
$folders
^createXmlFooter[]]



@createXmlHeader[]
$result[<?xml version="1.0" encoding="utf-8" ?> 
<Connector command="$command" resourceType="$resourceType" >
<CurrentFolder path="$currentFolder" url="$path" />
]

@createXmlFooter[]
$result[</Connector>]

@createFolder[newFolder]
$f[ ]
$error[<Error number="0" originalDescription="No Error" />]
^try{
^f.save[${path}${newFolder}/tmp.tmp]
}{
$exception.handled(1)
$error[<Error number="500" originalDescription="$exception.comment   ${path}${newFolder}/tmp.tmp" />]
}
^if(def $error){
$body[$error]
}{

$body[^getFolders[]]
}

$result[^createXmlHeader[] $body ^createXmlFooter[]]