PageRenderTime 50ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/core/libs/deprecated/deprecated.php

https://bitbucket.org/gio_jgs/botica
PHP | 776 lines | 480 code | 55 blank | 241 comment | 139 complexity | 7e57161bfd3b88c0397b577a8a463a16 MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. /**
  3. * KumbiaPHP web & app Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://wiki.kumbiaphp.com/Licencia
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@kumbiaphp.com so we can send you a copy immediately.
  14. *
  15. * Helper para Tags HTML
  16. *
  17. * @category Kumbia
  18. * @package Core
  19. * @copyright Copyright (c) 2005-2009 Kumbia Team (http://www.kumbiaphp.com)
  20. * @license http://wiki.kumbiaphp.com/Licencia New BSD License
  21. */
  22. /**
  23. * Merge Two Arrays Overwriting Values $a1
  24. * from $a2
  25. *
  26. * @param array $a1
  27. * @param array $a2
  28. * @return array
  29. */
  30. function array_merge_overwrite($a1, $a2){
  31. foreach($a2 as $key2 => $value2){
  32. if(!is_array($value2)){
  33. $a1[$key2] = $value2;
  34. } else {
  35. if(!isset($a1[$key2])){
  36. $a1[$key2] = null;
  37. }
  38. if(!is_array($a1[$key2])){
  39. $a1[$key2] = $value2;
  40. } else {
  41. $a1[$key2] = array_merge_overwrite($a1[$key2], $a2[$key2]);
  42. }
  43. }
  44. }
  45. return $a1;
  46. }
  47. /**
  48. * Inserts a element into a defined position
  49. * in a array
  50. *
  51. * @param array $form
  52. * @param mixed $index
  53. * @param mixed $value
  54. * @param mixed $key
  55. */
  56. function array_insert(&$form, $index, $value, $key=null){
  57. $ret = array();
  58. $n = 0;
  59. $i = false;
  60. foreach($form as $keys => $val){
  61. if($n!=$index){
  62. $ret[$keys] = $val;
  63. } else {
  64. if(!$key){
  65. $ret[$index] = $value;
  66. $i = true;
  67. } else {
  68. $ret[$key] = $value;
  69. $i = true;
  70. }
  71. $ret[$keys] = $val;
  72. }
  73. $n++;
  74. }
  75. if(!$i){
  76. if(!$key){
  77. $ret[$index] = $value;
  78. $i = true;
  79. } else {
  80. $ret[$key] = $value;
  81. $i = true;
  82. }
  83. }
  84. $form = $ret;
  85. }
  86. /**
  87. * Insert para arrays numericos
  88. * @param $array array donde se insertara (por referencia)
  89. * @param $index indice donde se realizara la insercion
  90. * @param $value valor a insertar
  91. **/
  92. function array_num_insert(&$array, $index, $value) {
  93. $array2 = array_splice($array, $index);
  94. array_push($array, $value);
  95. $array = array_merge($array, $array2);
  96. }
  97. /**
  98. * Las siguientes funciones son utilizadas para la generaciĆ³n
  99. * de versiones escritas de numeros
  100. *
  101. * @param numeric $a
  102. * @return string
  103. */
  104. function value_num($a){
  105. if($a<=21){
  106. switch ($a){
  107. case 1: return 'UNO';
  108. case 2: return 'DOS';
  109. case 3: return 'TRES';
  110. case 4: return 'CUATRO';
  111. case 5: return 'CINCO';
  112. case 6: return 'SEIS';
  113. case 7: return 'SIETE';
  114. case 8: return 'OCHO';
  115. case 9: return 'NUEVE';
  116. case 10: return 'DIEZ';
  117. case 11: return 'ONCE';
  118. case 12: return 'DOCE';
  119. case 13: return 'TRECE';
  120. case 14: return 'CATORCE';
  121. case 15: return 'QUINCE';
  122. case 16: return 'DIECISEIS';
  123. case 17: return 'DIECISIETE';
  124. case 18: return 'DIECIOCHO';
  125. case 19: return 'DIECINUEVE';
  126. case 20: return 'VEINTE';
  127. case 21: return 'VEINTIUN';
  128. }
  129. } else {
  130. if($a<=99){
  131. if($a>=22&&$a<=29)
  132. return "VENTI".value_num($a % 10);
  133. if($a==30) return "TREINTA";
  134. if($a>=31&&$a<=39)
  135. return "TREINTA Y ".value_num($a % 10);
  136. if($a==40) $b = "CUARENTA";
  137. if($a>=41&&$a<=49)
  138. return "CUARENTA Y ".value_num($a % 10);
  139. if($a==50) return "CINCUENTA";
  140. if($a>=51&&$a<=59)
  141. return "CINCUENTA Y ".value_num($a % 10);
  142. if($a==60) return "SESENTA";
  143. if($a>=61&&$a<=69)
  144. return "SESENTA Y ".value_num($a % 10);
  145. if($a==70) return "SETENTA";
  146. if($a>=71&&$a<=79)
  147. return "SETENTA Y ".value_num($a % 10);
  148. if($a==80) return "OCHENTA";
  149. if($a>=81&&$a<=89)
  150. return "OCHENTA Y ".value_num($a % 10);
  151. if($a==90) return "NOVENTA";
  152. if($a>=91&&$a<=99)
  153. return "NOVENTA Y ".value_num($a % 10);
  154. } else {
  155. if($a==100) return "CIEN";
  156. if($a>=101&&$a<=199)
  157. return "CIENTO ".value_num($a % 100);
  158. if($a>=200&&$a<=299)
  159. return "DOSCIENTOS ".value_num($a % 100);
  160. if($a>=300&&$a<=399)
  161. return "TRECIENTOS ".value_num($a % 100);
  162. if($a>=400&&$a<=499)
  163. return "CUATROCIENTOS ".value_num($a % 100);
  164. if($a>=500&&$a<=599)
  165. return "QUINIENTOS ".value_num($a % 100);
  166. if($a>=600&&$a<=699)
  167. return "SEICIENTOS ".value_num($a % 100);
  168. if($a>=700&&$a<=799)
  169. return "SETECIENTOS ".value_num($a % 100);
  170. if($a>=800&&$a<=899)
  171. return "OCHOCIENTOS ".value_num($a % 100);
  172. if($a>=901&&$a<=999)
  173. return "NOVECIENTOS ".value_num($a % 100);
  174. }
  175. }
  176. }
  177. /**
  178. * Genera una cadena de millones
  179. *
  180. * @param numeric $a
  181. * @return string
  182. */
  183. function millones($a){
  184. $a = $a / 1000000;
  185. if($a==1)
  186. return "UN MILLON ";
  187. else
  188. return value_num($a)." MILLONES ";
  189. }
  190. /**
  191. * Genera una cadena de miles
  192. *
  193. * @param numeric $a
  194. * @return string
  195. */
  196. function miles($a){
  197. $a = $a / 1000;
  198. if($a==1)
  199. return "MIL";
  200. else
  201. return value_num($a)."MIL ";
  202. }
  203. /**
  204. * Escribe en letras un monto numerico
  205. *
  206. * @param numeric $valor
  207. * @param string $moneda
  208. * @param string $centavos
  209. * @return string
  210. */
  211. function money_letter($valor, $moneda, $centavos){
  212. $a = $valor;
  213. $p = $moneda;
  214. $c = $centavos;
  215. $val = "";
  216. $v = $a;
  217. $a = (int) $a;
  218. $d = round($v - $a, 2);
  219. if($a>=1000000){
  220. $val = millones($a - ($a % 1000000));
  221. $a = $a % 1000000;
  222. }
  223. if($a>=1000){
  224. $val.= miles($a - ($a % 1000));
  225. $a = $a % 1000;
  226. }
  227. $val.= value_num($a)." $p ";
  228. if($d){
  229. $d*=100;
  230. $val.=" CON ".value_num($d)." $c ";
  231. }
  232. return $val;
  233. }
  234. /**
  235. * Escribe un valor en bytes en forma humana
  236. *
  237. * @param integer $num
  238. * @return string
  239. */
  240. function to_human($num){
  241. if($num<1024){
  242. return $num." bytes";
  243. } else {
  244. if($num<1024*1024){
  245. return round($num/1024, 2)." kb";
  246. } else {
  247. return round($num/1024/1024, 2)." mb";
  248. }
  249. }
  250. }
  251. /**
  252. * Cameliza una cadena
  253. *
  254. * @param string $str
  255. * @return string
  256. */
  257. function camelize($str) {
  258. $str = strtr($str, '_', ' ');
  259. $str = ucwords($str);
  260. $str = str_replace(' ', '', $str);
  261. return $str;
  262. }
  263. /**
  264. * Descameliza una cadena camelizada
  265. *
  266. * @param string $s
  267. * @return string
  268. */
  269. function uncamelize($str) {
  270. return strtolower(preg_replace('/([A-Z])/', "_\\1", $str));
  271. }
  272. /**
  273. * Convierte los parametros de una funcion o metodo de parametros por nombre a un array
  274. *
  275. * @param array $params
  276. * @return array
  277. */
  278. function get_params($params){
  279. $data = array();
  280. foreach ($params as $p) {
  281. if(is_string($p) && preg_match('/^(\w+): (.*)/', $p, $match)){
  282. $data[$match[1]] = $match[2];
  283. } else {
  284. $data[] = $p;
  285. }
  286. }
  287. return $data;
  288. }
  289. /*
  290. * Recibe una cadena como: item1,item2,item3 y retorna una como: "item1","item2","item3".
  291. * @param string $lista Cadena con Items separados por comas (,).
  292. * @return string $listaEncomillada Cadena con Items encerrados en doblecomillas y separados por comas (,).
  293. */
  294. function encomillar_lista($lista){
  295. $arrItems = explode(',', $lista);
  296. $n = count($arrItems);
  297. $listaEncomillada = '';
  298. for ($i=0; $i<$n-1; $i++) {
  299. $listaEncomillada.= "\"".$arrItems[$i]."\",";
  300. }
  301. $listaEncomillada.= "\"".$arrItems[$n-1]."\"";
  302. return $listaEncomillada;
  303. }
  304. /**
  305. * Devuelve un string encerrado en comillas
  306. *
  307. * @param string $word
  308. * @return string
  309. */
  310. function comillas($word){
  311. return "'$word'";
  312. }
  313. /**
  314. * Resalta un Texto en otro Texto
  315. *
  316. * @param string $sentence
  317. * @param string $what
  318. * @return string
  319. */
  320. function highlight($sentence, $what){
  321. return str_replace($what, '<strong class="highlight">'.$what.'</strong>', $sentence);
  322. }
  323. /**
  324. * Escribe un numero usando formato numerico
  325. *
  326. * @param string $number
  327. * @return string
  328. */
  329. function money($number){
  330. $number = my_round($number);
  331. return "$&nbsp;".number_format($number, 2, ",", ".");
  332. }
  333. /**
  334. * Redondea un numero
  335. *
  336. * @param numeric $n
  337. * @param integer $d
  338. * @return string
  339. */
  340. function roundnumber($n, $d = 0) {
  341. $n = $n - 0;
  342. if ($d === NULL) $d = 2;
  343. $f = pow(10, $d);
  344. $n += pow(10, - ($d + 1));
  345. $n = round($n * $f) / $f;
  346. $n += pow(10, - ($d + 1));
  347. $n += '';
  348. if ( $d == 0 ):
  349. return substr($n, 0, strpos($n, '.'));
  350. else:
  351. return substr($n, 0, strpos($n, '.') + $d + 1);
  352. endif;
  353. }
  354. /**
  355. * Realiza un redondeo usando la funcion round de la base
  356. * de datos.
  357. *
  358. * @param numeric $number
  359. * @param integer $n
  360. * @return numeric
  361. */
  362. function my_round($number, $n=2){
  363. $number = (float) $number;
  364. $n = (int) $number;
  365. return ActiveRecord::static_select_one("round($number, $n)");
  366. }
  367. /**
  368. * Copia un directorio.
  369. *
  370. * @param string $source directorio fuente
  371. * @param string $target directorio destino
  372. */
  373. function copy_dir($source, $target) {
  374. if (is_dir($source)) {
  375. if (!is_dir($target)){
  376. @mkdir($target);
  377. }
  378. $d = dir($source);
  379. while (false !== ($entry = $d->read())) {
  380. if ($entry == '.' || $entry == '..') {
  381. continue;
  382. }
  383. $Entry = $source.'/'.$entry;
  384. if (is_dir($Entry)) {
  385. copy_dir($Entry, $target.'/'.$entry);
  386. continue;
  387. }
  388. copy($Entry, $target.'/'. $entry);
  389. }
  390. $d->close();
  391. }else {
  392. copy($source, $target);
  393. }
  394. }
  395. /**
  396. * Crea un path apartir de directorios.
  397. * @param array $dirs array de partes de la ruta
  398. * @return string
  399. */
  400. function join_path($dirs){
  401. if(!is_array($dirs)) {
  402. $dirs = func_get_args();
  403. }
  404. $n = count($dirs);
  405. $path= '';
  406. for($i=0; $i<$n; $i++) {
  407. $dir = $dirs[$i];
  408. if(!empty($dir)) {
  409. $path.=$dir;
  410. if($i<($n-1) && $dir[strlen($dir)-1]!='/') $path.='/';
  411. }
  412. }
  413. return $path;
  414. }
  415. /**
  416. * Crea un path.
  417. *
  418. * @param string $path ruta a crear
  419. * @return boolean
  420. */
  421. function mkpath($path){
  422. $path = join_path(func_get_args());
  423. if(@mkdir($path) or file_exists($path)) return true;
  424. return (mkpath(dirname($path)) and mkdir($path));
  425. }
  426. /**
  427. * Calcula la edad
  428. *
  429. * order: orden de la fecha especificada (YYYY-MM-DD, DD-MM-YYYY, ...)
  430. * bithdate: fecha de nacimiento
  431. * today: fecha de referencia para calcular la edad (por defecto la de hoy)
  432. * year: aƱo de nacimiento
  433. * month: mes de nacimiento
  434. * day: dia de nacimiento
  435. * today_year: aƱo de hoy
  436. * today_month: mes de hoy
  437. * today_day: dia de hoy
  438. * @return integer
  439. */
  440. function age(){
  441. $params = get_params(func_get_args());
  442. $error = false;
  443. $active_app = Router::get_application();
  444. if(!isset($params['order'])){
  445. if($kumbia_config = Config::read('config')){
  446. if(preg_match('/^DD[^DMY]MM[^DMY]YYYY$/', $kumbia_config->$active_app->dbdate)){
  447. $params['order'] = 'd-m-Y';
  448. } elseif(preg_match('/^DD[^DMY]YYYY[^DMY]MM$/', $kumbia_config->$active_app->dbdate)){
  449. $params['order'] = 'd-Y-m';
  450. } elseif(preg_match('/^MM[^DMY]DD[^DMY]YYYY$/', $kumbia_config->$active_app->dbdate)) {
  451. $params['order'] = 'm-d-Y';
  452. } elseif(preg_match('/^MM[^DMY]YYYY[^DMY]DD$/', $kumbia_config->$active_app->dbdate)) {
  453. $params['order'] = 'm-Y-d';
  454. } elseif(preg_match('/^YYYY[^DMY]DD[^DMY]MM$/', $kumbia_config->$active_app->dbdate)) {
  455. $params['order'] = 'Y-d-m';
  456. } else {
  457. $params['order'] = 'Y-m-d';
  458. }
  459. }
  460. }
  461. if(isset($params['month'], $params['day'], $params['year'])){
  462. $time_nac = mktime(0, 0, 0, $params['month'], $params['day'], $params['year']);
  463. } elseif(isset($params['birthdate'])) {
  464. if (preg_match( '/^([0-9]+)[^0-9]([0-9]+)[^0-9]([0-9]+)$/', $params['birthdate'], $date)) {
  465. if($params['order'] == 'd-m-Y'){
  466. if(checkdate($date[2], $date[1], $date[3])) {
  467. $time_nac = mktime(0, 0, 0, $date[2], $date[1], $date[3]);
  468. } else {
  469. $error = true;
  470. }
  471. } elseif($params['order'] == 'd-Y-m'){
  472. if(checkdate($date[3], $date[1], $date[2])) {
  473. $time_nac = mktime(0, 0, 0, $date[3], $date[1], $date[2]);
  474. } else {
  475. $error = true;
  476. }
  477. } elseif($params['order'] == 'm-d-Y') {
  478. if(checkdate($date[1], $date[2], $date[3])) {
  479. $time_nac = mktime(0, 0, 0, $date[1], $date[2], $date[3]);
  480. } else {
  481. $error = true;
  482. }
  483. } elseif($params['order'] == 'm-Y-d') {
  484. if(checkdate($date[1], $date[3], $date[2])) {
  485. $time_nac = mktime(0, 0, 0, $date[1], $date[3], $date[2]);
  486. } else {
  487. $error = true;
  488. }
  489. } elseif($params['order'] == 'Y-d-m') {
  490. if(checkdate($date[3], $date[2], $date[1])) {
  491. $time_nac = mktime(0, 0, 0, $date[3], $date[2], $date[1]);
  492. } else {
  493. $error = true;
  494. }
  495. } else {
  496. if(checkdate($date[2], $date[3], $date[1])) {
  497. $time_nac = mktime(0, 0, 0, $date[2], $date[3], $date[1]);
  498. } else {
  499. $error = true;
  500. }
  501. }
  502. } else {
  503. $error = true;
  504. }
  505. } else {
  506. $time_nac = time();
  507. }
  508. if(isset($params['today_month'], $params['today_day'], $params['today_year'])){
  509. $time = mktime(0, 0, 0, $params['today_month'], $params['today_day'], $params['today_year']);
  510. } elseif(isset($params['today'])) {
  511. if (preg_match( '/^([0-9]+)[^0-9]([0-9]+)[^0-9]([0-9]+)$/', $params['today'], $date)) {
  512. if($params['order'] == 'd-m-Y'){
  513. if(checkdate($date[2], $date[1], $date[3])) {
  514. $time = mktime(0, 0, 0, $date[2], $date[1], $date[3]);
  515. } else {
  516. $error = true;
  517. }
  518. } elseif($params['order'] == 'd-Y-m'){
  519. if(checkdate($date[3], $date[1], $date[2])) {
  520. $time = mktime(0, 0, 0, $date[3], $date[1], $date[2]);
  521. } else {
  522. $error = true;
  523. }
  524. } elseif($params['order'] == 'm-d-Y') {
  525. if(checkdate($date[1], $date[2], $date[3])) {
  526. $time = mktime(0, 0, 0, $date[1], $date[2], $date[3]);
  527. } else {
  528. $error = true;
  529. }
  530. } elseif($params['order'] == 'm-Y-d') {
  531. if(checkdate($date[1], $date[3], $date[2])) {
  532. $time = mktime(0, 0, 0, $date[1], $date[3], $date[2]);
  533. } else {
  534. $error = true;
  535. }
  536. } elseif($params['order'] == 'Y-d-m') {
  537. if(checkdate($date[3], $date[2], $date[1])) {
  538. $time = mktime(0, 0, 0, $date[3], $date[2], $date[1]);
  539. } else {
  540. $error = true;
  541. }
  542. } else {
  543. if(checkdate($date[2], $date[3], $date[1])) {
  544. $time = mktime(0, 0, 0, $date[2], $date[3], $date[1]);
  545. } else {
  546. $error = true;
  547. }
  548. }
  549. } else {
  550. $error = true;
  551. }
  552. } else {
  553. $time = time();
  554. }
  555. if(!$error){
  556. $edad = idate('Y' ,$time) - idate('Y' ,$time_nac);
  557. } else {
  558. $edad = 0;
  559. }
  560. if($edad>0){
  561. if(idate('m' ,$time) < idate('m' ,$time_nac)){
  562. $edad--;
  563. } else if(idate('m' ,$time) == idate('m' ,$time_nac)){
  564. if(idate('d' ,$time) < idate('d' ,$time_nac)){
  565. $edad--;
  566. }
  567. }
  568. } elseif($edad<0) {
  569. $edad = 0;
  570. }
  571. return $edad;
  572. }
  573. /**
  574. * Elimina un directorio.
  575. *
  576. * @param string $dir ruta de directorio a eliminar
  577. * @return boolean
  578. */
  579. function remove_dir($dir){
  580. /**
  581. Si no es una variable vacia
  582. **/
  583. $dir = join_path(func_get_args());
  584. /**
  585. Obtengo los archivos en el directorio a eliminar
  586. **/
  587. if($files = array_merge(glob(join_path($dir,'*')), glob(join_path($dir,'.*')))) {
  588. /**
  589. Elimino cada subdirectorio o archivo
  590. **/
  591. foreach($files as $file) {
  592. /**
  593. Si no son los directorios "." o ".."
  594. **/
  595. if(!preg_match("/^.*\/?[\.]{1,2}$/",$file)) {
  596. if(is_dir($file)) {
  597. remove_dir($file);
  598. } else {
  599. unlink($file);
  600. }
  601. }
  602. }
  603. }
  604. return rmdir($dir);
  605. }
  606. /**
  607. * Obtiene un array de argumentos para usar con call_user_func_array a partir del array obtenido por get_params
  608. * @param $params array array de parametros obtenido de get_params
  609. * @return array
  610. **/
  611. function get_arguments($params) {
  612. $args = array();
  613. foreach($params as $k=>$v) {
  614. if(is_numeric($k)) {
  615. array_push($args, $v);
  616. } else {
  617. array_push($args, "$k: $v");
  618. }
  619. }
  620. return $args;
  621. }
  622. /**
  623. * Coloca la primera letra en minuscula
  624. * @param s string cadena a convertir
  625. * @return string
  626. **/
  627. function lcfirst($s) {
  628. return strtolower(substr($s, 0, 1)) . substr($s, 1);
  629. }
  630. /**
  631. * Crea un objeto stdClass apartir de parametros con nombre
  632. * @return object
  633. **/
  634. function object_from_params($s='') {
  635. $params = is_array($s) ? $s : get_params(func_get_args());
  636. $obj = (object) $params;
  637. return $obj;
  638. }
  639. /**
  640. * Efectua la misma operacion que range excepto que el key es identico a val
  641. * @param mixed $start
  642. * @param mixed $end
  643. * @param int $step
  644. **/
  645. function mirror_range($start, $end, $step=1) {
  646. $args = func_get_args();
  647. $arr = call_user_func_array('range', $args);
  648. $mirror = array();
  649. foreach($arr as $v) {
  650. $mirror[$v] = $v;
  651. }
  652. return $mirror;
  653. }
  654. /**
  655. * Obtiene la extension del archivo
  656. * @param string $filename nombre del archivo
  657. * @return string
  658. **/
  659. function file_extension($filename) {
  660. $ext = strchr($filename,".");
  661. return $ext;
  662. }
  663. /**
  664. * Obtiene una url completa para la accion en el servidor
  665. * @param string $route ruta a la accion
  666. * @return string
  667. **/
  668. function get_server_url($route) {
  669. $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'https' : 'http';
  670. return "$protocol://{$_SERVER['SERVER_NAME']}".get_kumbia_url($route);
  671. }
  672. /**
  673. * Carga uno o varios helpers (soporta argumento variable)
  674. * @param string $helper nombre del helper a cargar
  675. **/
  676. function use_helper($helper) {
  677. call_user_func_array(array('view' , 'helpers'), func_get_args());
  678. }
  679. /**
  680. * Envia la salida en buffer al navegador
  681. *
  682. */
  683. function content(){
  684. View::content();
  685. }
  686. /**
  687. * Trunca un texto
  688. *
  689. * @param $text
  690. * @param $word
  691. * @param $number
  692. * @return unknown_type
  693. */
  694. function truncate($text, $word, $number=0){
  695. if($number){
  696. $word = substr($word, 0, $number);
  697. } else {
  698. $word = rtrim($word);
  699. }
  700. return $word.$text;
  701. }
  702. /**
  703. * Renderiza una vista parcial
  704. *
  705. * @param string $partial vista a renderizar
  706. * @param string $time tiempo de cache
  707. * @param array $params
  708. **/
  709. function render_partial($partial, $time=false, $params=array()) {
  710. View::partial($partial, $time, $params);
  711. }
  712. /**
  713. * Redirecciona una a accion luego de transcurrir un periodo de tiempo
  714. * @param string $action accion a ejecutar
  715. * @param float $seconds segundos a esperar
  716. * @return string
  717. **/
  718. function redirect_to($action, $seconds = 0.01){
  719. $seconds*=1000;
  720. return xhtml_tag('script', 'type: text/javascript', "content: setTimeout('window.location=\"?/$action\"', $seconds)");
  721. }