| Новости | FAQ | Авторы | Документация | В действии | Библиотека |
| Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
Ike 09.05.2006 21:47
Меня всегда интересовал вопрос -- как хранить данные в базе в виде xml?#это временная конструкция -- надо переделать
@print2[]
^select_pid[]
^print[$postid;index;^select_template[]]
#выводим страницу
@print[postid;xslSheet;template]
$sourceDoc[^xdoc::create{
^print_page_object[$template;$postid]
}]
$menuItems[^sourceDoc.select[/page/body/navigation/menuItem]]
^for[i](0;$menuItems-1){
$node[$menuItems.$i]
^if(^node.getAttribute[link] eq $request:uri || !def ^node.getAttribute[link]){
^node.setAttribute[state;disabled]
}{
^node.setAttribute[state;enabled]
}
}
$transformedDoc[^sourceDoc.transform[/xsl/${xslSheet}.xsl]]
^memory:compact[]
^process{^transformedDoc.string[$.method[html]]}
#выбираем id страницы в соответствии с uri
@select_pid[]
$page[^if(def $form:page){$form:page}{main}]
$selectPageContent[^table::sql{
SELECT post_id, object_type
FROM posts
WHERE post_id = (SELECT uri_id FROM uri WHERE uri_path = '$page')
}]
$objectTypes[$selectPageContent.object_type]
$postid[^if(!def $form:id){$selectPageContent.post_id}{$form:id}]
@select_template[]
#####
#ToDDo
#SELECT template FROM objects_types WHERE object_type = ...
#####
^if(($form:page eq main || !def $form:page) && $objectTypes == 1){
$result[index_page]
}{
^if($objectTypes != 1){
$result[full_page]
}{
$result[regular_page]
}
}
#вывести страницу
@print_page_object[template;sid]
$selectObjectsTo[^table::sql{
SELECT post_id, creation_date, edit_date,
version, author, header, object_type,
publication_date, end_date, is_published
FROM posts
WHERE post_id = '$sid'
}]
$postId[$sid]
$value[^hash::sql{SELECT name, text FROM contents WHERE post_id = '$sid'}]
^selectObjectsTo.menu{
$head[$selectObjectsTo.header]
$sourceDocL[^xdoc::load[/datatypes/${template}.xml]]
^process{^sourceDocL.string[$.method[html]]}
}
^memory:compact[]Код конечно плохой...