Image functions.
Constantes
Text ImgTagFunciones
Set ImgGetSet(Text htmCod)Text ImgNormalize(Text imgCod)Text ImgGetSrc(Text imgCod)Text ImgGetAlt(Text imgCod)Text ImgGetTit(Text imgCod)Text Img2Htm(Text imgSrc, Text imgAlt, Text imgTit, Text imgCla, Text imgDef)Text Img2Div(Text imgSrc, Text imgAlt, Text imgTit, Text imgLnk, Text imgLst, Text imgCla, Text imgDef)//////////////////////////////////////////////////////////////////////////////
Text ImgTag = "<img ";
//////////////////////////////////////////////////////////////////////////////
PutDescription("Tag inicial para imagenes.", ImgTag);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set ImgGetSet(Text htmCod)
//////////////////////////////////////////////////////////////////////////////
{
Text imgTxt = Compact(TxtInside2TagPlus(htmCod, ImgTag, ">"));
If(imgTxt == "", Empty,
{
Text imgRep = Replace(imgTxt, "><", ">"+Char(7)+"<");
Tokenizer(imgRep, Char(7))
})
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el conjunto de imagenes de una pieza de codigo Html.",
ImgGetSet);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text ImgNormalize(Text imgCod)
//////////////////////////////////////////////////////////////////////////////
{
Text imgCmp = Compact(imgCod);
ReplaceTable(imgCmp,
[[
[["= ", "="]],
[[" =", "="]],
[[".'", "'"]], // Elimina los puntos finales
[[Char(34), "'"]]
]])
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el codigo Html de una imagen normalizado.",
ImgNormalize);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text ImgGetSrc(Text imgCod)
//////////////////////////////////////////////////////////////////////////////
{ TxtBetween2Tag(ImgNormalize(imgCod), "src='", "'", TRUE) };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna de un codigo Html de una imagen la url de la imagen.",
ImgGetSrc);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text ImgGetAlt(Text imgCod)
//////////////////////////////////////////////////////////////////////////////
{ TxtBetween2Tag(ImgNormalize(imgCod), "alt='", "'", TRUE) };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna de un codigo Html de una imagen el texto alt de la imagen.",
ImgGetAlt);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text ImgGetTit(Text imgCod)
//////////////////////////////////////////////////////////////////////////////
{ TxtBetween2Tag(ImgNormalize(imgCod), "title='", "'", TRUE) };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna de un codigo Html de una imagen el texto title de la imagen.",
ImgGetTit);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text Img2Htm(Text imgSrc, // Image path
Text imgAlt, // Alternate text, mandatory
Text imgTit, // Image title
Text imgCla, // Image class
Text imgDef) // Para cuando no hay textos
//////////////////////////////////////////////////////////////////////////////
{
Text htmSrc = " src="+Q(imgSrc);
Text htmCla = " class="+Q(imgCla);
Text htmAlt = If(imgAlt!="", " alt="+Q(imgAlt), // Hay alt
If(imgTit!="", " alt="+Q(imgTit), // Sin alt pero si title
" alt="+Q(imgDef))); // Sin nada
Text htmTit = If(imgTit!="", " title="+Q(imgTit), // Hay title
If(imgAlt!="", " title="+Q(imgAlt), // Sin title pero si alt
" title="+Q(imgDef))); // Sin nada
Text htmImg = "\n <img" + htmSrc +
"\n " + htmCla +
"\n " + htmAlt +
"\n " + htmTit + " />";
htmImg
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el codigo Html de una imagen con sus atributos completos rellenando
aquellos que faltan.",
Img2Htm);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text Img2Div(Text imgSrc, // Image path
Text imgAlt, // Alternate text, mandatory
Text imgTit, // Image title
Text imgLnk, // Main link
Text imgLst, // List of links
Text imgCla, // Image class
Text imgDef) // Para cuando no hay textos
//////////////////////////////////////////////////////////////////////////////
{
Text htmImg = Img2Htm(imgSrc, imgAlt, imgTit, imgCla, imgDef);
Text htmTxt = Case
(
And(imgAlt != "", imgTit == ""), imgAlt,
And(imgAlt == "", imgTit != ""), imgTit,
And(imgAlt == "", imgTit == ""), imgDef,
imgAlt == imgTit, imgAlt,
TRUE, imgTit+": "+imgAlt
)+". ";
Text htmDes = "<p>"+htmTxt+imgLst+"</p>";
"\n<div class="+Q(imgCla)+">" +
"\n " + imgLnk + htmImg + "</a>" +
"\n " + htmDes +
"\n</div><div style="+Q("clear:both")+"></div>\n"
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el codigo Html de una imagen con sus atributos completos rellenando
aquellos que faltan y todo dentro de una estructura Html div.",
Img2Div);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// FILE : img.tol
// AUTHOR : http://www.asolver.com
// PURPOSE : Image functions.
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// CONSTANTS
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text ImgTag = "<img ";
//////////////////////////////////////////////////////////////////////////////
PutDescription("Tag inicial para imagenes.", ImgTag);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set ImgGetSet(Text htmCod)
//////////////////////////////////////////////////////////////////////////////
{
Text imgTxt = Compact(TxtInside2TagPlus(htmCod, ImgTag, ">"));
If(imgTxt == "", Empty,
{
Text imgRep = Replace(imgTxt, "><", ">"+Char(7)+"<");
Tokenizer(imgRep, Char(7))
})
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el conjunto de imagenes de una pieza de codigo Html.",
ImgGetSet);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text ImgNormalize(Text imgCod)
//////////////////////////////////////////////////////////////////////////////
{
Text imgCmp = Compact(imgCod);
ReplaceTable(imgCmp,
[[
[["= ", "="]],
[[" =", "="]],
[[".'", "'"]], // Elimina los puntos finales
[[Char(34), "'"]]
]])
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el codigo Html de una imagen normalizado.",
ImgNormalize);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text ImgGetSrc(Text imgCod)
//////////////////////////////////////////////////////////////////////////////
{ TxtBetween2Tag(ImgNormalize(imgCod), "src='", "'", TRUE) };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna de un codigo Html de una imagen la url de la imagen.",
ImgGetSrc);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text ImgGetAlt(Text imgCod)
//////////////////////////////////////////////////////////////////////////////
{ TxtBetween2Tag(ImgNormalize(imgCod), "alt='", "'", TRUE) };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna de un codigo Html de una imagen el texto alt de la imagen.",
ImgGetAlt);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text ImgGetTit(Text imgCod)
//////////////////////////////////////////////////////////////////////////////
{ TxtBetween2Tag(ImgNormalize(imgCod), "title='", "'", TRUE) };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna de un codigo Html de una imagen el texto title de la imagen.",
ImgGetTit);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text Img2Htm(Text imgSrc, // Image path
Text imgAlt, // Alternate text, mandatory
Text imgTit, // Image title
Text imgCla, // Image class
Text imgDef) // Para cuando no hay textos
//////////////////////////////////////////////////////////////////////////////
{
Text htmSrc = " src="+Q(imgSrc);
Text htmCla = " class="+Q(imgCla);
Text htmAlt = If(imgAlt!="", " alt="+Q(imgAlt), // Hay alt
If(imgTit!="", " alt="+Q(imgTit), // Sin alt pero si title
" alt="+Q(imgDef))); // Sin nada
Text htmTit = If(imgTit!="", " title="+Q(imgTit), // Hay title
If(imgAlt!="", " title="+Q(imgAlt), // Sin title pero si alt
" title="+Q(imgDef))); // Sin nada
Text htmImg = "\n <img" + htmSrc +
"\n " + htmCla +
"\n " + htmAlt +
"\n " + htmTit + " />";
htmImg
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el codigo Html de una imagen con sus atributos completos rellenando
aquellos que faltan.",
Img2Htm);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Text Img2Div(Text imgSrc, // Image path
Text imgAlt, // Alternate text, mandatory
Text imgTit, // Image title
Text imgLnk, // Main link
Text imgLst, // List of links
Text imgCla, // Image class
Text imgDef) // Para cuando no hay textos
//////////////////////////////////////////////////////////////////////////////
{
Text htmImg = Img2Htm(imgSrc, imgAlt, imgTit, imgCla, imgDef);
Text htmTxt = Case
(
And(imgAlt != "", imgTit == ""), imgAlt,
And(imgAlt == "", imgTit != ""), imgTit,
And(imgAlt == "", imgTit == ""), imgDef,
imgAlt == imgTit, imgAlt,
TRUE, imgTit+": "+imgAlt
)+". ";
Text htmDes = "<p>"+htmTxt+imgLst+"</p>";
"\n<div class="+Q(imgCla)+">" +
"\n " + imgLnk + htmImg + "</a>" +
"\n " + htmDes +
"\n</div><div style="+Q("clear:both")+"></div>\n"
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el codigo Html de una imagen con sus atributos completos rellenando
aquellos que faltan y todo dentro de una estructura Html div.",
Img2Div);
//////////////////////////////////////////////////////////////////////////////
iForense construye las paginas del sitio sobre informática forense Forense.Info
2015 asolver.com | Aviso legal | XHTML | Δ Θ Ξ | Creative Commons | Mapa y funciones del sitio