parser

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

 

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

Не лучшим способом, ниже полный код

Mizter Egoist 03.12.2015 20:41

@USE
get.p
sidebars.p
seo.p
/bulk/genus/pages/home.p
/bulk/genus/pages/section.p
/bulk/genus/pages/heading.p
/bulk/genus/pages/entry.p
/bulk/genus/pages/goody.p
/bulk/admin/control.p

@init[]
$get[^GET::init[]]
$sidebars[^sidebars::init[]]
$seo[^info::init[]]
$M[^home::init[]]
$S[^section::init[]]
$H[^heading::init[]]
$E[^entry::init[]]
$G[^goody::init[]]
$admin[^control::init[]]
$address[$request:uri]
$address[^address.match[^^/admin(.+)]]

@path[params]
^init[]
$url[$params.url]
$uri[$params.uri]
$pid[$params.pid]
$request[$params.request]
$slash[^request.split[/;lh]]
$query[^request.split[?;lh]]
#Select all
$aSections[^get.getSections[]]
$aHeadings[^get.getHeadings[]]
$aEntries[^get.getEntries[]]
$aGoods[^get.getGoods[]]
#Split
$splitEntries[^aEntries.HID.split[,;lv;heading]]
$splitGoods[^aGoods.HID.split[,;lv;heading]]
#Hash by URI
$_uaSections[^aSections.hash[url]]
$_uaHeadings[^aHeadings.hash[url]]
$_uaEntries[^aEntries.hash[link]]
$_uaGoods[^aGoods.hash[link]]
#Hash by ID
$_iaSections[^aSections.hash[id]]
$_iaHeadings[^aHeadings.hash[id]]
$_iaEntries[^aEntries.hash[PID]]
$_iaGoods[^aGoods.hash[GID]]
#Sections and Headings
^if($_uaSections.[$url]){
	$cSection[^get.getSections[$.url[$url]]]
	$sHeading[^get.getHeadings[$.section_id[$cSection.id]]]
	$_usHeading[^sHeading.hash[url]]
	$_isHeading[^sHeading.hash[id]]
}
^if($_uaHeadings.[$uri]){
	$cHeading[^get.getHeadings[
		$.section_id[$cSection.id]
		$.url[$uri]
	]]
}
#Rules
^switch(true){
	^case($_uaSections.[$url] && $_uaHeadings.[$uri] && $_uaEntries.[$pid] && $request eq '/${url}/${uri}/${pid}^if(def $query.1){?${query.1}}'){
		$cEntry[^get.getEntries[
			$.SID[$cSection.id]
			$.NOHID[0]
			$.link[$pid]
		]]
		^E.page[
			$.s_id[${cSection.id}]
			$.h_id[${cHeading.id}]
			$.e_id[${cEntry.PID}]
		]
	}
	^case($_uaSections.[$url] && $_uaHeadings.[$uri] && $_uaGoods.[$pid] && $request eq '/${url}/${uri}/${pid}^if(def $query.1){?${query.1}}'){
		$cGoody[^get.getGoods[
			...
		]]
		^G.page[
			...
		]
	}
	^case($_uaSections.[$url] && $_uaEntries.[$uri] && $request eq '/${url}/${uri}^if(def $query.1){?${query.1}}'){
		...
	}
	^case($_uaSections.[$url] && $_uaGoods.[$uri] && $request eq '/${url}/${uri}^if(def $query.1){?${query.1}}'){
		...
	}
	^case($_uaSections.[$url] && $_uaHeadings.[$uri] && $request eq '/${url}/${uri}^if(def $query.1){?${query.1}}'){
		...
	}
	^case($_uaSections.[$url] && $request eq '/${url}^if(def $query.1){?${query.1}}'){
		...
	}
	^case($_uaEntries.[$url] && $request eq '/${url}^if(def $query.1){?${query.1}}'){
		...
	}
	^case($_uaGoods.[$url] && $request eq '/${url}^if(def $query.1){?${query.1}}'){
		...
	}
	^case($get.auth.gID == 1 && $request eq "/admin${address.1}"){
		^admin.page[]
		^sidebars.rightCtrl[]
	}
	^case($request eq '/^if(def $query.1){?${query.1}}'){
		^M.page[]
	}
	^case[DEFAULT]{
		^M.p404[]
	}
}

@page_rules[]
^seo.in[
	...
]
^path[
	^if(def $form:url){$.url[$form:url]}
	^if(def $form:uri){$.uri[$form:uri]}
	^if(def $form:pid){$.pid[$form:pid]}
	$.request[$request:uri]
]