-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
142 lines (133 loc) · 3.31 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
function link_action($action, $params = null, $sinFormato = false, $ruta = true)
{
if ($sinFormato)
{
$amp = '&';
}
else
{
$amp = '&';
}
if ($params and is_array($params))
{
$numParams = count($params);
if ($numParams > 0)
{
$action .= '?';
$cont = 1;
foreach ($params as $nombre => $valor)
{
$action .= $nombre . '=' . $valor;
if ($cont++ < $numParams)
{
$action .= $amp;
}
}
}
}
if ($ruta)
{
return URL_APP . $action;
}
return $action;
}
function carga($action, $id = null, $params = null, $funcion = null)
{
if (!$action)
{
return false;
}
if (!$id)
{
$id = $action;
}
$action = link_action($action, $params, true);
if (!$funcion)
{
$funcion = 'null';
}
else
{
$funcion = "'$funcion'";
}
?>
<script type="text/javascript">
<!--
carga('<?php echo $action; ?>', '<?php echo $id; ?>', <?php echo $funcion; ?>);
//-->
</script>
<?php
return true;
}
function vlink($action, $params = null, $sinFormato = false)
{
$action = link_action($action, $params, $sinFormato);
echo $action;
}
function olink($action, $dest = null, $params = null, $ocultar = false, $pregunta = null, $funcion = null
, $add_html = false, $ancla = null, $clase = null, $style = null, $title = null)
{
$action = link_action($action, $params, true);
?><a href="<?php if ($pregunta) echo 'javascript:'; else echo $action; ?>"<?php if ($dest) {
?> onclick="<?php if ($pregunta) echo 'if (pregunta(\'' . formato_html($pregunta) . '\')) ';
?>carga('<?php echo $action; ?>', '<?php echo $dest; ?>', <?php
if ($funcion) echo '\'' . str_replace('"', "\'", $funcion)
. '\''; else echo 'null'; ?>, null<?php if ($ocultar) { ?>, true<?php } ?><?php
if ($add_html) { ?>, false, true<?php } ?><?php if ($ancla) { ?>, '<?php echo $ancla; ?>'<?php
} ?>); return false;"<?php } ?><?php if ($clase){echo ' class="' . $clase . '"';} ?><?php
if ($style){echo ' style="' . $style . '"';} ?><?php
if ($title){echo ' title="' . $title . '"';} ?>><?php
}
function vlinkAjax($action, $dest = null, $params = null, $ocultar = false, $funcion = null
, $add_html = false, $ancla = null)
{
$action = link_action($action, $params, true);
$html = 'javascript:carga(\'' . $action . '\', \'' . $dest . '\', \'' . $funcion . '\'';
$html .= ', null, \'' . $ocultar . '\', \'' . $add_html . '\', \'' . $ancla . '\', true);';
return $html;
}
function clink()
{
?></a><?php
}
function carga_rotativa($action, $tiempo, $id = null)
{
if (!$action)
{
return false;
}
if (!$id)
{
$id = $action;
}
?>
<script type="text/javascript">
carga_rotativa('<?php vlink($action); ?>', <?php echo $tiempo; ?>, '<?php echo $id; ?>');
</script>
<?php
}
function formato_html($texto)
{
return htmlentities($texto);
}
function formato_texto($html)
{
return html_entity_decode($html);
}
function es_letra_o_numero($caracter)
{
if ($caracter == '/')
{
return false;
}
if (ord($caracter) >= 97 and ord($caracter) <= 122)
{
return true;
}
if (ord($caracter) >= 48 and ord($caracter) <= 57)
{
return true;
}
return false;
}