| Новости | FAQ | Авторы | Документация | В действии | Библиотека |
| Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
AleXp 18.10.2005 14:45
###################################################################################################
# $Id: visualization.p,v 1.7 2005/10/18 15:52:40 asharky@opensea.ru Exp $
###################################################################################################
#
# @debugShowObject[] Визуализация объектов
# @debugShowVoid[] Визуализация пустых объектов
# @debugShowString[] Визуализация объекта класса string
# @debugShowTable[] Визуализация объекта класса table
# @debugShowImage[] Визуализация объекта класса image
# @debugShowDate[] Визуализация объекта класса date
# @debugShowFile[] Визуализация объекта класса file
# @debugShowDouble[] Визуализация объекта класса int или double
# @debugShowBool[] Визуализация объекта класса bool
# @debugShowHash[] Визуализация объекта класса hash
#
###################################################################################################
# Если есть необходимость и желание сделать данную библиотеку операторов классом, то:
#
# 1. Раскоментируйте ниже расположенные две строки
# @CLASS
# visualization
# 2. Включите в Ваш класс MAIN оператор:
# @debugShowObject[object]
# ^visualization:debugShowObject[$object]
# #end @debugShowObject[]
###################################################################################################
@debugShowObject[object]
###################################################################################################
# Визуализация объектов
#
# string
# debugShowObject[
# undefined object
# ]
#
^if(!def $object){
^if($object is "bool"){
^debugShowBool[$object]
}{
^debugShowVoid[$object]
}
}{
^if($object is date){^debugShowDate[$object]}
^if($object is file){^debugShowFile[$object]}
^if($object is image){^debugShowImage[$object]}
^if($object is bool){^debugShowBool[$object]}
^if($object is table){^debugShowTable[$object]}
^if($object is string){^debugShowString[$object]}
^if($object is int || $object is double){^debugShowDouble[$object]}
^if($object is hash){^debugShowHash[$object]}
}<br>
#end @debugShowObject[]
@debugShowString[text;shash]
###################################################################################################
# Визуализация объекта класса string
#
# string
# debugShowString[
# string text
# ]
#
$result[<strong>$text</strong>^if(!def $shash){ (string)}]
#end @debugShowString[]
@debugShowDouble[d;shash]
###################################################################################################
# Визуализация объекта класса int или double
#
# string
# debugShowDouble[
# int/double d
# ]
#
$result[<strong>$d</strong>^if(!def $shash){( (int/double))}]
#end @debugShowDouble[]
@debugShowBool[b;shash]
###################################################################################################
# Визуализация объекта класса bool
#
# string
# debugShowBool[
# bool b
# ]
#
$result[<strong>^if($b){true}{false}</strong>^if(!def $shash){ (bool)}]
#end @debugShowBool[]
@debugShowVoid[v;shash]
###################################################################################################
# Визуализация пустых объектов
#
# string
# debugShowVoid[
# void v
# ]
#
$result[^if(!def $shash){<strong>Значение не присвоено</strong> (void)}]
#end @debugShowVoid[]
@debugShowFile[f][_f]
###################################################################################################
# Визуализация объекта класса file
#
# string
# debugShowFile[
# file f
# ]
#
^try{
$_f[^file::stat[$f.name]]
$result[Файл <strong>^file:fullpath[$f.name]</strong>, размером:
$_f.size байт, создан
${_f.cdate.day}.${_f.cdate.month}.${_f.cdate.year} в
${_f.cdate.hour}ч.${_f.cdate.minute}мин, изменен:
${_f.mdate.day}.${_f.mdate.month}.${_f.mdate.year} в
${_f.mdate.hour}ч.${_f.mdate.minute}мин, последний раз обращение к
файлу производилось
${_f.adate.day}.${_f.adate.month}.${_f.adate.year} в
${_f.adate.hour}ч.${_f.adate.minute}мин. MIME-тип файла: $_f.content-type<br>
^if(${_f.content-type} eq "text/plain" || ${_f.content-type} eq "text/html"){
Первые 100 символов файла:<br>
<strong><i>^f.text.left(100)...</i></strong><br>
Последние 100 символов файла:<br>
<strong><i>...^f.text.right(100)</i></strong><br>
}
]
}{
$exception.handled(1)
$result[<font color="red"><strong>^file:fullpath[$f.name]</strong> (file) не найден!</font>]
}
#end @debugShowFile[]
@debugShowDate[d]
###################################################################################################
# Визуализация объекта класса date
#
# string
# debugShowDate[
# date d
# ]
#
$result[<strong>${d.day}.${d.month}.${d.year}, ${d.hour}час ${d.minute}мин ${d.second}сек. $d.yearday день года</strong>]
#end @debugShowDate[]
@debugShowImage[i]
###################################################################################################
# Визуализация объектов класса image
#
# string
# debugShowImage[
# image i
# ]
#
$result[^if(def $i.src){<strong>^i.html[]</strong>}{<strong>Графический объект созданный Parser3.</strong>}<br>
Высота изображения^: ${i.height}px, ширина^: ${i.width}px<br>
^if(def $i.exif){^debugShowHash[$i.exif]}{EXIF информация в файле отсутствует!<br>}]
#end @debugShowImage[]
@debugShowTable[t][_tcol;_t;_path]
###################################################################################################
# Визуализация объектов класса table
#
# string
# debugShowTable[
# table t
# ]
#
^if(^t.columns[] != ^t.flip[]){
$_path[$TEMP_DIR/^math:uid64[]]
^t.save[$_path]
$_t[^table::load[$_path]]
^file:delete[$_path]
Объект является <strong>nameless</strong> таблицей!<br>
^debugShowTable[$_t]
}{
$_tcol[^t.columns[]]
$result[<table cellSpacing="1" cellPadding="1" border="1">
<tr align="center">
^_tcol.menu{
<td><strong>$_tcol.column</strong></td>
}
</tr>
^t.menu{
<tr align="center">
^_tcol.menu{
<td>$t.[$_tcol.column]</td>
}
</tr>
}
</table>]
}
#end @debugShowTable[]
@debugShowHash[h][k;v;_sdiv]
###################################################################################################
# Визуализация объекта класса hash
#
# string
# debugShowHash[
# hash h
# ]
#
^if(!def $caller.$_sdiv){$_sdiv(0)}
^_sdiv.inc(50)
^h.foreach[k;v]{<div style="padding-left: ${_sdiv}px">
^if(!def $v){
^if($v is "bool"){
^$.$k^[^debugShowBool[$v;1]^]<br>
}{
^$.$k^[^debugShowVoid[$v;1]^]<br>
}
}{
^if($v is bool){^$.$k^[^debugShowBool[$v;1]^]}
^if($v is string){^$.$k^[^debugShowString[$v;1]^]}
^if($v is date){^$.$k^[^debugShowDate[$v]^]}
^if($v is image){^$.$k^[^debugShowImage[$v]^]}
^if($v is file){^$.$k^[^debugShowFile[$v]^]}
^if($v is table){^$.$k^[^debugShowTable[$v]^]}
^if($v is int || $v is double){^$.$k^(^debugShowDouble($v;1)^)}
^if($v is hash){
^_sdiv.inc(50)
^$.$k^[^debugShowHash[$v]^]
^_sdiv.dec(50)
}
}
</div>}
#end @debugShowHash[]